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 /* 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 #define ACPI_EC_COMMAND_READ 0x80
57 #define ACPI_EC_COMMAND_WRITE 0x81
58 #define ACPI_EC_BURST_ENABLE 0x82
59 #define ACPI_EC_BURST_DISABLE 0x83
60 #define 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 */
70 #define ACPI_EC_UDELAY 100 /* Poll @ 100us increments */
71 #define ACPI_EC_UDELAY_COUNT 1000 /* Wait 100ms max. during EC ops */
74 EC_INTR = 1, /* Output buffer full */
75 EC_POLL, /* Input buffer empty */
78 static int acpi_ec_remove(struct acpi_device *device, int type);
79 static int acpi_ec_start(struct acpi_device *device);
80 static int acpi_ec_stop(struct acpi_device *device, int type);
81 static int acpi_ec_add(struct acpi_device *device);
83 static struct acpi_driver acpi_ec_driver = {
84 .name = ACPI_EC_DRIVER_NAME,
85 .class = ACPI_EC_CLASS,
89 .remove = acpi_ec_remove,
90 .start = acpi_ec_start,
95 /* If we find an EC via the ECDT, we need to keep a ptr to its context */
99 unsigned long gpe_bit;
100 unsigned long command_addr;
101 unsigned long data_addr;
102 unsigned long global_lock;
103 struct semaphore sem;
104 unsigned int expect_event;
105 atomic_t leaving_burst; /* 0 : No, 1 : Yes, 2: abort */
106 wait_queue_head_t wait;
109 /* External interfaces use first EC only, so remember */
110 static struct acpi_device *first_ec;
111 static int acpi_ec_mode = EC_INTR;
113 /* --------------------------------------------------------------------------
114 Transaction Management
115 -------------------------------------------------------------------------- */
117 static inline u8 acpi_ec_read_status(struct acpi_ec *ec)
119 return inb(ec->command_addr);
122 static inline u8 acpi_ec_read_data(struct acpi_ec *ec)
124 return inb(ec->data_addr);
127 static inline void acpi_ec_write_cmd(struct acpi_ec *ec, u8 command)
129 outb(command, ec->command_addr);
132 static inline void acpi_ec_write_data(struct acpi_ec *ec, u8 data)
134 outb(data, ec->data_addr);
137 static int acpi_ec_check_status(u8 status, u8 event)
140 case ACPI_EC_EVENT_OBF_1:
141 if (status & ACPI_EC_FLAG_OBF)
144 case ACPI_EC_EVENT_IBF_0:
145 if (!(status & ACPI_EC_FLAG_IBF))
155 static int acpi_ec_wait(struct acpi_ec *ec, u8 event)
157 int i = (acpi_ec_mode == EC_POLL) ? ACPI_EC_UDELAY_COUNT : 0;
160 ec->expect_event = event;
161 if (acpi_ec_check_status(acpi_ec_read_status(ec), event)) {
162 ec->expect_event = 0;
167 if (acpi_ec_mode == EC_POLL) {
168 udelay(ACPI_EC_UDELAY);
170 time_left = wait_event_timeout(ec->wait,
172 msecs_to_jiffies(ACPI_EC_DELAY));
174 ec->expect_event = 0;
178 if (acpi_ec_check_status(acpi_ec_read_status(ec), event)) {
179 ec->expect_event = 0;
184 ec->expect_event = 0;
189 #ifdef ACPI_FUTURE_USAGE
191 * Note: samsung nv5000 doesn't work with ec burst mode.
192 * http://bugzilla.kernel.org/show_bug.cgi?id=4980
194 int acpi_ec_enter_burst_mode(struct acpi_ec *ec)
200 status = acpi_ec_read_status(ec);
201 if (status != -EINVAL && !(status & ACPI_EC_FLAG_BURST)) {
202 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
205 acpi_ec_write_cmd(ec, ACPI_EC_BURST_ENABLE);
206 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1);
207 tmp = acpi_ec_read_data(ec);
208 if (tmp != 0x90) { /* Burst ACK byte */
213 atomic_set(&ec->leaving_burst, 0);
216 ACPI_EXCEPTION((AE_INFO, status, "EC wait, burst mode"));
220 int acpi_ec_leave_burst_mode(struct acpi_ec *ec)
225 status = acpi_ec_read_status(ec);
226 if (status != -EINVAL && (status & ACPI_EC_FLAG_BURST)){
227 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
230 acpi_ec_write_cmd(ec, ACPI_EC_BURST_DISABLE);
231 acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
233 atomic_set(&ec->leaving_burst, 1);
236 ACPI_EXCEPTION((AE_INFO, status, "EC leave burst mode"));
239 #endif /* ACPI_FUTURE_USAGE */
241 static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command,
242 const u8 *wdata, unsigned wdata_len,
243 u8 *rdata, unsigned rdata_len)
247 acpi_ec_write_cmd(ec, command);
249 for (; wdata_len > 0; wdata_len --) {
250 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
253 acpi_ec_write_data(ec, *(wdata++));
257 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
262 for (; rdata_len > 0; rdata_len --) {
263 result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1);
267 *(rdata++) = acpi_ec_read_data(ec);
273 static int acpi_ec_transaction(struct acpi_ec *ec, u8 command,
274 const u8 *wdata, unsigned wdata_len,
275 u8 *rdata, unsigned rdata_len)
280 if (!ec || (wdata_len && !wdata) || (rdata_len && !rdata))
284 memset(rdata, 0, rdata_len);
286 if (ec->global_lock) {
287 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
288 if (ACPI_FAILURE(status))
293 /* Make sure GPE is enabled before doing transaction */
294 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR);
296 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
298 printk(KERN_DEBUG PREFIX "read EC, IB not empty\n");
302 status = acpi_ec_transaction_unlocked(ec, command,
310 acpi_release_global_lock(glk);
315 static int acpi_ec_read(struct acpi_ec *ec, u8 address, u8 *data)
320 result = acpi_ec_transaction(ec, ACPI_EC_COMMAND_READ,
326 static int acpi_ec_write(struct acpi_ec *ec, u8 address, u8 data)
328 u8 wdata[2] = { address, data };
329 return acpi_ec_transaction(ec, ACPI_EC_COMMAND_WRITE,
334 * Externally callable EC access functions. For now, assume 1 EC only
336 int ec_read(u8 addr, u8 *val)
345 ec = acpi_driver_data(first_ec);
347 err = acpi_ec_read(ec, addr, &temp_data);
356 EXPORT_SYMBOL(ec_read);
358 int ec_write(u8 addr, u8 val)
366 ec = acpi_driver_data(first_ec);
368 err = acpi_ec_write(ec, addr, val);
373 EXPORT_SYMBOL(ec_write);
375 extern int ec_transaction(u8 command,
376 const u8 *wdata, unsigned wdata_len,
377 u8 *rdata, unsigned rdata_len)
384 ec = acpi_driver_data(first_ec);
386 return acpi_ec_transaction(ec, command, wdata,
387 wdata_len, rdata, rdata_len);
390 EXPORT_SYMBOL(ec_transaction);
392 static int acpi_ec_query(struct acpi_ec *ec, u8 *data)
401 * Query the EC to find out which _Qxx method we need to evaluate.
402 * Note that successful completion of the query causes the ACPI_EC_SCI
403 * bit to be cleared (and thus clearing the interrupt source).
406 result = acpi_ec_transaction(ec, ACPI_EC_COMMAND_QUERY, NULL, 0, &d, 1);
417 /* --------------------------------------------------------------------------
419 -------------------------------------------------------------------------- */
421 struct acpi_ec_query_data {
426 static void acpi_ec_gpe_query(void *ec_cxt)
428 struct acpi_ec *ec = (struct acpi_ec *)ec_cxt;
430 static char object_name[8];
435 value = acpi_ec_read_status(ec);
437 if (!(value & ACPI_EC_FLAG_SCI))
440 if (acpi_ec_query(ec, &value))
443 snprintf(object_name, 8, "_Q%2.2X", value);
445 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluating %s", object_name));
447 acpi_evaluate_object(ec->handle, object_name, NULL, NULL);
450 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR);
453 static u32 acpi_ec_gpe_handler(void *data)
455 acpi_status status = AE_OK;
457 struct acpi_ec *ec = (struct acpi_ec *)data;
459 acpi_clear_gpe(NULL, ec->gpe_bit, ACPI_ISR);
460 value = acpi_ec_read_status(ec);
462 if (acpi_ec_mode == EC_INTR) {
463 if (acpi_ec_check_status(value, ec->expect_event)) {
464 ec->expect_event = 0;
469 if (value & ACPI_EC_FLAG_SCI) {
470 status = acpi_os_execute(OSL_EC_BURST_HANDLER, acpi_ec_gpe_query, ec);
471 return status == AE_OK ?
472 ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED;
474 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_ISR);
475 return status == AE_OK ?
476 ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED;
479 /* --------------------------------------------------------------------------
480 Address Space Management
481 -------------------------------------------------------------------------- */
484 acpi_ec_space_setup(acpi_handle region_handle,
485 u32 function, void *handler_context, void **return_context)
488 * The EC object is in the handler context and is needed
489 * when calling the acpi_ec_space_handler.
491 *return_context = (function != ACPI_REGION_DEACTIVATE) ?
492 handler_context : NULL;
498 acpi_ec_space_handler(u32 function,
499 acpi_physical_address address,
501 acpi_integer * value,
502 void *handler_context, void *region_context)
505 struct acpi_ec *ec = NULL;
507 acpi_integer f_v = 0;
511 if ((address > 0xFF) || !value || !handler_context)
512 return AE_BAD_PARAMETER;
514 if (bit_width != 8 && acpi_strict) {
515 return AE_BAD_PARAMETER;
518 ec = (struct acpi_ec *)handler_context;
524 result = acpi_ec_read(ec, (u8) address, (u8 *) &temp);
527 result = acpi_ec_write(ec, (u8) address, (u8) temp);
537 if (function == ACPI_READ)
538 f_v |= temp << 8 * i;
539 if (function == ACPI_WRITE)
546 if (function == ACPI_READ) {
547 f_v |= temp << 8 * i;
554 return AE_BAD_PARAMETER;
567 /* --------------------------------------------------------------------------
569 -------------------------------------------------------------------------- */
571 static struct proc_dir_entry *acpi_ec_dir;
573 static int acpi_ec_read_info(struct seq_file *seq, void *offset)
575 struct acpi_ec *ec = (struct acpi_ec *)seq->private;
581 seq_printf(seq, "gpe bit: 0x%02x\n",
583 seq_printf(seq, "ports: 0x%02x, 0x%02x\n",
584 (u32) ec->command_addr,
585 (u32) ec->data_addr);
586 seq_printf(seq, "use global lock: %s\n",
587 ec->global_lock ? "yes" : "no");
588 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR);
594 static int acpi_ec_info_open_fs(struct inode *inode, struct file *file)
596 return single_open(file, acpi_ec_read_info, PDE(inode)->data);
599 static struct file_operations acpi_ec_info_ops = {
600 .open = acpi_ec_info_open_fs,
603 .release = single_release,
604 .owner = THIS_MODULE,
607 static int acpi_ec_add_fs(struct acpi_device *device)
609 struct proc_dir_entry *entry = NULL;
612 if (!acpi_device_dir(device)) {
613 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
615 if (!acpi_device_dir(device))
619 entry = create_proc_entry(ACPI_EC_FILE_INFO, S_IRUGO,
620 acpi_device_dir(device));
624 entry->proc_fops = &acpi_ec_info_ops;
625 entry->data = acpi_driver_data(device);
626 entry->owner = THIS_MODULE;
632 static int acpi_ec_remove_fs(struct acpi_device *device)
635 if (acpi_device_dir(device)) {
636 remove_proc_entry(ACPI_EC_FILE_INFO, acpi_device_dir(device));
637 remove_proc_entry(acpi_device_bid(device), acpi_ec_dir);
638 acpi_device_dir(device) = NULL;
644 /* --------------------------------------------------------------------------
646 -------------------------------------------------------------------------- */
648 static int acpi_ec_add(struct acpi_device *device)
651 acpi_status status = AE_OK;
652 struct acpi_ec *ec = NULL;
658 ec = kmalloc(sizeof(struct acpi_ec), GFP_KERNEL);
661 memset(ec, 0, sizeof(struct acpi_ec));
663 ec->handle = device->handle;
665 init_MUTEX(&ec->sem);
666 if (acpi_ec_mode == EC_INTR) {
667 atomic_set(&ec->leaving_burst, 1);
668 init_waitqueue_head(&ec->wait);
670 strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME);
671 strcpy(acpi_device_class(device), ACPI_EC_CLASS);
672 acpi_driver_data(device) = ec;
674 /* Use the global lock for all EC transactions? */
675 acpi_evaluate_integer(ec->handle, "_GLK", NULL,
678 /* XXX we don't test uids, because on some boxes ecdt uid = 0, see:
679 http://bugzilla.kernel.org/show_bug.cgi?id=6111 */
681 acpi_remove_address_space_handler(ACPI_ROOT_OBJECT,
683 &acpi_ec_space_handler);
685 acpi_remove_gpe_handler(NULL, ec_ecdt->gpe_bit,
686 &acpi_ec_gpe_handler);
691 /* Get GPE bit assignment (EC events). */
692 /* TODO: Add support for _GPE returning a package */
694 acpi_evaluate_integer(ec->handle, "_GPE", NULL,
696 if (ACPI_FAILURE(status)) {
697 ACPI_EXCEPTION((AE_INFO, status, "Obtaining GPE bit assignment"));
702 result = acpi_ec_add_fs(device);
706 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s [%s] (gpe %d) interrupt mode.",
707 acpi_device_name(device), acpi_device_bid(device),
720 static int acpi_ec_remove(struct acpi_device *device, int type)
722 struct acpi_ec *ec = NULL;
728 ec = acpi_driver_data(device);
730 acpi_ec_remove_fs(device);
738 acpi_ec_io_ports(struct acpi_resource *resource, void *context)
740 struct acpi_ec *ec = (struct acpi_ec *)context;
742 if (resource->type != ACPI_RESOURCE_TYPE_IO) {
747 * The first address region returned is the data port, and
748 * the second address region returned is the status/command
751 if (ec->data_addr == 0) {
752 ec->data_addr = resource->data.io.minimum;
753 } else if (ec->command_addr == 0) {
754 ec->command_addr = resource->data.io.minimum;
756 return AE_CTRL_TERMINATE;
762 static int acpi_ec_start(struct acpi_device *device)
764 acpi_status status = AE_OK;
765 struct acpi_ec *ec = NULL;
771 ec = acpi_driver_data(device);
777 * Get I/O port addresses. Convert to GAS format.
779 status = acpi_walk_resources(ec->handle, METHOD_NAME__CRS,
780 acpi_ec_io_ports, ec);
781 if (ACPI_FAILURE(status) || ec->command_addr == 0) {
782 ACPI_EXCEPTION((AE_INFO, status,
783 "Error getting I/O port addresses"));
787 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "gpe=0x%02lx, ports=0x%2lx,0x%2lx",
788 ec->gpe_bit, ec->command_addr, ec->data_addr));
791 * Install GPE handler
793 status = acpi_install_gpe_handler(NULL, ec->gpe_bit,
794 ACPI_GPE_EDGE_TRIGGERED,
795 &acpi_ec_gpe_handler, ec);
796 if (ACPI_FAILURE(status)) {
799 acpi_set_gpe_type(NULL, ec->gpe_bit, ACPI_GPE_TYPE_RUNTIME);
800 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR);
802 status = acpi_install_address_space_handler(ec->handle,
804 &acpi_ec_space_handler,
805 &acpi_ec_space_setup, ec);
806 if (ACPI_FAILURE(status)) {
807 acpi_remove_gpe_handler(NULL, ec->gpe_bit,
808 &acpi_ec_gpe_handler);
815 static int acpi_ec_stop(struct acpi_device *device, int type)
817 acpi_status status = AE_OK;
818 struct acpi_ec *ec = NULL;
824 ec = acpi_driver_data(device);
826 status = acpi_remove_address_space_handler(ec->handle,
828 &acpi_ec_space_handler);
829 if (ACPI_FAILURE(status))
833 acpi_remove_gpe_handler(NULL, ec->gpe_bit,
834 &acpi_ec_gpe_handler);
835 if (ACPI_FAILURE(status))
841 static acpi_status __init
842 acpi_fake_ecdt_callback(acpi_handle handle,
843 u32 Level, void *context, void **retval)
847 init_MUTEX(&ec_ecdt->sem);
848 if (acpi_ec_mode == EC_INTR) {
849 init_waitqueue_head(&ec_ecdt->wait);
851 status = acpi_walk_resources(handle, METHOD_NAME__CRS,
852 acpi_ec_io_ports, ec_ecdt);
853 if (ACPI_FAILURE(status))
857 acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->uid);
860 acpi_evaluate_integer(handle, "_GPE", NULL,
862 if (ACPI_FAILURE(status))
864 ec_ecdt->global_lock = TRUE;
865 ec_ecdt->handle = handle;
867 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "GPE=0x%02lx, ports=0x%2lx, 0x%2lx",
868 ec_ecdt->gpe_bit, ec_ecdt->command_addr, ec_ecdt->data_addr));
870 return AE_CTRL_TERMINATE;
874 * Some BIOS (such as some from Gateway laptops) access EC region very early
875 * such as in BAT0._INI or EC._INI before an EC device is found and
876 * do not provide an ECDT. According to ACPI spec, ECDT isn't mandatorily
877 * required, but if EC regison is accessed early, it is required.
878 * The routine tries to workaround the BIOS bug by pre-scan EC device
879 * It assumes that _CRS, _HID, _GPE, _UID methods of EC don't touch any
880 * op region (since _REG isn't invoked yet). The assumption is true for
883 static int __init acpi_ec_fake_ecdt(void)
888 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Try to make an fake ECDT"));
890 ec_ecdt = kmalloc(sizeof(struct acpi_ec), GFP_KERNEL);
895 memset(ec_ecdt, 0, sizeof(struct acpi_ec));
897 status = acpi_get_devices(ACPI_EC_HID,
898 acpi_fake_ecdt_callback, NULL, NULL);
899 if (ACPI_FAILURE(status)) {
903 ACPI_EXCEPTION((AE_INFO, status, "Can't make an fake ECDT"));
911 static int __init acpi_ec_get_real_ecdt(void)
914 struct acpi_table_ecdt *ecdt_ptr;
916 status = acpi_get_firmware_table("ECDT", 1, ACPI_LOGICAL_ADDRESSING,
917 (struct acpi_table_header **)
919 if (ACPI_FAILURE(status))
922 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found ECDT"));
925 * Generate a temporary ec context to use until the namespace is scanned
927 ec_ecdt = kmalloc(sizeof(struct acpi_ec), GFP_KERNEL);
930 memset(ec_ecdt, 0, sizeof(struct acpi_ec));
932 init_MUTEX(&ec_ecdt->sem);
933 if (acpi_ec_mode == EC_INTR) {
934 init_waitqueue_head(&ec_ecdt->wait);
936 ec_ecdt->command_addr = ecdt_ptr->ec_control.address;
937 ec_ecdt->data_addr = ecdt_ptr->ec_data.address;
938 ec_ecdt->gpe_bit = ecdt_ptr->gpe_bit;
939 /* use the GL just to be safe */
940 ec_ecdt->global_lock = TRUE;
941 ec_ecdt->uid = ecdt_ptr->uid;
944 acpi_get_handle(NULL, ecdt_ptr->ec_id, &ec_ecdt->handle);
945 if (ACPI_FAILURE(status)) {
951 ACPI_EXCEPTION((AE_INFO, status, "Could not use ECDT"));
958 static int __initdata acpi_fake_ecdt_enabled;
959 int __init acpi_ec_ecdt_probe(void)
964 ret = acpi_ec_get_real_ecdt();
965 /* Try to make a fake ECDT */
966 if (ret && acpi_fake_ecdt_enabled) {
967 ret = acpi_ec_fake_ecdt();
974 * Install GPE handler
976 status = acpi_install_gpe_handler(NULL, ec_ecdt->gpe_bit,
977 ACPI_GPE_EDGE_TRIGGERED,
978 &acpi_ec_gpe_handler, ec_ecdt);
979 if (ACPI_FAILURE(status)) {
982 acpi_set_gpe_type(NULL, ec_ecdt->gpe_bit, ACPI_GPE_TYPE_RUNTIME);
983 acpi_enable_gpe(NULL, ec_ecdt->gpe_bit, ACPI_NOT_ISR);
985 status = acpi_install_address_space_handler(ACPI_ROOT_OBJECT,
987 &acpi_ec_space_handler,
988 &acpi_ec_space_setup,
990 if (ACPI_FAILURE(status)) {
991 acpi_remove_gpe_handler(NULL, ec_ecdt->gpe_bit,
992 &acpi_ec_gpe_handler);
999 ACPI_EXCEPTION((AE_INFO, status, "Could not use ECDT"));
1006 static int __init acpi_ec_init(void)
1014 acpi_ec_dir = proc_mkdir(ACPI_EC_CLASS, acpi_root_dir);
1018 /* Now register the driver for the EC */
1019 result = acpi_bus_register_driver(&acpi_ec_driver);
1021 remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir);
1028 subsys_initcall(acpi_ec_init);
1030 /* EC driver currently not unloadable */
1032 static void __exit acpi_ec_exit(void)
1035 acpi_bus_unregister_driver(&acpi_ec_driver);
1037 remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir);
1043 static int __init acpi_fake_ecdt_setup(char *str)
1045 acpi_fake_ecdt_enabled = 1;
1049 __setup("acpi_fake_ecdt", acpi_fake_ecdt_setup);
1050 static int __init acpi_ec_set_intr_mode(char *str)
1054 if (!get_option(&str, &intr))
1058 acpi_ec_mode = EC_INTR;
1060 acpi_ec_mode = EC_POLL;
1062 acpi_ec_driver.ops.add = acpi_ec_add;
1063 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "EC %s mode.\n", intr ? "interrupt" : "polling"));
1068 __setup("ec_intr=", acpi_ec_set_intr_mode);