The get_reset_cause() helper only works on RK3288, RK3399, RK3568 and
RK3588 due to its dependency on rockchip_get_cru() and the glb_rst_st
field in struct rockchip_cru.

Convert to use the sysreset_get_status() helper now that the
sysreset_rockchip driver implements the get_status() ops to remove any
dependency on rockchip_get_cru() and the glb_rst_st field.

Signed-off-by: Jonas Karlman <[email protected]>
---
 arch/arm/include/asm/arch-rockchip/cru.h | 13 ------
 arch/arm/mach-rockchip/cpu-info.c        | 50 ++++++------------------
 2 files changed, 13 insertions(+), 50 deletions(-)

diff --git a/arch/arm/include/asm/arch-rockchip/cru.h 
b/arch/arm/include/asm/arch-rockchip/cru.h
index c3259b8e7cc0..b583d08a50c3 100644
--- a/arch/arm/include/asm/arch-rockchip/cru.h
+++ b/arch/arm/include/asm/arch-rockchip/cru.h
@@ -21,19 +21,6 @@
 #include <asm/arch-rockchip/cru_rk3588.h>
 #endif
 
-/* CRU_GLB_RST_ST */
-enum {
-       GLB_POR_RST,
-       FST_GLB_RST_ST          = BIT(0),
-       SND_GLB_RST_ST          = BIT(1),
-       FST_GLB_TSADC_RST_ST    = BIT(2),
-       SND_GLB_TSADC_RST_ST    = BIT(3),
-       FST_GLB_WDT_RST_ST      = BIT(4),
-       SND_GLB_WDT_RST_ST      = BIT(5),
-};
-
 #define MHz            1000000
 
-char *get_reset_cause(void);
-
 #endif /* _ROCKCHIP_CLOCK_H */
diff --git a/arch/arm/mach-rockchip/cpu-info.c 
b/arch/arm/mach-rockchip/cpu-info.c
index 14c7331e1ab2..9be523b11003 100644
--- a/arch/arm/mach-rockchip/cpu-info.c
+++ b/arch/arm/mach-rockchip/cpu-info.c
@@ -4,48 +4,24 @@
  * Author: Jagan Teki <[email protected]>
  */
 
+#include <dm.h>
 #include <env.h>
-#include <init.h>
-#include <asm/arch-rockchip/clock.h>
-#include <asm/arch-rockchip/cru.h>
-#include <asm/arch-rockchip/hardware.h>
-#include <linux/err.h>
-
-char *get_reset_cause(void)
-{
-       struct rockchip_cru *cru = rockchip_get_cru();
-       char *cause = NULL;
-
-       if (IS_ERR(cru))
-               return cause;
-
-       switch (cru->glb_rst_st) {
-       case GLB_POR_RST:
-               cause = "POR";
-               break;
-       case FST_GLB_RST_ST:
-       case SND_GLB_RST_ST:
-               cause = "RST";
-               break;
-       case FST_GLB_TSADC_RST_ST:
-       case SND_GLB_TSADC_RST_ST:
-               cause = "THERMAL";
-               break;
-       case FST_GLB_WDT_RST_ST:
-       case SND_GLB_WDT_RST_ST:
-               cause = "WDOG";
-               break;
-       default:
-               cause = "unknown reset";
-       }
-
-       return cause;
-}
+#include <sysreset.h>
 
 #if IS_ENABLED(CONFIG_DISPLAY_CPUINFO)
 int print_cpuinfo(void)
 {
-       char *cause = get_reset_cause();
+       struct udevice *sysreset_dev;
+       char cause[16];
+       int ret;
+
+       ret = uclass_get_device_by_driver(UCLASS_SYSRESET,
+                                         DM_DRIVER_GET(sysreset_rockchip),
+                                         &sysreset_dev);
+       if (!ret)
+               ret = sysreset_get_status(sysreset_dev, cause, sizeof(cause));
+       if (ret)
+               strcpy(cause, "unknown reset");
 
        printf("SoC: Rockchip %s\n", CONFIG_SYS_SOC);
        printf("Reset cause: %s\n", cause);
-- 
2.54.0

Reply via email to