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"
50 #define PREFIX "ACPI: EC: "
52 /* EC status register */
53 #define ACPI_EC_FLAG_OBF 0x01 /* Output buffer full */
54 #define ACPI_EC_FLAG_IBF 0x02 /* Input buffer full */
55 #define ACPI_EC_FLAG_BURST 0x10 /* burst mode */
56 #define ACPI_EC_FLAG_SCI 0x20 /* EC-SCI occurred */
59 #define ACPI_EC_COMMAND_READ 0x80
60 #define ACPI_EC_COMMAND_WRITE 0x81
61 #define ACPI_EC_BURST_ENABLE 0x82
62 #define ACPI_EC_BURST_DISABLE 0x83
63 #define ACPI_EC_COMMAND_QUERY 0x84
67 ACPI_EC_EVENT_OBF_1 = 1, /* Output buffer full */
68 ACPI_EC_EVENT_IBF_0, /* Input buffer empty */
71 #define ACPI_EC_DELAY 500 /* Wait 500ms max. during EC ops */
72 #define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */
75 EC_INTR = 1, /* Output buffer full */
76 EC_POLL, /* Input buffer empty */
79 static int acpi_ec_remove(struct acpi_device *device, int type);
80 static int acpi_ec_start(struct acpi_device *device);
81 static int acpi_ec_stop(struct acpi_device *device, int type);
82 static int acpi_ec_add(struct acpi_device *device);
84 static struct acpi_driver acpi_ec_driver = {
85 .name = ACPI_EC_DRIVER_NAME,
86 .class = ACPI_EC_CLASS,
90 .remove = acpi_ec_remove,
91 .start = acpi_ec_start,
96 /* If we find an EC via the ECDT, we need to keep a ptr to its context */
101 unsigned long command_addr;
102 unsigned long data_addr;
103 unsigned long global_lock;
105 atomic_t query_pending;
106 atomic_t leaving_burst; /* 0 : No, 1 : Yes, 2: abort */
107 wait_queue_head_t wait;
110 /* External interfaces use first EC only, so remember */
111 static struct acpi_device *first_ec;
112 static int acpi_ec_mode = EC_INTR;
114 /* --------------------------------------------------------------------------
115 Transaction Management
116 -------------------------------------------------------------------------- */
118 static inline u8 acpi_ec_read_status(struct acpi_ec *ec)
120 return inb(ec->command_addr);
123 static inline u8 acpi_ec_read_data(struct acpi_ec *ec)
125 return inb(ec->data_addr);
128 static inline void acpi_ec_write_cmd(struct acpi_ec *ec, u8 command)
130 outb(command, ec->command_addr);
133 static inline void acpi_ec_write_data(struct acpi_ec *ec, u8 data)
135 outb(data, ec->data_addr);
138 static int acpi_ec_check_status(struct acpi_ec *ec, u8 event)
140 u8 status = acpi_ec_read_status(ec);
142 case ACPI_EC_EVENT_OBF_1:
143 if (status & ACPI_EC_FLAG_OBF)
146 case ACPI_EC_EVENT_IBF_0:
147 if (!(status & ACPI_EC_FLAG_IBF))
157 static int acpi_ec_wait(struct acpi_ec *ec, u8 event)
159 if (acpi_ec_mode == EC_POLL) {
160 unsigned long delay = jiffies + msecs_to_jiffies(ACPI_EC_DELAY);
161 while (time_before(jiffies, delay)) {
162 if (acpi_ec_check_status(ec, event))
166 if (wait_event_timeout(ec->wait,
167 acpi_ec_check_status(ec, event),
168 msecs_to_jiffies(ACPI_EC_DELAY)) ||
169 acpi_ec_check_status(ec, event)) {
172 printk(KERN_ERR PREFIX "acpi_ec_wait timeout,"
173 " status = %d, expect_event = %d\n",
174 acpi_ec_read_status(ec), event);
181 #ifdef ACPI_FUTURE_USAGE
183 * Note: samsung nv5000 doesn't work with ec burst mode.
184 * http://bugzilla.kernel.org/show_bug.cgi?id=4980
186 int acpi_ec_enter_burst_mode(struct acpi_ec *ec)
192 status = acpi_ec_read_status(ec);
193 if (status != -EINVAL && !(status & ACPI_EC_FLAG_BURST)) {
194 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
197 acpi_ec_write_cmd(ec, ACPI_EC_BURST_ENABLE);
198 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1);
199 tmp = acpi_ec_read_data(ec);
200 if (tmp != 0x90) { /* Burst ACK byte */
205 atomic_set(&ec->leaving_burst, 0);
208 ACPI_EXCEPTION((AE_INFO, status, "EC wait, burst mode"));
212 int acpi_ec_leave_burst_mode(struct acpi_ec *ec)
217 status = acpi_ec_read_status(ec);
218 if (status != -EINVAL && (status & ACPI_EC_FLAG_BURST)){
219 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
222 acpi_ec_write_cmd(ec, ACPI_EC_BURST_DISABLE);
223 acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
225 atomic_set(&ec->leaving_burst, 1);
228 ACPI_EXCEPTION((AE_INFO, status, "EC leave burst mode"));
231 #endif /* ACPI_FUTURE_USAGE */
233 static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command,
234 const u8 *wdata, unsigned wdata_len,
235 u8 *rdata, unsigned rdata_len)
239 acpi_ec_write_cmd(ec, command);
241 for (; wdata_len > 0; wdata_len --) {
242 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
244 printk(KERN_ERR PREFIX "write_cmd timeout, command = %d\n",
248 acpi_ec_write_data(ec, *(wdata++));
252 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
254 printk(KERN_ERR PREFIX "finish-write timeout, command = %d\n",
258 } else if (command == ACPI_EC_COMMAND_QUERY) {
259 atomic_set(&ec->query_pending, 0);
262 for (; rdata_len > 0; rdata_len --) {
263 result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1);
265 printk(KERN_ERR PREFIX "read timeout, command = %d\n",
270 *(rdata++) = acpi_ec_read_data(ec);
276 static int acpi_ec_transaction(struct acpi_ec *ec, u8 command,
277 const u8 *wdata, unsigned wdata_len,
278 u8 *rdata, unsigned rdata_len)
283 if (!ec || (wdata_len && !wdata) || (rdata_len && !rdata))
287 memset(rdata, 0, rdata_len);
289 if (ec->global_lock) {
290 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
291 if (ACPI_FAILURE(status))
294 mutex_lock(&ec->lock);
296 /* Make sure GPE is enabled before doing transaction */
297 acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR);
299 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
301 printk(KERN_DEBUG PREFIX "read EC, IB not empty\n");
305 status = acpi_ec_transaction_unlocked(ec, command,
310 mutex_unlock(&ec->lock);
313 acpi_release_global_lock(glk);
318 static int acpi_ec_read(struct acpi_ec *ec, u8 address, u8 *data)
323 result = acpi_ec_transaction(ec, ACPI_EC_COMMAND_READ,
329 static int acpi_ec_write(struct acpi_ec *ec, u8 address, u8 data)
331 u8 wdata[2] = { address, data };
332 return acpi_ec_transaction(ec, ACPI_EC_COMMAND_WRITE,
337 * Externally callable EC access functions. For now, assume 1 EC only
339 int ec_read(u8 addr, u8 *val)
348 ec = acpi_driver_data(first_ec);
350 err = acpi_ec_read(ec, addr, &temp_data);
359 EXPORT_SYMBOL(ec_read);
361 int ec_write(u8 addr, u8 val)
369 ec = acpi_driver_data(first_ec);
371 err = acpi_ec_write(ec, addr, val);
376 EXPORT_SYMBOL(ec_write);
378 extern int ec_transaction(u8 command,
379 const u8 *wdata, unsigned wdata_len,
380 u8 *rdata, unsigned rdata_len)
387 ec = acpi_driver_data(first_ec);
389 return acpi_ec_transaction(ec, command, wdata,
390 wdata_len, rdata, rdata_len);
393 EXPORT_SYMBOL(ec_transaction);
395 static int acpi_ec_query(struct acpi_ec *ec, u8 *data)
404 * Query the EC to find out which _Qxx method we need to evaluate.
405 * Note that successful completion of the query causes the ACPI_EC_SCI
406 * bit to be cleared (and thus clearing the interrupt source).
409 result = acpi_ec_transaction(ec, ACPI_EC_COMMAND_QUERY, NULL, 0, &d, 1);
420 /* --------------------------------------------------------------------------
422 -------------------------------------------------------------------------- */
424 static void acpi_ec_gpe_query(void *ec_cxt)
426 struct acpi_ec *ec = (struct acpi_ec *)ec_cxt;
430 if (!ec || acpi_ec_query(ec, &value))
433 snprintf(object_name, 8, "_Q%2.2X", value);
435 printk(KERN_INFO PREFIX "evaluating %s\n", object_name);
437 acpi_evaluate_object(ec->handle, object_name, NULL, NULL);
440 static u32 acpi_ec_gpe_handler(void *data)
442 acpi_status status = AE_OK;
444 struct acpi_ec *ec = (struct acpi_ec *)data;
447 if (acpi_ec_mode == EC_INTR) {
451 value = acpi_ec_read_status(ec);
452 if ((value & ACPI_EC_FLAG_SCI) && !atomic_read(&ec->query_pending)) {
453 atomic_set(&ec->query_pending, 1);
454 status = acpi_os_execute(OSL_EC_BURST_HANDLER, acpi_ec_gpe_query, ec);
457 return status == AE_OK ?
458 ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED;
461 /* --------------------------------------------------------------------------
462 Address Space Management
463 -------------------------------------------------------------------------- */
466 acpi_ec_space_setup(acpi_handle region_handle,
467 u32 function, void *handler_context, void **return_context)
470 * The EC object is in the handler context and is needed
471 * when calling the acpi_ec_space_handler.
473 *return_context = (function != ACPI_REGION_DEACTIVATE) ?
474 handler_context : NULL;
480 acpi_ec_space_handler(u32 function,
481 acpi_physical_address address,
483 acpi_integer * value,
484 void *handler_context, void *region_context)
487 struct acpi_ec *ec = NULL;
489 acpi_integer f_v = 0;
493 if ((address > 0xFF) || !value || !handler_context)
494 return AE_BAD_PARAMETER;
496 if (bit_width != 8 && acpi_strict) {
497 return AE_BAD_PARAMETER;
500 ec = (struct acpi_ec *)handler_context;
506 result = acpi_ec_read(ec, (u8) address, (u8 *) &temp);
509 result = acpi_ec_write(ec, (u8) address, (u8) temp);
519 if (function == ACPI_READ)
520 f_v |= temp << 8 * i;
521 if (function == ACPI_WRITE)
528 if (function == ACPI_READ) {
529 f_v |= temp << 8 * i;
536 return AE_BAD_PARAMETER;
549 /* --------------------------------------------------------------------------
551 -------------------------------------------------------------------------- */
553 static struct proc_dir_entry *acpi_ec_dir;
555 static int acpi_ec_read_info(struct seq_file *seq, void *offset)
557 struct acpi_ec *ec = (struct acpi_ec *)seq->private;
563 seq_printf(seq, "gpe: 0x%02x\n",
565 seq_printf(seq, "ports: 0x%02x, 0x%02x\n",
566 (u32) ec->command_addr,
567 (u32) ec->data_addr);
568 seq_printf(seq, "use global lock: %s\n",
569 ec->global_lock ? "yes" : "no");
570 acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR);
576 static int acpi_ec_info_open_fs(struct inode *inode, struct file *file)
578 return single_open(file, acpi_ec_read_info, PDE(inode)->data);
581 static struct file_operations acpi_ec_info_ops = {
582 .open = acpi_ec_info_open_fs,
585 .release = single_release,
586 .owner = THIS_MODULE,
589 static int acpi_ec_add_fs(struct acpi_device *device)
591 struct proc_dir_entry *entry = NULL;
594 if (!acpi_device_dir(device)) {
595 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
597 if (!acpi_device_dir(device))
601 entry = create_proc_entry(ACPI_EC_FILE_INFO, S_IRUGO,
602 acpi_device_dir(device));
606 entry->proc_fops = &acpi_ec_info_ops;
607 entry->data = acpi_driver_data(device);
608 entry->owner = THIS_MODULE;
614 static int acpi_ec_remove_fs(struct acpi_device *device)
617 if (acpi_device_dir(device)) {
618 remove_proc_entry(ACPI_EC_FILE_INFO, acpi_device_dir(device));
619 remove_proc_entry(acpi_device_bid(device), acpi_ec_dir);
620 acpi_device_dir(device) = NULL;
626 /* --------------------------------------------------------------------------
628 -------------------------------------------------------------------------- */
630 static int acpi_ec_add(struct acpi_device *device)
633 acpi_status status = AE_OK;
634 struct acpi_ec *ec = NULL;
640 ec = kmalloc(sizeof(struct acpi_ec), GFP_KERNEL);
643 memset(ec, 0, sizeof(struct acpi_ec));
645 ec->handle = device->handle;
647 mutex_init(&ec->lock);
648 atomic_set(&ec->query_pending, 0);
649 if (acpi_ec_mode == EC_INTR) {
650 atomic_set(&ec->leaving_burst, 1);
651 init_waitqueue_head(&ec->wait);
653 strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME);
654 strcpy(acpi_device_class(device), ACPI_EC_CLASS);
655 acpi_driver_data(device) = ec;
657 /* Use the global lock for all EC transactions? */
658 acpi_evaluate_integer(ec->handle, "_GLK", NULL,
661 /* XXX we don't test uids, because on some boxes ecdt uid = 0, see:
662 http://bugzilla.kernel.org/show_bug.cgi?id=6111 */
664 acpi_remove_address_space_handler(ACPI_ROOT_OBJECT,
666 &acpi_ec_space_handler);
668 acpi_remove_gpe_handler(NULL, ec_ecdt->gpe,
669 &acpi_ec_gpe_handler);
674 /* Get GPE bit assignment (EC events). */
675 /* TODO: Add support for _GPE returning a package */
677 acpi_evaluate_integer(ec->handle, "_GPE", NULL,
679 if (ACPI_FAILURE(status)) {
680 ACPI_EXCEPTION((AE_INFO, status, "Obtaining GPE bit assignment"));
685 result = acpi_ec_add_fs(device);
689 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s [%s] (gpe %d) interrupt mode.",
690 acpi_device_name(device), acpi_device_bid(device),
703 static int acpi_ec_remove(struct acpi_device *device, int type)
705 struct acpi_ec *ec = NULL;
711 ec = acpi_driver_data(device);
713 acpi_ec_remove_fs(device);
721 acpi_ec_io_ports(struct acpi_resource *resource, void *context)
723 struct acpi_ec *ec = (struct acpi_ec *)context;
725 if (resource->type != ACPI_RESOURCE_TYPE_IO) {
730 * The first address region returned is the data port, and
731 * the second address region returned is the status/command
734 if (ec->data_addr == 0) {
735 ec->data_addr = resource->data.io.minimum;
736 } else if (ec->command_addr == 0) {
737 ec->command_addr = resource->data.io.minimum;
739 return AE_CTRL_TERMINATE;
745 static int acpi_ec_start(struct acpi_device *device)
747 acpi_status status = AE_OK;
748 struct acpi_ec *ec = NULL;
754 ec = acpi_driver_data(device);
760 * Get I/O port addresses. Convert to GAS format.
762 status = acpi_walk_resources(ec->handle, METHOD_NAME__CRS,
763 acpi_ec_io_ports, ec);
764 if (ACPI_FAILURE(status) || ec->command_addr == 0) {
765 ACPI_EXCEPTION((AE_INFO, status,
766 "Error getting I/O port addresses"));
770 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "gpe=0x%02lx, ports=0x%2lx,0x%2lx",
771 ec->gpe, ec->command_addr, ec->data_addr));
774 * Install GPE handler
776 status = acpi_install_gpe_handler(NULL, ec->gpe,
777 ACPI_GPE_EDGE_TRIGGERED,
778 &acpi_ec_gpe_handler, ec);
779 if (ACPI_FAILURE(status)) {
782 acpi_set_gpe_type(NULL, ec->gpe, ACPI_GPE_TYPE_RUNTIME);
783 acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR);
785 status = acpi_install_address_space_handler(ec->handle,
787 &acpi_ec_space_handler,
788 &acpi_ec_space_setup, ec);
789 if (ACPI_FAILURE(status)) {
790 acpi_remove_gpe_handler(NULL, ec->gpe,
791 &acpi_ec_gpe_handler);
798 static int acpi_ec_stop(struct acpi_device *device, int type)
800 acpi_status status = AE_OK;
801 struct acpi_ec *ec = NULL;
807 ec = acpi_driver_data(device);
809 status = acpi_remove_address_space_handler(ec->handle,
811 &acpi_ec_space_handler);
812 if (ACPI_FAILURE(status))
816 acpi_remove_gpe_handler(NULL, ec->gpe,
817 &acpi_ec_gpe_handler);
818 if (ACPI_FAILURE(status))
824 static acpi_status __init
825 acpi_fake_ecdt_callback(acpi_handle handle,
826 u32 Level, void *context, void **retval)
830 mutex_init(&ec_ecdt->lock);
831 if (acpi_ec_mode == EC_INTR) {
832 init_waitqueue_head(&ec_ecdt->wait);
834 status = acpi_walk_resources(handle, METHOD_NAME__CRS,
835 acpi_ec_io_ports, ec_ecdt);
836 if (ACPI_FAILURE(status))
840 acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->uid);
843 acpi_evaluate_integer(handle, "_GPE", NULL,
845 if (ACPI_FAILURE(status))
847 ec_ecdt->global_lock = TRUE;
848 ec_ecdt->handle = handle;
850 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "GPE=0x%02lx, ports=0x%2lx, 0x%2lx",
851 ec_ecdt->gpe, ec_ecdt->command_addr, ec_ecdt->data_addr));
853 return AE_CTRL_TERMINATE;
857 * Some BIOS (such as some from Gateway laptops) access EC region very early
858 * such as in BAT0._INI or EC._INI before an EC device is found and
859 * do not provide an ECDT. According to ACPI spec, ECDT isn't mandatorily
860 * required, but if EC regison is accessed early, it is required.
861 * The routine tries to workaround the BIOS bug by pre-scan EC device
862 * It assumes that _CRS, _HID, _GPE, _UID methods of EC don't touch any
863 * op region (since _REG isn't invoked yet). The assumption is true for
866 static int __init acpi_ec_fake_ecdt(void)
871 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Try to make an fake ECDT"));
873 ec_ecdt = kmalloc(sizeof(struct acpi_ec), GFP_KERNEL);
878 memset(ec_ecdt, 0, sizeof(struct acpi_ec));
880 status = acpi_get_devices(ACPI_EC_HID,
881 acpi_fake_ecdt_callback, NULL, NULL);
882 if (ACPI_FAILURE(status)) {
886 ACPI_EXCEPTION((AE_INFO, status, "Can't make an fake ECDT"));
894 static int __init acpi_ec_get_real_ecdt(void)
897 struct acpi_table_ecdt *ecdt_ptr;
899 status = acpi_get_firmware_table("ECDT", 1, ACPI_LOGICAL_ADDRESSING,
900 (struct acpi_table_header **)
902 if (ACPI_FAILURE(status))
905 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found ECDT"));
908 * Generate a temporary ec context to use until the namespace is scanned
910 ec_ecdt = kmalloc(sizeof(struct acpi_ec), GFP_KERNEL);
913 memset(ec_ecdt, 0, sizeof(struct acpi_ec));
915 mutex_init(&ec_ecdt->lock);
916 if (acpi_ec_mode == EC_INTR) {
917 init_waitqueue_head(&ec_ecdt->wait);
919 ec_ecdt->command_addr = ecdt_ptr->ec_control.address;
920 ec_ecdt->data_addr = ecdt_ptr->ec_data.address;
921 ec_ecdt->gpe = ecdt_ptr->gpe_bit;
922 /* use the GL just to be safe */
923 ec_ecdt->global_lock = TRUE;
924 ec_ecdt->uid = ecdt_ptr->uid;
927 acpi_get_handle(NULL, ecdt_ptr->ec_id, &ec_ecdt->handle);
928 if (ACPI_FAILURE(status)) {
934 ACPI_EXCEPTION((AE_INFO, status, "Could not use ECDT"));
941 static int __initdata acpi_fake_ecdt_enabled;
942 int __init acpi_ec_ecdt_probe(void)
947 ret = acpi_ec_get_real_ecdt();
948 /* Try to make a fake ECDT */
949 if (ret && acpi_fake_ecdt_enabled) {
950 ret = acpi_ec_fake_ecdt();
957 * Install GPE handler
959 status = acpi_install_gpe_handler(NULL, ec_ecdt->gpe,
960 ACPI_GPE_EDGE_TRIGGERED,
961 &acpi_ec_gpe_handler, ec_ecdt);
962 if (ACPI_FAILURE(status)) {
965 acpi_set_gpe_type(NULL, ec_ecdt->gpe, ACPI_GPE_TYPE_RUNTIME);
966 acpi_enable_gpe(NULL, ec_ecdt->gpe, ACPI_NOT_ISR);
968 status = acpi_install_address_space_handler(ACPI_ROOT_OBJECT,
970 &acpi_ec_space_handler,
971 &acpi_ec_space_setup,
973 if (ACPI_FAILURE(status)) {
974 acpi_remove_gpe_handler(NULL, ec_ecdt->gpe,
975 &acpi_ec_gpe_handler);
982 ACPI_EXCEPTION((AE_INFO, status, "Could not use ECDT"));
989 static int __init acpi_ec_init(void)
997 acpi_ec_dir = proc_mkdir(ACPI_EC_CLASS, acpi_root_dir);
1001 /* Now register the driver for the EC */
1002 result = acpi_bus_register_driver(&acpi_ec_driver);
1004 remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir);
1011 subsys_initcall(acpi_ec_init);
1013 /* EC driver currently not unloadable */
1015 static void __exit acpi_ec_exit(void)
1018 acpi_bus_unregister_driver(&acpi_ec_driver);
1020 remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir);
1026 static int __init acpi_fake_ecdt_setup(char *str)
1028 acpi_fake_ecdt_enabled = 1;
1032 __setup("acpi_fake_ecdt", acpi_fake_ecdt_setup);
1033 static int __init acpi_ec_set_intr_mode(char *str)
1037 if (!get_option(&str, &intr))
1041 acpi_ec_mode = EC_INTR;
1043 acpi_ec_mode = EC_POLL;
1045 acpi_ec_driver.ops.add = acpi_ec_add;
1046 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "EC %s mode.\n", intr ? "interrupt" : "polling"));
1051 __setup("ec_intr=", acpi_ec_set_intr_mode);