All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v4] rockchip: rk3288: Add reset reason detection
@ 2017-08-21 11:36 Wadim Egorov
  2017-08-21 12:01 ` [U-Boot] [U-Boot, " Philipp Tomsich
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Wadim Egorov @ 2017-08-21 11:36 UTC (permalink / raw)
  To: u-boot

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 environment variable which represents the reset reason.

Signed-off-by: Wadim Egorov <w.egorov@phytec.de>
---
Changes in v4:
- Factore out env_set()
- Use BIT/GENMASK for CRU_GLB_RST_ST register enum
---
 arch/arm/include/asm/arch-rockchip/cru_rk3288.h | 12 ++++++++
 arch/arm/mach-rockchip/rk3288-board.c           | 39 +++++++++++++++++++++++++
 2 files changed, 51 insertions(+)

diff --git a/arch/arm/include/asm/arch-rockchip/cru_rk3288.h b/arch/arm/include/asm/arch-rockchip/cru_rk3288.h
index c7e21bd..3885c05 100644
--- a/arch/arm/include/asm/arch-rockchip/cru_rk3288.h
+++ b/arch/arm/include/asm/arch-rockchip/cru_rk3288.h
@@ -220,4 +220,16 @@ enum {
 	CLKF_MASK		= 0x1fff << CLKF_SHIFT,
 };
 
+/* 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),
+	GLB_RST_ST_MASK		= GENMASK(5, 0),
+};
+
 #endif
diff --git a/arch/arm/mach-rockchip/rk3288-board.c b/arch/arm/mach-rockchip/rk3288-board.c
index 74c6cc1..278bb40 100644
--- a/arch/arm/mach-rockchip/rk3288-board.c
+++ b/arch/arm/mach-rockchip/rk3288-board.c
@@ -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,48 @@ int rk3288_qos_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_qos_init();
+	rk3288_detect_reset_reason();
 
 	return rk_board_late_init();
 }
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [U-Boot] [U-Boot, v4] rockchip: rk3288: Add reset reason detection
  2017-08-21 11:36 [U-Boot] [PATCH v4] rockchip: rk3288: Add reset reason detection Wadim Egorov
@ 2017-08-21 12:01 ` Philipp Tomsich
  2017-08-21 12:01 ` Philipp Tomsich
  2017-08-21 13:01 ` Philipp Tomsich
  2 siblings, 0 replies; 4+ messages in thread
From: Philipp Tomsich @ 2017-08-21 12:01 UTC (permalink / raw)
  To: u-boot

> 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 environment variable which represents the reset reason.
> 
> Signed-off-by: Wadim Egorov <w.egorov@phytec.de>
> ---
> Changes in v4:
> - Factore out env_set()
> - Use BIT/GENMASK for CRU_GLB_RST_ST register enum
> ---
>  arch/arm/include/asm/arch-rockchip/cru_rk3288.h | 12 ++++++++
>  arch/arm/mach-rockchip/rk3288-board.c           | 39 +++++++++++++++++++++++++
>  2 files changed, 51 insertions(+)
> 

Acked-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [U-Boot, v4] rockchip: rk3288: Add reset reason detection
  2017-08-21 11:36 [U-Boot] [PATCH v4] rockchip: rk3288: Add reset reason detection Wadim Egorov
  2017-08-21 12:01 ` [U-Boot] [U-Boot, " Philipp Tomsich
@ 2017-08-21 12:01 ` Philipp Tomsich
  2017-08-21 13:01 ` Philipp Tomsich
  2 siblings, 0 replies; 4+ messages in thread
From: Philipp Tomsich @ 2017-08-21 12:01 UTC (permalink / raw)
  To: u-boot

> 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 environment variable which represents the reset reason.
> 
> Signed-off-by: Wadim Egorov <w.egorov@phytec.de>
> ---
> Changes in v4:
> - Factore out env_set()
> - Use BIT/GENMASK for CRU_GLB_RST_ST register enum
> ---
>  arch/arm/include/asm/arch-rockchip/cru_rk3288.h | 12 ++++++++
>  arch/arm/mach-rockchip/rk3288-board.c           | 39 +++++++++++++++++++++++++
>  2 files changed, 51 insertions(+)
> 

Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [U-Boot, v4] rockchip: rk3288: Add reset reason detection
  2017-08-21 11:36 [U-Boot] [PATCH v4] rockchip: rk3288: Add reset reason detection Wadim Egorov
  2017-08-21 12:01 ` [U-Boot] [U-Boot, " Philipp Tomsich
  2017-08-21 12:01 ` Philipp Tomsich
@ 2017-08-21 13:01 ` Philipp Tomsich
  2 siblings, 0 replies; 4+ messages in thread
From: Philipp Tomsich @ 2017-08-21 13:01 UTC (permalink / raw)
  To: u-boot

> 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 environment variable which represents the reset reason.
> 
> Signed-off-by: Wadim Egorov <w.egorov@phytec.de>
> Acked-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
> Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
> ---
> Changes in v4:
> - Factore out env_set()
> - Use BIT/GENMASK for CRU_GLB_RST_ST register enum
> ---
>  arch/arm/include/asm/arch-rockchip/cru_rk3288.h | 12 ++++++++
>  arch/arm/mach-rockchip/rk3288-board.c           | 39 +++++++++++++++++++++++++
>  2 files changed, 51 insertions(+)
> 

Applied to u-boot-rockchip, thanks!

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-08-21 13:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-21 11:36 [U-Boot] [PATCH v4] rockchip: rk3288: Add reset reason detection Wadim Egorov
2017-08-21 12:01 ` [U-Boot] [U-Boot, " Philipp Tomsich
2017-08-21 12:01 ` Philipp Tomsich
2017-08-21 13:01 ` Philipp Tomsich

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.