blob: c1f6251a80a3fd7b751010e29c5c96b3e365857b [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"
Linus Torvalds1da177e2005-04-16 15:20:36 -070045#define ACPI_EC_DEVICE_NAME "Embedded Controller"
46#define ACPI_EC_FILE_INFO "info"
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +030047#undef PREFIX
48#define PREFIX "ACPI: EC: "
Denis M. Sadykov703959d2006-09-26 19:50:33 +040049/* EC status register */
Linus Torvalds1da177e2005-04-16 15:20:36 -070050#define ACPI_EC_FLAG_OBF 0x01 /* Output buffer full */
51#define ACPI_EC_FLAG_IBF 0x02 /* Input buffer full */
Dmitry Torokhov451566f2005-03-19 01:10:05 -050052#define ACPI_EC_FLAG_BURST 0x10 /* burst mode */
Linus Torvalds1da177e2005-04-16 15:20:36 -070053#define ACPI_EC_FLAG_SCI 0x20 /* EC-SCI occurred */
Denis M. Sadykov703959d2006-09-26 19:50:33 +040054/* EC commands */
Alexey Starikovskiy3261ff42006-12-07 18:42:17 +030055enum ec_command {
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +030056 ACPI_EC_COMMAND_READ = 0x80,
57 ACPI_EC_COMMAND_WRITE = 0x81,
58 ACPI_EC_BURST_ENABLE = 0x82,
59 ACPI_EC_BURST_DISABLE = 0x83,
60 ACPI_EC_COMMAND_QUERY = 0x84,
Alexey Starikovskiy3261ff42006-12-07 18:42:17 +030061};
Denis M. Sadykov703959d2006-09-26 19:50:33 +040062/* EC events */
Alexey Starikovskiy3261ff42006-12-07 18:42:17 +030063enum ec_event {
Denis M. Sadykov703959d2006-09-26 19:50:33 +040064 ACPI_EC_EVENT_OBF_1 = 1, /* Output buffer full */
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +030065 ACPI_EC_EVENT_IBF_0, /* Input buffer empty */
Denis M. Sadykov703959d2006-09-26 19:50:33 +040066};
67
Alexey Starikovskiy5c406412006-12-07 18:42:16 +030068#define ACPI_EC_DELAY 500 /* Wait 500ms max. during EC ops */
Denis M. Sadykov703959d2006-09-26 19:50:33 +040069#define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */
Denis M. Sadykov703959d2006-09-26 19:50:33 +040070
Alexey Starikovskiy3261ff42006-12-07 18:42:17 +030071static enum ec_mode {
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +030072 EC_INTR = 1, /* Output buffer full */
73 EC_POLL, /* Input buffer empty */
Alexey Starikovskiy3261ff42006-12-07 18:42:17 +030074} acpi_ec_mode = EC_INTR;
Denis M. Sadykov703959d2006-09-26 19:50:33 +040075
Len Brown50526df2005-08-11 17:32:05 -040076static int acpi_ec_remove(struct acpi_device *device, int type);
77static int acpi_ec_start(struct acpi_device *device);
78static int acpi_ec_stop(struct acpi_device *device, int type);
Denis M. Sadykov703959d2006-09-26 19:50:33 +040079static int acpi_ec_add(struct acpi_device *device);
Linus Torvalds1da177e2005-04-16 15:20:36 -070080
81static struct acpi_driver acpi_ec_driver = {
Len Brownc2b67052007-02-12 23:33:40 -050082 .name = "ec",
Len Brown50526df2005-08-11 17:32:05 -040083 .class = ACPI_EC_CLASS,
84 .ids = ACPI_EC_HID,
85 .ops = {
Denis M. Sadykov703959d2006-09-26 19:50:33 +040086 .add = acpi_ec_add,
Len Brown50526df2005-08-11 17:32:05 -040087 .remove = acpi_ec_remove,
88 .start = acpi_ec_start,
89 .stop = acpi_ec_stop,
90 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070091};
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +040092
93/* If we find an EC via the ECDT, we need to keep a ptr to its context */
Adrian Bunka854e082006-12-19 12:56:12 -080094static struct acpi_ec {
Denis M. Sadykov703959d2006-09-26 19:50:33 +040095 acpi_handle handle;
96 unsigned long uid;
Alexey Starikovskiya86e2772006-12-07 18:42:16 +030097 unsigned long gpe;
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +040098 unsigned long command_addr;
99 unsigned long data_addr;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400100 unsigned long global_lock;
Alexey Starikovskiyc787a852006-12-07 18:42:16 +0300101 struct mutex lock;
Alexey Starikovskiy5d0c2882006-12-07 18:42:16 +0300102 atomic_t query_pending;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400103 atomic_t leaving_burst; /* 0 : No, 1 : Yes, 2: abort */
104 wait_queue_head_t wait;
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400105} *ec_ecdt;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400106
107/* External interfaces use first EC only, so remember */
108static struct acpi_device *first_ec;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400109
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110/* --------------------------------------------------------------------------
111 Transaction Management
112 -------------------------------------------------------------------------- */
113
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400114static inline u8 acpi_ec_read_status(struct acpi_ec *ec)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115{
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400116 return inb(ec->command_addr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117}
118
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400119static inline u8 acpi_ec_read_data(struct acpi_ec *ec)
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400120{
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400121 return inb(ec->data_addr);
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400122}
123
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400124static inline void acpi_ec_write_cmd(struct acpi_ec *ec, u8 command)
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400125{
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400126 outb(command, ec->command_addr);
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400127}
128
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400129static inline void acpi_ec_write_data(struct acpi_ec *ec, u8 data)
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400130{
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400131 outb(data, ec->data_addr);
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400132}
133
Alexey Starikovskiy3261ff42006-12-07 18:42:17 +0300134static inline int acpi_ec_check_status(struct acpi_ec *ec, enum ec_event event)
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400135{
Alexey Starikovskiybec5a1e2006-12-07 18:42:16 +0300136 u8 status = acpi_ec_read_status(ec);
Alexey Starikovskiy78d0af32006-12-07 18:42:17 +0300137
138 if (event == ACPI_EC_EVENT_OBF_1) {
Denis M. Sadykov7c6db5e2006-09-26 19:50:33 +0400139 if (status & ACPI_EC_FLAG_OBF)
140 return 1;
Alexey Starikovskiy78d0af32006-12-07 18:42:17 +0300141 } else if (event == ACPI_EC_EVENT_IBF_0) {
Denis M. Sadykov7c6db5e2006-09-26 19:50:33 +0400142 if (!(status & ACPI_EC_FLAG_IBF))
143 return 1;
Denis M. Sadykov7c6db5e2006-09-26 19:50:33 +0400144 }
145
146 return 0;
147}
148
Alexey Starikovskiy3261ff42006-12-07 18:42:17 +0300149static int acpi_ec_wait(struct acpi_ec *ec, enum ec_event event)
Luming Yu45bea152005-07-23 04:08:00 -0400150{
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300151 if (acpi_ec_mode == EC_POLL) {
Alexey Starikovskiy50c1e112006-12-07 18:42:17 +0300152 unsigned long delay = jiffies + msecs_to_jiffies(ACPI_EC_DELAY);
153 while (time_before(jiffies, delay)) {
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300154 if (acpi_ec_check_status(ec, event))
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400155 return 0;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400156 }
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300157 } else {
158 if (wait_event_timeout(ec->wait,
159 acpi_ec_check_status(ec, event),
160 msecs_to_jiffies(ACPI_EC_DELAY)) ||
161 acpi_ec_check_status(ec, event)) {
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400162 return 0;
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300163 } else {
164 printk(KERN_ERR PREFIX "acpi_ec_wait timeout,"
165 " status = %d, expect_event = %d\n",
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300166 acpi_ec_read_status(ec), event);
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400167 }
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300168 }
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400169
Patrick Mocheld550d982006-06-27 00:41:40 -0400170 return -ETIME;
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500171}
172
Len Brown02b28a332005-12-05 16:33:04 -0500173#ifdef ACPI_FUTURE_USAGE
Luming Yu06a2a382005-09-27 00:43:00 -0400174/*
175 * Note: samsung nv5000 doesn't work with ec burst mode.
176 * http://bugzilla.kernel.org/show_bug.cgi?id=4980
177 */
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400178int acpi_ec_enter_burst_mode(struct acpi_ec *ec)
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500179{
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400180 u8 tmp = 0;
181 u8 status = 0;
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500182
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500183 status = acpi_ec_read_status(ec);
Len Brown50526df2005-08-11 17:32:05 -0400184 if (status != -EINVAL && !(status & ACPI_EC_FLAG_BURST)) {
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400185 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
Len Brown50526df2005-08-11 17:32:05 -0400186 if (status)
Luming Yu716e0842005-08-10 01:40:00 -0400187 goto end;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400188 acpi_ec_write_cmd(ec, ACPI_EC_BURST_ENABLE);
189 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1);
190 tmp = acpi_ec_read_data(ec);
Len Brown50526df2005-08-11 17:32:05 -0400191 if (tmp != 0x90) { /* Burst ACK byte */
Patrick Mocheld550d982006-06-27 00:41:40 -0400192 return -EINVAL;
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500193 }
Luming Yu668d74c2005-07-23 00:26:33 -0400194 }
195
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400196 atomic_set(&ec->leaving_burst, 0);
Patrick Mocheld550d982006-06-27 00:41:40 -0400197 return 0;
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300198 end:
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400199 ACPI_EXCEPTION((AE_INFO, status, "EC wait, burst mode"));
Patrick Mocheld550d982006-06-27 00:41:40 -0400200 return -1;
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500201}
202
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400203int acpi_ec_leave_burst_mode(struct acpi_ec *ec)
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500204{
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400205 u8 status = 0;
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500206
Luming Yu06a2a382005-09-27 00:43:00 -0400207 status = acpi_ec_read_status(ec);
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300208 if (status != -EINVAL && (status & ACPI_EC_FLAG_BURST)) {
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400209 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300210 if (status)
Luming Yu06a2a382005-09-27 00:43:00 -0400211 goto end;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400212 acpi_ec_write_cmd(ec, ACPI_EC_BURST_DISABLE);
213 acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
Denis M. Sadykov7c6db5e2006-09-26 19:50:33 +0400214 }
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400215 atomic_set(&ec->leaving_burst, 1);
Patrick Mocheld550d982006-06-27 00:41:40 -0400216 return 0;
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300217 end:
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400218 ACPI_EXCEPTION((AE_INFO, status, "EC leave burst mode"));
Patrick Mocheld550d982006-06-27 00:41:40 -0400219 return -1;
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500220}
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300221#endif /* ACPI_FUTURE_USAGE */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400223static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command,
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300224 const u8 * wdata, unsigned wdata_len,
225 u8 * rdata, unsigned rdata_len)
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400226{
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300227 int result = 0;
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400228
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400229 acpi_ec_write_cmd(ec, command);
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400230
Alexey Starikovskiy78d0af32006-12-07 18:42:17 +0300231 for (; wdata_len > 0; --wdata_len) {
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400232 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300233 if (result) {
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300234 printk(KERN_ERR PREFIX
235 "write_cmd timeout, command = %d\n", command);
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300236 goto end;
237 }
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400238 acpi_ec_write_data(ec, *(wdata++));
Denis M. Sadykov3576cf62006-09-26 19:50:33 +0400239 }
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400240
Alexey Starikovskiyd91df1a2006-12-07 18:42:16 +0300241 if (!rdata_len) {
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400242 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300243 if (result) {
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300244 printk(KERN_ERR PREFIX
245 "finish-write timeout, command = %d\n", command);
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300246 goto end;
247 }
Alexey Starikovskiy5d0c2882006-12-07 18:42:16 +0300248 } else if (command == ACPI_EC_COMMAND_QUERY) {
249 atomic_set(&ec->query_pending, 0);
Denis M. Sadykov7c6db5e2006-09-26 19:50:33 +0400250 }
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400251
Alexey Starikovskiy78d0af32006-12-07 18:42:17 +0300252 for (; rdata_len > 0; --rdata_len) {
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400253 result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1);
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300254 if (result) {
255 printk(KERN_ERR PREFIX "read timeout, command = %d\n",
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300256 command);
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300257 goto end;
258 }
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400259
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400260 *(rdata++) = acpi_ec_read_data(ec);
Denis M. Sadykov7c6db5e2006-09-26 19:50:33 +0400261 }
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300262 end:
263 return result;
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400264}
265
Denis M. Sadykov3576cf62006-09-26 19:50:33 +0400266static int acpi_ec_transaction(struct acpi_ec *ec, u8 command,
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300267 const u8 * wdata, unsigned wdata_len,
268 u8 * rdata, unsigned rdata_len)
Luming Yu45bea152005-07-23 04:08:00 -0400269{
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400270 int status;
Len Brown50526df2005-08-11 17:32:05 -0400271 u32 glk;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700272
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400273 if (!ec || (wdata_len && !wdata) || (rdata_len && !rdata))
Patrick Mocheld550d982006-06-27 00:41:40 -0400274 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300276 if (rdata)
277 memset(rdata, 0, rdata_len);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700278
Alexey Starikovskiy523953b2006-12-07 18:42:17 +0300279 mutex_lock(&ec->lock);
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400280 if (ec->global_lock) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
282 if (ACPI_FAILURE(status))
Patrick Mocheld550d982006-06-27 00:41:40 -0400283 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700284 }
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500285
Alexey Starikovskiy5d57a6a2006-12-07 18:42:16 +0300286 /* Make sure GPE is enabled before doing transaction */
Alexey Starikovskiya86e2772006-12-07 18:42:16 +0300287 acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR);
Alexey Starikovskiy5d57a6a2006-12-07 18:42:16 +0300288
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400289 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
Luming Yu716e0842005-08-10 01:40:00 -0400290 if (status) {
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300291 printk(KERN_DEBUG PREFIX
292 "input buffer is not empty, aborting transaction\n");
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500293 goto end;
Luming Yu716e0842005-08-10 01:40:00 -0400294 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300296 status = acpi_ec_transaction_unlocked(ec, command,
297 wdata, wdata_len,
298 rdata, rdata_len);
Len Brown50526df2005-08-11 17:32:05 -0400299
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300300 end:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400302 if (ec->global_lock)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303 acpi_release_global_lock(glk);
Alexey Starikovskiy523953b2006-12-07 18:42:17 +0300304 mutex_unlock(&ec->lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305
Patrick Mocheld550d982006-06-27 00:41:40 -0400306 return status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307}
308
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300309static int acpi_ec_read(struct acpi_ec *ec, u8 address, u8 * data)
Denis M. Sadykov3576cf62006-09-26 19:50:33 +0400310{
311 int result;
312 u8 d;
313
314 result = acpi_ec_transaction(ec, ACPI_EC_COMMAND_READ,
315 &address, 1, &d, 1);
316 *data = d;
317 return result;
318}
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400319
Denis M. Sadykov3576cf62006-09-26 19:50:33 +0400320static int acpi_ec_write(struct acpi_ec *ec, u8 address, u8 data)
321{
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300322 u8 wdata[2] = { address, data };
323 return acpi_ec_transaction(ec, ACPI_EC_COMMAND_WRITE,
Denis M. Sadykov3576cf62006-09-26 19:50:33 +0400324 wdata, 2, NULL, 0);
325}
326
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327/*
328 * Externally callable EC access functions. For now, assume 1 EC only
329 */
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300330int ec_read(u8 addr, u8 * val)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331{
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400332 struct acpi_ec *ec;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333 int err;
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400334 u8 temp_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335
336 if (!first_ec)
337 return -ENODEV;
338
339 ec = acpi_driver_data(first_ec);
340
341 err = acpi_ec_read(ec, addr, &temp_data);
342
343 if (!err) {
344 *val = temp_data;
345 return 0;
Len Brown50526df2005-08-11 17:32:05 -0400346 } else
Linus Torvalds1da177e2005-04-16 15:20:36 -0700347 return err;
348}
Len Brown50526df2005-08-11 17:32:05 -0400349
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350EXPORT_SYMBOL(ec_read);
351
Len Brown50526df2005-08-11 17:32:05 -0400352int ec_write(u8 addr, u8 val)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700353{
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400354 struct acpi_ec *ec;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355 int err;
356
357 if (!first_ec)
358 return -ENODEV;
359
360 ec = acpi_driver_data(first_ec);
361
362 err = acpi_ec_write(ec, addr, val);
363
364 return err;
365}
Len Brown50526df2005-08-11 17:32:05 -0400366
Linus Torvalds1da177e2005-04-16 15:20:36 -0700367EXPORT_SYMBOL(ec_write);
368
Randy Dunlap616362d2006-10-27 01:47:34 -0400369int ec_transaction(u8 command,
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300370 const u8 * wdata, unsigned wdata_len,
371 u8 * rdata, unsigned rdata_len)
Luming Yu45bea152005-07-23 04:08:00 -0400372{
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400373 struct acpi_ec *ec;
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400374
375 if (!first_ec)
376 return -ENODEV;
377
378 ec = acpi_driver_data(first_ec);
379
Denis M. Sadykov3576cf62006-09-26 19:50:33 +0400380 return acpi_ec_transaction(ec, command, wdata,
381 wdata_len, rdata, rdata_len);
Luming Yu45bea152005-07-23 04:08:00 -0400382}
Luming Yu45bea152005-07-23 04:08:00 -0400383
Lennart Poetteringab9e43c2006-10-03 22:49:00 -0400384EXPORT_SYMBOL(ec_transaction);
385
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300386static int acpi_ec_query(struct acpi_ec *ec, u8 * data)
Denis M. Sadykov3576cf62006-09-26 19:50:33 +0400387{
388 int result;
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300389 u8 d;
Luming Yu45bea152005-07-23 04:08:00 -0400390
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300391 if (!ec || !data)
392 return -EINVAL;
Luming Yu45bea152005-07-23 04:08:00 -0400393
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300394 /*
395 * Query the EC to find out which _Qxx method we need to evaluate.
396 * Note that successful completion of the query causes the ACPI_EC_SCI
397 * bit to be cleared (and thus clearing the interrupt source).
398 */
Luming Yu45bea152005-07-23 04:08:00 -0400399
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300400 result = acpi_ec_transaction(ec, ACPI_EC_COMMAND_QUERY, NULL, 0, &d, 1);
401 if (result)
402 return result;
Luming Yu45bea152005-07-23 04:08:00 -0400403
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300404 if (!d)
405 return -ENODATA;
Luming Yu45bea152005-07-23 04:08:00 -0400406
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300407 *data = d;
408 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700409}
410
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411/* --------------------------------------------------------------------------
412 Event Management
413 -------------------------------------------------------------------------- */
414
Len Brown50526df2005-08-11 17:32:05 -0400415static void acpi_ec_gpe_query(void *ec_cxt)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416{
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400417 struct acpi_ec *ec = (struct acpi_ec *)ec_cxt;
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400418 u8 value = 0;
Alexey Starikovskiy5d0c2882006-12-07 18:42:16 +0300419 char object_name[8];
Luming Yu45bea152005-07-23 04:08:00 -0400420
Alexey Starikovskiy5d0c2882006-12-07 18:42:16 +0300421 if (!ec || acpi_ec_query(ec, &value))
Alexey Starikovskiye41334c2006-12-07 18:42:16 +0300422 return;
Luming Yu45bea152005-07-23 04:08:00 -0400423
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400424 snprintf(object_name, 8, "_Q%2.2X", value);
Luming Yu45bea152005-07-23 04:08:00 -0400425
Guillaume Chazarainc6e19192006-12-24 22:19:02 +0100426 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluating %s", object_name));
Luming Yu45bea152005-07-23 04:08:00 -0400427
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400428 acpi_evaluate_object(ec->handle, object_name, NULL, NULL);
Luming Yu45bea152005-07-23 04:08:00 -0400429}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430
Len Brown50526df2005-08-11 17:32:05 -0400431static u32 acpi_ec_gpe_handler(void *data)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700432{
Len Brown50526df2005-08-11 17:32:05 -0400433 acpi_status status = AE_OK;
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400434 u8 value;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400435 struct acpi_ec *ec = (struct acpi_ec *)data;
Luming Yu45bea152005-07-23 04:08:00 -0400436
Denis M. Sadykov8e0341b2006-09-26 19:50:33 +0400437 if (acpi_ec_mode == EC_INTR) {
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300438 wake_up(&ec->wait);
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500439 }
440
Alexey Starikovskiybec5a1e2006-12-07 18:42:16 +0300441 value = acpi_ec_read_status(ec);
Alexey Starikovskiy5d0c2882006-12-07 18:42:16 +0300442 if ((value & ACPI_EC_FLAG_SCI) && !atomic_read(&ec->query_pending)) {
443 atomic_set(&ec->query_pending, 1);
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300444 status =
445 acpi_os_execute(OSL_EC_BURST_HANDLER, acpi_ec_gpe_query,
446 ec);
Len Brown50526df2005-08-11 17:32:05 -0400447 }
Alexey Starikovskiye41334c2006-12-07 18:42:16 +0300448
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500449 return status == AE_OK ?
Len Brown50526df2005-08-11 17:32:05 -0400450 ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700451}
452
453/* --------------------------------------------------------------------------
454 Address Space Management
455 -------------------------------------------------------------------------- */
456
457static acpi_status
Len Brown50526df2005-08-11 17:32:05 -0400458acpi_ec_space_setup(acpi_handle region_handle,
459 u32 function, void *handler_context, void **return_context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460{
461 /*
462 * The EC object is in the handler context and is needed
463 * when calling the acpi_ec_space_handler.
464 */
Len Brown50526df2005-08-11 17:32:05 -0400465 *return_context = (function != ACPI_REGION_DEACTIVATE) ?
466 handler_context : NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700467
468 return AE_OK;
469}
470
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471static acpi_status
Len Brown50526df2005-08-11 17:32:05 -0400472acpi_ec_space_handler(u32 function,
473 acpi_physical_address address,
474 u32 bit_width,
475 acpi_integer * value,
476 void *handler_context, void *region_context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477{
Len Brown50526df2005-08-11 17:32:05 -0400478 int result = 0;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400479 struct acpi_ec *ec = NULL;
Len Brown50526df2005-08-11 17:32:05 -0400480 u64 temp = *value;
481 acpi_integer f_v = 0;
482 int i = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700483
Linus Torvalds1da177e2005-04-16 15:20:36 -0700484 if ((address > 0xFF) || !value || !handler_context)
Patrick Mocheld550d982006-06-27 00:41:40 -0400485 return AE_BAD_PARAMETER;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700486
Luming Yufa9cd542005-03-19 01:54:47 -0500487 if (bit_width != 8 && acpi_strict) {
Patrick Mocheld550d982006-06-27 00:41:40 -0400488 return AE_BAD_PARAMETER;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700489 }
490
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400491 ec = (struct acpi_ec *)handler_context;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700492
Len Brown50526df2005-08-11 17:32:05 -0400493 next_byte:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494 switch (function) {
495 case ACPI_READ:
Luming Yufa9cd542005-03-19 01:54:47 -0500496 temp = 0;
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300497 result = acpi_ec_read(ec, (u8) address, (u8 *) & temp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700498 break;
499 case ACPI_WRITE:
Luming Yufa9cd542005-03-19 01:54:47 -0500500 result = acpi_ec_write(ec, (u8) address, (u8) temp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700501 break;
502 default:
503 result = -EINVAL;
504 goto out;
505 break;
506 }
507
508 bit_width -= 8;
Luming Yufa9cd542005-03-19 01:54:47 -0500509 if (bit_width) {
510 if (function == ACPI_READ)
511 f_v |= temp << 8 * i;
512 if (function == ACPI_WRITE)
513 temp >>= 8;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700514 i++;
Andrew Morton83ea7442005-03-30 22:12:13 -0500515 address++;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700516 goto next_byte;
517 }
518
Luming Yufa9cd542005-03-19 01:54:47 -0500519 if (function == ACPI_READ) {
520 f_v |= temp << 8 * i;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700521 *value = f_v;
522 }
523
Len Brown50526df2005-08-11 17:32:05 -0400524 out:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525 switch (result) {
526 case -EINVAL:
Patrick Mocheld550d982006-06-27 00:41:40 -0400527 return AE_BAD_PARAMETER;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700528 break;
529 case -ENODEV:
Patrick Mocheld550d982006-06-27 00:41:40 -0400530 return AE_NOT_FOUND;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700531 break;
532 case -ETIME:
Patrick Mocheld550d982006-06-27 00:41:40 -0400533 return AE_TIME;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700534 break;
535 default:
Patrick Mocheld550d982006-06-27 00:41:40 -0400536 return AE_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700537 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700538}
539
Linus Torvalds1da177e2005-04-16 15:20:36 -0700540/* --------------------------------------------------------------------------
541 FS Interface (/proc)
542 -------------------------------------------------------------------------- */
543
Len Brown50526df2005-08-11 17:32:05 -0400544static struct proc_dir_entry *acpi_ec_dir;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700545
Len Brown50526df2005-08-11 17:32:05 -0400546static int acpi_ec_read_info(struct seq_file *seq, void *offset)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700547{
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400548 struct acpi_ec *ec = (struct acpi_ec *)seq->private;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700549
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550 if (!ec)
551 goto end;
552
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300553 seq_printf(seq, "gpe: 0x%02x\n", (u32) ec->gpe);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700554 seq_printf(seq, "ports: 0x%02x, 0x%02x\n",
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300555 (u32) ec->command_addr, (u32) ec->data_addr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700556 seq_printf(seq, "use global lock: %s\n",
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400557 ec->global_lock ? "yes" : "no");
Alexey Starikovskiya86e2772006-12-07 18:42:16 +0300558 acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700559
Len Brown50526df2005-08-11 17:32:05 -0400560 end:
Patrick Mocheld550d982006-06-27 00:41:40 -0400561 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700562}
563
564static int acpi_ec_info_open_fs(struct inode *inode, struct file *file)
565{
566 return single_open(file, acpi_ec_read_info, PDE(inode)->data);
567}
568
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400569static struct file_operations acpi_ec_info_ops = {
Len Brown50526df2005-08-11 17:32:05 -0400570 .open = acpi_ec_info_open_fs,
571 .read = seq_read,
572 .llseek = seq_lseek,
573 .release = single_release,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700574 .owner = THIS_MODULE,
575};
576
Len Brown50526df2005-08-11 17:32:05 -0400577static int acpi_ec_add_fs(struct acpi_device *device)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700578{
Len Brown50526df2005-08-11 17:32:05 -0400579 struct proc_dir_entry *entry = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700580
Linus Torvalds1da177e2005-04-16 15:20:36 -0700581 if (!acpi_device_dir(device)) {
582 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
Len Brown50526df2005-08-11 17:32:05 -0400583 acpi_ec_dir);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700584 if (!acpi_device_dir(device))
Patrick Mocheld550d982006-06-27 00:41:40 -0400585 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700586 }
587
588 entry = create_proc_entry(ACPI_EC_FILE_INFO, S_IRUGO,
Len Brown50526df2005-08-11 17:32:05 -0400589 acpi_device_dir(device));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700590 if (!entry)
Patrick Mocheld550d982006-06-27 00:41:40 -0400591 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592 else {
593 entry->proc_fops = &acpi_ec_info_ops;
594 entry->data = acpi_driver_data(device);
595 entry->owner = THIS_MODULE;
596 }
597
Patrick Mocheld550d982006-06-27 00:41:40 -0400598 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700599}
600
Len Brown50526df2005-08-11 17:32:05 -0400601static int acpi_ec_remove_fs(struct acpi_device *device)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700602{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700603
604 if (acpi_device_dir(device)) {
605 remove_proc_entry(ACPI_EC_FILE_INFO, acpi_device_dir(device));
606 remove_proc_entry(acpi_device_bid(device), acpi_ec_dir);
607 acpi_device_dir(device) = NULL;
608 }
609
Patrick Mocheld550d982006-06-27 00:41:40 -0400610 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700611}
612
Linus Torvalds1da177e2005-04-16 15:20:36 -0700613/* --------------------------------------------------------------------------
614 Driver Interface
615 -------------------------------------------------------------------------- */
616
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400617static int acpi_ec_add(struct acpi_device *device)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700618{
Len Brown50526df2005-08-11 17:32:05 -0400619 int result = 0;
620 acpi_status status = AE_OK;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400621 struct acpi_ec *ec = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700622
Linus Torvalds1da177e2005-04-16 15:20:36 -0700623 if (!device)
Patrick Mocheld550d982006-06-27 00:41:40 -0400624 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700625
Burman Yan36bcbec2006-12-19 12:56:11 -0800626 ec = kzalloc(sizeof(struct acpi_ec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700627 if (!ec)
Patrick Mocheld550d982006-06-27 00:41:40 -0400628 return -ENOMEM;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700629
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400630 ec->handle = device->handle;
631 ec->uid = -1;
Alexey Starikovskiyc787a852006-12-07 18:42:16 +0300632 mutex_init(&ec->lock);
Alexey Starikovskiy5d0c2882006-12-07 18:42:16 +0300633 atomic_set(&ec->query_pending, 0);
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400634 if (acpi_ec_mode == EC_INTR) {
635 atomic_set(&ec->leaving_burst, 1);
636 init_waitqueue_head(&ec->wait);
637 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700638 strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME);
639 strcpy(acpi_device_class(device), ACPI_EC_CLASS);
640 acpi_driver_data(device) = ec;
641
642 /* Use the global lock for all EC transactions? */
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300643 acpi_evaluate_integer(ec->handle, "_GLK", NULL, &ec->global_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700644
Jiri Slabyff2fc3e2006-03-28 17:04:00 -0500645 /* XXX we don't test uids, because on some boxes ecdt uid = 0, see:
646 http://bugzilla.kernel.org/show_bug.cgi?id=6111 */
647 if (ec_ecdt) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700648 acpi_remove_address_space_handler(ACPI_ROOT_OBJECT,
Len Brown50526df2005-08-11 17:32:05 -0400649 ACPI_ADR_SPACE_EC,
650 &acpi_ec_space_handler);
651
Alexey Starikovskiya86e2772006-12-07 18:42:16 +0300652 acpi_remove_gpe_handler(NULL, ec_ecdt->gpe,
Len Brown50526df2005-08-11 17:32:05 -0400653 &acpi_ec_gpe_handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700654
655 kfree(ec_ecdt);
656 }
657
658 /* Get GPE bit assignment (EC events). */
659 /* TODO: Add support for _GPE returning a package */
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300660 status = acpi_evaluate_integer(ec->handle, "_GPE", NULL, &ec->gpe);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700661 if (ACPI_FAILURE(status)) {
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300662 ACPI_EXCEPTION((AE_INFO, status,
663 "Obtaining GPE bit assignment"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700664 result = -ENODEV;
665 goto end;
666 }
667
668 result = acpi_ec_add_fs(device);
669 if (result)
670 goto end;
671
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400672 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s [%s] (gpe %d) interrupt mode.",
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300673 acpi_device_name(device), acpi_device_bid(device),
674 (u32) ec->gpe));
Luming Yu45bea152005-07-23 04:08:00 -0400675
676 if (!first_ec)
677 first_ec = device;
678
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300679 end:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700680 if (result)
681 kfree(ec);
682
Patrick Mocheld550d982006-06-27 00:41:40 -0400683 return result;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700684}
685
Len Brown50526df2005-08-11 17:32:05 -0400686static int acpi_ec_remove(struct acpi_device *device, int type)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700687{
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400688 struct acpi_ec *ec = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700689
Linus Torvalds1da177e2005-04-16 15:20:36 -0700690 if (!device)
Patrick Mocheld550d982006-06-27 00:41:40 -0400691 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700692
693 ec = acpi_driver_data(device);
694
695 acpi_ec_remove_fs(device);
696
697 kfree(ec);
698
Patrick Mocheld550d982006-06-27 00:41:40 -0400699 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700700}
701
Linus Torvalds1da177e2005-04-16 15:20:36 -0700702static acpi_status
Len Brown50526df2005-08-11 17:32:05 -0400703acpi_ec_io_ports(struct acpi_resource *resource, void *context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700704{
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400705 struct acpi_ec *ec = (struct acpi_ec *)context;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700706
Bob Moore50eca3e2005-09-30 19:03:00 -0400707 if (resource->type != ACPI_RESOURCE_TYPE_IO) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700708 return AE_OK;
709 }
710
711 /*
712 * The first address region returned is the data port, and
713 * the second address region returned is the status/command
714 * port.
715 */
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400716 if (ec->data_addr == 0) {
717 ec->data_addr = resource->data.io.minimum;
718 } else if (ec->command_addr == 0) {
719 ec->command_addr = resource->data.io.minimum;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700720 } else {
721 return AE_CTRL_TERMINATE;
722 }
723
Linus Torvalds1da177e2005-04-16 15:20:36 -0700724 return AE_OK;
725}
726
Len Brown50526df2005-08-11 17:32:05 -0400727static int acpi_ec_start(struct acpi_device *device)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700728{
Len Brown50526df2005-08-11 17:32:05 -0400729 acpi_status status = AE_OK;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400730 struct acpi_ec *ec = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700731
Linus Torvalds1da177e2005-04-16 15:20:36 -0700732 if (!device)
Patrick Mocheld550d982006-06-27 00:41:40 -0400733 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700734
735 ec = acpi_driver_data(device);
736
737 if (!ec)
Patrick Mocheld550d982006-06-27 00:41:40 -0400738 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700739
740 /*
741 * Get I/O port addresses. Convert to GAS format.
742 */
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400743 status = acpi_walk_resources(ec->handle, METHOD_NAME__CRS,
Len Brown50526df2005-08-11 17:32:05 -0400744 acpi_ec_io_ports, ec);
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400745 if (ACPI_FAILURE(status) || ec->command_addr == 0) {
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400746 ACPI_EXCEPTION((AE_INFO, status,
747 "Error getting I/O port addresses"));
Patrick Mocheld550d982006-06-27 00:41:40 -0400748 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700749 }
750
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400751 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "gpe=0x%02lx, ports=0x%2lx,0x%2lx",
Alexey Starikovskiya86e2772006-12-07 18:42:16 +0300752 ec->gpe, ec->command_addr, ec->data_addr));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700753
754 /*
755 * Install GPE handler
756 */
Alexey Starikovskiya86e2772006-12-07 18:42:16 +0300757 status = acpi_install_gpe_handler(NULL, ec->gpe,
Len Brown50526df2005-08-11 17:32:05 -0400758 ACPI_GPE_EDGE_TRIGGERED,
759 &acpi_ec_gpe_handler, ec);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700760 if (ACPI_FAILURE(status)) {
Patrick Mocheld550d982006-06-27 00:41:40 -0400761 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700762 }
Alexey Starikovskiya86e2772006-12-07 18:42:16 +0300763 acpi_set_gpe_type(NULL, ec->gpe, ACPI_GPE_TYPE_RUNTIME);
764 acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700765
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400766 status = acpi_install_address_space_handler(ec->handle,
Len Brown50526df2005-08-11 17:32:05 -0400767 ACPI_ADR_SPACE_EC,
768 &acpi_ec_space_handler,
769 &acpi_ec_space_setup, ec);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700770 if (ACPI_FAILURE(status)) {
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300771 acpi_remove_gpe_handler(NULL, ec->gpe, &acpi_ec_gpe_handler);
Patrick Mocheld550d982006-06-27 00:41:40 -0400772 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700773 }
774
Patrick Mocheld550d982006-06-27 00:41:40 -0400775 return AE_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700776}
777
Len Brown50526df2005-08-11 17:32:05 -0400778static int acpi_ec_stop(struct acpi_device *device, int type)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700779{
Len Brown50526df2005-08-11 17:32:05 -0400780 acpi_status status = AE_OK;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400781 struct acpi_ec *ec = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700782
Linus Torvalds1da177e2005-04-16 15:20:36 -0700783 if (!device)
Patrick Mocheld550d982006-06-27 00:41:40 -0400784 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700785
786 ec = acpi_driver_data(device);
787
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400788 status = acpi_remove_address_space_handler(ec->handle,
Len Brown50526df2005-08-11 17:32:05 -0400789 ACPI_ADR_SPACE_EC,
790 &acpi_ec_space_handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700791 if (ACPI_FAILURE(status))
Patrick Mocheld550d982006-06-27 00:41:40 -0400792 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700793
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300794 status = acpi_remove_gpe_handler(NULL, ec->gpe, &acpi_ec_gpe_handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700795 if (ACPI_FAILURE(status))
Patrick Mocheld550d982006-06-27 00:41:40 -0400796 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700797
Patrick Mocheld550d982006-06-27 00:41:40 -0400798 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700799}
800
801static acpi_status __init
Len Brown50526df2005-08-11 17:32:05 -0400802acpi_fake_ecdt_callback(acpi_handle handle,
803 u32 Level, void *context, void **retval)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700804{
Len Brown50526df2005-08-11 17:32:05 -0400805 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700806
Alexey Starikovskiyc787a852006-12-07 18:42:16 +0300807 mutex_init(&ec_ecdt->lock);
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400808 if (acpi_ec_mode == EC_INTR) {
809 init_waitqueue_head(&ec_ecdt->wait);
810 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700811 status = acpi_walk_resources(handle, METHOD_NAME__CRS,
Len Brown50526df2005-08-11 17:32:05 -0400812 acpi_ec_io_ports, ec_ecdt);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700813 if (ACPI_FAILURE(status))
814 return status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700815
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400816 ec_ecdt->uid = -1;
817 acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->uid);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700818
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300819 status = acpi_evaluate_integer(handle, "_GPE", NULL, &ec_ecdt->gpe);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700820 if (ACPI_FAILURE(status))
821 return status;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400822 ec_ecdt->global_lock = TRUE;
823 ec_ecdt->handle = handle;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700824
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400825 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "GPE=0x%02lx, ports=0x%2lx, 0x%2lx",
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300826 ec_ecdt->gpe, ec_ecdt->command_addr,
827 ec_ecdt->data_addr));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700828
829 return AE_CTRL_TERMINATE;
830}
831
832/*
833 * Some BIOS (such as some from Gateway laptops) access EC region very early
834 * such as in BAT0._INI or EC._INI before an EC device is found and
835 * do not provide an ECDT. According to ACPI spec, ECDT isn't mandatorily
836 * required, but if EC regison is accessed early, it is required.
837 * The routine tries to workaround the BIOS bug by pre-scan EC device
838 * It assumes that _CRS, _HID, _GPE, _UID methods of EC don't touch any
839 * op region (since _REG isn't invoked yet). The assumption is true for
840 * all systems found.
841 */
Len Brown50526df2005-08-11 17:32:05 -0400842static int __init acpi_ec_fake_ecdt(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700843{
Len Brown50526df2005-08-11 17:32:05 -0400844 acpi_status status;
845 int ret = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700846
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400847 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Try to make an fake ECDT"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700848
Burman Yan36bcbec2006-12-19 12:56:11 -0800849 ec_ecdt = kzalloc(sizeof(struct acpi_ec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700850 if (!ec_ecdt) {
851 ret = -ENOMEM;
852 goto error;
853 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700854
Len Brown50526df2005-08-11 17:32:05 -0400855 status = acpi_get_devices(ACPI_EC_HID,
856 acpi_fake_ecdt_callback, NULL, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700857 if (ACPI_FAILURE(status)) {
858 kfree(ec_ecdt);
859 ec_ecdt = NULL;
860 ret = -ENODEV;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400861 ACPI_EXCEPTION((AE_INFO, status, "Can't make an fake ECDT"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700862 goto error;
863 }
864 return 0;
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300865 error:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700866 return ret;
867}
868
Len Brown50526df2005-08-11 17:32:05 -0400869static int __init acpi_ec_get_real_ecdt(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700870{
Len Brown50526df2005-08-11 17:32:05 -0400871 acpi_status status;
872 struct acpi_table_ecdt *ecdt_ptr;
Luming Yu45bea152005-07-23 04:08:00 -0400873
Alexey Starikovskiy15a58ed2007-02-02 19:48:22 +0300874 status = acpi_get_table(ACPI_SIG_ECDT, 1,
875 (struct acpi_table_header **)&ecdt_ptr);
Luming Yu45bea152005-07-23 04:08:00 -0400876 if (ACPI_FAILURE(status))
877 return -ENODEV;
878
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400879 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found ECDT"));
Luming Yu45bea152005-07-23 04:08:00 -0400880
881 /*
882 * Generate a temporary ec context to use until the namespace is scanned
883 */
Burman Yan36bcbec2006-12-19 12:56:11 -0800884 ec_ecdt = kzalloc(sizeof(struct acpi_ec), GFP_KERNEL);
Luming Yu45bea152005-07-23 04:08:00 -0400885 if (!ec_ecdt)
886 return -ENOMEM;
Luming Yu45bea152005-07-23 04:08:00 -0400887
Alexey Starikovskiyc787a852006-12-07 18:42:16 +0300888 mutex_init(&ec_ecdt->lock);
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400889 if (acpi_ec_mode == EC_INTR) {
890 init_waitqueue_head(&ec_ecdt->wait);
891 }
Alexey Starikovskiyad363f82007-02-02 19:48:22 +0300892 ec_ecdt->command_addr = ecdt_ptr->control.address;
893 ec_ecdt->data_addr = ecdt_ptr->data.address;
894 ec_ecdt->gpe = ecdt_ptr->gpe;
Luming Yu45bea152005-07-23 04:08:00 -0400895 /* use the GL just to be safe */
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400896 ec_ecdt->global_lock = TRUE;
897 ec_ecdt->uid = ecdt_ptr->uid;
Luming Yu45bea152005-07-23 04:08:00 -0400898
Alexey Starikovskiyad363f82007-02-02 19:48:22 +0300899 status = acpi_get_handle(NULL, ecdt_ptr->id, &ec_ecdt->handle);
Luming Yu45bea152005-07-23 04:08:00 -0400900 if (ACPI_FAILURE(status)) {
901 goto error;
902 }
903
904 return 0;
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300905 error:
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400906 ACPI_EXCEPTION((AE_INFO, status, "Could not use ECDT"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700907 kfree(ec_ecdt);
908 ec_ecdt = NULL;
909
910 return -ENODEV;
911}
912
913static int __initdata acpi_fake_ecdt_enabled;
Len Brown50526df2005-08-11 17:32:05 -0400914int __init acpi_ec_ecdt_probe(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700915{
Len Brown50526df2005-08-11 17:32:05 -0400916 acpi_status status;
917 int ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700918
919 ret = acpi_ec_get_real_ecdt();
920 /* Try to make a fake ECDT */
921 if (ret && acpi_fake_ecdt_enabled) {
922 ret = acpi_ec_fake_ecdt();
923 }
924
925 if (ret)
926 return 0;
927
928 /*
929 * Install GPE handler
930 */
Alexey Starikovskiya86e2772006-12-07 18:42:16 +0300931 status = acpi_install_gpe_handler(NULL, ec_ecdt->gpe,
Len Brown50526df2005-08-11 17:32:05 -0400932 ACPI_GPE_EDGE_TRIGGERED,
933 &acpi_ec_gpe_handler, ec_ecdt);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700934 if (ACPI_FAILURE(status)) {
935 goto error;
936 }
Alexey Starikovskiya86e2772006-12-07 18:42:16 +0300937 acpi_set_gpe_type(NULL, ec_ecdt->gpe, ACPI_GPE_TYPE_RUNTIME);
938 acpi_enable_gpe(NULL, ec_ecdt->gpe, ACPI_NOT_ISR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700939
Len Brown50526df2005-08-11 17:32:05 -0400940 status = acpi_install_address_space_handler(ACPI_ROOT_OBJECT,
941 ACPI_ADR_SPACE_EC,
942 &acpi_ec_space_handler,
943 &acpi_ec_space_setup,
944 ec_ecdt);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700945 if (ACPI_FAILURE(status)) {
Alexey Starikovskiya86e2772006-12-07 18:42:16 +0300946 acpi_remove_gpe_handler(NULL, ec_ecdt->gpe,
Len Brown50526df2005-08-11 17:32:05 -0400947 &acpi_ec_gpe_handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700948 goto error;
949 }
950
951 return 0;
952
Len Brown50526df2005-08-11 17:32:05 -0400953 error:
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400954 ACPI_EXCEPTION((AE_INFO, status, "Could not use ECDT"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700955 kfree(ec_ecdt);
956 ec_ecdt = NULL;
957
958 return -ENODEV;
959}
960
Len Brown50526df2005-08-11 17:32:05 -0400961static int __init acpi_ec_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700962{
Len Brown50526df2005-08-11 17:32:05 -0400963 int result = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700964
Linus Torvalds1da177e2005-04-16 15:20:36 -0700965 if (acpi_disabled)
Patrick Mocheld550d982006-06-27 00:41:40 -0400966 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700967
968 acpi_ec_dir = proc_mkdir(ACPI_EC_CLASS, acpi_root_dir);
969 if (!acpi_ec_dir)
Patrick Mocheld550d982006-06-27 00:41:40 -0400970 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700971
972 /* Now register the driver for the EC */
973 result = acpi_bus_register_driver(&acpi_ec_driver);
974 if (result < 0) {
975 remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir);
Patrick Mocheld550d982006-06-27 00:41:40 -0400976 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700977 }
978
Patrick Mocheld550d982006-06-27 00:41:40 -0400979 return result;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700980}
981
982subsys_initcall(acpi_ec_init);
983
984/* EC driver currently not unloadable */
985#if 0
Len Brown50526df2005-08-11 17:32:05 -0400986static void __exit acpi_ec_exit(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700987{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700988
989 acpi_bus_unregister_driver(&acpi_ec_driver);
990
991 remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir);
992
Patrick Mocheld550d982006-06-27 00:41:40 -0400993 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700994}
Len Brown50526df2005-08-11 17:32:05 -0400995#endif /* 0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700996
997static int __init acpi_fake_ecdt_setup(char *str)
998{
999 acpi_fake_ecdt_enabled = 1;
OGAWA Hirofumi9b410462006-03-31 02:30:33 -08001000 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001001}
Luming Yu7b15f5e2005-08-03 17:38:04 -04001002
Linus Torvalds1da177e2005-04-16 15:20:36 -07001003__setup("acpi_fake_ecdt", acpi_fake_ecdt_setup);
Len Brown02b28a332005-12-05 16:33:04 -05001004static int __init acpi_ec_set_intr_mode(char *str)
Luming Yu45bea152005-07-23 04:08:00 -04001005{
Len Brown02b28a332005-12-05 16:33:04 -05001006 int intr;
Luming Yu7b15f5e2005-08-03 17:38:04 -04001007
Len Brown02b28a332005-12-05 16:33:04 -05001008 if (!get_option(&str, &intr))
Luming Yu7b15f5e2005-08-03 17:38:04 -04001009 return 0;
1010
Len Brown02b28a332005-12-05 16:33:04 -05001011 if (intr) {
Denis M. Sadykov703959d2006-09-26 19:50:33 +04001012 acpi_ec_mode = EC_INTR;
Luming Yu7b15f5e2005-08-03 17:38:04 -04001013 } else {
Denis M. Sadykov703959d2006-09-26 19:50:33 +04001014 acpi_ec_mode = EC_POLL;
Luming Yu7b15f5e2005-08-03 17:38:04 -04001015 }
Denis M. Sadykov703959d2006-09-26 19:50:33 +04001016 acpi_ec_driver.ops.add = acpi_ec_add;
Len Brown723fe2c2007-01-06 00:02:07 -05001017 printk(KERN_NOTICE PREFIX "%s mode.\n",
1018 intr ? "interrupt" : "polling");
Denis M. Sadykov703959d2006-09-26 19:50:33 +04001019
OGAWA Hirofumi9b410462006-03-31 02:30:33 -08001020 return 1;
Luming Yu45bea152005-07-23 04:08:00 -04001021}
Len Brown50526df2005-08-11 17:32:05 -04001022
Len Brown53f11d42005-12-05 16:46:36 -05001023__setup("ec_intr=", acpi_ec_set_intr_mode);