blob: da67d228c9eabf7e921670bbc8ecc08dd5f51665 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Alexey Starikovskiy01f224622007-03-07 22:28:00 +03002 * ec.c - ACPI Embedded Controller Driver (v2.0)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 *
Alexey Starikovskiy01f224622007-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 Starikovskiy4c611062007-09-05 19:56:38 -0400109 u8 handlers_installed;
Alexey Starikovskiyd0338792007-03-07 22:28:00 +0300110} *boot_ec, *first_ec;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400111
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112/* --------------------------------------------------------------------------
113 Transaction Management
114 -------------------------------------------------------------------------- */
115
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400116static inline u8 acpi_ec_read_status(struct acpi_ec *ec)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117{
Márton Németh3ebe08a2007-11-21 03:23:26 +0300118 u8 x = inb(ec->command_addr);
Márton Németh86dae012008-01-23 22:33:06 -0500119 pr_debug(PREFIX "---> status = 0x%2.2x\n", x);
Márton Németh3ebe08a2007-11-21 03:23:26 +0300120 return x;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121}
122
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400123static inline u8 acpi_ec_read_data(struct acpi_ec *ec)
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400124{
Márton Németh3ebe08a2007-11-21 03:23:26 +0300125 u8 x = inb(ec->data_addr);
Márton Németh86dae012008-01-23 22:33:06 -0500126 pr_debug(PREFIX "---> data = 0x%2.2x\n", x);
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400127 return inb(ec->data_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_cmd(struct acpi_ec *ec, u8 command)
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400131{
Márton Németh86dae012008-01-23 22:33:06 -0500132 pr_debug(PREFIX "<--- command = 0x%2.2x\n", command);
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400133 outb(command, ec->command_addr);
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400134}
135
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400136static inline void acpi_ec_write_data(struct acpi_ec *ec, u8 data)
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400137{
Márton Németh86dae012008-01-23 22:33:06 -0500138 pr_debug(PREFIX "<--- data = 0x%2.2x\n", data);
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400139 outb(data, ec->data_addr);
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400140}
141
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400142static inline int acpi_ec_check_status(struct acpi_ec *ec, enum ec_event event)
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400143{
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400144 if (test_bit(EC_FLAGS_WAIT_GPE, &ec->flags))
Alexey Starikovskiy9e197212007-03-07 18:29:35 -0500145 return 0;
Alexey Starikovskiy78d0af32006-12-07 18:42:17 +0300146 if (event == ACPI_EC_EVENT_OBF_1) {
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400147 if (acpi_ec_read_status(ec) & ACPI_EC_FLAG_OBF)
Denis M. Sadykov7c6db5e2006-09-26 19:50:33 +0400148 return 1;
Alexey Starikovskiy78d0af32006-12-07 18:42:17 +0300149 } else if (event == ACPI_EC_EVENT_IBF_0) {
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400150 if (!(acpi_ec_read_status(ec) & ACPI_EC_FLAG_IBF))
Denis M. Sadykov7c6db5e2006-09-26 19:50:33 +0400151 return 1;
Denis M. Sadykov7c6db5e2006-09-26 19:50:33 +0400152 }
153
154 return 0;
155}
156
Alexey Starikovskiy845625c2008-03-21 17:07:03 +0300157static void ec_schedule_ec_poll(struct acpi_ec *ec)
158{
159 if (test_bit(EC_FLAGS_RESCHEDULE_POLL, &ec->flags))
160 schedule_delayed_work(&ec->work,
161 msecs_to_jiffies(ACPI_EC_DELAY));
162}
163
164static void ec_switch_to_poll_mode(struct acpi_ec *ec)
165{
Alexey Starikovskiyb77d81b2008-03-21 17:07:15 +0300166 set_bit(EC_FLAGS_NO_GPE, &ec->flags);
Alexey Starikovskiy845625c2008-03-21 17:07:03 +0300167 clear_bit(EC_FLAGS_GPE_MODE, &ec->flags);
168 acpi_disable_gpe(NULL, ec->gpe, ACPI_NOT_ISR);
169 set_bit(EC_FLAGS_RESCHEDULE_POLL, &ec->flags);
170}
171
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400172static int acpi_ec_wait(struct acpi_ec *ec, enum ec_event event, int force_poll)
Luming Yu45bea152005-07-23 04:08:00 -0400173{
Alexey Starikovskiy78439322007-10-22 14:18:43 +0400174 if (likely(test_bit(EC_FLAGS_GPE_MODE, &ec->flags)) &&
175 likely(!force_poll)) {
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400176 if (wait_event_timeout(ec->wait, acpi_ec_check_status(ec, event),
177 msecs_to_jiffies(ACPI_EC_DELAY)))
Alexey Starikovskiyb77d81b2008-03-21 17:07:15 +0300178 return 0;
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400179 clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
180 if (acpi_ec_check_status(ec, event)) {
Alexey Starikovskiyb77d81b2008-03-21 17:07:15 +0300181 /* missing GPEs, switch back to poll mode */
182 if (printk_ratelimit())
183 pr_info(PREFIX "missing confirmations, "
Márton Németh3ebe08a2007-11-21 03:23:26 +0300184 "switch off interrupt mode.\n");
Alexey Starikovskiyb77d81b2008-03-21 17:07:15 +0300185 ec_switch_to_poll_mode(ec);
186 ec_schedule_ec_poll(ec);
187 return 0;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400188 }
Alexey Starikovskiy78439322007-10-22 14:18:43 +0400189 } else {
190 unsigned long delay = jiffies + msecs_to_jiffies(ACPI_EC_DELAY);
191 clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
192 while (time_before(jiffies, delay)) {
193 if (acpi_ec_check_status(ec, event))
Alexey Starikovskiyb77d81b2008-03-21 17:07:15 +0300194 return 0;
Alexey Starikovskiye6e82a32008-03-21 17:06:57 +0300195 udelay(ACPI_EC_UDELAY);
Alexey Starikovskiy78439322007-10-22 14:18:43 +0400196 }
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300197 }
Alexey Starikovskiydc0e8492008-03-21 17:07:09 +0300198 pr_err(PREFIX "acpi_ec_wait timeout, status = 0x%2.2x, event = %s\n",
199 acpi_ec_read_status(ec),
200 (event == ACPI_EC_EVENT_OBF_1) ? "\"b0=1\"" : "\"b1=0\"");
Alexey Starikovskiyb77d81b2008-03-21 17:07:15 +0300201 return -ETIME;
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500202}
203
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400204static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command,
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300205 const u8 * wdata, unsigned wdata_len,
Lennart Poettering00eb43a2007-05-04 14:16:19 +0200206 u8 * rdata, unsigned rdata_len,
207 int force_poll)
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400208{
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300209 int result = 0;
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400210 set_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
Márton Németh3ebe08a2007-11-21 03:23:26 +0300211 pr_debug(PREFIX "transaction start\n");
Alexey Starikovskiydc0e8492008-03-21 17:07:09 +0300212 acpi_ec_write_cmd(ec, command);
Alexey Starikovskiy78d0af32006-12-07 18:42:17 +0300213 for (; wdata_len > 0; --wdata_len) {
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400214 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, force_poll);
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300215 if (result) {
Márton Németh3ebe08a2007-11-21 03:23:26 +0300216 pr_err(PREFIX
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300217 "write_cmd timeout, command = %d\n", command);
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300218 goto end;
219 }
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400220 set_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400221 acpi_ec_write_data(ec, *(wdata++));
Denis M. Sadykov3576cf62006-09-26 19:50:33 +0400222 }
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400223
Alexey Starikovskiyd91df1a2006-12-07 18:42:16 +0300224 if (!rdata_len) {
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400225 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, force_poll);
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300226 if (result) {
Márton Németh3ebe08a2007-11-21 03:23:26 +0300227 pr_err(PREFIX
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300228 "finish-write timeout, command = %d\n", command);
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300229 goto end;
230 }
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400231 } else if (command == ACPI_EC_COMMAND_QUERY)
232 clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags);
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400233
Alexey Starikovskiy78d0af32006-12-07 18:42:17 +0300234 for (; rdata_len > 0; --rdata_len) {
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400235 result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1, force_poll);
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300236 if (result) {
Márton Németh3ebe08a2007-11-21 03:23:26 +0300237 pr_err(PREFIX "read timeout, command = %d\n", command);
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300238 goto end;
239 }
Alexey Starikovskiy0c5d31f2007-10-22 14:18:36 +0400240 /* Don't expect GPE after last read */
241 if (rdata_len > 1)
242 set_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400243 *(rdata++) = acpi_ec_read_data(ec);
Denis M. Sadykov7c6db5e2006-09-26 19:50:33 +0400244 }
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300245 end:
Márton Németh3ebe08a2007-11-21 03:23:26 +0300246 pr_debug(PREFIX "transaction end\n");
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300247 return result;
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400248}
249
Denis M. Sadykov3576cf62006-09-26 19:50:33 +0400250static int acpi_ec_transaction(struct acpi_ec *ec, u8 command,
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300251 const u8 * wdata, unsigned wdata_len,
Lennart Poettering00eb43a2007-05-04 14:16:19 +0200252 u8 * rdata, unsigned rdata_len,
253 int force_poll)
Luming Yu45bea152005-07-23 04:08:00 -0400254{
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400255 int status;
Len Brown50526df2005-08-11 17:32:05 -0400256 u32 glk;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400258 if (!ec || (wdata_len && !wdata) || (rdata_len && !rdata))
Patrick Mocheld550d982006-06-27 00:41:40 -0400259 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300261 if (rdata)
262 memset(rdata, 0, rdata_len);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700263
Alexey Starikovskiy523953b2006-12-07 18:42:17 +0300264 mutex_lock(&ec->lock);
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400265 if (ec->global_lock) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700266 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
Alexey Starikovskiyc24e9122007-02-15 23:16:18 +0300267 if (ACPI_FAILURE(status)) {
268 mutex_unlock(&ec->lock);
Patrick Mocheld550d982006-06-27 00:41:40 -0400269 return -ENODEV;
Alexey Starikovskiyc24e9122007-02-15 23:16:18 +0300270 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271 }
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500272
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400273 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, 0);
Luming Yu716e0842005-08-10 01:40:00 -0400274 if (status) {
Márton Németh3ebe08a2007-11-21 03:23:26 +0300275 pr_err(PREFIX "input buffer is not empty, "
276 "aborting transaction\n");
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500277 goto end;
Luming Yu716e0842005-08-10 01:40:00 -0400278 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300280 status = acpi_ec_transaction_unlocked(ec, command,
281 wdata, wdata_len,
Lennart Poettering00eb43a2007-05-04 14:16:19 +0200282 rdata, rdata_len,
283 force_poll);
Len Brown50526df2005-08-11 17:32:05 -0400284
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300285 end:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400287 if (ec->global_lock)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288 acpi_release_global_lock(glk);
Alexey Starikovskiy523953b2006-12-07 18:42:17 +0300289 mutex_unlock(&ec->lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700290
Patrick Mocheld550d982006-06-27 00:41:40 -0400291 return status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700292}
293
Alexey Starikovskiyc45aac42007-03-07 22:28:00 +0300294/*
295 * Note: samsung nv5000 doesn't work with ec burst mode.
296 * http://bugzilla.kernel.org/show_bug.cgi?id=4980
297 */
298int acpi_ec_burst_enable(struct acpi_ec *ec)
299{
300 u8 d;
Lennart Poettering00eb43a2007-05-04 14:16:19 +0200301 return acpi_ec_transaction(ec, ACPI_EC_BURST_ENABLE, NULL, 0, &d, 1, 0);
Alexey Starikovskiyc45aac42007-03-07 22:28:00 +0300302}
303
304int acpi_ec_burst_disable(struct acpi_ec *ec)
305{
Lennart Poettering00eb43a2007-05-04 14:16:19 +0200306 return acpi_ec_transaction(ec, ACPI_EC_BURST_DISABLE, NULL, 0, NULL, 0, 0);
Alexey Starikovskiyc45aac42007-03-07 22:28:00 +0300307}
308
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300309static int acpi_ec_read(struct acpi_ec *ec, u8 address, u8 * data)
Denis M. Sadykov3576cf62006-09-26 19:50:33 +0400310{
311 int result;
312 u8 d;
313
314 result = acpi_ec_transaction(ec, ACPI_EC_COMMAND_READ,
Lennart Poettering00eb43a2007-05-04 14:16:19 +0200315 &address, 1, &d, 1, 0);
Denis M. Sadykov3576cf62006-09-26 19:50:33 +0400316 *data = d;
317 return result;
318}
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400319
Denis M. Sadykov3576cf62006-09-26 19:50:33 +0400320static int acpi_ec_write(struct acpi_ec *ec, u8 address, u8 data)
321{
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300322 u8 wdata[2] = { address, data };
323 return acpi_ec_transaction(ec, ACPI_EC_COMMAND_WRITE,
Lennart Poettering00eb43a2007-05-04 14:16:19 +0200324 wdata, 2, NULL, 0, 0);
Denis M. Sadykov3576cf62006-09-26 19:50:33 +0400325}
326
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327/*
328 * Externally callable EC access functions. For now, assume 1 EC only
329 */
Alexey Starikovskiyc45aac42007-03-07 22:28:00 +0300330int ec_burst_enable(void)
331{
Alexey Starikovskiyc45aac42007-03-07 22:28:00 +0300332 if (!first_ec)
333 return -ENODEV;
Alexey Starikovskiyd0338792007-03-07 22:28:00 +0300334 return acpi_ec_burst_enable(first_ec);
Alexey Starikovskiyc45aac42007-03-07 22:28:00 +0300335}
336
337EXPORT_SYMBOL(ec_burst_enable);
338
339int ec_burst_disable(void)
340{
Alexey Starikovskiyc45aac42007-03-07 22:28:00 +0300341 if (!first_ec)
342 return -ENODEV;
Alexey Starikovskiyd0338792007-03-07 22:28:00 +0300343 return acpi_ec_burst_disable(first_ec);
Alexey Starikovskiyc45aac42007-03-07 22:28:00 +0300344}
345
346EXPORT_SYMBOL(ec_burst_disable);
347
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300348int ec_read(u8 addr, u8 * val)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350 int err;
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400351 u8 temp_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352
353 if (!first_ec)
354 return -ENODEV;
355
Alexey Starikovskiyd0338792007-03-07 22:28:00 +0300356 err = acpi_ec_read(first_ec, addr, &temp_data);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700357
358 if (!err) {
359 *val = temp_data;
360 return 0;
Len Brown50526df2005-08-11 17:32:05 -0400361 } else
Linus Torvalds1da177e2005-04-16 15:20:36 -0700362 return err;
363}
Len Brown50526df2005-08-11 17:32:05 -0400364
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365EXPORT_SYMBOL(ec_read);
366
Len Brown50526df2005-08-11 17:32:05 -0400367int ec_write(u8 addr, u8 val)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369 int err;
370
371 if (!first_ec)
372 return -ENODEV;
373
Alexey Starikovskiyd0338792007-03-07 22:28:00 +0300374 err = acpi_ec_write(first_ec, addr, val);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700375
376 return err;
377}
Len Brown50526df2005-08-11 17:32:05 -0400378
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379EXPORT_SYMBOL(ec_write);
380
Randy Dunlap616362d2006-10-27 01:47:34 -0400381int ec_transaction(u8 command,
Alexey Starikovskiy9e197212007-03-07 18:29:35 -0500382 const u8 * wdata, unsigned wdata_len,
Lennart Poettering00eb43a2007-05-04 14:16:19 +0200383 u8 * rdata, unsigned rdata_len,
384 int force_poll)
Luming Yu45bea152005-07-23 04:08:00 -0400385{
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400386 if (!first_ec)
387 return -ENODEV;
388
Alexey Starikovskiyd0338792007-03-07 22:28:00 +0300389 return acpi_ec_transaction(first_ec, command, wdata,
Lennart Poettering00eb43a2007-05-04 14:16:19 +0200390 wdata_len, rdata, rdata_len,
391 force_poll);
Luming Yu45bea152005-07-23 04:08:00 -0400392}
Luming Yu45bea152005-07-23 04:08:00 -0400393
Lennart Poetteringab9e43c2006-10-03 22:49:00 -0400394EXPORT_SYMBOL(ec_transaction);
395
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300396static int acpi_ec_query(struct acpi_ec *ec, u8 * data)
Denis M. Sadykov3576cf62006-09-26 19:50:33 +0400397{
398 int result;
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300399 u8 d;
Luming Yu45bea152005-07-23 04:08:00 -0400400
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300401 if (!ec || !data)
402 return -EINVAL;
Luming Yu45bea152005-07-23 04:08:00 -0400403
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300404 /*
405 * Query the EC to find out which _Qxx method we need to evaluate.
406 * Note that successful completion of the query causes the ACPI_EC_SCI
407 * bit to be cleared (and thus clearing the interrupt source).
408 */
Luming Yu45bea152005-07-23 04:08:00 -0400409
Lennart Poettering00eb43a2007-05-04 14:16:19 +0200410 result = acpi_ec_transaction(ec, ACPI_EC_COMMAND_QUERY, NULL, 0, &d, 1, 0);
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300411 if (result)
412 return result;
Luming Yu45bea152005-07-23 04:08:00 -0400413
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300414 if (!d)
415 return -ENODATA;
Luming Yu45bea152005-07-23 04:08:00 -0400416
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300417 *data = d;
418 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700419}
420
Linus Torvalds1da177e2005-04-16 15:20:36 -0700421/* --------------------------------------------------------------------------
422 Event Management
423 -------------------------------------------------------------------------- */
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400424int acpi_ec_add_query_handler(struct acpi_ec *ec, u8 query_bit,
425 acpi_handle handle, acpi_ec_query_func func,
426 void *data)
427{
428 struct acpi_ec_query_handler *handler =
429 kzalloc(sizeof(struct acpi_ec_query_handler), GFP_KERNEL);
430 if (!handler)
431 return -ENOMEM;
432
433 handler->query_bit = query_bit;
434 handler->handle = handle;
435 handler->func = func;
436 handler->data = data;
437 mutex_lock(&ec->lock);
Alexey Starikovskiy30c08572007-09-26 19:43:22 +0400438 list_add(&handler->node, &ec->list);
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400439 mutex_unlock(&ec->lock);
440 return 0;
441}
442
443EXPORT_SYMBOL_GPL(acpi_ec_add_query_handler);
444
445void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit)
446{
Adrian Bunk1544fdb2007-10-24 18:26:00 +0200447 struct acpi_ec_query_handler *handler, *tmp;
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400448 mutex_lock(&ec->lock);
Adrian Bunk1544fdb2007-10-24 18:26:00 +0200449 list_for_each_entry_safe(handler, tmp, &ec->list, node) {
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400450 if (query_bit == handler->query_bit) {
451 list_del(&handler->node);
452 kfree(handler);
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400453 }
454 }
455 mutex_unlock(&ec->lock);
456}
457
458EXPORT_SYMBOL_GPL(acpi_ec_remove_query_handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700459
Len Brown50526df2005-08-11 17:32:05 -0400460static void acpi_ec_gpe_query(void *ec_cxt)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700461{
Alexey Starikovskiy3d02b902007-03-07 22:28:00 +0300462 struct acpi_ec *ec = ec_cxt;
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400463 u8 value = 0;
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400464 struct acpi_ec_query_handler *handler, copy;
Luming Yu45bea152005-07-23 04:08:00 -0400465
Alexey Starikovskiy5d0c2882006-12-07 18:42:16 +0300466 if (!ec || acpi_ec_query(ec, &value))
Alexey Starikovskiye41334c2006-12-07 18:42:16 +0300467 return;
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400468 mutex_lock(&ec->lock);
469 list_for_each_entry(handler, &ec->list, node) {
470 if (value == handler->query_bit) {
471 /* have custom handler for this bit */
472 memcpy(&copy, handler, sizeof(copy));
473 mutex_unlock(&ec->lock);
474 if (copy.func) {
475 copy.func(copy.data);
476 } else if (copy.handle) {
477 acpi_evaluate_object(copy.handle, NULL, NULL, NULL);
478 }
479 return;
480 }
481 }
482 mutex_unlock(&ec->lock);
Luming Yu45bea152005-07-23 04:08:00 -0400483}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700484
Len Brown50526df2005-08-11 17:32:05 -0400485static u32 acpi_ec_gpe_handler(void *data)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700486{
Len Brown50526df2005-08-11 17:32:05 -0400487 acpi_status status = AE_OK;
Alexey Starikovskiy3d02b902007-03-07 22:28:00 +0300488 struct acpi_ec *ec = data;
Alexey Starikovskiy845625c2008-03-21 17:07:03 +0300489 u8 state = acpi_ec_read_status(ec);
Lennart Poettering00eb43a2007-05-04 14:16:19 +0200490
Márton Németh3ebe08a2007-11-21 03:23:26 +0300491 pr_debug(PREFIX "~~~> interrupt\n");
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400492 clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
Alexey Starikovskiy78439322007-10-22 14:18:43 +0400493 if (test_bit(EC_FLAGS_GPE_MODE, &ec->flags))
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300494 wake_up(&ec->wait);
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500495
Alexey Starikovskiy845625c2008-03-21 17:07:03 +0300496 if (state & ACPI_EC_FLAG_SCI) {
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400497 if (!test_and_set_bit(EC_FLAGS_QUERY_PENDING, &ec->flags))
498 status = acpi_os_execute(OSL_EC_BURST_HANDLER,
499 acpi_ec_gpe_query, ec);
Alexey Starikovskiy845625c2008-03-21 17:07:03 +0300500 } else if (!test_bit(EC_FLAGS_GPE_MODE, &ec->flags) &&
Alexey Starikovskiyb77d81b2008-03-21 17:07:15 +0300501 !test_bit(EC_FLAGS_NO_GPE, &ec->flags) &&
Alexey Starikovskiy845625c2008-03-21 17:07:03 +0300502 in_interrupt()) {
Alexey Starikovskiy95b937e2007-10-22 14:19:03 +0400503 /* this is non-query, must be confirmation */
Márton Németh3ebe08a2007-11-21 03:23:26 +0300504 if (printk_ratelimit())
505 pr_info(PREFIX "non-query interrupt received,"
506 " switching to interrupt mode\n");
Alexey Starikovskiy78439322007-10-22 14:18:43 +0400507 set_bit(EC_FLAGS_GPE_MODE, &ec->flags);
Alexey Starikovskiy845625c2008-03-21 17:07:03 +0300508 clear_bit(EC_FLAGS_RESCHEDULE_POLL, &ec->flags);
Alexey Starikovskiy95b937e2007-10-22 14:19:03 +0400509 }
Alexey Starikovskiy845625c2008-03-21 17:07:03 +0300510 ec_schedule_ec_poll(ec);
Alexey Starikovskiy78439322007-10-22 14:18:43 +0400511 return ACPI_SUCCESS(status) ?
Len Brown50526df2005-08-11 17:32:05 -0400512 ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700513}
514
Alexey Starikovskiy845625c2008-03-21 17:07:03 +0300515static void do_ec_poll(struct work_struct *work)
516{
517 struct acpi_ec *ec = container_of(work, struct acpi_ec, work.work);
518 (void)acpi_ec_gpe_handler(ec);
519}
520
Linus Torvalds1da177e2005-04-16 15:20:36 -0700521/* --------------------------------------------------------------------------
522 Address Space Management
523 -------------------------------------------------------------------------- */
524
525static acpi_status
Len Brown50526df2005-08-11 17:32:05 -0400526acpi_ec_space_setup(acpi_handle region_handle,
527 u32 function, void *handler_context, void **return_context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700528{
529 /*
530 * The EC object is in the handler context and is needed
531 * when calling the acpi_ec_space_handler.
532 */
Len Brown50526df2005-08-11 17:32:05 -0400533 *return_context = (function != ACPI_REGION_DEACTIVATE) ?
534 handler_context : NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700535
536 return AE_OK;
537}
538
Linus Torvalds1da177e2005-04-16 15:20:36 -0700539static acpi_status
Alexey Starikovskiy5b7734b2007-05-29 16:42:52 +0400540acpi_ec_space_handler(u32 function, acpi_physical_address address,
541 u32 bits, acpi_integer *value,
Len Brown50526df2005-08-11 17:32:05 -0400542 void *handler_context, void *region_context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543{
Alexey Starikovskiy3d02b902007-03-07 22:28:00 +0300544 struct acpi_ec *ec = handler_context;
Alexey Starikovskiy3e71a872008-01-11 02:42:51 +0300545 int result = 0, i;
Alexey Starikovskiy5b7734b2007-05-29 16:42:52 +0400546 u8 temp = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700547
Linus Torvalds1da177e2005-04-16 15:20:36 -0700548 if ((address > 0xFF) || !value || !handler_context)
Patrick Mocheld550d982006-06-27 00:41:40 -0400549 return AE_BAD_PARAMETER;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550
Alexey Starikovskiy5b7734b2007-05-29 16:42:52 +0400551 if (function != ACPI_READ && function != ACPI_WRITE)
Patrick Mocheld550d982006-06-27 00:41:40 -0400552 return AE_BAD_PARAMETER;
Alexey Starikovskiy5b7734b2007-05-29 16:42:52 +0400553
554 if (bits != 8 && acpi_strict)
555 return AE_BAD_PARAMETER;
556
Alexey Starikovskiyb3b233c2008-01-11 02:42:57 +0300557 acpi_ec_burst_enable(ec);
558
Alexey Starikovskiy3e71a872008-01-11 02:42:51 +0300559 if (function == ACPI_READ) {
560 result = acpi_ec_read(ec, address, &temp);
561 *value = temp;
562 } else {
563 temp = 0xff & (*value);
564 result = acpi_ec_write(ec, address, temp);
565 }
566
567 for (i = 8; unlikely(bits - i > 0); i += 8) {
568 ++address;
Alexey Starikovskiy5b7734b2007-05-29 16:42:52 +0400569 if (function == ACPI_READ) {
570 result = acpi_ec_read(ec, address, &temp);
571 (*value) |= ((acpi_integer)temp) << i;
572 } else {
573 temp = 0xff & ((*value) >> i);
574 result = acpi_ec_write(ec, address, temp);
575 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700576 }
577
Alexey Starikovskiyb3b233c2008-01-11 02:42:57 +0300578 acpi_ec_burst_disable(ec);
579
Linus Torvalds1da177e2005-04-16 15:20:36 -0700580 switch (result) {
581 case -EINVAL:
Patrick Mocheld550d982006-06-27 00:41:40 -0400582 return AE_BAD_PARAMETER;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700583 break;
584 case -ENODEV:
Patrick Mocheld550d982006-06-27 00:41:40 -0400585 return AE_NOT_FOUND;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700586 break;
587 case -ETIME:
Patrick Mocheld550d982006-06-27 00:41:40 -0400588 return AE_TIME;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700589 break;
590 default:
Patrick Mocheld550d982006-06-27 00:41:40 -0400591 return AE_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700593}
594
Linus Torvalds1da177e2005-04-16 15:20:36 -0700595/* --------------------------------------------------------------------------
596 FS Interface (/proc)
597 -------------------------------------------------------------------------- */
598
Len Brown50526df2005-08-11 17:32:05 -0400599static struct proc_dir_entry *acpi_ec_dir;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700600
Len Brown50526df2005-08-11 17:32:05 -0400601static int acpi_ec_read_info(struct seq_file *seq, void *offset)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700602{
Alexey Starikovskiy3d02b902007-03-07 22:28:00 +0300603 struct acpi_ec *ec = seq->private;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700604
Linus Torvalds1da177e2005-04-16 15:20:36 -0700605 if (!ec)
606 goto end;
607
Alexey Starikovskiy01f224622007-03-07 22:28:00 +0300608 seq_printf(seq, "gpe:\t\t\t0x%02x\n", (u32) ec->gpe);
609 seq_printf(seq, "ports:\t\t\t0x%02x, 0x%02x\n",
610 (unsigned)ec->command_addr, (unsigned)ec->data_addr);
611 seq_printf(seq, "use global lock:\t%s\n",
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400612 ec->global_lock ? "yes" : "no");
Len Brown50526df2005-08-11 17:32:05 -0400613 end:
Patrick Mocheld550d982006-06-27 00:41:40 -0400614 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700615}
616
617static int acpi_ec_info_open_fs(struct inode *inode, struct file *file)
618{
619 return single_open(file, acpi_ec_read_info, PDE(inode)->data);
620}
621
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400622static struct file_operations acpi_ec_info_ops = {
Len Brown50526df2005-08-11 17:32:05 -0400623 .open = acpi_ec_info_open_fs,
624 .read = seq_read,
625 .llseek = seq_lseek,
626 .release = single_release,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700627 .owner = THIS_MODULE,
628};
629
Len Brown50526df2005-08-11 17:32:05 -0400630static int acpi_ec_add_fs(struct acpi_device *device)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700631{
Len Brown50526df2005-08-11 17:32:05 -0400632 struct proc_dir_entry *entry = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700633
Linus Torvalds1da177e2005-04-16 15:20:36 -0700634 if (!acpi_device_dir(device)) {
635 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
Len Brown50526df2005-08-11 17:32:05 -0400636 acpi_ec_dir);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700637 if (!acpi_device_dir(device))
Patrick Mocheld550d982006-06-27 00:41:40 -0400638 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700639 }
640
641 entry = create_proc_entry(ACPI_EC_FILE_INFO, S_IRUGO,
Len Brown50526df2005-08-11 17:32:05 -0400642 acpi_device_dir(device));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700643 if (!entry)
Patrick Mocheld550d982006-06-27 00:41:40 -0400644 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700645 else {
646 entry->proc_fops = &acpi_ec_info_ops;
647 entry->data = acpi_driver_data(device);
648 entry->owner = THIS_MODULE;
649 }
650
Patrick Mocheld550d982006-06-27 00:41:40 -0400651 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700652}
653
Len Brown50526df2005-08-11 17:32:05 -0400654static int acpi_ec_remove_fs(struct acpi_device *device)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700655{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700656
657 if (acpi_device_dir(device)) {
658 remove_proc_entry(ACPI_EC_FILE_INFO, acpi_device_dir(device));
659 remove_proc_entry(acpi_device_bid(device), acpi_ec_dir);
660 acpi_device_dir(device) = NULL;
661 }
662
Patrick Mocheld550d982006-06-27 00:41:40 -0400663 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700664}
665
Linus Torvalds1da177e2005-04-16 15:20:36 -0700666/* --------------------------------------------------------------------------
667 Driver Interface
668 -------------------------------------------------------------------------- */
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300669static acpi_status
670ec_parse_io_ports(struct acpi_resource *resource, void *context);
671
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300672static struct acpi_ec *make_acpi_ec(void)
673{
674 struct acpi_ec *ec = kzalloc(sizeof(struct acpi_ec), GFP_KERNEL);
675 if (!ec)
676 return NULL;
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400677 ec->flags = 1 << EC_FLAGS_QUERY_PENDING;
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300678 mutex_init(&ec->lock);
679 init_waitqueue_head(&ec->wait);
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400680 INIT_LIST_HEAD(&ec->list);
Alexey Starikovskiy845625c2008-03-21 17:07:03 +0300681 INIT_DELAYED_WORK_DEFERRABLE(&ec->work, do_ec_poll);
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300682 return ec;
683}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700684
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400685static acpi_status
Alexey Starikovskiyc019b192007-08-14 01:03:42 -0400686acpi_ec_register_query_methods(acpi_handle handle, u32 level,
687 void *context, void **return_value)
688{
689 struct acpi_namespace_node *node = handle;
690 struct acpi_ec *ec = context;
691 int value = 0;
692 if (sscanf(node->name.ascii, "_Q%x", &value) == 1) {
693 acpi_ec_add_query_handler(ec, value, handle, NULL, NULL);
694 }
695 return AE_OK;
696}
697
698static acpi_status
Alexey Starikovskiycd8c93a2007-08-03 17:52:48 -0400699ec_parse_device(acpi_handle handle, u32 Level, void *context, void **retval)
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400700{
Alexey Starikovskiycd8c93a2007-08-03 17:52:48 -0400701 acpi_status status;
702
703 struct acpi_ec *ec = context;
704 status = acpi_walk_resources(handle, METHOD_NAME__CRS,
705 ec_parse_io_ports, ec);
706 if (ACPI_FAILURE(status))
707 return status;
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400708
709 /* Get GPE bit assignment (EC events). */
710 /* TODO: Add support for _GPE returning a package */
Alexey Starikovskiycd8c93a2007-08-03 17:52:48 -0400711 status = acpi_evaluate_integer(handle, "_GPE", NULL, &ec->gpe);
712 if (ACPI_FAILURE(status))
713 return status;
Alexey Starikovskiyc019b192007-08-14 01:03:42 -0400714 /* Find and register all query methods */
715 acpi_walk_namespace(ACPI_TYPE_METHOD, handle, 1,
716 acpi_ec_register_query_methods, ec, NULL);
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400717 /* Use the global lock for all EC transactions? */
718 acpi_evaluate_integer(handle, "_GLK", NULL, &ec->global_lock);
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400719 ec->handle = handle;
Alexey Starikovskiycd8c93a2007-08-03 17:52:48 -0400720 return AE_CTRL_TERMINATE;
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400721}
722
Alexey Starikovskiy845625c2008-03-21 17:07:03 +0300723static void ec_poll_stop(struct acpi_ec *ec)
724{
725 clear_bit(EC_FLAGS_RESCHEDULE_POLL, &ec->flags);
726 cancel_delayed_work(&ec->work);
727}
728
Alexey Starikovskiy4c611062007-09-05 19:56:38 -0400729static void ec_remove_handlers(struct acpi_ec *ec)
730{
Alexey Starikovskiy845625c2008-03-21 17:07:03 +0300731 ec_poll_stop(ec);
Alexey Starikovskiy4c611062007-09-05 19:56:38 -0400732 if (ACPI_FAILURE(acpi_remove_address_space_handler(ec->handle,
733 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler)))
Márton Németh3ebe08a2007-11-21 03:23:26 +0300734 pr_err(PREFIX "failed to remove space handler\n");
Alexey Starikovskiy4c611062007-09-05 19:56:38 -0400735 if (ACPI_FAILURE(acpi_remove_gpe_handler(NULL, ec->gpe,
736 &acpi_ec_gpe_handler)))
Márton Németh3ebe08a2007-11-21 03:23:26 +0300737 pr_err(PREFIX "failed to remove gpe handler\n");
Alexey Starikovskiy4c611062007-09-05 19:56:38 -0400738 ec->handlers_installed = 0;
739}
740
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400741static int acpi_ec_add(struct acpi_device *device)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700742{
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400743 struct acpi_ec *ec = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700744
Linus Torvalds1da177e2005-04-16 15:20:36 -0700745 if (!device)
Patrick Mocheld550d982006-06-27 00:41:40 -0400746 return -EINVAL;
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300747 strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME);
748 strcpy(acpi_device_class(device), ACPI_EC_CLASS);
749
Alexey Starikovskiy4c611062007-09-05 19:56:38 -0400750 /* Check for boot EC */
751 if (boot_ec) {
752 if (boot_ec->handle == device->handle) {
753 /* Pre-loaded EC from DSDT, just move pointer */
754 ec = boot_ec;
755 boot_ec = NULL;
756 goto end;
757 } else if (boot_ec->handle == ACPI_ROOT_OBJECT) {
758 /* ECDT-based EC, time to shut it down */
759 ec_remove_handlers(boot_ec);
760 kfree(boot_ec);
761 first_ec = boot_ec = NULL;
762 }
763 }
764
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300765 ec = make_acpi_ec();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700766 if (!ec)
Patrick Mocheld550d982006-06-27 00:41:40 -0400767 return -ENOMEM;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700768
Alexey Starikovskiycd8c93a2007-08-03 17:52:48 -0400769 if (ec_parse_device(device->handle, 0, ec, NULL) !=
770 AE_CTRL_TERMINATE) {
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300771 kfree(ec);
772 return -EINVAL;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400773 }
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300774 ec->handle = device->handle;
Alexey Starikovskiy4c611062007-09-05 19:56:38 -0400775 end:
776 if (!first_ec)
777 first_ec = ec;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700778 acpi_driver_data(device) = ec;
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300779 acpi_ec_add_fs(device);
Márton Németh3ebe08a2007-11-21 03:23:26 +0300780 pr_info(PREFIX "GPE = 0x%lx, I/O: command/status = 0x%lx, data = 0x%lx\n",
Alexey Starikovskiy4c611062007-09-05 19:56:38 -0400781 ec->gpe, ec->command_addr, ec->data_addr);
Márton Németh3ebe08a2007-11-21 03:23:26 +0300782 pr_info(PREFIX "driver started in %s mode\n",
Alexey Starikovskiy95b937e2007-10-22 14:19:03 +0400783 (test_bit(EC_FLAGS_GPE_MODE, &ec->flags))?"interrupt":"poll");
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300784 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700785}
786
Len Brown50526df2005-08-11 17:32:05 -0400787static int acpi_ec_remove(struct acpi_device *device, int type)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700788{
Alexey Starikovskiy01f224622007-03-07 22:28:00 +0300789 struct acpi_ec *ec;
Adrian Bunk07ddf762007-07-29 17:00:37 +0200790 struct acpi_ec_query_handler *handler, *tmp;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700791
Linus Torvalds1da177e2005-04-16 15:20:36 -0700792 if (!device)
Patrick Mocheld550d982006-06-27 00:41:40 -0400793 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700794
795 ec = acpi_driver_data(device);
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400796 mutex_lock(&ec->lock);
Adrian Bunk07ddf762007-07-29 17:00:37 +0200797 list_for_each_entry_safe(handler, tmp, &ec->list, node) {
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400798 list_del(&handler->node);
799 kfree(handler);
800 }
801 mutex_unlock(&ec->lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700802 acpi_ec_remove_fs(device);
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300803 acpi_driver_data(device) = NULL;
Alexey Starikovskiyd0338792007-03-07 22:28:00 +0300804 if (ec == first_ec)
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300805 first_ec = NULL;
Alexey Starikovskiy4c611062007-09-05 19:56:38 -0400806 kfree(ec);
Patrick Mocheld550d982006-06-27 00:41:40 -0400807 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700808}
809
Linus Torvalds1da177e2005-04-16 15:20:36 -0700810static acpi_status
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300811ec_parse_io_ports(struct acpi_resource *resource, void *context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700812{
Alexey Starikovskiy3d02b902007-03-07 22:28:00 +0300813 struct acpi_ec *ec = context;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700814
Alexey Starikovskiy01f224622007-03-07 22:28:00 +0300815 if (resource->type != ACPI_RESOURCE_TYPE_IO)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700816 return AE_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700817
818 /*
819 * The first address region returned is the data port, and
820 * the second address region returned is the status/command
821 * port.
822 */
Alexey Starikovskiy01f224622007-03-07 22:28:00 +0300823 if (ec->data_addr == 0)
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400824 ec->data_addr = resource->data.io.minimum;
Alexey Starikovskiy01f224622007-03-07 22:28:00 +0300825 else if (ec->command_addr == 0)
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400826 ec->command_addr = resource->data.io.minimum;
Alexey Starikovskiy01f224622007-03-07 22:28:00 +0300827 else
Linus Torvalds1da177e2005-04-16 15:20:36 -0700828 return AE_CTRL_TERMINATE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700829
Linus Torvalds1da177e2005-04-16 15:20:36 -0700830 return AE_OK;
831}
832
Alexey Starikovskiye8284322007-03-07 22:28:00 +0300833static int ec_install_handlers(struct acpi_ec *ec)
834{
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300835 acpi_status status;
Alexey Starikovskiy4c611062007-09-05 19:56:38 -0400836 if (ec->handlers_installed)
837 return 0;
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300838 status = acpi_install_gpe_handler(NULL, ec->gpe,
839 ACPI_GPE_EDGE_TRIGGERED,
840 &acpi_ec_gpe_handler, ec);
Alexey Starikovskiye8284322007-03-07 22:28:00 +0300841 if (ACPI_FAILURE(status))
842 return -ENODEV;
Alexey Starikovskiy01f224622007-03-07 22:28:00 +0300843
Alexey Starikovskiye8284322007-03-07 22:28:00 +0300844 acpi_set_gpe_type(NULL, ec->gpe, ACPI_GPE_TYPE_RUNTIME);
845 acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR);
846
847 status = acpi_install_address_space_handler(ec->handle,
848 ACPI_ADR_SPACE_EC,
849 &acpi_ec_space_handler,
850 &acpi_ec_space_setup, ec);
851 if (ACPI_FAILURE(status)) {
852 acpi_remove_gpe_handler(NULL, ec->gpe, &acpi_ec_gpe_handler);
853 return -ENODEV;
854 }
855
Alexey Starikovskiy4c611062007-09-05 19:56:38 -0400856 ec->handlers_installed = 1;
Alexey Starikovskiye8284322007-03-07 22:28:00 +0300857 return 0;
858}
859
Len Brown50526df2005-08-11 17:32:05 -0400860static int acpi_ec_start(struct acpi_device *device)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700861{
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300862 struct acpi_ec *ec;
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400863 int ret = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700864
Linus Torvalds1da177e2005-04-16 15:20:36 -0700865 if (!device)
Patrick Mocheld550d982006-06-27 00:41:40 -0400866 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700867
868 ec = acpi_driver_data(device);
869
870 if (!ec)
Patrick Mocheld550d982006-06-27 00:41:40 -0400871 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700872
Alexey Starikovskiy4c611062007-09-05 19:56:38 -0400873 ret = ec_install_handlers(ec);
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300874
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400875 /* EC is fully operational, allow queries */
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400876 clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags);
Alexey Starikovskiy845625c2008-03-21 17:07:03 +0300877 ec_schedule_ec_poll(ec);
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400878 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700879}
880
Len Brown50526df2005-08-11 17:32:05 -0400881static int acpi_ec_stop(struct acpi_device *device, int type)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700882{
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300883 struct acpi_ec *ec;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700884 if (!device)
Patrick Mocheld550d982006-06-27 00:41:40 -0400885 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700886 ec = acpi_driver_data(device);
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300887 if (!ec)
888 return -EINVAL;
Alexey Starikovskiy4c611062007-09-05 19:56:38 -0400889 ec_remove_handlers(ec);
Alexey Starikovskiyf9319f92007-08-24 08:10:11 +0400890
Patrick Mocheld550d982006-06-27 00:41:40 -0400891 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700892}
893
Alexey Starikovskiyc04209a2008-01-01 14:12:55 -0500894int __init acpi_boot_ec_enable(void)
895{
896 if (!boot_ec || boot_ec->handlers_installed)
897 return 0;
898 if (!ec_install_handlers(boot_ec)) {
899 first_ec = boot_ec;
900 return 0;
901 }
902 return -EFAULT;
903}
904
Alexey Starikovskiy223883b2008-03-21 17:07:21 +0300905static const struct acpi_device_id ec_device_ids[] = {
906 {"PNP0C09", 0},
907 {"", 0},
908};
909
Len Brown50526df2005-08-11 17:32:05 -0400910int __init acpi_ec_ecdt_probe(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700911{
Len Brown50526df2005-08-11 17:32:05 -0400912 int ret;
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300913 acpi_status status;
914 struct acpi_table_ecdt *ecdt_ptr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700915
Alexey Starikovskiyd66d9692007-03-07 22:28:00 +0300916 boot_ec = make_acpi_ec();
917 if (!boot_ec)
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300918 return -ENOMEM;
919 /*
920 * Generate a boot ec context
921 */
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300922 status = acpi_get_table(ACPI_SIG_ECDT, 1,
923 (struct acpi_table_header **)&ecdt_ptr);
Alexey Starikovskiycd8c93a2007-08-03 17:52:48 -0400924 if (ACPI_SUCCESS(status)) {
Márton Németh3ebe08a2007-11-21 03:23:26 +0300925 pr_info(PREFIX "EC description table is found, configuring boot EC\n");
Alexey Starikovskiycd8c93a2007-08-03 17:52:48 -0400926 boot_ec->command_addr = ecdt_ptr->control.address;
927 boot_ec->data_addr = ecdt_ptr->data.address;
928 boot_ec->gpe = ecdt_ptr->gpe;
Len Brown4af8e102008-03-11 00:27:16 -0400929 boot_ec->handle = ACPI_ROOT_OBJECT;
Alexey Starikovskiycd8c93a2007-08-03 17:52:48 -0400930 } else {
Alexey Starikovskiy5870a8c2007-11-15 21:52:47 +0300931 /* This workaround is needed only on some broken machines,
932 * which require early EC, but fail to provide ECDT */
933 acpi_handle x;
Alexey Starikovskiycd8c93a2007-08-03 17:52:48 -0400934 printk(KERN_DEBUG PREFIX "Look up EC in DSDT\n");
935 status = acpi_get_devices(ec_device_ids[0].id, ec_parse_device,
936 boot_ec, NULL);
Alexey Starikovskiy2d8348b2007-08-31 09:05:26 +0400937 /* Check that acpi_get_devices actually find something */
938 if (ACPI_FAILURE(status) || !boot_ec->handle)
Alexey Starikovskiycd8c93a2007-08-03 17:52:48 -0400939 goto error;
Alexey Starikovskiy5870a8c2007-11-15 21:52:47 +0300940 /* We really need to limit this workaround, the only ASUS,
941 * which needs it, has fake EC._INI method, so use it as flag.
Alexey Starikovskiyc04209a2008-01-01 14:12:55 -0500942 * Keep boot_ec struct as it will be needed soon.
Alexey Starikovskiy5870a8c2007-11-15 21:52:47 +0300943 */
944 if (ACPI_FAILURE(acpi_get_handle(boot_ec->handle, "_INI", &x)))
Alexey Starikovskiyc04209a2008-01-01 14:12:55 -0500945 return -ENODEV;
Alexey Starikovskiycd8c93a2007-08-03 17:52:48 -0400946 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700947
Alexey Starikovskiyd66d9692007-03-07 22:28:00 +0300948 ret = ec_install_handlers(boot_ec);
Alexey Starikovskiyd0338792007-03-07 22:28:00 +0300949 if (!ret) {
950 first_ec = boot_ec;
Alexey Starikovskiye8284322007-03-07 22:28:00 +0300951 return 0;
Alexey Starikovskiyd0338792007-03-07 22:28:00 +0300952 }
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300953 error:
Alexey Starikovskiyd66d9692007-03-07 22:28:00 +0300954 kfree(boot_ec);
955 boot_ec = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700956 return -ENODEV;
957}
958
Alexey Starikovskiy223883b2008-03-21 17:07:21 +0300959static int acpi_ec_suspend(struct acpi_device *device, pm_message_t state)
960{
961 struct acpi_ec *ec = acpi_driver_data(device);
962 /* Stop using GPE */
963 set_bit(EC_FLAGS_NO_GPE, &ec->flags);
964 clear_bit(EC_FLAGS_GPE_MODE, &ec->flags);
965 acpi_disable_gpe(NULL, ec->gpe, ACPI_NOT_ISR);
966 return 0;
967}
968
969static int acpi_ec_resume(struct acpi_device *device)
970{
971 struct acpi_ec *ec = acpi_driver_data(device);
972 /* Enable use of GPE back */
973 clear_bit(EC_FLAGS_NO_GPE, &ec->flags);
974 acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR);
975 return 0;
976}
977
978static struct acpi_driver acpi_ec_driver = {
979 .name = "ec",
980 .class = ACPI_EC_CLASS,
981 .ids = ec_device_ids,
982 .ops = {
983 .add = acpi_ec_add,
984 .remove = acpi_ec_remove,
985 .start = acpi_ec_start,
986 .stop = acpi_ec_stop,
987 .suspend = acpi_ec_suspend,
988 .resume = acpi_ec_resume,
989 },
990};
991
Len Brown50526df2005-08-11 17:32:05 -0400992static int __init acpi_ec_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700993{
Len Brown50526df2005-08-11 17:32:05 -0400994 int result = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700995
Linus Torvalds1da177e2005-04-16 15:20:36 -0700996 if (acpi_disabled)
Patrick Mocheld550d982006-06-27 00:41:40 -0400997 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700998
999 acpi_ec_dir = proc_mkdir(ACPI_EC_CLASS, acpi_root_dir);
1000 if (!acpi_ec_dir)
Patrick Mocheld550d982006-06-27 00:41:40 -04001001 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001002
1003 /* Now register the driver for the EC */
1004 result = acpi_bus_register_driver(&acpi_ec_driver);
1005 if (result < 0) {
1006 remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir);
Patrick Mocheld550d982006-06-27 00:41:40 -04001007 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001008 }
1009
Patrick Mocheld550d982006-06-27 00:41:40 -04001010 return result;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001011}
1012
1013subsys_initcall(acpi_ec_init);
1014
1015/* EC driver currently not unloadable */
1016#if 0
Len Brown50526df2005-08-11 17:32:05 -04001017static void __exit acpi_ec_exit(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001018{
Linus Torvalds1da177e2005-04-16 15:20:36 -07001019
1020 acpi_bus_unregister_driver(&acpi_ec_driver);
1021
1022 remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir);
1023
Patrick Mocheld550d982006-06-27 00:41:40 -04001024 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001025}
Alexey Starikovskiy78439322007-10-22 14:18:43 +04001026#endif /* 0 */