]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
sysreset: Implement PSCI based reset to EDL mode for QCOM SoCs
authorVaradarajan Narayanan <varadarajan.narayanan@oss.qualcomm.com>
Wed, 21 Jan 2026 06:39:18 +0000 (12:09 +0530)
committerCasey Connolly <casey.connolly@linaro.org>
Mon, 27 Apr 2026 10:38:44 +0000 (12:38 +0200)
Implement request_arg() sysreset_op for QCOM SoCs that use
PSCI to reset to EDL (Emergency Download) mode.

Reviewed-by: Casey Connolly <casey.connolly@linaro.org>
Reviewed-by: Sumit Garg <sumit.garg@oss.qualcomm.com>
Signed-off-by: Varadarajan Narayanan <varadarajan.narayanan@oss.qualcomm.com>
Link: https://patch.msgid.link/20260121063920.1500293-4-varadarajan.narayanan@oss.qualcomm.com
[casey: add missing ARM_SMCCC depends to kconfig to fix CI allyesconfig]
Signed-off-by: Casey Connolly <casey.connolly@linaro.org>
drivers/firmware/psci.c
drivers/sysreset/Kconfig
drivers/sysreset/Makefile
drivers/sysreset/sysreset_qcom-psci.c [new file with mode: 0644]

index 2e3223e1c32a0f7cbdd13debea4cb1a090e0b3eb..b6838a244d2b2d888f8d3470c71a11299bb3d04a 100644 (file)
@@ -186,6 +186,10 @@ static int psci_bind(struct udevice *dev)
                                         NULL);
                if (ret)
                        pr_debug("PSCI System Reset was not bound.\n");
+               if (IS_ENABLED(CONFIG_SYSRESET_QCOM_PSCI) &&
+                   device_bind_driver(dev, "qcom_psci-sysreset",
+                                      "qcom_psci-sysreset", NULL))
+                       pr_debug("QCOM PSCI System Reset was not bound.\n");
        }
 
        /* From PSCI v1.0 onward we can discover services through ARM_SMCCC_FEATURE */
index f589ad154186e5aa8fead51708d15186d3123d32..90f740f51d42abe40fa025e08c70abc4b835cfb7 100644 (file)
@@ -301,6 +301,13 @@ config SYSRESET_RAA215300
        help
          Add support for the system reboot via the Renesas RAA215300 PMIC.
 
+config SYSRESET_QCOM_PSCI
+       bool "Support reset to EDL for Qualcomm SoCs via PSCI"
+       depends on ARM_SMCCC
+       help
+         Add support for the reset to EDL (Emergency Download) on Qualcomm
+         SoCs via PSCI.
+
 config SYSRESET_QCOM_PSHOLD
        bool "Support sysreset for Qualcomm SoCs via PSHOLD"
        help
index d18a5d523605d78d984ab516bd8f5aacdee3f09b..b5b99235b6ef9a91d6c5298fb5de286c0a0c198a 100644 (file)
@@ -30,6 +30,7 @@ obj-$(CONFIG_SYSRESET_RESETCTL) += sysreset_resetctl.o
 obj-$(CONFIG_$(PHASE_)SYSRESET_AT91) += sysreset_at91.o
 obj-$(CONFIG_$(PHASE_)SYSRESET_X86) += sysreset_x86.o
 obj-$(CONFIG_SYSRESET_RAA215300) += sysreset_raa215300.o
+obj-$(CONFIG_SYSRESET_QCOM_PSCI) += sysreset_qcom-psci.o
 obj-$(CONFIG_SYSRESET_QCOM_PSHOLD) += sysreset_qcom-pshold.o
 obj-$(CONFIG_TARGET_XTFPGA) += sysreset_xtfpga.o
 obj-$(CONFIG_SYSRESET_QEMU_VIRT_CTRL) += sysreset_qemu_virt_ctrl.o
diff --git a/drivers/sysreset/sysreset_qcom-psci.c b/drivers/sysreset/sysreset_qcom-psci.c
new file mode 100644 (file)
index 0000000..3627bbf
--- /dev/null
@@ -0,0 +1,45 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2017 Masahiro Yamada <yamada.masahiro@socionext.com>
+ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
+ */
+
+#include <dm.h>
+#include <sysreset.h>
+#include <asm/system.h>
+#include <linux/errno.h>
+#include <linux/psci.h>
+#include <asm/psci.h>
+
+static int qcom_psci_sysreset_get_status(struct udevice *dev, char *buf, int size)
+{
+       return -EOPNOTSUPP;
+}
+
+static int qcom_psci_sysreset_request_arg(struct udevice *dev, int argc,
+                                         char * const argv[])
+{
+       if (!strncasecmp(argv[1], "-edl", 4)) {
+               /* Supported in qcs9100, qcs8300, sc7280, qcs615 */
+               if (psci_features(ARM_PSCI_1_1_FN64_SYSTEM_RESET2) ==
+                                                       ARM_PSCI_RET_SUCCESS) {
+                       psci_system_reset2(0, 1);
+                       return -EINPROGRESS;
+               }
+               printf("PSCI SYSTEM_RESET2 not supported\n");
+       }
+
+       return -EPROTONOSUPPORT;
+}
+
+static struct sysreset_ops qcom_psci_sysreset_ops = {
+       .request_arg = qcom_psci_sysreset_request_arg,
+       .get_status = qcom_psci_sysreset_get_status,
+};
+
+U_BOOT_DRIVER(qcom_psci_sysreset) = {
+       .name = "qcom_psci-sysreset",
+       .id = UCLASS_SYSRESET,
+       .ops = &qcom_psci_sysreset_ops,
+       .flags = DM_FLAG_PRE_RELOC,
+};