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 /* Uncomment next line to get verbose print outs*/
53 /* EC status register */
54 #define ACPI_EC_FLAG_OBF 0x01 /* Output buffer full */
55 #define ACPI_EC_FLAG_IBF 0x02 /* Input buffer full */
56 #define ACPI_EC_FLAG_BURST 0x10 /* burst mode */
57 #define ACPI_EC_FLAG_SCI 0x20 /* EC-SCI occurred */
61 ACPI_EC_COMMAND_READ = 0x80,
62 ACPI_EC_COMMAND_WRITE = 0x81,
63 ACPI_EC_BURST_ENABLE = 0x82,
64 ACPI_EC_BURST_DISABLE = 0x83,
65 ACPI_EC_COMMAND_QUERY = 0x84,
70 ACPI_EC_EVENT_OBF_1 = 1, /* Output buffer full */
71 ACPI_EC_EVENT_IBF_0, /* Input buffer empty */
74 #define ACPI_EC_DELAY 500 /* Wait 500ms max. during EC ops */
75 #define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */
78 EC_FLAGS_WAIT_GPE = 0, /* Don't check status until GPE arrives */
79 EC_FLAGS_QUERY_PENDING, /* Query is pending */
80 EC_FLAGS_GPE_MODE, /* Expect GPE to be sent for status change */
81 EC_FLAGS_ONLY_IBF_GPE, /* Expect GPE only for IBF = 0 event */
84 static int acpi_ec_remove(struct acpi_device *device, int type);
85 static int acpi_ec_start(struct acpi_device *device);
86 static int acpi_ec_stop(struct acpi_device *device, int type);
87 static int acpi_ec_add(struct acpi_device *device);
89 static const struct acpi_device_id ec_device_ids[] = {
94 static struct acpi_driver acpi_ec_driver = {
96 .class = ACPI_EC_CLASS,
100 .remove = acpi_ec_remove,
101 .start = acpi_ec_start,
102 .stop = acpi_ec_stop,
106 /* If we find an EC via the ECDT, we need to keep a ptr to its context */
107 /* External interfaces use first EC only, so remember */
108 typedef int (*acpi_ec_query_func) (void *data);
110 struct acpi_ec_query_handler {
111 struct list_head node;
112 acpi_ec_query_func func;
118 static struct acpi_ec {
121 unsigned long command_addr;
122 unsigned long data_addr;
123 unsigned long global_lock;
126 wait_queue_head_t wait;
127 struct list_head list;
128 u8 handlers_installed;
129 } *boot_ec, *first_ec;
131 /* --------------------------------------------------------------------------
132 Transaction Management
133 -------------------------------------------------------------------------- */
135 static inline u8 acpi_ec_read_status(struct acpi_ec *ec)
137 u8 x = inb(ec->command_addr);
138 pr_debug(PREFIX "---> status = 0x%2x\n", x);
142 static inline u8 acpi_ec_read_data(struct acpi_ec *ec)
144 u8 x = inb(ec->data_addr);
145 pr_debug(PREFIX "---> data = 0x%2x\n", x);
146 return inb(ec->data_addr);
149 static inline void acpi_ec_write_cmd(struct acpi_ec *ec, u8 command)
151 pr_debug(PREFIX "<--- command = 0x%2x\n", command);
152 outb(command, ec->command_addr);
155 static inline void acpi_ec_write_data(struct acpi_ec *ec, u8 data)
157 pr_debug(PREFIX "<--- data = 0x%2x\n", data);
158 outb(data, ec->data_addr);
161 static inline int acpi_ec_check_status(struct acpi_ec *ec, enum ec_event event)
163 if (test_bit(EC_FLAGS_WAIT_GPE, &ec->flags))
165 if (event == ACPI_EC_EVENT_OBF_1) {
166 if (acpi_ec_read_status(ec) & ACPI_EC_FLAG_OBF)
168 } else if (event == ACPI_EC_EVENT_IBF_0) {
169 if (!(acpi_ec_read_status(ec) & ACPI_EC_FLAG_IBF))
176 static int acpi_ec_wait(struct acpi_ec *ec, enum ec_event event, int force_poll)
178 if (likely(test_bit(EC_FLAGS_GPE_MODE, &ec->flags)) &&
179 likely(!force_poll)) {
180 if (wait_event_timeout(ec->wait, acpi_ec_check_status(ec, event),
181 msecs_to_jiffies(ACPI_EC_DELAY)))
183 clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
184 if (acpi_ec_check_status(ec, event)) {
185 if (event == ACPI_EC_EVENT_OBF_1) {
186 /* miss OBF = 1 GPE, don't expect it anymore */
187 pr_info(PREFIX "missing OBF_1 confirmation,"
188 "switching to degraded mode.\n");
189 set_bit(EC_FLAGS_ONLY_IBF_GPE, &ec->flags);
191 /* missing GPEs, switch back to poll mode */
192 if (printk_ratelimit())
193 pr_info(PREFIX "missing IBF_1 confirmations,"
194 "switch off interrupt mode.\n");
195 clear_bit(EC_FLAGS_GPE_MODE, &ec->flags);
200 unsigned long delay = jiffies + msecs_to_jiffies(ACPI_EC_DELAY);
201 clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
202 while (time_before(jiffies, delay)) {
203 if (acpi_ec_check_status(ec, event))
207 pr_err(PREFIX "acpi_ec_wait timeout,"
208 " status = %d, expect_event = %d\n",
209 acpi_ec_read_status(ec), event);
213 static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command,
214 const u8 * wdata, unsigned wdata_len,
215 u8 * rdata, unsigned rdata_len,
219 set_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
220 acpi_ec_write_cmd(ec, command);
221 pr_debug(PREFIX "transaction start\n");
222 for (; wdata_len > 0; --wdata_len) {
223 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, force_poll);
226 "write_cmd timeout, command = %d\n", command);
229 set_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
230 acpi_ec_write_data(ec, *(wdata++));
234 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, force_poll);
237 "finish-write timeout, command = %d\n", command);
240 } else if (command == ACPI_EC_COMMAND_QUERY)
241 clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags);
243 for (; rdata_len > 0; --rdata_len) {
244 if (test_bit(EC_FLAGS_ONLY_IBF_GPE, &ec->flags))
246 result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1, force_poll);
248 pr_err(PREFIX "read timeout, command = %d\n", command);
251 /* Don't expect GPE after last read */
253 set_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
254 *(rdata++) = acpi_ec_read_data(ec);
257 pr_debug(PREFIX "transaction end\n");
261 static int acpi_ec_transaction(struct acpi_ec *ec, u8 command,
262 const u8 * wdata, unsigned wdata_len,
263 u8 * rdata, unsigned rdata_len,
269 if (!ec || (wdata_len && !wdata) || (rdata_len && !rdata))
273 memset(rdata, 0, rdata_len);
275 mutex_lock(&ec->lock);
276 if (ec->global_lock) {
277 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
278 if (ACPI_FAILURE(status)) {
279 mutex_unlock(&ec->lock);
284 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, 0);
286 pr_err(PREFIX "input buffer is not empty, "
287 "aborting transaction\n");
291 status = acpi_ec_transaction_unlocked(ec, command,
299 acpi_release_global_lock(glk);
300 mutex_unlock(&ec->lock);
306 * Note: samsung nv5000 doesn't work with ec burst mode.
307 * http://bugzilla.kernel.org/show_bug.cgi?id=4980
309 int acpi_ec_burst_enable(struct acpi_ec *ec)
312 return acpi_ec_transaction(ec, ACPI_EC_BURST_ENABLE, NULL, 0, &d, 1, 0);
315 int acpi_ec_burst_disable(struct acpi_ec *ec)
317 return acpi_ec_transaction(ec, ACPI_EC_BURST_DISABLE, NULL, 0, NULL, 0, 0);
320 static int acpi_ec_read(struct acpi_ec *ec, u8 address, u8 * data)
325 result = acpi_ec_transaction(ec, ACPI_EC_COMMAND_READ,
326 &address, 1, &d, 1, 0);
331 static int acpi_ec_write(struct acpi_ec *ec, u8 address, u8 data)
333 u8 wdata[2] = { address, data };
334 return acpi_ec_transaction(ec, ACPI_EC_COMMAND_WRITE,
335 wdata, 2, NULL, 0, 0);
339 * Externally callable EC access functions. For now, assume 1 EC only
341 int ec_burst_enable(void)
345 return acpi_ec_burst_enable(first_ec);
348 EXPORT_SYMBOL(ec_burst_enable);
350 int ec_burst_disable(void)
354 return acpi_ec_burst_disable(first_ec);
357 EXPORT_SYMBOL(ec_burst_disable);
359 int ec_read(u8 addr, u8 * val)
367 err = acpi_ec_read(first_ec, addr, &temp_data);
376 EXPORT_SYMBOL(ec_read);
378 int ec_write(u8 addr, u8 val)
385 err = acpi_ec_write(first_ec, addr, val);
390 EXPORT_SYMBOL(ec_write);
392 int ec_transaction(u8 command,
393 const u8 * wdata, unsigned wdata_len,
394 u8 * rdata, unsigned rdata_len,
400 return acpi_ec_transaction(first_ec, command, wdata,
401 wdata_len, rdata, rdata_len,
405 EXPORT_SYMBOL(ec_transaction);
407 static int acpi_ec_query(struct acpi_ec *ec, u8 * data)
416 * Query the EC to find out which _Qxx method we need to evaluate.
417 * Note that successful completion of the query causes the ACPI_EC_SCI
418 * bit to be cleared (and thus clearing the interrupt source).
421 result = acpi_ec_transaction(ec, ACPI_EC_COMMAND_QUERY, NULL, 0, &d, 1, 0);
432 /* --------------------------------------------------------------------------
434 -------------------------------------------------------------------------- */
435 int acpi_ec_add_query_handler(struct acpi_ec *ec, u8 query_bit,
436 acpi_handle handle, acpi_ec_query_func func,
439 struct acpi_ec_query_handler *handler =
440 kzalloc(sizeof(struct acpi_ec_query_handler), GFP_KERNEL);
444 handler->query_bit = query_bit;
445 handler->handle = handle;
446 handler->func = func;
447 handler->data = data;
448 mutex_lock(&ec->lock);
449 list_add(&handler->node, &ec->list);
450 mutex_unlock(&ec->lock);
454 EXPORT_SYMBOL_GPL(acpi_ec_add_query_handler);
456 void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit)
458 struct acpi_ec_query_handler *handler, *tmp;
459 mutex_lock(&ec->lock);
460 list_for_each_entry_safe(handler, tmp, &ec->list, node) {
461 if (query_bit == handler->query_bit) {
462 list_del(&handler->node);
466 mutex_unlock(&ec->lock);
469 EXPORT_SYMBOL_GPL(acpi_ec_remove_query_handler);
471 static void acpi_ec_gpe_query(void *ec_cxt)
473 struct acpi_ec *ec = ec_cxt;
475 struct acpi_ec_query_handler *handler, copy;
477 if (!ec || acpi_ec_query(ec, &value))
479 mutex_lock(&ec->lock);
480 list_for_each_entry(handler, &ec->list, node) {
481 if (value == handler->query_bit) {
482 /* have custom handler for this bit */
483 memcpy(©, handler, sizeof(copy));
484 mutex_unlock(&ec->lock);
486 copy.func(copy.data);
487 } else if (copy.handle) {
488 acpi_evaluate_object(copy.handle, NULL, NULL, NULL);
493 mutex_unlock(&ec->lock);
496 static u32 acpi_ec_gpe_handler(void *data)
498 acpi_status status = AE_OK;
499 struct acpi_ec *ec = data;
501 pr_debug(PREFIX "~~~> interrupt\n");
502 clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
503 if (test_bit(EC_FLAGS_GPE_MODE, &ec->flags))
506 if (acpi_ec_read_status(ec) & ACPI_EC_FLAG_SCI) {
507 if (!test_and_set_bit(EC_FLAGS_QUERY_PENDING, &ec->flags))
508 status = acpi_os_execute(OSL_EC_BURST_HANDLER,
509 acpi_ec_gpe_query, ec);
510 } else if (unlikely(!test_bit(EC_FLAGS_GPE_MODE, &ec->flags))) {
511 /* this is non-query, must be confirmation */
512 if (printk_ratelimit())
513 pr_info(PREFIX "non-query interrupt received,"
514 " switching to interrupt mode\n");
515 set_bit(EC_FLAGS_GPE_MODE, &ec->flags);
518 return ACPI_SUCCESS(status) ?
519 ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED;
522 /* --------------------------------------------------------------------------
523 Address Space Management
524 -------------------------------------------------------------------------- */
527 acpi_ec_space_setup(acpi_handle region_handle,
528 u32 function, void *handler_context, void **return_context)
531 * The EC object is in the handler context and is needed
532 * when calling the acpi_ec_space_handler.
534 *return_context = (function != ACPI_REGION_DEACTIVATE) ?
535 handler_context : NULL;
541 acpi_ec_space_handler(u32 function, acpi_physical_address address,
542 u32 bits, acpi_integer *value,
543 void *handler_context, void *region_context)
545 struct acpi_ec *ec = handler_context;
546 int result = 0, i = 0;
549 if ((address > 0xFF) || !value || !handler_context)
550 return AE_BAD_PARAMETER;
552 if (function != ACPI_READ && function != ACPI_WRITE)
553 return AE_BAD_PARAMETER;
555 if (bits != 8 && acpi_strict)
556 return AE_BAD_PARAMETER;
558 while (bits - i > 0) {
559 if (function == ACPI_READ) {
560 result = acpi_ec_read(ec, address, &temp);
561 (*value) |= ((acpi_integer)temp) << i;
563 temp = 0xff & ((*value) >> i);
564 result = acpi_ec_write(ec, address, temp);
572 return AE_BAD_PARAMETER;
585 /* --------------------------------------------------------------------------
587 -------------------------------------------------------------------------- */
589 static struct proc_dir_entry *acpi_ec_dir;
591 static int acpi_ec_read_info(struct seq_file *seq, void *offset)
593 struct acpi_ec *ec = seq->private;
598 seq_printf(seq, "gpe:\t\t\t0x%02x\n", (u32) ec->gpe);
599 seq_printf(seq, "ports:\t\t\t0x%02x, 0x%02x\n",
600 (unsigned)ec->command_addr, (unsigned)ec->data_addr);
601 seq_printf(seq, "use global lock:\t%s\n",
602 ec->global_lock ? "yes" : "no");
607 static int acpi_ec_info_open_fs(struct inode *inode, struct file *file)
609 return single_open(file, acpi_ec_read_info, PDE(inode)->data);
612 static struct file_operations acpi_ec_info_ops = {
613 .open = acpi_ec_info_open_fs,
616 .release = single_release,
617 .owner = THIS_MODULE,
620 static int acpi_ec_add_fs(struct acpi_device *device)
622 struct proc_dir_entry *entry = NULL;
624 if (!acpi_device_dir(device)) {
625 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
627 if (!acpi_device_dir(device))
631 entry = create_proc_entry(ACPI_EC_FILE_INFO, S_IRUGO,
632 acpi_device_dir(device));
636 entry->proc_fops = &acpi_ec_info_ops;
637 entry->data = acpi_driver_data(device);
638 entry->owner = THIS_MODULE;
644 static int acpi_ec_remove_fs(struct acpi_device *device)
647 if (acpi_device_dir(device)) {
648 remove_proc_entry(ACPI_EC_FILE_INFO, acpi_device_dir(device));
649 remove_proc_entry(acpi_device_bid(device), acpi_ec_dir);
650 acpi_device_dir(device) = NULL;
656 /* --------------------------------------------------------------------------
658 -------------------------------------------------------------------------- */
660 ec_parse_io_ports(struct acpi_resource *resource, void *context);
662 static struct acpi_ec *make_acpi_ec(void)
664 struct acpi_ec *ec = kzalloc(sizeof(struct acpi_ec), GFP_KERNEL);
667 ec->flags = 1 << EC_FLAGS_QUERY_PENDING;
668 mutex_init(&ec->lock);
669 init_waitqueue_head(&ec->wait);
670 INIT_LIST_HEAD(&ec->list);
675 acpi_ec_register_query_methods(acpi_handle handle, u32 level,
676 void *context, void **return_value)
678 struct acpi_namespace_node *node = handle;
679 struct acpi_ec *ec = context;
681 if (sscanf(node->name.ascii, "_Q%x", &value) == 1) {
682 acpi_ec_add_query_handler(ec, value, handle, NULL, NULL);
688 ec_parse_device(acpi_handle handle, u32 Level, void *context, void **retval)
692 struct acpi_ec *ec = context;
693 status = acpi_walk_resources(handle, METHOD_NAME__CRS,
694 ec_parse_io_ports, ec);
695 if (ACPI_FAILURE(status))
698 /* Get GPE bit assignment (EC events). */
699 /* TODO: Add support for _GPE returning a package */
700 status = acpi_evaluate_integer(handle, "_GPE", NULL, &ec->gpe);
701 if (ACPI_FAILURE(status))
703 /* Find and register all query methods */
704 acpi_walk_namespace(ACPI_TYPE_METHOD, handle, 1,
705 acpi_ec_register_query_methods, ec, NULL);
706 /* Use the global lock for all EC transactions? */
707 acpi_evaluate_integer(handle, "_GLK", NULL, &ec->global_lock);
709 return AE_CTRL_TERMINATE;
712 static void ec_remove_handlers(struct acpi_ec *ec)
714 if (ACPI_FAILURE(acpi_remove_address_space_handler(ec->handle,
715 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler)))
716 pr_err(PREFIX "failed to remove space handler\n");
717 if (ACPI_FAILURE(acpi_remove_gpe_handler(NULL, ec->gpe,
718 &acpi_ec_gpe_handler)))
719 pr_err(PREFIX "failed to remove gpe handler\n");
720 ec->handlers_installed = 0;
723 static int acpi_ec_add(struct acpi_device *device)
725 struct acpi_ec *ec = NULL;
729 strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME);
730 strcpy(acpi_device_class(device), ACPI_EC_CLASS);
732 /* Check for boot EC */
734 if (boot_ec->handle == device->handle) {
735 /* Pre-loaded EC from DSDT, just move pointer */
739 } else if (boot_ec->handle == ACPI_ROOT_OBJECT) {
740 /* ECDT-based EC, time to shut it down */
741 ec_remove_handlers(boot_ec);
743 first_ec = boot_ec = NULL;
751 if (ec_parse_device(device->handle, 0, ec, NULL) !=
756 ec->handle = device->handle;
760 acpi_driver_data(device) = ec;
761 acpi_ec_add_fs(device);
762 pr_info(PREFIX "GPE = 0x%lx, I/O: command/status = 0x%lx, data = 0x%lx\n",
763 ec->gpe, ec->command_addr, ec->data_addr);
764 pr_info(PREFIX "driver started in %s mode\n",
765 (test_bit(EC_FLAGS_GPE_MODE, &ec->flags))?"interrupt":"poll");
769 static int acpi_ec_remove(struct acpi_device *device, int type)
772 struct acpi_ec_query_handler *handler, *tmp;
777 ec = acpi_driver_data(device);
778 mutex_lock(&ec->lock);
779 list_for_each_entry_safe(handler, tmp, &ec->list, node) {
780 list_del(&handler->node);
783 mutex_unlock(&ec->lock);
784 acpi_ec_remove_fs(device);
785 acpi_driver_data(device) = NULL;
793 ec_parse_io_ports(struct acpi_resource *resource, void *context)
795 struct acpi_ec *ec = context;
797 if (resource->type != ACPI_RESOURCE_TYPE_IO)
801 * The first address region returned is the data port, and
802 * the second address region returned is the status/command
805 if (ec->data_addr == 0)
806 ec->data_addr = resource->data.io.minimum;
807 else if (ec->command_addr == 0)
808 ec->command_addr = resource->data.io.minimum;
810 return AE_CTRL_TERMINATE;
815 static int ec_install_handlers(struct acpi_ec *ec)
818 if (ec->handlers_installed)
820 status = acpi_install_gpe_handler(NULL, ec->gpe,
821 ACPI_GPE_EDGE_TRIGGERED,
822 &acpi_ec_gpe_handler, ec);
823 if (ACPI_FAILURE(status))
826 acpi_set_gpe_type(NULL, ec->gpe, ACPI_GPE_TYPE_RUNTIME);
827 acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR);
829 status = acpi_install_address_space_handler(ec->handle,
831 &acpi_ec_space_handler,
832 &acpi_ec_space_setup, ec);
833 if (ACPI_FAILURE(status)) {
834 acpi_remove_gpe_handler(NULL, ec->gpe, &acpi_ec_gpe_handler);
838 ec->handlers_installed = 1;
842 static int acpi_ec_start(struct acpi_device *device)
850 ec = acpi_driver_data(device);
855 ret = ec_install_handlers(ec);
857 /* EC is fully operational, allow queries */
858 clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags);
862 static int acpi_ec_stop(struct acpi_device *device, int type)
867 ec = acpi_driver_data(device);
870 ec_remove_handlers(ec);
875 int __init acpi_ec_ecdt_probe(void)
879 struct acpi_table_ecdt *ecdt_ptr;
881 boot_ec = make_acpi_ec();
885 * Generate a boot ec context
887 status = acpi_get_table(ACPI_SIG_ECDT, 1,
888 (struct acpi_table_header **)&ecdt_ptr);
889 if (ACPI_SUCCESS(status)) {
890 pr_info(PREFIX "EC description table is found, configuring boot EC\n");
891 boot_ec->command_addr = ecdt_ptr->control.address;
892 boot_ec->data_addr = ecdt_ptr->data.address;
893 boot_ec->gpe = ecdt_ptr->gpe;
894 boot_ec->handle = ACPI_ROOT_OBJECT;
896 printk(KERN_DEBUG PREFIX "Look up EC in DSDT\n");
897 status = acpi_get_devices(ec_device_ids[0].id, ec_parse_device,
899 /* Check that acpi_get_devices actually find something */
900 if (ACPI_FAILURE(status) || !boot_ec->handle)
904 ret = ec_install_handlers(boot_ec);
915 static int __init acpi_ec_init(void)
922 acpi_ec_dir = proc_mkdir(ACPI_EC_CLASS, acpi_root_dir);
926 /* Now register the driver for the EC */
927 result = acpi_bus_register_driver(&acpi_ec_driver);
929 remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir);
936 subsys_initcall(acpi_ec_init);
938 /* EC driver currently not unloadable */
940 static void __exit acpi_ec_exit(void)
943 acpi_bus_unregister_driver(&acpi_ec_driver);
945 remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir);