]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
sysreset: add Qualcomm PSHOLD reset driver
authorRobert Marko <robert.marko@sartura.hr>
Tue, 14 May 2024 10:15:02 +0000 (12:15 +0200)
committerCaleb Connolly <caleb.connolly@linaro.org>
Fri, 5 Jul 2024 10:04:46 +0000 (12:04 +0200)
Number of Qualcomm ARMv7 SoC-s did not use PSCI but rather used PSHOLD
(Qualcomm Power Supply Hold Reset) bit to trigger reset or poweroff.

Qualcomm IPQ40XX is one of them, so provide a simple sysreset driver based
on the upstream Linux one, it is DT compatible as well.

Signed-off-by: Robert Marko <robert.marko@sartura.hr>
Reviewed-by: Caleb Connolly <caleb.connolly@linaro.org>
Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
drivers/sysreset/Kconfig
drivers/sysreset/Makefile
drivers/sysreset/sysreset_qcom-pshold.c [new file with mode: 0644]

index b64bfadb207798796b0f9dee5c6107ffb105873b..121194e4418f48012c28fa3a4d7da174d3359f54 100644 (file)
@@ -240,6 +240,12 @@ config SYSRESET_RAA215300
        help
          Add support for the system reboot via the Renesas RAA215300 PMIC.
 
+config SYSRESET_QCOM_PSHOLD
+       bool "Support sysreset for Qualcomm SoCs via PSHOLD"
+       depends on ARCH_IPQ40XX
+       help
+         Add support for the system reboot on Qualcomm SoCs via PSHOLD.
+
 endif
 
 endmenu
index d59299aa318cd66fce4b9c1427d2213be4d0c3ed..a6a0584585c4044017435e6f40b75edd319cfa74 100644 (file)
@@ -29,4 +29,5 @@ obj-$(CONFIG_SYSRESET_RESETCTL) += sysreset_resetctl.o
 obj-$(CONFIG_$(SPL_TPL_)SYSRESET_AT91) += sysreset_at91.o
 obj-$(CONFIG_$(SPL_TPL_)SYSRESET_X86) += sysreset_x86.o
 obj-$(CONFIG_SYSRESET_RAA215300) += sysreset_raa215300.o
+obj-$(CONFIG_SYSRESET_QCOM_PSHOLD) += sysreset_qcom-pshold.o
 obj-$(CONFIG_TARGET_XTFPGA) += sysreset_xtfpga.o
diff --git a/drivers/sysreset/sysreset_qcom-pshold.c b/drivers/sysreset/sysreset_qcom-pshold.c
new file mode 100644 (file)
index 0000000..4529047
--- /dev/null
@@ -0,0 +1,55 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Qualcomm PSHOLD reset driver
+ *
+ * Copyright (c) 2024 Sartura Ltd.
+ *
+ * Author: Robert Marko <robert.marko@sartura.hr>
+ * Based on the Linux msm-poweroff driver.
+ *
+ */
+
+#include <dm.h>
+#include <sysreset.h>
+#include <asm/io.h>
+#include <linux/delay.h>
+
+struct qcom_pshold_priv {
+       phys_addr_t base;
+};
+
+static int qcom_pshold_request(struct udevice *dev, enum sysreset_t type)
+{
+       struct qcom_pshold_priv *priv = dev_get_priv(dev);
+
+       writel(0, priv->base);
+       mdelay(10000);
+
+       return 0;
+}
+
+static struct sysreset_ops qcom_pshold_ops = {
+       .request = qcom_pshold_request,
+};
+
+static int qcom_pshold_probe(struct udevice *dev)
+{
+       struct qcom_pshold_priv *priv = dev_get_priv(dev);
+
+       priv->base = dev_read_addr(dev);
+       return priv->base == FDT_ADDR_T_NONE ? -EINVAL : 0;
+}
+
+static const struct udevice_id qcom_pshold_ids[] = {
+       { .compatible = "qcom,pshold", },
+       { /* sentinel */ }
+};
+
+U_BOOT_DRIVER(qcom_pshold) = {
+       .name           = "qcom_pshold",
+       .id             = UCLASS_SYSRESET,
+       .of_match       = qcom_pshold_ids,
+       .probe          = qcom_pshold_probe,
+       .priv_auto      = sizeof(struct qcom_pshold_priv),
+       .ops            = &qcom_pshold_ops,
+};