diff mbox

[U-Boot,19/27] omap4: Reboot mode support

Message ID 1456597155-10711-20-git-send-email-contact@paulk.fr
State Accepted
Commit faec3f984120f1bee3f193c339f15c451b6d26e1
Delegated to: Tom Rini
Headers show

Commit Message

Paul Kocialkowski Feb. 27, 2016, 6:19 p.m. UTC
Reboot mode is written to SAR memory before reboot in the form of a string.

This mechanism is supported on OMAP4 by various TI kernels.

It is up to each board to make use of this mechanism or not.

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
---
 arch/arm/cpu/armv7/omap4/boot.c        | 41 ++++++++++++++++++++++++++++++++++
 arch/arm/include/asm/arch-omap4/omap.h |  8 +++++++
 2 files changed, 49 insertions(+)

Comments

Tom Rini March 17, 2016, 1:59 a.m. UTC | #1
On Sat, Feb 27, 2016 at 07:19:07PM +0100, Paul Kocialkowski wrote:

> Reboot mode is written to SAR memory before reboot in the form of a string.
> 
> This mechanism is supported on OMAP4 by various TI kernels.
> 
> It is up to each board to make use of this mechanism or not.
> 
> Signed-off-by: Paul Kocialkowski <contact@paulk.fr>

Applied to u-boot/master, thanks!
diff mbox

Patch

diff --git a/arch/arm/cpu/armv7/omap4/boot.c b/arch/arm/cpu/armv7/omap4/boot.c
index 4b5aa77..bae49f4 100644
--- a/arch/arm/cpu/armv7/omap4/boot.c
+++ b/arch/arm/cpu/armv7/omap4/boot.c
@@ -58,3 +58,44 @@  u32 omap_sys_boot_device(void)
 
 	return boot_devices[sys_boot];
 }
+
+int omap_reboot_mode(char *mode, unsigned int length)
+{
+	unsigned int limit;
+	unsigned int i;
+
+	if (length < 2)
+		return -1;
+
+	limit = (length < OMAP_REBOOT_REASON_SIZE) ? length :
+		OMAP_REBOOT_REASON_SIZE;
+
+	for (i = 0; i < (limit - 1); i++)
+		mode[i] = readb((u8 *)(OMAP44XX_SAR_RAM_BASE +
+			OMAP_REBOOT_REASON_OFFSET + i));
+
+	mode[i] = '\0';
+
+	return 0;
+}
+
+int omap_reboot_mode_clear(void)
+{
+	writeb(0, (u8 *)(OMAP44XX_SAR_RAM_BASE + OMAP_REBOOT_REASON_OFFSET));
+
+	return 0;
+}
+
+int omap_reboot_mode_store(char *mode)
+{
+	unsigned int i;
+
+	for (i = 0; i < (OMAP_REBOOT_REASON_SIZE - 1) && mode[i] != '\0'; i++)
+		writeb(mode[i], (u8 *)(OMAP44XX_SAR_RAM_BASE +
+			OMAP_REBOOT_REASON_OFFSET + i));
+
+	writeb('\0', (u8 *)(OMAP44XX_SAR_RAM_BASE +
+		OMAP_REBOOT_REASON_OFFSET + i));
+
+	return 0;
+}
diff --git a/arch/arm/include/asm/arch-omap4/omap.h b/arch/arm/include/asm/arch-omap4/omap.h
index 4712722..5ccda6e 100644
--- a/arch/arm/include/asm/arch-omap4/omap.h
+++ b/arch/arm/include/asm/arch-omap4/omap.h
@@ -120,6 +120,10 @@  struct s32ktimer {
 /* ABB tranxdone mask */
 #define OMAP_ABB_MPU_TXDONE_MASK	(0x1 << 7)
 
+#define OMAP44XX_SAR_RAM_BASE		0x4a326000
+#define OMAP_REBOOT_REASON_OFFSET	0xA0C
+#define OMAP_REBOOT_REASON_SIZE		0x0F
+
 /* Boot parameters */
 #ifndef __ASSEMBLY__
 struct omap_boot_parameters {
@@ -129,6 +133,10 @@  struct omap_boot_parameters {
 	unsigned char reset_reason;
 	unsigned char ch_flags;
 };
+
+int omap_reboot_mode(char *mode, unsigned int length);
+int omap_reboot_mode_clear(void);
+int omap_reboot_mode_store(char *mode);
 #endif
 
 #endif