[OLPC] Add poweroff function, check for ROM signature to detect board.

David Woodhouse dwmw2 at infradead.unroutableorg
Thu Nov 9 01:17:24 EST 2006


Commit:     a43965ddf74f5debdd8b6ad061519a5c69771de7
Parent:     06dd74c7aee94f41c0f67743114ee830e085ff7f
commit a43965ddf74f5debdd8b6ad061519a5c69771de7
Author:     David Woodhouse <dwmw2 at infradead.org>
AuthorDate: Thu Nov 9 14:18:15 2006 +0800
Commit:     David Woodhouse <dwmw2 at infradead.org>
CommitDate: Thu Nov 9 14:18:15 2006 +0800

    [OLPC] Add poweroff function, check for ROM signature to detect board.
    
    Signed-off-by: David Woodhouse <dwmw2 at infradead.org>
---
 arch/i386/kernel/olpc.c |   55 +++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 46 insertions(+), 9 deletions(-)

diff --git a/arch/i386/kernel/olpc.c b/arch/i386/kernel/olpc.c
index b2b1f0a..0a33579 100644
--- a/arch/i386/kernel/olpc.c
+++ b/arch/i386/kernel/olpc.c
@@ -12,7 +12,22 @@ #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/mc146818rtc.h>
 
-int olpc_dcon_present;
+
+static void olpc_power_off(void)
+{
+	printk(KERN_INFO "OLPC power off sequence...\n");
+	outb(0xff, 0x381);
+	outb(0x14, 0x382);
+	outb(0x01, 0x383);
+	outb(0xff, 0x381);
+	outb(0x14, 0x382);
+	outb(0x00, 0x383);
+}
+
+
+
+int olpc_dcon_present = -1;
+module_param(olpc_dcon_present, int, 0444);
 
 /* REV_A CMOS map:
  * bit 440;  DCON present bit
@@ -21,18 +36,40 @@ int olpc_dcon_present;
 #define OLPC_CMOS_DCON_OFFSET (440 / 8)
 #define OLPC_CMOS_DCON_MASK   0x01
 
-static int __init olpc_init(void) {
+static int __init olpc_init(void)
+{
+	unsigned char val;
+	unsigned char *romsig;
+
+	romsig = ioremap(0xffffffc0, 16);
+	if (!romsig) {
+		printk(KERN_INFO "Failed to map BIOS. Assuming not OLPC\n");
+		return 0;
+	}
+	if (strncmp(romsig, "CL1   Q", 7)) {
+		printk("Board signature doesn't match. Assuming not OLPC\n");
+		goto unmap;
+	}
+	if (strncmp(romsig+6, romsig+13, 3)) {
+		printk("OLPC BIOS signature looks invalid. Assuming not OLPC\n");
+		goto unmap;
+	}
+	printk("OLPC board with OpenFirmware: %.16s\n", romsig);
 
-  unsigned char val;
+	pm_power_off = olpc_power_off;
 
-  /* Read the DCON present bit in the CMOS and set the flag accordingly */
+	/* Read the DCON present bit in the CMOS and set the flag accordingly */
+	val = CMOS_READ(OLPC_CMOS_DCON_OFFSET);
+	if (olpc_dcon_present == -1)
+		olpc_dcon_present = (val & OLPC_CMOS_DCON_MASK);
 
-  val = CMOS_READ(OLPC_CMOS_DCON_OFFSET);
-  olpc_dcon_present = (val & OLPC_CMOS_DCON_MASK);
+	printk(KERN_INFO "CMOS DCON_PRESENT: %d\n", olpc_dcon_present);
 
-  return 0;
+ unmap:
+	iounmap(romsig);
+
+	return 0;
 }
 
 subsys_initcall(olpc_init);
-EXPORT_SYMBOL(olpc_dcon_present);
-
+EXPORT_SYMBOL_GPL(olpc_dcon_present);


More information about the Commits-kernel mailing list