* [PATCH: For next 1/2] ARM: am33xx: Add a function to retrieve the reset reason
@ 2015-02-09 15:01 Wadim Egorov
2015-02-09 15:01 ` [PATCH: For next 2/2] board: phytec-som-am335x: Print last occurred " Wadim Egorov
2015-02-09 23:07 ` [PATCH: For next 1/2] ARM: am33xx: Add a function to retrieve the " Marc Kleine-Budde
0 siblings, 2 replies; 3+ messages in thread
From: Wadim Egorov @ 2015-02-09 15:01 UTC (permalink / raw)
To: barebox
This patch adds a function to retrieve the last occurred reset reason
on the AM335x.
Signed-off-by: Wadim Egorov <w.egorov@phytec.de>
---
arch/arm/mach-omap/am33xx_generic.c | 41 ++++++++++++++++++++++++
arch/arm/mach-omap/include/mach/am33xx-generic.h | 13 ++++++++
arch/arm/mach-omap/include/mach/am33xx-silicon.h | 1 +
3 files changed, 55 insertions(+)
diff --git a/arch/arm/mach-omap/am33xx_generic.c b/arch/arm/mach-omap/am33xx_generic.c
index 912138d..ceafc09 100644
--- a/arch/arm/mach-omap/am33xx_generic.c
+++ b/arch/arm/mach-omap/am33xx_generic.c
@@ -476,3 +476,44 @@ int am33xx_of_register_bootdevice(void)
return 0;
}
+
+static const char *resetreason_str[] = {
+ [AM33XX_RESET_ICEPICK] = "IcePick",
+ [AM33XX_RESET_EXTWARM] = "External warm",
+ [AM33XX_RESET_WD1] = "Watchdog1 timer",
+ [AM33XX_RESET_WD0] = "Watchdog0 timer",
+ [AM33XX_RESET_GLOBALSW] = "Global warm software",
+ [AM33XX_RESET_COLD] = "Power-on (cold)",
+ [AM33XX_RESET_UNKNOWN] = "Unknown",
+};
+
+const char *am33xx_get_reset_reason_str(void)
+{
+ return resetreason_str[am33xx_get_reset_reason()];
+}
+
+enum am33xx_resetreason am33xx_get_reset_reason(void)
+{
+ static int init;
+ static uint32_t val;
+
+ if (!init) {
+ /* save value of AM33XX_PRM_RSTST register */
+ val = readl(AM33XX_PRM_RSTST);
+ /* clear AM33XX_PRM_RSTST - must be cleared by software
+ * (warm reset insensitive) */
+ writel(val, AM33XX_PRM_RSTST);
+ init = 1;
+ }
+
+ switch (val) {
+ case (1 << 9): return AM33XX_RESET_ICEPICK;
+ case (1 << 5): return AM33XX_RESET_EXTWARM;
+ case (1 << 4): return AM33XX_RESET_WD1;
+ case (1 << 3): return AM33XX_RESET_WD0;
+ case (1 << 1): return AM33XX_RESET_GLOBALSW;
+ case (1 << 0): return AM33XX_RESET_COLD;
+ }
+
+ return AM33XX_RESET_UNKNOWN;
+}
diff --git a/arch/arm/mach-omap/include/mach/am33xx-generic.h b/arch/arm/mach-omap/include/mach/am33xx-generic.h
index 03418b0..18ca6e7 100644
--- a/arch/arm/mach-omap/include/mach/am33xx-generic.h
+++ b/arch/arm/mach-omap/include/mach/am33xx-generic.h
@@ -36,4 +36,17 @@ int am33xx_devices_init(void);
void am33xx_select_rmii2_crs_dv(void);
int am33xx_of_register_bootdevice(void);
+enum am33xx_resetreason {
+ AM33XX_RESET_ICEPICK,
+ AM33XX_RESET_EXTWARM,
+ AM33XX_RESET_WD1,
+ AM33XX_RESET_WD0,
+ AM33XX_RESET_GLOBALSW,
+ AM33XX_RESET_COLD,
+ AM33XX_RESET_UNKNOWN,
+};
+
+enum am33xx_resetreason am33xx_get_reset_reason(void);
+const char *am33xx_get_reset_reason_str(void);
+
#endif /* __MACH_AM33XX_GENERIC_H */
diff --git a/arch/arm/mach-omap/include/mach/am33xx-silicon.h b/arch/arm/mach-omap/include/mach/am33xx-silicon.h
index 4e63b43..7c209ec 100644
--- a/arch/arm/mach-omap/include/mach/am33xx-silicon.h
+++ b/arch/arm/mach-omap/include/mach/am33xx-silicon.h
@@ -68,6 +68,7 @@
#define AM33XX_PRM_RSTCTRL (AM33XX_PRM_BASE + 0x0f00)
#define AM33XX_PRM_RSTCTRL_RESET 0x1
+#define AM33XX_PRM_RSTST (AM33XX_PRM_BASE + 0x0f08)
/* CTRL */
#define AM33XX_CTRL_BASE (AM33XX_L4_WKUP_BASE + 0x210000)
--
1.9.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH: For next 2/2] board: phytec-som-am335x: Print last occurred reset reason.
2015-02-09 15:01 [PATCH: For next 1/2] ARM: am33xx: Add a function to retrieve the reset reason Wadim Egorov
@ 2015-02-09 15:01 ` Wadim Egorov
2015-02-09 23:07 ` [PATCH: For next 1/2] ARM: am33xx: Add a function to retrieve the " Marc Kleine-Budde
1 sibling, 0 replies; 3+ messages in thread
From: Wadim Egorov @ 2015-02-09 15:01 UTC (permalink / raw)
To: barebox
Print the last occurred reset reason in MLO.
Signed-off-by: Wadim Egorov <w.egorov@phytec.de>
---
arch/arm/boards/phytec-som-am335x/board.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/arch/arm/boards/phytec-som-am335x/board.c b/arch/arm/boards/phytec-som-am335x/board.c
index d084898..61ee0f9 100644
--- a/arch/arm/boards/phytec-som-am335x/board.c
+++ b/arch/arm/boards/phytec-som-am335x/board.c
@@ -96,8 +96,10 @@ static int physom_devices_init(void)
xloadslots, ARRAY_SIZE(xloadslots));
am33xx_bbu_nand_register_handler("nand", "/dev/nand0.barebox.bb");
- if (IS_ENABLED(CONFIG_SHELL_NONE))
+ if (IS_ENABLED(CONFIG_SHELL_NONE)) {
+ printf("%s reset occurred\n", am33xx_get_reset_reason_str());
return am33xx_of_register_bootdevice();
+ }
return 0;
}
--
1.9.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH: For next 1/2] ARM: am33xx: Add a function to retrieve the reset reason
2015-02-09 15:01 [PATCH: For next 1/2] ARM: am33xx: Add a function to retrieve the reset reason Wadim Egorov
2015-02-09 15:01 ` [PATCH: For next 2/2] board: phytec-som-am335x: Print last occurred " Wadim Egorov
@ 2015-02-09 23:07 ` Marc Kleine-Budde
1 sibling, 0 replies; 3+ messages in thread
From: Marc Kleine-Budde @ 2015-02-09 23:07 UTC (permalink / raw)
To: Wadim Egorov, barebox
[-- Attachment #1.1: Type: text/plain, Size: 631 bytes --]
On 02/09/2015 04:01 PM, Wadim Egorov wrote:
> This patch adds a function to retrieve the last occurred reset reason
> on the AM335x.
Please make use of the existing rest_source framework. See
reset_source.h, reset_source_set() and how the tegra code for example:
1834169f13cc tegra: pmc: add support for reset src detection
regards,
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
[-- Attachment #2: Type: text/plain, Size: 149 bytes --]
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-02-09 23:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-09 15:01 [PATCH: For next 1/2] ARM: am33xx: Add a function to retrieve the reset reason Wadim Egorov
2015-02-09 15:01 ` [PATCH: For next 2/2] board: phytec-som-am335x: Print last occurred " Wadim Egorov
2015-02-09 23:07 ` [PATCH: For next 1/2] ARM: am33xx: Add a function to retrieve the " Marc Kleine-Budde
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox