From f699c92b61b17fd9cf90f8cbd67759a1d787d69c Mon Sep 17 00:00:00 2001 From: Rick Adams Date: Tue, 28 Sep 2010 10:21:07 -0700 Subject: [PATCH] msm: 8x55: put reason for boot in procfs from SMEM During board initialization read the shared memory item SMEM_POWER_ON_STATUS_INFO and place it in the procfs at /proc/sys/kernel/boot_reason The data item is an integer with a bit being set to identify the reason the device was powered on. The values of this data item is defined in the document Document/arm/msm/boot.txt, the following is the data in the documentation file. power_on_status values set by the PMIC for power on event: ---------------------------------------------------------- 0x01 -- keyboard power on 0x02 -- RTC alarm 0x04 -- cable power on 0x08 -- SMPL 0x10 -- Watch Dog timeout 0x20 -- USB charger 0x40 -- Wall charger 0xFF -- error reading power_on_status value Change-Id: I59e665f92e6e29f7dfef4380314f676a2d92c94b Signed-off-by: Rick Adams --- Documentation/arm/msm/boot.txt | 23 +++++++++++++++++++++++ Documentation/sysctl/kernel.txt | 15 +++++++++++++++ arch/arm/include/asm/processor.h | 2 ++ arch/arm/kernel/setup.c | 3 +++ include/uapi/linux/sysctl.h | 1 + kernel/sysctl.c | 9 +++++++++ kernel/sysctl_binary.c | 1 + 7 files changed, 54 insertions(+) create mode 100644 Documentation/arm/msm/boot.txt diff --git a/Documentation/arm/msm/boot.txt b/Documentation/arm/msm/boot.txt new file mode 100644 index 000000000000..1a41cd532020 --- /dev/null +++ b/Documentation/arm/msm/boot.txt @@ -0,0 +1,23 @@ +Introduction +============= +The power management integrated circuit (PMIC) records the reason the +Application processor was powered on in Shared Memory. +The hardware and software used is the shared memory interface. This document +is not for the purpose of describing this interface, but to identify the +possible values for this data item. + +Description +=========== +Shared memory item (SMEM_POWER_ON_STATUS_INFO) is read to get access to +this data. The table below identifies the possible values stored. + +power_on_status values set by the PMIC for power on event: +---------------------------------------------------------- +0x01 -- keyboard power on +0x02 -- RTC alarm +0x04 -- cable power on +0x08 -- SMPL +0x10 -- Watch Dog timeout +0x20 -- USB charger +0x40 -- Wall charger +0xFF -- error reading power_on_status value diff --git a/Documentation/sysctl/kernel.txt b/Documentation/sysctl/kernel.txt index 0e4a8129e86f..9c494fecd7c6 100644 --- a/Documentation/sysctl/kernel.txt +++ b/Documentation/sysctl/kernel.txt @@ -23,6 +23,7 @@ show up in /proc/sys/kernel: - auto_msgmni - bootloader_type [ X86 only ] - bootloader_version [ X86 only ] +- boot_reason [ ARM only ] - callhome [ S390 only ] - cap_last_cap - core_pattern @@ -168,6 +169,20 @@ Documentation/x86/boot.txt for additional information. ============================================================== +boot_reason: + +ARM -- reason for device boot + +A single bit will be set in the unsigned integer value to identify the +reason the device was booted / powered on. The value will be zero if this +feature is not supported on the ARM device being booted. + +See the power-on-status field definitions in +Documentation/arm/msm/boot.txt for Qualcomm Technologies, Inc. family of +devices. + +============================================================== + callhome: Controls the kernel's callhome behavior in case of a kernel panic. diff --git a/arch/arm/include/asm/processor.h b/arch/arm/include/asm/processor.h index 1bf65b47808a..facd89e5b6eb 100644 --- a/arch/arm/include/asm/processor.h +++ b/arch/arm/include/asm/processor.h @@ -30,6 +30,8 @@ #define STACK_TOP_MAX TASK_SIZE #endif +extern unsigned int boot_reason; + struct debug_info { #ifdef CONFIG_HAVE_HW_BREAKPOINT struct perf_event *hbp[ARM_MAX_HBP_SLOTS]; diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index 4fdc55f76ab5..1a1ba186b8cc 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c @@ -116,6 +116,9 @@ EXPORT_SYMBOL(elf_hwcap2); char* (*arch_read_hardware_id)(void); EXPORT_SYMBOL(arch_read_hardware_id); +unsigned int boot_reason; +EXPORT_SYMBOL(boot_reason); + #ifdef MULTI_CPU struct processor processor __ro_after_init; #endif diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h index d71013fffaf6..0b7f89b2d8c4 100644 --- a/include/uapi/linux/sysctl.h +++ b/include/uapi/linux/sysctl.h @@ -153,6 +153,7 @@ enum KERN_NMI_WATCHDOG=75, /* int: enable/disable nmi watchdog */ KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */ KERN_PANIC_ON_WARN=77, /* int: call panic() in WARN() functions */ + KERN_BOOT_REASON=78, /* int: identify reason system was booted */ }; diff --git a/kernel/sysctl.c b/kernel/sysctl.c index c23e0b039069..0add93350428 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -1233,6 +1233,15 @@ static struct ctl_table kern_table[] = { .extra1 = &zero, .extra2 = &one, }, +#endif +#ifdef CONFIG_ARM + { + .procname = "boot_reason", + .data = &boot_reason, + .maxlen = sizeof(int), + .mode = 0444, + .proc_handler = proc_dointvec, +}, #endif { } }; diff --git a/kernel/sysctl_binary.c b/kernel/sysctl_binary.c index 07148b497451..ef7e1c0206ef 100644 --- a/kernel/sysctl_binary.c +++ b/kernel/sysctl_binary.c @@ -140,6 +140,7 @@ static const struct bin_table bin_kern_table[] = { { CTL_INT, KERN_MAX_LOCK_DEPTH, "max_lock_depth" }, { CTL_INT, KERN_PANIC_ON_NMI, "panic_on_unrecovered_nmi" }, { CTL_INT, KERN_PANIC_ON_WARN, "panic_on_warn" }, + { CTL_INT, KERN_BOOT_REASON, "boot_reason" }, {} };