aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/ec.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/ec.c')
-rw-r--r--drivers/acpi/ec.c907
1 files changed, 736 insertions, 171 deletions
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index fca4140a50a9..1ac5731d45e5 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -59,76 +59,186 @@ ACPI_MODULE_NAME ("acpi_ec")
59#define ACPI_EC_DELAY 50 /* Wait 50ms max. during EC ops */ 59#define ACPI_EC_DELAY 50 /* Wait 50ms max. during EC ops */
60#define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */ 60#define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */
61 61
62#define ACPI_EC_UDELAY 100 /* Poll @ 100us increments */
63#define ACPI_EC_UDELAY_COUNT 1000 /* Wait 10ms max. during EC ops */
64
62#define ACPI_EC_COMMAND_READ 0x80 65#define ACPI_EC_COMMAND_READ 0x80
63#define ACPI_EC_COMMAND_WRITE 0x81 66#define ACPI_EC_COMMAND_WRITE 0x81
64#define ACPI_EC_BURST_ENABLE 0x82 67#define ACPI_EC_BURST_ENABLE 0x82
65#define ACPI_EC_BURST_DISABLE 0x83 68#define ACPI_EC_BURST_DISABLE 0x83
66#define ACPI_EC_COMMAND_QUERY 0x84 69#define ACPI_EC_COMMAND_QUERY 0x84
67 70
68static int acpi_ec_add (struct acpi_device *device); 71#define EC_POLLING 0xFF
72#define EC_BURST 0x00
73
74
69static int acpi_ec_remove (struct acpi_device *device, int type); 75static int acpi_ec_remove (struct acpi_device *device, int type);
70static int acpi_ec_start (struct acpi_device *device); 76static int acpi_ec_start (struct acpi_device *device);
71static int acpi_ec_stop (struct acpi_device *device, int type); 77static int acpi_ec_stop (struct acpi_device *device, int type);
78static int acpi_ec_burst_add ( struct acpi_device *device);
79static int acpi_ec_polling_add ( struct acpi_device *device);
72 80
73static struct acpi_driver acpi_ec_driver = { 81static struct acpi_driver acpi_ec_driver = {
74 .name = ACPI_EC_DRIVER_NAME, 82 .name = ACPI_EC_DRIVER_NAME,
75 .class = ACPI_EC_CLASS, 83 .class = ACPI_EC_CLASS,
76 .ids = ACPI_EC_HID, 84 .ids = ACPI_EC_HID,
77 .ops = { 85 .ops = {
78 .add = acpi_ec_add, 86 .add = acpi_ec_polling_add,
79 .remove = acpi_ec_remove, 87 .remove = acpi_ec_remove,
80 .start = acpi_ec_start, 88 .start = acpi_ec_start,
81 .stop = acpi_ec_stop, 89 .stop = acpi_ec_stop,
82 }, 90 },
83}; 91};
84 92union acpi_ec {
85struct acpi_ec { 93 struct {
86 acpi_handle handle; 94 u32 mode;
87 unsigned long uid; 95 acpi_handle handle;
88 unsigned long gpe_bit; 96 unsigned long uid;
89 struct acpi_generic_address status_addr; 97 unsigned long gpe_bit;
90 struct acpi_generic_address command_addr; 98 struct acpi_generic_address status_addr;
91 struct acpi_generic_address data_addr; 99 struct acpi_generic_address command_addr;
92 unsigned long global_lock; 100 struct acpi_generic_address data_addr;
93 unsigned int expect_event; 101 unsigned long global_lock;
94 atomic_t leaving_burst; /* 0 : No, 1 : Yes, 2: abort*/ 102 } common;
95 atomic_t pending_gpe; 103
96 struct semaphore sem; 104 struct {
97 wait_queue_head_t wait; 105 u32 mode;
106 acpi_handle handle;
107 unsigned long uid;
108 unsigned long gpe_bit;
109 struct acpi_generic_address status_addr;
110 struct acpi_generic_address command_addr;
111 struct acpi_generic_address data_addr;
112 unsigned long global_lock;
113 unsigned int expect_event;
114 atomic_t leaving_burst; /* 0 : No, 1 : Yes, 2: abort*/
115 atomic_t pending_gpe;
116 struct semaphore sem;
117 wait_queue_head_t wait;
118 }burst;
119
120 struct {
121 u32 mode;
122 acpi_handle handle;
123 unsigned long uid;
124 unsigned long gpe_bit;
125 struct acpi_generic_address status_addr;
126 struct acpi_generic_address command_addr;
127 struct acpi_generic_address data_addr;
128 unsigned long global_lock;
129 spinlock_t lock;
130 }polling;
98}; 131};
99 132
133static int acpi_ec_polling_wait ( union acpi_ec *ec, u8 event);
134static int acpi_ec_burst_wait(union acpi_ec *ec, unsigned int event);
135static int acpi_ec_polling_read ( union acpi_ec *ec, u8 address, u32 *data);
136static int acpi_ec_burst_read( union acpi_ec *ec, u8 address, u32 *data);
137static int acpi_ec_polling_write ( union acpi_ec *ec, u8 address, u8 data);
138static int acpi_ec_burst_write ( union acpi_ec *ec, u8 address, u8 data);
139static int acpi_ec_polling_query ( union acpi_ec *ec, u32 *data);
140static int acpi_ec_burst_query ( union acpi_ec *ec, u32 *data);
141static void acpi_ec_gpe_polling_query ( void *ec_cxt);
142static void acpi_ec_gpe_burst_query ( void *ec_cxt);
143static u32 acpi_ec_gpe_polling_handler ( void *data);
144static u32 acpi_ec_gpe_burst_handler ( void *data);
145static acpi_status __init
146acpi_fake_ecdt_polling_callback (
147 acpi_handle handle,
148 u32 Level,
149 void *context,
150 void **retval);
151
152static acpi_status __init
153acpi_fake_ecdt_burst_callback (
154 acpi_handle handle,
155 u32 Level,
156 void *context,
157 void **retval);
158
159static int __init
160acpi_ec_polling_get_real_ecdt(void);
161static int __init
162acpi_ec_burst_get_real_ecdt(void);
100/* If we find an EC via the ECDT, we need to keep a ptr to its context */ 163/* If we find an EC via the ECDT, we need to keep a ptr to its context */
101static struct acpi_ec *ec_ecdt; 164static union acpi_ec *ec_ecdt;
102 165
103/* External interfaces use first EC only, so remember */ 166/* External interfaces use first EC only, so remember */
104static struct acpi_device *first_ec; 167static struct acpi_device *first_ec;
168static int acpi_ec_polling_mode = EC_POLLING;
105 169
106/* -------------------------------------------------------------------------- 170/* --------------------------------------------------------------------------
107 Transaction Management 171 Transaction Management
108 -------------------------------------------------------------------------- */ 172 -------------------------------------------------------------------------- */
109 173
110static inline u32 acpi_ec_read_status(struct acpi_ec *ec) 174static inline u32 acpi_ec_read_status(union acpi_ec *ec)
111{ 175{
112 u32 status = 0; 176 u32 status = 0;
113 177
114 acpi_hw_low_level_read(8, &status, &ec->status_addr); 178 acpi_hw_low_level_read(8, &status, &ec->common.status_addr);
115 return status; 179 return status;
116} 180}
117 181
118static int acpi_ec_wait(struct acpi_ec *ec, unsigned int event) 182static int
183acpi_ec_wait (
184 union acpi_ec *ec,
185 u8 event)
186{
187 if (acpi_ec_polling_mode)
188 return acpi_ec_polling_wait (ec, event);
189 else
190 return acpi_ec_burst_wait (ec, event);
191}
192
193static int
194acpi_ec_polling_wait (
195 union acpi_ec *ec,
196 u8 event)
197{
198 u32 acpi_ec_status = 0;
199 u32 i = ACPI_EC_UDELAY_COUNT;
200
201 if (!ec)
202 return -EINVAL;
203
204 /* Poll the EC status register waiting for the event to occur. */
205 switch (event) {
206 case ACPI_EC_EVENT_OBF:
207 do {
208 acpi_hw_low_level_read(8, &acpi_ec_status, &ec->common.status_addr);
209 if (acpi_ec_status & ACPI_EC_FLAG_OBF)
210 return 0;
211 udelay(ACPI_EC_UDELAY);
212 } while (--i>0);
213 break;
214 case ACPI_EC_EVENT_IBE:
215 do {
216 acpi_hw_low_level_read(8, &acpi_ec_status, &ec->common.status_addr);
217 if (!(acpi_ec_status & ACPI_EC_FLAG_IBF))
218 return 0;
219 udelay(ACPI_EC_UDELAY);
220 } while (--i>0);
221 break;
222 default:
223 return -EINVAL;
224 }
225
226 return -ETIME;
227}
228static int acpi_ec_burst_wait(union acpi_ec *ec, unsigned int event)
119{ 229{
120 int result = 0; 230 int result = 0;
121 231
122 ACPI_FUNCTION_TRACE("acpi_ec_wait"); 232 ACPI_FUNCTION_TRACE("acpi_ec_wait");
123 233
124 ec->expect_event = event; 234 ec->burst.expect_event = event;
125 smp_mb(); 235 smp_mb();
126 236
127 result = wait_event_interruptible_timeout(ec->wait, 237 result = wait_event_interruptible_timeout(ec->burst.wait,
128 !ec->expect_event, 238 !ec->burst.expect_event,
129 msecs_to_jiffies(ACPI_EC_DELAY)); 239 msecs_to_jiffies(ACPI_EC_DELAY));
130 240
131 ec->expect_event = 0; 241 ec->burst.expect_event = 0;
132 smp_mb(); 242 smp_mb();
133 243
134 if (result < 0){ 244 if (result < 0){
@@ -160,7 +270,7 @@ static int acpi_ec_wait(struct acpi_ec *ec, unsigned int event)
160 270
161static int 271static int
162acpi_ec_enter_burst_mode ( 272acpi_ec_enter_burst_mode (
163 struct acpi_ec *ec) 273 union acpi_ec *ec)
164{ 274{
165 u32 tmp = 0; 275 u32 tmp = 0;
166 int status = 0; 276 int status = 0;
@@ -170,43 +280,43 @@ acpi_ec_enter_burst_mode (
170 status = acpi_ec_read_status(ec); 280 status = acpi_ec_read_status(ec);
171 if (status != -EINVAL && 281 if (status != -EINVAL &&
172 !(status & ACPI_EC_FLAG_BURST)){ 282 !(status & ACPI_EC_FLAG_BURST)){
173 acpi_hw_low_level_write(8, ACPI_EC_BURST_ENABLE, &ec->command_addr); 283 acpi_hw_low_level_write(8, ACPI_EC_BURST_ENABLE, &ec->common.command_addr);
174 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); 284 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
175 if (status){ 285 if (status){
176 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); 286 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
177 return_VALUE(-EINVAL); 287 return_VALUE(-EINVAL);
178 } 288 }
179 acpi_hw_low_level_read(8, &tmp, &ec->data_addr); 289 acpi_hw_low_level_read(8, &tmp, &ec->common.data_addr);
180 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); 290 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
181 if(tmp != 0x90 ) {/* Burst ACK byte*/ 291 if(tmp != 0x90 ) {/* Burst ACK byte*/
182 return_VALUE(-EINVAL); 292 return_VALUE(-EINVAL);
183 } 293 }
184 } 294 }
185 295
186 atomic_set(&ec->leaving_burst , 0); 296 atomic_set(&ec->burst.leaving_burst , 0);
187 return_VALUE(0); 297 return_VALUE(0);
188} 298}
189 299
190static int 300static int
191acpi_ec_leave_burst_mode ( 301acpi_ec_leave_burst_mode (
192 struct acpi_ec *ec) 302 union acpi_ec *ec)
193{ 303{
194 int status =0; 304 int status =0;
195 305
196 ACPI_FUNCTION_TRACE("acpi_ec_leave_burst_mode"); 306 ACPI_FUNCTION_TRACE("acpi_ec_leave_burst_mode");
197 307
198 atomic_set(&ec->leaving_burst , 1); 308 atomic_set(&ec->burst.leaving_burst , 1);
199 status = acpi_ec_read_status(ec); 309 status = acpi_ec_read_status(ec);
200 if (status != -EINVAL && 310 if (status != -EINVAL &&
201 (status & ACPI_EC_FLAG_BURST)){ 311 (status & ACPI_EC_FLAG_BURST)){
202 acpi_hw_low_level_write(8, ACPI_EC_BURST_DISABLE, &ec->command_addr); 312 acpi_hw_low_level_write(8, ACPI_EC_BURST_DISABLE, &ec->common.command_addr);
203 status = acpi_ec_wait(ec, ACPI_EC_FLAG_IBF); 313 status = acpi_ec_wait(ec, ACPI_EC_FLAG_IBF);
204 if (status){ 314 if (status){
205 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); 315 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
206 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,"------->wait fail\n")); 316 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,"------->wait fail\n"));
207 return_VALUE(-EINVAL); 317 return_VALUE(-EINVAL);
208 } 318 }
209 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); 319 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
210 status = acpi_ec_read_status(ec); 320 status = acpi_ec_read_status(ec);
211 } 321 }
212 322
@@ -215,7 +325,131 @@ acpi_ec_leave_burst_mode (
215 325
216static int 326static int
217acpi_ec_read ( 327acpi_ec_read (
218 struct acpi_ec *ec, 328 union acpi_ec *ec,
329 u8 address,
330 u32 *data)
331{
332 if (acpi_ec_polling_mode)
333 return acpi_ec_polling_read(ec, address, data);
334 else
335 return acpi_ec_burst_read(ec, address, data);
336}
337static int
338acpi_ec_write (
339 union acpi_ec *ec,
340 u8 address,
341 u8 data)
342{
343 if (acpi_ec_polling_mode)
344 return acpi_ec_polling_write(ec, address, data);
345 else
346 return acpi_ec_burst_write(ec, address, data);
347}
348static int
349acpi_ec_polling_read (
350 union acpi_ec *ec,
351 u8 address,
352 u32 *data)
353{
354 acpi_status status = AE_OK;
355 int result = 0;
356 unsigned long flags = 0;
357 u32 glk = 0;
358
359 ACPI_FUNCTION_TRACE("acpi_ec_read");
360
361 if (!ec || !data)
362 return_VALUE(-EINVAL);
363
364 *data = 0;
365
366 if (ec->common.global_lock) {
367 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
368 if (ACPI_FAILURE(status))
369 return_VALUE(-ENODEV);
370 }
371
372 spin_lock_irqsave(&ec->polling.lock, flags);
373
374 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_READ, &ec->common.command_addr);
375 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
376 if (result)
377 goto end;
378
379 acpi_hw_low_level_write(8, address, &ec->common.data_addr);
380 result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
381 if (result)
382 goto end;
383
384 acpi_hw_low_level_read(8, data, &ec->common.data_addr);
385
386 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Read [%02x] from address [%02x]\n",
387 *data, address));
388
389end:
390 spin_unlock_irqrestore(&ec->polling.lock, flags);
391
392 if (ec->common.global_lock)
393 acpi_release_global_lock(glk);
394
395 return_VALUE(result);
396}
397
398
399static int
400acpi_ec_polling_write (
401 union acpi_ec *ec,
402 u8 address,
403 u8 data)
404{
405 int result = 0;
406 acpi_status status = AE_OK;
407 unsigned long flags = 0;
408 u32 glk = 0;
409
410 ACPI_FUNCTION_TRACE("acpi_ec_write");
411
412 if (!ec)
413 return_VALUE(-EINVAL);
414
415 if (ec->common.global_lock) {
416 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
417 if (ACPI_FAILURE(status))
418 return_VALUE(-ENODEV);
419 }
420
421 spin_lock_irqsave(&ec->polling.lock, flags);
422
423 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_WRITE, &ec->common.command_addr);
424 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
425 if (result)
426 goto end;
427
428 acpi_hw_low_level_write(8, address, &ec->common.data_addr);
429 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
430 if (result)
431 goto end;
432
433 acpi_hw_low_level_write(8, data, &ec->common.data_addr);
434 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
435 if (result)
436 goto end;
437
438 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Wrote [%02x] to address [%02x]\n",
439 data, address));
440
441end:
442 spin_unlock_irqrestore(&ec->polling.lock, flags);
443
444 if (ec->common.global_lock)
445 acpi_release_global_lock(glk);
446
447 return_VALUE(result);
448}
449
450static int
451acpi_ec_burst_read (
452 union acpi_ec *ec,
219 u8 address, 453 u8 address,
220 u32 *data) 454 u32 *data)
221{ 455{
@@ -230,51 +464,51 @@ acpi_ec_read (
230retry: 464retry:
231 *data = 0; 465 *data = 0;
232 466
233 if (ec->global_lock) { 467 if (ec->common.global_lock) {
234 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); 468 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
235 if (ACPI_FAILURE(status)) 469 if (ACPI_FAILURE(status))
236 return_VALUE(-ENODEV); 470 return_VALUE(-ENODEV);
237 } 471 }
238 472
239 WARN_ON(in_interrupt()); 473 WARN_ON(in_interrupt());
240 down(&ec->sem); 474 down(&ec->burst.sem);
241 475
242 if(acpi_ec_enter_burst_mode(ec)) 476 if(acpi_ec_enter_burst_mode(ec))
243 goto end; 477 goto end;
244 478
245 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_READ, &ec->command_addr); 479 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_READ, &ec->common.command_addr);
246 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); 480 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
247 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); 481 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
248 if (status) { 482 if (status) {
249 goto end; 483 goto end;
250 } 484 }
251 485
252 acpi_hw_low_level_write(8, address, &ec->data_addr); 486 acpi_hw_low_level_write(8, address, &ec->common.data_addr);
253 status= acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); 487 status= acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
254 if (status){ 488 if (status){
255 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); 489 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
256 goto end; 490 goto end;
257 } 491 }
258 492
259 acpi_hw_low_level_read(8, data, &ec->data_addr); 493 acpi_hw_low_level_read(8, data, &ec->common.data_addr);
260 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); 494 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
261 495
262 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Read [%02x] from address [%02x]\n", 496 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Read [%02x] from address [%02x]\n",
263 *data, address)); 497 *data, address));
264 498
265end: 499end:
266 acpi_ec_leave_burst_mode(ec); 500 acpi_ec_leave_burst_mode(ec);
267 up(&ec->sem); 501 up(&ec->burst.sem);
268 502
269 if (ec->global_lock) 503 if (ec->common.global_lock)
270 acpi_release_global_lock(glk); 504 acpi_release_global_lock(glk);
271 505
272 if(atomic_read(&ec->leaving_burst) == 2){ 506 if(atomic_read(&ec->burst.leaving_burst) == 2){
273 ACPI_DEBUG_PRINT((ACPI_DB_INFO,"aborted, retry ...\n")); 507 ACPI_DEBUG_PRINT((ACPI_DB_INFO,"aborted, retry ...\n"));
274 while(atomic_read(&ec->pending_gpe)){ 508 while(atomic_read(&ec->burst.pending_gpe)){
275 msleep(1); 509 msleep(1);
276 } 510 }
277 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); 511 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
278 goto retry; 512 goto retry;
279 } 513 }
280 514
@@ -283,8 +517,8 @@ end:
283 517
284 518
285static int 519static int
286acpi_ec_write ( 520acpi_ec_burst_write (
287 struct acpi_ec *ec, 521 union acpi_ec *ec,
288 u8 address, 522 u8 address,
289 u8 data) 523 u8 data)
290{ 524{
@@ -297,14 +531,14 @@ acpi_ec_write (
297 if (!ec) 531 if (!ec)
298 return_VALUE(-EINVAL); 532 return_VALUE(-EINVAL);
299retry: 533retry:
300 if (ec->global_lock) { 534 if (ec->common.global_lock) {
301 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); 535 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
302 if (ACPI_FAILURE(status)) 536 if (ACPI_FAILURE(status))
303 return_VALUE(-ENODEV); 537 return_VALUE(-ENODEV);
304 } 538 }
305 539
306 WARN_ON(in_interrupt()); 540 WARN_ON(in_interrupt());
307 down(&ec->sem); 541 down(&ec->burst.sem);
308 542
309 if(acpi_ec_enter_burst_mode(ec)) 543 if(acpi_ec_enter_burst_mode(ec))
310 goto end; 544 goto end;
@@ -312,33 +546,33 @@ retry:
312 status = acpi_ec_read_status(ec); 546 status = acpi_ec_read_status(ec);
313 if (status != -EINVAL && 547 if (status != -EINVAL &&
314 !(status & ACPI_EC_FLAG_BURST)){ 548 !(status & ACPI_EC_FLAG_BURST)){
315 acpi_hw_low_level_write(8, ACPI_EC_BURST_ENABLE, &ec->command_addr); 549 acpi_hw_low_level_write(8, ACPI_EC_BURST_ENABLE, &ec->common.command_addr);
316 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); 550 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
317 if (status) 551 if (status)
318 goto end; 552 goto end;
319 acpi_hw_low_level_read(8, &tmp, &ec->data_addr); 553 acpi_hw_low_level_read(8, &tmp, &ec->common.data_addr);
320 if(tmp != 0x90 ) /* Burst ACK byte*/ 554 if(tmp != 0x90 ) /* Burst ACK byte*/
321 goto end; 555 goto end;
322 } 556 }
323 /*Now we are in burst mode*/ 557 /*Now we are in burst mode*/
324 558
325 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_WRITE, &ec->command_addr); 559 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_WRITE, &ec->common.command_addr);
326 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); 560 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
327 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); 561 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
328 if (status){ 562 if (status){
329 goto end; 563 goto end;
330 } 564 }
331 565
332 acpi_hw_low_level_write(8, address, &ec->data_addr); 566 acpi_hw_low_level_write(8, address, &ec->common.data_addr);
333 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); 567 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
334 if (status){ 568 if (status){
335 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); 569 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
336 goto end; 570 goto end;
337 } 571 }
338 572
339 acpi_hw_low_level_write(8, data, &ec->data_addr); 573 acpi_hw_low_level_write(8, data, &ec->common.data_addr);
340 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); 574 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
341 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); 575 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
342 if (status) 576 if (status)
343 goto end; 577 goto end;
344 578
@@ -347,17 +581,17 @@ retry:
347 581
348end: 582end:
349 acpi_ec_leave_burst_mode(ec); 583 acpi_ec_leave_burst_mode(ec);
350 up(&ec->sem); 584 up(&ec->burst.sem);
351 585
352 if (ec->global_lock) 586 if (ec->common.global_lock)
353 acpi_release_global_lock(glk); 587 acpi_release_global_lock(glk);
354 588
355 if(atomic_read(&ec->leaving_burst) == 2){ 589 if(atomic_read(&ec->burst.leaving_burst) == 2){
356 ACPI_DEBUG_PRINT((ACPI_DB_INFO,"aborted, retry ...\n")); 590 ACPI_DEBUG_PRINT((ACPI_DB_INFO,"aborted, retry ...\n"));
357 while(atomic_read(&ec->pending_gpe)){ 591 while(atomic_read(&ec->burst.pending_gpe)){
358 msleep(1); 592 msleep(1);
359 } 593 }
360 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); 594 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
361 goto retry; 595 goto retry;
362 } 596 }
363 597
@@ -370,7 +604,7 @@ end:
370int 604int
371ec_read(u8 addr, u8 *val) 605ec_read(u8 addr, u8 *val)
372{ 606{
373 struct acpi_ec *ec; 607 union acpi_ec *ec;
374 int err; 608 int err;
375 u32 temp_data; 609 u32 temp_data;
376 610
@@ -393,7 +627,7 @@ EXPORT_SYMBOL(ec_read);
393int 627int
394ec_write(u8 addr, u8 val) 628ec_write(u8 addr, u8 val)
395{ 629{
396 struct acpi_ec *ec; 630 union acpi_ec *ec;
397 int err; 631 int err;
398 632
399 if (!first_ec) 633 if (!first_ec)
@@ -407,10 +641,66 @@ ec_write(u8 addr, u8 val)
407} 641}
408EXPORT_SYMBOL(ec_write); 642EXPORT_SYMBOL(ec_write);
409 643
410
411static int 644static int
412acpi_ec_query ( 645acpi_ec_query (
413 struct acpi_ec *ec, 646 union acpi_ec *ec,
647 u32 *data)
648{
649 if (acpi_ec_polling_mode)
650 return acpi_ec_polling_query(ec, data);
651 else
652 return acpi_ec_burst_query(ec, data);
653}
654static int
655acpi_ec_polling_query (
656 union acpi_ec *ec,
657 u32 *data)
658{
659 int result = 0;
660 acpi_status status = AE_OK;
661 unsigned long flags = 0;
662 u32 glk = 0;
663
664 ACPI_FUNCTION_TRACE("acpi_ec_query");
665
666 if (!ec || !data)
667 return_VALUE(-EINVAL);
668
669 *data = 0;
670
671 if (ec->common.global_lock) {
672 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
673 if (ACPI_FAILURE(status))
674 return_VALUE(-ENODEV);
675 }
676
677 /*
678 * Query the EC to find out which _Qxx method we need to evaluate.
679 * Note that successful completion of the query causes the ACPI_EC_SCI
680 * bit to be cleared (and thus clearing the interrupt source).
681 */
682 spin_lock_irqsave(&ec->polling.lock, flags);
683
684 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_QUERY, &ec->common.command_addr);
685 result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
686 if (result)
687 goto end;
688
689 acpi_hw_low_level_read(8, data, &ec->common.data_addr);
690 if (!*data)
691 result = -ENODATA;
692
693end:
694 spin_unlock_irqrestore(&ec->polling.lock, flags);
695
696 if (ec->common.global_lock)
697 acpi_release_global_lock(glk);
698
699 return_VALUE(result);
700}
701static int
702acpi_ec_burst_query (
703 union acpi_ec *ec,
414 u32 *data) 704 u32 *data)
415{ 705{
416 int status = 0; 706 int status = 0;
@@ -422,13 +712,13 @@ acpi_ec_query (
422 return_VALUE(-EINVAL); 712 return_VALUE(-EINVAL);
423 *data = 0; 713 *data = 0;
424 714
425 if (ec->global_lock) { 715 if (ec->common.global_lock) {
426 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); 716 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
427 if (ACPI_FAILURE(status)) 717 if (ACPI_FAILURE(status))
428 return_VALUE(-ENODEV); 718 return_VALUE(-ENODEV);
429 } 719 }
430 720
431 down(&ec->sem); 721 down(&ec->burst.sem);
432 if(acpi_ec_enter_burst_mode(ec)) 722 if(acpi_ec_enter_burst_mode(ec))
433 goto end; 723 goto end;
434 /* 724 /*
@@ -436,28 +726,28 @@ acpi_ec_query (
436 * Note that successful completion of the query causes the ACPI_EC_SCI 726 * Note that successful completion of the query causes the ACPI_EC_SCI
437 * bit to be cleared (and thus clearing the interrupt source). 727 * bit to be cleared (and thus clearing the interrupt source).
438 */ 728 */
439 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_QUERY, &ec->command_addr); 729 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_QUERY, &ec->common.command_addr);
440 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); 730 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
441 if (status){ 731 if (status){
442 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); 732 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
443 goto end; 733 goto end;
444 } 734 }
445 735
446 acpi_hw_low_level_read(8, data, &ec->data_addr); 736 acpi_hw_low_level_read(8, data, &ec->common.data_addr);
447 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); 737 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
448 if (!*data) 738 if (!*data)
449 status = -ENODATA; 739 status = -ENODATA;
450 740
451end: 741end:
452 acpi_ec_leave_burst_mode(ec); 742 acpi_ec_leave_burst_mode(ec);
453 up(&ec->sem); 743 up(&ec->burst.sem);
454 744
455 if (ec->global_lock) 745 if (ec->common.global_lock)
456 acpi_release_global_lock(glk); 746 acpi_release_global_lock(glk);
457 747
458 if(atomic_read(&ec->leaving_burst) == 2){ 748 if(atomic_read(&ec->burst.leaving_burst) == 2){
459 ACPI_DEBUG_PRINT((ACPI_DB_INFO,"aborted, retry ...\n")); 749 ACPI_DEBUG_PRINT((ACPI_DB_INFO,"aborted, retry ...\n"));
460 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); 750 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
461 status = -ENODATA; 751 status = -ENODATA;
462 } 752 }
463 return_VALUE(status); 753 return_VALUE(status);
@@ -468,7 +758,7 @@ end:
468 Event Management 758 Event Management
469 -------------------------------------------------------------------------- */ 759 -------------------------------------------------------------------------- */
470 760
471struct acpi_ec_query_data { 761union acpi_ec_query_data {
472 acpi_handle handle; 762 acpi_handle handle;
473 u8 data; 763 u8 data;
474}; 764};
@@ -477,7 +767,59 @@ static void
477acpi_ec_gpe_query ( 767acpi_ec_gpe_query (
478 void *ec_cxt) 768 void *ec_cxt)
479{ 769{
480 struct acpi_ec *ec = (struct acpi_ec *) ec_cxt; 770 if (acpi_ec_polling_mode)
771 acpi_ec_gpe_polling_query(ec_cxt);
772 else
773 acpi_ec_gpe_burst_query(ec_cxt);
774}
775
776static void
777acpi_ec_gpe_polling_query (
778 void *ec_cxt)
779{
780 union acpi_ec *ec = (union acpi_ec *) ec_cxt;
781 u32 value = 0;
782 unsigned long flags = 0;
783 static char object_name[5] = {'_','Q','0','0','\0'};
784 const char hex[] = {'0','1','2','3','4','5','6','7',
785 '8','9','A','B','C','D','E','F'};
786
787 ACPI_FUNCTION_TRACE("acpi_ec_gpe_query");
788
789 if (!ec_cxt)
790 goto end;
791
792 spin_lock_irqsave(&ec->polling.lock, flags);
793 acpi_hw_low_level_read(8, &value, &ec->common.command_addr);
794 spin_unlock_irqrestore(&ec->polling.lock, flags);
795
796 /* TBD: Implement asynch events!
797 * NOTE: All we care about are EC-SCI's. Other EC events are
798 * handled via polling (yuck!). This is because some systems
799 * treat EC-SCIs as level (versus EDGE!) triggered, preventing
800 * a purely interrupt-driven approach (grumble, grumble).
801 */
802 if (!(value & ACPI_EC_FLAG_SCI))
803 goto end;
804
805 if (acpi_ec_query(ec, &value))
806 goto end;
807
808 object_name[2] = hex[((value >> 4) & 0x0F)];
809 object_name[3] = hex[(value & 0x0F)];
810
811 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluating %s\n", object_name));
812
813 acpi_evaluate_object(ec->common.handle, object_name, NULL, NULL);
814
815end:
816 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
817}
818static void
819acpi_ec_gpe_burst_query (
820 void *ec_cxt)
821{
822 union acpi_ec *ec = (union acpi_ec *) ec_cxt;
481 u32 value; 823 u32 value;
482 int result = -ENODATA; 824 int result = -ENODATA;
483 static char object_name[5] = {'_','Q','0','0','\0'}; 825 static char object_name[5] = {'_','Q','0','0','\0'};
@@ -497,9 +839,9 @@ acpi_ec_gpe_query (
497 839
498 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluating %s\n", object_name)); 840 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluating %s\n", object_name));
499 841
500 acpi_evaluate_object(ec->handle, object_name, NULL, NULL); 842 acpi_evaluate_object(ec->common.handle, object_name, NULL, NULL);
501end: 843end:
502 atomic_dec(&ec->pending_gpe); 844 atomic_dec(&ec->burst.pending_gpe);
503 return; 845 return;
504} 846}
505 847
@@ -507,48 +849,77 @@ static u32
507acpi_ec_gpe_handler ( 849acpi_ec_gpe_handler (
508 void *data) 850 void *data)
509{ 851{
852 if (acpi_ec_polling_mode)
853 return acpi_ec_gpe_polling_handler(data);
854 else
855 return acpi_ec_gpe_burst_handler(data);
856}
857static u32
858acpi_ec_gpe_polling_handler (
859 void *data)
860{
861 acpi_status status = AE_OK;
862 union acpi_ec *ec = (union acpi_ec *) data;
863
864 if (!ec)
865 return ACPI_INTERRUPT_NOT_HANDLED;
866
867 acpi_disable_gpe(NULL, ec->common.gpe_bit, ACPI_ISR);
868
869 status = acpi_os_queue_for_execution(OSD_PRIORITY_GPE,
870 acpi_ec_gpe_query, ec);
871
872 if (status == AE_OK)
873 return ACPI_INTERRUPT_HANDLED;
874 else
875 return ACPI_INTERRUPT_NOT_HANDLED;
876}
877static u32
878acpi_ec_gpe_burst_handler (
879 void *data)
880{
510 acpi_status status = AE_OK; 881 acpi_status status = AE_OK;
511 u32 value; 882 u32 value;
512 struct acpi_ec *ec = (struct acpi_ec *) data; 883 union acpi_ec *ec = (union acpi_ec *) data;
513 884
514 if (!ec) 885 if (!ec)
515 return ACPI_INTERRUPT_NOT_HANDLED; 886 return ACPI_INTERRUPT_NOT_HANDLED;
516 887
517 acpi_disable_gpe(NULL, ec->gpe_bit, ACPI_ISR); 888 acpi_disable_gpe(NULL, ec->common.gpe_bit, ACPI_ISR);
518 889
519 value = acpi_ec_read_status(ec); 890 value = acpi_ec_read_status(ec);
520 891
521 if((value & ACPI_EC_FLAG_IBF) && 892 if((value & ACPI_EC_FLAG_IBF) &&
522 !(value & ACPI_EC_FLAG_BURST) && 893 !(value & ACPI_EC_FLAG_BURST) &&
523 (atomic_read(&ec->leaving_burst) == 0)) { 894 (atomic_read(&ec->burst.leaving_burst) == 0)) {
524 /* 895 /*
525 * the embedded controller disables 896 * the embedded controller disables
526 * burst mode for any reason other 897 * burst mode for any reason other
527 * than the burst disable command 898 * than the burst disable command
528 * to process critical event. 899 * to process critical event.
529 */ 900 */
530 atomic_set(&ec->leaving_burst , 2); /* block current pending transaction 901 atomic_set(&ec->burst.leaving_burst , 2); /* block current pending transaction
531 and retry */ 902 and retry */
532 wake_up(&ec->wait); 903 wake_up(&ec->burst.wait);
533 }else { 904 }else {
534 if ((ec->expect_event == ACPI_EC_EVENT_OBF && 905 if ((ec->burst.expect_event == ACPI_EC_EVENT_OBF &&
535 (value & ACPI_EC_FLAG_OBF)) || 906 (value & ACPI_EC_FLAG_OBF)) ||
536 (ec->expect_event == ACPI_EC_EVENT_IBE && 907 (ec->burst.expect_event == ACPI_EC_EVENT_IBE &&
537 !(value & ACPI_EC_FLAG_IBF))) { 908 !(value & ACPI_EC_FLAG_IBF))) {
538 ec->expect_event = 0; 909 ec->burst.expect_event = 0;
539 wake_up(&ec->wait); 910 wake_up(&ec->burst.wait);
540 return ACPI_INTERRUPT_HANDLED; 911 return ACPI_INTERRUPT_HANDLED;
541 } 912 }
542 } 913 }
543 914
544 if (value & ACPI_EC_FLAG_SCI){ 915 if (value & ACPI_EC_FLAG_SCI){
545 atomic_add(1, &ec->pending_gpe) ; 916 atomic_add(1, &ec->burst.pending_gpe) ;
546 status = acpi_os_queue_for_execution(OSD_PRIORITY_GPE, 917 status = acpi_os_queue_for_execution(OSD_PRIORITY_GPE,
547 acpi_ec_gpe_query, ec); 918 acpi_ec_gpe_query, ec);
548 return status == AE_OK ? 919 return status == AE_OK ?
549 ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED; 920 ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED;
550 } 921 }
551 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_ISR); 922 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_ISR);
552 return status == AE_OK ? 923 return status == AE_OK ?
553 ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED; 924 ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED;
554} 925}
@@ -585,7 +956,7 @@ acpi_ec_space_handler (
585 void *region_context) 956 void *region_context)
586{ 957{
587 int result = 0; 958 int result = 0;
588 struct acpi_ec *ec = NULL; 959 union acpi_ec *ec = NULL;
589 u64 temp = *value; 960 u64 temp = *value;
590 acpi_integer f_v = 0; 961 acpi_integer f_v = 0;
591 int i = 0; 962 int i = 0;
@@ -600,7 +971,7 @@ acpi_ec_space_handler (
600 return_VALUE(AE_BAD_PARAMETER); 971 return_VALUE(AE_BAD_PARAMETER);
601 } 972 }
602 973
603 ec = (struct acpi_ec *) handler_context; 974 ec = (union acpi_ec *) handler_context;
604 975
605next_byte: 976next_byte:
606 switch (function) { 977 switch (function) {
@@ -661,7 +1032,7 @@ static struct proc_dir_entry *acpi_ec_dir;
661static int 1032static int
662acpi_ec_read_info (struct seq_file *seq, void *offset) 1033acpi_ec_read_info (struct seq_file *seq, void *offset)
663{ 1034{
664 struct acpi_ec *ec = (struct acpi_ec *) seq->private; 1035 union acpi_ec *ec = (union acpi_ec *) seq->private;
665 1036
666 ACPI_FUNCTION_TRACE("acpi_ec_read_info"); 1037 ACPI_FUNCTION_TRACE("acpi_ec_read_info");
667 1038
@@ -669,12 +1040,12 @@ acpi_ec_read_info (struct seq_file *seq, void *offset)
669 goto end; 1040 goto end;
670 1041
671 seq_printf(seq, "gpe bit: 0x%02x\n", 1042 seq_printf(seq, "gpe bit: 0x%02x\n",
672 (u32) ec->gpe_bit); 1043 (u32) ec->common.gpe_bit);
673 seq_printf(seq, "ports: 0x%02x, 0x%02x\n", 1044 seq_printf(seq, "ports: 0x%02x, 0x%02x\n",
674 (u32) ec->status_addr.address, (u32) ec->data_addr.address); 1045 (u32) ec->common.status_addr.address, (u32) ec->common.data_addr.address);
675 seq_printf(seq, "use global lock: %s\n", 1046 seq_printf(seq, "use global lock: %s\n",
676 ec->global_lock?"yes":"no"); 1047 ec->common.global_lock?"yes":"no");
677 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); 1048 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
678 1049
679end: 1050end:
680 return_VALUE(0); 1051 return_VALUE(0);
@@ -697,7 +1068,7 @@ static int
697acpi_ec_add_fs ( 1068acpi_ec_add_fs (
698 struct acpi_device *device) 1069 struct acpi_device *device)
699{ 1070{
700 struct proc_dir_entry *entry; 1071 struct proc_dir_entry *entry = NULL;
701 1072
702 ACPI_FUNCTION_TRACE("acpi_ec_add_fs"); 1073 ACPI_FUNCTION_TRACE("acpi_ec_add_fs");
703 1074
@@ -744,13 +1115,14 @@ acpi_ec_remove_fs (
744 Driver Interface 1115 Driver Interface
745 -------------------------------------------------------------------------- */ 1116 -------------------------------------------------------------------------- */
746 1117
1118
747static int 1119static int
748acpi_ec_add ( 1120acpi_ec_polling_add (
749 struct acpi_device *device) 1121 struct acpi_device *device)
750{ 1122{
751 int result; 1123 int result = 0;
752 acpi_status status; 1124 acpi_status status = AE_OK;
753 struct acpi_ec *ec; 1125 union acpi_ec *ec = NULL;
754 unsigned long uid; 1126 unsigned long uid;
755 1127
756 ACPI_FUNCTION_TRACE("acpi_ec_add"); 1128 ACPI_FUNCTION_TRACE("acpi_ec_add");
@@ -758,39 +1130,107 @@ acpi_ec_add (
758 if (!device) 1130 if (!device)
759 return_VALUE(-EINVAL); 1131 return_VALUE(-EINVAL);
760 1132
761 ec = kmalloc(sizeof(struct acpi_ec), GFP_KERNEL); 1133 ec = kmalloc(sizeof(union acpi_ec), GFP_KERNEL);
762 if (!ec) 1134 if (!ec)
763 return_VALUE(-ENOMEM); 1135 return_VALUE(-ENOMEM);
764 memset(ec, 0, sizeof(struct acpi_ec)); 1136 memset(ec, 0, sizeof(union acpi_ec));
765 1137
766 ec->handle = device->handle; 1138 ec->common.handle = device->handle;
767 ec->uid = -1; 1139 ec->common.uid = -1;
768 atomic_set(&ec->pending_gpe, 0); 1140 spin_lock_init(&ec->polling.lock);
769 atomic_set(&ec->leaving_burst , 1);
770 init_MUTEX(&ec->sem);
771 init_waitqueue_head(&ec->wait);
772 strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME); 1141 strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME);
773 strcpy(acpi_device_class(device), ACPI_EC_CLASS); 1142 strcpy(acpi_device_class(device), ACPI_EC_CLASS);
774 acpi_driver_data(device) = ec; 1143 acpi_driver_data(device) = ec;
775 1144
776 /* Use the global lock for all EC transactions? */ 1145 /* Use the global lock for all EC transactions? */
777 acpi_evaluate_integer(ec->handle, "_GLK", NULL, &ec->global_lock); 1146 acpi_evaluate_integer(ec->common.handle, "_GLK", NULL, &ec->common.global_lock);
778 1147
779 /* If our UID matches the UID for the ECDT-enumerated EC, 1148 /* If our UID matches the UID for the ECDT-enumerated EC,
780 we now have the *real* EC info, so kill the makeshift one.*/ 1149 we now have the *real* EC info, so kill the makeshift one.*/
781 acpi_evaluate_integer(ec->handle, "_UID", NULL, &uid); 1150 acpi_evaluate_integer(ec->common.handle, "_UID", NULL, &uid);
782 if (ec_ecdt && ec_ecdt->uid == uid) { 1151 if (ec_ecdt && ec_ecdt->common.uid == uid) {
783 acpi_remove_address_space_handler(ACPI_ROOT_OBJECT, 1152 acpi_remove_address_space_handler(ACPI_ROOT_OBJECT,
784 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler); 1153 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler);
1154
1155 acpi_remove_gpe_handler(NULL, ec_ecdt->common.gpe_bit, &acpi_ec_gpe_handler);
1156
1157 kfree(ec_ecdt);
1158 }
1159
1160 /* Get GPE bit assignment (EC events). */
1161 /* TODO: Add support for _GPE returning a package */
1162 status = acpi_evaluate_integer(ec->common.handle, "_GPE", NULL, &ec->common.gpe_bit);
1163 if (ACPI_FAILURE(status)) {
1164 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1165 "Error obtaining GPE bit assignment\n"));
1166 result = -ENODEV;
1167 goto end;
1168 }
785 1169
786 acpi_remove_gpe_handler(NULL, ec_ecdt->gpe_bit, &acpi_ec_gpe_handler); 1170 result = acpi_ec_add_fs(device);
1171 if (result)
1172 goto end;
1173
1174 printk(KERN_INFO PREFIX "%s [%s] (gpe %d)\n",
1175 acpi_device_name(device), acpi_device_bid(device),
1176 (u32) ec->common.gpe_bit);
1177
1178 if (!first_ec)
1179 first_ec = device;
1180
1181end:
1182 if (result)
1183 kfree(ec);
1184
1185 return_VALUE(result);
1186}
1187static int
1188acpi_ec_burst_add (
1189 struct acpi_device *device)
1190{
1191 int result = 0;
1192 acpi_status status = AE_OK;
1193 union acpi_ec *ec = NULL;
1194 unsigned long uid;
1195
1196 ACPI_FUNCTION_TRACE("acpi_ec_add");
1197
1198 if (!device)
1199 return_VALUE(-EINVAL);
1200
1201 ec = kmalloc(sizeof(union acpi_ec), GFP_KERNEL);
1202 if (!ec)
1203 return_VALUE(-ENOMEM);
1204 memset(ec, 0, sizeof(union acpi_ec));
1205
1206 ec->common.handle = device->handle;
1207 ec->common.uid = -1;
1208 atomic_set(&ec->burst.pending_gpe, 0);
1209 atomic_set(&ec->burst.leaving_burst , 1);
1210 init_MUTEX(&ec->burst.sem);
1211 init_waitqueue_head(&ec->burst.wait);
1212 strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME);
1213 strcpy(acpi_device_class(device), ACPI_EC_CLASS);
1214 acpi_driver_data(device) = ec;
1215
1216 /* Use the global lock for all EC transactions? */
1217 acpi_evaluate_integer(ec->common.handle, "_GLK", NULL, &ec->common.global_lock);
1218
1219 /* If our UID matches the UID for the ECDT-enumerated EC,
1220 we now have the *real* EC info, so kill the makeshift one.*/
1221 acpi_evaluate_integer(ec->common.handle, "_UID", NULL, &uid);
1222 if (ec_ecdt && ec_ecdt->common.uid == uid) {
1223 acpi_remove_address_space_handler(ACPI_ROOT_OBJECT,
1224 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler);
1225
1226 acpi_remove_gpe_handler(NULL, ec_ecdt->common.gpe_bit, &acpi_ec_gpe_handler);
787 1227
788 kfree(ec_ecdt); 1228 kfree(ec_ecdt);
789 } 1229 }
790 1230
791 /* Get GPE bit assignment (EC events). */ 1231 /* Get GPE bit assignment (EC events). */
792 /* TODO: Add support for _GPE returning a package */ 1232 /* TODO: Add support for _GPE returning a package */
793 status = acpi_evaluate_integer(ec->handle, "_GPE", NULL, &ec->gpe_bit); 1233 status = acpi_evaluate_integer(ec->common.handle, "_GPE", NULL, &ec->common.gpe_bit);
794 if (ACPI_FAILURE(status)) { 1234 if (ACPI_FAILURE(status)) {
795 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1235 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
796 "Error obtaining GPE bit assignment\n")); 1236 "Error obtaining GPE bit assignment\n"));
@@ -804,7 +1244,7 @@ acpi_ec_add (
804 1244
805 printk(KERN_INFO PREFIX "%s [%s] (gpe %d)\n", 1245 printk(KERN_INFO PREFIX "%s [%s] (gpe %d)\n",
806 acpi_device_name(device), acpi_device_bid(device), 1246 acpi_device_name(device), acpi_device_bid(device),
807 (u32) ec->gpe_bit); 1247 (u32) ec->common.gpe_bit);
808 1248
809 if (!first_ec) 1249 if (!first_ec)
810 first_ec = device; 1250 first_ec = device;
@@ -822,7 +1262,7 @@ acpi_ec_remove (
822 struct acpi_device *device, 1262 struct acpi_device *device,
823 int type) 1263 int type)
824{ 1264{
825 struct acpi_ec *ec; 1265 union acpi_ec *ec = NULL;
826 1266
827 ACPI_FUNCTION_TRACE("acpi_ec_remove"); 1267 ACPI_FUNCTION_TRACE("acpi_ec_remove");
828 1268
@@ -844,7 +1284,7 @@ acpi_ec_io_ports (
844 struct acpi_resource *resource, 1284 struct acpi_resource *resource,
845 void *context) 1285 void *context)
846{ 1286{
847 struct acpi_ec *ec = (struct acpi_ec *) context; 1287 union acpi_ec *ec = (union acpi_ec *) context;
848 struct acpi_generic_address *addr; 1288 struct acpi_generic_address *addr;
849 1289
850 if (resource->id != ACPI_RSTYPE_IO) { 1290 if (resource->id != ACPI_RSTYPE_IO) {
@@ -856,10 +1296,10 @@ acpi_ec_io_ports (
856 * the second address region returned is the status/command 1296 * the second address region returned is the status/command
857 * port. 1297 * port.
858 */ 1298 */
859 if (ec->data_addr.register_bit_width == 0) { 1299 if (ec->common.data_addr.register_bit_width == 0) {
860 addr = &ec->data_addr; 1300 addr = &ec->common.data_addr;
861 } else if (ec->command_addr.register_bit_width == 0) { 1301 } else if (ec->common.command_addr.register_bit_width == 0) {
862 addr = &ec->command_addr; 1302 addr = &ec->common.command_addr;
863 } else { 1303 } else {
864 return AE_CTRL_TERMINATE; 1304 return AE_CTRL_TERMINATE;
865 } 1305 }
@@ -877,8 +1317,8 @@ static int
877acpi_ec_start ( 1317acpi_ec_start (
878 struct acpi_device *device) 1318 struct acpi_device *device)
879{ 1319{
880 acpi_status status; 1320 acpi_status status = AE_OK;
881 struct acpi_ec *ec; 1321 union acpi_ec *ec = NULL;
882 1322
883 ACPI_FUNCTION_TRACE("acpi_ec_start"); 1323 ACPI_FUNCTION_TRACE("acpi_ec_start");
884 1324
@@ -893,35 +1333,36 @@ acpi_ec_start (
893 /* 1333 /*
894 * Get I/O port addresses. Convert to GAS format. 1334 * Get I/O port addresses. Convert to GAS format.
895 */ 1335 */
896 status = acpi_walk_resources(ec->handle, METHOD_NAME__CRS, 1336 status = acpi_walk_resources(ec->common.handle, METHOD_NAME__CRS,
897 acpi_ec_io_ports, ec); 1337 acpi_ec_io_ports, ec);
898 if (ACPI_FAILURE(status) || ec->command_addr.register_bit_width == 0) { 1338 if (ACPI_FAILURE(status) || ec->common.command_addr.register_bit_width == 0) {
899 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error getting I/O port addresses")); 1339 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error getting I/O port addresses"));
900 return_VALUE(-ENODEV); 1340 return_VALUE(-ENODEV);
901 } 1341 }
902 1342
903 ec->status_addr = ec->command_addr; 1343 ec->common.status_addr = ec->common.command_addr;
904 1344
905 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "gpe=0x%02x, ports=0x%2x,0x%2x\n", 1345 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "gpe=0x%02x, ports=0x%2x,0x%2x\n",
906 (u32) ec->gpe_bit, (u32) ec->command_addr.address, 1346 (u32) ec->common.gpe_bit, (u32) ec->common.command_addr.address,
907 (u32) ec->data_addr.address)); 1347 (u32) ec->common.data_addr.address));
1348
908 1349
909 /* 1350 /*
910 * Install GPE handler 1351 * Install GPE handler
911 */ 1352 */
912 status = acpi_install_gpe_handler(NULL, ec->gpe_bit, 1353 status = acpi_install_gpe_handler(NULL, ec->common.gpe_bit,
913 ACPI_GPE_EDGE_TRIGGERED, &acpi_ec_gpe_handler, ec); 1354 ACPI_GPE_EDGE_TRIGGERED, &acpi_ec_gpe_handler, ec);
914 if (ACPI_FAILURE(status)) { 1355 if (ACPI_FAILURE(status)) {
915 return_VALUE(-ENODEV); 1356 return_VALUE(-ENODEV);
916 } 1357 }
917 acpi_set_gpe_type (NULL, ec->gpe_bit, ACPI_GPE_TYPE_RUNTIME); 1358 acpi_set_gpe_type (NULL, ec->common.gpe_bit, ACPI_GPE_TYPE_RUNTIME);
918 acpi_enable_gpe (NULL, ec->gpe_bit, ACPI_NOT_ISR); 1359 acpi_enable_gpe (NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
919 1360
920 status = acpi_install_address_space_handler (ec->handle, 1361 status = acpi_install_address_space_handler (ec->common.handle,
921 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler, 1362 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler,
922 &acpi_ec_space_setup, ec); 1363 &acpi_ec_space_setup, ec);
923 if (ACPI_FAILURE(status)) { 1364 if (ACPI_FAILURE(status)) {
924 acpi_remove_gpe_handler(NULL, ec->gpe_bit, &acpi_ec_gpe_handler); 1365 acpi_remove_gpe_handler(NULL, ec->common.gpe_bit, &acpi_ec_gpe_handler);
925 return_VALUE(-ENODEV); 1366 return_VALUE(-ENODEV);
926 } 1367 }
927 1368
@@ -934,8 +1375,8 @@ acpi_ec_stop (
934 struct acpi_device *device, 1375 struct acpi_device *device,
935 int type) 1376 int type)
936{ 1377{
937 acpi_status status; 1378 acpi_status status = AE_OK;
938 struct acpi_ec *ec; 1379 union acpi_ec *ec = NULL;
939 1380
940 ACPI_FUNCTION_TRACE("acpi_ec_stop"); 1381 ACPI_FUNCTION_TRACE("acpi_ec_stop");
941 1382
@@ -944,12 +1385,12 @@ acpi_ec_stop (
944 1385
945 ec = acpi_driver_data(device); 1386 ec = acpi_driver_data(device);
946 1387
947 status = acpi_remove_address_space_handler(ec->handle, 1388 status = acpi_remove_address_space_handler(ec->common.handle,
948 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler); 1389 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler);
949 if (ACPI_FAILURE(status)) 1390 if (ACPI_FAILURE(status))
950 return_VALUE(-ENODEV); 1391 return_VALUE(-ENODEV);
951 1392
952 status = acpi_remove_gpe_handler(NULL, ec->gpe_bit, &acpi_ec_gpe_handler); 1393 status = acpi_remove_gpe_handler(NULL, ec->common.gpe_bit, &acpi_ec_gpe_handler);
953 if (ACPI_FAILURE(status)) 1394 if (ACPI_FAILURE(status))
954 return_VALUE(-ENODEV); 1395 return_VALUE(-ENODEV);
955 1396
@@ -963,26 +1404,76 @@ acpi_fake_ecdt_callback (
963 void *context, 1404 void *context,
964 void **retval) 1405 void **retval)
965{ 1406{
1407
1408 if (acpi_ec_polling_mode)
1409 return acpi_fake_ecdt_polling_callback(handle,
1410 Level, context, retval);
1411 else
1412 return acpi_fake_ecdt_burst_callback(handle,
1413 Level, context, retval);
1414}
1415
1416static acpi_status __init
1417acpi_fake_ecdt_polling_callback (
1418 acpi_handle handle,
1419 u32 Level,
1420 void *context,
1421 void **retval)
1422{
966 acpi_status status; 1423 acpi_status status;
967 1424
968 status = acpi_walk_resources(handle, METHOD_NAME__CRS, 1425 status = acpi_walk_resources(handle, METHOD_NAME__CRS,
969 acpi_ec_io_ports, ec_ecdt); 1426 acpi_ec_io_ports, ec_ecdt);
970 if (ACPI_FAILURE(status)) 1427 if (ACPI_FAILURE(status))
971 return status; 1428 return status;
972 ec_ecdt->status_addr = ec_ecdt->command_addr; 1429 ec_ecdt->common.status_addr = ec_ecdt->common.command_addr;
973 1430
974 ec_ecdt->uid = -1; 1431 ec_ecdt->common.uid = -1;
975 acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->uid); 1432 acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->common.uid);
976 1433
977 status = acpi_evaluate_integer(handle, "_GPE", NULL, &ec_ecdt->gpe_bit); 1434 status = acpi_evaluate_integer(handle, "_GPE", NULL, &ec_ecdt->common.gpe_bit);
978 if (ACPI_FAILURE(status)) 1435 if (ACPI_FAILURE(status))
979 return status; 1436 return status;
980 ec_ecdt->global_lock = TRUE; 1437 spin_lock_init(&ec_ecdt->polling.lock);
981 ec_ecdt->handle = handle; 1438 ec_ecdt->common.global_lock = TRUE;
1439 ec_ecdt->common.handle = handle;
982 1440
983 printk(KERN_INFO PREFIX "GPE=0x%02x, ports=0x%2x, 0x%2x\n", 1441 printk(KERN_INFO PREFIX "GPE=0x%02x, ports=0x%2x, 0x%2x\n",
984 (u32) ec_ecdt->gpe_bit, (u32) ec_ecdt->command_addr.address, 1442 (u32) ec_ecdt->common.gpe_bit, (u32) ec_ecdt->common.command_addr.address,
985 (u32) ec_ecdt->data_addr.address); 1443 (u32) ec_ecdt->common.data_addr.address);
1444
1445 return AE_CTRL_TERMINATE;
1446}
1447
1448static acpi_status __init
1449acpi_fake_ecdt_burst_callback (
1450 acpi_handle handle,
1451 u32 Level,
1452 void *context,
1453 void **retval)
1454{
1455 acpi_status status;
1456
1457 init_MUTEX(&ec_ecdt->burst.sem);
1458 init_waitqueue_head(&ec_ecdt->burst.wait);
1459 status = acpi_walk_resources(handle, METHOD_NAME__CRS,
1460 acpi_ec_io_ports, ec_ecdt);
1461 if (ACPI_FAILURE(status))
1462 return status;
1463 ec_ecdt->common.status_addr = ec_ecdt->common.command_addr;
1464
1465 ec_ecdt->common.uid = -1;
1466 acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->common.uid);
1467
1468 status = acpi_evaluate_integer(handle, "_GPE", NULL, &ec_ecdt->common.gpe_bit);
1469 if (ACPI_FAILURE(status))
1470 return status;
1471 ec_ecdt->common.global_lock = TRUE;
1472 ec_ecdt->common.handle = handle;
1473
1474 printk(KERN_INFO PREFIX "GPE=0x%02x, ports=0x%2x, 0x%2x\n",
1475 (u32) ec_ecdt->common.gpe_bit, (u32) ec_ecdt->common.command_addr.address,
1476 (u32) ec_ecdt->common.data_addr.address);
986 1477
987 return AE_CTRL_TERMINATE; 1478 return AE_CTRL_TERMINATE;
988} 1479}
@@ -1005,12 +1496,12 @@ acpi_ec_fake_ecdt(void)
1005 1496
1006 printk(KERN_INFO PREFIX "Try to make an fake ECDT\n"); 1497 printk(KERN_INFO PREFIX "Try to make an fake ECDT\n");
1007 1498
1008 ec_ecdt = kmalloc(sizeof(struct acpi_ec), GFP_KERNEL); 1499 ec_ecdt = kmalloc(sizeof(union acpi_ec), GFP_KERNEL);
1009 if (!ec_ecdt) { 1500 if (!ec_ecdt) {
1010 ret = -ENOMEM; 1501 ret = -ENOMEM;
1011 goto error; 1502 goto error;
1012 } 1503 }
1013 memset(ec_ecdt, 0, sizeof(struct acpi_ec)); 1504 memset(ec_ecdt, 0, sizeof(union acpi_ec));
1014 1505
1015 status = acpi_get_devices (ACPI_EC_HID, 1506 status = acpi_get_devices (ACPI_EC_HID,
1016 acpi_fake_ecdt_callback, 1507 acpi_fake_ecdt_callback,
@@ -1031,6 +1522,60 @@ error:
1031static int __init 1522static int __init
1032acpi_ec_get_real_ecdt(void) 1523acpi_ec_get_real_ecdt(void)
1033{ 1524{
1525 if (acpi_ec_polling_mode)
1526 return acpi_ec_polling_get_real_ecdt();
1527 else
1528 return acpi_ec_burst_get_real_ecdt();
1529}
1530
1531static int __init
1532acpi_ec_polling_get_real_ecdt(void)
1533{
1534 acpi_status status;
1535 struct acpi_table_ecdt *ecdt_ptr;
1536
1537 status = acpi_get_firmware_table("ECDT", 1, ACPI_LOGICAL_ADDRESSING,
1538 (struct acpi_table_header **) &ecdt_ptr);
1539 if (ACPI_FAILURE(status))
1540 return -ENODEV;
1541
1542 printk(KERN_INFO PREFIX "Found ECDT\n");
1543
1544 /*
1545 * Generate a temporary ec context to use until the namespace is scanned
1546 */
1547 ec_ecdt = kmalloc(sizeof(union acpi_ec), GFP_KERNEL);
1548 if (!ec_ecdt)
1549 return -ENOMEM;
1550 memset(ec_ecdt, 0, sizeof(union acpi_ec));
1551
1552 ec_ecdt->common.command_addr = ecdt_ptr->ec_control;
1553 ec_ecdt->common.status_addr = ecdt_ptr->ec_control;
1554 ec_ecdt->common.data_addr = ecdt_ptr->ec_data;
1555 ec_ecdt->common.gpe_bit = ecdt_ptr->gpe_bit;
1556 spin_lock_init(&ec_ecdt->polling.lock);
1557 /* use the GL just to be safe */
1558 ec_ecdt->common.global_lock = TRUE;
1559 ec_ecdt->common.uid = ecdt_ptr->uid;
1560
1561 status = acpi_get_handle(NULL, ecdt_ptr->ec_id, &ec_ecdt->common.handle);
1562 if (ACPI_FAILURE(status)) {
1563 goto error;
1564 }
1565
1566 return 0;
1567error:
1568 printk(KERN_ERR PREFIX "Could not use ECDT\n");
1569 kfree(ec_ecdt);
1570 ec_ecdt = NULL;
1571
1572 return -ENODEV;
1573}
1574
1575
1576static int __init
1577acpi_ec_burst_get_real_ecdt(void)
1578{
1034 acpi_status status; 1579 acpi_status status;
1035 struct acpi_table_ecdt *ecdt_ptr; 1580 struct acpi_table_ecdt *ecdt_ptr;
1036 1581
@@ -1044,22 +1589,22 @@ acpi_ec_get_real_ecdt(void)
1044 /* 1589 /*
1045 * Generate a temporary ec context to use until the namespace is scanned 1590 * Generate a temporary ec context to use until the namespace is scanned
1046 */ 1591 */
1047 ec_ecdt = kmalloc(sizeof(struct acpi_ec), GFP_KERNEL); 1592 ec_ecdt = kmalloc(sizeof(union acpi_ec), GFP_KERNEL);
1048 if (!ec_ecdt) 1593 if (!ec_ecdt)
1049 return -ENOMEM; 1594 return -ENOMEM;
1050 memset(ec_ecdt, 0, sizeof(struct acpi_ec)); 1595 memset(ec_ecdt, 0, sizeof(union acpi_ec));
1051 1596
1052 init_MUTEX(&ec_ecdt->sem); 1597 init_MUTEX(&ec_ecdt->burst.sem);
1053 init_waitqueue_head(&ec_ecdt->wait); 1598 init_waitqueue_head(&ec_ecdt->burst.wait);
1054 ec_ecdt->command_addr = ecdt_ptr->ec_control; 1599 ec_ecdt->common.command_addr = ecdt_ptr->ec_control;
1055 ec_ecdt->status_addr = ecdt_ptr->ec_control; 1600 ec_ecdt->common.status_addr = ecdt_ptr->ec_control;
1056 ec_ecdt->data_addr = ecdt_ptr->ec_data; 1601 ec_ecdt->common.data_addr = ecdt_ptr->ec_data;
1057 ec_ecdt->gpe_bit = ecdt_ptr->gpe_bit; 1602 ec_ecdt->common.gpe_bit = ecdt_ptr->gpe_bit;
1058 /* use the GL just to be safe */ 1603 /* use the GL just to be safe */
1059 ec_ecdt->global_lock = TRUE; 1604 ec_ecdt->common.global_lock = TRUE;
1060 ec_ecdt->uid = ecdt_ptr->uid; 1605 ec_ecdt->common.uid = ecdt_ptr->uid;
1061 1606
1062 status = acpi_get_handle(NULL, ecdt_ptr->ec_id, &ec_ecdt->handle); 1607 status = acpi_get_handle(NULL, ecdt_ptr->ec_id, &ec_ecdt->common.handle);
1063 if (ACPI_FAILURE(status)) { 1608 if (ACPI_FAILURE(status)) {
1064 goto error; 1609 goto error;
1065 } 1610 }
@@ -1092,20 +1637,20 @@ acpi_ec_ecdt_probe (void)
1092 /* 1637 /*
1093 * Install GPE handler 1638 * Install GPE handler
1094 */ 1639 */
1095 status = acpi_install_gpe_handler(NULL, ec_ecdt->gpe_bit, 1640 status = acpi_install_gpe_handler(NULL, ec_ecdt->common.gpe_bit,
1096 ACPI_GPE_EDGE_TRIGGERED, &acpi_ec_gpe_handler, 1641 ACPI_GPE_EDGE_TRIGGERED, &acpi_ec_gpe_handler,
1097 ec_ecdt); 1642 ec_ecdt);
1098 if (ACPI_FAILURE(status)) { 1643 if (ACPI_FAILURE(status)) {
1099 goto error; 1644 goto error;
1100 } 1645 }
1101 acpi_set_gpe_type (NULL, ec_ecdt->gpe_bit, ACPI_GPE_TYPE_RUNTIME); 1646 acpi_set_gpe_type (NULL, ec_ecdt->common.gpe_bit, ACPI_GPE_TYPE_RUNTIME);
1102 acpi_enable_gpe (NULL, ec_ecdt->gpe_bit, ACPI_NOT_ISR); 1647 acpi_enable_gpe (NULL, ec_ecdt->common.gpe_bit, ACPI_NOT_ISR);
1103 1648
1104 status = acpi_install_address_space_handler (ACPI_ROOT_OBJECT, 1649 status = acpi_install_address_space_handler (ACPI_ROOT_OBJECT,
1105 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler, 1650 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler,
1106 &acpi_ec_space_setup, ec_ecdt); 1651 &acpi_ec_space_setup, ec_ecdt);
1107 if (ACPI_FAILURE(status)) { 1652 if (ACPI_FAILURE(status)) {
1108 acpi_remove_gpe_handler(NULL, ec_ecdt->gpe_bit, 1653 acpi_remove_gpe_handler(NULL, ec_ecdt->common.gpe_bit,
1109 &acpi_ec_gpe_handler); 1654 &acpi_ec_gpe_handler);
1110 goto error; 1655 goto error;
1111 } 1656 }
@@ -1123,7 +1668,7 @@ error:
1123 1668
1124static int __init acpi_ec_init (void) 1669static int __init acpi_ec_init (void)
1125{ 1670{
1126 int result; 1671 int result = 0;
1127 1672
1128 ACPI_FUNCTION_TRACE("acpi_ec_init"); 1673 ACPI_FUNCTION_TRACE("acpi_ec_init");
1129 1674
@@ -1166,4 +1711,24 @@ static int __init acpi_fake_ecdt_setup(char *str)
1166 acpi_fake_ecdt_enabled = 1; 1711 acpi_fake_ecdt_enabled = 1;
1167 return 0; 1712 return 0;
1168} 1713}
1714
1169__setup("acpi_fake_ecdt", acpi_fake_ecdt_setup); 1715__setup("acpi_fake_ecdt", acpi_fake_ecdt_setup);
1716static int __init acpi_ec_set_polling_mode(char *str)
1717{
1718 int burst;
1719
1720 if (!get_option(&str, &burst))
1721 return 0;
1722
1723 if (burst) {
1724 acpi_ec_polling_mode = EC_BURST;
1725 acpi_ec_driver.ops.add = acpi_ec_burst_add;
1726 } else {
1727 acpi_ec_polling_mode = EC_POLLING;
1728 acpi_ec_driver.ops.add = acpi_ec_polling_add;
1729 }
1730 printk(KERN_INFO PREFIX "EC %s mode.\n",
1731 burst ? "burst": "polling");
1732 return 0;
1733}
1734__setup("ec_burst=", acpi_ec_set_polling_mode);