blob: 3d93621408315dbf76a3b734b46239471d3647ac [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Alexey Starikovskiy01f22462007-03-07 22:28:00 +03002 * ec.c - ACPI Embedded Controller Driver (v2.0)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 *
Alexey Starikovskiy01f22462007-03-07 22:28:00 +03004 * Copyright (C) 2006, 2007 Alexey Starikovskiy <alexey.y.starikovskiy@intel.com>
5 * Copyright (C) 2006 Denis Sadykov <denis.m.sadykov@intel.com>
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 * Copyright (C) 2004 Luming Yu <luming.yu@intel.com>
7 * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
8 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
9 *
10 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or (at
15 * your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License along
23 * with this program; if not, write to the Free Software Foundation, Inc.,
24 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
25 *
26 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
27 */
28
Márton Némethd772b3b2008-01-23 22:34:09 -050029/* Uncomment next line to get verbose print outs*/
30/* #define DEBUG */
31
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#include <linux/kernel.h>
33#include <linux/module.h>
34#include <linux/init.h>
35#include <linux/types.h>
36#include <linux/delay.h>
37#include <linux/proc_fs.h>
38#include <linux/seq_file.h>
Dmitry Torokhov451566f2005-03-19 01:10:05 -050039#include <linux/interrupt.h>
Alexey Starikovskiy837012e2007-05-29 16:43:02 +040040#include <linux/list.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070041#include <asm/io.h>
42#include <acpi/acpi_bus.h>
43#include <acpi/acpi_drivers.h>
44#include <acpi/actypes.h>
45
Linus Torvalds1da177e2005-04-16 15:20:36 -070046#define ACPI_EC_CLASS "embedded_controller"
Linus Torvalds1da177e2005-04-16 15:20:36 -070047#define ACPI_EC_DEVICE_NAME "Embedded Controller"
48#define ACPI_EC_FILE_INFO "info"
Alexey Starikovskiy837012e2007-05-29 16:43:02 +040049
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +030050#undef PREFIX
51#define PREFIX "ACPI: EC: "
Alexey Starikovskiy43509332007-05-29 16:42:57 +040052
Denis M. Sadykov703959d2006-09-26 19:50:33 +040053/* EC status register */
Linus Torvalds1da177e2005-04-16 15:20:36 -070054#define ACPI_EC_FLAG_OBF 0x01 /* Output buffer full */
55#define ACPI_EC_FLAG_IBF 0x02 /* Input buffer full */
Dmitry Torokhov451566f2005-03-19 01:10:05 -050056#define ACPI_EC_FLAG_BURST 0x10 /* burst mode */
Linus Torvalds1da177e2005-04-16 15:20:36 -070057#define ACPI_EC_FLAG_SCI 0x20 /* EC-SCI occurred */
Alexey Starikovskiy43509332007-05-29 16:42:57 +040058
Denis M. Sadykov703959d2006-09-26 19:50:33 +040059/* EC commands */
Alexey Starikovskiy3261ff42006-12-07 18:42:17 +030060enum ec_command {
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +030061 ACPI_EC_COMMAND_READ = 0x80,
62 ACPI_EC_COMMAND_WRITE = 0x81,
63 ACPI_EC_BURST_ENABLE = 0x82,
64 ACPI_EC_BURST_DISABLE = 0x83,
65 ACPI_EC_COMMAND_QUERY = 0x84,
Alexey Starikovskiy3261ff42006-12-07 18:42:17 +030066};
Alexey Starikovskiy837012e2007-05-29 16:43:02 +040067
Denis M. Sadykov703959d2006-09-26 19:50:33 +040068/* EC events */
Alexey Starikovskiy3261ff42006-12-07 18:42:17 +030069enum ec_event {
Denis M. Sadykov703959d2006-09-26 19:50:33 +040070 ACPI_EC_EVENT_OBF_1 = 1, /* Output buffer full */
Alexey Starikovskiy080e4122007-10-22 14:18:30 +040071 ACPI_EC_EVENT_IBF_0, /* Input buffer empty */
Denis M. Sadykov703959d2006-09-26 19:50:33 +040072};
73
Alexey Starikovskiy5c406412006-12-07 18:42:16 +030074#define ACPI_EC_DELAY 500 /* Wait 500ms max. during EC ops */
Denis M. Sadykov703959d2006-09-26 19:50:33 +040075#define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */
Alexey Starikovskiye6e82a32008-03-21 17:06:57 +030076#define ACPI_EC_UDELAY 100 /* Wait 100us before polling EC again */
Denis M. Sadykov703959d2006-09-26 19:50:33 +040077
Alexey Starikovskiy080e4122007-10-22 14:18:30 +040078enum {
79 EC_FLAGS_WAIT_GPE = 0, /* Don't check status until GPE arrives */
80 EC_FLAGS_QUERY_PENDING, /* Query is pending */
Alexey Starikovskiy78439322007-10-22 14:18:43 +040081 EC_FLAGS_GPE_MODE, /* Expect GPE to be sent for status change */
Alexey Starikovskiyb77d81b2008-03-21 17:07:15 +030082 EC_FLAGS_NO_GPE, /* Don't use GPE mode */
Alexey Starikovskiy845625c2008-03-21 17:07:03 +030083 EC_FLAGS_RESCHEDULE_POLL /* Re-schedule poll */
Alexey Starikovskiy080e4122007-10-22 14:18:30 +040084};
85
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +040086/* If we find an EC via the ECDT, we need to keep a ptr to its context */
Alexey Starikovskiyd0338792007-03-07 22:28:00 +030087/* External interfaces use first EC only, so remember */
Alexey Starikovskiy837012e2007-05-29 16:43:02 +040088typedef int (*acpi_ec_query_func) (void *data);
89
90struct acpi_ec_query_handler {
91 struct list_head node;
92 acpi_ec_query_func func;
93 acpi_handle handle;
94 void *data;
95 u8 query_bit;
96};
97
Adrian Bunka854e082006-12-19 12:56:12 -080098static struct acpi_ec {
Denis M. Sadykov703959d2006-09-26 19:50:33 +040099 acpi_handle handle;
Alexey Starikovskiya86e2772006-12-07 18:42:16 +0300100 unsigned long gpe;
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400101 unsigned long command_addr;
102 unsigned long data_addr;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400103 unsigned long global_lock;
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400104 unsigned long flags;
Alexey Starikovskiyc787a852006-12-07 18:42:16 +0300105 struct mutex lock;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400106 wait_queue_head_t wait;
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400107 struct list_head list;
Alexey Starikovskiy845625c2008-03-21 17:07:03 +0300108 struct delayed_work work;
Alexey Starikovskiyfa95ba02008-03-21 19:36:02 +0300109 atomic_t irq_count;
Alexey Starikovskiy4c611062007-09-05 19:56:38 -0400110 u8 handlers_installed;
Alexey Starikovskiyd0338792007-03-07 22:28:00 +0300111} *boot_ec, *first_ec;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400112
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113/* --------------------------------------------------------------------------
114 Transaction Management
115 -------------------------------------------------------------------------- */
116
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400117static inline u8 acpi_ec_read_status(struct acpi_ec *ec)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118{
Márton Németh3ebe08a2007-11-21 03:23:26 +0300119 u8 x = inb(ec->command_addr);
Márton Németh86dae012008-01-23 22:33:06 -0500120 pr_debug(PREFIX "---> status = 0x%2.2x\n", x);
Márton Németh3ebe08a2007-11-21 03:23:26 +0300121 return x;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122}
123
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400124static inline u8 acpi_ec_read_data(struct acpi_ec *ec)
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400125{
Márton Németh3ebe08a2007-11-21 03:23:26 +0300126 u8 x = inb(ec->data_addr);
Márton Németh86dae012008-01-23 22:33:06 -0500127 pr_debug(PREFIX "---> data = 0x%2.2x\n", x);
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400128 return inb(ec->data_addr);
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400129}
130
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400131static inline void acpi_ec_write_cmd(struct acpi_ec *ec, u8 command)
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400132{
Márton Németh86dae012008-01-23 22:33:06 -0500133 pr_debug(PREFIX "<--- command = 0x%2.2x\n", command);
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400134 outb(command, ec->command_addr);
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400135}
136
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400137static inline void acpi_ec_write_data(struct acpi_ec *ec, u8 data)
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400138{
Márton Németh86dae012008-01-23 22:33:06 -0500139 pr_debug(PREFIX "<--- data = 0x%2.2x\n", data);
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400140 outb(data, ec->data_addr);
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400141}
142
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400143static inline int acpi_ec_check_status(struct acpi_ec *ec, enum ec_event event)
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400144{
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400145 if (test_bit(EC_FLAGS_WAIT_GPE, &ec->flags))
Alexey Starikovskiy9e197212007-03-07 18:29:35 -0500146 return 0;
Alexey Starikovskiy78d0af32006-12-07 18:42:17 +0300147 if (event == ACPI_EC_EVENT_OBF_1) {
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400148 if (acpi_ec_read_status(ec) & ACPI_EC_FLAG_OBF)
Denis M. Sadykov7c6db5e2006-09-26 19:50:33 +0400149 return 1;
Alexey Starikovskiy78d0af32006-12-07 18:42:17 +0300150 } else if (event == ACPI_EC_EVENT_IBF_0) {
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400151 if (!(acpi_ec_read_status(ec) & ACPI_EC_FLAG_IBF))
Denis M. Sadykov7c6db5e2006-09-26 19:50:33 +0400152 return 1;
Denis M. Sadykov7c6db5e2006-09-26 19:50:33 +0400153 }
154
155 return 0;
156}
157
Alexey Starikovskiy845625c2008-03-21 17:07:03 +0300158static void ec_schedule_ec_poll(struct acpi_ec *ec)
159{
160 if (test_bit(EC_FLAGS_RESCHEDULE_POLL, &ec->flags))
161 schedule_delayed_work(&ec->work,
162 msecs_to_jiffies(ACPI_EC_DELAY));
163}
164
165static void ec_switch_to_poll_mode(struct acpi_ec *ec)
166{
Alexey Starikovskiyb77d81b2008-03-21 17:07:15 +0300167 set_bit(EC_FLAGS_NO_GPE, &ec->flags);
Alexey Starikovskiy845625c2008-03-21 17:07:03 +0300168 clear_bit(EC_FLAGS_GPE_MODE, &ec->flags);
169 acpi_disable_gpe(NULL, ec->gpe, ACPI_NOT_ISR);
170 set_bit(EC_FLAGS_RESCHEDULE_POLL, &ec->flags);
171}
172
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400173static int acpi_ec_wait(struct acpi_ec *ec, enum ec_event event, int force_poll)
Luming Yu45bea152005-07-23 04:08:00 -0400174{
Alexey Starikovskiyfa95ba02008-03-21 19:36:02 +0300175 atomic_set(&ec->irq_count, 0);
Alexey Starikovskiy78439322007-10-22 14:18:43 +0400176 if (likely(test_bit(EC_FLAGS_GPE_MODE, &ec->flags)) &&
177 likely(!force_poll)) {
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400178 if (wait_event_timeout(ec->wait, acpi_ec_check_status(ec, event),
179 msecs_to_jiffies(ACPI_EC_DELAY)))
Alexey Starikovskiyb77d81b2008-03-21 17:07:15 +0300180 return 0;
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400181 clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
182 if (acpi_ec_check_status(ec, event)) {
Alexey Starikovskiyb77d81b2008-03-21 17:07:15 +0300183 /* missing GPEs, switch back to poll mode */
184 if (printk_ratelimit())
185 pr_info(PREFIX "missing confirmations, "
Márton Németh3ebe08a2007-11-21 03:23:26 +0300186 "switch off interrupt mode.\n");
Alexey Starikovskiyb77d81b2008-03-21 17:07:15 +0300187 ec_switch_to_poll_mode(ec);
188 ec_schedule_ec_poll(ec);
189 return 0;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400190 }
Alexey Starikovskiy78439322007-10-22 14:18:43 +0400191 } else {
192 unsigned long delay = jiffies + msecs_to_jiffies(ACPI_EC_DELAY);
193 clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
194 while (time_before(jiffies, delay)) {
195 if (acpi_ec_check_status(ec, event))
Alexey Starikovskiyb77d81b2008-03-21 17:07:15 +0300196 return 0;
Alexey Starikovskiye6e82a32008-03-21 17:06:57 +0300197 udelay(ACPI_EC_UDELAY);
Alexey Starikovskiy78439322007-10-22 14:18:43 +0400198 }
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300199 }
Alexey Starikovskiydc0e8492008-03-21 17:07:09 +0300200 pr_err(PREFIX "acpi_ec_wait timeout, status = 0x%2.2x, event = %s\n",
201 acpi_ec_read_status(ec),
202 (event == ACPI_EC_EVENT_OBF_1) ? "\"b0=1\"" : "\"b1=0\"");
Alexey Starikovskiyb77d81b2008-03-21 17:07:15 +0300203 return -ETIME;
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500204}
205
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400206static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command,
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300207 const u8 * wdata, unsigned wdata_len,
Lennart Poettering00eb43a2007-05-04 14:16:19 +0200208 u8 * rdata, unsigned rdata_len,
209 int force_poll)
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400210{
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300211 int result = 0;
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400212 set_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
Márton Németh3ebe08a2007-11-21 03:23:26 +0300213 pr_debug(PREFIX "transaction start\n");
Alexey Starikovskiydc0e8492008-03-21 17:07:09 +0300214 acpi_ec_write_cmd(ec, command);
Alexey Starikovskiy78d0af32006-12-07 18:42:17 +0300215 for (; wdata_len > 0; --wdata_len) {
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400216 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, force_poll);
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300217 if (result) {
Márton Németh3ebe08a2007-11-21 03:23:26 +0300218 pr_err(PREFIX
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300219 "write_cmd timeout, command = %d\n", command);
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300220 goto end;
221 }
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400222 set_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400223 acpi_ec_write_data(ec, *(wdata++));
Denis M. Sadykov3576cf62006-09-26 19:50:33 +0400224 }
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400225
Alexey Starikovskiyd91df1a2006-12-07 18:42:16 +0300226 if (!rdata_len) {
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400227 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, force_poll);
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300228 if (result) {
Márton Németh3ebe08a2007-11-21 03:23:26 +0300229 pr_err(PREFIX
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300230 "finish-write timeout, command = %d\n", command);
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300231 goto end;
232 }
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400233 } else if (command == ACPI_EC_COMMAND_QUERY)
234 clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags);
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400235
Alexey Starikovskiy78d0af32006-12-07 18:42:17 +0300236 for (; rdata_len > 0; --rdata_len) {
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400237 result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1, force_poll);
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300238 if (result) {
Márton Németh3ebe08a2007-11-21 03:23:26 +0300239 pr_err(PREFIX "read timeout, command = %d\n", command);
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300240 goto end;
241 }
Alexey Starikovskiy0c5d31f2007-10-22 14:18:36 +0400242 /* Don't expect GPE after last read */
243 if (rdata_len > 1)
244 set_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400245 *(rdata++) = acpi_ec_read_data(ec);
Denis M. Sadykov7c6db5e2006-09-26 19:50:33 +0400246 }
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300247 end:
Márton Németh3ebe08a2007-11-21 03:23:26 +0300248 pr_debug(PREFIX "transaction end\n");
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300249 return result;
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400250}
251
Denis M. Sadykov3576cf62006-09-26 19:50:33 +0400252static int acpi_ec_transaction(struct acpi_ec *ec, u8 command,
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300253 const u8 * wdata, unsigned wdata_len,
Lennart Poettering00eb43a2007-05-04 14:16:19 +0200254 u8 * rdata, unsigned rdata_len,
255 int force_poll)
Luming Yu45bea152005-07-23 04:08:00 -0400256{
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400257 int status;
Len Brown50526df2005-08-11 17:32:05 -0400258 u32 glk;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400260 if (!ec || (wdata_len && !wdata) || (rdata_len && !rdata))
Patrick Mocheld550d982006-06-27 00:41:40 -0400261 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300263 if (rdata)
264 memset(rdata, 0, rdata_len);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700265
Alexey Starikovskiy523953b2006-12-07 18:42:17 +0300266 mutex_lock(&ec->lock);
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400267 if (ec->global_lock) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
Alexey Starikovskiyc24e9122007-02-15 23:16:18 +0300269 if (ACPI_FAILURE(status)) {
270 mutex_unlock(&ec->lock);
Patrick Mocheld550d982006-06-27 00:41:40 -0400271 return -ENODEV;
Alexey Starikovskiyc24e9122007-02-15 23:16:18 +0300272 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273 }
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500274
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400275 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, 0);
Luming Yu716e0842005-08-10 01:40:00 -0400276 if (status) {
Márton Németh3ebe08a2007-11-21 03:23:26 +0300277 pr_err(PREFIX "input buffer is not empty, "
278 "aborting transaction\n");
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500279 goto end;
Luming Yu716e0842005-08-10 01:40:00 -0400280 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300282 status = acpi_ec_transaction_unlocked(ec, command,
283 wdata, wdata_len,
Lennart Poettering00eb43a2007-05-04 14:16:19 +0200284 rdata, rdata_len,
285 force_poll);
Len Brown50526df2005-08-11 17:32:05 -0400286
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300287 end:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400289 if (ec->global_lock)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700290 acpi_release_global_lock(glk);
Alexey Starikovskiy523953b2006-12-07 18:42:17 +0300291 mutex_unlock(&ec->lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700292
Patrick Mocheld550d982006-06-27 00:41:40 -0400293 return status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294}
295
Alexey Starikovskiyc45aac42007-03-07 22:28:00 +0300296/*
297 * Note: samsung nv5000 doesn't work with ec burst mode.
298 * http://bugzilla.kernel.org/show_bug.cgi?id=4980
299 */
300int acpi_ec_burst_enable(struct acpi_ec *ec)
301{
302 u8 d;
Lennart Poettering00eb43a2007-05-04 14:16:19 +0200303 return acpi_ec_transaction(ec, ACPI_EC_BURST_ENABLE, NULL, 0, &d, 1, 0);
Alexey Starikovskiyc45aac42007-03-07 22:28:00 +0300304}
305
306int acpi_ec_burst_disable(struct acpi_ec *ec)
307{
Lennart Poettering00eb43a2007-05-04 14:16:19 +0200308 return acpi_ec_transaction(ec, ACPI_EC_BURST_DISABLE, NULL, 0, NULL, 0, 0);
Alexey Starikovskiyc45aac42007-03-07 22:28:00 +0300309}
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,
Lennart Poettering00eb43a2007-05-04 14:16:19 +0200317 &address, 1, &d, 1, 0);
Denis M. Sadykov3576cf62006-09-26 19:50:33 +0400318 *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,
Lennart Poettering00eb43a2007-05-04 14:16:19 +0200326 wdata, 2, NULL, 0, 0);
Denis M. Sadykov3576cf62006-09-26 19:50:33 +0400327}
328
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329/*
330 * Externally callable EC access functions. For now, assume 1 EC only
331 */
Alexey Starikovskiyc45aac42007-03-07 22:28:00 +0300332int ec_burst_enable(void)
333{
Alexey Starikovskiyc45aac42007-03-07 22:28:00 +0300334 if (!first_ec)
335 return -ENODEV;
Alexey Starikovskiyd0338792007-03-07 22:28:00 +0300336 return acpi_ec_burst_enable(first_ec);
Alexey Starikovskiyc45aac42007-03-07 22:28:00 +0300337}
338
339EXPORT_SYMBOL(ec_burst_enable);
340
341int ec_burst_disable(void)
342{
Alexey Starikovskiyc45aac42007-03-07 22:28:00 +0300343 if (!first_ec)
344 return -ENODEV;
Alexey Starikovskiyd0338792007-03-07 22:28:00 +0300345 return acpi_ec_burst_disable(first_ec);
Alexey Starikovskiyc45aac42007-03-07 22:28:00 +0300346}
347
348EXPORT_SYMBOL(ec_burst_disable);
349
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300350int ec_read(u8 addr, u8 * val)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700351{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352 int err;
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400353 u8 temp_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354
355 if (!first_ec)
356 return -ENODEV;
357
Alexey Starikovskiyd0338792007-03-07 22:28:00 +0300358 err = acpi_ec_read(first_ec, addr, &temp_data);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359
360 if (!err) {
361 *val = temp_data;
362 return 0;
Len Brown50526df2005-08-11 17:32:05 -0400363 } else
Linus Torvalds1da177e2005-04-16 15:20:36 -0700364 return err;
365}
Len Brown50526df2005-08-11 17:32:05 -0400366
Linus Torvalds1da177e2005-04-16 15:20:36 -0700367EXPORT_SYMBOL(ec_read);
368
Len Brown50526df2005-08-11 17:32:05 -0400369int ec_write(u8 addr, u8 val)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700370{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371 int err;
372
373 if (!first_ec)
374 return -ENODEV;
375
Alexey Starikovskiyd0338792007-03-07 22:28:00 +0300376 err = acpi_ec_write(first_ec, addr, val);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377
378 return err;
379}
Len Brown50526df2005-08-11 17:32:05 -0400380
Linus Torvalds1da177e2005-04-16 15:20:36 -0700381EXPORT_SYMBOL(ec_write);
382
Randy Dunlap616362d2006-10-27 01:47:34 -0400383int ec_transaction(u8 command,
Alexey Starikovskiy9e197212007-03-07 18:29:35 -0500384 const u8 * wdata, unsigned wdata_len,
Lennart Poettering00eb43a2007-05-04 14:16:19 +0200385 u8 * rdata, unsigned rdata_len,
386 int force_poll)
Luming Yu45bea152005-07-23 04:08:00 -0400387{
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400388 if (!first_ec)
389 return -ENODEV;
390
Alexey Starikovskiyd0338792007-03-07 22:28:00 +0300391 return acpi_ec_transaction(first_ec, command, wdata,
Lennart Poettering00eb43a2007-05-04 14:16:19 +0200392 wdata_len, rdata, rdata_len,
393 force_poll);
Luming Yu45bea152005-07-23 04:08:00 -0400394}
Luming Yu45bea152005-07-23 04:08:00 -0400395
Lennart Poetteringab9e43c2006-10-03 22:49:00 -0400396EXPORT_SYMBOL(ec_transaction);
397
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300398static int acpi_ec_query(struct acpi_ec *ec, u8 * data)
Denis M. Sadykov3576cf62006-09-26 19:50:33 +0400399{
400 int result;
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300401 u8 d;
Luming Yu45bea152005-07-23 04:08:00 -0400402
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300403 if (!ec || !data)
404 return -EINVAL;
Luming Yu45bea152005-07-23 04:08:00 -0400405
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300406 /*
407 * Query the EC to find out which _Qxx method we need to evaluate.
408 * Note that successful completion of the query causes the ACPI_EC_SCI
409 * bit to be cleared (and thus clearing the interrupt source).
410 */
Luming Yu45bea152005-07-23 04:08:00 -0400411
Lennart Poettering00eb43a2007-05-04 14:16:19 +0200412 result = acpi_ec_transaction(ec, ACPI_EC_COMMAND_QUERY, NULL, 0, &d, 1, 0);
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300413 if (result)
414 return result;
Luming Yu45bea152005-07-23 04:08:00 -0400415
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300416 if (!d)
417 return -ENODATA;
Luming Yu45bea152005-07-23 04:08:00 -0400418
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300419 *data = d;
420 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700421}
422
Linus Torvalds1da177e2005-04-16 15:20:36 -0700423/* --------------------------------------------------------------------------
424 Event Management
425 -------------------------------------------------------------------------- */
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400426int acpi_ec_add_query_handler(struct acpi_ec *ec, u8 query_bit,
427 acpi_handle handle, acpi_ec_query_func func,
428 void *data)
429{
430 struct acpi_ec_query_handler *handler =
431 kzalloc(sizeof(struct acpi_ec_query_handler), GFP_KERNEL);
432 if (!handler)
433 return -ENOMEM;
434
435 handler->query_bit = query_bit;
436 handler->handle = handle;
437 handler->func = func;
438 handler->data = data;
439 mutex_lock(&ec->lock);
Alexey Starikovskiy30c08572007-09-26 19:43:22 +0400440 list_add(&handler->node, &ec->list);
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400441 mutex_unlock(&ec->lock);
442 return 0;
443}
444
445EXPORT_SYMBOL_GPL(acpi_ec_add_query_handler);
446
447void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit)
448{
Adrian Bunk1544fdb2007-10-24 18:26:00 +0200449 struct acpi_ec_query_handler *handler, *tmp;
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400450 mutex_lock(&ec->lock);
Adrian Bunk1544fdb2007-10-24 18:26:00 +0200451 list_for_each_entry_safe(handler, tmp, &ec->list, node) {
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400452 if (query_bit == handler->query_bit) {
453 list_del(&handler->node);
454 kfree(handler);
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400455 }
456 }
457 mutex_unlock(&ec->lock);
458}
459
460EXPORT_SYMBOL_GPL(acpi_ec_remove_query_handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700461
Len Brown50526df2005-08-11 17:32:05 -0400462static void acpi_ec_gpe_query(void *ec_cxt)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700463{
Alexey Starikovskiy3d02b902007-03-07 22:28:00 +0300464 struct acpi_ec *ec = ec_cxt;
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400465 u8 value = 0;
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400466 struct acpi_ec_query_handler *handler, copy;
Luming Yu45bea152005-07-23 04:08:00 -0400467
Alexey Starikovskiy5d0c2882006-12-07 18:42:16 +0300468 if (!ec || acpi_ec_query(ec, &value))
Alexey Starikovskiye41334c2006-12-07 18:42:16 +0300469 return;
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400470 mutex_lock(&ec->lock);
471 list_for_each_entry(handler, &ec->list, node) {
472 if (value == handler->query_bit) {
473 /* have custom handler for this bit */
474 memcpy(&copy, handler, sizeof(copy));
475 mutex_unlock(&ec->lock);
476 if (copy.func) {
477 copy.func(copy.data);
478 } else if (copy.handle) {
479 acpi_evaluate_object(copy.handle, NULL, NULL, NULL);
480 }
481 return;
482 }
483 }
484 mutex_unlock(&ec->lock);
Luming Yu45bea152005-07-23 04:08:00 -0400485}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700486
Len Brown50526df2005-08-11 17:32:05 -0400487static u32 acpi_ec_gpe_handler(void *data)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700488{
Len Brown50526df2005-08-11 17:32:05 -0400489 acpi_status status = AE_OK;
Alexey Starikovskiy3d02b902007-03-07 22:28:00 +0300490 struct acpi_ec *ec = data;
Alexey Starikovskiy845625c2008-03-21 17:07:03 +0300491 u8 state = acpi_ec_read_status(ec);
Lennart Poettering00eb43a2007-05-04 14:16:19 +0200492
Márton Németh3ebe08a2007-11-21 03:23:26 +0300493 pr_debug(PREFIX "~~~> interrupt\n");
Alexey Starikovskiyfa95ba02008-03-21 19:36:02 +0300494 atomic_inc(&ec->irq_count);
495 if (atomic_read(&ec->irq_count) > 5) {
496 pr_err(PREFIX "GPE storm detected, disabling EC GPE\n");
497 ec_switch_to_poll_mode(ec);
498 goto end;
499 }
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400500 clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
Alexey Starikovskiy78439322007-10-22 14:18:43 +0400501 if (test_bit(EC_FLAGS_GPE_MODE, &ec->flags))
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300502 wake_up(&ec->wait);
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500503
Alexey Starikovskiy845625c2008-03-21 17:07:03 +0300504 if (state & ACPI_EC_FLAG_SCI) {
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400505 if (!test_and_set_bit(EC_FLAGS_QUERY_PENDING, &ec->flags))
506 status = acpi_os_execute(OSL_EC_BURST_HANDLER,
507 acpi_ec_gpe_query, ec);
Alexey Starikovskiy845625c2008-03-21 17:07:03 +0300508 } else if (!test_bit(EC_FLAGS_GPE_MODE, &ec->flags) &&
Alexey Starikovskiyb77d81b2008-03-21 17:07:15 +0300509 !test_bit(EC_FLAGS_NO_GPE, &ec->flags) &&
Alexey Starikovskiy845625c2008-03-21 17:07:03 +0300510 in_interrupt()) {
Alexey Starikovskiy95b937e2007-10-22 14:19:03 +0400511 /* this is non-query, must be confirmation */
Márton Németh3ebe08a2007-11-21 03:23:26 +0300512 if (printk_ratelimit())
513 pr_info(PREFIX "non-query interrupt received,"
514 " switching to interrupt mode\n");
Alexey Starikovskiy78439322007-10-22 14:18:43 +0400515 set_bit(EC_FLAGS_GPE_MODE, &ec->flags);
Alexey Starikovskiy845625c2008-03-21 17:07:03 +0300516 clear_bit(EC_FLAGS_RESCHEDULE_POLL, &ec->flags);
Alexey Starikovskiy95b937e2007-10-22 14:19:03 +0400517 }
Alexey Starikovskiyfa95ba02008-03-21 19:36:02 +0300518end:
Alexey Starikovskiy845625c2008-03-21 17:07:03 +0300519 ec_schedule_ec_poll(ec);
Alexey Starikovskiy78439322007-10-22 14:18:43 +0400520 return ACPI_SUCCESS(status) ?
Len Brown50526df2005-08-11 17:32:05 -0400521 ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522}
523
Alexey Starikovskiy845625c2008-03-21 17:07:03 +0300524static void do_ec_poll(struct work_struct *work)
525{
526 struct acpi_ec *ec = container_of(work, struct acpi_ec, work.work);
Alexey Starikovskiyfa95ba02008-03-21 19:36:02 +0300527 atomic_set(&ec->irq_count, 0);
Alexey Starikovskiy845625c2008-03-21 17:07:03 +0300528 (void)acpi_ec_gpe_handler(ec);
529}
530
Linus Torvalds1da177e2005-04-16 15:20:36 -0700531/* --------------------------------------------------------------------------
532 Address Space Management
533 -------------------------------------------------------------------------- */
534
535static acpi_status
Alexey Starikovskiy5b7734b2007-05-29 16:42:52 +0400536acpi_ec_space_handler(u32 function, acpi_physical_address address,
537 u32 bits, acpi_integer *value,
Len Brown50526df2005-08-11 17:32:05 -0400538 void *handler_context, void *region_context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700539{
Alexey Starikovskiy3d02b902007-03-07 22:28:00 +0300540 struct acpi_ec *ec = handler_context;
Alexey Starikovskiy3e71a872008-01-11 02:42:51 +0300541 int result = 0, i;
Alexey Starikovskiy5b7734b2007-05-29 16:42:52 +0400542 u8 temp = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543
Linus Torvalds1da177e2005-04-16 15:20:36 -0700544 if ((address > 0xFF) || !value || !handler_context)
Patrick Mocheld550d982006-06-27 00:41:40 -0400545 return AE_BAD_PARAMETER;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700546
Alexey Starikovskiy5b7734b2007-05-29 16:42:52 +0400547 if (function != ACPI_READ && function != ACPI_WRITE)
Patrick Mocheld550d982006-06-27 00:41:40 -0400548 return AE_BAD_PARAMETER;
Alexey Starikovskiy5b7734b2007-05-29 16:42:52 +0400549
550 if (bits != 8 && acpi_strict)
551 return AE_BAD_PARAMETER;
552
Alexey Starikovskiyb3b233c2008-01-11 02:42:57 +0300553 acpi_ec_burst_enable(ec);
554
Alexey Starikovskiy3e71a872008-01-11 02:42:51 +0300555 if (function == ACPI_READ) {
556 result = acpi_ec_read(ec, address, &temp);
557 *value = temp;
558 } else {
559 temp = 0xff & (*value);
560 result = acpi_ec_write(ec, address, temp);
561 }
562
563 for (i = 8; unlikely(bits - i > 0); i += 8) {
564 ++address;
Alexey Starikovskiy5b7734b2007-05-29 16:42:52 +0400565 if (function == ACPI_READ) {
566 result = acpi_ec_read(ec, address, &temp);
567 (*value) |= ((acpi_integer)temp) << i;
568 } else {
569 temp = 0xff & ((*value) >> i);
570 result = acpi_ec_write(ec, address, temp);
571 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700572 }
573
Alexey Starikovskiyb3b233c2008-01-11 02:42:57 +0300574 acpi_ec_burst_disable(ec);
575
Linus Torvalds1da177e2005-04-16 15:20:36 -0700576 switch (result) {
577 case -EINVAL:
Patrick Mocheld550d982006-06-27 00:41:40 -0400578 return AE_BAD_PARAMETER;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700579 break;
580 case -ENODEV:
Patrick Mocheld550d982006-06-27 00:41:40 -0400581 return AE_NOT_FOUND;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700582 break;
583 case -ETIME:
Patrick Mocheld550d982006-06-27 00:41:40 -0400584 return AE_TIME;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700585 break;
586 default:
Patrick Mocheld550d982006-06-27 00:41:40 -0400587 return AE_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700588 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700589}
590
Linus Torvalds1da177e2005-04-16 15:20:36 -0700591/* --------------------------------------------------------------------------
592 FS Interface (/proc)
593 -------------------------------------------------------------------------- */
594
Len Brown50526df2005-08-11 17:32:05 -0400595static struct proc_dir_entry *acpi_ec_dir;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700596
Len Brown50526df2005-08-11 17:32:05 -0400597static int acpi_ec_read_info(struct seq_file *seq, void *offset)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700598{
Alexey Starikovskiy3d02b902007-03-07 22:28:00 +0300599 struct acpi_ec *ec = seq->private;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700600
Linus Torvalds1da177e2005-04-16 15:20:36 -0700601 if (!ec)
602 goto end;
603
Alexey Starikovskiy01f22462007-03-07 22:28:00 +0300604 seq_printf(seq, "gpe:\t\t\t0x%02x\n", (u32) ec->gpe);
605 seq_printf(seq, "ports:\t\t\t0x%02x, 0x%02x\n",
606 (unsigned)ec->command_addr, (unsigned)ec->data_addr);
607 seq_printf(seq, "use global lock:\t%s\n",
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400608 ec->global_lock ? "yes" : "no");
Len Brown50526df2005-08-11 17:32:05 -0400609 end:
Patrick Mocheld550d982006-06-27 00:41:40 -0400610 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700611}
612
613static int acpi_ec_info_open_fs(struct inode *inode, struct file *file)
614{
615 return single_open(file, acpi_ec_read_info, PDE(inode)->data);
616}
617
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400618static struct file_operations acpi_ec_info_ops = {
Len Brown50526df2005-08-11 17:32:05 -0400619 .open = acpi_ec_info_open_fs,
620 .read = seq_read,
621 .llseek = seq_lseek,
622 .release = single_release,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700623 .owner = THIS_MODULE,
624};
625
Len Brown50526df2005-08-11 17:32:05 -0400626static int acpi_ec_add_fs(struct acpi_device *device)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700627{
Len Brown50526df2005-08-11 17:32:05 -0400628 struct proc_dir_entry *entry = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700629
Linus Torvalds1da177e2005-04-16 15:20:36 -0700630 if (!acpi_device_dir(device)) {
631 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
Len Brown50526df2005-08-11 17:32:05 -0400632 acpi_ec_dir);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700633 if (!acpi_device_dir(device))
Patrick Mocheld550d982006-06-27 00:41:40 -0400634 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700635 }
636
637 entry = create_proc_entry(ACPI_EC_FILE_INFO, S_IRUGO,
Len Brown50526df2005-08-11 17:32:05 -0400638 acpi_device_dir(device));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700639 if (!entry)
Patrick Mocheld550d982006-06-27 00:41:40 -0400640 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700641 else {
642 entry->proc_fops = &acpi_ec_info_ops;
643 entry->data = acpi_driver_data(device);
644 entry->owner = THIS_MODULE;
645 }
646
Patrick Mocheld550d982006-06-27 00:41:40 -0400647 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700648}
649
Len Brown50526df2005-08-11 17:32:05 -0400650static int acpi_ec_remove_fs(struct acpi_device *device)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700651{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700652
653 if (acpi_device_dir(device)) {
654 remove_proc_entry(ACPI_EC_FILE_INFO, acpi_device_dir(device));
655 remove_proc_entry(acpi_device_bid(device), acpi_ec_dir);
656 acpi_device_dir(device) = NULL;
657 }
658
Patrick Mocheld550d982006-06-27 00:41:40 -0400659 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700660}
661
Linus Torvalds1da177e2005-04-16 15:20:36 -0700662/* --------------------------------------------------------------------------
663 Driver Interface
664 -------------------------------------------------------------------------- */
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300665static acpi_status
666ec_parse_io_ports(struct acpi_resource *resource, void *context);
667
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300668static struct acpi_ec *make_acpi_ec(void)
669{
670 struct acpi_ec *ec = kzalloc(sizeof(struct acpi_ec), GFP_KERNEL);
671 if (!ec)
672 return NULL;
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400673 ec->flags = 1 << EC_FLAGS_QUERY_PENDING;
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300674 mutex_init(&ec->lock);
675 init_waitqueue_head(&ec->wait);
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400676 INIT_LIST_HEAD(&ec->list);
Alexey Starikovskiy845625c2008-03-21 17:07:03 +0300677 INIT_DELAYED_WORK_DEFERRABLE(&ec->work, do_ec_poll);
Alexey Starikovskiyfa95ba02008-03-21 19:36:02 +0300678 atomic_set(&ec->irq_count, 0);
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300679 return ec;
680}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700681
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400682static acpi_status
Alexey Starikovskiyc019b192007-08-14 01:03:42 -0400683acpi_ec_register_query_methods(acpi_handle handle, u32 level,
684 void *context, void **return_value)
685{
686 struct acpi_namespace_node *node = handle;
687 struct acpi_ec *ec = context;
688 int value = 0;
689 if (sscanf(node->name.ascii, "_Q%x", &value) == 1) {
690 acpi_ec_add_query_handler(ec, value, handle, NULL, NULL);
691 }
692 return AE_OK;
693}
694
695static acpi_status
Alexey Starikovskiycd8c93a2007-08-03 17:52:48 -0400696ec_parse_device(acpi_handle handle, u32 Level, void *context, void **retval)
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400697{
Alexey Starikovskiycd8c93a2007-08-03 17:52:48 -0400698 acpi_status status;
699
700 struct acpi_ec *ec = context;
701 status = acpi_walk_resources(handle, METHOD_NAME__CRS,
702 ec_parse_io_ports, ec);
703 if (ACPI_FAILURE(status))
704 return status;
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400705
706 /* Get GPE bit assignment (EC events). */
707 /* TODO: Add support for _GPE returning a package */
Alexey Starikovskiycd8c93a2007-08-03 17:52:48 -0400708 status = acpi_evaluate_integer(handle, "_GPE", NULL, &ec->gpe);
709 if (ACPI_FAILURE(status))
710 return status;
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400711 /* Use the global lock for all EC transactions? */
712 acpi_evaluate_integer(handle, "_GLK", NULL, &ec->global_lock);
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400713 ec->handle = handle;
Alexey Starikovskiycd8c93a2007-08-03 17:52:48 -0400714 return AE_CTRL_TERMINATE;
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400715}
716
Alexey Starikovskiy845625c2008-03-21 17:07:03 +0300717static void ec_poll_stop(struct acpi_ec *ec)
718{
719 clear_bit(EC_FLAGS_RESCHEDULE_POLL, &ec->flags);
720 cancel_delayed_work(&ec->work);
721}
722
Alexey Starikovskiy4c611062007-09-05 19:56:38 -0400723static void ec_remove_handlers(struct acpi_ec *ec)
724{
Alexey Starikovskiy845625c2008-03-21 17:07:03 +0300725 ec_poll_stop(ec);
Alexey Starikovskiy4c611062007-09-05 19:56:38 -0400726 if (ACPI_FAILURE(acpi_remove_address_space_handler(ec->handle,
727 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler)))
Márton Németh3ebe08a2007-11-21 03:23:26 +0300728 pr_err(PREFIX "failed to remove space handler\n");
Alexey Starikovskiy4c611062007-09-05 19:56:38 -0400729 if (ACPI_FAILURE(acpi_remove_gpe_handler(NULL, ec->gpe,
730 &acpi_ec_gpe_handler)))
Márton Németh3ebe08a2007-11-21 03:23:26 +0300731 pr_err(PREFIX "failed to remove gpe handler\n");
Alexey Starikovskiy4c611062007-09-05 19:56:38 -0400732 ec->handlers_installed = 0;
733}
734
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400735static int acpi_ec_add(struct acpi_device *device)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700736{
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400737 struct acpi_ec *ec = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700738
Linus Torvalds1da177e2005-04-16 15:20:36 -0700739 if (!device)
Patrick Mocheld550d982006-06-27 00:41:40 -0400740 return -EINVAL;
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300741 strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME);
742 strcpy(acpi_device_class(device), ACPI_EC_CLASS);
743
Alexey Starikovskiy4c611062007-09-05 19:56:38 -0400744 /* Check for boot EC */
Alexey Starikovskiyce52ddf2008-03-24 23:22:36 +0300745 if (boot_ec &&
746 (boot_ec->handle == device->handle ||
747 boot_ec->handle == ACPI_ROOT_OBJECT)) {
748 ec = boot_ec;
749 boot_ec = NULL;
750 } else {
751 ec = make_acpi_ec();
752 if (!ec)
753 return -ENOMEM;
754 if (ec_parse_device(device->handle, 0, ec, NULL) !=
755 AE_CTRL_TERMINATE) {
756 kfree(ec);
757 return -EINVAL;
Alexey Starikovskiy4c611062007-09-05 19:56:38 -0400758 }
759 }
760
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300761 ec->handle = device->handle;
Alexey Starikovskiyce52ddf2008-03-24 23:22:36 +0300762
763 /* Find and register all query methods */
764 acpi_walk_namespace(ACPI_TYPE_METHOD, ec->handle, 1,
765 acpi_ec_register_query_methods, ec, NULL);
766
Alexey Starikovskiy4c611062007-09-05 19:56:38 -0400767 if (!first_ec)
768 first_ec = ec;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700769 acpi_driver_data(device) = ec;
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300770 acpi_ec_add_fs(device);
Márton Németh3ebe08a2007-11-21 03:23:26 +0300771 pr_info(PREFIX "GPE = 0x%lx, I/O: command/status = 0x%lx, data = 0x%lx\n",
Alexey Starikovskiy4c611062007-09-05 19:56:38 -0400772 ec->gpe, ec->command_addr, ec->data_addr);
Márton Németh3ebe08a2007-11-21 03:23:26 +0300773 pr_info(PREFIX "driver started in %s mode\n",
Alexey Starikovskiy95b937e2007-10-22 14:19:03 +0400774 (test_bit(EC_FLAGS_GPE_MODE, &ec->flags))?"interrupt":"poll");
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300775 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700776}
777
Len Brown50526df2005-08-11 17:32:05 -0400778static int acpi_ec_remove(struct acpi_device *device, int type)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700779{
Alexey Starikovskiy01f22462007-03-07 22:28:00 +0300780 struct acpi_ec *ec;
Adrian Bunk07ddf762007-07-29 17:00:37 +0200781 struct acpi_ec_query_handler *handler, *tmp;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700782
Linus Torvalds1da177e2005-04-16 15:20:36 -0700783 if (!device)
Patrick Mocheld550d982006-06-27 00:41:40 -0400784 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700785
786 ec = acpi_driver_data(device);
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400787 mutex_lock(&ec->lock);
Adrian Bunk07ddf762007-07-29 17:00:37 +0200788 list_for_each_entry_safe(handler, tmp, &ec->list, node) {
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400789 list_del(&handler->node);
790 kfree(handler);
791 }
792 mutex_unlock(&ec->lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700793 acpi_ec_remove_fs(device);
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300794 acpi_driver_data(device) = NULL;
Alexey Starikovskiyd0338792007-03-07 22:28:00 +0300795 if (ec == first_ec)
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300796 first_ec = NULL;
Alexey Starikovskiy4c611062007-09-05 19:56:38 -0400797 kfree(ec);
Patrick Mocheld550d982006-06-27 00:41:40 -0400798 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700799}
800
Linus Torvalds1da177e2005-04-16 15:20:36 -0700801static acpi_status
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300802ec_parse_io_ports(struct acpi_resource *resource, void *context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700803{
Alexey Starikovskiy3d02b902007-03-07 22:28:00 +0300804 struct acpi_ec *ec = context;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700805
Alexey Starikovskiy01f22462007-03-07 22:28:00 +0300806 if (resource->type != ACPI_RESOURCE_TYPE_IO)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700807 return AE_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700808
809 /*
810 * The first address region returned is the data port, and
811 * the second address region returned is the status/command
812 * port.
813 */
Alexey Starikovskiy01f22462007-03-07 22:28:00 +0300814 if (ec->data_addr == 0)
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400815 ec->data_addr = resource->data.io.minimum;
Alexey Starikovskiy01f22462007-03-07 22:28:00 +0300816 else if (ec->command_addr == 0)
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400817 ec->command_addr = resource->data.io.minimum;
Alexey Starikovskiy01f22462007-03-07 22:28:00 +0300818 else
Linus Torvalds1da177e2005-04-16 15:20:36 -0700819 return AE_CTRL_TERMINATE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700820
Linus Torvalds1da177e2005-04-16 15:20:36 -0700821 return AE_OK;
822}
823
Alexey Starikovskiye8284322007-03-07 22:28:00 +0300824static int ec_install_handlers(struct acpi_ec *ec)
825{
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300826 acpi_status status;
Alexey Starikovskiy4c611062007-09-05 19:56:38 -0400827 if (ec->handlers_installed)
828 return 0;
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300829 status = acpi_install_gpe_handler(NULL, ec->gpe,
830 ACPI_GPE_EDGE_TRIGGERED,
831 &acpi_ec_gpe_handler, ec);
Alexey Starikovskiye8284322007-03-07 22:28:00 +0300832 if (ACPI_FAILURE(status))
833 return -ENODEV;
Alexey Starikovskiy01f22462007-03-07 22:28:00 +0300834
Alexey Starikovskiye8284322007-03-07 22:28:00 +0300835 acpi_set_gpe_type(NULL, ec->gpe, ACPI_GPE_TYPE_RUNTIME);
836 acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR);
837
838 status = acpi_install_address_space_handler(ec->handle,
839 ACPI_ADR_SPACE_EC,
840 &acpi_ec_space_handler,
Alexey Starikovskiy6d9e1122008-03-24 23:22:29 +0300841 NULL, ec);
Alexey Starikovskiye8284322007-03-07 22:28:00 +0300842 if (ACPI_FAILURE(status)) {
843 acpi_remove_gpe_handler(NULL, ec->gpe, &acpi_ec_gpe_handler);
844 return -ENODEV;
845 }
846
Alexey Starikovskiy4c611062007-09-05 19:56:38 -0400847 ec->handlers_installed = 1;
Alexey Starikovskiye8284322007-03-07 22:28:00 +0300848 return 0;
849}
850
Len Brown50526df2005-08-11 17:32:05 -0400851static int acpi_ec_start(struct acpi_device *device)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700852{
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300853 struct acpi_ec *ec;
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400854 int ret = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700855
Linus Torvalds1da177e2005-04-16 15:20:36 -0700856 if (!device)
Patrick Mocheld550d982006-06-27 00:41:40 -0400857 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700858
859 ec = acpi_driver_data(device);
860
861 if (!ec)
Patrick Mocheld550d982006-06-27 00:41:40 -0400862 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700863
Alexey Starikovskiy4c611062007-09-05 19:56:38 -0400864 ret = ec_install_handlers(ec);
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300865
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400866 /* EC is fully operational, allow queries */
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400867 clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags);
Alexey Starikovskiy845625c2008-03-21 17:07:03 +0300868 ec_schedule_ec_poll(ec);
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400869 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700870}
871
Len Brown50526df2005-08-11 17:32:05 -0400872static int acpi_ec_stop(struct acpi_device *device, int type)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700873{
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300874 struct acpi_ec *ec;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700875 if (!device)
Patrick Mocheld550d982006-06-27 00:41:40 -0400876 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700877 ec = acpi_driver_data(device);
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300878 if (!ec)
879 return -EINVAL;
Alexey Starikovskiy4c611062007-09-05 19:56:38 -0400880 ec_remove_handlers(ec);
Alexey Starikovskiyf9319f92007-08-24 08:10:11 +0400881
Patrick Mocheld550d982006-06-27 00:41:40 -0400882 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700883}
884
Alexey Starikovskiyc04209a2008-01-01 14:12:55 -0500885int __init acpi_boot_ec_enable(void)
886{
887 if (!boot_ec || boot_ec->handlers_installed)
888 return 0;
889 if (!ec_install_handlers(boot_ec)) {
890 first_ec = boot_ec;
891 return 0;
892 }
893 return -EFAULT;
894}
895
Alexey Starikovskiy223883b2008-03-21 17:07:21 +0300896static const struct acpi_device_id ec_device_ids[] = {
897 {"PNP0C09", 0},
898 {"", 0},
899};
900
Len Brown50526df2005-08-11 17:32:05 -0400901int __init acpi_ec_ecdt_probe(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700902{
Len Brown50526df2005-08-11 17:32:05 -0400903 int ret;
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300904 acpi_status status;
905 struct acpi_table_ecdt *ecdt_ptr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700906
Alexey Starikovskiyd66d9692007-03-07 22:28:00 +0300907 boot_ec = make_acpi_ec();
908 if (!boot_ec)
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300909 return -ENOMEM;
910 /*
911 * Generate a boot ec context
912 */
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300913 status = acpi_get_table(ACPI_SIG_ECDT, 1,
914 (struct acpi_table_header **)&ecdt_ptr);
Alexey Starikovskiycd8c93a2007-08-03 17:52:48 -0400915 if (ACPI_SUCCESS(status)) {
Márton Németh3ebe08a2007-11-21 03:23:26 +0300916 pr_info(PREFIX "EC description table is found, configuring boot EC\n");
Alexey Starikovskiycd8c93a2007-08-03 17:52:48 -0400917 boot_ec->command_addr = ecdt_ptr->control.address;
918 boot_ec->data_addr = ecdt_ptr->data.address;
919 boot_ec->gpe = ecdt_ptr->gpe;
Len Brown4af8e102008-03-11 00:27:16 -0400920 boot_ec->handle = ACPI_ROOT_OBJECT;
Alexey Starikovskiyce52ddf2008-03-24 23:22:36 +0300921 acpi_get_handle(ACPI_ROOT_OBJECT, ecdt_ptr->id, &boot_ec->handle);
Alexey Starikovskiycd8c93a2007-08-03 17:52:48 -0400922 } else {
Alexey Starikovskiy5870a8c2007-11-15 21:52:47 +0300923 /* This workaround is needed only on some broken machines,
924 * which require early EC, but fail to provide ECDT */
925 acpi_handle x;
Alexey Starikovskiycd8c93a2007-08-03 17:52:48 -0400926 printk(KERN_DEBUG PREFIX "Look up EC in DSDT\n");
927 status = acpi_get_devices(ec_device_ids[0].id, ec_parse_device,
928 boot_ec, NULL);
Alexey Starikovskiy2d8348b2007-08-31 09:05:26 +0400929 /* Check that acpi_get_devices actually find something */
930 if (ACPI_FAILURE(status) || !boot_ec->handle)
Alexey Starikovskiycd8c93a2007-08-03 17:52:48 -0400931 goto error;
Alexey Starikovskiy5870a8c2007-11-15 21:52:47 +0300932 /* We really need to limit this workaround, the only ASUS,
933 * which needs it, has fake EC._INI method, so use it as flag.
Alexey Starikovskiyc04209a2008-01-01 14:12:55 -0500934 * Keep boot_ec struct as it will be needed soon.
Alexey Starikovskiy5870a8c2007-11-15 21:52:47 +0300935 */
936 if (ACPI_FAILURE(acpi_get_handle(boot_ec->handle, "_INI", &x)))
Alexey Starikovskiyc04209a2008-01-01 14:12:55 -0500937 return -ENODEV;
Alexey Starikovskiycd8c93a2007-08-03 17:52:48 -0400938 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700939
Alexey Starikovskiyd66d9692007-03-07 22:28:00 +0300940 ret = ec_install_handlers(boot_ec);
Alexey Starikovskiyd0338792007-03-07 22:28:00 +0300941 if (!ret) {
942 first_ec = boot_ec;
Alexey Starikovskiye8284322007-03-07 22:28:00 +0300943 return 0;
Alexey Starikovskiyd0338792007-03-07 22:28:00 +0300944 }
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300945 error:
Alexey Starikovskiyd66d9692007-03-07 22:28:00 +0300946 kfree(boot_ec);
947 boot_ec = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700948 return -ENODEV;
949}
950
Alexey Starikovskiy223883b2008-03-21 17:07:21 +0300951static int acpi_ec_suspend(struct acpi_device *device, pm_message_t state)
952{
953 struct acpi_ec *ec = acpi_driver_data(device);
954 /* Stop using GPE */
955 set_bit(EC_FLAGS_NO_GPE, &ec->flags);
956 clear_bit(EC_FLAGS_GPE_MODE, &ec->flags);
957 acpi_disable_gpe(NULL, ec->gpe, ACPI_NOT_ISR);
958 return 0;
959}
960
961static int acpi_ec_resume(struct acpi_device *device)
962{
963 struct acpi_ec *ec = acpi_driver_data(device);
964 /* Enable use of GPE back */
965 clear_bit(EC_FLAGS_NO_GPE, &ec->flags);
966 acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR);
967 return 0;
968}
969
970static struct acpi_driver acpi_ec_driver = {
971 .name = "ec",
972 .class = ACPI_EC_CLASS,
973 .ids = ec_device_ids,
974 .ops = {
975 .add = acpi_ec_add,
976 .remove = acpi_ec_remove,
977 .start = acpi_ec_start,
978 .stop = acpi_ec_stop,
979 .suspend = acpi_ec_suspend,
980 .resume = acpi_ec_resume,
981 },
982};
983
Len Brown50526df2005-08-11 17:32:05 -0400984static int __init acpi_ec_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700985{
Len Brown50526df2005-08-11 17:32:05 -0400986 int result = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700987
Linus Torvalds1da177e2005-04-16 15:20:36 -0700988 if (acpi_disabled)
Patrick Mocheld550d982006-06-27 00:41:40 -0400989 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700990
991 acpi_ec_dir = proc_mkdir(ACPI_EC_CLASS, acpi_root_dir);
992 if (!acpi_ec_dir)
Patrick Mocheld550d982006-06-27 00:41:40 -0400993 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700994
995 /* Now register the driver for the EC */
996 result = acpi_bus_register_driver(&acpi_ec_driver);
997 if (result < 0) {
998 remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir);
Patrick Mocheld550d982006-06-27 00:41:40 -0400999 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001000 }
1001
Patrick Mocheld550d982006-06-27 00:41:40 -04001002 return result;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001003}
1004
1005subsys_initcall(acpi_ec_init);
1006
1007/* EC driver currently not unloadable */
1008#if 0
Len Brown50526df2005-08-11 17:32:05 -04001009static void __exit acpi_ec_exit(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001010{
Linus Torvalds1da177e2005-04-16 15:20:36 -07001011
1012 acpi_bus_unregister_driver(&acpi_ec_driver);
1013
1014 remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir);
1015
Patrick Mocheld550d982006-06-27 00:41:40 -04001016 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001017}
Alexey Starikovskiy78439322007-10-22 14:18:43 +04001018#endif /* 0 */