ARM: tegra: stingray: add /proc/bootinfo
authorvcdt34 <john.poplett@motorola.com>
Thu, 28 Oct 2010 04:23:01 +0000 (23:23 -0500)
committerColin Cross <ccross@android.com>
Tue, 2 Nov 2010 23:09:27 +0000 (16:09 -0700)
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 <john.poplett@motorola.com>
arch/arm/mach-tegra/Makefile
arch/arm/mach-tegra/board-stingray-bootinfo.c [new file with mode: 0644]
arch/arm/mach-tegra/board-stingray.c
arch/arm/mach-tegra/board-stingray.h

index a9de7cb0b019826c2ddb8493d5b14c219941499c..728c5deaf31ad67659da5834c8d6a3ba71441a12 100644 (file)
@@ -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 (file)
index 0000000..55642de
--- /dev/null
@@ -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 <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/seq_file.h>
+#include <linux/proc_fs.h>
+#include <asm/setup.h>
+#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);
index 58e3456c1f0331b0c1e3d3b9516714041ad6b33c..03fc9a167829954b0701fe3d9302f27a80d33a59 100644 (file)
@@ -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)
index b1010c208f232be36856e6643ae2a51902d09f70..be6d9696819c41fecef959a94f70ca38fc999514 100644 (file)
@@ -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*/