From d4a6a651b1b493dfc3a4d90b39cc40878fb49b0a Mon Sep 17 00:00:00 2001 From: vcdt34 Date: Wed, 27 Oct 2010 23:23:01 -0500 Subject: [PATCH] ARM: tegra: stingray: add /proc/bootinfo Add /proc/bootinfo pseudo-file to make the power-up reason available to user-mode applications. Removed macros and superfluous code. Revised to pass checkpatch.pl gauntlet. Revised leading comments for accuracy. Remove trailing whitespaces. Recheck with checkpatch.pl Converted to seq_file interface. Change-Id: I5098a4aef645f5e346d4bdd60ced1b2beb3f68db Signed-off-by: vcdt34 --- arch/arm/mach-tegra/Makefile | 1 + arch/arm/mach-tegra/board-stingray-bootinfo.c | 76 +++++++++++++++++++ arch/arm/mach-tegra/board-stingray.c | 5 ++ arch/arm/mach-tegra/board-stingray.h | 1 + 4 files changed, 83 insertions(+) create mode 100644 arch/arm/mach-tegra/board-stingray-bootinfo.c diff --git a/arch/arm/mach-tegra/Makefile b/arch/arm/mach-tegra/Makefile index a9de7cb0b019..728c5deaf31a 100644 --- a/arch/arm/mach-tegra/Makefile +++ b/arch/arm/mach-tegra/Makefile @@ -68,3 +68,4 @@ obj-${CONFIG_MACH_STINGRAY} += board-stingray-power.o obj-${CONFIG_MACH_STINGRAY} += board-stingray-rfkill.o obj-${CONFIG_MACH_STINGRAY} += board-stingray-gps.o obj-${CONFIG_MACH_STINGRAY} += board-stingray-usbnet.o +obj-${CONFIG_MACH_STINGRAY} += board-stingray-bootinfo.o diff --git a/arch/arm/mach-tegra/board-stingray-bootinfo.c b/arch/arm/mach-tegra/board-stingray-bootinfo.c new file mode 100644 index 000000000000..55642dec3164 --- /dev/null +++ b/arch/arm/mach-tegra/board-stingray-bootinfo.c @@ -0,0 +1,76 @@ +/* + * bootinfo.c: This code provides boot information via /proc/bootinfo. + * The information currently includes: + * - the powerup reason + * - the hardware revision + * All new user-space consumers of the powerup reason should use + * the /proc/bootinfo interface; all kernel-space consumers of the + * powerup reason should use the stingray_powerup_reason interface. + * + * Copyright (C) 2009 Motorola, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Revision History: + * + * Date Author Comment + * ---------- -------- ----------- + * 30/06/2009 Motorola Initialize version + * 25/10/2010 Motorola Modified for stingray + * 30/10/2010 Motorola Converted to seq_file interface + */ + +#include +#include +#include +#include +#include +#include "board-stingray.h" + +static int bootinfo_show(struct seq_file *m, void *v) +{ + seq_printf(m, "POWERUPREASON : 0x%08x\n", + stingray_powerup_reason()); + + seq_printf(m, "BOARDREVISION : 0x%08x\n", + stingray_revision()); + + return 0; +} + +static int bootinfo_open(struct inode *inode, struct file *file) +{ + return single_open(file, bootinfo_show, NULL); +} + +static const struct file_operations bootinfo_operations = { + .open = bootinfo_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + +int __init bootinfo_init(void) +{ + struct proc_dir_entry *pe; + + pe = proc_create("bootinfo", S_IRUGO, NULL, &bootinfo_operations); + if (!pe) + return -ENOMEM; + + return 0; +} + +device_initcall(bootinfo_init); diff --git a/arch/arm/mach-tegra/board-stingray.c b/arch/arm/mach-tegra/board-stingray.c index 58e3456c1f03..03fc9a167829 100644 --- a/arch/arm/mach-tegra/board-stingray.c +++ b/arch/arm/mach-tegra/board-stingray.c @@ -720,6 +720,11 @@ static void stingray_w1_init(void) static unsigned int powerup_reason = PU_REASON_PWR_KEY_PRESS; +unsigned int stingray_powerup_reason (void) +{ + return powerup_reason; +} + static int __init parse_tag_powerup_reason(const struct tag *tag) { if (tag->hdr.size != ATAG_POWERUP_REASON_SIZE) diff --git a/arch/arm/mach-tegra/board-stingray.h b/arch/arm/mach-tegra/board-stingray.h index b1010c208f23..be6d9696819c 100644 --- a/arch/arm/mach-tegra/board-stingray.h +++ b/arch/arm/mach-tegra/board-stingray.h @@ -27,6 +27,7 @@ int stingray_sensors_init(void); int stingray_touch_init(void); int stingray_power_init(void); unsigned int stingray_revision(void); +unsigned int stingray_powerup_reason (void); void stingray_gps_init(void); /* as defined in the bootloader*/ -- 2.34.1