2 * acpi_ec.c - ACPI Embedded Controller Driver ($Revision: 38 $)
4 * Copyright (C) 2004 Luming Yu <luming.yu@intel.com>
5 * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
6 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
8 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or (at
13 * your option) any later version.
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
24 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
27 #include <linux/kernel.h>
28 #include <linux/module.h>
29 #include <linux/init.h>
30 #include <linux/types.h>
31 #include <linux/delay.h>
32 #include <linux/proc_fs.h>
33 #include <linux/seq_file.h>
34 #include <linux/interrupt.h>
36 #include <acpi/acpi_bus.h>
37 #include <acpi/acpi_drivers.h>
38 #include <acpi/actypes.h>
40 #define _COMPONENT ACPI_EC_COMPONENT
41 ACPI_MODULE_NAME("acpi_ec")
42 #define ACPI_EC_COMPONENT 0x00100000
43 #define ACPI_EC_CLASS "embedded_controller"
44 #define ACPI_EC_HID "PNP0C09"
45 #define ACPI_EC_DRIVER_NAME "ACPI Embedded Controller Driver"
46 #define ACPI_EC_DEVICE_NAME "Embedded Controller"
47 #define ACPI_EC_FILE_INFO "info"
49 #define PREFIX "ACPI: EC: "
50 /* EC status register */
51 #define ACPI_EC_FLAG_OBF 0x01 /* Output buffer full */
52 #define ACPI_EC_FLAG_IBF 0x02 /* Input buffer full */
53 #define ACPI_EC_FLAG_BURST 0x10 /* burst mode */
54 #define ACPI_EC_FLAG_SCI 0x20 /* EC-SCI occurred */
57 ACPI_EC_COMMAND_READ = 0x80,
58 ACPI_EC_COMMAND_WRITE = 0x81,
59 ACPI_EC_BURST_ENABLE = 0x82,
60 ACPI_EC_BURST_DISABLE = 0x83,
61 ACPI_EC_COMMAND_QUERY = 0x84,
65 ACPI_EC_EVENT_OBF_1 = 1, /* Output buffer full */
66 ACPI_EC_EVENT_IBF_0, /* Input buffer empty */
69 #define ACPI_EC_DELAY 500 /* Wait 500ms max. during EC ops */
70 #define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */
73 EC_INTR = 1, /* Output buffer full */
74 EC_POLL, /* Input buffer empty */
75 } acpi_ec_mode = EC_INTR;
77 static int acpi_ec_remove(struct acpi_device *device, int type);
78 static int acpi_ec_start(struct acpi_device *device);
79 static int acpi_ec_stop(struct acpi_device *device, int type);
80 static int acpi_ec_add(struct acpi_device *device);
82 static struct acpi_driver acpi_ec_driver = {
83 .name = ACPI_EC_DRIVER_NAME,
84 .class = ACPI_EC_CLASS,
88 .remove = acpi_ec_remove,
89 .start = acpi_ec_start,
94 /* If we find an EC via the ECDT, we need to keep a ptr to its context */
95 static struct acpi_ec {
99 unsigned long command_addr;
100 unsigned long data_addr;
101 unsigned long global_lock;
103 atomic_t query_pending;
104 atomic_t leaving_burst; /* 0 : No, 1 : Yes, 2: abort */
105 wait_queue_head_t wait;
108 /* External interfaces use first EC only, so remember */
109 static struct acpi_device *first_ec;
111 /* --------------------------------------------------------------------------
112 Transaction Management
113 -------------------------------------------------------------------------- */
115 static inline u8 acpi_ec_read_status(struct acpi_ec *ec)
117 return inb(ec->command_addr);
120 static inline u8 acpi_ec_read_data(struct acpi_ec *ec)
122 return inb(ec->data_addr);
125 static inline void acpi_ec_write_cmd(struct acpi_ec *ec, u8 command)
127 outb(command, ec->command_addr);
130 static inline void acpi_ec_write_data(struct acpi_ec *ec, u8 data)
132 outb(data, ec->data_addr);
135 static inline int acpi_ec_check_status(struct acpi_ec *ec, enum ec_event event)
137 u8 status = acpi_ec_read_status(ec);
139 if (event == ACPI_EC_EVENT_OBF_1) {
140 if (status & ACPI_EC_FLAG_OBF)
142 } else if (event == ACPI_EC_EVENT_IBF_0) {
143 if (!(status & ACPI_EC_FLAG_IBF))
150 static int acpi_ec_wait(struct acpi_ec *ec, enum ec_event event)
152 if (acpi_ec_mode == EC_POLL) {
153 unsigned long delay = jiffies + msecs_to_jiffies(ACPI_EC_DELAY);
154 while (time_before(jiffies, delay)) {
155 if (acpi_ec_check_status(ec, event))
159 if (wait_event_timeout(ec->wait,
160 acpi_ec_check_status(ec, event),
161 msecs_to_jiffies(ACPI_EC_DELAY)) ||
162 acpi_ec_check_status(ec, event)) {
165 printk(KERN_ERR PREFIX "acpi_ec_wait timeout,"
166 " status = %d, expect_event = %d\n",
167 acpi_ec_read_status(ec), event);
174 #ifdef ACPI_FUTURE_USAGE
176 * Note: samsung nv5000 doesn't work with ec burst mode.
177 * http://bugzilla.kernel.org/show_bug.cgi?id=4980
179 int acpi_ec_enter_burst_mode(struct acpi_ec *ec)
184 status = acpi_ec_read_status(ec);
185 if (status != -EINVAL && !(status & ACPI_EC_FLAG_BURST)) {
186 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
189 acpi_ec_write_cmd(ec, ACPI_EC_BURST_ENABLE);
190 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1);
191 tmp = acpi_ec_read_data(ec);
192 if (tmp != 0x90) { /* Burst ACK byte */
197 atomic_set(&ec->leaving_burst, 0);
200 ACPI_EXCEPTION((AE_INFO, status, "EC wait, burst mode"));
204 int acpi_ec_leave_burst_mode(struct acpi_ec *ec)
208 status = acpi_ec_read_status(ec);
209 if (status != -EINVAL && (status & ACPI_EC_FLAG_BURST)) {
210 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
213 acpi_ec_write_cmd(ec, ACPI_EC_BURST_DISABLE);
214 acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
216 atomic_set(&ec->leaving_burst, 1);
219 ACPI_EXCEPTION((AE_INFO, status, "EC leave burst mode"));
222 #endif /* ACPI_FUTURE_USAGE */
224 static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command,
225 const u8 * wdata, unsigned wdata_len,
226 u8 * rdata, unsigned rdata_len)
230 acpi_ec_write_cmd(ec, command);
232 for (; wdata_len > 0; --wdata_len) {
233 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
235 printk(KERN_ERR PREFIX
236 "write_cmd timeout, command = %d\n", command);
239 acpi_ec_write_data(ec, *(wdata++));
243 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
245 printk(KERN_ERR PREFIX
246 "finish-write timeout, command = %d\n", command);
249 } else if (command == ACPI_EC_COMMAND_QUERY) {
250 atomic_set(&ec->query_pending, 0);
253 for (; rdata_len > 0; --rdata_len) {
254 result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1);
256 printk(KERN_ERR PREFIX "read timeout, command = %d\n",
261 *(rdata++) = acpi_ec_read_data(ec);
267 static int acpi_ec_transaction(struct acpi_ec *ec, u8 command,
268 const u8 * wdata, unsigned wdata_len,
269 u8 * rdata, unsigned rdata_len)
274 if (!ec || (wdata_len && !wdata) || (rdata_len && !rdata))
278 memset(rdata, 0, rdata_len);
280 mutex_lock(&ec->lock);
281 if (ec->global_lock) {
282 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
283 if (ACPI_FAILURE(status)) {
284 mutex_unlock(&ec->lock);
289 /* Make sure GPE is enabled before doing transaction */
290 acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR);
292 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
294 printk(KERN_DEBUG PREFIX
295 "input buffer is not empty, aborting transaction\n");
299 status = acpi_ec_transaction_unlocked(ec, command,
306 acpi_release_global_lock(glk);
307 mutex_unlock(&ec->lock);
312 static int acpi_ec_read(struct acpi_ec *ec, u8 address, u8 * data)
317 result = acpi_ec_transaction(ec, ACPI_EC_COMMAND_READ,
323 static int acpi_ec_write(struct acpi_ec *ec, u8 address, u8 data)
325 u8 wdata[2] = { address, data };
326 return acpi_ec_transaction(ec, ACPI_EC_COMMAND_WRITE,
331 * Externally callable EC access functions. For now, assume 1 EC only
333 int ec_read(u8 addr, u8 * val)
342 ec = acpi_driver_data(first_ec);
344 err = acpi_ec_read(ec, addr, &temp_data);
353 EXPORT_SYMBOL(ec_read);
355 int ec_write(u8 addr, u8 val)
363 ec = acpi_driver_data(first_ec);
365 err = acpi_ec_write(ec, addr, val);
370 EXPORT_SYMBOL(ec_write);
372 int ec_transaction(u8 command,
373 const u8 * wdata, unsigned wdata_len,
374 u8 * rdata, unsigned rdata_len)
381 ec = acpi_driver_data(first_ec);
383 return acpi_ec_transaction(ec, command, wdata,
384 wdata_len, rdata, rdata_len);
387 EXPORT_SYMBOL(ec_transaction);
389 static int acpi_ec_query(struct acpi_ec *ec, u8 * data)
398 * Query the EC to find out which _Qxx method we need to evaluate.
399 * Note that successful completion of the query causes the ACPI_EC_SCI
400 * bit to be cleared (and thus clearing the interrupt source).
403 result = acpi_ec_transaction(ec, ACPI_EC_COMMAND_QUERY, NULL, 0, &d, 1);
414 /* --------------------------------------------------------------------------
416 -------------------------------------------------------------------------- */
418 static void acpi_ec_gpe_query(void *ec_cxt)
420 struct acpi_ec *ec = (struct acpi_ec *)ec_cxt;
424 if (!ec || acpi_ec_query(ec, &value))
427 snprintf(object_name, 8, "_Q%2.2X", value);
429 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluating %s", object_name));
431 acpi_evaluate_object(ec->handle, object_name, NULL, NULL);
434 static u32 acpi_ec_gpe_handler(void *data)
436 acpi_status status = AE_OK;
438 struct acpi_ec *ec = (struct acpi_ec *)data;
440 if (acpi_ec_mode == EC_INTR) {
444 value = acpi_ec_read_status(ec);
445 if ((value & ACPI_EC_FLAG_SCI) && !atomic_read(&ec->query_pending)) {
446 atomic_set(&ec->query_pending, 1);
448 acpi_os_execute(OSL_EC_BURST_HANDLER, acpi_ec_gpe_query,
452 return status == AE_OK ?
453 ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED;
456 /* --------------------------------------------------------------------------
457 Address Space Management
458 -------------------------------------------------------------------------- */
461 acpi_ec_space_setup(acpi_handle region_handle,
462 u32 function, void *handler_context, void **return_context)
465 * The EC object is in the handler context and is needed
466 * when calling the acpi_ec_space_handler.
468 *return_context = (function != ACPI_REGION_DEACTIVATE) ?
469 handler_context : NULL;
475 acpi_ec_space_handler(u32 function,
476 acpi_physical_address address,
478 acpi_integer * value,
479 void *handler_context, void *region_context)
482 struct acpi_ec *ec = NULL;
484 acpi_integer f_v = 0;
487 if ((address > 0xFF) || !value || !handler_context)
488 return AE_BAD_PARAMETER;
490 if (bit_width != 8 && acpi_strict) {
491 return AE_BAD_PARAMETER;
494 ec = (struct acpi_ec *)handler_context;
500 result = acpi_ec_read(ec, (u8) address, (u8 *) & temp);
503 result = acpi_ec_write(ec, (u8) address, (u8) temp);
513 if (function == ACPI_READ)
514 f_v |= temp << 8 * i;
515 if (function == ACPI_WRITE)
522 if (function == ACPI_READ) {
523 f_v |= temp << 8 * i;
530 return AE_BAD_PARAMETER;
543 /* --------------------------------------------------------------------------
545 -------------------------------------------------------------------------- */
547 static struct proc_dir_entry *acpi_ec_dir;
549 static int acpi_ec_read_info(struct seq_file *seq, void *offset)
551 struct acpi_ec *ec = (struct acpi_ec *)seq->private;
556 seq_printf(seq, "gpe: 0x%02x\n", (u32) ec->gpe);
557 seq_printf(seq, "ports: 0x%02x, 0x%02x\n",
558 (u32) ec->command_addr, (u32) ec->data_addr);
559 seq_printf(seq, "use global lock: %s\n",
560 ec->global_lock ? "yes" : "no");
561 acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR);
567 static int acpi_ec_info_open_fs(struct inode *inode, struct file *file)
569 return single_open(file, acpi_ec_read_info, PDE(inode)->data);
572 static struct file_operations acpi_ec_info_ops = {
573 .open = acpi_ec_info_open_fs,
576 .release = single_release,
577 .owner = THIS_MODULE,
580 static int acpi_ec_add_fs(struct acpi_device *device)
582 struct proc_dir_entry *entry = NULL;
584 if (!acpi_device_dir(device)) {
585 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
587 if (!acpi_device_dir(device))
591 entry = create_proc_entry(ACPI_EC_FILE_INFO, S_IRUGO,
592 acpi_device_dir(device));
596 entry->proc_fops = &acpi_ec_info_ops;
597 entry->data = acpi_driver_data(device);
598 entry->owner = THIS_MODULE;
604 static int acpi_ec_remove_fs(struct acpi_device *device)
607 if (acpi_device_dir(device)) {
608 remove_proc_entry(ACPI_EC_FILE_INFO, acpi_device_dir(device));
609 remove_proc_entry(acpi_device_bid(device), acpi_ec_dir);
610 acpi_device_dir(device) = NULL;
616 /* --------------------------------------------------------------------------
618 -------------------------------------------------------------------------- */
620 static int acpi_ec_add(struct acpi_device *device)
623 acpi_status status = AE_OK;
624 struct acpi_ec *ec = NULL;
629 ec = kzalloc(sizeof(struct acpi_ec), GFP_KERNEL);
633 ec->handle = device->handle;
635 mutex_init(&ec->lock);
636 atomic_set(&ec->query_pending, 0);
637 if (acpi_ec_mode == EC_INTR) {
638 atomic_set(&ec->leaving_burst, 1);
639 init_waitqueue_head(&ec->wait);
641 strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME);
642 strcpy(acpi_device_class(device), ACPI_EC_CLASS);
643 acpi_driver_data(device) = ec;
645 /* Use the global lock for all EC transactions? */
646 acpi_evaluate_integer(ec->handle, "_GLK", NULL, &ec->global_lock);
648 /* XXX we don't test uids, because on some boxes ecdt uid = 0, see:
649 http://bugzilla.kernel.org/show_bug.cgi?id=6111 */
651 acpi_remove_address_space_handler(ACPI_ROOT_OBJECT,
653 &acpi_ec_space_handler);
655 acpi_remove_gpe_handler(NULL, ec_ecdt->gpe,
656 &acpi_ec_gpe_handler);
661 /* Get GPE bit assignment (EC events). */
662 /* TODO: Add support for _GPE returning a package */
663 status = acpi_evaluate_integer(ec->handle, "_GPE", NULL, &ec->gpe);
664 if (ACPI_FAILURE(status)) {
665 ACPI_EXCEPTION((AE_INFO, status,
666 "Obtaining GPE bit assignment"));
671 result = acpi_ec_add_fs(device);
675 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s [%s] (gpe %d) interrupt mode.",
676 acpi_device_name(device), acpi_device_bid(device),
689 static int acpi_ec_remove(struct acpi_device *device, int type)
691 struct acpi_ec *ec = NULL;
696 ec = acpi_driver_data(device);
698 acpi_ec_remove_fs(device);
706 acpi_ec_io_ports(struct acpi_resource *resource, void *context)
708 struct acpi_ec *ec = (struct acpi_ec *)context;
710 if (resource->type != ACPI_RESOURCE_TYPE_IO) {
715 * The first address region returned is the data port, and
716 * the second address region returned is the status/command
719 if (ec->data_addr == 0) {
720 ec->data_addr = resource->data.io.minimum;
721 } else if (ec->command_addr == 0) {
722 ec->command_addr = resource->data.io.minimum;
724 return AE_CTRL_TERMINATE;
730 static int acpi_ec_start(struct acpi_device *device)
732 acpi_status status = AE_OK;
733 struct acpi_ec *ec = NULL;
738 ec = acpi_driver_data(device);
744 * Get I/O port addresses. Convert to GAS format.
746 status = acpi_walk_resources(ec->handle, METHOD_NAME__CRS,
747 acpi_ec_io_ports, ec);
748 if (ACPI_FAILURE(status) || ec->command_addr == 0) {
749 ACPI_EXCEPTION((AE_INFO, status,
750 "Error getting I/O port addresses"));
754 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "gpe=0x%02lx, ports=0x%2lx,0x%2lx",
755 ec->gpe, ec->command_addr, ec->data_addr));
758 * Install GPE handler
760 status = acpi_install_gpe_handler(NULL, ec->gpe,
761 ACPI_GPE_EDGE_TRIGGERED,
762 &acpi_ec_gpe_handler, ec);
763 if (ACPI_FAILURE(status)) {
766 acpi_set_gpe_type(NULL, ec->gpe, ACPI_GPE_TYPE_RUNTIME);
767 acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR);
769 status = acpi_install_address_space_handler(ec->handle,
771 &acpi_ec_space_handler,
772 &acpi_ec_space_setup, ec);
773 if (ACPI_FAILURE(status)) {
774 acpi_remove_gpe_handler(NULL, ec->gpe, &acpi_ec_gpe_handler);
781 static int acpi_ec_stop(struct acpi_device *device, int type)
783 acpi_status status = AE_OK;
784 struct acpi_ec *ec = NULL;
789 ec = acpi_driver_data(device);
791 status = acpi_remove_address_space_handler(ec->handle,
793 &acpi_ec_space_handler);
794 if (ACPI_FAILURE(status))
797 status = acpi_remove_gpe_handler(NULL, ec->gpe, &acpi_ec_gpe_handler);
798 if (ACPI_FAILURE(status))
804 static acpi_status __init
805 acpi_fake_ecdt_callback(acpi_handle handle,
806 u32 Level, void *context, void **retval)
810 mutex_init(&ec_ecdt->lock);
811 if (acpi_ec_mode == EC_INTR) {
812 init_waitqueue_head(&ec_ecdt->wait);
814 status = acpi_walk_resources(handle, METHOD_NAME__CRS,
815 acpi_ec_io_ports, ec_ecdt);
816 if (ACPI_FAILURE(status))
820 acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->uid);
822 status = acpi_evaluate_integer(handle, "_GPE", NULL, &ec_ecdt->gpe);
823 if (ACPI_FAILURE(status))
825 ec_ecdt->global_lock = TRUE;
826 ec_ecdt->handle = handle;
828 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "GPE=0x%02lx, ports=0x%2lx, 0x%2lx",
829 ec_ecdt->gpe, ec_ecdt->command_addr,
830 ec_ecdt->data_addr));
832 return AE_CTRL_TERMINATE;
836 * Some BIOS (such as some from Gateway laptops) access EC region very early
837 * such as in BAT0._INI or EC._INI before an EC device is found and
838 * do not provide an ECDT. According to ACPI spec, ECDT isn't mandatorily
839 * required, but if EC regison is accessed early, it is required.
840 * The routine tries to workaround the BIOS bug by pre-scan EC device
841 * It assumes that _CRS, _HID, _GPE, _UID methods of EC don't touch any
842 * op region (since _REG isn't invoked yet). The assumption is true for
845 static int __init acpi_ec_fake_ecdt(void)
850 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Try to make an fake ECDT"));
852 ec_ecdt = kzalloc(sizeof(struct acpi_ec), GFP_KERNEL);
858 status = acpi_get_devices(ACPI_EC_HID,
859 acpi_fake_ecdt_callback, NULL, NULL);
860 if (ACPI_FAILURE(status)) {
864 ACPI_EXCEPTION((AE_INFO, status, "Can't make an fake ECDT"));
872 static int __init acpi_ec_get_real_ecdt(void)
875 struct acpi_table_ecdt *ecdt_ptr;
877 status = acpi_get_table(ACPI_SIG_ECDT, 1,
878 (struct acpi_table_header **)&ecdt_ptr);
879 if (ACPI_FAILURE(status))
882 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found ECDT"));
885 * Generate a temporary ec context to use until the namespace is scanned
887 ec_ecdt = kzalloc(sizeof(struct acpi_ec), GFP_KERNEL);
891 mutex_init(&ec_ecdt->lock);
892 if (acpi_ec_mode == EC_INTR) {
893 init_waitqueue_head(&ec_ecdt->wait);
895 ec_ecdt->command_addr = ecdt_ptr->control.address;
896 ec_ecdt->data_addr = ecdt_ptr->data.address;
897 ec_ecdt->gpe = ecdt_ptr->gpe;
898 /* use the GL just to be safe */
899 ec_ecdt->global_lock = TRUE;
900 ec_ecdt->uid = ecdt_ptr->uid;
902 status = acpi_get_handle(NULL, ecdt_ptr->id, &ec_ecdt->handle);
903 if (ACPI_FAILURE(status)) {
909 ACPI_EXCEPTION((AE_INFO, status, "Could not use ECDT"));
916 static int __initdata acpi_fake_ecdt_enabled;
917 int __init acpi_ec_ecdt_probe(void)
922 ret = acpi_ec_get_real_ecdt();
923 /* Try to make a fake ECDT */
924 if (ret && acpi_fake_ecdt_enabled) {
925 ret = acpi_ec_fake_ecdt();
932 * Install GPE handler
934 status = acpi_install_gpe_handler(NULL, ec_ecdt->gpe,
935 ACPI_GPE_EDGE_TRIGGERED,
936 &acpi_ec_gpe_handler, ec_ecdt);
937 if (ACPI_FAILURE(status)) {
940 acpi_set_gpe_type(NULL, ec_ecdt->gpe, ACPI_GPE_TYPE_RUNTIME);
941 acpi_enable_gpe(NULL, ec_ecdt->gpe, ACPI_NOT_ISR);
943 status = acpi_install_address_space_handler(ACPI_ROOT_OBJECT,
945 &acpi_ec_space_handler,
946 &acpi_ec_space_setup,
948 if (ACPI_FAILURE(status)) {
949 acpi_remove_gpe_handler(NULL, ec_ecdt->gpe,
950 &acpi_ec_gpe_handler);
957 ACPI_EXCEPTION((AE_INFO, status, "Could not use ECDT"));
964 static int __init acpi_ec_init(void)
971 acpi_ec_dir = proc_mkdir(ACPI_EC_CLASS, acpi_root_dir);
975 /* Now register the driver for the EC */
976 result = acpi_bus_register_driver(&acpi_ec_driver);
978 remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir);
985 subsys_initcall(acpi_ec_init);
987 /* EC driver currently not unloadable */
989 static void __exit acpi_ec_exit(void)
992 acpi_bus_unregister_driver(&acpi_ec_driver);
994 remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir);
1000 static int __init acpi_fake_ecdt_setup(char *str)
1002 acpi_fake_ecdt_enabled = 1;
1006 __setup("acpi_fake_ecdt", acpi_fake_ecdt_setup);
1007 static int __init acpi_ec_set_intr_mode(char *str)
1011 if (!get_option(&str, &intr))
1015 acpi_ec_mode = EC_INTR;
1017 acpi_ec_mode = EC_POLL;
1019 acpi_ec_driver.ops.add = acpi_ec_add;
1020 printk(KERN_NOTICE PREFIX "%s mode.\n",
1021 intr ? "interrupt" : "polling");
1026 __setup("ec_intr=", acpi_ec_set_intr_mode);