sysreset: Support reset via Renesas RAA215300 PMIC
authorPaul Barker <paul.barker.ct@bp.renesas.com>
Tue, 27 Feb 2024 20:40:33 +0000 (20:40 +0000)
committerMarek Vasut <marek.vasut+renesas@mailbox.org>
Wed, 28 Feb 2024 17:42:27 +0000 (18:42 +0100)
This patch adds support for resetting a board via the RAA215300 PMIC.

Note that the RAA215300 documentation names the available reset types
differently to u-boot:

  * A "warm" reset via the RAA215300 PMIC will fully reset the SoC
    (CPU & GPIOs), so this corresponds to SYSRESET_COLD.

  * A "cold" reset via the RAA215300 PMIC will cycle all power supply
    rails, so this corresponds to SYSRESET_POWER.

Signed-off-by: Paul Barker <paul.barker.ct@bp.renesas.com>
Reviewed-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
drivers/sysreset/Kconfig
drivers/sysreset/Makefile
drivers/sysreset/sysreset_raa215300.c [new file with mode: 0644]

index 0e52f99..49c0787 100644 (file)
@@ -229,6 +229,12 @@ config SYSRESET_MPC83XX
        help
          Reboot support for NXP MPC83xx SoCs.
 
+config SYSRESET_RAA215300
+       bool "Support sysreset via Renesas RAA215300 PMIC"
+       depends on PMIC_RAA215300
+       help
+         Add support for the system reboot via the Renesas RAA215300 PMIC.
+
 endif
 
 endmenu
index c9f1c62..e0e7322 100644 (file)
@@ -27,4 +27,5 @@ obj-$(CONFIG_SYSRESET_WATCHDOG) += sysreset_watchdog.o
 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_TARGET_XTFPGA) += sysreset_xtfpga.o
diff --git a/drivers/sysreset/sysreset_raa215300.c b/drivers/sysreset/sysreset_raa215300.c
new file mode 100644 (file)
index 0000000..32dfcb0
--- /dev/null
@@ -0,0 +1,58 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2023 Renesas Electronics Corporation
+ */
+
+#include <dm.h>
+#include <power/pmic.h>
+#include <sysreset.h>
+
+#define RAA215300_REG_SWRESET  0x6D
+#define RAA215300_COLD_RESET   BIT(0)
+#define RAA215300_WARM_RESET   BIT(1)
+
+static int raa215300_sysreset_request(struct udevice *dev, enum sysreset_t type)
+{
+       struct udevice *pmic = dev_get_parent(dev);
+       int ret;
+       u8 val;
+
+       /*
+        * The RAA215300 documentation names the available reset types
+        * differently to u-boot:
+        *
+        *   - A "warm" reset via the RAA215300 PMIC will fully reset the SoC
+        *     (CPU & GPIOs), so this corresponds to SYSRESET_COLD.
+        *
+        *   - A "cold" reset via the RAA215300 PMIC will cycle all power supply
+        *     rails, so this corresponds to SYSRESET_POWER.
+        */
+       switch (type) {
+       case SYSRESET_COLD:
+               val = RAA215300_WARM_RESET;
+               break;
+
+       case SYSRESET_POWER:
+               val = RAA215300_COLD_RESET;
+               break;
+
+       default:
+               return -EPROTONOSUPPORT;
+       }
+
+       ret = pmic_reg_write(pmic, RAA215300_REG_SWRESET, val);
+       if (ret)
+               return ret;
+
+       return -EINPROGRESS;
+}
+
+static struct sysreset_ops raa215300_sysreset_ops = {
+       .request = raa215300_sysreset_request,
+};
+
+U_BOOT_DRIVER(raa215300_sysreset) = {
+       .name = "raa215300_sysreset",
+       .id = UCLASS_SYSRESET,
+       .ops = &raa215300_sysreset_ops,
+};