The rk3288_detect_reset_reason() is per-SoC operation, move
it to rk3288.c, and extend the rk_board_late_init() with
rk3288_board_late_init() to make all the board works fine
as before.

Signed-off-by: Kever Yang <kever.y...@rock-chips.com>
---

 arch/arm/mach-rockchip/rk3288-board.c         | 38 --------------
 arch/arm/mach-rockchip/rk3288/rk3288.c        | 49 +++++++++++++++++++
 .../popmetal_rk3288/popmetal-rk3288.c         |  2 +-
 board/phytec/phycore_rk3288/phycore-rk3288.c  |  2 +-
 board/rockchip/tinker_rk3288/tinker-rk3288.c  |  2 +-
 5 files changed, 52 insertions(+), 41 deletions(-)

diff --git a/arch/arm/mach-rockchip/rk3288-board.c 
b/arch/arm/mach-rockchip/rk3288-board.c
index 1c37038c99..1f33f25943 100644
--- a/arch/arm/mach-rockchip/rk3288-board.c
+++ b/arch/arm/mach-rockchip/rk3288-board.c
@@ -24,47 +24,9 @@ __weak int rk_board_late_init(void)
        return 0;
 }
 
-static void rk3288_detect_reset_reason(void)
-{
-       struct rk3288_cru *cru = rockchip_get_cru();
-       const char *reason;
-
-       if (IS_ERR(cru))
-               return;
-
-       switch (cru->cru_glb_rst_st) {
-       case GLB_POR_RST:
-               reason = "POR";
-               break;
-       case FST_GLB_RST_ST:
-       case SND_GLB_RST_ST:
-               reason = "RST";
-               break;
-       case FST_GLB_TSADC_RST_ST:
-       case SND_GLB_TSADC_RST_ST:
-               reason = "THERMAL";
-               break;
-       case FST_GLB_WDT_RST_ST:
-       case SND_GLB_WDT_RST_ST:
-               reason = "WDOG";
-               break;
-       default:
-               reason = "unknown reset";
-       }
-
-       env_set("reset_reason", reason);
-
-       /*
-        * Clear cru_glb_rst_st, so we can determine the last reset cause
-        * for following resets.
-        */
-       rk_clrreg(&cru->cru_glb_rst_st, GLB_RST_ST_MASK);
-}
-
 int board_late_init(void)
 {
        setup_boot_mode();
-       rk3288_detect_reset_reason();
 
        return rk_board_late_init();
 }
diff --git a/arch/arm/mach-rockchip/rk3288/rk3288.c 
b/arch/arm/mach-rockchip/rk3288/rk3288.c
index 98e8610691..eae05ac849 100644
--- a/arch/arm/mach-rockchip/rk3288/rk3288.c
+++ b/arch/arm/mach-rockchip/rk3288/rk3288.c
@@ -113,6 +113,55 @@ int dram_init_banksize(void)
 }
 #endif
 
+static void rk3288_detect_reset_reason(void)
+{
+       struct rk3288_cru *cru = rockchip_get_cru();
+       const char *reason;
+
+       if (IS_ERR(cru))
+               return;
+
+       switch (cru->cru_glb_rst_st) {
+       case GLB_POR_RST:
+               reason = "POR";
+               break;
+       case FST_GLB_RST_ST:
+       case SND_GLB_RST_ST:
+               reason = "RST";
+               break;
+       case FST_GLB_TSADC_RST_ST:
+       case SND_GLB_TSADC_RST_ST:
+               reason = "THERMAL";
+               break;
+       case FST_GLB_WDT_RST_ST:
+       case SND_GLB_WDT_RST_ST:
+               reason = "WDOG";
+               break;
+       default:
+               reason = "unknown reset";
+       }
+
+       env_set("reset_reason", reason);
+
+       /*
+        * Clear cru_glb_rst_st, so we can determine the last reset cause
+        * for following resets.
+        */
+       rk_clrreg(&cru->cru_glb_rst_st, GLB_RST_ST_MASK);
+}
+
+__weak int rk3288_board_late_init(void)
+{
+       return 0;
+}
+
+int rk_board_late_init(void)
+{
+       rk3288_detect_reset_reason();
+
+       return rk3288_board_late_init();
+}
+
 static int do_clock(cmd_tbl_t *cmdtp, int flag, int argc,
                       char * const argv[])
 {
diff --git a/board/chipspark/popmetal_rk3288/popmetal-rk3288.c 
b/board/chipspark/popmetal_rk3288/popmetal-rk3288.c
index 9ba1fbd0e2..47b921a748 100644
--- a/board/chipspark/popmetal_rk3288/popmetal-rk3288.c
+++ b/board/chipspark/popmetal_rk3288/popmetal-rk3288.c
@@ -8,7 +8,7 @@
 
 #define GPIO7A3_HUB_RST        227
 
-int rk_board_late_init(void)
+int rk3288_board_late_init(void)
 {
        int ret;
 
diff --git a/board/phytec/phycore_rk3288/phycore-rk3288.c 
b/board/phytec/phycore_rk3288/phycore-rk3288.c
index fbf1511978..92f3bd25f4 100644
--- a/board/phytec/phycore_rk3288/phycore-rk3288.c
+++ b/board/phytec/phycore_rk3288/phycore-rk3288.c
@@ -30,7 +30,7 @@ static int valid_rk3288_som(struct rk3288_som *som)
        return hw == som->bs;
 }
 
-int rk_board_late_init(void)
+int rk3288_board_late_init(void)
 {
        int ret;
        struct udevice *dev;
diff --git a/board/rockchip/tinker_rk3288/tinker-rk3288.c 
b/board/rockchip/tinker_rk3288/tinker-rk3288.c
index 44f13183a5..e6b018d89c 100644
--- a/board/rockchip/tinker_rk3288/tinker-rk3288.c
+++ b/board/rockchip/tinker_rk3288/tinker-rk3288.c
@@ -21,7 +21,7 @@ static int get_ethaddr_from_eeprom(u8 *addr)
        return i2c_eeprom_read(dev, 0, addr, 6);
 }
 
-int rk_board_late_init(void)
+int rk3288_board_late_init(void)
 {
        u8 ethaddr[6];
 
-- 
2.17.1

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot

Reply via email to