blob: ab688837379534b46ab194dacb41925215c3670b [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 Brown02b28a32005-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);
Alexey Starikovskiyc24e9122007-02-15 23:16:18 +0300282 if (ACPI_FAILURE(status)) {
283 mutex_unlock(&ec->lock);
Patrick Mocheld550d982006-06-27 00:41:40 -0400284 return -ENODEV;
Alexey Starikovskiyc24e9122007-02-15 23:16:18 +0300285 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286 }
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500287
Alexey Starikovskiy5d57a6a2006-12-07 18:42:16 +0300288 /* Make sure GPE is enabled before doing transaction */
Alexey Starikovskiya86e2772006-12-07 18:42:16 +0300289 acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR);
Alexey Starikovskiy5d57a6a2006-12-07 18:42:16 +0300290
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400291 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
Luming Yu716e0842005-08-10 01:40:00 -0400292 if (status) {
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300293 printk(KERN_DEBUG PREFIX
294 "input buffer is not empty, aborting transaction\n");
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500295 goto end;
Luming Yu716e0842005-08-10 01:40:00 -0400296 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700297
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300298 status = acpi_ec_transaction_unlocked(ec, command,
299 wdata, wdata_len,
300 rdata, rdata_len);
Len Brown50526df2005-08-11 17:32:05 -0400301
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300302 end:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400304 if (ec->global_lock)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305 acpi_release_global_lock(glk);
Alexey Starikovskiy523953b2006-12-07 18:42:17 +0300306 mutex_unlock(&ec->lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307
Patrick Mocheld550d982006-06-27 00:41:40 -0400308 return status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309}
310
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300311static int acpi_ec_read(struct acpi_ec *ec, u8 address, u8 * data)
Denis M. Sadykov3576cf62006-09-26 19:50:33 +0400312{
313 int result;
314 u8 d;
315
316 result = acpi_ec_transaction(ec, ACPI_EC_COMMAND_READ,
317 &address, 1, &d, 1);
318 *data = d;
319 return result;
320}
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400321
Denis M. Sadykov3576cf62006-09-26 19:50:33 +0400322static int acpi_ec_write(struct acpi_ec *ec, u8 address, u8 data)
323{
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300324 u8 wdata[2] = { address, data };
325 return acpi_ec_transaction(ec, ACPI_EC_COMMAND_WRITE,
Denis M. Sadykov3576cf62006-09-26 19:50:33 +0400326 wdata, 2, NULL, 0);
327}
328
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329/*
330 * Externally callable EC access functions. For now, assume 1 EC only
331 */
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300332int ec_read(u8 addr, u8 * val)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333{
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400334 struct acpi_ec *ec;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335 int err;
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400336 u8 temp_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700337
338 if (!first_ec)
339 return -ENODEV;
340
341 ec = acpi_driver_data(first_ec);
342
343 err = acpi_ec_read(ec, addr, &temp_data);
344
345 if (!err) {
346 *val = temp_data;
347 return 0;
Len Brown50526df2005-08-11 17:32:05 -0400348 } else
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349 return err;
350}
Len Brown50526df2005-08-11 17:32:05 -0400351
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352EXPORT_SYMBOL(ec_read);
353
Len Brown50526df2005-08-11 17:32:05 -0400354int ec_write(u8 addr, u8 val)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355{
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400356 struct acpi_ec *ec;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700357 int err;
358
359 if (!first_ec)
360 return -ENODEV;
361
362 ec = acpi_driver_data(first_ec);
363
364 err = acpi_ec_write(ec, addr, val);
365
366 return err;
367}
Len Brown50526df2005-08-11 17:32:05 -0400368
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369EXPORT_SYMBOL(ec_write);
370
Randy Dunlap616362d2006-10-27 01:47:34 -0400371int ec_transaction(u8 command,
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300372 const u8 * wdata, unsigned wdata_len,
373 u8 * rdata, unsigned rdata_len)
Luming Yu45bea152005-07-23 04:08:00 -0400374{
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400375 struct acpi_ec *ec;
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400376
377 if (!first_ec)
378 return -ENODEV;
379
380 ec = acpi_driver_data(first_ec);
381
Denis M. Sadykov3576cf62006-09-26 19:50:33 +0400382 return acpi_ec_transaction(ec, command, wdata,
383 wdata_len, rdata, rdata_len);
Luming Yu45bea152005-07-23 04:08:00 -0400384}
Luming Yu45bea152005-07-23 04:08:00 -0400385
Lennart Poetteringab9e43c2006-10-03 22:49:00 -0400386EXPORT_SYMBOL(ec_transaction);
387
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300388static int acpi_ec_query(struct acpi_ec *ec, u8 * data)
Denis M. Sadykov3576cf62006-09-26 19:50:33 +0400389{
390 int result;
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300391 u8 d;
Luming Yu45bea152005-07-23 04:08:00 -0400392
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300393 if (!ec || !data)
394 return -EINVAL;
Luming Yu45bea152005-07-23 04:08:00 -0400395
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300396 /*
397 * Query the EC to find out which _Qxx method we need to evaluate.
398 * Note that successful completion of the query causes the ACPI_EC_SCI
399 * bit to be cleared (and thus clearing the interrupt source).
400 */
Luming Yu45bea152005-07-23 04:08:00 -0400401
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300402 result = acpi_ec_transaction(ec, ACPI_EC_COMMAND_QUERY, NULL, 0, &d, 1);
403 if (result)
404 return result;
Luming Yu45bea152005-07-23 04:08:00 -0400405
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300406 if (!d)
407 return -ENODATA;
Luming Yu45bea152005-07-23 04:08:00 -0400408
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300409 *data = d;
410 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411}
412
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413/* --------------------------------------------------------------------------
414 Event Management
415 -------------------------------------------------------------------------- */
416
Len Brown50526df2005-08-11 17:32:05 -0400417static void acpi_ec_gpe_query(void *ec_cxt)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700418{
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400419 struct acpi_ec *ec = (struct acpi_ec *)ec_cxt;
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400420 u8 value = 0;
Alexey Starikovskiy5d0c2882006-12-07 18:42:16 +0300421 char object_name[8];
Luming Yu45bea152005-07-23 04:08:00 -0400422
Alexey Starikovskiy5d0c2882006-12-07 18:42:16 +0300423 if (!ec || acpi_ec_query(ec, &value))
Alexey Starikovskiye41334c2006-12-07 18:42:16 +0300424 return;
Luming Yu45bea152005-07-23 04:08:00 -0400425
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400426 snprintf(object_name, 8, "_Q%2.2X", value);
Luming Yu45bea152005-07-23 04:08:00 -0400427
Guillaume Chazarainc6e19192006-12-24 22:19:02 +0100428 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluating %s", object_name));
Luming Yu45bea152005-07-23 04:08:00 -0400429
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400430 acpi_evaluate_object(ec->handle, object_name, NULL, NULL);
Luming Yu45bea152005-07-23 04:08:00 -0400431}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700432
Len Brown50526df2005-08-11 17:32:05 -0400433static u32 acpi_ec_gpe_handler(void *data)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434{
Len Brown50526df2005-08-11 17:32:05 -0400435 acpi_status status = AE_OK;
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400436 u8 value;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400437 struct acpi_ec *ec = (struct acpi_ec *)data;
Luming Yu45bea152005-07-23 04:08:00 -0400438
Denis M. Sadykov8e0341b2006-09-26 19:50:33 +0400439 if (acpi_ec_mode == EC_INTR) {
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300440 wake_up(&ec->wait);
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500441 }
442
Alexey Starikovskiybec5a1e2006-12-07 18:42:16 +0300443 value = acpi_ec_read_status(ec);
Alexey Starikovskiy5d0c2882006-12-07 18:42:16 +0300444 if ((value & ACPI_EC_FLAG_SCI) && !atomic_read(&ec->query_pending)) {
445 atomic_set(&ec->query_pending, 1);
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300446 status =
447 acpi_os_execute(OSL_EC_BURST_HANDLER, acpi_ec_gpe_query,
448 ec);
Len Brown50526df2005-08-11 17:32:05 -0400449 }
Alexey Starikovskiye41334c2006-12-07 18:42:16 +0300450
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500451 return status == AE_OK ?
Len Brown50526df2005-08-11 17:32:05 -0400452 ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700453}
454
455/* --------------------------------------------------------------------------
456 Address Space Management
457 -------------------------------------------------------------------------- */
458
459static acpi_status
Len Brown50526df2005-08-11 17:32:05 -0400460acpi_ec_space_setup(acpi_handle region_handle,
461 u32 function, void *handler_context, void **return_context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462{
463 /*
464 * The EC object is in the handler context and is needed
465 * when calling the acpi_ec_space_handler.
466 */
Len Brown50526df2005-08-11 17:32:05 -0400467 *return_context = (function != ACPI_REGION_DEACTIVATE) ?
468 handler_context : NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469
470 return AE_OK;
471}
472
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473static acpi_status
Len Brown50526df2005-08-11 17:32:05 -0400474acpi_ec_space_handler(u32 function,
475 acpi_physical_address address,
476 u32 bit_width,
477 acpi_integer * value,
478 void *handler_context, void *region_context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479{
Len Brown50526df2005-08-11 17:32:05 -0400480 int result = 0;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400481 struct acpi_ec *ec = NULL;
Len Brown50526df2005-08-11 17:32:05 -0400482 u64 temp = *value;
483 acpi_integer f_v = 0;
484 int i = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485
Linus Torvalds1da177e2005-04-16 15:20:36 -0700486 if ((address > 0xFF) || !value || !handler_context)
Patrick Mocheld550d982006-06-27 00:41:40 -0400487 return AE_BAD_PARAMETER;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700488
Luming Yufa9cd542005-03-19 01:54:47 -0500489 if (bit_width != 8 && acpi_strict) {
Patrick Mocheld550d982006-06-27 00:41:40 -0400490 return AE_BAD_PARAMETER;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700491 }
492
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400493 ec = (struct acpi_ec *)handler_context;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494
Len Brown50526df2005-08-11 17:32:05 -0400495 next_byte:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700496 switch (function) {
497 case ACPI_READ:
Luming Yufa9cd542005-03-19 01:54:47 -0500498 temp = 0;
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300499 result = acpi_ec_read(ec, (u8) address, (u8 *) & temp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700500 break;
501 case ACPI_WRITE:
Luming Yufa9cd542005-03-19 01:54:47 -0500502 result = acpi_ec_write(ec, (u8) address, (u8) temp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503 break;
504 default:
505 result = -EINVAL;
506 goto out;
507 break;
508 }
509
510 bit_width -= 8;
Luming Yufa9cd542005-03-19 01:54:47 -0500511 if (bit_width) {
512 if (function == ACPI_READ)
513 f_v |= temp << 8 * i;
514 if (function == ACPI_WRITE)
515 temp >>= 8;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700516 i++;
Andrew Morton83ea7442005-03-30 22:12:13 -0500517 address++;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700518 goto next_byte;
519 }
520
Luming Yufa9cd542005-03-19 01:54:47 -0500521 if (function == ACPI_READ) {
522 f_v |= temp << 8 * i;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700523 *value = f_v;
524 }
525
Len Brown50526df2005-08-11 17:32:05 -0400526 out:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527 switch (result) {
528 case -EINVAL:
Patrick Mocheld550d982006-06-27 00:41:40 -0400529 return AE_BAD_PARAMETER;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700530 break;
531 case -ENODEV:
Patrick Mocheld550d982006-06-27 00:41:40 -0400532 return AE_NOT_FOUND;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700533 break;
534 case -ETIME:
Patrick Mocheld550d982006-06-27 00:41:40 -0400535 return AE_TIME;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700536 break;
537 default:
Patrick Mocheld550d982006-06-27 00:41:40 -0400538 return AE_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700539 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700540}
541
Linus Torvalds1da177e2005-04-16 15:20:36 -0700542/* --------------------------------------------------------------------------
543 FS Interface (/proc)
544 -------------------------------------------------------------------------- */
545
Len Brown50526df2005-08-11 17:32:05 -0400546static struct proc_dir_entry *acpi_ec_dir;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700547
Len Brown50526df2005-08-11 17:32:05 -0400548static int acpi_ec_read_info(struct seq_file *seq, void *offset)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700549{
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400550 struct acpi_ec *ec = (struct acpi_ec *)seq->private;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700551
Linus Torvalds1da177e2005-04-16 15:20:36 -0700552 if (!ec)
553 goto end;
554
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300555 seq_printf(seq, "gpe: 0x%02x\n", (u32) ec->gpe);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700556 seq_printf(seq, "ports: 0x%02x, 0x%02x\n",
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300557 (u32) ec->command_addr, (u32) ec->data_addr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700558 seq_printf(seq, "use global lock: %s\n",
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400559 ec->global_lock ? "yes" : "no");
Alexey Starikovskiya86e2772006-12-07 18:42:16 +0300560 acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700561
Len Brown50526df2005-08-11 17:32:05 -0400562 end:
Patrick Mocheld550d982006-06-27 00:41:40 -0400563 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700564}
565
566static int acpi_ec_info_open_fs(struct inode *inode, struct file *file)
567{
568 return single_open(file, acpi_ec_read_info, PDE(inode)->data);
569}
570
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400571static struct file_operations acpi_ec_info_ops = {
Len Brown50526df2005-08-11 17:32:05 -0400572 .open = acpi_ec_info_open_fs,
573 .read = seq_read,
574 .llseek = seq_lseek,
575 .release = single_release,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700576 .owner = THIS_MODULE,
577};
578
Len Brown50526df2005-08-11 17:32:05 -0400579static int acpi_ec_add_fs(struct acpi_device *device)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700580{
Len Brown50526df2005-08-11 17:32:05 -0400581 struct proc_dir_entry *entry = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700582
Linus Torvalds1da177e2005-04-16 15:20:36 -0700583 if (!acpi_device_dir(device)) {
584 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
Len Brown50526df2005-08-11 17:32:05 -0400585 acpi_ec_dir);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700586 if (!acpi_device_dir(device))
Patrick Mocheld550d982006-06-27 00:41:40 -0400587 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700588 }
589
590 entry = create_proc_entry(ACPI_EC_FILE_INFO, S_IRUGO,
Len Brown50526df2005-08-11 17:32:05 -0400591 acpi_device_dir(device));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592 if (!entry)
Patrick Mocheld550d982006-06-27 00:41:40 -0400593 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700594 else {
595 entry->proc_fops = &acpi_ec_info_ops;
596 entry->data = acpi_driver_data(device);
597 entry->owner = THIS_MODULE;
598 }
599
Patrick Mocheld550d982006-06-27 00:41:40 -0400600 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700601}
602
Len Brown50526df2005-08-11 17:32:05 -0400603static int acpi_ec_remove_fs(struct acpi_device *device)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700604{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700605
606 if (acpi_device_dir(device)) {
607 remove_proc_entry(ACPI_EC_FILE_INFO, acpi_device_dir(device));
608 remove_proc_entry(acpi_device_bid(device), acpi_ec_dir);
609 acpi_device_dir(device) = NULL;
610 }
611
Patrick Mocheld550d982006-06-27 00:41:40 -0400612 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700613}
614
Linus Torvalds1da177e2005-04-16 15:20:36 -0700615/* --------------------------------------------------------------------------
616 Driver Interface
617 -------------------------------------------------------------------------- */
618
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400619static int acpi_ec_add(struct acpi_device *device)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700620{
Len Brown50526df2005-08-11 17:32:05 -0400621 int result = 0;
622 acpi_status status = AE_OK;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400623 struct acpi_ec *ec = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700624
Linus Torvalds1da177e2005-04-16 15:20:36 -0700625 if (!device)
Patrick Mocheld550d982006-06-27 00:41:40 -0400626 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700627
Burman Yan36bcbec2006-12-19 12:56:11 -0800628 ec = kzalloc(sizeof(struct acpi_ec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700629 if (!ec)
Patrick Mocheld550d982006-06-27 00:41:40 -0400630 return -ENOMEM;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700631
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400632 ec->handle = device->handle;
633 ec->uid = -1;
Alexey Starikovskiyc787a852006-12-07 18:42:16 +0300634 mutex_init(&ec->lock);
Alexey Starikovskiy5d0c2882006-12-07 18:42:16 +0300635 atomic_set(&ec->query_pending, 0);
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400636 if (acpi_ec_mode == EC_INTR) {
637 atomic_set(&ec->leaving_burst, 1);
638 init_waitqueue_head(&ec->wait);
639 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700640 strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME);
641 strcpy(acpi_device_class(device), ACPI_EC_CLASS);
642 acpi_driver_data(device) = ec;
643
644 /* Use the global lock for all EC transactions? */
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300645 acpi_evaluate_integer(ec->handle, "_GLK", NULL, &ec->global_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700646
Jiri Slabyff2fc3e2006-03-28 17:04:00 -0500647 /* XXX we don't test uids, because on some boxes ecdt uid = 0, see:
648 http://bugzilla.kernel.org/show_bug.cgi?id=6111 */
649 if (ec_ecdt) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700650 acpi_remove_address_space_handler(ACPI_ROOT_OBJECT,
Len Brown50526df2005-08-11 17:32:05 -0400651 ACPI_ADR_SPACE_EC,
652 &acpi_ec_space_handler);
653
Alexey Starikovskiya86e2772006-12-07 18:42:16 +0300654 acpi_remove_gpe_handler(NULL, ec_ecdt->gpe,
Len Brown50526df2005-08-11 17:32:05 -0400655 &acpi_ec_gpe_handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700656
657 kfree(ec_ecdt);
658 }
659
660 /* Get GPE bit assignment (EC events). */
661 /* TODO: Add support for _GPE returning a package */
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300662 status = acpi_evaluate_integer(ec->handle, "_GPE", NULL, &ec->gpe);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700663 if (ACPI_FAILURE(status)) {
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300664 ACPI_EXCEPTION((AE_INFO, status,
665 "Obtaining GPE bit assignment"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700666 result = -ENODEV;
667 goto end;
668 }
669
670 result = acpi_ec_add_fs(device);
671 if (result)
672 goto end;
673
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400674 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s [%s] (gpe %d) interrupt mode.",
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300675 acpi_device_name(device), acpi_device_bid(device),
676 (u32) ec->gpe));
Luming Yu45bea152005-07-23 04:08:00 -0400677
678 if (!first_ec)
679 first_ec = device;
680
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300681 end:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700682 if (result)
683 kfree(ec);
684
Patrick Mocheld550d982006-06-27 00:41:40 -0400685 return result;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700686}
687
Len Brown50526df2005-08-11 17:32:05 -0400688static int acpi_ec_remove(struct acpi_device *device, int type)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700689{
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400690 struct acpi_ec *ec = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700691
Linus Torvalds1da177e2005-04-16 15:20:36 -0700692 if (!device)
Patrick Mocheld550d982006-06-27 00:41:40 -0400693 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700694
695 ec = acpi_driver_data(device);
696
697 acpi_ec_remove_fs(device);
698
699 kfree(ec);
700
Patrick Mocheld550d982006-06-27 00:41:40 -0400701 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700702}
703
Linus Torvalds1da177e2005-04-16 15:20:36 -0700704static acpi_status
Len Brown50526df2005-08-11 17:32:05 -0400705acpi_ec_io_ports(struct acpi_resource *resource, void *context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700706{
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400707 struct acpi_ec *ec = (struct acpi_ec *)context;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700708
Bob Moore50eca3e2005-09-30 19:03:00 -0400709 if (resource->type != ACPI_RESOURCE_TYPE_IO) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700710 return AE_OK;
711 }
712
713 /*
714 * The first address region returned is the data port, and
715 * the second address region returned is the status/command
716 * port.
717 */
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400718 if (ec->data_addr == 0) {
719 ec->data_addr = resource->data.io.minimum;
720 } else if (ec->command_addr == 0) {
721 ec->command_addr = resource->data.io.minimum;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700722 } else {
723 return AE_CTRL_TERMINATE;
724 }
725
Linus Torvalds1da177e2005-04-16 15:20:36 -0700726 return AE_OK;
727}
728
Len Brown50526df2005-08-11 17:32:05 -0400729static int acpi_ec_start(struct acpi_device *device)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700730{
Len Brown50526df2005-08-11 17:32:05 -0400731 acpi_status status = AE_OK;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400732 struct acpi_ec *ec = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700733
Linus Torvalds1da177e2005-04-16 15:20:36 -0700734 if (!device)
Patrick Mocheld550d982006-06-27 00:41:40 -0400735 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700736
737 ec = acpi_driver_data(device);
738
739 if (!ec)
Patrick Mocheld550d982006-06-27 00:41:40 -0400740 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700741
742 /*
743 * Get I/O port addresses. Convert to GAS format.
744 */
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400745 status = acpi_walk_resources(ec->handle, METHOD_NAME__CRS,
Len Brown50526df2005-08-11 17:32:05 -0400746 acpi_ec_io_ports, ec);
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400747 if (ACPI_FAILURE(status) || ec->command_addr == 0) {
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400748 ACPI_EXCEPTION((AE_INFO, status,
749 "Error getting I/O port addresses"));
Patrick Mocheld550d982006-06-27 00:41:40 -0400750 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700751 }
752
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400753 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "gpe=0x%02lx, ports=0x%2lx,0x%2lx",
Alexey Starikovskiya86e2772006-12-07 18:42:16 +0300754 ec->gpe, ec->command_addr, ec->data_addr));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700755
756 /*
757 * Install GPE handler
758 */
Alexey Starikovskiya86e2772006-12-07 18:42:16 +0300759 status = acpi_install_gpe_handler(NULL, ec->gpe,
Len Brown50526df2005-08-11 17:32:05 -0400760 ACPI_GPE_EDGE_TRIGGERED,
761 &acpi_ec_gpe_handler, ec);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700762 if (ACPI_FAILURE(status)) {
Patrick Mocheld550d982006-06-27 00:41:40 -0400763 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700764 }
Alexey Starikovskiya86e2772006-12-07 18:42:16 +0300765 acpi_set_gpe_type(NULL, ec->gpe, ACPI_GPE_TYPE_RUNTIME);
766 acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700767
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400768 status = acpi_install_address_space_handler(ec->handle,
Len Brown50526df2005-08-11 17:32:05 -0400769 ACPI_ADR_SPACE_EC,
770 &acpi_ec_space_handler,
771 &acpi_ec_space_setup, ec);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700772 if (ACPI_FAILURE(status)) {
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300773 acpi_remove_gpe_handler(NULL, ec->gpe, &acpi_ec_gpe_handler);
Patrick Mocheld550d982006-06-27 00:41:40 -0400774 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700775 }
776
Patrick Mocheld550d982006-06-27 00:41:40 -0400777 return AE_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700778}
779
Len Brown50526df2005-08-11 17:32:05 -0400780static int acpi_ec_stop(struct acpi_device *device, int type)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700781{
Len Brown50526df2005-08-11 17:32:05 -0400782 acpi_status status = AE_OK;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400783 struct acpi_ec *ec = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700784
Linus Torvalds1da177e2005-04-16 15:20:36 -0700785 if (!device)
Patrick Mocheld550d982006-06-27 00:41:40 -0400786 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700787
788 ec = acpi_driver_data(device);
789
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400790 status = acpi_remove_address_space_handler(ec->handle,
Len Brown50526df2005-08-11 17:32:05 -0400791 ACPI_ADR_SPACE_EC,
792 &acpi_ec_space_handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700793 if (ACPI_FAILURE(status))
Patrick Mocheld550d982006-06-27 00:41:40 -0400794 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700795
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300796 status = acpi_remove_gpe_handler(NULL, ec->gpe, &acpi_ec_gpe_handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700797 if (ACPI_FAILURE(status))
Patrick Mocheld550d982006-06-27 00:41:40 -0400798 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700799
Patrick Mocheld550d982006-06-27 00:41:40 -0400800 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700801}
802
803static acpi_status __init
Len Brown50526df2005-08-11 17:32:05 -0400804acpi_fake_ecdt_callback(acpi_handle handle,
805 u32 Level, void *context, void **retval)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700806{
Len Brown50526df2005-08-11 17:32:05 -0400807 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700808
Alexey Starikovskiyc787a852006-12-07 18:42:16 +0300809 mutex_init(&ec_ecdt->lock);
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400810 if (acpi_ec_mode == EC_INTR) {
811 init_waitqueue_head(&ec_ecdt->wait);
812 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700813 status = acpi_walk_resources(handle, METHOD_NAME__CRS,
Len Brown50526df2005-08-11 17:32:05 -0400814 acpi_ec_io_ports, ec_ecdt);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700815 if (ACPI_FAILURE(status))
816 return status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700817
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400818 ec_ecdt->uid = -1;
819 acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->uid);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700820
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300821 status = acpi_evaluate_integer(handle, "_GPE", NULL, &ec_ecdt->gpe);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700822 if (ACPI_FAILURE(status))
823 return status;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400824 ec_ecdt->global_lock = TRUE;
825 ec_ecdt->handle = handle;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700826
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400827 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "GPE=0x%02lx, ports=0x%2lx, 0x%2lx",
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300828 ec_ecdt->gpe, ec_ecdt->command_addr,
829 ec_ecdt->data_addr));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700830
831 return AE_CTRL_TERMINATE;
832}
833
834/*
835 * Some BIOS (such as some from Gateway laptops) access EC region very early
836 * such as in BAT0._INI or EC._INI before an EC device is found and
837 * do not provide an ECDT. According to ACPI spec, ECDT isn't mandatorily
838 * required, but if EC regison is accessed early, it is required.
839 * The routine tries to workaround the BIOS bug by pre-scan EC device
840 * It assumes that _CRS, _HID, _GPE, _UID methods of EC don't touch any
841 * op region (since _REG isn't invoked yet). The assumption is true for
842 * all systems found.
843 */
Len Brown50526df2005-08-11 17:32:05 -0400844static int __init acpi_ec_fake_ecdt(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700845{
Len Brown50526df2005-08-11 17:32:05 -0400846 acpi_status status;
847 int ret = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700848
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400849 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Try to make an fake ECDT"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700850
Burman Yan36bcbec2006-12-19 12:56:11 -0800851 ec_ecdt = kzalloc(sizeof(struct acpi_ec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700852 if (!ec_ecdt) {
853 ret = -ENOMEM;
854 goto error;
855 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700856
Len Brown50526df2005-08-11 17:32:05 -0400857 status = acpi_get_devices(ACPI_EC_HID,
858 acpi_fake_ecdt_callback, NULL, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700859 if (ACPI_FAILURE(status)) {
860 kfree(ec_ecdt);
861 ec_ecdt = NULL;
862 ret = -ENODEV;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400863 ACPI_EXCEPTION((AE_INFO, status, "Can't make an fake ECDT"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700864 goto error;
865 }
866 return 0;
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300867 error:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700868 return ret;
869}
870
Len Brown50526df2005-08-11 17:32:05 -0400871static int __init acpi_ec_get_real_ecdt(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700872{
Len Brown50526df2005-08-11 17:32:05 -0400873 acpi_status status;
874 struct acpi_table_ecdt *ecdt_ptr;
Luming Yu45bea152005-07-23 04:08:00 -0400875
Alexey Starikovskiy15a58ed2007-02-02 19:48:22 +0300876 status = acpi_get_table(ACPI_SIG_ECDT, 1,
877 (struct acpi_table_header **)&ecdt_ptr);
Luming Yu45bea152005-07-23 04:08:00 -0400878 if (ACPI_FAILURE(status))
879 return -ENODEV;
880
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400881 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found ECDT"));
Luming Yu45bea152005-07-23 04:08:00 -0400882
883 /*
884 * Generate a temporary ec context to use until the namespace is scanned
885 */
Burman Yan36bcbec2006-12-19 12:56:11 -0800886 ec_ecdt = kzalloc(sizeof(struct acpi_ec), GFP_KERNEL);
Luming Yu45bea152005-07-23 04:08:00 -0400887 if (!ec_ecdt)
888 return -ENOMEM;
Luming Yu45bea152005-07-23 04:08:00 -0400889
Alexey Starikovskiyc787a852006-12-07 18:42:16 +0300890 mutex_init(&ec_ecdt->lock);
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400891 if (acpi_ec_mode == EC_INTR) {
892 init_waitqueue_head(&ec_ecdt->wait);
893 }
Alexey Starikovskiyad363f82007-02-02 19:48:22 +0300894 ec_ecdt->command_addr = ecdt_ptr->control.address;
895 ec_ecdt->data_addr = ecdt_ptr->data.address;
896 ec_ecdt->gpe = ecdt_ptr->gpe;
Luming Yu45bea152005-07-23 04:08:00 -0400897 /* use the GL just to be safe */
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400898 ec_ecdt->global_lock = TRUE;
899 ec_ecdt->uid = ecdt_ptr->uid;
Luming Yu45bea152005-07-23 04:08:00 -0400900
Alexey Starikovskiyad363f82007-02-02 19:48:22 +0300901 status = acpi_get_handle(NULL, ecdt_ptr->id, &ec_ecdt->handle);
Luming Yu45bea152005-07-23 04:08:00 -0400902 if (ACPI_FAILURE(status)) {
903 goto error;
904 }
905
906 return 0;
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300907 error:
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400908 ACPI_EXCEPTION((AE_INFO, status, "Could not use ECDT"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700909 kfree(ec_ecdt);
910 ec_ecdt = NULL;
911
912 return -ENODEV;
913}
914
915static int __initdata acpi_fake_ecdt_enabled;
Len Brown50526df2005-08-11 17:32:05 -0400916int __init acpi_ec_ecdt_probe(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700917{
Len Brown50526df2005-08-11 17:32:05 -0400918 acpi_status status;
919 int ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700920
921 ret = acpi_ec_get_real_ecdt();
922 /* Try to make a fake ECDT */
923 if (ret && acpi_fake_ecdt_enabled) {
924 ret = acpi_ec_fake_ecdt();
925 }
926
927 if (ret)
928 return 0;
929
930 /*
931 * Install GPE handler
932 */
Alexey Starikovskiya86e2772006-12-07 18:42:16 +0300933 status = acpi_install_gpe_handler(NULL, ec_ecdt->gpe,
Len Brown50526df2005-08-11 17:32:05 -0400934 ACPI_GPE_EDGE_TRIGGERED,
935 &acpi_ec_gpe_handler, ec_ecdt);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700936 if (ACPI_FAILURE(status)) {
937 goto error;
938 }
Alexey Starikovskiya86e2772006-12-07 18:42:16 +0300939 acpi_set_gpe_type(NULL, ec_ecdt->gpe, ACPI_GPE_TYPE_RUNTIME);
940 acpi_enable_gpe(NULL, ec_ecdt->gpe, ACPI_NOT_ISR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700941
Len Brown50526df2005-08-11 17:32:05 -0400942 status = acpi_install_address_space_handler(ACPI_ROOT_OBJECT,
943 ACPI_ADR_SPACE_EC,
944 &acpi_ec_space_handler,
945 &acpi_ec_space_setup,
946 ec_ecdt);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700947 if (ACPI_FAILURE(status)) {
Alexey Starikovskiya86e2772006-12-07 18:42:16 +0300948 acpi_remove_gpe_handler(NULL, ec_ecdt->gpe,
Len Brown50526df2005-08-11 17:32:05 -0400949 &acpi_ec_gpe_handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700950 goto error;
951 }
952
953 return 0;
954
Len Brown50526df2005-08-11 17:32:05 -0400955 error:
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400956 ACPI_EXCEPTION((AE_INFO, status, "Could not use ECDT"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700957 kfree(ec_ecdt);
958 ec_ecdt = NULL;
959
960 return -ENODEV;
961}
962
Len Brown50526df2005-08-11 17:32:05 -0400963static int __init acpi_ec_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700964{
Len Brown50526df2005-08-11 17:32:05 -0400965 int result = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700966
Linus Torvalds1da177e2005-04-16 15:20:36 -0700967 if (acpi_disabled)
Patrick Mocheld550d982006-06-27 00:41:40 -0400968 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700969
970 acpi_ec_dir = proc_mkdir(ACPI_EC_CLASS, acpi_root_dir);
971 if (!acpi_ec_dir)
Patrick Mocheld550d982006-06-27 00:41:40 -0400972 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700973
974 /* Now register the driver for the EC */
975 result = acpi_bus_register_driver(&acpi_ec_driver);
976 if (result < 0) {
977 remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir);
Patrick Mocheld550d982006-06-27 00:41:40 -0400978 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700979 }
980
Patrick Mocheld550d982006-06-27 00:41:40 -0400981 return result;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700982}
983
984subsys_initcall(acpi_ec_init);
985
986/* EC driver currently not unloadable */
987#if 0
Len Brown50526df2005-08-11 17:32:05 -0400988static void __exit acpi_ec_exit(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700989{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700990
991 acpi_bus_unregister_driver(&acpi_ec_driver);
992
993 remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir);
994
Patrick Mocheld550d982006-06-27 00:41:40 -0400995 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700996}
Len Brown50526df2005-08-11 17:32:05 -0400997#endif /* 0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700998
999static int __init acpi_fake_ecdt_setup(char *str)
1000{
1001 acpi_fake_ecdt_enabled = 1;
OGAWA Hirofumi9b410462006-03-31 02:30:33 -08001002 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001003}
Luming Yu7b15f5e2005-08-03 17:38:04 -04001004
Linus Torvalds1da177e2005-04-16 15:20:36 -07001005__setup("acpi_fake_ecdt", acpi_fake_ecdt_setup);
Len Brown02b28a32005-12-05 16:33:04 -05001006static int __init acpi_ec_set_intr_mode(char *str)
Luming Yu45bea152005-07-23 04:08:00 -04001007{
Len Brown02b28a32005-12-05 16:33:04 -05001008 int intr;
Luming Yu7b15f5e2005-08-03 17:38:04 -04001009
Len Brown02b28a32005-12-05 16:33:04 -05001010 if (!get_option(&str, &intr))
Luming Yu7b15f5e2005-08-03 17:38:04 -04001011 return 0;
1012
Len Brown02b28a32005-12-05 16:33:04 -05001013 if (intr) {
Denis M. Sadykov703959d2006-09-26 19:50:33 +04001014 acpi_ec_mode = EC_INTR;
Luming Yu7b15f5e2005-08-03 17:38:04 -04001015 } else {
Denis M. Sadykov703959d2006-09-26 19:50:33 +04001016 acpi_ec_mode = EC_POLL;
Luming Yu7b15f5e2005-08-03 17:38:04 -04001017 }
Denis M. Sadykov703959d2006-09-26 19:50:33 +04001018 acpi_ec_driver.ops.add = acpi_ec_add;
Len Brown723fe2c2007-01-06 00:02:07 -05001019 printk(KERN_NOTICE PREFIX "%s mode.\n",
1020 intr ? "interrupt" : "polling");
Denis M. Sadykov703959d2006-09-26 19:50:33 +04001021
OGAWA Hirofumi9b410462006-03-31 02:30:33 -08001022 return 1;
Luming Yu45bea152005-07-23 04:08:00 -04001023}
Len Brown50526df2005-08-11 17:32:05 -04001024
Len Brown53f11d42005-12-05 16:46:36 -05001025__setup("ec_intr=", acpi_ec_set_intr_mode);