aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap2/omap4-reboot-reason.c
diff options
context:
space:
mode:
authorNishanth Menon <nm@ti.com>2011-11-22 11:10:38 -0600
committerZiyann <jaraidaniel@gmail.com>2014-10-01 12:55:12 +0200
commit99b10fe0506d97bdbb111ca8d385fecddec0ca7a (patch)
treef73a4f4795eda6e35037fed657639b41d3fea561 /arch/arm/mach-omap2/omap4-reboot-reason.c
parentbfe318e518ded1f2f6d48c19f282e859d241cdd0 (diff)
downloadkernel_samsung_tuna-99b10fe0506d97bdbb111ca8d385fecddec0ca7a.zip
kernel_samsung_tuna-99b10fe0506d97bdbb111ca8d385fecddec0ca7a.tar.gz
kernel_samsung_tuna-99b10fe0506d97bdbb111ca8d385fecddec0ca7a.tar.bz2
OMAP4+: Add ability to store reboot reason
Bootloaders need to know when their platforms do a reboot. The only memory that is retained is SAR ram accross reboots, provide ability to store the reboot reason in a standard location in the SAR memory (using the last 0xf bytes in SAR BANK1 ram). This is now populated with the string "normal" if the reboot is due to ordinary reboot commands, if the reboot reason is for other reasons, such as bootloader or recovery as is the case with Android systems, this stores the same. NOTE: bootloader should be updated accordingly. Change-Id: I32d05ef023682a1530b34315dac90fd97bed3265 Signed-off-by: Nishanth Menon <nm@ti.com> Conflicts: arch/arm/mach-omap2/Kconfig
Diffstat (limited to 'arch/arm/mach-omap2/omap4-reboot-reason.c')
-rw-r--r--arch/arm/mach-omap2/omap4-reboot-reason.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/arch/arm/mach-omap2/omap4-reboot-reason.c b/arch/arm/mach-omap2/omap4-reboot-reason.c
new file mode 100644
index 0000000..9c16bb7
--- /dev/null
+++ b/arch/arm/mach-omap2/omap4-reboot-reason.c
@@ -0,0 +1,54 @@
+/*
+ * Reboot reason special handler
+ *
+ * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
+ * Nishanth Menon
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+#include <linux/platform_device.h>
+#include <linux/reboot.h>
+#include <linux/notifier.h>
+
+#include <mach/hardware.h>
+#include <mach/omap4-common.h>
+#include "omap4-sar-layout.h"
+
+static int omap_reboot_notifier_call(struct notifier_block *this,
+ unsigned long code, void *cmd)
+{
+ void __iomem *sar_base;
+ char *reason = "normal";
+
+ sar_base = omap4_get_sar_ram_base();
+
+ if (!sar_base)
+ return notifier_from_errno(-ENOMEM);
+
+ /* Save reboot mode in scratch memory */
+ if (code == SYS_RESTART && cmd != NULL && strlen(cmd))
+ reason = cmd;
+ else if (code == SYS_POWER_OFF)
+ reason = "off";
+
+ strncpy(sar_base + OMAP_REBOOT_REASON_OFFSET,
+ reason, OMAP_REBOOT_REASON_SIZE);
+ return NOTIFY_DONE;
+}
+
+static struct notifier_block omap_reboot_notifier = {
+ .notifier_call = omap_reboot_notifier_call,
+};
+
+static int __init omap_reboot_reason_init(void)
+{
+ return register_reboot_notifier(&omap_reboot_notifier);
+}
+late_initcall(omap_reboot_reason_init);