blob: 8f5aaf753fdac7d81b5772fe8f5bff1e186941ac [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 Brown50526df2005-08-11 17:32:05 -040041ACPI_MODULE_NAME("acpi_ec")
Linus Torvalds1da177e2005-04-16 15:20:36 -070042#define ACPI_EC_COMPONENT 0x00100000
43#define ACPI_EC_CLASS "embedded_controller"
44#define ACPI_EC_HID "PNP0C09"
45#define ACPI_EC_DRIVER_NAME "ACPI Embedded Controller Driver"
46#define ACPI_EC_DEVICE_NAME "Embedded Controller"
47#define ACPI_EC_FILE_INFO "info"
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +030048#undef PREFIX
49#define PREFIX "ACPI: EC: "
Denis M. Sadykov703959d2006-09-26 19:50:33 +040050/* EC status register */
Linus Torvalds1da177e2005-04-16 15:20:36 -070051#define ACPI_EC_FLAG_OBF 0x01 /* Output buffer full */
52#define ACPI_EC_FLAG_IBF 0x02 /* Input buffer full */
Dmitry Torokhov451566f2005-03-19 01:10:05 -050053#define ACPI_EC_FLAG_BURST 0x10 /* burst mode */
Linus Torvalds1da177e2005-04-16 15:20:36 -070054#define ACPI_EC_FLAG_SCI 0x20 /* EC-SCI occurred */
Denis M. Sadykov703959d2006-09-26 19:50:33 +040055/* EC commands */
Alexey Starikovskiy3261ff42006-12-07 18:42:17 +030056enum ec_command {
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +030057 ACPI_EC_COMMAND_READ = 0x80,
58 ACPI_EC_COMMAND_WRITE = 0x81,
59 ACPI_EC_BURST_ENABLE = 0x82,
60 ACPI_EC_BURST_DISABLE = 0x83,
61 ACPI_EC_COMMAND_QUERY = 0x84,
Alexey Starikovskiy3261ff42006-12-07 18:42:17 +030062};
Denis M. Sadykov703959d2006-09-26 19:50:33 +040063/* EC events */
Alexey Starikovskiy3261ff42006-12-07 18:42:17 +030064enum ec_event {
Denis M. Sadykov703959d2006-09-26 19:50:33 +040065 ACPI_EC_EVENT_OBF_1 = 1, /* Output buffer full */
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +030066 ACPI_EC_EVENT_IBF_0, /* Input buffer empty */
Denis M. Sadykov703959d2006-09-26 19:50:33 +040067};
68
Alexey Starikovskiy5c406412006-12-07 18:42:16 +030069#define ACPI_EC_DELAY 500 /* Wait 500ms max. during EC ops */
Denis M. Sadykov703959d2006-09-26 19:50:33 +040070#define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */
Denis M. Sadykov703959d2006-09-26 19:50:33 +040071
Alexey Starikovskiy3261ff42006-12-07 18:42:17 +030072static enum ec_mode {
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +030073 EC_INTR = 1, /* Output buffer full */
74 EC_POLL, /* Input buffer empty */
Alexey Starikovskiy3261ff42006-12-07 18:42:17 +030075} acpi_ec_mode = EC_INTR;
Denis M. Sadykov703959d2006-09-26 19:50:33 +040076
Len Brown50526df2005-08-11 17:32:05 -040077static int acpi_ec_remove(struct acpi_device *device, int type);
78static int acpi_ec_start(struct acpi_device *device);
79static int acpi_ec_stop(struct acpi_device *device, int type);
Denis M. Sadykov703959d2006-09-26 19:50:33 +040080static int acpi_ec_add(struct acpi_device *device);
Linus Torvalds1da177e2005-04-16 15:20:36 -070081
82static struct acpi_driver acpi_ec_driver = {
Len Brown50526df2005-08-11 17:32:05 -040083 .name = ACPI_EC_DRIVER_NAME,
84 .class = ACPI_EC_CLASS,
85 .ids = ACPI_EC_HID,
86 .ops = {
Denis M. Sadykov703959d2006-09-26 19:50:33 +040087 .add = acpi_ec_add,
Len Brown50526df2005-08-11 17:32:05 -040088 .remove = acpi_ec_remove,
89 .start = acpi_ec_start,
90 .stop = acpi_ec_stop,
91 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070092};
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +040093
94/* If we find an EC via the ECDT, we need to keep a ptr to its context */
Adrian Bunka854e082006-12-19 12:56:12 -080095static struct acpi_ec {
Denis M. Sadykov703959d2006-09-26 19:50:33 +040096 acpi_handle handle;
97 unsigned long uid;
Alexey Starikovskiya86e2772006-12-07 18:42:16 +030098 unsigned long gpe;
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +040099 unsigned long command_addr;
100 unsigned long data_addr;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400101 unsigned long global_lock;
Alexey Starikovskiyc787a852006-12-07 18:42:16 +0300102 struct mutex lock;
Alexey Starikovskiy5d0c2882006-12-07 18:42:16 +0300103 atomic_t query_pending;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400104 atomic_t leaving_burst; /* 0 : No, 1 : Yes, 2: abort */
105 wait_queue_head_t wait;
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400106} *ec_ecdt;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400107
108/* External interfaces use first EC only, so remember */
109static struct acpi_device *first_ec;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400110
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111/* --------------------------------------------------------------------------
112 Transaction Management
113 -------------------------------------------------------------------------- */
114
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400115static inline u8 acpi_ec_read_status(struct acpi_ec *ec)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116{
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400117 return inb(ec->command_addr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118}
119
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400120static inline u8 acpi_ec_read_data(struct acpi_ec *ec)
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400121{
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400122 return inb(ec->data_addr);
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400123}
124
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400125static inline void acpi_ec_write_cmd(struct acpi_ec *ec, u8 command)
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400126{
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400127 outb(command, ec->command_addr);
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400128}
129
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400130static inline void acpi_ec_write_data(struct acpi_ec *ec, u8 data)
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400131{
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400132 outb(data, ec->data_addr);
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400133}
134
Alexey Starikovskiy3261ff42006-12-07 18:42:17 +0300135static inline int acpi_ec_check_status(struct acpi_ec *ec, enum ec_event event)
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400136{
Alexey Starikovskiybec5a1e2006-12-07 18:42:16 +0300137 u8 status = acpi_ec_read_status(ec);
Alexey Starikovskiy78d0af32006-12-07 18:42:17 +0300138
139 if (event == ACPI_EC_EVENT_OBF_1) {
Denis M. Sadykov7c6db5e2006-09-26 19:50:33 +0400140 if (status & ACPI_EC_FLAG_OBF)
141 return 1;
Alexey Starikovskiy78d0af32006-12-07 18:42:17 +0300142 } else if (event == ACPI_EC_EVENT_IBF_0) {
Denis M. Sadykov7c6db5e2006-09-26 19:50:33 +0400143 if (!(status & ACPI_EC_FLAG_IBF))
144 return 1;
Denis M. Sadykov7c6db5e2006-09-26 19:50:33 +0400145 }
146
147 return 0;
148}
149
Alexey Starikovskiy3261ff42006-12-07 18:42:17 +0300150static int acpi_ec_wait(struct acpi_ec *ec, enum ec_event event)
Luming Yu45bea152005-07-23 04:08:00 -0400151{
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300152 if (acpi_ec_mode == EC_POLL) {
Alexey Starikovskiy50c1e112006-12-07 18:42:17 +0300153 unsigned long delay = jiffies + msecs_to_jiffies(ACPI_EC_DELAY);
154 while (time_before(jiffies, delay)) {
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300155 if (acpi_ec_check_status(ec, event))
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400156 return 0;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400157 }
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300158 } else {
159 if (wait_event_timeout(ec->wait,
160 acpi_ec_check_status(ec, event),
161 msecs_to_jiffies(ACPI_EC_DELAY)) ||
162 acpi_ec_check_status(ec, event)) {
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400163 return 0;
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300164 } else {
165 printk(KERN_ERR PREFIX "acpi_ec_wait timeout,"
166 " status = %d, expect_event = %d\n",
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300167 acpi_ec_read_status(ec), event);
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400168 }
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300169 }
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400170
Patrick Mocheld550d982006-06-27 00:41:40 -0400171 return -ETIME;
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500172}
173
Len Brown02b28a32005-12-05 16:33:04 -0500174#ifdef ACPI_FUTURE_USAGE
Luming Yu06a2a382005-09-27 00:43:00 -0400175/*
176 * Note: samsung nv5000 doesn't work with ec burst mode.
177 * http://bugzilla.kernel.org/show_bug.cgi?id=4980
178 */
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400179int acpi_ec_enter_burst_mode(struct acpi_ec *ec)
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500180{
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400181 u8 tmp = 0;
182 u8 status = 0;
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500183
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500184 status = acpi_ec_read_status(ec);
Len Brown50526df2005-08-11 17:32:05 -0400185 if (status != -EINVAL && !(status & ACPI_EC_FLAG_BURST)) {
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400186 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
Len Brown50526df2005-08-11 17:32:05 -0400187 if (status)
Luming Yu716e0842005-08-10 01:40:00 -0400188 goto end;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400189 acpi_ec_write_cmd(ec, ACPI_EC_BURST_ENABLE);
190 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1);
191 tmp = acpi_ec_read_data(ec);
Len Brown50526df2005-08-11 17:32:05 -0400192 if (tmp != 0x90) { /* Burst ACK byte */
Patrick Mocheld550d982006-06-27 00:41:40 -0400193 return -EINVAL;
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500194 }
Luming Yu668d74c2005-07-23 00:26:33 -0400195 }
196
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400197 atomic_set(&ec->leaving_burst, 0);
Patrick Mocheld550d982006-06-27 00:41:40 -0400198 return 0;
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300199 end:
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400200 ACPI_EXCEPTION((AE_INFO, status, "EC wait, burst mode"));
Patrick Mocheld550d982006-06-27 00:41:40 -0400201 return -1;
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500202}
203
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400204int acpi_ec_leave_burst_mode(struct acpi_ec *ec)
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500205{
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400206 u8 status = 0;
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500207
Luming Yu06a2a382005-09-27 00:43:00 -0400208 status = acpi_ec_read_status(ec);
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300209 if (status != -EINVAL && (status & ACPI_EC_FLAG_BURST)) {
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400210 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300211 if (status)
Luming Yu06a2a382005-09-27 00:43:00 -0400212 goto end;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400213 acpi_ec_write_cmd(ec, ACPI_EC_BURST_DISABLE);
214 acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
Denis M. Sadykov7c6db5e2006-09-26 19:50:33 +0400215 }
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400216 atomic_set(&ec->leaving_burst, 1);
Patrick Mocheld550d982006-06-27 00:41:40 -0400217 return 0;
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300218 end:
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400219 ACPI_EXCEPTION((AE_INFO, status, "EC leave burst mode"));
Patrick Mocheld550d982006-06-27 00:41:40 -0400220 return -1;
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500221}
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300222#endif /* ACPI_FUTURE_USAGE */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400224static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command,
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300225 const u8 * wdata, unsigned wdata_len,
226 u8 * rdata, unsigned rdata_len)
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400227{
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300228 int result = 0;
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400229
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400230 acpi_ec_write_cmd(ec, command);
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400231
Alexey Starikovskiy78d0af32006-12-07 18:42:17 +0300232 for (; wdata_len > 0; --wdata_len) {
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400233 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300234 if (result) {
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300235 printk(KERN_ERR PREFIX
236 "write_cmd timeout, command = %d\n", command);
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300237 goto end;
238 }
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400239 acpi_ec_write_data(ec, *(wdata++));
Denis M. Sadykov3576cf62006-09-26 19:50:33 +0400240 }
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400241
Alexey Starikovskiyd91df1a2006-12-07 18:42:16 +0300242 if (!rdata_len) {
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400243 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300244 if (result) {
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300245 printk(KERN_ERR PREFIX
246 "finish-write timeout, command = %d\n", command);
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300247 goto end;
248 }
Alexey Starikovskiy5d0c2882006-12-07 18:42:16 +0300249 } else if (command == ACPI_EC_COMMAND_QUERY) {
250 atomic_set(&ec->query_pending, 0);
Denis M. Sadykov7c6db5e2006-09-26 19:50:33 +0400251 }
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400252
Alexey Starikovskiy78d0af32006-12-07 18:42:17 +0300253 for (; rdata_len > 0; --rdata_len) {
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400254 result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1);
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300255 if (result) {
256 printk(KERN_ERR PREFIX "read timeout, command = %d\n",
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300257 command);
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300258 goto end;
259 }
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400260
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400261 *(rdata++) = acpi_ec_read_data(ec);
Denis M. Sadykov7c6db5e2006-09-26 19:50:33 +0400262 }
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300263 end:
264 return result;
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400265}
266
Denis M. Sadykov3576cf62006-09-26 19:50:33 +0400267static int acpi_ec_transaction(struct acpi_ec *ec, u8 command,
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300268 const u8 * wdata, unsigned wdata_len,
269 u8 * rdata, unsigned rdata_len)
Luming Yu45bea152005-07-23 04:08:00 -0400270{
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400271 int status;
Len Brown50526df2005-08-11 17:32:05 -0400272 u32 glk;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400274 if (!ec || (wdata_len && !wdata) || (rdata_len && !rdata))
Patrick Mocheld550d982006-06-27 00:41:40 -0400275 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700276
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300277 if (rdata)
278 memset(rdata, 0, rdata_len);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279
Alexey Starikovskiy523953b2006-12-07 18:42:17 +0300280 mutex_lock(&ec->lock);
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400281 if (ec->global_lock) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
Alexey Starikovskiyc24e9122007-02-15 23:16:18 +0300283 if (ACPI_FAILURE(status)) {
284 mutex_unlock(&ec->lock);
Patrick Mocheld550d982006-06-27 00:41:40 -0400285 return -ENODEV;
Alexey Starikovskiyc24e9122007-02-15 23:16:18 +0300286 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700287 }
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500288
Alexey Starikovskiy5d57a6a2006-12-07 18:42:16 +0300289 /* Make sure GPE is enabled before doing transaction */
Alexey Starikovskiya86e2772006-12-07 18:42:16 +0300290 acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR);
Alexey Starikovskiy5d57a6a2006-12-07 18:42:16 +0300291
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400292 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
Luming Yu716e0842005-08-10 01:40:00 -0400293 if (status) {
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300294 printk(KERN_DEBUG PREFIX
295 "input buffer is not empty, aborting transaction\n");
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500296 goto end;
Luming Yu716e0842005-08-10 01:40:00 -0400297 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300299 status = acpi_ec_transaction_unlocked(ec, command,
300 wdata, wdata_len,
301 rdata, rdata_len);
Len Brown50526df2005-08-11 17:32:05 -0400302
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300303 end:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700304
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400305 if (ec->global_lock)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306 acpi_release_global_lock(glk);
Alexey Starikovskiy523953b2006-12-07 18:42:17 +0300307 mutex_unlock(&ec->lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308
Patrick Mocheld550d982006-06-27 00:41:40 -0400309 return status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700310}
311
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300312static int acpi_ec_read(struct acpi_ec *ec, u8 address, u8 * data)
Denis M. Sadykov3576cf62006-09-26 19:50:33 +0400313{
314 int result;
315 u8 d;
316
317 result = acpi_ec_transaction(ec, ACPI_EC_COMMAND_READ,
318 &address, 1, &d, 1);
319 *data = d;
320 return result;
321}
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400322
Denis M. Sadykov3576cf62006-09-26 19:50:33 +0400323static int acpi_ec_write(struct acpi_ec *ec, u8 address, u8 data)
324{
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300325 u8 wdata[2] = { address, data };
326 return acpi_ec_transaction(ec, ACPI_EC_COMMAND_WRITE,
Denis M. Sadykov3576cf62006-09-26 19:50:33 +0400327 wdata, 2, NULL, 0);
328}
329
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330/*
331 * Externally callable EC access functions. For now, assume 1 EC only
332 */
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300333int ec_read(u8 addr, u8 * val)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334{
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400335 struct acpi_ec *ec;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700336 int err;
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400337 u8 temp_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338
339 if (!first_ec)
340 return -ENODEV;
341
342 ec = acpi_driver_data(first_ec);
343
344 err = acpi_ec_read(ec, addr, &temp_data);
345
346 if (!err) {
347 *val = temp_data;
348 return 0;
Len Brown50526df2005-08-11 17:32:05 -0400349 } else
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350 return err;
351}
Len Brown50526df2005-08-11 17:32:05 -0400352
Linus Torvalds1da177e2005-04-16 15:20:36 -0700353EXPORT_SYMBOL(ec_read);
354
Len Brown50526df2005-08-11 17:32:05 -0400355int ec_write(u8 addr, u8 val)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700356{
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400357 struct acpi_ec *ec;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700358 int err;
359
360 if (!first_ec)
361 return -ENODEV;
362
363 ec = acpi_driver_data(first_ec);
364
365 err = acpi_ec_write(ec, addr, val);
366
367 return err;
368}
Len Brown50526df2005-08-11 17:32:05 -0400369
Linus Torvalds1da177e2005-04-16 15:20:36 -0700370EXPORT_SYMBOL(ec_write);
371
Randy Dunlap616362d2006-10-27 01:47:34 -0400372int ec_transaction(u8 command,
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300373 const u8 * wdata, unsigned wdata_len,
374 u8 * rdata, unsigned rdata_len)
Luming Yu45bea152005-07-23 04:08:00 -0400375{
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400376 struct acpi_ec *ec;
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400377
378 if (!first_ec)
379 return -ENODEV;
380
381 ec = acpi_driver_data(first_ec);
382
Denis M. Sadykov3576cf62006-09-26 19:50:33 +0400383 return acpi_ec_transaction(ec, command, wdata,
384 wdata_len, rdata, rdata_len);
Luming Yu45bea152005-07-23 04:08:00 -0400385}
Luming Yu45bea152005-07-23 04:08:00 -0400386
Lennart Poetteringab9e43c2006-10-03 22:49:00 -0400387EXPORT_SYMBOL(ec_transaction);
388
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300389static int acpi_ec_query(struct acpi_ec *ec, u8 * data)
Denis M. Sadykov3576cf62006-09-26 19:50:33 +0400390{
391 int result;
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300392 u8 d;
Luming Yu45bea152005-07-23 04:08:00 -0400393
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300394 if (!ec || !data)
395 return -EINVAL;
Luming Yu45bea152005-07-23 04:08:00 -0400396
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300397 /*
398 * Query the EC to find out which _Qxx method we need to evaluate.
399 * Note that successful completion of the query causes the ACPI_EC_SCI
400 * bit to be cleared (and thus clearing the interrupt source).
401 */
Luming Yu45bea152005-07-23 04:08:00 -0400402
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300403 result = acpi_ec_transaction(ec, ACPI_EC_COMMAND_QUERY, NULL, 0, &d, 1);
404 if (result)
405 return result;
Luming Yu45bea152005-07-23 04:08:00 -0400406
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300407 if (!d)
408 return -ENODATA;
Luming Yu45bea152005-07-23 04:08:00 -0400409
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300410 *data = d;
411 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412}
413
Linus Torvalds1da177e2005-04-16 15:20:36 -0700414/* --------------------------------------------------------------------------
415 Event Management
416 -------------------------------------------------------------------------- */
417
Len Brown50526df2005-08-11 17:32:05 -0400418static void acpi_ec_gpe_query(void *ec_cxt)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700419{
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400420 struct acpi_ec *ec = (struct acpi_ec *)ec_cxt;
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400421 u8 value = 0;
Alexey Starikovskiy5d0c2882006-12-07 18:42:16 +0300422 char object_name[8];
Luming Yu45bea152005-07-23 04:08:00 -0400423
Alexey Starikovskiy5d0c2882006-12-07 18:42:16 +0300424 if (!ec || acpi_ec_query(ec, &value))
Alexey Starikovskiye41334c2006-12-07 18:42:16 +0300425 return;
Luming Yu45bea152005-07-23 04:08:00 -0400426
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400427 snprintf(object_name, 8, "_Q%2.2X", value);
Luming Yu45bea152005-07-23 04:08:00 -0400428
Guillaume Chazarainc6e19192006-12-24 22:19:02 +0100429 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluating %s", object_name));
Luming Yu45bea152005-07-23 04:08:00 -0400430
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400431 acpi_evaluate_object(ec->handle, object_name, NULL, NULL);
Luming Yu45bea152005-07-23 04:08:00 -0400432}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700433
Len Brown50526df2005-08-11 17:32:05 -0400434static u32 acpi_ec_gpe_handler(void *data)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435{
Len Brown50526df2005-08-11 17:32:05 -0400436 acpi_status status = AE_OK;
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400437 u8 value;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400438 struct acpi_ec *ec = (struct acpi_ec *)data;
Luming Yu45bea152005-07-23 04:08:00 -0400439
Denis M. Sadykov8e0341b2006-09-26 19:50:33 +0400440 if (acpi_ec_mode == EC_INTR) {
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300441 wake_up(&ec->wait);
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500442 }
443
Alexey Starikovskiybec5a1e2006-12-07 18:42:16 +0300444 value = acpi_ec_read_status(ec);
Alexey Starikovskiy5d0c2882006-12-07 18:42:16 +0300445 if ((value & ACPI_EC_FLAG_SCI) && !atomic_read(&ec->query_pending)) {
446 atomic_set(&ec->query_pending, 1);
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300447 status =
448 acpi_os_execute(OSL_EC_BURST_HANDLER, acpi_ec_gpe_query,
449 ec);
Len Brown50526df2005-08-11 17:32:05 -0400450 }
Alexey Starikovskiye41334c2006-12-07 18:42:16 +0300451
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500452 return status == AE_OK ?
Len Brown50526df2005-08-11 17:32:05 -0400453 ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454}
455
456/* --------------------------------------------------------------------------
457 Address Space Management
458 -------------------------------------------------------------------------- */
459
460static acpi_status
Len Brown50526df2005-08-11 17:32:05 -0400461acpi_ec_space_setup(acpi_handle region_handle,
462 u32 function, void *handler_context, void **return_context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700463{
464 /*
465 * The EC object is in the handler context and is needed
466 * when calling the acpi_ec_space_handler.
467 */
Len Brown50526df2005-08-11 17:32:05 -0400468 *return_context = (function != ACPI_REGION_DEACTIVATE) ?
469 handler_context : NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470
471 return AE_OK;
472}
473
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474static acpi_status
Len Brown50526df2005-08-11 17:32:05 -0400475acpi_ec_space_handler(u32 function,
476 acpi_physical_address address,
477 u32 bit_width,
478 acpi_integer * value,
479 void *handler_context, void *region_context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700480{
Len Brown50526df2005-08-11 17:32:05 -0400481 int result = 0;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400482 struct acpi_ec *ec = NULL;
Len Brown50526df2005-08-11 17:32:05 -0400483 u64 temp = *value;
484 acpi_integer f_v = 0;
485 int i = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700486
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487 if ((address > 0xFF) || !value || !handler_context)
Patrick Mocheld550d982006-06-27 00:41:40 -0400488 return AE_BAD_PARAMETER;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700489
Luming Yufa9cd542005-03-19 01:54:47 -0500490 if (bit_width != 8 && acpi_strict) {
Patrick Mocheld550d982006-06-27 00:41:40 -0400491 return AE_BAD_PARAMETER;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700492 }
493
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400494 ec = (struct acpi_ec *)handler_context;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700495
Len Brown50526df2005-08-11 17:32:05 -0400496 next_byte:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700497 switch (function) {
498 case ACPI_READ:
Luming Yufa9cd542005-03-19 01:54:47 -0500499 temp = 0;
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300500 result = acpi_ec_read(ec, (u8) address, (u8 *) & temp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700501 break;
502 case ACPI_WRITE:
Luming Yufa9cd542005-03-19 01:54:47 -0500503 result = acpi_ec_write(ec, (u8) address, (u8) temp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700504 break;
505 default:
506 result = -EINVAL;
507 goto out;
508 break;
509 }
510
511 bit_width -= 8;
Luming Yufa9cd542005-03-19 01:54:47 -0500512 if (bit_width) {
513 if (function == ACPI_READ)
514 f_v |= temp << 8 * i;
515 if (function == ACPI_WRITE)
516 temp >>= 8;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700517 i++;
Andrew Morton83ea7442005-03-30 22:12:13 -0500518 address++;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700519 goto next_byte;
520 }
521
Luming Yufa9cd542005-03-19 01:54:47 -0500522 if (function == ACPI_READ) {
523 f_v |= temp << 8 * i;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700524 *value = f_v;
525 }
526
Len Brown50526df2005-08-11 17:32:05 -0400527 out:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700528 switch (result) {
529 case -EINVAL:
Patrick Mocheld550d982006-06-27 00:41:40 -0400530 return AE_BAD_PARAMETER;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700531 break;
532 case -ENODEV:
Patrick Mocheld550d982006-06-27 00:41:40 -0400533 return AE_NOT_FOUND;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700534 break;
535 case -ETIME:
Patrick Mocheld550d982006-06-27 00:41:40 -0400536 return AE_TIME;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700537 break;
538 default:
Patrick Mocheld550d982006-06-27 00:41:40 -0400539 return AE_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700540 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700541}
542
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543/* --------------------------------------------------------------------------
544 FS Interface (/proc)
545 -------------------------------------------------------------------------- */
546
Len Brown50526df2005-08-11 17:32:05 -0400547static struct proc_dir_entry *acpi_ec_dir;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700548
Len Brown50526df2005-08-11 17:32:05 -0400549static int acpi_ec_read_info(struct seq_file *seq, void *offset)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550{
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400551 struct acpi_ec *ec = (struct acpi_ec *)seq->private;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700552
Linus Torvalds1da177e2005-04-16 15:20:36 -0700553 if (!ec)
554 goto end;
555
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300556 seq_printf(seq, "gpe: 0x%02x\n", (u32) ec->gpe);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700557 seq_printf(seq, "ports: 0x%02x, 0x%02x\n",
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300558 (u32) ec->command_addr, (u32) ec->data_addr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700559 seq_printf(seq, "use global lock: %s\n",
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400560 ec->global_lock ? "yes" : "no");
Alexey Starikovskiya86e2772006-12-07 18:42:16 +0300561 acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700562
Len Brown50526df2005-08-11 17:32:05 -0400563 end:
Patrick Mocheld550d982006-06-27 00:41:40 -0400564 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700565}
566
567static int acpi_ec_info_open_fs(struct inode *inode, struct file *file)
568{
569 return single_open(file, acpi_ec_read_info, PDE(inode)->data);
570}
571
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400572static struct file_operations acpi_ec_info_ops = {
Len Brown50526df2005-08-11 17:32:05 -0400573 .open = acpi_ec_info_open_fs,
574 .read = seq_read,
575 .llseek = seq_lseek,
576 .release = single_release,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700577 .owner = THIS_MODULE,
578};
579
Len Brown50526df2005-08-11 17:32:05 -0400580static int acpi_ec_add_fs(struct acpi_device *device)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700581{
Len Brown50526df2005-08-11 17:32:05 -0400582 struct proc_dir_entry *entry = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700583
Linus Torvalds1da177e2005-04-16 15:20:36 -0700584 if (!acpi_device_dir(device)) {
585 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
Len Brown50526df2005-08-11 17:32:05 -0400586 acpi_ec_dir);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700587 if (!acpi_device_dir(device))
Patrick Mocheld550d982006-06-27 00:41:40 -0400588 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700589 }
590
591 entry = create_proc_entry(ACPI_EC_FILE_INFO, S_IRUGO,
Len Brown50526df2005-08-11 17:32:05 -0400592 acpi_device_dir(device));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700593 if (!entry)
Patrick Mocheld550d982006-06-27 00:41:40 -0400594 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700595 else {
596 entry->proc_fops = &acpi_ec_info_ops;
597 entry->data = acpi_driver_data(device);
598 entry->owner = THIS_MODULE;
599 }
600
Patrick Mocheld550d982006-06-27 00:41:40 -0400601 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700602}
603
Len Brown50526df2005-08-11 17:32:05 -0400604static int acpi_ec_remove_fs(struct acpi_device *device)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700605{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700606
607 if (acpi_device_dir(device)) {
608 remove_proc_entry(ACPI_EC_FILE_INFO, acpi_device_dir(device));
609 remove_proc_entry(acpi_device_bid(device), acpi_ec_dir);
610 acpi_device_dir(device) = NULL;
611 }
612
Patrick Mocheld550d982006-06-27 00:41:40 -0400613 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700614}
615
Linus Torvalds1da177e2005-04-16 15:20:36 -0700616/* --------------------------------------------------------------------------
617 Driver Interface
618 -------------------------------------------------------------------------- */
619
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400620static int acpi_ec_add(struct acpi_device *device)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700621{
Len Brown50526df2005-08-11 17:32:05 -0400622 int result = 0;
623 acpi_status status = AE_OK;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400624 struct acpi_ec *ec = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700625
Linus Torvalds1da177e2005-04-16 15:20:36 -0700626 if (!device)
Patrick Mocheld550d982006-06-27 00:41:40 -0400627 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700628
Burman Yan36bcbec2006-12-19 12:56:11 -0800629 ec = kzalloc(sizeof(struct acpi_ec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700630 if (!ec)
Patrick Mocheld550d982006-06-27 00:41:40 -0400631 return -ENOMEM;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700632
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400633 ec->handle = device->handle;
634 ec->uid = -1;
Alexey Starikovskiyc787a852006-12-07 18:42:16 +0300635 mutex_init(&ec->lock);
Alexey Starikovskiy5d0c2882006-12-07 18:42:16 +0300636 atomic_set(&ec->query_pending, 0);
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400637 if (acpi_ec_mode == EC_INTR) {
638 atomic_set(&ec->leaving_burst, 1);
639 init_waitqueue_head(&ec->wait);
640 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700641 strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME);
642 strcpy(acpi_device_class(device), ACPI_EC_CLASS);
643 acpi_driver_data(device) = ec;
644
645 /* Use the global lock for all EC transactions? */
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300646 acpi_evaluate_integer(ec->handle, "_GLK", NULL, &ec->global_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700647
Jiri Slabyff2fc3e2006-03-28 17:04:00 -0500648 /* XXX we don't test uids, because on some boxes ecdt uid = 0, see:
649 http://bugzilla.kernel.org/show_bug.cgi?id=6111 */
650 if (ec_ecdt) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700651 acpi_remove_address_space_handler(ACPI_ROOT_OBJECT,
Len Brown50526df2005-08-11 17:32:05 -0400652 ACPI_ADR_SPACE_EC,
653 &acpi_ec_space_handler);
654
Alexey Starikovskiya86e2772006-12-07 18:42:16 +0300655 acpi_remove_gpe_handler(NULL, ec_ecdt->gpe,
Len Brown50526df2005-08-11 17:32:05 -0400656 &acpi_ec_gpe_handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700657
658 kfree(ec_ecdt);
659 }
660
661 /* Get GPE bit assignment (EC events). */
662 /* TODO: Add support for _GPE returning a package */
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300663 status = acpi_evaluate_integer(ec->handle, "_GPE", NULL, &ec->gpe);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700664 if (ACPI_FAILURE(status)) {
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300665 ACPI_EXCEPTION((AE_INFO, status,
666 "Obtaining GPE bit assignment"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700667 result = -ENODEV;
668 goto end;
669 }
670
671 result = acpi_ec_add_fs(device);
672 if (result)
673 goto end;
674
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400675 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s [%s] (gpe %d) interrupt mode.",
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300676 acpi_device_name(device), acpi_device_bid(device),
677 (u32) ec->gpe));
Luming Yu45bea152005-07-23 04:08:00 -0400678
679 if (!first_ec)
680 first_ec = device;
681
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300682 end:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700683 if (result)
684 kfree(ec);
685
Patrick Mocheld550d982006-06-27 00:41:40 -0400686 return result;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700687}
688
Len Brown50526df2005-08-11 17:32:05 -0400689static int acpi_ec_remove(struct acpi_device *device, int type)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700690{
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400691 struct acpi_ec *ec = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700692
Linus Torvalds1da177e2005-04-16 15:20:36 -0700693 if (!device)
Patrick Mocheld550d982006-06-27 00:41:40 -0400694 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700695
696 ec = acpi_driver_data(device);
697
698 acpi_ec_remove_fs(device);
699
700 kfree(ec);
701
Patrick Mocheld550d982006-06-27 00:41:40 -0400702 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700703}
704
Linus Torvalds1da177e2005-04-16 15:20:36 -0700705static acpi_status
Len Brown50526df2005-08-11 17:32:05 -0400706acpi_ec_io_ports(struct acpi_resource *resource, void *context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700707{
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400708 struct acpi_ec *ec = (struct acpi_ec *)context;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700709
Bob Moore50eca3e2005-09-30 19:03:00 -0400710 if (resource->type != ACPI_RESOURCE_TYPE_IO) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700711 return AE_OK;
712 }
713
714 /*
715 * The first address region returned is the data port, and
716 * the second address region returned is the status/command
717 * port.
718 */
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400719 if (ec->data_addr == 0) {
720 ec->data_addr = resource->data.io.minimum;
721 } else if (ec->command_addr == 0) {
722 ec->command_addr = resource->data.io.minimum;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700723 } else {
724 return AE_CTRL_TERMINATE;
725 }
726
Linus Torvalds1da177e2005-04-16 15:20:36 -0700727 return AE_OK;
728}
729
Len Brown50526df2005-08-11 17:32:05 -0400730static int acpi_ec_start(struct acpi_device *device)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700731{
Len Brown50526df2005-08-11 17:32:05 -0400732 acpi_status status = AE_OK;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400733 struct acpi_ec *ec = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700734
Linus Torvalds1da177e2005-04-16 15:20:36 -0700735 if (!device)
Patrick Mocheld550d982006-06-27 00:41:40 -0400736 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700737
738 ec = acpi_driver_data(device);
739
740 if (!ec)
Patrick Mocheld550d982006-06-27 00:41:40 -0400741 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700742
743 /*
744 * Get I/O port addresses. Convert to GAS format.
745 */
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400746 status = acpi_walk_resources(ec->handle, METHOD_NAME__CRS,
Len Brown50526df2005-08-11 17:32:05 -0400747 acpi_ec_io_ports, ec);
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400748 if (ACPI_FAILURE(status) || ec->command_addr == 0) {
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400749 ACPI_EXCEPTION((AE_INFO, status,
750 "Error getting I/O port addresses"));
Patrick Mocheld550d982006-06-27 00:41:40 -0400751 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700752 }
753
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400754 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "gpe=0x%02lx, ports=0x%2lx,0x%2lx",
Alexey Starikovskiya86e2772006-12-07 18:42:16 +0300755 ec->gpe, ec->command_addr, ec->data_addr));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700756
757 /*
758 * Install GPE handler
759 */
Alexey Starikovskiya86e2772006-12-07 18:42:16 +0300760 status = acpi_install_gpe_handler(NULL, ec->gpe,
Len Brown50526df2005-08-11 17:32:05 -0400761 ACPI_GPE_EDGE_TRIGGERED,
762 &acpi_ec_gpe_handler, ec);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700763 if (ACPI_FAILURE(status)) {
Patrick Mocheld550d982006-06-27 00:41:40 -0400764 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700765 }
Alexey Starikovskiya86e2772006-12-07 18:42:16 +0300766 acpi_set_gpe_type(NULL, ec->gpe, ACPI_GPE_TYPE_RUNTIME);
767 acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700768
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400769 status = acpi_install_address_space_handler(ec->handle,
Len Brown50526df2005-08-11 17:32:05 -0400770 ACPI_ADR_SPACE_EC,
771 &acpi_ec_space_handler,
772 &acpi_ec_space_setup, ec);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700773 if (ACPI_FAILURE(status)) {
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300774 acpi_remove_gpe_handler(NULL, ec->gpe, &acpi_ec_gpe_handler);
Patrick Mocheld550d982006-06-27 00:41:40 -0400775 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700776 }
777
Patrick Mocheld550d982006-06-27 00:41:40 -0400778 return AE_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700779}
780
Len Brown50526df2005-08-11 17:32:05 -0400781static int acpi_ec_stop(struct acpi_device *device, int type)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700782{
Len Brown50526df2005-08-11 17:32:05 -0400783 acpi_status status = AE_OK;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400784 struct acpi_ec *ec = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700785
Linus Torvalds1da177e2005-04-16 15:20:36 -0700786 if (!device)
Patrick Mocheld550d982006-06-27 00:41:40 -0400787 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700788
789 ec = acpi_driver_data(device);
790
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400791 status = acpi_remove_address_space_handler(ec->handle,
Len Brown50526df2005-08-11 17:32:05 -0400792 ACPI_ADR_SPACE_EC,
793 &acpi_ec_space_handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700794 if (ACPI_FAILURE(status))
Patrick Mocheld550d982006-06-27 00:41:40 -0400795 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700796
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300797 status = acpi_remove_gpe_handler(NULL, ec->gpe, &acpi_ec_gpe_handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700798 if (ACPI_FAILURE(status))
Patrick Mocheld550d982006-06-27 00:41:40 -0400799 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700800
Patrick Mocheld550d982006-06-27 00:41:40 -0400801 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700802}
803
804static acpi_status __init
Len Brown50526df2005-08-11 17:32:05 -0400805acpi_fake_ecdt_callback(acpi_handle handle,
806 u32 Level, void *context, void **retval)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700807{
Len Brown50526df2005-08-11 17:32:05 -0400808 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700809
Alexey Starikovskiyc787a852006-12-07 18:42:16 +0300810 mutex_init(&ec_ecdt->lock);
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400811 if (acpi_ec_mode == EC_INTR) {
812 init_waitqueue_head(&ec_ecdt->wait);
813 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700814 status = acpi_walk_resources(handle, METHOD_NAME__CRS,
Len Brown50526df2005-08-11 17:32:05 -0400815 acpi_ec_io_ports, ec_ecdt);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700816 if (ACPI_FAILURE(status))
817 return status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700818
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400819 ec_ecdt->uid = -1;
820 acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->uid);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700821
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300822 status = acpi_evaluate_integer(handle, "_GPE", NULL, &ec_ecdt->gpe);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700823 if (ACPI_FAILURE(status))
824 return status;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400825 ec_ecdt->global_lock = TRUE;
826 ec_ecdt->handle = handle;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700827
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400828 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "GPE=0x%02lx, ports=0x%2lx, 0x%2lx",
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300829 ec_ecdt->gpe, ec_ecdt->command_addr,
830 ec_ecdt->data_addr));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700831
832 return AE_CTRL_TERMINATE;
833}
834
835/*
836 * Some BIOS (such as some from Gateway laptops) access EC region very early
837 * such as in BAT0._INI or EC._INI before an EC device is found and
838 * do not provide an ECDT. According to ACPI spec, ECDT isn't mandatorily
839 * required, but if EC regison is accessed early, it is required.
840 * The routine tries to workaround the BIOS bug by pre-scan EC device
841 * It assumes that _CRS, _HID, _GPE, _UID methods of EC don't touch any
842 * op region (since _REG isn't invoked yet). The assumption is true for
843 * all systems found.
844 */
Len Brown50526df2005-08-11 17:32:05 -0400845static int __init acpi_ec_fake_ecdt(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700846{
Len Brown50526df2005-08-11 17:32:05 -0400847 acpi_status status;
848 int ret = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700849
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400850 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Try to make an fake ECDT"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700851
Burman Yan36bcbec2006-12-19 12:56:11 -0800852 ec_ecdt = kzalloc(sizeof(struct acpi_ec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700853 if (!ec_ecdt) {
854 ret = -ENOMEM;
855 goto error;
856 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700857
Len Brown50526df2005-08-11 17:32:05 -0400858 status = acpi_get_devices(ACPI_EC_HID,
859 acpi_fake_ecdt_callback, NULL, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700860 if (ACPI_FAILURE(status)) {
861 kfree(ec_ecdt);
862 ec_ecdt = NULL;
863 ret = -ENODEV;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400864 ACPI_EXCEPTION((AE_INFO, status, "Can't make an fake ECDT"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700865 goto error;
866 }
867 return 0;
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300868 error:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700869 return ret;
870}
871
Len Brown50526df2005-08-11 17:32:05 -0400872static int __init acpi_ec_get_real_ecdt(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700873{
Len Brown50526df2005-08-11 17:32:05 -0400874 acpi_status status;
875 struct acpi_table_ecdt *ecdt_ptr;
Luming Yu45bea152005-07-23 04:08:00 -0400876
Alexey Starikovskiy15a58ed2007-02-02 19:48:22 +0300877 status = acpi_get_table(ACPI_SIG_ECDT, 1,
878 (struct acpi_table_header **)&ecdt_ptr);
Luming Yu45bea152005-07-23 04:08:00 -0400879 if (ACPI_FAILURE(status))
880 return -ENODEV;
881
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400882 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found ECDT"));
Luming Yu45bea152005-07-23 04:08:00 -0400883
884 /*
885 * Generate a temporary ec context to use until the namespace is scanned
886 */
Burman Yan36bcbec2006-12-19 12:56:11 -0800887 ec_ecdt = kzalloc(sizeof(struct acpi_ec), GFP_KERNEL);
Luming Yu45bea152005-07-23 04:08:00 -0400888 if (!ec_ecdt)
889 return -ENOMEM;
Luming Yu45bea152005-07-23 04:08:00 -0400890
Alexey Starikovskiyc787a852006-12-07 18:42:16 +0300891 mutex_init(&ec_ecdt->lock);
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400892 if (acpi_ec_mode == EC_INTR) {
893 init_waitqueue_head(&ec_ecdt->wait);
894 }
Alexey Starikovskiyad363f82007-02-02 19:48:22 +0300895 ec_ecdt->command_addr = ecdt_ptr->control.address;
896 ec_ecdt->data_addr = ecdt_ptr->data.address;
897 ec_ecdt->gpe = ecdt_ptr->gpe;
Luming Yu45bea152005-07-23 04:08:00 -0400898 /* use the GL just to be safe */
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400899 ec_ecdt->global_lock = TRUE;
900 ec_ecdt->uid = ecdt_ptr->uid;
Luming Yu45bea152005-07-23 04:08:00 -0400901
Alexey Starikovskiyad363f82007-02-02 19:48:22 +0300902 status = acpi_get_handle(NULL, ecdt_ptr->id, &ec_ecdt->handle);
Luming Yu45bea152005-07-23 04:08:00 -0400903 if (ACPI_FAILURE(status)) {
904 goto error;
905 }
906
907 return 0;
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300908 error:
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400909 ACPI_EXCEPTION((AE_INFO, status, "Could not use ECDT"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700910 kfree(ec_ecdt);
911 ec_ecdt = NULL;
912
913 return -ENODEV;
914}
915
916static int __initdata acpi_fake_ecdt_enabled;
Len Brown50526df2005-08-11 17:32:05 -0400917int __init acpi_ec_ecdt_probe(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700918{
Len Brown50526df2005-08-11 17:32:05 -0400919 acpi_status status;
920 int ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700921
922 ret = acpi_ec_get_real_ecdt();
923 /* Try to make a fake ECDT */
924 if (ret && acpi_fake_ecdt_enabled) {
925 ret = acpi_ec_fake_ecdt();
926 }
927
928 if (ret)
929 return 0;
930
931 /*
932 * Install GPE handler
933 */
Alexey Starikovskiya86e2772006-12-07 18:42:16 +0300934 status = acpi_install_gpe_handler(NULL, ec_ecdt->gpe,
Len Brown50526df2005-08-11 17:32:05 -0400935 ACPI_GPE_EDGE_TRIGGERED,
936 &acpi_ec_gpe_handler, ec_ecdt);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700937 if (ACPI_FAILURE(status)) {
938 goto error;
939 }
Alexey Starikovskiya86e2772006-12-07 18:42:16 +0300940 acpi_set_gpe_type(NULL, ec_ecdt->gpe, ACPI_GPE_TYPE_RUNTIME);
941 acpi_enable_gpe(NULL, ec_ecdt->gpe, ACPI_NOT_ISR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700942
Len Brown50526df2005-08-11 17:32:05 -0400943 status = acpi_install_address_space_handler(ACPI_ROOT_OBJECT,
944 ACPI_ADR_SPACE_EC,
945 &acpi_ec_space_handler,
946 &acpi_ec_space_setup,
947 ec_ecdt);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700948 if (ACPI_FAILURE(status)) {
Alexey Starikovskiya86e2772006-12-07 18:42:16 +0300949 acpi_remove_gpe_handler(NULL, ec_ecdt->gpe,
Len Brown50526df2005-08-11 17:32:05 -0400950 &acpi_ec_gpe_handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700951 goto error;
952 }
953
954 return 0;
955
Len Brown50526df2005-08-11 17:32:05 -0400956 error:
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400957 ACPI_EXCEPTION((AE_INFO, status, "Could not use ECDT"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700958 kfree(ec_ecdt);
959 ec_ecdt = NULL;
960
961 return -ENODEV;
962}
963
Len Brown50526df2005-08-11 17:32:05 -0400964static int __init acpi_ec_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700965{
Len Brown50526df2005-08-11 17:32:05 -0400966 int result = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700967
Linus Torvalds1da177e2005-04-16 15:20:36 -0700968 if (acpi_disabled)
Patrick Mocheld550d982006-06-27 00:41:40 -0400969 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700970
971 acpi_ec_dir = proc_mkdir(ACPI_EC_CLASS, acpi_root_dir);
972 if (!acpi_ec_dir)
Patrick Mocheld550d982006-06-27 00:41:40 -0400973 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700974
975 /* Now register the driver for the EC */
976 result = acpi_bus_register_driver(&acpi_ec_driver);
977 if (result < 0) {
978 remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir);
Patrick Mocheld550d982006-06-27 00:41:40 -0400979 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700980 }
981
Patrick Mocheld550d982006-06-27 00:41:40 -0400982 return result;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700983}
984
985subsys_initcall(acpi_ec_init);
986
987/* EC driver currently not unloadable */
988#if 0
Len Brown50526df2005-08-11 17:32:05 -0400989static void __exit acpi_ec_exit(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700990{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700991
992 acpi_bus_unregister_driver(&acpi_ec_driver);
993
994 remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir);
995
Patrick Mocheld550d982006-06-27 00:41:40 -0400996 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700997}
Len Brown50526df2005-08-11 17:32:05 -0400998#endif /* 0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700999
1000static int __init acpi_fake_ecdt_setup(char *str)
1001{
1002 acpi_fake_ecdt_enabled = 1;
OGAWA Hirofumi9b410462006-03-31 02:30:33 -08001003 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001004}
Luming Yu7b15f5e2005-08-03 17:38:04 -04001005
Linus Torvalds1da177e2005-04-16 15:20:36 -07001006__setup("acpi_fake_ecdt", acpi_fake_ecdt_setup);
Len Brown02b28a32005-12-05 16:33:04 -05001007static int __init acpi_ec_set_intr_mode(char *str)
Luming Yu45bea152005-07-23 04:08:00 -04001008{
Len Brown02b28a32005-12-05 16:33:04 -05001009 int intr;
Luming Yu7b15f5e2005-08-03 17:38:04 -04001010
Len Brown02b28a32005-12-05 16:33:04 -05001011 if (!get_option(&str, &intr))
Luming Yu7b15f5e2005-08-03 17:38:04 -04001012 return 0;
1013
Len Brown02b28a32005-12-05 16:33:04 -05001014 if (intr) {
Denis M. Sadykov703959d2006-09-26 19:50:33 +04001015 acpi_ec_mode = EC_INTR;
Luming Yu7b15f5e2005-08-03 17:38:04 -04001016 } else {
Denis M. Sadykov703959d2006-09-26 19:50:33 +04001017 acpi_ec_mode = EC_POLL;
Luming Yu7b15f5e2005-08-03 17:38:04 -04001018 }
Denis M. Sadykov703959d2006-09-26 19:50:33 +04001019 acpi_ec_driver.ops.add = acpi_ec_add;
Len Brown723fe2c2007-01-06 00:02:07 -05001020 printk(KERN_NOTICE PREFIX "%s mode.\n",
1021 intr ? "interrupt" : "polling");
Denis M. Sadykov703959d2006-09-26 19:50:33 +04001022
OGAWA Hirofumi9b410462006-03-31 02:30:33 -08001023 return 1;
Luming Yu45bea152005-07-23 04:08:00 -04001024}
Len Brown50526df2005-08-11 17:32:05 -04001025
Len Brown53f11d42005-12-05 16:46:36 -05001026__setup("ec_intr=", acpi_ec_set_intr_mode);