summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilippe Langlais <philippe.langlais@linaro.org>2011-05-05 16:21:11 +0200
committerUlf Hansson <ulf.hansson@stericsson.com>2011-09-19 15:15:02 +0200
commit56e6fc7c13bd19025049f6d089ff9b9e1020f1a6 (patch)
tree1117bdd405b266ccdb2f7930e637450e8e40894b
parent8b0ffab72a5eaa13d9758099bd769c82a21bd596 (diff)
ux500: sw reset: Save SW Reset Reason before reset
Converts the reboot reason string received in SYSCALL_DEFINE4 in sys.c into a 2 bytes reset reason code. This 16 bit value is stored in the TCDM Memory at location: tcdm_base + 0xFF8. The string to code mapping structure has been added in file reboot_reasons.h and reboot_reasons.c. The code for translation has been placed in cpu.c. ST-Ericsson Linux next: Tested and reviewed with 2011-03-28 ST-Ericsson ID: 327863 ST-Ericsson FOSS-OUT ID: Trivial Change-Id: I5fe83b824c6dbe3f61a3d77671ce845e6f81d87b Signed-off-by: rickard evertsson <rickard.evertsson@stericsson.com> Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/19174 Reviewed-by: Mattias WALLIN <mattias.wallin@stericsson.com> Conflicts: arch/arm/mach-ux500/Makefile arch/arm/mach-ux500/cpu.c
-rw-r--r--arch/arm/mach-ux500/Makefile2
-rw-r--r--arch/arm/mach-ux500/cpu.c31
-rw-r--r--arch/arm/mach-ux500/include/mach/prcmu-fw-api.h4
-rw-r--r--arch/arm/mach-ux500/include/mach/reboot_reasons.h39
-rw-r--r--arch/arm/mach-ux500/include/mach/system.h4
-rw-r--r--arch/arm/mach-ux500/prcmu-db8500.c8
-rw-r--r--arch/arm/mach-ux500/reboot_reasons.c20
-rw-r--r--drivers/misc/shrm/shrm_protocol.c4
8 files changed, 104 insertions, 8 deletions
diff --git a/arch/arm/mach-ux500/Makefile b/arch/arm/mach-ux500/Makefile
index 2caed676923..36dd67fc053 100644
--- a/arch/arm/mach-ux500/Makefile
+++ b/arch/arm/mach-ux500/Makefile
@@ -4,7 +4,7 @@
obj-y := clock.o cpu.o devices.o dcache.o \
devices-common.o id.o pins.o \
- timer.o timer-mtu.o usb.o
+ timer.o timer-mtu.o usb.o reboot_reasons.o
obj-y += pm/
obj-$(CONFIG_UX500_SOC_DB5500) += cpu-db5500.o dma-db5500.o prcmu-db5500.o \
devices-db5500.o clock-db5500.o
diff --git a/arch/arm/mach-ux500/cpu.c b/arch/arm/mach-ux500/cpu.c
index d8a62845791..3d4ceed17e3 100644
--- a/arch/arm/mach-ux500/cpu.c
+++ b/arch/arm/mach-ux500/cpu.c
@@ -24,6 +24,7 @@
#include <mach/devices.h>
#include <mach/prcmu-fw-api.h>
#include <mach/prcmu-db5500.h>
+#include <mach/reboot_reasons.h>
#include "clock.h"
@@ -33,9 +34,37 @@ void __iomem *_PRCMU_BASE;
static void __iomem *l2x0_base;
#endif
+/*
+ * The reboot reason string can be 255 characters long and the memory
+ * in which we save the sw reset reason is 2 bytes. Therefore we need to
+ * convert the string into a 16 bit pattern.
+ *
+ * See file reboot_reasons.h for conversion.
+ */
+static unsigned short map_cmd_to_code(const char *cmd)
+{
+ int i;
+
+ if (cmd == NULL)
+ /* normal reboot w/o argument */
+ return SW_RESET_NO_ARGUMENT;
+
+ /* Search through reboot reason list */
+ for (i = 0; i < reboot_reasons_size; i++) {
+ if (!strcmp(reboot_reasons[i].reason, cmd))
+ return reboot_reasons[i].code;
+ }
+
+ /* No valid Reboot Reason found */
+ return SW_RESET_CRASH;
+}
+
static void ux500_restart(char mode, const char *cmd)
{
- prcmu_system_reset();
+ unsigned short reset_code;
+
+ reset_code = map_cmd_to_code(cmd);
+ prcmu_system_reset(reset_code);
mdelay(1000);
printk("Reboot via PRCMU failed -- System halted\n");
diff --git a/arch/arm/mach-ux500/include/mach/prcmu-fw-api.h b/arch/arm/mach-ux500/include/mach/prcmu-fw-api.h
index a671ed02ae5..bc7764fc1d9 100644
--- a/arch/arm/mach-ux500/include/mach/prcmu-fw-api.h
+++ b/arch/arm/mach-ux500/include/mach/prcmu-fw-api.h
@@ -277,7 +277,7 @@ int prcmu_abb_write(u8 slave, u8 reg, u8 *value, u8 size);
void prcmu_ac_wake_req(void);
void prcmu_ac_sleep_req(void);
-void prcmu_system_reset(void);
+void prcmu_system_reset(u16 reset_code);
void prcmu_modem_reset(void);
bool prcmu_is_ac_wake_requested(void);
void prcmu_enable_spi2(void);
@@ -438,7 +438,7 @@ static inline void prcmu_ac_wake_req(void) {}
static inline void prcmu_ac_sleep_req(void) {}
-static inline void prcmu_system_reset(void) {}
+static inline void prcmu_system_reset(u16 reset_code) {}
static inline void prcmu_modem_reset(void) {}
diff --git a/arch/arm/mach-ux500/include/mach/reboot_reasons.h b/arch/arm/mach-ux500/include/mach/reboot_reasons.h
new file mode 100644
index 00000000000..06a73754b56
--- /dev/null
+++ b/arch/arm/mach-ux500/include/mach/reboot_reasons.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) ST-Ericsson SA 2011
+ * Author: Rickard Evertsson <rickard.evertsson@stericsson.com>
+ * for ST-Ericsson.
+ *
+ * License terms: GNU General Public License (GPL) version 2
+ *
+ * Use this file to customize your reboot / sw reset reasons. Add, remove or
+ * modify reasons in reboot_reasons[].
+ * The reboot reasons will be saved to a secure location in TCDM memory and
+ * can be read at bootup by e.g. the bootloader.
+ */
+
+#ifndef _REBOOT_REASONS_H
+#define _REBOOT_REASONS_H
+
+/*
+ * These defines contains the codes that will be written down to a secure
+ * location before resetting. These values are just dummy values and does not,
+ * at the moment, affect anything.
+ */
+#define SW_RESET_NO_ARGUMENT 0x0
+#define SW_RESET_CRASH 0xDEAD
+#define SW_RESET_NORMAL 0xc001
+
+/*
+ * The array reboot_reasons[] is used when you want to map a string to a reboot
+ * reason code
+ */
+struct reboot_reason {
+ const char *reason;
+ unsigned short code;
+};
+
+extern struct reboot_reason reboot_reasons[];
+
+extern unsigned int reboot_reasons_size;
+
+#endif
diff --git a/arch/arm/mach-ux500/include/mach/system.h b/arch/arm/mach-ux500/include/mach/system.h
index 4fff1c94e58..ec056d9198c 100644
--- a/arch/arm/mach-ux500/include/mach/system.h
+++ b/arch/arm/mach-ux500/include/mach/system.h
@@ -9,6 +9,7 @@
#define __ASM_ARCH_SYSTEM_H
#include <mach/prcmu-fw-api.h>
+#include <mach/reboot_reasons.h>
static inline void arch_idle(void)
{
@@ -22,7 +23,8 @@ static inline void arch_idle(void)
static inline void arch_reset(char mode, const char *cmd)
{
#ifdef CONFIG_UX500_SOC_DB8500
- prcmu_system_reset();
+ /* Call the PRCMU reset API (w/o reset reason code) */
+ prcmu_system_reset(SW_RESET_NO_ARGUMENT);
#endif
}
diff --git a/arch/arm/mach-ux500/prcmu-db8500.c b/arch/arm/mach-ux500/prcmu-db8500.c
index cf13675e273..63332d4c5c7 100644
--- a/arch/arm/mach-ux500/prcmu-db8500.c
+++ b/arch/arm/mach-ux500/prcmu-db8500.c
@@ -78,6 +78,8 @@
#define PRCM_ROMCODE_P2A 0xFFD
#define PRCM_XP70_CUR_PWR_STATE 0xFFC /* 4 BYTES */
+#define PRCM_SW_RST_REASON 0xFF8 /* 2 bytes */
+
#define _PRCM_MBOX_HEADER 0xFE8 /* 16 bytes */
#define PRCM_MBOX_HEADER_REQ_MB0 (_PRCM_MBOX_HEADER + 0x0)
#define PRCM_MBOX_HEADER_REQ_MB1 (_PRCM_MBOX_HEADER + 0x1)
@@ -1677,10 +1679,12 @@ bool prcmu_is_ac_wake_requested(void)
/**
* prcmu_system_reset - System reset
*
- * Sets the APE_SOFRST register which fires interrupt to fw
+ * Saves the reset reason code and then sets the APE_SOFRST register which
+ * fires interrupt to fw
*/
-void prcmu_system_reset(void)
+void prcmu_system_reset(u16 reset_code)
{
+ writew(reset_code, (tcdm_base + PRCM_SW_RST_REASON));
writel(1, (_PRCMU_BASE + PRCM_APE_SOFTRST));
}
diff --git a/arch/arm/mach-ux500/reboot_reasons.c b/arch/arm/mach-ux500/reboot_reasons.c
new file mode 100644
index 00000000000..b625c6a615f
--- /dev/null
+++ b/arch/arm/mach-ux500/reboot_reasons.c
@@ -0,0 +1,20 @@
+/*
+ * Copyright (C) ST-Ericsson SA 2011
+ * Author: Rickard Evertsson <rickard.evertsson@stericsson.com>
+ * for ST-Ericsson.
+ *
+ * License terms: GNU General Public License (GPL) version 2
+ *
+ * Use this file to customize your reboot / sw reset reasons. Add, remove or
+ * modify reasons in reboot_reasons[].
+ */
+
+#include <linux/kernel.h>
+#include <mach/reboot_reasons.h>
+
+struct reboot_reason reboot_reasons[] = {
+ {"crash", SW_RESET_CRASH},
+ {"", SW_RESET_NORMAL}, /* Normal Boot */
+};
+
+unsigned int reboot_reasons_size = ARRAY_SIZE(reboot_reasons);
diff --git a/drivers/misc/shrm/shrm_protocol.c b/drivers/misc/shrm/shrm_protocol.c
index 6afe423d2cb..351f78ecbc2 100644
--- a/drivers/misc/shrm/shrm_protocol.c
+++ b/drivers/misc/shrm/shrm_protocol.c
@@ -19,6 +19,7 @@
#include <mach/prcmu-fw-api.h>
#include <mach/prcmu-regs.h>
#include <mach/suspend.h>
+#include <mach/reboot_reasons.h>
#define L2_HEADER_ISI 0x0
#define L2_HEADER_RPC 0x1
@@ -557,8 +558,9 @@ static void shrm_modem_reset_callback(unsigned long irq)
}
#else
dev_info(shm_dev->dev, "Modem in reset loop, doing System reset\n");
+
/* Call the PRCMU reset API */
- prcmu_system_reset();
+ prcmu_system_reset(SW_RESET_NO_ARGUMENT);
#endif
}