patch-2.4.0-test9 linux/drivers/acpi/ec.c

Next file: linux/drivers/acpi/events/Makefile
Previous file: linux/drivers/acpi/driver.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.0-test8/linux/drivers/acpi/ec.c linux/drivers/acpi/ec.c
@@ -1,21 +1,21 @@
 /*
- *  ec.c - Embedded controller support
+ *	ec.c - Embedded controller support
  *
- *  Copyright (C) 2000 Andrew Henroid
+ *	Copyright (C) 2000 Andrew Henroid
  *
- *  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 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.
+ *	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
+ *	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
  */
 
 #include <linux/kernel.h>
@@ -28,28 +28,28 @@
 #include "acpi.h"
 #include "driver.h"
 
-enum
-{
-	ACPI_EC_HID = 0x090cd041,
-};
+#define _COMPONENT	OS_DEPENDENT
+	MODULE_NAME	("ec")
+
+#define ACPI_EC_HID	"PNP0A09"
 
 enum
 {
-        ACPI_EC_SMI = 0x40,
-        ACPI_EC_SCI = 0x20,
-        ACPI_EC_BURST = 0x10,
-        ACPI_EC_CMD = 0x08,
-        ACPI_EC_IBF = 0x02,
-        ACPI_EC_OBF = 0x01
+	ACPI_EC_SMI = 0x40,
+	ACPI_EC_SCI = 0x20,
+	ACPI_EC_BURST = 0x10,
+	ACPI_EC_CMD = 0x08,
+	ACPI_EC_IBF = 0x02,
+	ACPI_EC_OBF = 0x01
 };
 
 enum
 {
-        ACPI_EC_READ = 0x80,
-        ACPI_EC_WRITE = 0x81,
-        ACPI_EC_BURST_ENABLE = 0x82,
-        ACPI_EC_BURST_DISABLE = 0x83,
-        ACPI_EC_QUERY = 0x84,
+	ACPI_EC_READ = 0x80,
+	ACPI_EC_WRITE = 0x81,
+	ACPI_EC_BURST_ENABLE = 0x82,
+	ACPI_EC_BURST_DISABLE = 0x83,
+	ACPI_EC_QUERY = 0x84,
 };
 
 
@@ -74,9 +74,9 @@
 static void
 acpi_ec_wait_control(void)
 {
-        udelay(1);
-        while(inb(acpi_ec_status) & ACPI_EC_IBF)
-                udelay(10);
+		udelay(1);
+		while(inb(acpi_ec_status) & ACPI_EC_IBF)
+				udelay(10);
 }
 
 /*
@@ -88,12 +88,12 @@
 	if (!acpi_ec_data || !acpi_ec_status)
 		return -1;
 
-        outb(ACPI_EC_READ, acpi_ec_status);
-        acpi_ec_wait_control();
-        outb(addr, acpi_ec_data);
-        acpi_ec_wait_control();
-        interruptible_sleep_on(&acpi_ec_wait);
-        *value = inb(acpi_ec_data);
+		outb(ACPI_EC_READ, acpi_ec_status);
+		acpi_ec_wait_control();
+		outb(addr, acpi_ec_data);
+		acpi_ec_wait_control();
+		interruptible_sleep_on(&acpi_ec_wait);
+		*value = inb(acpi_ec_data);
 
 	return 0;
 }
@@ -107,33 +107,32 @@
 	if (!acpi_ec_data || !acpi_ec_status)
 		return -1;
 
-        outb(ACPI_EC_WRITE, acpi_ec_status);
-        acpi_ec_wait_control();
-        outb(addr, acpi_ec_data);
-        acpi_ec_wait_control();
-        outb(value, acpi_ec_data);
-        acpi_ec_wait_control();
-        interruptible_sleep_on(&acpi_ec_wait);
+		outb(ACPI_EC_WRITE, acpi_ec_status);
+		acpi_ec_wait_control();
+		outb(addr, acpi_ec_data);
+		acpi_ec_wait_control();
+		outb(value, acpi_ec_data);
+		acpi_ec_wait_control();
+		interruptible_sleep_on(&acpi_ec_wait);
 
 	return 0;
 }
 
 /*
- * Get processor information
+ * Get Embedded Controller information
  */
 static ACPI_STATUS
 acpi_find_ec(ACPI_HANDLE handle, u32 level, void *ctx, void **value)
 {
-	ACPI_BUFFER buf;
+	ACPI_DEVICE_INFO dev_info;
 	ACPI_OBJECT obj;
+	ACPI_BUFFER buf;
 	RESOURCE *res;
 	int gpe;
 
-	buf.length = sizeof(obj);
-	buf.pointer = &obj;
-	if (!ACPI_SUCCESS(acpi_evaluate_object(handle, "_HID", NULL, &buf))
-	    || obj.type != ACPI_TYPE_NUMBER
-	    || obj.number.value != ACPI_EC_HID)
+	if (!ACPI_SUCCESS(acpi_get_object_info(handle, &dev_info))
+		|| !(dev_info.valid & ACPI_VALID_HID)
+		|| 0 != STRCMP(dev_info.hardware_id, ACPI_EC_HID))
 		return AE_OK;
 
 	buf.length = 0;
@@ -160,20 +159,23 @@
 	buf.length = sizeof(obj);
 	buf.pointer = &obj;
 	if (!ACPI_SUCCESS(acpi_evaluate_object(handle, "_GPE", NULL, &buf))
-	    || obj.type != ACPI_TYPE_NUMBER)
+		|| obj.type != ACPI_TYPE_NUMBER)
 		return AE_OK;
 	gpe = (int) obj.number.value;
 
 	printk(KERN_INFO "ACPI: found EC @ (0x%02x,0x%02x,%d)\n",
-	       acpi_ec_data, acpi_ec_status, gpe);
+		   acpi_ec_data, acpi_ec_status, gpe);
 
 	if (!ACPI_SUCCESS(acpi_install_gpe_handler(
 		gpe,
 		(ACPI_EVENT_LEVEL_TRIGGERED
 		 | ACPI_EVENT_EDGE_TRIGGERED),
 		acpi_ec_gpe,
-		NULL)))
+		NULL))) {
+		
+		DEBUG_PRINT(ACPI_ERROR, ("Could not install GPE handler for EC.\n"));
 		return AE_OK;
+	}
 	
 	return AE_OK;
 }
@@ -182,10 +184,10 @@
 acpi_ec_init(void)
 {
 	acpi_walk_namespace(ACPI_TYPE_DEVICE,
-			    ACPI_ROOT_OBJECT,
-			    ACPI_INT32_MAX,
-			    acpi_find_ec,
-			    NULL,
-			    NULL);
+				ACPI_ROOT_OBJECT,
+				ACPI_UINT32_MAX,
+				acpi_find_ec,
+				NULL,
+				NULL);
 	return 0;
 }

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)