rockchip: rk3288: Add reset reason detection
Subsystems (3)
PATCH v2 1/1 rockchip: rk3288: Add reset reason detection
Sometimes it's helpful to know the reset reason caused in the SoC. Add reset reason detection for the RK3288 SoC.
This will set an environemt variable which represents the reset reason.
---
Changes in v2:
- Added Acked-by: Philipp Tomsich <[email protected]>
- Clear cru_glb_rst_st
- POR if cru_glb_rst_st is 0
- RST if 1st or 2nd bit is set
Can be tested with mw 0xff7601b0 0xfffffdb9
mw 0xff7601b4 0xffffeca8
--- arch/arm/mach-rockchip/rk3288-board.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
arch/arm/mach-rockchip/rk3288-board.c +35 -0
@@ -11,6 +11,7 @@#include <syscon.h> #include <asm/io.h> #include <asm/arch/clock.h> +#include <asm/arch/cru_rk3288.h> #include <asm/arch/periph.h> #include <asm/arch/pmu_rk3288.h> #include <asm/arch/qos_rk3288.h>
@@ -70,10 +71,44 @@ int rk3288_qos_init(void)return 0 ; } +static void rk3288_detect_reset_reason (void ) +{ +struct rk3288_cru *cru =rockchip_get_cru (); +if (IS_ERR (cru)) +return ; + +switch (cru->cru_glb_rst_st) { +case 0 : +setenv ("reset_reason" ,"POR" ); +break ; +case (1 <<0 ): +case (1 <<1 ): +setenv ("reset_reason" ,"RST" ); +break ; +case (1 <<2 ): +case (1 <<3 ): +setenv ("reset_reason" ,"THERMAL" ); +break ; +case (1 <<4 ): +case (1 <<5 ): +setenv ("reset_reason" ,"WDOG" ); +break ; +default : +setenv ("reset_reason" ,"unknown reset" ); + } + +/* +* Clear cru_glb_rst_st, so we can determine the last reset cause +* for following resets. +*/ +rk_clrreg (&cru->cru_glb_rst_st,0x3f ); +} +int board_late_init (void ) {setup_boot_mode ();rk3288_qos_init (); +rk3288_detect_reset_reason ();return rk_board_late_init (); }
Signature · 1 line
1.9.1
PATCH v2 1/1 rockchip: rk3288: Add reset reason detection
Quoted 3 lines · Wadim Egorov
Sometimes it's helpful to know the reset reason caused in the SoC. Add reset reason detection for the RK3288 SoC.
This will set an environemt variable which represents the reset reason.
typo: environment
Quoted 34 lines
Signed-off-by Wadim Egorov <[email protected]>Acked-by Philipp Tomsich <[email protected]>---
Changes in v2:
- Added Acked-by: Philipp Tomsich <[email protected]>
- Clearcru_glb_rst_st
- POR ifcru_glb_rst_stis 0
- RST if 1st or 2nd bit is set
Can be tested with mw0xff7601b00xfffffdb9mw 0xff7601b4 0xffffeca8---
arch/arm/mach-rockchip/rk3288-board.c| 35 +++++++++++++++++++++++++++++++++++1 file changed, 35 insertions(+)arch/arm/mach-rockchip/rk3288-board.c +3
-0@@ -11,6 +11,7 @@#include <syscon.h> #include <asm/io.h> #include <asm/arch/clock.h> +#include <asm/arch/cru_rk3288.h> #include <asm/arch/periph.h> #include <asm/arch/pmu_rk3288.h> #include <asm/arch/qos_rk3288.h> @@ -70,10 +71,44 @@ int rk3288_qos_init(void)return 0 ; } +static void rk3288_detect_reset_reason (void ) +{
arch/arm/mach-rockchip/rk3288-board.c int rk3288_qos_init(void) · line 85
Quoted 10 lines
arch/arm/mach-rockchip/rk3288-board.c +10
-0+struct rk3288_cru *cru =rockchip_get_cru (); +if (IS_ERR (cru)) +return ; + +switch (cru->cru_glb_rst_st) { +case 0 : +setenv ("reset_reason" ,"POR" ); +break ; +case (1 <<0 ): +case (1 <<1 ):
Please use symbolic constants (either 'const u32' or enum). Applies to the below ones as well.
Quoted 30 lines
arch/arm/mach-rockchip/rk3288-board.c +22
-0+setenv ("reset_reason" ,"RST" ); +break ; +case (1 <<2 ): +case (1 <<3 ): +setenv ("reset_reason" ,"THERMAL" ); +break ; +case (1 <<4 ): +case (1 <<5 ): +setenv ("reset_reason" ,"WDOG" ); +break ; +default : +setenv ("reset_reason" ,"unknown reset" ); + } + +/* +* Clear cru_glb_rst_st, so we can determine the last reset cause +* for following resets. +*/ +rk_clrreg (&cru->cru_glb_rst_st,0x3f ); +} +int board_late_init (void ) {setup_boot_mode ();rk3288_qos_init (); +rk3288_detect_reset_reason ();return rk_board_late_init (); }
PATCH v2 1/1 rockchip: rk3288: Add reset reason detection
In reply to Wadim EgorovHi,
Quoted 51 lines · Wadim Egorov
Sometimes it's helpful to know the reset reason caused in the SoC. Add reset reason detection for the RK3288 SoC.
This will set an environemt variable which represents the reset reason.Signed-off-by Wadim Egorov <[email protected]>Acked-by Philipp Tomsich <[email protected]>---
Changes in v2:
- Added Acked-by: Philipp Tomsich <[email protected]>
- Clearcru_glb_rst_st
- POR ifcru_glb_rst_stis 0
- RST if 1st or 2nd bit is set
Can be tested with mw0xff7601b00xfffffdb9mw 0xff7601b4 0xffffeca8--- arch/arm/mach-rockchip/rk3288-board.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)arch/arm/mach-rockchip/rk3288-board.c +16
-0@@ -11,6 +11,7 @@#include <syscon.h> #include <asm/io.h> #include <asm/arch/clock.h> +#include <asm/arch/cru_rk3288.h> #include <asm/arch/periph.h> #include <asm/arch/pmu_rk3288.h> #include <asm/arch/qos_rk3288.h> @@ -70,10 +71,44 @@ int rk3288_qos_init(void)return 0 ; } +static void rk3288_detect_reset_reason (void ) +{ +struct rk3288_cru *cru =rockchip_get_cru (); +if (IS_ERR (cru)) +return ; + +switch (cru->cru_glb_rst_st) { +case 0 : +setenv ("reset_reason" ,"POR" ); +break ; +case (1 <<0 ): +case (1 <<1 ): +setenv ("reset_reason" ,"RST" ); +break ; +case (1 <<2 ):
arch/arm/mach-rockchip/rk3288-board.c int rk3288_qos_init(void) · line 98
Quoted 10 lines
arch/arm/mach-rockchip/rk3288-board.c +10
-0+case (1 <<3 ): +setenv ("reset_reason" ,"THERMAL" ); +break ; +case (1 <<4 ): +case (1 <<5 ): +setenv ("reset_reason" ,"WDOG" ); +break ; +default : +setenv ("reset_reason" ,"unknown reset" ); + }
Can you factor out the setenv() and put it (once) at the end? Inside the switch() you can set a string var to POR or RST.
Quoted 17 lines
arch/arm/mach-rockchip/rk3288-board.c +9
-1+ +/* +* Clear cru_glb_rst_st, so we can determine the last reset cause +* for following resets. +*/ +rk_clrreg (&cru->cru_glb_rst_st,0x3f ); +} +int board_late_init (void ) {setup_boot_mode ();rk3288_qos_init (); +rk3288_detect_reset_reason ();return rk_board_late_init (); } --
Quoted 2 lines
1.9.1
Regards,
Simon