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 inline int acpi_ec_check_status(struct acpi_ec *ec, u8 event)
140 u8 status = acpi_ec_read_status(ec);
142 if (event == ACPI_EC_EVENT_OBF_1) {
143 if (status & ACPI_EC_FLAG_OBF)
145 } else if (event == ACPI_EC_EVENT_IBF_0) {
146 if (!(status & ACPI_EC_FLAG_IBF))
153 static int acpi_ec_wait(struct acpi_ec *ec, u8 event)
155 if (acpi_ec_mode == EC_POLL) {
156 unsigned long delay = jiffies + msecs_to_jiffies(ACPI_EC_DELAY);
157 while (time_before(jiffies, delay)) {
158 if (acpi_ec_check_status(ec, event))
162 if (wait_event_timeout(ec->wait,
163 acpi_ec_check_status(ec, event),
164 msecs_to_jiffies(ACPI_EC_DELAY)) ||
165 acpi_ec_check_status(ec, event)) {
168 printk(KERN_ERR PREFIX "acpi_ec_wait timeout,"
169 " status = %d, expect_event = %d\n",
170 acpi_ec_read_status(ec), event);
177 #ifdef ACPI_FUTURE_USAGE
179 * Note: samsung nv5000 doesn't work with ec burst mode.
180 * http://bugzilla.kernel.org/show_bug.cgi?id=4980
182 int acpi_ec_enter_burst_mode(struct acpi_ec *ec)
188 status = acpi_ec_read_status(ec);
189 if (status != -EINVAL && !(status & ACPI_EC_FLAG_BURST)) {
190 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
193 acpi_ec_write_cmd(ec, ACPI_EC_BURST_ENABLE);
194 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1);
195 tmp = acpi_ec_read_data(ec);
196 if (tmp != 0x90) { /* Burst ACK byte */
201 atomic_set(&ec->leaving_burst, 0);
204 ACPI_EXCEPTION((AE_INFO, status, "EC wait, burst mode"));
208 int acpi_ec_leave_burst_mode(struct acpi_ec *ec)
213 status = acpi_ec_read_status(ec);
214 if (status != -EINVAL && (status & ACPI_EC_FLAG_BURST)){
215 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
218 acpi_ec_write_cmd(ec, ACPI_EC_BURST_DISABLE);
219 acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
221 atomic_set(&ec->leaving_burst, 1);
224 ACPI_EXCEPTION((AE_INFO, status, "EC leave burst mode"));
227 #endif /* ACPI_FUTURE_USAGE */
229 static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command,
230 const u8 *wdata, unsigned wdata_len,
231 u8 *rdata, unsigned rdata_len)
235 acpi_ec_write_cmd(ec, command);
237 for (; wdata_len > 0; --wdata_len) {
238 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
240 printk(KERN_ERR PREFIX "write_cmd timeout, command = %d\n",
244 acpi_ec_write_data(ec, *(wdata++));
248 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
250 printk(KERN_ERR PREFIX "finish-write timeout, command = %d\n",
254 } else if (command == ACPI_EC_COMMAND_QUERY) {
255 atomic_set(&ec->query_pending, 0);
258 for (; rdata_len > 0; --rdata_len) {
259 result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1);
261 printk(KERN_ERR PREFIX "read timeout, command = %d\n",
266 *(rdata++) = acpi_ec_read_data(ec);
272 static int acpi_ec_transaction(struct acpi_ec *ec, u8 command,
273 const u8 *wdata, unsigned wdata_len,
274 u8 *rdata, unsigned rdata_len)
279 if (!ec || (wdata_len && !wdata) || (rdata_len && !rdata))
283 memset(rdata, 0, rdata_len);
285 mutex_lock(&ec->lock);
286 if (ec->global_lock) {
287 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
288 if (ACPI_FAILURE(status))
292 /* Make sure GPE is enabled before doing transaction */
293 acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR);
295 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
297 printk(KERN_DEBUG PREFIX "read EC, IB not empty\n");
301 status = acpi_ec_transaction_unlocked(ec, command,
308 acpi_release_global_lock(glk);
309 mutex_unlock(&ec->lock);
314 static int acpi_ec_read(struct acpi_ec *ec, u8 address, u8 *data)
319 result = acpi_ec_transaction(ec, ACPI_EC_COMMAND_READ,
325 static int acpi_ec_write(struct acpi_ec *ec, u8 address, u8 data)
327 u8 wdata[2] = { address, data };
328 return acpi_ec_transaction(ec, ACPI_EC_COMMAND_WRITE,
333 * Externally callable EC access functions. For now, assume 1 EC only
335 int ec_read(u8 addr, u8 *val)
344 ec = acpi_driver_data(first_ec);
346 err = acpi_ec_read(ec, addr, &temp_data);
355 EXPORT_SYMBOL(ec_read);
357 int ec_write(u8 addr, u8 val)
365 ec = acpi_driver_data(first_ec);
367 err = acpi_ec_write(ec, addr, val);
372 EXPORT_SYMBOL(ec_write);
374 extern int ec_transaction(u8 command,
375 const u8 *wdata, unsigned wdata_len,
376 u8 *rdata, unsigned rdata_len)
383 ec = acpi_driver_data(first_ec);
385 return acpi_ec_transaction(ec, command, wdata,
386 wdata_len, rdata, rdata_len);
389 EXPORT_SYMBOL(ec_transaction);
391 static int acpi_ec_query(struct acpi_ec *ec, u8 *data)
400 * Query the EC to find out which _Qxx method we need to evaluate.
401 * Note that successful completion of the query causes the ACPI_EC_SCI
402 * bit to be cleared (and thus clearing the interrupt source).
405 result = acpi_ec_transaction(ec, ACPI_EC_COMMAND_QUERY, NULL, 0, &d, 1);
416 /* --------------------------------------------------------------------------
418 -------------------------------------------------------------------------- */
420 static void acpi_ec_gpe_query(void *ec_cxt)
422 struct acpi_ec *ec = (struct acpi_ec *)ec_cxt;
426 if (!ec || acpi_ec_query(ec, &value))
429 snprintf(object_name, 8, "_Q%2.2X", value);
431 printk(KERN_INFO PREFIX "evaluating %s\n", object_name);
433 acpi_evaluate_object(ec->handle, object_name, NULL, NULL);
436 static u32 acpi_ec_gpe_handler(void *data)
438 acpi_status status = AE_OK;
440 struct acpi_ec *ec = (struct acpi_ec *)data;
443 if (acpi_ec_mode == EC_INTR) {
447 value = acpi_ec_read_status(ec);
448 if ((value & ACPI_EC_FLAG_SCI) && !atomic_read(&ec->query_pending)) {
449 atomic_set(&ec->query_pending, 1);
450 status = acpi_os_execute(OSL_EC_BURST_HANDLER, acpi_ec_gpe_query, ec);
453 return status == AE_OK ?
454 ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED;
457 /* --------------------------------------------------------------------------
458 Address Space Management
459 -------------------------------------------------------------------------- */
462 acpi_ec_space_setup(acpi_handle region_handle,
463 u32 function, void *handler_context, void **return_context)
466 * The EC object is in the handler context and is needed
467 * when calling the acpi_ec_space_handler.
469 *return_context = (function != ACPI_REGION_DEACTIVATE) ?
470 handler_context : NULL;
476 acpi_ec_space_handler(u32 function,
477 acpi_physical_address address,
479 acpi_integer * value,
480 void *handler_context, void *region_context)
483 struct acpi_ec *ec = NULL;
485 acpi_integer f_v = 0;
489 if ((address > 0xFF) || !value || !handler_context)
490 return AE_BAD_PARAMETER;
492 if (bit_width != 8 && acpi_strict) {
493 return AE_BAD_PARAMETER;
496 ec = (struct acpi_ec *)handler_context;
502 result = acpi_ec_read(ec, (u8) address, (u8 *) &temp);
505 result = acpi_ec_write(ec, (u8) address, (u8) temp);
515 if (function == ACPI_READ)
516 f_v |= temp << 8 * i;
517 if (function == ACPI_WRITE)
524 if (function == ACPI_READ) {
525 f_v |= temp << 8 * i;
532 return AE_BAD_PARAMETER;
545 /* --------------------------------------------------------------------------
547 -------------------------------------------------------------------------- */
549 static struct proc_dir_entry *acpi_ec_dir;
551 static int acpi_ec_read_info(struct seq_file *seq, void *offset)
553 struct acpi_ec *ec = (struct acpi_ec *)seq->private;
559 seq_printf(seq, "gpe: 0x%02x\n",
561 seq_printf(seq, "ports: 0x%02x, 0x%02x\n",
562 (u32) ec->command_addr,
563 (u32) ec->data_addr);
564 seq_printf(seq, "use global lock: %s\n",
565 ec->global_lock ? "yes" : "no");
566 acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR);
572 static int acpi_ec_info_open_fs(struct inode *inode, struct file *file)
574 return single_open(file, acpi_ec_read_info, PDE(inode)->data);
577 static struct file_operations acpi_ec_info_ops = {
578 .open = acpi_ec_info_open_fs,
581 .release = single_release,
582 .owner = THIS_MODULE,
585 static int acpi_ec_add_fs(struct acpi_device *device)
587 struct proc_dir_entry *entry = NULL;
590 if (!acpi_device_dir(device)) {
591 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
593 if (!acpi_device_dir(device))
597 entry = create_proc_entry(ACPI_EC_FILE_INFO, S_IRUGO,
598 acpi_device_dir(device));
602 entry->proc_fops = &acpi_ec_info_ops;
603 entry->data = acpi_driver_data(device);
604 entry->owner = THIS_MODULE;
610 static int acpi_ec_remove_fs(struct acpi_device *device)
613 if (acpi_device_dir(device)) {
614 remove_proc_entry(ACPI_EC_FILE_INFO, acpi_device_dir(device));
615 remove_proc_entry(acpi_device_bid(device), acpi_ec_dir);
616 acpi_device_dir(device) = NULL;
622 /* --------------------------------------------------------------------------
624 -------------------------------------------------------------------------- */
626 static int acpi_ec_add(struct acpi_device *device)
629 acpi_status status = AE_OK;
630 struct acpi_ec *ec = NULL;
636 ec = kmalloc(sizeof(struct acpi_ec), GFP_KERNEL);
639 memset(ec, 0, sizeof(struct acpi_ec));
641 ec->handle = device->handle;
643 mutex_init(&ec->lock);
644 atomic_set(&ec->query_pending, 0);
645 if (acpi_ec_mode == EC_INTR) {
646 atomic_set(&ec->leaving_burst, 1);
647 init_waitqueue_head(&ec->wait);
649 strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME);
650 strcpy(acpi_device_class(device), ACPI_EC_CLASS);
651 acpi_driver_data(device) = ec;
653 /* Use the global lock for all EC transactions? */
654 acpi_evaluate_integer(ec->handle, "_GLK", NULL,
657 /* XXX we don't test uids, because on some boxes ecdt uid = 0, see:
658 http://bugzilla.kernel.org/show_bug.cgi?id=6111 */
660 acpi_remove_address_space_handler(ACPI_ROOT_OBJECT,
662 &acpi_ec_space_handler);
664 acpi_remove_gpe_handler(NULL, ec_ecdt->gpe,
665 &acpi_ec_gpe_handler);
670 /* Get GPE bit assignment (EC events). */
671 /* TODO: Add support for _GPE returning a package */
673 acpi_evaluate_integer(ec->handle, "_GPE", NULL,
675 if (ACPI_FAILURE(status)) {
676 ACPI_EXCEPTION((AE_INFO, status, "Obtaining GPE bit assignment"));
681 result = acpi_ec_add_fs(device);
685 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s [%s] (gpe %d) interrupt mode.",
686 acpi_device_name(device), acpi_device_bid(device),
699 static int acpi_ec_remove(struct acpi_device *device, int type)
701 struct acpi_ec *ec = NULL;
707 ec = acpi_driver_data(device);
709 acpi_ec_remove_fs(device);
717 acpi_ec_io_ports(struct acpi_resource *resource, void *context)
719 struct acpi_ec *ec = (struct acpi_ec *)context;
721 if (resource->type != ACPI_RESOURCE_TYPE_IO) {
726 * The first address region returned is the data port, and
727 * the second address region returned is the status/command
730 if (ec->data_addr == 0) {
731 ec->data_addr = resource->data.io.minimum;
732 } else if (ec->command_addr == 0) {
733 ec->command_addr = resource->data.io.minimum;
735 return AE_CTRL_TERMINATE;
741 static int acpi_ec_start(struct acpi_device *device)
743 acpi_status status = AE_OK;
744 struct acpi_ec *ec = NULL;
750 ec = acpi_driver_data(device);
756 * Get I/O port addresses. Convert to GAS format.
758 status = acpi_walk_resources(ec->handle, METHOD_NAME__CRS,
759 acpi_ec_io_ports, ec);
760 if (ACPI_FAILURE(status) || ec->command_addr == 0) {
761 ACPI_EXCEPTION((AE_INFO, status,
762 "Error getting I/O port addresses"));
766 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "gpe=0x%02lx, ports=0x%2lx,0x%2lx",
767 ec->gpe, ec->command_addr, ec->data_addr));
770 * Install GPE handler
772 status = acpi_install_gpe_handler(NULL, ec->gpe,
773 ACPI_GPE_EDGE_TRIGGERED,
774 &acpi_ec_gpe_handler, ec);
775 if (ACPI_FAILURE(status)) {
778 acpi_set_gpe_type(NULL, ec->gpe, ACPI_GPE_TYPE_RUNTIME);
779 acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR);
781 status = acpi_install_address_space_handler(ec->handle,
783 &acpi_ec_space_handler,
784 &acpi_ec_space_setup, ec);
785 if (ACPI_FAILURE(status)) {
786 acpi_remove_gpe_handler(NULL, ec->gpe,
787 &acpi_ec_gpe_handler);
794 static int acpi_ec_stop(struct acpi_device *device, int type)
796 acpi_status status = AE_OK;
797 struct acpi_ec *ec = NULL;
803 ec = acpi_driver_data(device);
805 status = acpi_remove_address_space_handler(ec->handle,
807 &acpi_ec_space_handler);
808 if (ACPI_FAILURE(status))
812 acpi_remove_gpe_handler(NULL, ec->gpe,
813 &acpi_ec_gpe_handler);
814 if (ACPI_FAILURE(status))
820 static acpi_status __init
821 acpi_fake_ecdt_callback(acpi_handle handle,
822 u32 Level, void *context, void **retval)
826 mutex_init(&ec_ecdt->lock);
827 if (acpi_ec_mode == EC_INTR) {
828 init_waitqueue_head(&ec_ecdt->wait);
830 status = acpi_walk_resources(handle, METHOD_NAME__CRS,
831 acpi_ec_io_ports, ec_ecdt);
832 if (ACPI_FAILURE(status))
836 acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->uid);
839 acpi_evaluate_integer(handle, "_GPE", NULL,
841 if (ACPI_FAILURE(status))
843 ec_ecdt->global_lock = TRUE;
844 ec_ecdt->handle = handle;
846 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "GPE=0x%02lx, ports=0x%2lx, 0x%2lx",
847 ec_ecdt->gpe, ec_ecdt->command_addr, ec_ecdt->data_addr));
849 return AE_CTRL_TERMINATE;
853 * Some BIOS (such as some from Gateway laptops) access EC region very early
854 * such as in BAT0._INI or EC._INI before an EC device is found and
855 * do not provide an ECDT. According to ACPI spec, ECDT isn't mandatorily
856 * required, but if EC regison is accessed early, it is required.
857 * The routine tries to workaround the BIOS bug by pre-scan EC device
858 * It assumes that _CRS, _HID, _GPE, _UID methods of EC don't touch any
859 * op region (since _REG isn't invoked yet). The assumption is true for
862 static int __init acpi_ec_fake_ecdt(void)
867 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Try to make an fake ECDT"));
869 ec_ecdt = kmalloc(sizeof(struct acpi_ec), GFP_KERNEL);
874 memset(ec_ecdt, 0, sizeof(struct acpi_ec));
876 status = acpi_get_devices(ACPI_EC_HID,
877 acpi_fake_ecdt_callback, NULL, NULL);
878 if (ACPI_FAILURE(status)) {
882 ACPI_EXCEPTION((AE_INFO, status, "Can't make an fake ECDT"));
890 static int __init acpi_ec_get_real_ecdt(void)
893 struct acpi_table_ecdt *ecdt_ptr;
895 status = acpi_get_firmware_table("ECDT", 1, ACPI_LOGICAL_ADDRESSING,
896 (struct acpi_table_header **)
898 if (ACPI_FAILURE(status))
901 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found ECDT"));
904 * Generate a temporary ec context to use until the namespace is scanned
906 ec_ecdt = kmalloc(sizeof(struct acpi_ec), GFP_KERNEL);
909 memset(ec_ecdt, 0, sizeof(struct acpi_ec));
911 mutex_init(&ec_ecdt->lock);
912 if (acpi_ec_mode == EC_INTR) {
913 init_waitqueue_head(&ec_ecdt->wait);
915 ec_ecdt->command_addr = ecdt_ptr->ec_control.address;
916 ec_ecdt->data_addr = ecdt_ptr->ec_data.address;
917 ec_ecdt->gpe = ecdt_ptr->gpe_bit;
918 /* use the GL just to be safe */
919 ec_ecdt->global_lock = TRUE;
920 ec_ecdt->uid = ecdt_ptr->uid;
923 acpi_get_handle(NULL, ecdt_ptr->ec_id, &ec_ecdt->handle);
924 if (ACPI_FAILURE(status)) {
930 ACPI_EXCEPTION((AE_INFO, status, "Could not use ECDT"));
937 static int __initdata acpi_fake_ecdt_enabled;
938 int __init acpi_ec_ecdt_probe(void)
943 ret = acpi_ec_get_real_ecdt();
944 /* Try to make a fake ECDT */
945 if (ret && acpi_fake_ecdt_enabled) {
946 ret = acpi_ec_fake_ecdt();
953 * Install GPE handler
955 status = acpi_install_gpe_handler(NULL, ec_ecdt->gpe,
956 ACPI_GPE_EDGE_TRIGGERED,
957 &acpi_ec_gpe_handler, ec_ecdt);
958 if (ACPI_FAILURE(status)) {
961 acpi_set_gpe_type(NULL, ec_ecdt->gpe, ACPI_GPE_TYPE_RUNTIME);
962 acpi_enable_gpe(NULL, ec_ecdt->gpe, ACPI_NOT_ISR);
964 status = acpi_install_address_space_handler(ACPI_ROOT_OBJECT,
966 &acpi_ec_space_handler,
967 &acpi_ec_space_setup,
969 if (ACPI_FAILURE(status)) {
970 acpi_remove_gpe_handler(NULL, ec_ecdt->gpe,
971 &acpi_ec_gpe_handler);
978 ACPI_EXCEPTION((AE_INFO, status, "Could not use ECDT"));
985 static int __init acpi_ec_init(void)
993 acpi_ec_dir = proc_mkdir(ACPI_EC_CLASS, acpi_root_dir);
997 /* Now register the driver for the EC */
998 result = acpi_bus_register_driver(&acpi_ec_driver);
1000 remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir);
1007 subsys_initcall(acpi_ec_init);
1009 /* EC driver currently not unloadable */
1011 static void __exit acpi_ec_exit(void)
1014 acpi_bus_unregister_driver(&acpi_ec_driver);
1016 remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir);
1022 static int __init acpi_fake_ecdt_setup(char *str)
1024 acpi_fake_ecdt_enabled = 1;
1028 __setup("acpi_fake_ecdt", acpi_fake_ecdt_setup);
1029 static int __init acpi_ec_set_intr_mode(char *str)
1033 if (!get_option(&str, &intr))
1037 acpi_ec_mode = EC_INTR;
1039 acpi_ec_mode = EC_POLL;
1041 acpi_ec_driver.ops.add = acpi_ec_add;
1042 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "EC %s mode.\n", intr ? "interrupt" : "polling"));
1047 __setup("ec_intr=", acpi_ec_set_intr_mode);