From: Peng Fan <[email protected]>

Check the GPIO2 dts node status to determine reset it or not.
On iMX952 single SPL/U-Boot image is shared for both mx952evk
and mx952evkrpmsg SM configs. GPIO2 is assigned to M7 domain
in mx952evkrpmsg, and there is no active user of GPIO2 for
mx952evk and mx952evkrpmsg in SPL/U-Boot, so it is disabled in
DTS. Otherwise, reset GPIO2 will meet hang when working with
mx952evkrpmsg SM.

Signed-off-by: Ye Li <[email protected]>
Signed-off-by: Peng Fan <[email protected]>
---
 arch/arm/mach-imx/imx9/scmi/soc.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-imx/imx9/scmi/soc.c 
b/arch/arm/mach-imx/imx9/scmi/soc.c
index c4127349aa3..00b8693fbe0 100644
--- a/arch/arm/mach-imx/imx9/scmi/soc.c
+++ b/arch/arm/mach-imx/imx9/scmi/soc.c
@@ -14,6 +14,7 @@
 #include <asm/setup.h>
 #include <dm/uclass.h>
 #include <dm/device.h>
+#include <dm/ofnode.h>
 #include <env_internal.h>
 #include <fuse.h>
 #include <imx_thermal.h>
@@ -949,6 +950,22 @@ static void gpio_reset(ulong gpio_base)
        writel(0, gpio_base + 0x1c);
 }
 
+static int gpio_available(const char *nodes_path)
+{
+       ofnode gpio_node = ofnode_path(nodes_path);
+       const char *status;
+
+       if (!ofnode_valid(gpio_node))
+               return false;
+
+       status = ofnode_read_string(gpio_node, "status");
+
+       if (status && !strcmp(status, "disabled"))
+               return false;
+
+       return true;
+}
+
 int arch_cpu_init(void)
 {
        if (IS_ENABLED(CONFIG_SPL_BUILD)) {
@@ -964,7 +981,9 @@ int arch_cpu_init(void)
                        disable_wdog((void __iomem *)base);
                }
 
-               gpio_reset(GPIO2_BASE_ADDR);
+               if (gpio_available("/soc/gpio@43810000"))
+                       gpio_reset(GPIO2_BASE_ADDR);
+
                gpio_reset(GPIO3_BASE_ADDR);
                gpio_reset(GPIO4_BASE_ADDR);
                gpio_reset(GPIO5_BASE_ADDR);
-- 
2.34.1

Reply via email to