From: Alif Zakuan Yuslaimi <alif.zakuan.yusla...@altera.com>

Refactor system manager initialization by searching for system manager
alias in Agilex5 device tree instead of manually passing node name to
the device model calling function

Signed-off-by: Alif Zakuan Yuslaimi <alif.zakuan.yusla...@altera.com>
---
 arch/arm/dts/socfpga_agilex5.dtsi         |  4 ++++
 arch/arm/mach-socfpga/include/mach/misc.h |  2 +-
 arch/arm/mach-socfpga/misc.c              | 16 ++++++++++++----
 arch/arm/mach-socfpga/spl_agilex5.c       |  2 +-
 board/intel/agilex5-socdk/socfpga.c       |  2 +-
 5 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/arch/arm/dts/socfpga_agilex5.dtsi 
b/arch/arm/dts/socfpga_agilex5.dtsi
index 86322d7b0ce..d6a89300761 100644
--- a/arch/arm/dts/socfpga_agilex5.dtsi
+++ b/arch/arm/dts/socfpga_agilex5.dtsi
@@ -594,4 +594,8 @@
                        };
                };
        };
+
+       aliases {
+               sysmgr = &sysmgr;
+       };
 };
diff --git a/arch/arm/mach-socfpga/include/mach/misc.h 
b/arch/arm/mach-socfpga/include/mach/misc.h
index ab46415168f..b200c877d43 100644
--- a/arch/arm/mach-socfpga/include/mach/misc.h
+++ b/arch/arm/mach-socfpga/include/mach/misc.h
@@ -52,7 +52,7 @@ bool is_periph_program_force(void);
 void set_regular_boot(unsigned int status);
 void socfpga_pl310_clear(void);
 void socfpga_get_managers_addr(void);
-void socfpga_get_sys_mgr_addr(const char *compat);
+void socfpga_get_sys_mgr_addr(void);
 int qspi_flash_software_reset(void);
 
 #endif /* _SOCFPGA_MISC_H_ */
diff --git a/arch/arm/mach-socfpga/misc.c b/arch/arm/mach-socfpga/misc.c
index 97e01140513..3089f823b20 100644
--- a/arch/arm/mach-socfpga/misc.c
+++ b/arch/arm/mach-socfpga/misc.c
@@ -11,6 +11,7 @@
 #include <hang.h>
 #include <watchdog.h>
 #include <fdtdec.h>
+#include <dm/ofnode.h>
 #include <linux/libfdt.h>
 #include <linux/printk.h>
 #include <miiphy.h>
@@ -274,17 +275,24 @@ void socfpga_get_managers_addr(void)
                hang();
 }
 
-void socfpga_get_sys_mgr_addr(const char *compat)
+void socfpga_get_sys_mgr_addr(void)
 {
        int ret;
-       struct udevice *sysmgr_dev;
+       struct udevice *dev;
+
+       ofnode node = ofnode_get_aliases_node("sysmgr");
+
+       if (!ofnode_valid(node)) {
+               printf("'sysmgr' alias not found in device tree\n");
+               hang();
+       }
 
-       ret = uclass_get_device_by_name(UCLASS_NOP, compat, &sysmgr_dev);
+       ret = uclass_get_device_by_ofnode(UCLASS_NOP, node, &dev);
        if (ret) {
                printf("Altera system manager init failed: %d\n", ret);
                hang();
        } else {
-               socfpga_sysmgr_base = (phys_addr_t)dev_read_addr(sysmgr_dev);
+               socfpga_sysmgr_base = (phys_addr_t)dev_read_addr(dev);
        }
 }
 
diff --git a/arch/arm/mach-socfpga/spl_agilex5.c 
b/arch/arm/mach-socfpga/spl_agilex5.c
index a9aad5350d2..92b9db89252 100644
--- a/arch/arm/mach-socfpga/spl_agilex5.c
+++ b/arch/arm/mach-socfpga/spl_agilex5.c
@@ -51,7 +51,7 @@ void board_init_f(ulong dummy)
        if (ret)
                hang();
 
-       socfpga_get_sys_mgr_addr("sysmgr@10d12000");
+       socfpga_get_sys_mgr_addr();
        socfpga_get_managers_addr();
 
        sysmgr_pinmux_init();
diff --git a/board/intel/agilex5-socdk/socfpga.c 
b/board/intel/agilex5-socdk/socfpga.c
index d6628cfc696..60c8704b391 100644
--- a/board/intel/agilex5-socdk/socfpga.c
+++ b/board/intel/agilex5-socdk/socfpga.c
@@ -7,6 +7,6 @@
 
 int board_early_init_f(void)
 {
-       socfpga_get_sys_mgr_addr("sysmgr@10d12000");
+       socfpga_get_sys_mgr_addr();
        return 0;
 }
-- 
2.35.3

Reply via email to