blob: 9d6795299af1d0e7b5f18edd7264cc7e9c0d7242 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * acpi_ec.c - ACPI Embedded Controller Driver ($Revision: 38 $)
3 *
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>
7 *
8 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9 *
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.
14 *
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.
19 *
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.
23 *
24 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
25 */
26
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>
Dmitry Torokhov451566f2005-03-19 01:10:05 -050034#include <linux/interrupt.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070035#include <asm/io.h>
36#include <acpi/acpi_bus.h>
37#include <acpi/acpi_drivers.h>
38#include <acpi/actypes.h>
39
40#define _COMPONENT ACPI_EC_COMPONENT
Len Brownf52fd662007-02-12 22:42:12 -050041ACPI_MODULE_NAME("ec");
Linus Torvalds1da177e2005-04-16 15:20:36 -070042#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"
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +030048#undef PREFIX
49#define PREFIX "ACPI: EC: "
Denis M. Sadykov703959d2006-09-26 19:50:33 +040050/* EC status register */
Linus Torvalds1da177e2005-04-16 15:20:36 -070051#define ACPI_EC_FLAG_OBF 0x01 /* Output buffer full */
52#define ACPI_EC_FLAG_IBF 0x02 /* Input buffer full */
Dmitry Torokhov451566f2005-03-19 01:10:05 -050053#define ACPI_EC_FLAG_BURST 0x10 /* burst mode */
Linus Torvalds1da177e2005-04-16 15:20:36 -070054#define ACPI_EC_FLAG_SCI 0x20 /* EC-SCI occurred */
Denis M. Sadykov703959d2006-09-26 19:50:33 +040055/* EC commands */
Alexey Starikovskiy3261ff42006-12-07 18:42:17 +030056enum ec_command {
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +030057 ACPI_EC_COMMAND_READ = 0x80,
58 ACPI_EC_COMMAND_WRITE = 0x81,
59 ACPI_EC_BURST_ENABLE = 0x82,
60 ACPI_EC_BURST_DISABLE = 0x83,
61 ACPI_EC_COMMAND_QUERY = 0x84,
Alexey Starikovskiy3261ff42006-12-07 18:42:17 +030062};
Denis M. Sadykov703959d2006-09-26 19:50:33 +040063/* EC events */
Alexey Starikovskiy3261ff42006-12-07 18:42:17 +030064enum ec_event {
Denis M. Sadykov703959d2006-09-26 19:50:33 +040065 ACPI_EC_EVENT_OBF_1 = 1, /* Output buffer full */
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +030066 ACPI_EC_EVENT_IBF_0, /* Input buffer empty */
Denis M. Sadykov703959d2006-09-26 19:50:33 +040067};
68
Alexey Starikovskiy5c406412006-12-07 18:42:16 +030069#define ACPI_EC_DELAY 500 /* Wait 500ms max. during EC ops */
Denis M. Sadykov703959d2006-09-26 19:50:33 +040070#define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */
Denis M. Sadykov703959d2006-09-26 19:50:33 +040071
Alexey Starikovskiy3261ff42006-12-07 18:42:17 +030072static enum ec_mode {
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +030073 EC_INTR = 1, /* Output buffer full */
74 EC_POLL, /* Input buffer empty */
Alexey Starikovskiy3261ff42006-12-07 18:42:17 +030075} acpi_ec_mode = EC_INTR;
Denis M. Sadykov703959d2006-09-26 19:50:33 +040076
Len Brown50526df2005-08-11 17:32:05 -040077static int acpi_ec_remove(struct acpi_device *device, int type);
78static int acpi_ec_start(struct acpi_device *device);
79static int acpi_ec_stop(struct acpi_device *device, int type);
Denis M. Sadykov703959d2006-09-26 19:50:33 +040080static int acpi_ec_add(struct acpi_device *device);
Linus Torvalds1da177e2005-04-16 15:20:36 -070081
82static struct acpi_driver acpi_ec_driver = {
Len Brownc2b67052007-02-12 23:33:40 -050083 .name = "ec",
Len Brown50526df2005-08-11 17:32:05 -040084 .class = ACPI_EC_CLASS,
85 .ids = ACPI_EC_HID,
86 .ops = {
Denis M. Sadykov703959d2006-09-26 19:50:33 +040087 .add = acpi_ec_add,
Len Brown50526df2005-08-11 17:32:05 -040088 .remove = acpi_ec_remove,
89 .start = acpi_ec_start,
90 .stop = acpi_ec_stop,
91 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070092};
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +040093
94/* If we find an EC via the ECDT, we need to keep a ptr to its context */
Adrian Bunka854e082006-12-19 12:56:12 -080095static struct acpi_ec {
Denis M. Sadykov703959d2006-09-26 19:50:33 +040096 acpi_handle handle;
97 unsigned long uid;
Alexey Starikovskiya86e2772006-12-07 18:42:16 +030098 unsigned long gpe;
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +040099 unsigned long command_addr;
100 unsigned long data_addr;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400101 unsigned long global_lock;
Alexey Starikovskiyc787a852006-12-07 18:42:16 +0300102 struct mutex lock;
Alexey Starikovskiy5d0c2882006-12-07 18:42:16 +0300103 atomic_t query_pending;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400104 atomic_t leaving_burst; /* 0 : No, 1 : Yes, 2: abort */
105 wait_queue_head_t wait;
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400106} *ec_ecdt;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400107
108/* External interfaces use first EC only, so remember */
109static struct acpi_device *first_ec;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400110
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111/* --------------------------------------------------------------------------
112 Transaction Management
113 -------------------------------------------------------------------------- */
114
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400115static inline u8 acpi_ec_read_status(struct acpi_ec *ec)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116{
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400117 return inb(ec->command_addr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118}
119
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400120static inline u8 acpi_ec_read_data(struct acpi_ec *ec)
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400121{
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400122 return inb(ec->data_addr);
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400123}
124
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400125static inline void acpi_ec_write_cmd(struct acpi_ec *ec, u8 command)
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400126{
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400127 outb(command, ec->command_addr);
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400128}
129
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400130static inline void acpi_ec_write_data(struct acpi_ec *ec, u8 data)
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400131{
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400132 outb(data, ec->data_addr);
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400133}
134
Alexey Starikovskiy3261ff42006-12-07 18:42:17 +0300135static inline int acpi_ec_check_status(struct acpi_ec *ec, enum ec_event event)
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400136{
Alexey Starikovskiybec5a1e2006-12-07 18:42:16 +0300137 u8 status = acpi_ec_read_status(ec);
Alexey Starikovskiy78d0af32006-12-07 18:42:17 +0300138
139 if (event == ACPI_EC_EVENT_OBF_1) {
Denis M. Sadykov7c6db5e2006-09-26 19:50:33 +0400140 if (status & ACPI_EC_FLAG_OBF)
141 return 1;
Alexey Starikovskiy78d0af32006-12-07 18:42:17 +0300142 } else if (event == ACPI_EC_EVENT_IBF_0) {
Denis M. Sadykov7c6db5e2006-09-26 19:50:33 +0400143 if (!(status & ACPI_EC_FLAG_IBF))
144 return 1;
Denis M. Sadykov7c6db5e2006-09-26 19:50:33 +0400145 }
146
147 return 0;
148}
149
Alexey Starikovskiy3261ff42006-12-07 18:42:17 +0300150static int acpi_ec_wait(struct acpi_ec *ec, enum ec_event event)
Luming Yu45bea152005-07-23 04:08:00 -0400151{
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300152 if (acpi_ec_mode == EC_POLL) {
Alexey Starikovskiy50c1e112006-12-07 18:42:17 +0300153 unsigned long delay = jiffies + msecs_to_jiffies(ACPI_EC_DELAY);
154 while (time_before(jiffies, delay)) {
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300155 if (acpi_ec_check_status(ec, event))
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400156 return 0;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400157 }
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300158 } else {
159 if (wait_event_timeout(ec->wait,
160 acpi_ec_check_status(ec, event),
161 msecs_to_jiffies(ACPI_EC_DELAY)) ||
162 acpi_ec_check_status(ec, event)) {
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400163 return 0;
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300164 } else {
165 printk(KERN_ERR PREFIX "acpi_ec_wait timeout,"
166 " status = %d, expect_event = %d\n",
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300167 acpi_ec_read_status(ec), event);
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400168 }
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300169 }
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400170
Patrick Mocheld550d982006-06-27 00:41:40 -0400171 return -ETIME;
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500172}
173
Len Brown02b28a332005-12-05 16:33:04 -0500174#ifdef ACPI_FUTURE_USAGE
Luming Yu06a2a382005-09-27 00:43:00 -0400175/*
176 * Note: samsung nv5000 doesn't work with ec burst mode.
177 * http://bugzilla.kernel.org/show_bug.cgi?id=4980
178 */
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400179int acpi_ec_enter_burst_mode(struct acpi_ec *ec)
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500180{
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400181 u8 tmp = 0;
182 u8 status = 0;
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500183
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500184 status = acpi_ec_read_status(ec);
Len Brown50526df2005-08-11 17:32:05 -0400185 if (status != -EINVAL && !(status & ACPI_EC_FLAG_BURST)) {
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400186 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
Len Brown50526df2005-08-11 17:32:05 -0400187 if (status)
Luming Yu716e0842005-08-10 01:40:00 -0400188 goto end;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400189 acpi_ec_write_cmd(ec, ACPI_EC_BURST_ENABLE);
190 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1);
191 tmp = acpi_ec_read_data(ec);
Len Brown50526df2005-08-11 17:32:05 -0400192 if (tmp != 0x90) { /* Burst ACK byte */
Patrick Mocheld550d982006-06-27 00:41:40 -0400193 return -EINVAL;
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500194 }
Luming Yu668d74c2005-07-23 00:26:33 -0400195 }
196
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400197 atomic_set(&ec->leaving_burst, 0);
Patrick Mocheld550d982006-06-27 00:41:40 -0400198 return 0;
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300199 end:
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400200 ACPI_EXCEPTION((AE_INFO, status, "EC wait, burst mode"));
Patrick Mocheld550d982006-06-27 00:41:40 -0400201 return -1;
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500202}
203
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400204int acpi_ec_leave_burst_mode(struct acpi_ec *ec)
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500205{
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400206 u8 status = 0;
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500207
Luming Yu06a2a382005-09-27 00:43:00 -0400208 status = acpi_ec_read_status(ec);
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300209 if (status != -EINVAL && (status & ACPI_EC_FLAG_BURST)) {
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400210 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300211 if (status)
Luming Yu06a2a382005-09-27 00:43:00 -0400212 goto end;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400213 acpi_ec_write_cmd(ec, ACPI_EC_BURST_DISABLE);
214 acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
Denis M. Sadykov7c6db5e2006-09-26 19:50:33 +0400215 }
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400216 atomic_set(&ec->leaving_burst, 1);
Patrick Mocheld550d982006-06-27 00:41:40 -0400217 return 0;
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300218 end:
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400219 ACPI_EXCEPTION((AE_INFO, status, "EC leave burst mode"));
Patrick Mocheld550d982006-06-27 00:41:40 -0400220 return -1;
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500221}
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300222#endif /* ACPI_FUTURE_USAGE */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400224static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command,
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300225 const u8 * wdata, unsigned wdata_len,
226 u8 * rdata, unsigned rdata_len)
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400227{
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300228 int result = 0;
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400229
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400230 acpi_ec_write_cmd(ec, command);
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400231
Alexey Starikovskiy78d0af32006-12-07 18:42:17 +0300232 for (; wdata_len > 0; --wdata_len) {
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400233 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300234 if (result) {
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300235 printk(KERN_ERR PREFIX
236 "write_cmd timeout, command = %d\n", command);
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300237 goto end;
238 }
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400239 acpi_ec_write_data(ec, *(wdata++));
Denis M. Sadykov3576cf62006-09-26 19:50:33 +0400240 }
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400241
Alexey Starikovskiyd91df1a2006-12-07 18:42:16 +0300242 if (!rdata_len) {
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400243 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300244 if (result) {
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300245 printk(KERN_ERR PREFIX
246 "finish-write timeout, command = %d\n", command);
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300247 goto end;
248 }
Alexey Starikovskiy5d0c2882006-12-07 18:42:16 +0300249 } else if (command == ACPI_EC_COMMAND_QUERY) {
250 atomic_set(&ec->query_pending, 0);
Denis M. Sadykov7c6db5e2006-09-26 19:50:33 +0400251 }
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400252
Alexey Starikovskiy78d0af32006-12-07 18:42:17 +0300253 for (; rdata_len > 0; --rdata_len) {
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400254 result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1);
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300255 if (result) {
256 printk(KERN_ERR PREFIX "read timeout, command = %d\n",
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300257 command);
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300258 goto end;
259 }
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400260
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400261 *(rdata++) = acpi_ec_read_data(ec);
Denis M. Sadykov7c6db5e2006-09-26 19:50:33 +0400262 }
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300263 end:
264 return result;
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400265}
266
Denis M. Sadykov3576cf62006-09-26 19:50:33 +0400267static int acpi_ec_transaction(struct acpi_ec *ec, u8 command,
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300268 const u8 * wdata, unsigned wdata_len,
269 u8 * rdata, unsigned rdata_len)
Luming Yu45bea152005-07-23 04:08:00 -0400270{
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400271 int status;
Len Brown50526df2005-08-11 17:32:05 -0400272 u32 glk;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400274 if (!ec || (wdata_len && !wdata) || (rdata_len && !rdata))
Patrick Mocheld550d982006-06-27 00:41:40 -0400275 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700276
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300277 if (rdata)
278 memset(rdata, 0, rdata_len);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279
Alexey Starikovskiy523953b2006-12-07 18:42:17 +0300280 mutex_lock(&ec->lock);
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400281 if (ec->global_lock) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
283 if (ACPI_FAILURE(status))
Patrick Mocheld550d982006-06-27 00:41:40 -0400284 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285 }
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500286
Alexey Starikovskiy5d57a6a2006-12-07 18:42:16 +0300287 /* Make sure GPE is enabled before doing transaction */
Alexey Starikovskiya86e2772006-12-07 18:42:16 +0300288 acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR);
Alexey Starikovskiy5d57a6a2006-12-07 18:42:16 +0300289
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400290 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
Luming Yu716e0842005-08-10 01:40:00 -0400291 if (status) {
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300292 printk(KERN_DEBUG PREFIX
293 "input buffer is not empty, aborting transaction\n");
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500294 goto end;
Luming Yu716e0842005-08-10 01:40:00 -0400295 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300297 status = acpi_ec_transaction_unlocked(ec, command,
298 wdata, wdata_len,
299 rdata, rdata_len);
Len Brown50526df2005-08-11 17:32:05 -0400300
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300301 end:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400303 if (ec->global_lock)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700304 acpi_release_global_lock(glk);
Alexey Starikovskiy523953b2006-12-07 18:42:17 +0300305 mutex_unlock(&ec->lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306
Patrick Mocheld550d982006-06-27 00:41:40 -0400307 return status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308}
309
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300310static int acpi_ec_read(struct acpi_ec *ec, u8 address, u8 * data)
Denis M. Sadykov3576cf62006-09-26 19:50:33 +0400311{
312 int result;
313 u8 d;
314
315 result = acpi_ec_transaction(ec, ACPI_EC_COMMAND_READ,
316 &address, 1, &d, 1);
317 *data = d;
318 return result;
319}
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400320
Denis M. Sadykov3576cf62006-09-26 19:50:33 +0400321static int acpi_ec_write(struct acpi_ec *ec, u8 address, u8 data)
322{
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300323 u8 wdata[2] = { address, data };
324 return acpi_ec_transaction(ec, ACPI_EC_COMMAND_WRITE,
Denis M. Sadykov3576cf62006-09-26 19:50:33 +0400325 wdata, 2, NULL, 0);
326}
327
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328/*
329 * Externally callable EC access functions. For now, assume 1 EC only
330 */
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300331int ec_read(u8 addr, u8 * val)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700332{
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400333 struct acpi_ec *ec;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334 int err;
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400335 u8 temp_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700336
337 if (!first_ec)
338 return -ENODEV;
339
340 ec = acpi_driver_data(first_ec);
341
342 err = acpi_ec_read(ec, addr, &temp_data);
343
344 if (!err) {
345 *val = temp_data;
346 return 0;
Len Brown50526df2005-08-11 17:32:05 -0400347 } else
Linus Torvalds1da177e2005-04-16 15:20:36 -0700348 return err;
349}
Len Brown50526df2005-08-11 17:32:05 -0400350
Linus Torvalds1da177e2005-04-16 15:20:36 -0700351EXPORT_SYMBOL(ec_read);
352
Len Brown50526df2005-08-11 17:32:05 -0400353int ec_write(u8 addr, u8 val)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354{
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400355 struct acpi_ec *ec;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700356 int err;
357
358 if (!first_ec)
359 return -ENODEV;
360
361 ec = acpi_driver_data(first_ec);
362
363 err = acpi_ec_write(ec, addr, val);
364
365 return err;
366}
Len Brown50526df2005-08-11 17:32:05 -0400367
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368EXPORT_SYMBOL(ec_write);
369
Randy Dunlap616362d2006-10-27 01:47:34 -0400370int ec_transaction(u8 command,
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300371 const u8 * wdata, unsigned wdata_len,
372 u8 * rdata, unsigned rdata_len)
Luming Yu45bea152005-07-23 04:08:00 -0400373{
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400374 struct acpi_ec *ec;
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400375
376 if (!first_ec)
377 return -ENODEV;
378
379 ec = acpi_driver_data(first_ec);
380
Denis M. Sadykov3576cf62006-09-26 19:50:33 +0400381 return acpi_ec_transaction(ec, command, wdata,
382 wdata_len, rdata, rdata_len);
Luming Yu45bea152005-07-23 04:08:00 -0400383}
Luming Yu45bea152005-07-23 04:08:00 -0400384
Lennart Poetteringab9e43c2006-10-03 22:49:00 -0400385EXPORT_SYMBOL(ec_transaction);
386
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300387static int acpi_ec_query(struct acpi_ec *ec, u8 * data)
Denis M. Sadykov3576cf62006-09-26 19:50:33 +0400388{
389 int result;
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300390 u8 d;
Luming Yu45bea152005-07-23 04:08:00 -0400391
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300392 if (!ec || !data)
393 return -EINVAL;
Luming Yu45bea152005-07-23 04:08:00 -0400394
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300395 /*
396 * Query the EC to find out which _Qxx method we need to evaluate.
397 * Note that successful completion of the query causes the ACPI_EC_SCI
398 * bit to be cleared (and thus clearing the interrupt source).
399 */
Luming Yu45bea152005-07-23 04:08:00 -0400400
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300401 result = acpi_ec_transaction(ec, ACPI_EC_COMMAND_QUERY, NULL, 0, &d, 1);
402 if (result)
403 return result;
Luming Yu45bea152005-07-23 04:08:00 -0400404
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300405 if (!d)
406 return -ENODATA;
Luming Yu45bea152005-07-23 04:08:00 -0400407
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300408 *data = d;
409 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700410}
411
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412/* --------------------------------------------------------------------------
413 Event Management
414 -------------------------------------------------------------------------- */
415
Len Brown50526df2005-08-11 17:32:05 -0400416static void acpi_ec_gpe_query(void *ec_cxt)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700417{
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400418 struct acpi_ec *ec = (struct acpi_ec *)ec_cxt;
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400419 u8 value = 0;
Alexey Starikovskiy5d0c2882006-12-07 18:42:16 +0300420 char object_name[8];
Luming Yu45bea152005-07-23 04:08:00 -0400421
Alexey Starikovskiy5d0c2882006-12-07 18:42:16 +0300422 if (!ec || acpi_ec_query(ec, &value))
Alexey Starikovskiye41334c2006-12-07 18:42:16 +0300423 return;
Luming Yu45bea152005-07-23 04:08:00 -0400424
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400425 snprintf(object_name, 8, "_Q%2.2X", value);
Luming Yu45bea152005-07-23 04:08:00 -0400426
Guillaume Chazarainc6e19192006-12-24 22:19:02 +0100427 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluating %s", object_name));
Luming Yu45bea152005-07-23 04:08:00 -0400428
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400429 acpi_evaluate_object(ec->handle, object_name, NULL, NULL);
Luming Yu45bea152005-07-23 04:08:00 -0400430}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431
Len Brown50526df2005-08-11 17:32:05 -0400432static u32 acpi_ec_gpe_handler(void *data)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700433{
Len Brown50526df2005-08-11 17:32:05 -0400434 acpi_status status = AE_OK;
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400435 u8 value;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400436 struct acpi_ec *ec = (struct acpi_ec *)data;
Luming Yu45bea152005-07-23 04:08:00 -0400437
Denis M. Sadykov8e0341b2006-09-26 19:50:33 +0400438 if (acpi_ec_mode == EC_INTR) {
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300439 wake_up(&ec->wait);
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500440 }
441
Alexey Starikovskiybec5a1e2006-12-07 18:42:16 +0300442 value = acpi_ec_read_status(ec);
Alexey Starikovskiy5d0c2882006-12-07 18:42:16 +0300443 if ((value & ACPI_EC_FLAG_SCI) && !atomic_read(&ec->query_pending)) {
444 atomic_set(&ec->query_pending, 1);
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300445 status =
446 acpi_os_execute(OSL_EC_BURST_HANDLER, acpi_ec_gpe_query,
447 ec);
Len Brown50526df2005-08-11 17:32:05 -0400448 }
Alexey Starikovskiye41334c2006-12-07 18:42:16 +0300449
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500450 return status == AE_OK ?
Len Brown50526df2005-08-11 17:32:05 -0400451 ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700452}
453
454/* --------------------------------------------------------------------------
455 Address Space Management
456 -------------------------------------------------------------------------- */
457
458static acpi_status
Len Brown50526df2005-08-11 17:32:05 -0400459acpi_ec_space_setup(acpi_handle region_handle,
460 u32 function, void *handler_context, void **return_context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700461{
462 /*
463 * The EC object is in the handler context and is needed
464 * when calling the acpi_ec_space_handler.
465 */
Len Brown50526df2005-08-11 17:32:05 -0400466 *return_context = (function != ACPI_REGION_DEACTIVATE) ?
467 handler_context : NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700468
469 return AE_OK;
470}
471
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472static acpi_status
Len Brown50526df2005-08-11 17:32:05 -0400473acpi_ec_space_handler(u32 function,
474 acpi_physical_address address,
475 u32 bit_width,
476 acpi_integer * value,
477 void *handler_context, void *region_context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700478{
Len Brown50526df2005-08-11 17:32:05 -0400479 int result = 0;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400480 struct acpi_ec *ec = NULL;
Len Brown50526df2005-08-11 17:32:05 -0400481 u64 temp = *value;
482 acpi_integer f_v = 0;
483 int i = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700484
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485 if ((address > 0xFF) || !value || !handler_context)
Patrick Mocheld550d982006-06-27 00:41:40 -0400486 return AE_BAD_PARAMETER;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487
Luming Yufa9cd542005-03-19 01:54:47 -0500488 if (bit_width != 8 && acpi_strict) {
Patrick Mocheld550d982006-06-27 00:41:40 -0400489 return AE_BAD_PARAMETER;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700490 }
491
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400492 ec = (struct acpi_ec *)handler_context;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493
Len Brown50526df2005-08-11 17:32:05 -0400494 next_byte:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700495 switch (function) {
496 case ACPI_READ:
Luming Yufa9cd542005-03-19 01:54:47 -0500497 temp = 0;
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300498 result = acpi_ec_read(ec, (u8) address, (u8 *) & temp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700499 break;
500 case ACPI_WRITE:
Luming Yufa9cd542005-03-19 01:54:47 -0500501 result = acpi_ec_write(ec, (u8) address, (u8) temp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700502 break;
503 default:
504 result = -EINVAL;
505 goto out;
506 break;
507 }
508
509 bit_width -= 8;
Luming Yufa9cd542005-03-19 01:54:47 -0500510 if (bit_width) {
511 if (function == ACPI_READ)
512 f_v |= temp << 8 * i;
513 if (function == ACPI_WRITE)
514 temp >>= 8;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700515 i++;
Andrew Morton83ea7442005-03-30 22:12:13 -0500516 address++;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700517 goto next_byte;
518 }
519
Luming Yufa9cd542005-03-19 01:54:47 -0500520 if (function == ACPI_READ) {
521 f_v |= temp << 8 * i;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522 *value = f_v;
523 }
524
Len Brown50526df2005-08-11 17:32:05 -0400525 out:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700526 switch (result) {
527 case -EINVAL:
Patrick Mocheld550d982006-06-27 00:41:40 -0400528 return AE_BAD_PARAMETER;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700529 break;
530 case -ENODEV:
Patrick Mocheld550d982006-06-27 00:41:40 -0400531 return AE_NOT_FOUND;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700532 break;
533 case -ETIME:
Patrick Mocheld550d982006-06-27 00:41:40 -0400534 return AE_TIME;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700535 break;
536 default:
Patrick Mocheld550d982006-06-27 00:41:40 -0400537 return AE_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700538 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700539}
540
Linus Torvalds1da177e2005-04-16 15:20:36 -0700541/* --------------------------------------------------------------------------
542 FS Interface (/proc)
543 -------------------------------------------------------------------------- */
544
Len Brown50526df2005-08-11 17:32:05 -0400545static struct proc_dir_entry *acpi_ec_dir;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700546
Len Brown50526df2005-08-11 17:32:05 -0400547static int acpi_ec_read_info(struct seq_file *seq, void *offset)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700548{
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400549 struct acpi_ec *ec = (struct acpi_ec *)seq->private;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550
Linus Torvalds1da177e2005-04-16 15:20:36 -0700551 if (!ec)
552 goto end;
553
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300554 seq_printf(seq, "gpe: 0x%02x\n", (u32) ec->gpe);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700555 seq_printf(seq, "ports: 0x%02x, 0x%02x\n",
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300556 (u32) ec->command_addr, (u32) ec->data_addr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700557 seq_printf(seq, "use global lock: %s\n",
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400558 ec->global_lock ? "yes" : "no");
Alexey Starikovskiya86e2772006-12-07 18:42:16 +0300559 acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700560
Len Brown50526df2005-08-11 17:32:05 -0400561 end:
Patrick Mocheld550d982006-06-27 00:41:40 -0400562 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700563}
564
565static int acpi_ec_info_open_fs(struct inode *inode, struct file *file)
566{
567 return single_open(file, acpi_ec_read_info, PDE(inode)->data);
568}
569
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400570static struct file_operations acpi_ec_info_ops = {
Len Brown50526df2005-08-11 17:32:05 -0400571 .open = acpi_ec_info_open_fs,
572 .read = seq_read,
573 .llseek = seq_lseek,
574 .release = single_release,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700575 .owner = THIS_MODULE,
576};
577
Len Brown50526df2005-08-11 17:32:05 -0400578static int acpi_ec_add_fs(struct acpi_device *device)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700579{
Len Brown50526df2005-08-11 17:32:05 -0400580 struct proc_dir_entry *entry = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700581
Linus Torvalds1da177e2005-04-16 15:20:36 -0700582 if (!acpi_device_dir(device)) {
583 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
Len Brown50526df2005-08-11 17:32:05 -0400584 acpi_ec_dir);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700585 if (!acpi_device_dir(device))
Patrick Mocheld550d982006-06-27 00:41:40 -0400586 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700587 }
588
589 entry = create_proc_entry(ACPI_EC_FILE_INFO, S_IRUGO,
Len Brown50526df2005-08-11 17:32:05 -0400590 acpi_device_dir(device));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700591 if (!entry)
Patrick Mocheld550d982006-06-27 00:41:40 -0400592 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700593 else {
594 entry->proc_fops = &acpi_ec_info_ops;
595 entry->data = acpi_driver_data(device);
596 entry->owner = THIS_MODULE;
597 }
598
Patrick Mocheld550d982006-06-27 00:41:40 -0400599 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700600}
601
Len Brown50526df2005-08-11 17:32:05 -0400602static int acpi_ec_remove_fs(struct acpi_device *device)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700603{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700604
605 if (acpi_device_dir(device)) {
606 remove_proc_entry(ACPI_EC_FILE_INFO, acpi_device_dir(device));
607 remove_proc_entry(acpi_device_bid(device), acpi_ec_dir);
608 acpi_device_dir(device) = NULL;
609 }
610
Patrick Mocheld550d982006-06-27 00:41:40 -0400611 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700612}
613
Linus Torvalds1da177e2005-04-16 15:20:36 -0700614/* --------------------------------------------------------------------------
615 Driver Interface
616 -------------------------------------------------------------------------- */
617
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400618static int acpi_ec_add(struct acpi_device *device)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700619{
Len Brown50526df2005-08-11 17:32:05 -0400620 int result = 0;
621 acpi_status status = AE_OK;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400622 struct acpi_ec *ec = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700623
Linus Torvalds1da177e2005-04-16 15:20:36 -0700624 if (!device)
Patrick Mocheld550d982006-06-27 00:41:40 -0400625 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700626
Burman Yan36bcbec2006-12-19 12:56:11 -0800627 ec = kzalloc(sizeof(struct acpi_ec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700628 if (!ec)
Patrick Mocheld550d982006-06-27 00:41:40 -0400629 return -ENOMEM;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700630
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400631 ec->handle = device->handle;
632 ec->uid = -1;
Alexey Starikovskiyc787a852006-12-07 18:42:16 +0300633 mutex_init(&ec->lock);
Alexey Starikovskiy5d0c2882006-12-07 18:42:16 +0300634 atomic_set(&ec->query_pending, 0);
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400635 if (acpi_ec_mode == EC_INTR) {
636 atomic_set(&ec->leaving_burst, 1);
637 init_waitqueue_head(&ec->wait);
638 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700639 strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME);
640 strcpy(acpi_device_class(device), ACPI_EC_CLASS);
641 acpi_driver_data(device) = ec;
642
643 /* Use the global lock for all EC transactions? */
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300644 acpi_evaluate_integer(ec->handle, "_GLK", NULL, &ec->global_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700645
Jiri Slabyff2fc3e2006-03-28 17:04:00 -0500646 /* XXX we don't test uids, because on some boxes ecdt uid = 0, see:
647 http://bugzilla.kernel.org/show_bug.cgi?id=6111 */
648 if (ec_ecdt) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700649 acpi_remove_address_space_handler(ACPI_ROOT_OBJECT,
Len Brown50526df2005-08-11 17:32:05 -0400650 ACPI_ADR_SPACE_EC,
651 &acpi_ec_space_handler);
652
Alexey Starikovskiya86e2772006-12-07 18:42:16 +0300653 acpi_remove_gpe_handler(NULL, ec_ecdt->gpe,
Len Brown50526df2005-08-11 17:32:05 -0400654 &acpi_ec_gpe_handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700655
656 kfree(ec_ecdt);
657 }
658
659 /* Get GPE bit assignment (EC events). */
660 /* TODO: Add support for _GPE returning a package */
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300661 status = acpi_evaluate_integer(ec->handle, "_GPE", NULL, &ec->gpe);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700662 if (ACPI_FAILURE(status)) {
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300663 ACPI_EXCEPTION((AE_INFO, status,
664 "Obtaining GPE bit assignment"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700665 result = -ENODEV;
666 goto end;
667 }
668
669 result = acpi_ec_add_fs(device);
670 if (result)
671 goto end;
672
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400673 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s [%s] (gpe %d) interrupt mode.",
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300674 acpi_device_name(device), acpi_device_bid(device),
675 (u32) ec->gpe));
Luming Yu45bea152005-07-23 04:08:00 -0400676
677 if (!first_ec)
678 first_ec = device;
679
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300680 end:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700681 if (result)
682 kfree(ec);
683
Patrick Mocheld550d982006-06-27 00:41:40 -0400684 return result;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700685}
686
Len Brown50526df2005-08-11 17:32:05 -0400687static int acpi_ec_remove(struct acpi_device *device, int type)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700688{
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400689 struct acpi_ec *ec = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700690
Linus Torvalds1da177e2005-04-16 15:20:36 -0700691 if (!device)
Patrick Mocheld550d982006-06-27 00:41:40 -0400692 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700693
694 ec = acpi_driver_data(device);
695
696 acpi_ec_remove_fs(device);
697
698 kfree(ec);
699
Patrick Mocheld550d982006-06-27 00:41:40 -0400700 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700701}
702
Linus Torvalds1da177e2005-04-16 15:20:36 -0700703static acpi_status
Len Brown50526df2005-08-11 17:32:05 -0400704acpi_ec_io_ports(struct acpi_resource *resource, void *context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700705{
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400706 struct acpi_ec *ec = (struct acpi_ec *)context;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700707
Bob Moore50eca3e2005-09-30 19:03:00 -0400708 if (resource->type != ACPI_RESOURCE_TYPE_IO) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700709 return AE_OK;
710 }
711
712 /*
713 * The first address region returned is the data port, and
714 * the second address region returned is the status/command
715 * port.
716 */
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400717 if (ec->data_addr == 0) {
718 ec->data_addr = resource->data.io.minimum;
719 } else if (ec->command_addr == 0) {
720 ec->command_addr = resource->data.io.minimum;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700721 } else {
722 return AE_CTRL_TERMINATE;
723 }
724
Linus Torvalds1da177e2005-04-16 15:20:36 -0700725 return AE_OK;
726}
727
Len Brown50526df2005-08-11 17:32:05 -0400728static int acpi_ec_start(struct acpi_device *device)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700729{
Len Brown50526df2005-08-11 17:32:05 -0400730 acpi_status status = AE_OK;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400731 struct acpi_ec *ec = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700732
Linus Torvalds1da177e2005-04-16 15:20:36 -0700733 if (!device)
Patrick Mocheld550d982006-06-27 00:41:40 -0400734 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700735
736 ec = acpi_driver_data(device);
737
738 if (!ec)
Patrick Mocheld550d982006-06-27 00:41:40 -0400739 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700740
741 /*
742 * Get I/O port addresses. Convert to GAS format.
743 */
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400744 status = acpi_walk_resources(ec->handle, METHOD_NAME__CRS,
Len Brown50526df2005-08-11 17:32:05 -0400745 acpi_ec_io_ports, ec);
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400746 if (ACPI_FAILURE(status) || ec->command_addr == 0) {
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400747 ACPI_EXCEPTION((AE_INFO, status,
748 "Error getting I/O port addresses"));
Patrick Mocheld550d982006-06-27 00:41:40 -0400749 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700750 }
751
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400752 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "gpe=0x%02lx, ports=0x%2lx,0x%2lx",
Alexey Starikovskiya86e2772006-12-07 18:42:16 +0300753 ec->gpe, ec->command_addr, ec->data_addr));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700754
755 /*
756 * Install GPE handler
757 */
Alexey Starikovskiya86e2772006-12-07 18:42:16 +0300758 status = acpi_install_gpe_handler(NULL, ec->gpe,
Len Brown50526df2005-08-11 17:32:05 -0400759 ACPI_GPE_EDGE_TRIGGERED,
760 &acpi_ec_gpe_handler, ec);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700761 if (ACPI_FAILURE(status)) {
Patrick Mocheld550d982006-06-27 00:41:40 -0400762 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700763 }
Alexey Starikovskiya86e2772006-12-07 18:42:16 +0300764 acpi_set_gpe_type(NULL, ec->gpe, ACPI_GPE_TYPE_RUNTIME);
765 acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700766
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400767 status = acpi_install_address_space_handler(ec->handle,
Len Brown50526df2005-08-11 17:32:05 -0400768 ACPI_ADR_SPACE_EC,
769 &acpi_ec_space_handler,
770 &acpi_ec_space_setup, ec);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700771 if (ACPI_FAILURE(status)) {
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300772 acpi_remove_gpe_handler(NULL, ec->gpe, &acpi_ec_gpe_handler);
Patrick Mocheld550d982006-06-27 00:41:40 -0400773 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700774 }
775
Patrick Mocheld550d982006-06-27 00:41:40 -0400776 return AE_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700777}
778
Len Brown50526df2005-08-11 17:32:05 -0400779static int acpi_ec_stop(struct acpi_device *device, int type)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700780{
Len Brown50526df2005-08-11 17:32:05 -0400781 acpi_status status = AE_OK;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400782 struct acpi_ec *ec = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700783
Linus Torvalds1da177e2005-04-16 15:20:36 -0700784 if (!device)
Patrick Mocheld550d982006-06-27 00:41:40 -0400785 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700786
787 ec = acpi_driver_data(device);
788
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400789 status = acpi_remove_address_space_handler(ec->handle,
Len Brown50526df2005-08-11 17:32:05 -0400790 ACPI_ADR_SPACE_EC,
791 &acpi_ec_space_handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700792 if (ACPI_FAILURE(status))
Patrick Mocheld550d982006-06-27 00:41:40 -0400793 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700794
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300795 status = acpi_remove_gpe_handler(NULL, ec->gpe, &acpi_ec_gpe_handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700796 if (ACPI_FAILURE(status))
Patrick Mocheld550d982006-06-27 00:41:40 -0400797 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700798
Patrick Mocheld550d982006-06-27 00:41:40 -0400799 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700800}
801
802static acpi_status __init
Len Brown50526df2005-08-11 17:32:05 -0400803acpi_fake_ecdt_callback(acpi_handle handle,
804 u32 Level, void *context, void **retval)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700805{
Len Brown50526df2005-08-11 17:32:05 -0400806 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700807
Alexey Starikovskiyc787a852006-12-07 18:42:16 +0300808 mutex_init(&ec_ecdt->lock);
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400809 if (acpi_ec_mode == EC_INTR) {
810 init_waitqueue_head(&ec_ecdt->wait);
811 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700812 status = acpi_walk_resources(handle, METHOD_NAME__CRS,
Len Brown50526df2005-08-11 17:32:05 -0400813 acpi_ec_io_ports, ec_ecdt);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700814 if (ACPI_FAILURE(status))
815 return status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700816
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400817 ec_ecdt->uid = -1;
818 acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->uid);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700819
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300820 status = acpi_evaluate_integer(handle, "_GPE", NULL, &ec_ecdt->gpe);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700821 if (ACPI_FAILURE(status))
822 return status;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400823 ec_ecdt->global_lock = TRUE;
824 ec_ecdt->handle = handle;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700825
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400826 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "GPE=0x%02lx, ports=0x%2lx, 0x%2lx",
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300827 ec_ecdt->gpe, ec_ecdt->command_addr,
828 ec_ecdt->data_addr));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700829
830 return AE_CTRL_TERMINATE;
831}
832
833/*
834 * Some BIOS (such as some from Gateway laptops) access EC region very early
835 * such as in BAT0._INI or EC._INI before an EC device is found and
836 * do not provide an ECDT. According to ACPI spec, ECDT isn't mandatorily
837 * required, but if EC regison is accessed early, it is required.
838 * The routine tries to workaround the BIOS bug by pre-scan EC device
839 * It assumes that _CRS, _HID, _GPE, _UID methods of EC don't touch any
840 * op region (since _REG isn't invoked yet). The assumption is true for
841 * all systems found.
842 */
Len Brown50526df2005-08-11 17:32:05 -0400843static int __init acpi_ec_fake_ecdt(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700844{
Len Brown50526df2005-08-11 17:32:05 -0400845 acpi_status status;
846 int ret = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700847
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400848 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Try to make an fake ECDT"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700849
Burman Yan36bcbec2006-12-19 12:56:11 -0800850 ec_ecdt = kzalloc(sizeof(struct acpi_ec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700851 if (!ec_ecdt) {
852 ret = -ENOMEM;
853 goto error;
854 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700855
Len Brown50526df2005-08-11 17:32:05 -0400856 status = acpi_get_devices(ACPI_EC_HID,
857 acpi_fake_ecdt_callback, NULL, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700858 if (ACPI_FAILURE(status)) {
859 kfree(ec_ecdt);
860 ec_ecdt = NULL;
861 ret = -ENODEV;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400862 ACPI_EXCEPTION((AE_INFO, status, "Can't make an fake ECDT"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700863 goto error;
864 }
865 return 0;
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300866 error:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700867 return ret;
868}
869
Len Brown50526df2005-08-11 17:32:05 -0400870static int __init acpi_ec_get_real_ecdt(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700871{
Len Brown50526df2005-08-11 17:32:05 -0400872 acpi_status status;
873 struct acpi_table_ecdt *ecdt_ptr;
Luming Yu45bea152005-07-23 04:08:00 -0400874
Alexey Starikovskiy15a58ed2007-02-02 19:48:22 +0300875 status = acpi_get_table(ACPI_SIG_ECDT, 1,
876 (struct acpi_table_header **)&ecdt_ptr);
Luming Yu45bea152005-07-23 04:08:00 -0400877 if (ACPI_FAILURE(status))
878 return -ENODEV;
879
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400880 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found ECDT"));
Luming Yu45bea152005-07-23 04:08:00 -0400881
882 /*
883 * Generate a temporary ec context to use until the namespace is scanned
884 */
Burman Yan36bcbec2006-12-19 12:56:11 -0800885 ec_ecdt = kzalloc(sizeof(struct acpi_ec), GFP_KERNEL);
Luming Yu45bea152005-07-23 04:08:00 -0400886 if (!ec_ecdt)
887 return -ENOMEM;
Luming Yu45bea152005-07-23 04:08:00 -0400888
Alexey Starikovskiyc787a852006-12-07 18:42:16 +0300889 mutex_init(&ec_ecdt->lock);
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400890 if (acpi_ec_mode == EC_INTR) {
891 init_waitqueue_head(&ec_ecdt->wait);
892 }
Alexey Starikovskiyad363f82007-02-02 19:48:22 +0300893 ec_ecdt->command_addr = ecdt_ptr->control.address;
894 ec_ecdt->data_addr = ecdt_ptr->data.address;
895 ec_ecdt->gpe = ecdt_ptr->gpe;
Luming Yu45bea152005-07-23 04:08:00 -0400896 /* use the GL just to be safe */
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400897 ec_ecdt->global_lock = TRUE;
898 ec_ecdt->uid = ecdt_ptr->uid;
Luming Yu45bea152005-07-23 04:08:00 -0400899
Alexey Starikovskiyad363f82007-02-02 19:48:22 +0300900 status = acpi_get_handle(NULL, ecdt_ptr->id, &ec_ecdt->handle);
Luming Yu45bea152005-07-23 04:08:00 -0400901 if (ACPI_FAILURE(status)) {
902 goto error;
903 }
904
905 return 0;
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300906 error:
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400907 ACPI_EXCEPTION((AE_INFO, status, "Could not use ECDT"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700908 kfree(ec_ecdt);
909 ec_ecdt = NULL;
910
911 return -ENODEV;
912}
913
914static int __initdata acpi_fake_ecdt_enabled;
Len Brown50526df2005-08-11 17:32:05 -0400915int __init acpi_ec_ecdt_probe(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700916{
Len Brown50526df2005-08-11 17:32:05 -0400917 acpi_status status;
918 int ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700919
920 ret = acpi_ec_get_real_ecdt();
921 /* Try to make a fake ECDT */
922 if (ret && acpi_fake_ecdt_enabled) {
923 ret = acpi_ec_fake_ecdt();
924 }
925
926 if (ret)
927 return 0;
928
929 /*
930 * Install GPE handler
931 */
Alexey Starikovskiya86e2772006-12-07 18:42:16 +0300932 status = acpi_install_gpe_handler(NULL, ec_ecdt->gpe,
Len Brown50526df2005-08-11 17:32:05 -0400933 ACPI_GPE_EDGE_TRIGGERED,
934 &acpi_ec_gpe_handler, ec_ecdt);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700935 if (ACPI_FAILURE(status)) {
936 goto error;
937 }
Alexey Starikovskiya86e2772006-12-07 18:42:16 +0300938 acpi_set_gpe_type(NULL, ec_ecdt->gpe, ACPI_GPE_TYPE_RUNTIME);
939 acpi_enable_gpe(NULL, ec_ecdt->gpe, ACPI_NOT_ISR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700940
Len Brown50526df2005-08-11 17:32:05 -0400941 status = acpi_install_address_space_handler(ACPI_ROOT_OBJECT,
942 ACPI_ADR_SPACE_EC,
943 &acpi_ec_space_handler,
944 &acpi_ec_space_setup,
945 ec_ecdt);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700946 if (ACPI_FAILURE(status)) {
Alexey Starikovskiya86e2772006-12-07 18:42:16 +0300947 acpi_remove_gpe_handler(NULL, ec_ecdt->gpe,
Len Brown50526df2005-08-11 17:32:05 -0400948 &acpi_ec_gpe_handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700949 goto error;
950 }
951
952 return 0;
953
Len Brown50526df2005-08-11 17:32:05 -0400954 error:
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400955 ACPI_EXCEPTION((AE_INFO, status, "Could not use ECDT"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700956 kfree(ec_ecdt);
957 ec_ecdt = NULL;
958
959 return -ENODEV;
960}
961
Len Brown50526df2005-08-11 17:32:05 -0400962static int __init acpi_ec_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700963{
Len Brown50526df2005-08-11 17:32:05 -0400964 int result = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700965
Linus Torvalds1da177e2005-04-16 15:20:36 -0700966 if (acpi_disabled)
Patrick Mocheld550d982006-06-27 00:41:40 -0400967 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700968
969 acpi_ec_dir = proc_mkdir(ACPI_EC_CLASS, acpi_root_dir);
970 if (!acpi_ec_dir)
Patrick Mocheld550d982006-06-27 00:41:40 -0400971 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700972
973 /* Now register the driver for the EC */
974 result = acpi_bus_register_driver(&acpi_ec_driver);
975 if (result < 0) {
976 remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir);
Patrick Mocheld550d982006-06-27 00:41:40 -0400977 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700978 }
979
Patrick Mocheld550d982006-06-27 00:41:40 -0400980 return result;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700981}
982
983subsys_initcall(acpi_ec_init);
984
985/* EC driver currently not unloadable */
986#if 0
Len Brown50526df2005-08-11 17:32:05 -0400987static void __exit acpi_ec_exit(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700988{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700989
990 acpi_bus_unregister_driver(&acpi_ec_driver);
991
992 remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir);
993
Patrick Mocheld550d982006-06-27 00:41:40 -0400994 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700995}
Len Brown50526df2005-08-11 17:32:05 -0400996#endif /* 0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700997
998static int __init acpi_fake_ecdt_setup(char *str)
999{
1000 acpi_fake_ecdt_enabled = 1;
OGAWA Hirofumi9b410462006-03-31 02:30:33 -08001001 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001002}
Luming Yu7b15f5e2005-08-03 17:38:04 -04001003
Linus Torvalds1da177e2005-04-16 15:20:36 -07001004__setup("acpi_fake_ecdt", acpi_fake_ecdt_setup);
Len Brown02b28a332005-12-05 16:33:04 -05001005static int __init acpi_ec_set_intr_mode(char *str)
Luming Yu45bea152005-07-23 04:08:00 -04001006{
Len Brown02b28a332005-12-05 16:33:04 -05001007 int intr;
Luming Yu7b15f5e2005-08-03 17:38:04 -04001008
Len Brown02b28a332005-12-05 16:33:04 -05001009 if (!get_option(&str, &intr))
Luming Yu7b15f5e2005-08-03 17:38:04 -04001010 return 0;
1011
Len Brown02b28a332005-12-05 16:33:04 -05001012 if (intr) {
Denis M. Sadykov703959d2006-09-26 19:50:33 +04001013 acpi_ec_mode = EC_INTR;
Luming Yu7b15f5e2005-08-03 17:38:04 -04001014 } else {
Denis M. Sadykov703959d2006-09-26 19:50:33 +04001015 acpi_ec_mode = EC_POLL;
Luming Yu7b15f5e2005-08-03 17:38:04 -04001016 }
Denis M. Sadykov703959d2006-09-26 19:50:33 +04001017 acpi_ec_driver.ops.add = acpi_ec_add;
Len Brown723fe2c2007-01-06 00:02:07 -05001018 printk(KERN_NOTICE PREFIX "%s mode.\n",
1019 intr ? "interrupt" : "polling");
Denis M. Sadykov703959d2006-09-26 19:50:33 +04001020
OGAWA Hirofumi9b410462006-03-31 02:30:33 -08001021 return 1;
Luming Yu45bea152005-07-23 04:08:00 -04001022}
Len Brown50526df2005-08-11 17:32:05 -04001023
Len Brown53f11d42005-12-05 16:46:36 -05001024__setup("ec_intr=", acpi_ec_set_intr_mode);