2 * ec.c - ACPI Embedded Controller Driver (v2.0)
4 * Copyright (C) 2006, 2007 Alexey Starikovskiy <alexey.y.starikovskiy@intel.com>
5 * Copyright (C) 2006 Denis Sadykov <denis.m.sadykov@intel.com>
6 * Copyright (C) 2004 Luming Yu <luming.yu@intel.com>
7 * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
8 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
10 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or (at
15 * your option) any later version.
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
22 * You should have received a copy of the GNU General Public License along
23 * with this program; if not, write to the Free Software Foundation, Inc.,
24 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
26 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
29 #include <linux/kernel.h>
30 #include <linux/module.h>
31 #include <linux/init.h>
32 #include <linux/types.h>
33 #include <linux/delay.h>
34 #include <linux/proc_fs.h>
35 #include <linux/seq_file.h>
36 #include <linux/interrupt.h>
37 #include <linux/list.h>
39 #include <acpi/acpi_bus.h>
40 #include <acpi/acpi_drivers.h>
41 #include <acpi/actypes.h>
43 #define ACPI_EC_CLASS "embedded_controller"
44 #define ACPI_EC_DEVICE_NAME "Embedded Controller"
45 #define ACPI_EC_FILE_INFO "info"
48 #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 */
58 ACPI_EC_COMMAND_READ = 0x80,
59 ACPI_EC_COMMAND_WRITE = 0x81,
60 ACPI_EC_BURST_ENABLE = 0x82,
61 ACPI_EC_BURST_DISABLE = 0x83,
62 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_FLAGS_WAIT_GPE = 0, /* Don't check status until GPE arrives */
76 EC_FLAGS_QUERY_PENDING, /* Query is pending */
77 EC_FLAGS_GPE_MODE, /* Expect GPE to be sent for status change */
78 EC_FLAGS_ONLY_IBF_GPE, /* Expect GPE only for IBF = 0 event */
81 static int acpi_ec_remove(struct acpi_device *device, int type);
82 static int acpi_ec_start(struct acpi_device *device);
83 static int acpi_ec_stop(struct acpi_device *device, int type);
84 static int acpi_ec_add(struct acpi_device *device);
86 static const struct acpi_device_id ec_device_ids[] = {
91 static struct acpi_driver acpi_ec_driver = {
93 .class = ACPI_EC_CLASS,
97 .remove = acpi_ec_remove,
98 .start = acpi_ec_start,
103 /* If we find an EC via the ECDT, we need to keep a ptr to its context */
104 /* External interfaces use first EC only, so remember */
105 typedef int (*acpi_ec_query_func) (void *data);
107 struct acpi_ec_query_handler {
108 struct list_head node;
109 acpi_ec_query_func func;
115 static struct acpi_ec {
118 unsigned long command_addr;
119 unsigned long data_addr;
120 unsigned long global_lock;
123 wait_queue_head_t wait;
124 struct list_head list;
125 u8 handlers_installed;
126 } *boot_ec, *first_ec;
128 /* --------------------------------------------------------------------------
129 Transaction Management
130 -------------------------------------------------------------------------- */
132 static inline u8 acpi_ec_read_status(struct acpi_ec *ec)
134 return inb(ec->command_addr);
137 static inline u8 acpi_ec_read_data(struct acpi_ec *ec)
139 return inb(ec->data_addr);
142 static inline void acpi_ec_write_cmd(struct acpi_ec *ec, u8 command)
144 outb(command, ec->command_addr);
147 static inline void acpi_ec_write_data(struct acpi_ec *ec, u8 data)
149 outb(data, ec->data_addr);
152 static inline int acpi_ec_check_status(struct acpi_ec *ec, enum ec_event event)
154 if (test_bit(EC_FLAGS_WAIT_GPE, &ec->flags))
156 if (event == ACPI_EC_EVENT_OBF_1) {
157 if (acpi_ec_read_status(ec) & ACPI_EC_FLAG_OBF)
159 } else if (event == ACPI_EC_EVENT_IBF_0) {
160 if (!(acpi_ec_read_status(ec) & ACPI_EC_FLAG_IBF))
167 static int acpi_ec_wait(struct acpi_ec *ec, enum ec_event event, int force_poll)
169 if (likely(test_bit(EC_FLAGS_GPE_MODE, &ec->flags)) &&
170 likely(!force_poll)) {
171 if (wait_event_timeout(ec->wait, acpi_ec_check_status(ec, event),
172 msecs_to_jiffies(ACPI_EC_DELAY)))
174 clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
175 if (acpi_ec_check_status(ec, event)) {
176 if (event == ACPI_EC_EVENT_OBF_1) {
177 /* miss OBF = 1 GPE, don't expect it anymore */
178 printk(KERN_INFO PREFIX "missing OBF_1 confirmation,"
179 "switching to degraded mode.\n");
180 set_bit(EC_FLAGS_ONLY_IBF_GPE, &ec->flags);
182 /* missing GPEs, switch back to poll mode */
183 printk(KERN_INFO PREFIX "missing IBF_1 confirmations,"
184 "switch off interrupt mode.\n");
185 clear_bit(EC_FLAGS_GPE_MODE, &ec->flags);
190 unsigned long delay = jiffies + msecs_to_jiffies(ACPI_EC_DELAY);
191 clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
192 while (time_before(jiffies, delay)) {
193 if (acpi_ec_check_status(ec, event))
197 printk(KERN_ERR PREFIX "acpi_ec_wait timeout,"
198 " status = %d, expect_event = %d\n",
199 acpi_ec_read_status(ec), event);
203 static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command,
204 const u8 * wdata, unsigned wdata_len,
205 u8 * rdata, unsigned rdata_len,
209 set_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
210 acpi_ec_write_cmd(ec, command);
212 for (; wdata_len > 0; --wdata_len) {
213 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, force_poll);
215 printk(KERN_ERR PREFIX
216 "write_cmd timeout, command = %d\n", command);
219 set_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
220 acpi_ec_write_data(ec, *(wdata++));
224 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, force_poll);
226 printk(KERN_ERR PREFIX
227 "finish-write timeout, command = %d\n", command);
230 } else if (command == ACPI_EC_COMMAND_QUERY)
231 clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags);
233 for (; rdata_len > 0; --rdata_len) {
234 if (test_bit(EC_FLAGS_ONLY_IBF_GPE, &ec->flags))
236 result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1, force_poll);
238 printk(KERN_ERR PREFIX "read timeout, command = %d\n",
242 /* Don't expect GPE after last read */
244 set_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
245 *(rdata++) = acpi_ec_read_data(ec);
251 static int acpi_ec_transaction(struct acpi_ec *ec, u8 command,
252 const u8 * wdata, unsigned wdata_len,
253 u8 * rdata, unsigned rdata_len,
259 if (!ec || (wdata_len && !wdata) || (rdata_len && !rdata))
263 memset(rdata, 0, rdata_len);
265 mutex_lock(&ec->lock);
266 if (ec->global_lock) {
267 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
268 if (ACPI_FAILURE(status)) {
269 mutex_unlock(&ec->lock);
274 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, 0);
276 printk(KERN_ERR PREFIX
277 "input buffer is not empty, aborting transaction\n");
281 status = acpi_ec_transaction_unlocked(ec, command,
289 acpi_release_global_lock(glk);
290 mutex_unlock(&ec->lock);
296 * Note: samsung nv5000 doesn't work with ec burst mode.
297 * http://bugzilla.kernel.org/show_bug.cgi?id=4980
299 int acpi_ec_burst_enable(struct acpi_ec *ec)
302 return acpi_ec_transaction(ec, ACPI_EC_BURST_ENABLE, NULL, 0, &d, 1, 0);
305 int acpi_ec_burst_disable(struct acpi_ec *ec)
307 return acpi_ec_transaction(ec, ACPI_EC_BURST_DISABLE, NULL, 0, NULL, 0, 0);
310 static int acpi_ec_read(struct acpi_ec *ec, u8 address, u8 * data)
315 result = acpi_ec_transaction(ec, ACPI_EC_COMMAND_READ,
316 &address, 1, &d, 1, 0);
321 static int acpi_ec_write(struct acpi_ec *ec, u8 address, u8 data)
323 u8 wdata[2] = { address, data };
324 return acpi_ec_transaction(ec, ACPI_EC_COMMAND_WRITE,
325 wdata, 2, NULL, 0, 0);
329 * Externally callable EC access functions. For now, assume 1 EC only
331 int ec_burst_enable(void)
335 return acpi_ec_burst_enable(first_ec);
338 EXPORT_SYMBOL(ec_burst_enable);
340 int ec_burst_disable(void)
344 return acpi_ec_burst_disable(first_ec);
347 EXPORT_SYMBOL(ec_burst_disable);
349 int ec_read(u8 addr, u8 * val)
357 err = acpi_ec_read(first_ec, addr, &temp_data);
366 EXPORT_SYMBOL(ec_read);
368 int ec_write(u8 addr, u8 val)
375 err = acpi_ec_write(first_ec, addr, val);
380 EXPORT_SYMBOL(ec_write);
382 int ec_transaction(u8 command,
383 const u8 * wdata, unsigned wdata_len,
384 u8 * rdata, unsigned rdata_len,
390 return acpi_ec_transaction(first_ec, command, wdata,
391 wdata_len, rdata, rdata_len,
395 EXPORT_SYMBOL(ec_transaction);
397 static int acpi_ec_query(struct acpi_ec *ec, u8 * data)
406 * Query the EC to find out which _Qxx method we need to evaluate.
407 * Note that successful completion of the query causes the ACPI_EC_SCI
408 * bit to be cleared (and thus clearing the interrupt source).
411 result = acpi_ec_transaction(ec, ACPI_EC_COMMAND_QUERY, NULL, 0, &d, 1, 0);
422 /* --------------------------------------------------------------------------
424 -------------------------------------------------------------------------- */
425 int acpi_ec_add_query_handler(struct acpi_ec *ec, u8 query_bit,
426 acpi_handle handle, acpi_ec_query_func func,
429 struct acpi_ec_query_handler *handler =
430 kzalloc(sizeof(struct acpi_ec_query_handler), GFP_KERNEL);
434 handler->query_bit = query_bit;
435 handler->handle = handle;
436 handler->func = func;
437 handler->data = data;
438 mutex_lock(&ec->lock);
439 list_add(&handler->node, &ec->list);
440 mutex_unlock(&ec->lock);
444 EXPORT_SYMBOL_GPL(acpi_ec_add_query_handler);
446 void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit)
448 struct acpi_ec_query_handler *handler, *tmp;
449 mutex_lock(&ec->lock);
450 list_for_each_entry_safe(handler, tmp, &ec->list, node) {
451 if (query_bit == handler->query_bit) {
452 list_del(&handler->node);
456 mutex_unlock(&ec->lock);
459 EXPORT_SYMBOL_GPL(acpi_ec_remove_query_handler);
461 static void acpi_ec_gpe_query(void *ec_cxt)
463 struct acpi_ec *ec = ec_cxt;
465 struct acpi_ec_query_handler *handler, copy;
467 if (!ec || acpi_ec_query(ec, &value))
469 mutex_lock(&ec->lock);
470 list_for_each_entry(handler, &ec->list, node) {
471 if (value == handler->query_bit) {
472 /* have custom handler for this bit */
473 memcpy(©, handler, sizeof(copy));
474 mutex_unlock(&ec->lock);
476 copy.func(copy.data);
477 } else if (copy.handle) {
478 acpi_evaluate_object(copy.handle, NULL, NULL, NULL);
483 mutex_unlock(&ec->lock);
486 static u32 acpi_ec_gpe_handler(void *data)
488 acpi_status status = AE_OK;
489 struct acpi_ec *ec = data;
491 clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
492 if (test_bit(EC_FLAGS_GPE_MODE, &ec->flags))
495 if (acpi_ec_read_status(ec) & ACPI_EC_FLAG_SCI) {
496 if (!test_and_set_bit(EC_FLAGS_QUERY_PENDING, &ec->flags))
497 status = acpi_os_execute(OSL_EC_BURST_HANDLER,
498 acpi_ec_gpe_query, ec);
499 } else if (unlikely(!test_bit(EC_FLAGS_GPE_MODE, &ec->flags))) {
500 /* this is non-query, must be confirmation */
501 printk(KERN_INFO PREFIX "non-query interrupt received,"
502 " switching to interrupt mode\n");
503 set_bit(EC_FLAGS_GPE_MODE, &ec->flags);
506 return ACPI_SUCCESS(status) ?
507 ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED;
510 /* --------------------------------------------------------------------------
511 Address Space Management
512 -------------------------------------------------------------------------- */
515 acpi_ec_space_setup(acpi_handle region_handle,
516 u32 function, void *handler_context, void **return_context)
519 * The EC object is in the handler context and is needed
520 * when calling the acpi_ec_space_handler.
522 *return_context = (function != ACPI_REGION_DEACTIVATE) ?
523 handler_context : NULL;
529 acpi_ec_space_handler(u32 function, acpi_physical_address address,
530 u32 bits, acpi_integer *value,
531 void *handler_context, void *region_context)
533 struct acpi_ec *ec = handler_context;
534 int result = 0, i = 0;
537 if ((address > 0xFF) || !value || !handler_context)
538 return AE_BAD_PARAMETER;
540 if (function != ACPI_READ && function != ACPI_WRITE)
541 return AE_BAD_PARAMETER;
543 if (bits != 8 && acpi_strict)
544 return AE_BAD_PARAMETER;
546 while (bits - i > 0) {
547 if (function == ACPI_READ) {
548 result = acpi_ec_read(ec, address, &temp);
549 (*value) |= ((acpi_integer)temp) << i;
551 temp = 0xff & ((*value) >> i);
552 result = acpi_ec_write(ec, address, temp);
560 return AE_BAD_PARAMETER;
573 /* --------------------------------------------------------------------------
575 -------------------------------------------------------------------------- */
577 static struct proc_dir_entry *acpi_ec_dir;
579 static int acpi_ec_read_info(struct seq_file *seq, void *offset)
581 struct acpi_ec *ec = seq->private;
586 seq_printf(seq, "gpe:\t\t\t0x%02x\n", (u32) ec->gpe);
587 seq_printf(seq, "ports:\t\t\t0x%02x, 0x%02x\n",
588 (unsigned)ec->command_addr, (unsigned)ec->data_addr);
589 seq_printf(seq, "use global lock:\t%s\n",
590 ec->global_lock ? "yes" : "no");
595 static int acpi_ec_info_open_fs(struct inode *inode, struct file *file)
597 return single_open(file, acpi_ec_read_info, PDE(inode)->data);
600 static struct file_operations acpi_ec_info_ops = {
601 .open = acpi_ec_info_open_fs,
604 .release = single_release,
605 .owner = THIS_MODULE,
608 static int acpi_ec_add_fs(struct acpi_device *device)
610 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 ec_parse_io_ports(struct acpi_resource *resource, void *context);
650 static struct acpi_ec *make_acpi_ec(void)
652 struct acpi_ec *ec = kzalloc(sizeof(struct acpi_ec), GFP_KERNEL);
655 ec->flags = 1 << EC_FLAGS_QUERY_PENDING;
656 mutex_init(&ec->lock);
657 init_waitqueue_head(&ec->wait);
658 INIT_LIST_HEAD(&ec->list);
663 acpi_ec_register_query_methods(acpi_handle handle, u32 level,
664 void *context, void **return_value)
666 struct acpi_namespace_node *node = handle;
667 struct acpi_ec *ec = context;
669 if (sscanf(node->name.ascii, "_Q%x", &value) == 1) {
670 acpi_ec_add_query_handler(ec, value, handle, NULL, NULL);
676 ec_parse_device(acpi_handle handle, u32 Level, void *context, void **retval)
680 struct acpi_ec *ec = context;
681 status = acpi_walk_resources(handle, METHOD_NAME__CRS,
682 ec_parse_io_ports, ec);
683 if (ACPI_FAILURE(status))
686 /* Get GPE bit assignment (EC events). */
687 /* TODO: Add support for _GPE returning a package */
688 status = acpi_evaluate_integer(handle, "_GPE", NULL, &ec->gpe);
689 if (ACPI_FAILURE(status))
691 /* Find and register all query methods */
692 acpi_walk_namespace(ACPI_TYPE_METHOD, handle, 1,
693 acpi_ec_register_query_methods, ec, NULL);
694 /* Use the global lock for all EC transactions? */
695 acpi_evaluate_integer(handle, "_GLK", NULL, &ec->global_lock);
697 return AE_CTRL_TERMINATE;
700 static void ec_remove_handlers(struct acpi_ec *ec)
702 if (ACPI_FAILURE(acpi_remove_address_space_handler(ec->handle,
703 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler)))
704 printk(KERN_ERR PREFIX "failed to remove space handler\n");
705 if (ACPI_FAILURE(acpi_remove_gpe_handler(NULL, ec->gpe,
706 &acpi_ec_gpe_handler)))
707 printk(KERN_ERR PREFIX "failed to remove gpe handler\n");
708 ec->handlers_installed = 0;
711 static int acpi_ec_add(struct acpi_device *device)
713 struct acpi_ec *ec = NULL;
717 strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME);
718 strcpy(acpi_device_class(device), ACPI_EC_CLASS);
720 /* Check for boot EC */
722 if (boot_ec->handle == device->handle) {
723 /* Pre-loaded EC from DSDT, just move pointer */
727 } else if (boot_ec->handle == ACPI_ROOT_OBJECT) {
728 /* ECDT-based EC, time to shut it down */
729 ec_remove_handlers(boot_ec);
731 first_ec = boot_ec = NULL;
739 if (ec_parse_device(device->handle, 0, ec, NULL) !=
744 ec->handle = device->handle;
748 acpi_driver_data(device) = ec;
749 acpi_ec_add_fs(device);
750 printk(KERN_INFO PREFIX "GPE = 0x%lx, I/O: command/status = 0x%lx, data = 0x%lx\n",
751 ec->gpe, ec->command_addr, ec->data_addr);
752 printk(KERN_INFO PREFIX "driver started in %s mode\n",
753 (test_bit(EC_FLAGS_GPE_MODE, &ec->flags))?"interrupt":"poll");
757 static int acpi_ec_remove(struct acpi_device *device, int type)
760 struct acpi_ec_query_handler *handler, *tmp;
765 ec = acpi_driver_data(device);
766 mutex_lock(&ec->lock);
767 list_for_each_entry_safe(handler, tmp, &ec->list, node) {
768 list_del(&handler->node);
771 mutex_unlock(&ec->lock);
772 acpi_ec_remove_fs(device);
773 acpi_driver_data(device) = NULL;
781 ec_parse_io_ports(struct acpi_resource *resource, void *context)
783 struct acpi_ec *ec = context;
785 if (resource->type != ACPI_RESOURCE_TYPE_IO)
789 * The first address region returned is the data port, and
790 * the second address region returned is the status/command
793 if (ec->data_addr == 0)
794 ec->data_addr = resource->data.io.minimum;
795 else if (ec->command_addr == 0)
796 ec->command_addr = resource->data.io.minimum;
798 return AE_CTRL_TERMINATE;
803 static int ec_install_handlers(struct acpi_ec *ec)
806 if (ec->handlers_installed)
808 status = acpi_install_gpe_handler(NULL, ec->gpe,
809 ACPI_GPE_EDGE_TRIGGERED,
810 &acpi_ec_gpe_handler, ec);
811 if (ACPI_FAILURE(status))
814 acpi_set_gpe_type(NULL, ec->gpe, ACPI_GPE_TYPE_RUNTIME);
815 acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR);
817 status = acpi_install_address_space_handler(ec->handle,
819 &acpi_ec_space_handler,
820 &acpi_ec_space_setup, ec);
821 if (ACPI_FAILURE(status)) {
822 acpi_remove_gpe_handler(NULL, ec->gpe, &acpi_ec_gpe_handler);
826 ec->handlers_installed = 1;
830 static int acpi_ec_start(struct acpi_device *device)
838 ec = acpi_driver_data(device);
843 ret = ec_install_handlers(ec);
845 /* EC is fully operational, allow queries */
846 clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags);
850 static int acpi_ec_stop(struct acpi_device *device, int type)
855 ec = acpi_driver_data(device);
858 ec_remove_handlers(ec);
863 int __init acpi_ec_ecdt_probe(void)
867 struct acpi_table_ecdt *ecdt_ptr;
869 boot_ec = make_acpi_ec();
873 * Generate a boot ec context
875 status = acpi_get_table(ACPI_SIG_ECDT, 1,
876 (struct acpi_table_header **)&ecdt_ptr);
877 if (ACPI_SUCCESS(status)) {
878 printk(KERN_INFO PREFIX "EC description table is found, configuring boot EC\n");
879 boot_ec->command_addr = ecdt_ptr->control.address;
880 boot_ec->data_addr = ecdt_ptr->data.address;
881 boot_ec->gpe = ecdt_ptr->gpe;
882 boot_ec->handle = ACPI_ROOT_OBJECT;
884 /* This workaround is needed only on some broken machines,
885 * which require early EC, but fail to provide ECDT */
887 printk(KERN_DEBUG PREFIX "Look up EC in DSDT\n");
888 status = acpi_get_devices(ec_device_ids[0].id, ec_parse_device,
890 /* Check that acpi_get_devices actually find something */
891 if (ACPI_FAILURE(status) || !boot_ec->handle)
893 /* We really need to limit this workaround, the only ASUS,
894 * which needs it, has fake EC._INI method, so use it as flag.
896 if (ACPI_FAILURE(acpi_get_handle(boot_ec->handle, "_INI", &x)))
900 ret = ec_install_handlers(boot_ec);
911 static int __init acpi_ec_init(void)
918 acpi_ec_dir = proc_mkdir(ACPI_EC_CLASS, acpi_root_dir);
922 /* Now register the driver for the EC */
923 result = acpi_bus_register_driver(&acpi_ec_driver);
925 remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir);
932 subsys_initcall(acpi_ec_init);
934 /* EC driver currently not unloadable */
936 static void __exit acpi_ec_exit(void)
939 acpi_bus_unregister_driver(&acpi_ec_driver);
941 remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir);