blob: 7f07b6806ac073211aa2f8ade85196eeeb2da7b9 [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
Len Brown50526df2005-08-11 17:32:05 -040086static int acpi_ec_remove(struct acpi_device *device, int type);
87static int acpi_ec_start(struct acpi_device *device);
88static int acpi_ec_stop(struct acpi_device *device, int type);
Denis M. Sadykov703959d2006-09-26 19:50:33 +040089static int acpi_ec_add(struct acpi_device *device);
Linus Torvalds1da177e2005-04-16 15:20:36 -070090
Thomas Renninger1ba90e32007-07-23 14:44:41 +020091static const struct acpi_device_id ec_device_ids[] = {
92 {"PNP0C09", 0},
93 {"", 0},
94};
95
Linus Torvalds1da177e2005-04-16 15:20:36 -070096static struct acpi_driver acpi_ec_driver = {
Len Brownc2b67052007-02-12 23:33:40 -050097 .name = "ec",
Len Brown50526df2005-08-11 17:32:05 -040098 .class = ACPI_EC_CLASS,
Thomas Renninger1ba90e32007-07-23 14:44:41 +020099 .ids = ec_device_ids,
Len Brown50526df2005-08-11 17:32:05 -0400100 .ops = {
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400101 .add = acpi_ec_add,
Len Brown50526df2005-08-11 17:32:05 -0400102 .remove = acpi_ec_remove,
103 .start = acpi_ec_start,
104 .stop = acpi_ec_stop,
105 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106};
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400107
108/* If we find an EC via the ECDT, we need to keep a ptr to its context */
Alexey Starikovskiyd0338792007-03-07 22:28:00 +0300109/* External interfaces use first EC only, so remember */
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400110typedef int (*acpi_ec_query_func) (void *data);
111
112struct acpi_ec_query_handler {
113 struct list_head node;
114 acpi_ec_query_func func;
115 acpi_handle handle;
116 void *data;
117 u8 query_bit;
118};
119
Adrian Bunka854e082006-12-19 12:56:12 -0800120static struct acpi_ec {
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400121 acpi_handle handle;
Alexey Starikovskiya86e2772006-12-07 18:42:16 +0300122 unsigned long gpe;
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400123 unsigned long command_addr;
124 unsigned long data_addr;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400125 unsigned long global_lock;
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400126 unsigned long flags;
Alexey Starikovskiyc787a852006-12-07 18:42:16 +0300127 struct mutex lock;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400128 wait_queue_head_t wait;
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400129 struct list_head list;
Alexey Starikovskiy845625c2008-03-21 17:07:03 +0300130 struct delayed_work work;
Alexey Starikovskiy4c611062007-09-05 19:56:38 -0400131 u8 handlers_installed;
Alexey Starikovskiyd0338792007-03-07 22:28:00 +0300132} *boot_ec, *first_ec;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400133
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134/* --------------------------------------------------------------------------
135 Transaction Management
136 -------------------------------------------------------------------------- */
137
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400138static inline u8 acpi_ec_read_status(struct acpi_ec *ec)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139{
Márton Németh3ebe08a2007-11-21 03:23:26 +0300140 u8 x = inb(ec->command_addr);
Márton Németh86dae012008-01-23 22:33:06 -0500141 pr_debug(PREFIX "---> status = 0x%2.2x\n", x);
Márton Németh3ebe08a2007-11-21 03:23:26 +0300142 return x;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143}
144
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400145static inline u8 acpi_ec_read_data(struct acpi_ec *ec)
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400146{
Márton Németh3ebe08a2007-11-21 03:23:26 +0300147 u8 x = inb(ec->data_addr);
Márton Németh86dae012008-01-23 22:33:06 -0500148 pr_debug(PREFIX "---> data = 0x%2.2x\n", x);
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400149 return inb(ec->data_addr);
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400150}
151
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400152static inline void acpi_ec_write_cmd(struct acpi_ec *ec, u8 command)
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400153{
Márton Németh86dae012008-01-23 22:33:06 -0500154 pr_debug(PREFIX "<--- command = 0x%2.2x\n", command);
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400155 outb(command, ec->command_addr);
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400156}
157
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400158static inline void acpi_ec_write_data(struct acpi_ec *ec, u8 data)
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400159{
Márton Németh86dae012008-01-23 22:33:06 -0500160 pr_debug(PREFIX "<--- data = 0x%2.2x\n", data);
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400161 outb(data, ec->data_addr);
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400162}
163
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400164static inline int acpi_ec_check_status(struct acpi_ec *ec, enum ec_event event)
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400165{
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400166 if (test_bit(EC_FLAGS_WAIT_GPE, &ec->flags))
Alexey Starikovskiy9e197212007-03-07 18:29:35 -0500167 return 0;
Alexey Starikovskiy78d0af32006-12-07 18:42:17 +0300168 if (event == ACPI_EC_EVENT_OBF_1) {
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400169 if (acpi_ec_read_status(ec) & ACPI_EC_FLAG_OBF)
Denis M. Sadykov7c6db5e2006-09-26 19:50:33 +0400170 return 1;
Alexey Starikovskiy78d0af32006-12-07 18:42:17 +0300171 } else if (event == ACPI_EC_EVENT_IBF_0) {
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400172 if (!(acpi_ec_read_status(ec) & ACPI_EC_FLAG_IBF))
Denis M. Sadykov7c6db5e2006-09-26 19:50:33 +0400173 return 1;
Denis M. Sadykov7c6db5e2006-09-26 19:50:33 +0400174 }
175
176 return 0;
177}
178
Alexey Starikovskiy845625c2008-03-21 17:07:03 +0300179static void ec_schedule_ec_poll(struct acpi_ec *ec)
180{
181 if (test_bit(EC_FLAGS_RESCHEDULE_POLL, &ec->flags))
182 schedule_delayed_work(&ec->work,
183 msecs_to_jiffies(ACPI_EC_DELAY));
184}
185
186static void ec_switch_to_poll_mode(struct acpi_ec *ec)
187{
Alexey Starikovskiyb77d81b2008-03-21 17:07:15 +0300188 set_bit(EC_FLAGS_NO_GPE, &ec->flags);
Alexey Starikovskiy845625c2008-03-21 17:07:03 +0300189 clear_bit(EC_FLAGS_GPE_MODE, &ec->flags);
190 acpi_disable_gpe(NULL, ec->gpe, ACPI_NOT_ISR);
191 set_bit(EC_FLAGS_RESCHEDULE_POLL, &ec->flags);
192}
193
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400194static int acpi_ec_wait(struct acpi_ec *ec, enum ec_event event, int force_poll)
Luming Yu45bea152005-07-23 04:08:00 -0400195{
Alexey Starikovskiy78439322007-10-22 14:18:43 +0400196 if (likely(test_bit(EC_FLAGS_GPE_MODE, &ec->flags)) &&
197 likely(!force_poll)) {
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400198 if (wait_event_timeout(ec->wait, acpi_ec_check_status(ec, event),
199 msecs_to_jiffies(ACPI_EC_DELAY)))
Alexey Starikovskiyb77d81b2008-03-21 17:07:15 +0300200 return 0;
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400201 clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
202 if (acpi_ec_check_status(ec, event)) {
Alexey Starikovskiyb77d81b2008-03-21 17:07:15 +0300203 /* missing GPEs, switch back to poll mode */
204 if (printk_ratelimit())
205 pr_info(PREFIX "missing confirmations, "
Márton Németh3ebe08a2007-11-21 03:23:26 +0300206 "switch off interrupt mode.\n");
Alexey Starikovskiyb77d81b2008-03-21 17:07:15 +0300207 ec_switch_to_poll_mode(ec);
208 ec_schedule_ec_poll(ec);
209 return 0;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400210 }
Alexey Starikovskiy78439322007-10-22 14:18:43 +0400211 } else {
212 unsigned long delay = jiffies + msecs_to_jiffies(ACPI_EC_DELAY);
213 clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
214 while (time_before(jiffies, delay)) {
215 if (acpi_ec_check_status(ec, event))
Alexey Starikovskiyb77d81b2008-03-21 17:07:15 +0300216 return 0;
Alexey Starikovskiye6e82a32008-03-21 17:06:57 +0300217 udelay(ACPI_EC_UDELAY);
Alexey Starikovskiy78439322007-10-22 14:18:43 +0400218 }
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300219 }
Alexey Starikovskiydc0e8492008-03-21 17:07:09 +0300220 pr_err(PREFIX "acpi_ec_wait timeout, status = 0x%2.2x, event = %s\n",
221 acpi_ec_read_status(ec),
222 (event == ACPI_EC_EVENT_OBF_1) ? "\"b0=1\"" : "\"b1=0\"");
Alexey Starikovskiyb77d81b2008-03-21 17:07:15 +0300223 return -ETIME;
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500224}
225
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400226static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command,
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300227 const u8 * wdata, unsigned wdata_len,
Lennart Poettering00eb43a2007-05-04 14:16:19 +0200228 u8 * rdata, unsigned rdata_len,
229 int force_poll)
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400230{
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300231 int result = 0;
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400232 set_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
Márton Németh3ebe08a2007-11-21 03:23:26 +0300233 pr_debug(PREFIX "transaction start\n");
Alexey Starikovskiydc0e8492008-03-21 17:07:09 +0300234 acpi_ec_write_cmd(ec, command);
Alexey Starikovskiy78d0af32006-12-07 18:42:17 +0300235 for (; wdata_len > 0; --wdata_len) {
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400236 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, force_poll);
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300237 if (result) {
Márton Németh3ebe08a2007-11-21 03:23:26 +0300238 pr_err(PREFIX
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300239 "write_cmd timeout, command = %d\n", command);
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300240 goto end;
241 }
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400242 set_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400243 acpi_ec_write_data(ec, *(wdata++));
Denis M. Sadykov3576cf62006-09-26 19:50:33 +0400244 }
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400245
Alexey Starikovskiyd91df1a2006-12-07 18:42:16 +0300246 if (!rdata_len) {
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400247 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, force_poll);
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300248 if (result) {
Márton Németh3ebe08a2007-11-21 03:23:26 +0300249 pr_err(PREFIX
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300250 "finish-write timeout, command = %d\n", command);
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300251 goto end;
252 }
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400253 } else if (command == ACPI_EC_COMMAND_QUERY)
254 clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags);
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400255
Alexey Starikovskiy78d0af32006-12-07 18:42:17 +0300256 for (; rdata_len > 0; --rdata_len) {
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400257 result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1, force_poll);
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300258 if (result) {
Márton Németh3ebe08a2007-11-21 03:23:26 +0300259 pr_err(PREFIX "read timeout, command = %d\n", command);
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300260 goto end;
261 }
Alexey Starikovskiy0c5d31f2007-10-22 14:18:36 +0400262 /* Don't expect GPE after last read */
263 if (rdata_len > 1)
264 set_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400265 *(rdata++) = acpi_ec_read_data(ec);
Denis M. Sadykov7c6db5e2006-09-26 19:50:33 +0400266 }
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300267 end:
Márton Németh3ebe08a2007-11-21 03:23:26 +0300268 pr_debug(PREFIX "transaction end\n");
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300269 return result;
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400270}
271
Denis M. Sadykov3576cf62006-09-26 19:50:33 +0400272static int acpi_ec_transaction(struct acpi_ec *ec, u8 command,
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300273 const u8 * wdata, unsigned wdata_len,
Lennart Poettering00eb43a2007-05-04 14:16:19 +0200274 u8 * rdata, unsigned rdata_len,
275 int force_poll)
Luming Yu45bea152005-07-23 04:08:00 -0400276{
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400277 int status;
Len Brown50526df2005-08-11 17:32:05 -0400278 u32 glk;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400280 if (!ec || (wdata_len && !wdata) || (rdata_len && !rdata))
Patrick Mocheld550d982006-06-27 00:41:40 -0400281 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300283 if (rdata)
284 memset(rdata, 0, rdata_len);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285
Alexey Starikovskiy523953b2006-12-07 18:42:17 +0300286 mutex_lock(&ec->lock);
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400287 if (ec->global_lock) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
Alexey Starikovskiyc24e9122007-02-15 23:16:18 +0300289 if (ACPI_FAILURE(status)) {
290 mutex_unlock(&ec->lock);
Patrick Mocheld550d982006-06-27 00:41:40 -0400291 return -ENODEV;
Alexey Starikovskiyc24e9122007-02-15 23:16:18 +0300292 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700293 }
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500294
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400295 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, 0);
Luming Yu716e0842005-08-10 01:40:00 -0400296 if (status) {
Márton Németh3ebe08a2007-11-21 03:23:26 +0300297 pr_err(PREFIX "input buffer is not empty, "
298 "aborting transaction\n");
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500299 goto end;
Luming Yu716e0842005-08-10 01:40:00 -0400300 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300302 status = acpi_ec_transaction_unlocked(ec, command,
303 wdata, wdata_len,
Lennart Poettering00eb43a2007-05-04 14:16:19 +0200304 rdata, rdata_len,
305 force_poll);
Len Brown50526df2005-08-11 17:32:05 -0400306
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300307 end:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400309 if (ec->global_lock)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700310 acpi_release_global_lock(glk);
Alexey Starikovskiy523953b2006-12-07 18:42:17 +0300311 mutex_unlock(&ec->lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312
Patrick Mocheld550d982006-06-27 00:41:40 -0400313 return status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314}
315
Alexey Starikovskiyc45aac42007-03-07 22:28:00 +0300316/*
317 * Note: samsung nv5000 doesn't work with ec burst mode.
318 * http://bugzilla.kernel.org/show_bug.cgi?id=4980
319 */
320int acpi_ec_burst_enable(struct acpi_ec *ec)
321{
322 u8 d;
Lennart Poettering00eb43a2007-05-04 14:16:19 +0200323 return acpi_ec_transaction(ec, ACPI_EC_BURST_ENABLE, NULL, 0, &d, 1, 0);
Alexey Starikovskiyc45aac42007-03-07 22:28:00 +0300324}
325
326int acpi_ec_burst_disable(struct acpi_ec *ec)
327{
Lennart Poettering00eb43a2007-05-04 14:16:19 +0200328 return acpi_ec_transaction(ec, ACPI_EC_BURST_DISABLE, NULL, 0, NULL, 0, 0);
Alexey Starikovskiyc45aac42007-03-07 22:28:00 +0300329}
330
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300331static int acpi_ec_read(struct acpi_ec *ec, u8 address, u8 * data)
Denis M. Sadykov3576cf62006-09-26 19:50:33 +0400332{
333 int result;
334 u8 d;
335
336 result = acpi_ec_transaction(ec, ACPI_EC_COMMAND_READ,
Lennart Poettering00eb43a2007-05-04 14:16:19 +0200337 &address, 1, &d, 1, 0);
Denis M. Sadykov3576cf62006-09-26 19:50:33 +0400338 *data = d;
339 return result;
340}
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400341
Denis M. Sadykov3576cf62006-09-26 19:50:33 +0400342static int acpi_ec_write(struct acpi_ec *ec, u8 address, u8 data)
343{
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300344 u8 wdata[2] = { address, data };
345 return acpi_ec_transaction(ec, ACPI_EC_COMMAND_WRITE,
Lennart Poettering00eb43a2007-05-04 14:16:19 +0200346 wdata, 2, NULL, 0, 0);
Denis M. Sadykov3576cf62006-09-26 19:50:33 +0400347}
348
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349/*
350 * Externally callable EC access functions. For now, assume 1 EC only
351 */
Alexey Starikovskiyc45aac42007-03-07 22:28:00 +0300352int ec_burst_enable(void)
353{
Alexey Starikovskiyc45aac42007-03-07 22:28:00 +0300354 if (!first_ec)
355 return -ENODEV;
Alexey Starikovskiyd0338792007-03-07 22:28:00 +0300356 return acpi_ec_burst_enable(first_ec);
Alexey Starikovskiyc45aac42007-03-07 22:28:00 +0300357}
358
359EXPORT_SYMBOL(ec_burst_enable);
360
361int ec_burst_disable(void)
362{
Alexey Starikovskiyc45aac42007-03-07 22:28:00 +0300363 if (!first_ec)
364 return -ENODEV;
Alexey Starikovskiyd0338792007-03-07 22:28:00 +0300365 return acpi_ec_burst_disable(first_ec);
Alexey Starikovskiyc45aac42007-03-07 22:28:00 +0300366}
367
368EXPORT_SYMBOL(ec_burst_disable);
369
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300370int ec_read(u8 addr, u8 * val)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700372 int err;
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400373 u8 temp_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700374
375 if (!first_ec)
376 return -ENODEV;
377
Alexey Starikovskiyd0338792007-03-07 22:28:00 +0300378 err = acpi_ec_read(first_ec, addr, &temp_data);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379
380 if (!err) {
381 *val = temp_data;
382 return 0;
Len Brown50526df2005-08-11 17:32:05 -0400383 } else
Linus Torvalds1da177e2005-04-16 15:20:36 -0700384 return err;
385}
Len Brown50526df2005-08-11 17:32:05 -0400386
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387EXPORT_SYMBOL(ec_read);
388
Len Brown50526df2005-08-11 17:32:05 -0400389int ec_write(u8 addr, u8 val)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391 int err;
392
393 if (!first_ec)
394 return -ENODEV;
395
Alexey Starikovskiyd0338792007-03-07 22:28:00 +0300396 err = acpi_ec_write(first_ec, addr, val);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700397
398 return err;
399}
Len Brown50526df2005-08-11 17:32:05 -0400400
Linus Torvalds1da177e2005-04-16 15:20:36 -0700401EXPORT_SYMBOL(ec_write);
402
Randy Dunlap616362d2006-10-27 01:47:34 -0400403int ec_transaction(u8 command,
Alexey Starikovskiy9e197212007-03-07 18:29:35 -0500404 const u8 * wdata, unsigned wdata_len,
Lennart Poettering00eb43a2007-05-04 14:16:19 +0200405 u8 * rdata, unsigned rdata_len,
406 int force_poll)
Luming Yu45bea152005-07-23 04:08:00 -0400407{
Lennart Poetteringd7a76e42006-09-05 12:12:24 -0400408 if (!first_ec)
409 return -ENODEV;
410
Alexey Starikovskiyd0338792007-03-07 22:28:00 +0300411 return acpi_ec_transaction(first_ec, command, wdata,
Lennart Poettering00eb43a2007-05-04 14:16:19 +0200412 wdata_len, rdata, rdata_len,
413 force_poll);
Luming Yu45bea152005-07-23 04:08:00 -0400414}
Luming Yu45bea152005-07-23 04:08:00 -0400415
Lennart Poetteringab9e43c2006-10-03 22:49:00 -0400416EXPORT_SYMBOL(ec_transaction);
417
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300418static int acpi_ec_query(struct acpi_ec *ec, u8 * data)
Denis M. Sadykov3576cf62006-09-26 19:50:33 +0400419{
420 int result;
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300421 u8 d;
Luming Yu45bea152005-07-23 04:08:00 -0400422
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300423 if (!ec || !data)
424 return -EINVAL;
Luming Yu45bea152005-07-23 04:08:00 -0400425
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300426 /*
427 * Query the EC to find out which _Qxx method we need to evaluate.
428 * Note that successful completion of the query causes the ACPI_EC_SCI
429 * bit to be cleared (and thus clearing the interrupt source).
430 */
Luming Yu45bea152005-07-23 04:08:00 -0400431
Lennart Poettering00eb43a2007-05-04 14:16:19 +0200432 result = acpi_ec_transaction(ec, ACPI_EC_COMMAND_QUERY, NULL, 0, &d, 1, 0);
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300433 if (result)
434 return result;
Luming Yu45bea152005-07-23 04:08:00 -0400435
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300436 if (!d)
437 return -ENODATA;
Luming Yu45bea152005-07-23 04:08:00 -0400438
Alexey Starikovskiy6ccedb12006-12-07 18:42:17 +0300439 *data = d;
440 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441}
442
Linus Torvalds1da177e2005-04-16 15:20:36 -0700443/* --------------------------------------------------------------------------
444 Event Management
445 -------------------------------------------------------------------------- */
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400446int acpi_ec_add_query_handler(struct acpi_ec *ec, u8 query_bit,
447 acpi_handle handle, acpi_ec_query_func func,
448 void *data)
449{
450 struct acpi_ec_query_handler *handler =
451 kzalloc(sizeof(struct acpi_ec_query_handler), GFP_KERNEL);
452 if (!handler)
453 return -ENOMEM;
454
455 handler->query_bit = query_bit;
456 handler->handle = handle;
457 handler->func = func;
458 handler->data = data;
459 mutex_lock(&ec->lock);
Alexey Starikovskiy30c08572007-09-26 19:43:22 +0400460 list_add(&handler->node, &ec->list);
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400461 mutex_unlock(&ec->lock);
462 return 0;
463}
464
465EXPORT_SYMBOL_GPL(acpi_ec_add_query_handler);
466
467void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit)
468{
Adrian Bunk1544fdb2007-10-24 18:26:00 +0200469 struct acpi_ec_query_handler *handler, *tmp;
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400470 mutex_lock(&ec->lock);
Adrian Bunk1544fdb2007-10-24 18:26:00 +0200471 list_for_each_entry_safe(handler, tmp, &ec->list, node) {
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400472 if (query_bit == handler->query_bit) {
473 list_del(&handler->node);
474 kfree(handler);
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400475 }
476 }
477 mutex_unlock(&ec->lock);
478}
479
480EXPORT_SYMBOL_GPL(acpi_ec_remove_query_handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700481
Len Brown50526df2005-08-11 17:32:05 -0400482static void acpi_ec_gpe_query(void *ec_cxt)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700483{
Alexey Starikovskiy3d02b902007-03-07 22:28:00 +0300484 struct acpi_ec *ec = ec_cxt;
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400485 u8 value = 0;
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400486 struct acpi_ec_query_handler *handler, copy;
Luming Yu45bea152005-07-23 04:08:00 -0400487
Alexey Starikovskiy5d0c2882006-12-07 18:42:16 +0300488 if (!ec || acpi_ec_query(ec, &value))
Alexey Starikovskiye41334c2006-12-07 18:42:16 +0300489 return;
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400490 mutex_lock(&ec->lock);
491 list_for_each_entry(handler, &ec->list, node) {
492 if (value == handler->query_bit) {
493 /* have custom handler for this bit */
494 memcpy(&copy, handler, sizeof(copy));
495 mutex_unlock(&ec->lock);
496 if (copy.func) {
497 copy.func(copy.data);
498 } else if (copy.handle) {
499 acpi_evaluate_object(copy.handle, NULL, NULL, NULL);
500 }
501 return;
502 }
503 }
504 mutex_unlock(&ec->lock);
Luming Yu45bea152005-07-23 04:08:00 -0400505}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700506
Len Brown50526df2005-08-11 17:32:05 -0400507static u32 acpi_ec_gpe_handler(void *data)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700508{
Len Brown50526df2005-08-11 17:32:05 -0400509 acpi_status status = AE_OK;
Alexey Starikovskiy3d02b902007-03-07 22:28:00 +0300510 struct acpi_ec *ec = data;
Alexey Starikovskiy845625c2008-03-21 17:07:03 +0300511 u8 state = acpi_ec_read_status(ec);
Lennart Poettering00eb43a2007-05-04 14:16:19 +0200512
Márton Németh3ebe08a2007-11-21 03:23:26 +0300513 pr_debug(PREFIX "~~~> interrupt\n");
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400514 clear_bit(EC_FLAGS_WAIT_GPE, &ec->flags);
Alexey Starikovskiy78439322007-10-22 14:18:43 +0400515 if (test_bit(EC_FLAGS_GPE_MODE, &ec->flags))
Alexey Starikovskiyaf3fd142006-12-07 18:42:16 +0300516 wake_up(&ec->wait);
Dmitry Torokhov451566f2005-03-19 01:10:05 -0500517
Alexey Starikovskiy845625c2008-03-21 17:07:03 +0300518 if (state & ACPI_EC_FLAG_SCI) {
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400519 if (!test_and_set_bit(EC_FLAGS_QUERY_PENDING, &ec->flags))
520 status = acpi_os_execute(OSL_EC_BURST_HANDLER,
521 acpi_ec_gpe_query, ec);
Alexey Starikovskiy845625c2008-03-21 17:07:03 +0300522 } else if (!test_bit(EC_FLAGS_GPE_MODE, &ec->flags) &&
Alexey Starikovskiyb77d81b2008-03-21 17:07:15 +0300523 !test_bit(EC_FLAGS_NO_GPE, &ec->flags) &&
Alexey Starikovskiy845625c2008-03-21 17:07:03 +0300524 in_interrupt()) {
Alexey Starikovskiy95b937e2007-10-22 14:19:03 +0400525 /* this is non-query, must be confirmation */
Márton Németh3ebe08a2007-11-21 03:23:26 +0300526 if (printk_ratelimit())
527 pr_info(PREFIX "non-query interrupt received,"
528 " switching to interrupt mode\n");
Alexey Starikovskiy78439322007-10-22 14:18:43 +0400529 set_bit(EC_FLAGS_GPE_MODE, &ec->flags);
Alexey Starikovskiy845625c2008-03-21 17:07:03 +0300530 clear_bit(EC_FLAGS_RESCHEDULE_POLL, &ec->flags);
Alexey Starikovskiy95b937e2007-10-22 14:19:03 +0400531 }
Alexey Starikovskiy845625c2008-03-21 17:07:03 +0300532 ec_schedule_ec_poll(ec);
Alexey Starikovskiy78439322007-10-22 14:18:43 +0400533 return ACPI_SUCCESS(status) ?
Len Brown50526df2005-08-11 17:32:05 -0400534 ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700535}
536
Alexey Starikovskiy845625c2008-03-21 17:07:03 +0300537static void do_ec_poll(struct work_struct *work)
538{
539 struct acpi_ec *ec = container_of(work, struct acpi_ec, work.work);
540 (void)acpi_ec_gpe_handler(ec);
541}
542
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543/* --------------------------------------------------------------------------
544 Address Space Management
545 -------------------------------------------------------------------------- */
546
547static acpi_status
Len Brown50526df2005-08-11 17:32:05 -0400548acpi_ec_space_setup(acpi_handle region_handle,
549 u32 function, void *handler_context, void **return_context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550{
551 /*
552 * The EC object is in the handler context and is needed
553 * when calling the acpi_ec_space_handler.
554 */
Len Brown50526df2005-08-11 17:32:05 -0400555 *return_context = (function != ACPI_REGION_DEACTIVATE) ?
556 handler_context : NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700557
558 return AE_OK;
559}
560
Linus Torvalds1da177e2005-04-16 15:20:36 -0700561static acpi_status
Alexey Starikovskiy5b7734b2007-05-29 16:42:52 +0400562acpi_ec_space_handler(u32 function, acpi_physical_address address,
563 u32 bits, acpi_integer *value,
Len Brown50526df2005-08-11 17:32:05 -0400564 void *handler_context, void *region_context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700565{
Alexey Starikovskiy3d02b902007-03-07 22:28:00 +0300566 struct acpi_ec *ec = handler_context;
Alexey Starikovskiy3e71a872008-01-11 02:42:51 +0300567 int result = 0, i;
Alexey Starikovskiy5b7734b2007-05-29 16:42:52 +0400568 u8 temp = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700569
Linus Torvalds1da177e2005-04-16 15:20:36 -0700570 if ((address > 0xFF) || !value || !handler_context)
Patrick Mocheld550d982006-06-27 00:41:40 -0400571 return AE_BAD_PARAMETER;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700572
Alexey Starikovskiy5b7734b2007-05-29 16:42:52 +0400573 if (function != ACPI_READ && function != ACPI_WRITE)
Patrick Mocheld550d982006-06-27 00:41:40 -0400574 return AE_BAD_PARAMETER;
Alexey Starikovskiy5b7734b2007-05-29 16:42:52 +0400575
576 if (bits != 8 && acpi_strict)
577 return AE_BAD_PARAMETER;
578
Alexey Starikovskiyb3b233c2008-01-11 02:42:57 +0300579 acpi_ec_burst_enable(ec);
580
Alexey Starikovskiy3e71a872008-01-11 02:42:51 +0300581 if (function == ACPI_READ) {
582 result = acpi_ec_read(ec, address, &temp);
583 *value = temp;
584 } else {
585 temp = 0xff & (*value);
586 result = acpi_ec_write(ec, address, temp);
587 }
588
589 for (i = 8; unlikely(bits - i > 0); i += 8) {
590 ++address;
Alexey Starikovskiy5b7734b2007-05-29 16:42:52 +0400591 if (function == ACPI_READ) {
592 result = acpi_ec_read(ec, address, &temp);
593 (*value) |= ((acpi_integer)temp) << i;
594 } else {
595 temp = 0xff & ((*value) >> i);
596 result = acpi_ec_write(ec, address, temp);
597 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700598 }
599
Alexey Starikovskiyb3b233c2008-01-11 02:42:57 +0300600 acpi_ec_burst_disable(ec);
601
Linus Torvalds1da177e2005-04-16 15:20:36 -0700602 switch (result) {
603 case -EINVAL:
Patrick Mocheld550d982006-06-27 00:41:40 -0400604 return AE_BAD_PARAMETER;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700605 break;
606 case -ENODEV:
Patrick Mocheld550d982006-06-27 00:41:40 -0400607 return AE_NOT_FOUND;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700608 break;
609 case -ETIME:
Patrick Mocheld550d982006-06-27 00:41:40 -0400610 return AE_TIME;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700611 break;
612 default:
Patrick Mocheld550d982006-06-27 00:41:40 -0400613 return AE_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700614 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700615}
616
Linus Torvalds1da177e2005-04-16 15:20:36 -0700617/* --------------------------------------------------------------------------
618 FS Interface (/proc)
619 -------------------------------------------------------------------------- */
620
Len Brown50526df2005-08-11 17:32:05 -0400621static struct proc_dir_entry *acpi_ec_dir;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700622
Len Brown50526df2005-08-11 17:32:05 -0400623static int acpi_ec_read_info(struct seq_file *seq, void *offset)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700624{
Alexey Starikovskiy3d02b902007-03-07 22:28:00 +0300625 struct acpi_ec *ec = seq->private;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700626
Linus Torvalds1da177e2005-04-16 15:20:36 -0700627 if (!ec)
628 goto end;
629
Alexey Starikovskiy01f22462007-03-07 22:28:00 +0300630 seq_printf(seq, "gpe:\t\t\t0x%02x\n", (u32) ec->gpe);
631 seq_printf(seq, "ports:\t\t\t0x%02x, 0x%02x\n",
632 (unsigned)ec->command_addr, (unsigned)ec->data_addr);
633 seq_printf(seq, "use global lock:\t%s\n",
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400634 ec->global_lock ? "yes" : "no");
Len Brown50526df2005-08-11 17:32:05 -0400635 end:
Patrick Mocheld550d982006-06-27 00:41:40 -0400636 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700637}
638
639static int acpi_ec_info_open_fs(struct inode *inode, struct file *file)
640{
641 return single_open(file, acpi_ec_read_info, PDE(inode)->data);
642}
643
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400644static struct file_operations acpi_ec_info_ops = {
Len Brown50526df2005-08-11 17:32:05 -0400645 .open = acpi_ec_info_open_fs,
646 .read = seq_read,
647 .llseek = seq_lseek,
648 .release = single_release,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700649 .owner = THIS_MODULE,
650};
651
Len Brown50526df2005-08-11 17:32:05 -0400652static int acpi_ec_add_fs(struct acpi_device *device)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700653{
Len Brown50526df2005-08-11 17:32:05 -0400654 struct proc_dir_entry *entry = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700655
Linus Torvalds1da177e2005-04-16 15:20:36 -0700656 if (!acpi_device_dir(device)) {
657 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
Len Brown50526df2005-08-11 17:32:05 -0400658 acpi_ec_dir);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700659 if (!acpi_device_dir(device))
Patrick Mocheld550d982006-06-27 00:41:40 -0400660 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700661 }
662
663 entry = create_proc_entry(ACPI_EC_FILE_INFO, S_IRUGO,
Len Brown50526df2005-08-11 17:32:05 -0400664 acpi_device_dir(device));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700665 if (!entry)
Patrick Mocheld550d982006-06-27 00:41:40 -0400666 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700667 else {
668 entry->proc_fops = &acpi_ec_info_ops;
669 entry->data = acpi_driver_data(device);
670 entry->owner = THIS_MODULE;
671 }
672
Patrick Mocheld550d982006-06-27 00:41:40 -0400673 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700674}
675
Len Brown50526df2005-08-11 17:32:05 -0400676static int acpi_ec_remove_fs(struct acpi_device *device)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700677{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700678
679 if (acpi_device_dir(device)) {
680 remove_proc_entry(ACPI_EC_FILE_INFO, acpi_device_dir(device));
681 remove_proc_entry(acpi_device_bid(device), acpi_ec_dir);
682 acpi_device_dir(device) = NULL;
683 }
684
Patrick Mocheld550d982006-06-27 00:41:40 -0400685 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700686}
687
Linus Torvalds1da177e2005-04-16 15:20:36 -0700688/* --------------------------------------------------------------------------
689 Driver Interface
690 -------------------------------------------------------------------------- */
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300691static acpi_status
692ec_parse_io_ports(struct acpi_resource *resource, void *context);
693
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300694static struct acpi_ec *make_acpi_ec(void)
695{
696 struct acpi_ec *ec = kzalloc(sizeof(struct acpi_ec), GFP_KERNEL);
697 if (!ec)
698 return NULL;
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400699 ec->flags = 1 << EC_FLAGS_QUERY_PENDING;
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300700 mutex_init(&ec->lock);
701 init_waitqueue_head(&ec->wait);
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400702 INIT_LIST_HEAD(&ec->list);
Alexey Starikovskiy845625c2008-03-21 17:07:03 +0300703 INIT_DELAYED_WORK_DEFERRABLE(&ec->work, do_ec_poll);
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300704 return ec;
705}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700706
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400707static acpi_status
Alexey Starikovskiyc019b192007-08-14 01:03:42 -0400708acpi_ec_register_query_methods(acpi_handle handle, u32 level,
709 void *context, void **return_value)
710{
711 struct acpi_namespace_node *node = handle;
712 struct acpi_ec *ec = context;
713 int value = 0;
714 if (sscanf(node->name.ascii, "_Q%x", &value) == 1) {
715 acpi_ec_add_query_handler(ec, value, handle, NULL, NULL);
716 }
717 return AE_OK;
718}
719
720static acpi_status
Alexey Starikovskiycd8c93a2007-08-03 17:52:48 -0400721ec_parse_device(acpi_handle handle, u32 Level, void *context, void **retval)
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400722{
Alexey Starikovskiycd8c93a2007-08-03 17:52:48 -0400723 acpi_status status;
724
725 struct acpi_ec *ec = context;
726 status = acpi_walk_resources(handle, METHOD_NAME__CRS,
727 ec_parse_io_ports, ec);
728 if (ACPI_FAILURE(status))
729 return status;
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400730
731 /* Get GPE bit assignment (EC events). */
732 /* TODO: Add support for _GPE returning a package */
Alexey Starikovskiycd8c93a2007-08-03 17:52:48 -0400733 status = acpi_evaluate_integer(handle, "_GPE", NULL, &ec->gpe);
734 if (ACPI_FAILURE(status))
735 return status;
Alexey Starikovskiyc019b192007-08-14 01:03:42 -0400736 /* Find and register all query methods */
737 acpi_walk_namespace(ACPI_TYPE_METHOD, handle, 1,
738 acpi_ec_register_query_methods, ec, NULL);
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400739 /* Use the global lock for all EC transactions? */
740 acpi_evaluate_integer(handle, "_GLK", NULL, &ec->global_lock);
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400741 ec->handle = handle;
Alexey Starikovskiycd8c93a2007-08-03 17:52:48 -0400742 return AE_CTRL_TERMINATE;
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400743}
744
Alexey Starikovskiy845625c2008-03-21 17:07:03 +0300745static void ec_poll_stop(struct acpi_ec *ec)
746{
747 clear_bit(EC_FLAGS_RESCHEDULE_POLL, &ec->flags);
748 cancel_delayed_work(&ec->work);
749}
750
Alexey Starikovskiy4c611062007-09-05 19:56:38 -0400751static void ec_remove_handlers(struct acpi_ec *ec)
752{
Alexey Starikovskiy845625c2008-03-21 17:07:03 +0300753 ec_poll_stop(ec);
Alexey Starikovskiy4c611062007-09-05 19:56:38 -0400754 if (ACPI_FAILURE(acpi_remove_address_space_handler(ec->handle,
755 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler)))
Márton Németh3ebe08a2007-11-21 03:23:26 +0300756 pr_err(PREFIX "failed to remove space handler\n");
Alexey Starikovskiy4c611062007-09-05 19:56:38 -0400757 if (ACPI_FAILURE(acpi_remove_gpe_handler(NULL, ec->gpe,
758 &acpi_ec_gpe_handler)))
Márton Németh3ebe08a2007-11-21 03:23:26 +0300759 pr_err(PREFIX "failed to remove gpe handler\n");
Alexey Starikovskiy4c611062007-09-05 19:56:38 -0400760 ec->handlers_installed = 0;
761}
762
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400763static int acpi_ec_add(struct acpi_device *device)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700764{
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400765 struct acpi_ec *ec = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700766
Linus Torvalds1da177e2005-04-16 15:20:36 -0700767 if (!device)
Patrick Mocheld550d982006-06-27 00:41:40 -0400768 return -EINVAL;
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300769 strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME);
770 strcpy(acpi_device_class(device), ACPI_EC_CLASS);
771
Alexey Starikovskiy4c611062007-09-05 19:56:38 -0400772 /* Check for boot EC */
773 if (boot_ec) {
774 if (boot_ec->handle == device->handle) {
775 /* Pre-loaded EC from DSDT, just move pointer */
776 ec = boot_ec;
777 boot_ec = NULL;
778 goto end;
779 } else if (boot_ec->handle == ACPI_ROOT_OBJECT) {
780 /* ECDT-based EC, time to shut it down */
781 ec_remove_handlers(boot_ec);
782 kfree(boot_ec);
783 first_ec = boot_ec = NULL;
784 }
785 }
786
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300787 ec = make_acpi_ec();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700788 if (!ec)
Patrick Mocheld550d982006-06-27 00:41:40 -0400789 return -ENOMEM;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700790
Alexey Starikovskiycd8c93a2007-08-03 17:52:48 -0400791 if (ec_parse_device(device->handle, 0, ec, NULL) !=
792 AE_CTRL_TERMINATE) {
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300793 kfree(ec);
794 return -EINVAL;
Denis M. Sadykov703959d2006-09-26 19:50:33 +0400795 }
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300796 ec->handle = device->handle;
Alexey Starikovskiy4c611062007-09-05 19:56:38 -0400797 end:
798 if (!first_ec)
799 first_ec = ec;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700800 acpi_driver_data(device) = ec;
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300801 acpi_ec_add_fs(device);
Márton Németh3ebe08a2007-11-21 03:23:26 +0300802 pr_info(PREFIX "GPE = 0x%lx, I/O: command/status = 0x%lx, data = 0x%lx\n",
Alexey Starikovskiy4c611062007-09-05 19:56:38 -0400803 ec->gpe, ec->command_addr, ec->data_addr);
Márton Németh3ebe08a2007-11-21 03:23:26 +0300804 pr_info(PREFIX "driver started in %s mode\n",
Alexey Starikovskiy95b937e2007-10-22 14:19:03 +0400805 (test_bit(EC_FLAGS_GPE_MODE, &ec->flags))?"interrupt":"poll");
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300806 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700807}
808
Len Brown50526df2005-08-11 17:32:05 -0400809static int acpi_ec_remove(struct acpi_device *device, int type)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700810{
Alexey Starikovskiy01f22462007-03-07 22:28:00 +0300811 struct acpi_ec *ec;
Adrian Bunk07ddf762007-07-29 17:00:37 +0200812 struct acpi_ec_query_handler *handler, *tmp;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700813
Linus Torvalds1da177e2005-04-16 15:20:36 -0700814 if (!device)
Patrick Mocheld550d982006-06-27 00:41:40 -0400815 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700816
817 ec = acpi_driver_data(device);
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400818 mutex_lock(&ec->lock);
Adrian Bunk07ddf762007-07-29 17:00:37 +0200819 list_for_each_entry_safe(handler, tmp, &ec->list, node) {
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400820 list_del(&handler->node);
821 kfree(handler);
822 }
823 mutex_unlock(&ec->lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700824 acpi_ec_remove_fs(device);
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300825 acpi_driver_data(device) = NULL;
Alexey Starikovskiyd0338792007-03-07 22:28:00 +0300826 if (ec == first_ec)
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300827 first_ec = NULL;
Alexey Starikovskiy4c611062007-09-05 19:56:38 -0400828 kfree(ec);
Patrick Mocheld550d982006-06-27 00:41:40 -0400829 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700830}
831
Linus Torvalds1da177e2005-04-16 15:20:36 -0700832static acpi_status
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300833ec_parse_io_ports(struct acpi_resource *resource, void *context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700834{
Alexey Starikovskiy3d02b902007-03-07 22:28:00 +0300835 struct acpi_ec *ec = context;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700836
Alexey Starikovskiy01f22462007-03-07 22:28:00 +0300837 if (resource->type != ACPI_RESOURCE_TYPE_IO)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700838 return AE_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700839
840 /*
841 * The first address region returned is the data port, and
842 * the second address region returned is the status/command
843 * port.
844 */
Alexey Starikovskiy01f22462007-03-07 22:28:00 +0300845 if (ec->data_addr == 0)
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400846 ec->data_addr = resource->data.io.minimum;
Alexey Starikovskiy01f22462007-03-07 22:28:00 +0300847 else if (ec->command_addr == 0)
Denis M. Sadykov6ffb2212006-09-26 19:50:33 +0400848 ec->command_addr = resource->data.io.minimum;
Alexey Starikovskiy01f22462007-03-07 22:28:00 +0300849 else
Linus Torvalds1da177e2005-04-16 15:20:36 -0700850 return AE_CTRL_TERMINATE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700851
Linus Torvalds1da177e2005-04-16 15:20:36 -0700852 return AE_OK;
853}
854
Alexey Starikovskiye8284322007-03-07 22:28:00 +0300855static int ec_install_handlers(struct acpi_ec *ec)
856{
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300857 acpi_status status;
Alexey Starikovskiy4c611062007-09-05 19:56:38 -0400858 if (ec->handlers_installed)
859 return 0;
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300860 status = acpi_install_gpe_handler(NULL, ec->gpe,
861 ACPI_GPE_EDGE_TRIGGERED,
862 &acpi_ec_gpe_handler, ec);
Alexey Starikovskiye8284322007-03-07 22:28:00 +0300863 if (ACPI_FAILURE(status))
864 return -ENODEV;
Alexey Starikovskiy01f22462007-03-07 22:28:00 +0300865
Alexey Starikovskiye8284322007-03-07 22:28:00 +0300866 acpi_set_gpe_type(NULL, ec->gpe, ACPI_GPE_TYPE_RUNTIME);
867 acpi_enable_gpe(NULL, ec->gpe, ACPI_NOT_ISR);
868
869 status = acpi_install_address_space_handler(ec->handle,
870 ACPI_ADR_SPACE_EC,
871 &acpi_ec_space_handler,
872 &acpi_ec_space_setup, ec);
873 if (ACPI_FAILURE(status)) {
874 acpi_remove_gpe_handler(NULL, ec->gpe, &acpi_ec_gpe_handler);
875 return -ENODEV;
876 }
877
Alexey Starikovskiy4c611062007-09-05 19:56:38 -0400878 ec->handlers_installed = 1;
Alexey Starikovskiye8284322007-03-07 22:28:00 +0300879 return 0;
880}
881
Len Brown50526df2005-08-11 17:32:05 -0400882static int acpi_ec_start(struct acpi_device *device)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700883{
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300884 struct acpi_ec *ec;
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400885 int ret = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700886
Linus Torvalds1da177e2005-04-16 15:20:36 -0700887 if (!device)
Patrick Mocheld550d982006-06-27 00:41:40 -0400888 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700889
890 ec = acpi_driver_data(device);
891
892 if (!ec)
Patrick Mocheld550d982006-06-27 00:41:40 -0400893 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700894
Alexey Starikovskiy4c611062007-09-05 19:56:38 -0400895 ret = ec_install_handlers(ec);
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300896
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400897 /* EC is fully operational, allow queries */
Alexey Starikovskiy080e4122007-10-22 14:18:30 +0400898 clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags);
Alexey Starikovskiy845625c2008-03-21 17:07:03 +0300899 ec_schedule_ec_poll(ec);
Alexey Starikovskiy837012e2007-05-29 16:43:02 +0400900 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700901}
902
Len Brown50526df2005-08-11 17:32:05 -0400903static int acpi_ec_stop(struct acpi_device *device, int type)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700904{
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300905 struct acpi_ec *ec;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700906 if (!device)
Patrick Mocheld550d982006-06-27 00:41:40 -0400907 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700908 ec = acpi_driver_data(device);
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300909 if (!ec)
910 return -EINVAL;
Alexey Starikovskiy4c611062007-09-05 19:56:38 -0400911 ec_remove_handlers(ec);
Alexey Starikovskiyf9319f92007-08-24 08:10:11 +0400912
Patrick Mocheld550d982006-06-27 00:41:40 -0400913 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700914}
915
Alexey Starikovskiyc04209a2008-01-01 14:12:55 -0500916int __init acpi_boot_ec_enable(void)
917{
918 if (!boot_ec || boot_ec->handlers_installed)
919 return 0;
920 if (!ec_install_handlers(boot_ec)) {
921 first_ec = boot_ec;
922 return 0;
923 }
924 return -EFAULT;
925}
926
Len Brown50526df2005-08-11 17:32:05 -0400927int __init acpi_ec_ecdt_probe(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700928{
Len Brown50526df2005-08-11 17:32:05 -0400929 int ret;
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300930 acpi_status status;
931 struct acpi_table_ecdt *ecdt_ptr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700932
Alexey Starikovskiyd66d9692007-03-07 22:28:00 +0300933 boot_ec = make_acpi_ec();
934 if (!boot_ec)
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300935 return -ENOMEM;
936 /*
937 * Generate a boot ec context
938 */
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300939 status = acpi_get_table(ACPI_SIG_ECDT, 1,
940 (struct acpi_table_header **)&ecdt_ptr);
Alexey Starikovskiycd8c93a2007-08-03 17:52:48 -0400941 if (ACPI_SUCCESS(status)) {
Márton Németh3ebe08a2007-11-21 03:23:26 +0300942 pr_info(PREFIX "EC description table is found, configuring boot EC\n");
Alexey Starikovskiycd8c93a2007-08-03 17:52:48 -0400943 boot_ec->command_addr = ecdt_ptr->control.address;
944 boot_ec->data_addr = ecdt_ptr->data.address;
945 boot_ec->gpe = ecdt_ptr->gpe;
Len Brown4af8e102008-03-11 00:27:16 -0400946 boot_ec->handle = ACPI_ROOT_OBJECT;
Alexey Starikovskiycd8c93a2007-08-03 17:52:48 -0400947 } else {
Alexey Starikovskiy5870a8c2007-11-15 21:52:47 +0300948 /* This workaround is needed only on some broken machines,
949 * which require early EC, but fail to provide ECDT */
950 acpi_handle x;
Alexey Starikovskiycd8c93a2007-08-03 17:52:48 -0400951 printk(KERN_DEBUG PREFIX "Look up EC in DSDT\n");
952 status = acpi_get_devices(ec_device_ids[0].id, ec_parse_device,
953 boot_ec, NULL);
Alexey Starikovskiy2d8348b2007-08-31 09:05:26 +0400954 /* Check that acpi_get_devices actually find something */
955 if (ACPI_FAILURE(status) || !boot_ec->handle)
Alexey Starikovskiycd8c93a2007-08-03 17:52:48 -0400956 goto error;
Alexey Starikovskiy5870a8c2007-11-15 21:52:47 +0300957 /* We really need to limit this workaround, the only ASUS,
958 * which needs it, has fake EC._INI method, so use it as flag.
Alexey Starikovskiyc04209a2008-01-01 14:12:55 -0500959 * Keep boot_ec struct as it will be needed soon.
Alexey Starikovskiy5870a8c2007-11-15 21:52:47 +0300960 */
961 if (ACPI_FAILURE(acpi_get_handle(boot_ec->handle, "_INI", &x)))
Alexey Starikovskiyc04209a2008-01-01 14:12:55 -0500962 return -ENODEV;
Alexey Starikovskiycd8c93a2007-08-03 17:52:48 -0400963 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700964
Alexey Starikovskiyd66d9692007-03-07 22:28:00 +0300965 ret = ec_install_handlers(boot_ec);
Alexey Starikovskiyd0338792007-03-07 22:28:00 +0300966 if (!ret) {
967 first_ec = boot_ec;
Alexey Starikovskiye8284322007-03-07 22:28:00 +0300968 return 0;
Alexey Starikovskiyd0338792007-03-07 22:28:00 +0300969 }
Alexey Starikovskiyc0900c32007-03-07 22:28:00 +0300970 error:
Alexey Starikovskiyd66d9692007-03-07 22:28:00 +0300971 kfree(boot_ec);
972 boot_ec = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700973 return -ENODEV;
974}
975
Len Brown50526df2005-08-11 17:32:05 -0400976static int __init acpi_ec_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700977{
Len Brown50526df2005-08-11 17:32:05 -0400978 int result = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700979
Linus Torvalds1da177e2005-04-16 15:20:36 -0700980 if (acpi_disabled)
Patrick Mocheld550d982006-06-27 00:41:40 -0400981 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700982
983 acpi_ec_dir = proc_mkdir(ACPI_EC_CLASS, acpi_root_dir);
984 if (!acpi_ec_dir)
Patrick Mocheld550d982006-06-27 00:41:40 -0400985 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700986
987 /* Now register the driver for the EC */
988 result = acpi_bus_register_driver(&acpi_ec_driver);
989 if (result < 0) {
990 remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir);
Patrick Mocheld550d982006-06-27 00:41:40 -0400991 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700992 }
993
Patrick Mocheld550d982006-06-27 00:41:40 -0400994 return result;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700995}
996
997subsys_initcall(acpi_ec_init);
998
999/* EC driver currently not unloadable */
1000#if 0
Len Brown50526df2005-08-11 17:32:05 -04001001static void __exit acpi_ec_exit(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001002{
Linus Torvalds1da177e2005-04-16 15:20:36 -07001003
1004 acpi_bus_unregister_driver(&acpi_ec_driver);
1005
1006 remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir);
1007
Patrick Mocheld550d982006-06-27 00:41:40 -04001008 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001009}
Alexey Starikovskiy78439322007-10-22 14:18:43 +04001010#endif /* 0 */