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("ec");
42 #define ACPI_EC_COMPONENT 0x00100000
43 #define ACPI_EC_CLASS "embedded_controller"
44 #define ACPI_EC_HID "PNP0C09"
45 #define ACPI_EC_DEVICE_NAME "Embedded Controller"
46 #define ACPI_EC_FILE_INFO "info"
48 #define PREFIX "ACPI: EC: "
49 /* EC status register */
50 #define ACPI_EC_FLAG_OBF 0x01 /* Output buffer full */
51 #define ACPI_EC_FLAG_IBF 0x02 /* Input buffer full */
52 #define ACPI_EC_FLAG_BURST 0x10 /* burst mode */
53 #define ACPI_EC_FLAG_SCI 0x20 /* EC-SCI occurred */
56 ACPI_EC_COMMAND_READ = 0x80,
57 ACPI_EC_COMMAND_WRITE = 0x81,
58 ACPI_EC_BURST_ENABLE = 0x82,
59 ACPI_EC_BURST_DISABLE = 0x83,
60 ACPI_EC_COMMAND_QUERY = 0x84,
64 ACPI_EC_EVENT_OBF_1 = 1, /* Output buffer full */
65 ACPI_EC_EVENT_IBF_0, /* Input buffer empty */
68 #define ACPI_EC_DELAY 500 /* Wait 500ms max. during EC ops */
69 #define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */
72 EC_INTR = 1, /* Output buffer full */
73 EC_POLL, /* Input buffer empty */
74 } acpi_ec_mode = EC_INTR;
76 static int acpi_ec_remove(struct acpi_device *device, int type);
77 static int acpi_ec_start(struct acpi_device *device);
78 static int acpi_ec_stop(struct acpi_device *device, int type);
79 static int acpi_ec_add(struct acpi_device *device);
81 static struct acpi_driver acpi_ec_driver = {
83 .class = ACPI_EC_CLASS,
87 .remove = acpi_ec_remove,
88 .start = acpi_ec_start,
93 /* If we find an EC via the ECDT, we need to keep a ptr to its context */
94 static struct acpi_ec {
98 unsigned long command_addr;
99 unsigned long data_addr;
100 unsigned long global_lock;
102 atomic_t query_pending;
103 atomic_t leaving_burst; /* 0 : No, 1 : Yes, 2: abort */
104 wait_queue_head_t wait;
107 /* External interfaces use first EC only, so remember */
108 static struct acpi_device *first_ec;
110 /* --------------------------------------------------------------------------
111 Transaction Management
112 -------------------------------------------------------------------------- */
114 static inline u8 acpi_ec_read_status(struct acpi_ec *ec)
116 return inb(ec->command_addr);
119 static inline u8 acpi_ec_read_data(struct acpi_ec *ec)
121 return inb(ec->data_addr);
124 static inline void acpi_ec_write_cmd(struct acpi_ec *ec, u8 command)
126 outb(command, ec->command_addr);
129 static inline void acpi_ec_write_data(struct acpi_ec *ec, u8 data)
131 outb(data, ec->data_addr);
134 static inline int acpi_ec_check_status(struct acpi_ec *ec, enum ec_event event)
136 u8 status = acpi_ec_read_status(ec);
138 if (event == ACPI_EC_EVENT_OBF_1) {
139 if (status & ACPI_EC_FLAG_OBF)
141 } else if (event == ACPI_EC_EVENT_IBF_0) {
142 if (!(status & ACPI_EC_FLAG_IBF))
149 static int acpi_ec_wait(struct acpi_ec *ec, enum ec_event event)
151 if (acpi_ec_mode == EC_POLL) {
152 unsigned long delay = jiffies + msecs_to_jiffies(ACPI_EC_DELAY);
153 while (time_before(jiffies, delay)) {
154 if (acpi_ec_check_status(ec, event))
158 if (wait_event_timeout(ec->wait,
159 acpi_ec_check_status(ec, event),
160 msecs_to_jiffies(ACPI_EC_DELAY)) ||
161 acpi_ec_check_status(ec, event)) {
164 printk(KERN_ERR PREFIX "acpi_ec_wait timeout,"
165 " status = %d, expect_event = %d\n",
166 acpi_ec_read_status(ec), event);
173 #ifdef ACPI_FUTURE_USAGE
175 * Note: samsung nv5000 doesn't work with ec burst mode.
176 * http://bugzilla.kernel.org/show_bug.cgi?id=4980
178 int acpi_ec_enter_burst_mode(struct acpi_ec *ec)
183 status = acpi_ec_read_status(ec);
184 if (status != -EINVAL && !(status & ACPI_EC_FLAG_BURST)) {
185 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
188 acpi_ec_write_cmd(ec, ACPI_EC_BURST_ENABLE);
189 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1);
190 tmp = acpi_ec_read_data(ec);
191 if (tmp != 0x90) { /* Burst ACK byte */
196 atomic_set(&ec->leaving_burst, 0);
199 ACPI_EXCEPTION((AE_INFO, status, "EC wait, burst mode"));
203 int acpi_ec_leave_burst_mode(struct acpi_ec *ec)
207 status = acpi_ec_read_status(ec);
208 if (status != -EINVAL && (status & ACPI_EC_FLAG_BURST)) {
209 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
212 acpi_ec_write_cmd(ec, ACPI_EC_BURST_DISABLE);
213 acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
215 atomic_set(&ec->leaving_burst, 1);
218 ACPI_EXCEPTION((AE_INFO, status, "EC leave burst mode"));
221 #endif /* ACPI_FUTURE_USAGE */
223 static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command,
224 const u8 * wdata, unsigned wdata_len,
225 u8 * rdata, unsigned rdata_len)
229 acpi_ec_write_cmd(ec, command);
231 for (; wdata_len > 0; --wdata_len) {
232 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
234 printk(KERN_ERR PREFIX
235 "write_cmd timeout, command = %d\n", command);
238 acpi_ec_write_data(ec, *(wdata++));
242 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
244 printk(KERN_ERR PREFIX
245 "finish-write timeout, command = %d\n", command);
248 } else if (command == ACPI_EC_COMMAND_QUERY) {
249 atomic_set(&ec->query_pending, 0);
252 for (; rdata_len > 0; --rdata_len) {
253 result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1);
255 printk(KERN_ERR PREFIX "read timeout, command = %d\n",
260 *(rdata++) = acpi_ec_read_data(ec);
266 static int acpi_ec_transaction(struct acpi_ec *ec, u8 command,
267 const u8 * wdata, unsigned wdata_len,
268 u8 * rdata, unsigned rdata_len)
273 if (!ec || (wdata_len && !wdata) || (rdata_len && !rdata))
277 memset(rdata, 0, rdata_len);
279 mutex_lock(&ec->lock);
280 if (ec->global_lock) {
281 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
282 if (ACPI_FAILURE(status))
286 /* Make sure GPE is enabled before doing transaction */
287 acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR);
289 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
291 printk(KERN_DEBUG PREFIX
292 "input buffer is not empty, aborting transaction\n");
296 status = acpi_ec_transaction_unlocked(ec, command,
303 acpi_release_global_lock(glk);
304 mutex_unlock(&ec->lock);
309 static int acpi_ec_read(struct acpi_ec *ec, u8 address, u8 * data)
314 result = acpi_ec_transaction(ec, ACPI_EC_COMMAND_READ,
320 static int acpi_ec_write(struct acpi_ec *ec, u8 address, u8 data)
322 u8 wdata[2] = { address, data };
323 return acpi_ec_transaction(ec, ACPI_EC_COMMAND_WRITE,
328 * Externally callable EC access functions. For now, assume 1 EC only
330 int ec_read(u8 addr, u8 * val)
339 ec = acpi_driver_data(first_ec);
341 err = acpi_ec_read(ec, addr, &temp_data);
350 EXPORT_SYMBOL(ec_read);
352 int ec_write(u8 addr, u8 val)
360 ec = acpi_driver_data(first_ec);
362 err = acpi_ec_write(ec, addr, val);
367 EXPORT_SYMBOL(ec_write);
369 int ec_transaction(u8 command,
370 const u8 * wdata, unsigned wdata_len,
371 u8 * rdata, unsigned rdata_len)
378 ec = acpi_driver_data(first_ec);
380 return acpi_ec_transaction(ec, command, wdata,
381 wdata_len, rdata, rdata_len);
384 EXPORT_SYMBOL(ec_transaction);
386 static int acpi_ec_query(struct acpi_ec *ec, u8 * data)
395 * Query the EC to find out which _Qxx method we need to evaluate.
396 * Note that successful completion of the query causes the ACPI_EC_SCI
397 * bit to be cleared (and thus clearing the interrupt source).
400 result = acpi_ec_transaction(ec, ACPI_EC_COMMAND_QUERY, NULL, 0, &d, 1);
411 /* --------------------------------------------------------------------------
413 -------------------------------------------------------------------------- */
415 static void acpi_ec_gpe_query(void *ec_cxt)
417 struct acpi_ec *ec = (struct acpi_ec *)ec_cxt;
421 if (!ec || acpi_ec_query(ec, &value))
424 snprintf(object_name, 8, "_Q%2.2X", value);
426 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluating %s", object_name));
428 acpi_evaluate_object(ec->handle, object_name, NULL, NULL);
431 static u32 acpi_ec_gpe_handler(void *data)
433 acpi_status status = AE_OK;
435 struct acpi_ec *ec = (struct acpi_ec *)data;
437 if (acpi_ec_mode == EC_INTR) {
441 value = acpi_ec_read_status(ec);
442 if ((value & ACPI_EC_FLAG_SCI) && !atomic_read(&ec->query_pending)) {
443 atomic_set(&ec->query_pending, 1);
445 acpi_os_execute(OSL_EC_BURST_HANDLER, acpi_ec_gpe_query,
449 return status == AE_OK ?
450 ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED;
453 /* --------------------------------------------------------------------------
454 Address Space Management
455 -------------------------------------------------------------------------- */
458 acpi_ec_space_setup(acpi_handle region_handle,
459 u32 function, void *handler_context, void **return_context)
462 * The EC object is in the handler context and is needed
463 * when calling the acpi_ec_space_handler.
465 *return_context = (function != ACPI_REGION_DEACTIVATE) ?
466 handler_context : NULL;
472 acpi_ec_space_handler(u32 function,
473 acpi_physical_address address,
475 acpi_integer * value,
476 void *handler_context, void *region_context)
479 struct acpi_ec *ec = NULL;
481 acpi_integer f_v = 0;
484 if ((address > 0xFF) || !value || !handler_context)
485 return AE_BAD_PARAMETER;
487 if (bit_width != 8 && acpi_strict) {
488 return AE_BAD_PARAMETER;
491 ec = (struct acpi_ec *)handler_context;
497 result = acpi_ec_read(ec, (u8) address, (u8 *) & temp);
500 result = acpi_ec_write(ec, (u8) address, (u8) temp);
510 if (function == ACPI_READ)
511 f_v |= temp << 8 * i;
512 if (function == ACPI_WRITE)
519 if (function == ACPI_READ) {
520 f_v |= temp << 8 * i;
527 return AE_BAD_PARAMETER;
540 /* --------------------------------------------------------------------------
542 -------------------------------------------------------------------------- */
544 static struct proc_dir_entry *acpi_ec_dir;
546 static int acpi_ec_read_info(struct seq_file *seq, void *offset)
548 struct acpi_ec *ec = (struct acpi_ec *)seq->private;
553 seq_printf(seq, "gpe: 0x%02x\n", (u32) ec->gpe);
554 seq_printf(seq, "ports: 0x%02x, 0x%02x\n",
555 (u32) ec->command_addr, (u32) ec->data_addr);
556 seq_printf(seq, "use global lock: %s\n",
557 ec->global_lock ? "yes" : "no");
558 acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR);
564 static int acpi_ec_info_open_fs(struct inode *inode, struct file *file)
566 return single_open(file, acpi_ec_read_info, PDE(inode)->data);
569 static struct file_operations acpi_ec_info_ops = {
570 .open = acpi_ec_info_open_fs,
573 .release = single_release,
574 .owner = THIS_MODULE,
577 static int acpi_ec_add_fs(struct acpi_device *device)
579 struct proc_dir_entry *entry = NULL;
581 if (!acpi_device_dir(device)) {
582 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
584 if (!acpi_device_dir(device))
588 entry = create_proc_entry(ACPI_EC_FILE_INFO, S_IRUGO,
589 acpi_device_dir(device));
593 entry->proc_fops = &acpi_ec_info_ops;
594 entry->data = acpi_driver_data(device);
595 entry->owner = THIS_MODULE;
601 static int acpi_ec_remove_fs(struct acpi_device *device)
604 if (acpi_device_dir(device)) {
605 remove_proc_entry(ACPI_EC_FILE_INFO, acpi_device_dir(device));
606 remove_proc_entry(acpi_device_bid(device), acpi_ec_dir);
607 acpi_device_dir(device) = NULL;
613 /* --------------------------------------------------------------------------
615 -------------------------------------------------------------------------- */
617 static int acpi_ec_add(struct acpi_device *device)
620 acpi_status status = AE_OK;
621 struct acpi_ec *ec = NULL;
626 ec = kzalloc(sizeof(struct acpi_ec), GFP_KERNEL);
630 ec->handle = device->handle;
632 mutex_init(&ec->lock);
633 atomic_set(&ec->query_pending, 0);
634 if (acpi_ec_mode == EC_INTR) {
635 atomic_set(&ec->leaving_burst, 1);
636 init_waitqueue_head(&ec->wait);
638 strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME);
639 strcpy(acpi_device_class(device), ACPI_EC_CLASS);
640 acpi_driver_data(device) = ec;
642 /* Use the global lock for all EC transactions? */
643 acpi_evaluate_integer(ec->handle, "_GLK", NULL, &ec->global_lock);
645 /* XXX we don't test uids, because on some boxes ecdt uid = 0, see:
646 http://bugzilla.kernel.org/show_bug.cgi?id=6111 */
648 acpi_remove_address_space_handler(ACPI_ROOT_OBJECT,
650 &acpi_ec_space_handler);
652 acpi_remove_gpe_handler(NULL, ec_ecdt->gpe,
653 &acpi_ec_gpe_handler);
658 /* Get GPE bit assignment (EC events). */
659 /* TODO: Add support for _GPE returning a package */
660 status = acpi_evaluate_integer(ec->handle, "_GPE", NULL, &ec->gpe);
661 if (ACPI_FAILURE(status)) {
662 ACPI_EXCEPTION((AE_INFO, status,
663 "Obtaining GPE bit assignment"));
668 result = acpi_ec_add_fs(device);
672 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s [%s] (gpe %d) interrupt mode.",
673 acpi_device_name(device), acpi_device_bid(device),
686 static int acpi_ec_remove(struct acpi_device *device, int type)
688 struct acpi_ec *ec = NULL;
693 ec = acpi_driver_data(device);
695 acpi_ec_remove_fs(device);
703 acpi_ec_io_ports(struct acpi_resource *resource, void *context)
705 struct acpi_ec *ec = (struct acpi_ec *)context;
707 if (resource->type != ACPI_RESOURCE_TYPE_IO) {
712 * The first address region returned is the data port, and
713 * the second address region returned is the status/command
716 if (ec->data_addr == 0) {
717 ec->data_addr = resource->data.io.minimum;
718 } else if (ec->command_addr == 0) {
719 ec->command_addr = resource->data.io.minimum;
721 return AE_CTRL_TERMINATE;
727 static int acpi_ec_start(struct acpi_device *device)
729 acpi_status status = AE_OK;
730 struct acpi_ec *ec = NULL;
735 ec = acpi_driver_data(device);
741 * Get I/O port addresses. Convert to GAS format.
743 status = acpi_walk_resources(ec->handle, METHOD_NAME__CRS,
744 acpi_ec_io_ports, ec);
745 if (ACPI_FAILURE(status) || ec->command_addr == 0) {
746 ACPI_EXCEPTION((AE_INFO, status,
747 "Error getting I/O port addresses"));
751 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "gpe=0x%02lx, ports=0x%2lx,0x%2lx",
752 ec->gpe, ec->command_addr, ec->data_addr));
755 * Install GPE handler
757 status = acpi_install_gpe_handler(NULL, ec->gpe,
758 ACPI_GPE_EDGE_TRIGGERED,
759 &acpi_ec_gpe_handler, ec);
760 if (ACPI_FAILURE(status)) {
763 acpi_set_gpe_type(NULL, ec->gpe, ACPI_GPE_TYPE_RUNTIME);
764 acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR);
766 status = acpi_install_address_space_handler(ec->handle,
768 &acpi_ec_space_handler,
769 &acpi_ec_space_setup, ec);
770 if (ACPI_FAILURE(status)) {
771 acpi_remove_gpe_handler(NULL, ec->gpe, &acpi_ec_gpe_handler);
778 static int acpi_ec_stop(struct acpi_device *device, int type)
780 acpi_status status = AE_OK;
781 struct acpi_ec *ec = NULL;
786 ec = acpi_driver_data(device);
788 status = acpi_remove_address_space_handler(ec->handle,
790 &acpi_ec_space_handler);
791 if (ACPI_FAILURE(status))
794 status = acpi_remove_gpe_handler(NULL, ec->gpe, &acpi_ec_gpe_handler);
795 if (ACPI_FAILURE(status))
801 static acpi_status __init
802 acpi_fake_ecdt_callback(acpi_handle handle,
803 u32 Level, void *context, void **retval)
807 mutex_init(&ec_ecdt->lock);
808 if (acpi_ec_mode == EC_INTR) {
809 init_waitqueue_head(&ec_ecdt->wait);
811 status = acpi_walk_resources(handle, METHOD_NAME__CRS,
812 acpi_ec_io_ports, ec_ecdt);
813 if (ACPI_FAILURE(status))
817 acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->uid);
819 status = acpi_evaluate_integer(handle, "_GPE", NULL, &ec_ecdt->gpe);
820 if (ACPI_FAILURE(status))
822 ec_ecdt->global_lock = TRUE;
823 ec_ecdt->handle = handle;
825 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "GPE=0x%02lx, ports=0x%2lx, 0x%2lx",
826 ec_ecdt->gpe, ec_ecdt->command_addr,
827 ec_ecdt->data_addr));
829 return AE_CTRL_TERMINATE;
833 * Some BIOS (such as some from Gateway laptops) access EC region very early
834 * such as in BAT0._INI or EC._INI before an EC device is found and
835 * do not provide an ECDT. According to ACPI spec, ECDT isn't mandatorily
836 * required, but if EC regison is accessed early, it is required.
837 * The routine tries to workaround the BIOS bug by pre-scan EC device
838 * It assumes that _CRS, _HID, _GPE, _UID methods of EC don't touch any
839 * op region (since _REG isn't invoked yet). The assumption is true for
842 static int __init acpi_ec_fake_ecdt(void)
847 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Try to make an fake ECDT"));
849 ec_ecdt = kzalloc(sizeof(struct acpi_ec), GFP_KERNEL);
855 status = acpi_get_devices(ACPI_EC_HID,
856 acpi_fake_ecdt_callback, NULL, NULL);
857 if (ACPI_FAILURE(status)) {
861 ACPI_EXCEPTION((AE_INFO, status, "Can't make an fake ECDT"));
869 static int __init acpi_ec_get_real_ecdt(void)
872 struct acpi_table_ecdt *ecdt_ptr;
874 status = acpi_get_table(ACPI_SIG_ECDT, 1,
875 (struct acpi_table_header **)&ecdt_ptr);
876 if (ACPI_FAILURE(status))
879 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found ECDT"));
882 * Generate a temporary ec context to use until the namespace is scanned
884 ec_ecdt = kzalloc(sizeof(struct acpi_ec), GFP_KERNEL);
888 mutex_init(&ec_ecdt->lock);
889 if (acpi_ec_mode == EC_INTR) {
890 init_waitqueue_head(&ec_ecdt->wait);
892 ec_ecdt->command_addr = ecdt_ptr->control.address;
893 ec_ecdt->data_addr = ecdt_ptr->data.address;
894 ec_ecdt->gpe = ecdt_ptr->gpe;
895 /* use the GL just to be safe */
896 ec_ecdt->global_lock = TRUE;
897 ec_ecdt->uid = ecdt_ptr->uid;
899 status = acpi_get_handle(NULL, ecdt_ptr->id, &ec_ecdt->handle);
900 if (ACPI_FAILURE(status)) {
906 ACPI_EXCEPTION((AE_INFO, status, "Could not use ECDT"));
913 static int __initdata acpi_fake_ecdt_enabled;
914 int __init acpi_ec_ecdt_probe(void)
919 ret = acpi_ec_get_real_ecdt();
920 /* Try to make a fake ECDT */
921 if (ret && acpi_fake_ecdt_enabled) {
922 ret = acpi_ec_fake_ecdt();
929 * Install GPE handler
931 status = acpi_install_gpe_handler(NULL, ec_ecdt->gpe,
932 ACPI_GPE_EDGE_TRIGGERED,
933 &acpi_ec_gpe_handler, ec_ecdt);
934 if (ACPI_FAILURE(status)) {
937 acpi_set_gpe_type(NULL, ec_ecdt->gpe, ACPI_GPE_TYPE_RUNTIME);
938 acpi_enable_gpe(NULL, ec_ecdt->gpe, ACPI_NOT_ISR);
940 status = acpi_install_address_space_handler(ACPI_ROOT_OBJECT,
942 &acpi_ec_space_handler,
943 &acpi_ec_space_setup,
945 if (ACPI_FAILURE(status)) {
946 acpi_remove_gpe_handler(NULL, ec_ecdt->gpe,
947 &acpi_ec_gpe_handler);
954 ACPI_EXCEPTION((AE_INFO, status, "Could not use ECDT"));
961 static int __init acpi_ec_init(void)
968 acpi_ec_dir = proc_mkdir(ACPI_EC_CLASS, acpi_root_dir);
972 /* Now register the driver for the EC */
973 result = acpi_bus_register_driver(&acpi_ec_driver);
975 remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir);
982 subsys_initcall(acpi_ec_init);
984 /* EC driver currently not unloadable */
986 static void __exit acpi_ec_exit(void)
989 acpi_bus_unregister_driver(&acpi_ec_driver);
991 remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir);
997 static int __init acpi_fake_ecdt_setup(char *str)
999 acpi_fake_ecdt_enabled = 1;
1003 __setup("acpi_fake_ecdt", acpi_fake_ecdt_setup);
1004 static int __init acpi_ec_set_intr_mode(char *str)
1008 if (!get_option(&str, &intr))
1012 acpi_ec_mode = EC_INTR;
1014 acpi_ec_mode = EC_POLL;
1016 acpi_ec_driver.ops.add = acpi_ec_add;
1017 printk(KERN_NOTICE PREFIX "%s mode.\n",
1018 intr ? "interrupt" : "polling");
1023 __setup("ec_intr=", acpi_ec_set_intr_mode);