aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLen Brown <len.brown@intel.com>2005-07-29 23:11:11 -0400
committerLen Brown <len.brown@intel.com>2005-07-29 23:11:11 -0400
commitdd8f39bbf5154cdbfd698fc70c66faba33eafa44 (patch)
tree9df3fe38a57d0ea056ffa11b1fb95b8908e73af5 /drivers
parentc2c2e03409f5f5405e79d9d9156202b75cb5b35b (diff)
parent87bec66b9691522414862dd8d41e430b063735ef (diff)
Merge ../to-linus
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/ec.c910
-rw-r--r--drivers/acpi/pci_irq.c85
-rw-r--r--drivers/acpi/pci_link.c103
-rw-r--r--drivers/acpi/processor_idle.c31
-rw-r--r--drivers/net/sk98lin/skge.c63
-rw-r--r--drivers/pcmcia/yenta_socket.c9
6 files changed, 960 insertions, 241 deletions
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index 8e665f2e3138..2dadb7f63269 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -59,76 +59,185 @@ 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);
72 79
73static struct acpi_driver acpi_ec_driver = { 80static struct acpi_driver acpi_ec_driver = {
74 .name = ACPI_EC_DRIVER_NAME, 81 .name = ACPI_EC_DRIVER_NAME,
75 .class = ACPI_EC_CLASS, 82 .class = ACPI_EC_CLASS,
76 .ids = ACPI_EC_HID, 83 .ids = ACPI_EC_HID,
77 .ops = { 84 .ops = {
78 .add = acpi_ec_add, 85 .add = acpi_ec_burst_add,
79 .remove = acpi_ec_remove, 86 .remove = acpi_ec_remove,
80 .start = acpi_ec_start, 87 .start = acpi_ec_start,
81 .stop = acpi_ec_stop, 88 .stop = acpi_ec_stop,
82 }, 89 },
83}; 90};
84 91union acpi_ec {
85struct acpi_ec { 92 struct {
86 acpi_handle handle; 93 u32 mode;
87 unsigned long uid; 94 acpi_handle handle;
88 unsigned long gpe_bit; 95 unsigned long uid;
89 struct acpi_generic_address status_addr; 96 unsigned long gpe_bit;
90 struct acpi_generic_address command_addr; 97 struct acpi_generic_address status_addr;
91 struct acpi_generic_address data_addr; 98 struct acpi_generic_address command_addr;
92 unsigned long global_lock; 99 struct acpi_generic_address data_addr;
93 unsigned int expect_event; 100 unsigned long global_lock;
94 atomic_t leaving_burst; /* 0 : No, 1 : Yes, 2: abort*/ 101 } common;
95 atomic_t pending_gpe; 102
96 struct semaphore sem; 103 struct {
97 wait_queue_head_t wait; 104 u32 mode;
105 acpi_handle handle;
106 unsigned long uid;
107 unsigned long gpe_bit;
108 struct acpi_generic_address status_addr;
109 struct acpi_generic_address command_addr;
110 struct acpi_generic_address data_addr;
111 unsigned long global_lock;
112 unsigned int expect_event;
113 atomic_t leaving_burst; /* 0 : No, 1 : Yes, 2: abort*/
114 atomic_t pending_gpe;
115 struct semaphore sem;
116 wait_queue_head_t wait;
117 }burst;
118
119 struct {
120 u32 mode;
121 acpi_handle handle;
122 unsigned long uid;
123 unsigned long gpe_bit;
124 struct acpi_generic_address status_addr;
125 struct acpi_generic_address command_addr;
126 struct acpi_generic_address data_addr;
127 unsigned long global_lock;
128 spinlock_t lock;
129 }polling;
98}; 130};
99 131
132static int acpi_ec_polling_wait ( union acpi_ec *ec, u8 event);
133static int acpi_ec_burst_wait(union acpi_ec *ec, unsigned int event);
134static int acpi_ec_polling_read ( union acpi_ec *ec, u8 address, u32 *data);
135static int acpi_ec_burst_read( union acpi_ec *ec, u8 address, u32 *data);
136static int acpi_ec_polling_write ( union acpi_ec *ec, u8 address, u8 data);
137static int acpi_ec_burst_write ( union acpi_ec *ec, u8 address, u8 data);
138static int acpi_ec_polling_query ( union acpi_ec *ec, u32 *data);
139static int acpi_ec_burst_query ( union acpi_ec *ec, u32 *data);
140static void acpi_ec_gpe_polling_query ( void *ec_cxt);
141static void acpi_ec_gpe_burst_query ( void *ec_cxt);
142static u32 acpi_ec_gpe_polling_handler ( void *data);
143static u32 acpi_ec_gpe_burst_handler ( void *data);
144static acpi_status __init
145acpi_fake_ecdt_polling_callback (
146 acpi_handle handle,
147 u32 Level,
148 void *context,
149 void **retval);
150
151static acpi_status __init
152acpi_fake_ecdt_burst_callback (
153 acpi_handle handle,
154 u32 Level,
155 void *context,
156 void **retval);
157
158static int __init
159acpi_ec_polling_get_real_ecdt(void);
160static int __init
161acpi_ec_burst_get_real_ecdt(void);
100/* If we find an EC via the ECDT, we need to keep a ptr to its context */ 162/* If we find an EC via the ECDT, we need to keep a ptr to its context */
101static struct acpi_ec *ec_ecdt; 163static union acpi_ec *ec_ecdt;
102 164
103/* External interfaces use first EC only, so remember */ 165/* External interfaces use first EC only, so remember */
104static struct acpi_device *first_ec; 166static struct acpi_device *first_ec;
167static int acpi_ec_polling_mode;
105 168
106/* -------------------------------------------------------------------------- 169/* --------------------------------------------------------------------------
107 Transaction Management 170 Transaction Management
108 -------------------------------------------------------------------------- */ 171 -------------------------------------------------------------------------- */
109 172
110static inline u32 acpi_ec_read_status(struct acpi_ec *ec) 173static inline u32 acpi_ec_read_status(union acpi_ec *ec)
111{ 174{
112 u32 status = 0; 175 u32 status = 0;
113 176
114 acpi_hw_low_level_read(8, &status, &ec->status_addr); 177 acpi_hw_low_level_read(8, &status, &ec->common.status_addr);
115 return status; 178 return status;
116} 179}
117 180
118static int acpi_ec_wait(struct acpi_ec *ec, unsigned int event) 181static int
182acpi_ec_wait (
183 union acpi_ec *ec,
184 u8 event)
185{
186 if (acpi_ec_polling_mode)
187 return acpi_ec_polling_wait (ec, event);
188 else
189 return acpi_ec_burst_wait (ec, event);
190}
191
192static int
193acpi_ec_polling_wait (
194 union acpi_ec *ec,
195 u8 event)
196{
197 u32 acpi_ec_status = 0;
198 u32 i = ACPI_EC_UDELAY_COUNT;
199
200 if (!ec)
201 return -EINVAL;
202
203 /* Poll the EC status register waiting for the event to occur. */
204 switch (event) {
205 case ACPI_EC_EVENT_OBF:
206 do {
207 acpi_hw_low_level_read(8, &acpi_ec_status, &ec->common.status_addr);
208 if (acpi_ec_status & ACPI_EC_FLAG_OBF)
209 return 0;
210 udelay(ACPI_EC_UDELAY);
211 } while (--i>0);
212 break;
213 case ACPI_EC_EVENT_IBE:
214 do {
215 acpi_hw_low_level_read(8, &acpi_ec_status, &ec->common.status_addr);
216 if (!(acpi_ec_status & ACPI_EC_FLAG_IBF))
217 return 0;
218 udelay(ACPI_EC_UDELAY);
219 } while (--i>0);
220 break;
221 default:
222 return -EINVAL;
223 }
224
225 return -ETIME;
226}
227static int acpi_ec_burst_wait(union acpi_ec *ec, unsigned int event)
119{ 228{
120 int result = 0; 229 int result = 0;
121 230
122 ACPI_FUNCTION_TRACE("acpi_ec_wait"); 231 ACPI_FUNCTION_TRACE("acpi_ec_wait");
123 232
124 ec->expect_event = event; 233 ec->burst.expect_event = event;
125 smp_mb(); 234 smp_mb();
126 235
127 result = wait_event_interruptible_timeout(ec->wait, 236 result = wait_event_interruptible_timeout(ec->burst.wait,
128 !ec->expect_event, 237 !ec->burst.expect_event,
129 msecs_to_jiffies(ACPI_EC_DELAY)); 238 msecs_to_jiffies(ACPI_EC_DELAY));
130 239
131 ec->expect_event = 0; 240 ec->burst.expect_event = 0;
132 smp_mb(); 241 smp_mb();
133 242
134 if (result < 0){ 243 if (result < 0){
@@ -160,7 +269,7 @@ static int acpi_ec_wait(struct acpi_ec *ec, unsigned int event)
160 269
161static int 270static int
162acpi_ec_enter_burst_mode ( 271acpi_ec_enter_burst_mode (
163 struct acpi_ec *ec) 272 union acpi_ec *ec)
164{ 273{
165 u32 tmp = 0; 274 u32 tmp = 0;
166 int status = 0; 275 int status = 0;
@@ -170,63 +279,176 @@ acpi_ec_enter_burst_mode (
170 status = acpi_ec_read_status(ec); 279 status = acpi_ec_read_status(ec);
171 if (status != -EINVAL && 280 if (status != -EINVAL &&
172 !(status & ACPI_EC_FLAG_BURST)){ 281 !(status & ACPI_EC_FLAG_BURST)){
173 ACPI_DEBUG_PRINT((ACPI_DB_INFO,"entering burst mode \n")); 282 acpi_hw_low_level_write(8, ACPI_EC_BURST_ENABLE, &ec->common.command_addr);
174 acpi_hw_low_level_write(8, ACPI_EC_BURST_ENABLE, &ec->command_addr);
175 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); 283 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
176 if (status){ 284 if (status){
177 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); 285 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
178 ACPI_DEBUG_PRINT((ACPI_DB_ERROR," status = %d\n", status));
179 return_VALUE(-EINVAL); 286 return_VALUE(-EINVAL);
180 } 287 }
181 acpi_hw_low_level_read(8, &tmp, &ec->data_addr); 288 acpi_hw_low_level_read(8, &tmp, &ec->common.data_addr);
182 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); 289 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
183 if(tmp != 0x90 ) {/* Burst ACK byte*/ 290 if(tmp != 0x90 ) {/* Burst ACK byte*/
184 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,"Ack failed \n"));
185 return_VALUE(-EINVAL); 291 return_VALUE(-EINVAL);
186 } 292 }
187 } else 293 }
188 ACPI_DEBUG_PRINT((ACPI_DB_INFO,"already be in burst mode \n")); 294
189 atomic_set(&ec->leaving_burst , 0); 295 atomic_set(&ec->burst.leaving_burst , 0);
190 return_VALUE(0); 296 return_VALUE(0);
191} 297}
192 298
193static int 299static int
194acpi_ec_leave_burst_mode ( 300acpi_ec_leave_burst_mode (
195 struct acpi_ec *ec) 301 union acpi_ec *ec)
196{ 302{
197 int status =0; 303 int status =0;
198 304
199 ACPI_FUNCTION_TRACE("acpi_ec_leave_burst_mode"); 305 ACPI_FUNCTION_TRACE("acpi_ec_leave_burst_mode");
200 306
201 atomic_set(&ec->leaving_burst , 1); 307 atomic_set(&ec->burst.leaving_burst , 1);
202 status = acpi_ec_read_status(ec); 308 status = acpi_ec_read_status(ec);
203 if (status != -EINVAL && 309 if (status != -EINVAL &&
204 (status & ACPI_EC_FLAG_BURST)){ 310 (status & ACPI_EC_FLAG_BURST)){
205 ACPI_DEBUG_PRINT((ACPI_DB_INFO,"leaving burst mode\n")); 311 acpi_hw_low_level_write(8, ACPI_EC_BURST_DISABLE, &ec->common.command_addr);
206 acpi_hw_low_level_write(8, ACPI_EC_BURST_DISABLE, &ec->command_addr);
207 status = acpi_ec_wait(ec, ACPI_EC_FLAG_IBF); 312 status = acpi_ec_wait(ec, ACPI_EC_FLAG_IBF);
208 if (status){ 313 if (status){
209 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); 314 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
210 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,"------->wait fail\n")); 315 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,"------->wait fail\n"));
211 return_VALUE(-EINVAL); 316 return_VALUE(-EINVAL);
212 } 317 }
213 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); 318 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
214 status = acpi_ec_read_status(ec); 319 status = acpi_ec_read_status(ec);
215 if (status != -EINVAL && 320 }
216 (status & ACPI_EC_FLAG_BURST)) {
217 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,"------->status fail\n"));
218 return_VALUE(-EINVAL);
219 }
220 }else
221 ACPI_DEBUG_PRINT((ACPI_DB_INFO,"already be in Non-burst mode \n"));
222 ACPI_DEBUG_PRINT((ACPI_DB_INFO,"leaving burst mode\n"));
223 321
224 return_VALUE(0); 322 return_VALUE(0);
225} 323}
226 324
227static int 325static int
228acpi_ec_read ( 326acpi_ec_read (
229 struct acpi_ec *ec, 327 union acpi_ec *ec,
328 u8 address,
329 u32 *data)
330{
331 if (acpi_ec_polling_mode)
332 return acpi_ec_polling_read(ec, address, data);
333 else
334 return acpi_ec_burst_read(ec, address, data);
335}
336static int
337acpi_ec_write (
338 union acpi_ec *ec,
339 u8 address,
340 u8 data)
341{
342 if (acpi_ec_polling_mode)
343 return acpi_ec_polling_write(ec, address, data);
344 else
345 return acpi_ec_burst_write(ec, address, data);
346}
347static int
348acpi_ec_polling_read (
349 union acpi_ec *ec,
350 u8 address,
351 u32 *data)
352{
353 acpi_status status = AE_OK;
354 int result = 0;
355 unsigned long flags = 0;
356 u32 glk = 0;
357
358 ACPI_FUNCTION_TRACE("acpi_ec_read");
359
360 if (!ec || !data)
361 return_VALUE(-EINVAL);
362
363 *data = 0;
364
365 if (ec->common.global_lock) {
366 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
367 if (ACPI_FAILURE(status))
368 return_VALUE(-ENODEV);
369 }
370
371 spin_lock_irqsave(&ec->polling.lock, flags);
372
373 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_READ, &ec->common.command_addr);
374 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
375 if (result)
376 goto end;
377
378 acpi_hw_low_level_write(8, address, &ec->common.data_addr);
379 result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
380 if (result)
381 goto end;
382
383 acpi_hw_low_level_read(8, data, &ec->common.data_addr);
384
385 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Read [%02x] from address [%02x]\n",
386 *data, address));
387
388end:
389 spin_unlock_irqrestore(&ec->polling.lock, flags);
390
391 if (ec->common.global_lock)
392 acpi_release_global_lock(glk);
393
394 return_VALUE(result);
395}
396
397
398static int
399acpi_ec_polling_write (
400 union acpi_ec *ec,
401 u8 address,
402 u8 data)
403{
404 int result = 0;
405 acpi_status status = AE_OK;
406 unsigned long flags = 0;
407 u32 glk = 0;
408
409 ACPI_FUNCTION_TRACE("acpi_ec_write");
410
411 if (!ec)
412 return_VALUE(-EINVAL);
413
414 if (ec->common.global_lock) {
415 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
416 if (ACPI_FAILURE(status))
417 return_VALUE(-ENODEV);
418 }
419
420 spin_lock_irqsave(&ec->polling.lock, flags);
421
422 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_WRITE, &ec->common.command_addr);
423 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
424 if (result)
425 goto end;
426
427 acpi_hw_low_level_write(8, address, &ec->common.data_addr);
428 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
429 if (result)
430 goto end;
431
432 acpi_hw_low_level_write(8, data, &ec->common.data_addr);
433 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
434 if (result)
435 goto end;
436
437 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Wrote [%02x] to address [%02x]\n",
438 data, address));
439
440end:
441 spin_unlock_irqrestore(&ec->polling.lock, flags);
442
443 if (ec->common.global_lock)
444 acpi_release_global_lock(glk);
445
446 return_VALUE(result);
447}
448
449static int
450acpi_ec_burst_read (
451 union acpi_ec *ec,
230 u8 address, 452 u8 address,
231 u32 *data) 453 u32 *data)
232{ 454{
@@ -241,51 +463,51 @@ acpi_ec_read (
241retry: 463retry:
242 *data = 0; 464 *data = 0;
243 465
244 if (ec->global_lock) { 466 if (ec->common.global_lock) {
245 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); 467 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
246 if (ACPI_FAILURE(status)) 468 if (ACPI_FAILURE(status))
247 return_VALUE(-ENODEV); 469 return_VALUE(-ENODEV);
248 } 470 }
249 471
250 WARN_ON(in_interrupt()); 472 WARN_ON(in_interrupt());
251 down(&ec->sem); 473 down(&ec->burst.sem);
252 474
253 if(acpi_ec_enter_burst_mode(ec)) 475 if(acpi_ec_enter_burst_mode(ec))
254 goto end; 476 goto end;
255 477
256 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_READ, &ec->command_addr); 478 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_READ, &ec->common.command_addr);
257 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); 479 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
258 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); 480 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
259 if (status) { 481 if (status) {
260 goto end; 482 goto end;
261 } 483 }
262 484
263 acpi_hw_low_level_write(8, address, &ec->data_addr); 485 acpi_hw_low_level_write(8, address, &ec->common.data_addr);
264 status= acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); 486 status= acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
265 if (status){ 487 if (status){
266 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); 488 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
267 goto end; 489 goto end;
268 } 490 }
269 491
270 acpi_hw_low_level_read(8, data, &ec->data_addr); 492 acpi_hw_low_level_read(8, data, &ec->common.data_addr);
271 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); 493 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
272 494
273 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Read [%02x] from address [%02x]\n", 495 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Read [%02x] from address [%02x]\n",
274 *data, address)); 496 *data, address));
275 497
276end: 498end:
277 acpi_ec_leave_burst_mode(ec); 499 acpi_ec_leave_burst_mode(ec);
278 up(&ec->sem); 500 up(&ec->burst.sem);
279 501
280 if (ec->global_lock) 502 if (ec->common.global_lock)
281 acpi_release_global_lock(glk); 503 acpi_release_global_lock(glk);
282 504
283 if(atomic_read(&ec->leaving_burst) == 2){ 505 if(atomic_read(&ec->burst.leaving_burst) == 2){
284 ACPI_DEBUG_PRINT((ACPI_DB_INFO,"aborted, retry ...\n")); 506 ACPI_DEBUG_PRINT((ACPI_DB_INFO,"aborted, retry ...\n"));
285 while(atomic_read(&ec->pending_gpe)){ 507 while(atomic_read(&ec->burst.pending_gpe)){
286 msleep(1); 508 msleep(1);
287 } 509 }
288 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); 510 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
289 goto retry; 511 goto retry;
290 } 512 }
291 513
@@ -294,8 +516,8 @@ end:
294 516
295 517
296static int 518static int
297acpi_ec_write ( 519acpi_ec_burst_write (
298 struct acpi_ec *ec, 520 union acpi_ec *ec,
299 u8 address, 521 u8 address,
300 u8 data) 522 u8 data)
301{ 523{
@@ -308,14 +530,14 @@ acpi_ec_write (
308 if (!ec) 530 if (!ec)
309 return_VALUE(-EINVAL); 531 return_VALUE(-EINVAL);
310retry: 532retry:
311 if (ec->global_lock) { 533 if (ec->common.global_lock) {
312 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); 534 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
313 if (ACPI_FAILURE(status)) 535 if (ACPI_FAILURE(status))
314 return_VALUE(-ENODEV); 536 return_VALUE(-ENODEV);
315 } 537 }
316 538
317 WARN_ON(in_interrupt()); 539 WARN_ON(in_interrupt());
318 down(&ec->sem); 540 down(&ec->burst.sem);
319 541
320 if(acpi_ec_enter_burst_mode(ec)) 542 if(acpi_ec_enter_burst_mode(ec))
321 goto end; 543 goto end;
@@ -323,33 +545,33 @@ retry:
323 status = acpi_ec_read_status(ec); 545 status = acpi_ec_read_status(ec);
324 if (status != -EINVAL && 546 if (status != -EINVAL &&
325 !(status & ACPI_EC_FLAG_BURST)){ 547 !(status & ACPI_EC_FLAG_BURST)){
326 acpi_hw_low_level_write(8, ACPI_EC_BURST_ENABLE, &ec->command_addr); 548 acpi_hw_low_level_write(8, ACPI_EC_BURST_ENABLE, &ec->common.command_addr);
327 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); 549 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
328 if (status) 550 if (status)
329 goto end; 551 goto end;
330 acpi_hw_low_level_read(8, &tmp, &ec->data_addr); 552 acpi_hw_low_level_read(8, &tmp, &ec->common.data_addr);
331 if(tmp != 0x90 ) /* Burst ACK byte*/ 553 if(tmp != 0x90 ) /* Burst ACK byte*/
332 goto end; 554 goto end;
333 } 555 }
334 /*Now we are in burst mode*/ 556 /*Now we are in burst mode*/
335 557
336 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_WRITE, &ec->command_addr); 558 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_WRITE, &ec->common.command_addr);
337 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); 559 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
338 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); 560 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
339 if (status){ 561 if (status){
340 goto end; 562 goto end;
341 } 563 }
342 564
343 acpi_hw_low_level_write(8, address, &ec->data_addr); 565 acpi_hw_low_level_write(8, address, &ec->common.data_addr);
344 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); 566 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
345 if (status){ 567 if (status){
346 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); 568 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
347 goto end; 569 goto end;
348 } 570 }
349 571
350 acpi_hw_low_level_write(8, data, &ec->data_addr); 572 acpi_hw_low_level_write(8, data, &ec->common.data_addr);
351 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); 573 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
352 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); 574 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
353 if (status) 575 if (status)
354 goto end; 576 goto end;
355 577
@@ -358,17 +580,17 @@ retry:
358 580
359end: 581end:
360 acpi_ec_leave_burst_mode(ec); 582 acpi_ec_leave_burst_mode(ec);
361 up(&ec->sem); 583 up(&ec->burst.sem);
362 584
363 if (ec->global_lock) 585 if (ec->common.global_lock)
364 acpi_release_global_lock(glk); 586 acpi_release_global_lock(glk);
365 587
366 if(atomic_read(&ec->leaving_burst) == 2){ 588 if(atomic_read(&ec->burst.leaving_burst) == 2){
367 ACPI_DEBUG_PRINT((ACPI_DB_INFO,"aborted, retry ...\n")); 589 ACPI_DEBUG_PRINT((ACPI_DB_INFO,"aborted, retry ...\n"));
368 while(atomic_read(&ec->pending_gpe)){ 590 while(atomic_read(&ec->burst.pending_gpe)){
369 msleep(1); 591 msleep(1);
370 } 592 }
371 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); 593 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
372 goto retry; 594 goto retry;
373 } 595 }
374 596
@@ -381,7 +603,7 @@ end:
381int 603int
382ec_read(u8 addr, u8 *val) 604ec_read(u8 addr, u8 *val)
383{ 605{
384 struct acpi_ec *ec; 606 union acpi_ec *ec;
385 int err; 607 int err;
386 u32 temp_data; 608 u32 temp_data;
387 609
@@ -404,7 +626,7 @@ EXPORT_SYMBOL(ec_read);
404int 626int
405ec_write(u8 addr, u8 val) 627ec_write(u8 addr, u8 val)
406{ 628{
407 struct acpi_ec *ec; 629 union acpi_ec *ec;
408 int err; 630 int err;
409 631
410 if (!first_ec) 632 if (!first_ec)
@@ -418,10 +640,66 @@ ec_write(u8 addr, u8 val)
418} 640}
419EXPORT_SYMBOL(ec_write); 641EXPORT_SYMBOL(ec_write);
420 642
421
422static int 643static int
423acpi_ec_query ( 644acpi_ec_query (
424 struct acpi_ec *ec, 645 union acpi_ec *ec,
646 u32 *data)
647{
648 if (acpi_ec_polling_mode)
649 return acpi_ec_polling_query(ec, data);
650 else
651 return acpi_ec_burst_query(ec, data);
652}
653static int
654acpi_ec_polling_query (
655 union acpi_ec *ec,
656 u32 *data)
657{
658 int result = 0;
659 acpi_status status = AE_OK;
660 unsigned long flags = 0;
661 u32 glk = 0;
662
663 ACPI_FUNCTION_TRACE("acpi_ec_query");
664
665 if (!ec || !data)
666 return_VALUE(-EINVAL);
667
668 *data = 0;
669
670 if (ec->common.global_lock) {
671 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
672 if (ACPI_FAILURE(status))
673 return_VALUE(-ENODEV);
674 }
675
676 /*
677 * Query the EC to find out which _Qxx method we need to evaluate.
678 * Note that successful completion of the query causes the ACPI_EC_SCI
679 * bit to be cleared (and thus clearing the interrupt source).
680 */
681 spin_lock_irqsave(&ec->polling.lock, flags);
682
683 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_QUERY, &ec->common.command_addr);
684 result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
685 if (result)
686 goto end;
687
688 acpi_hw_low_level_read(8, data, &ec->common.data_addr);
689 if (!*data)
690 result = -ENODATA;
691
692end:
693 spin_unlock_irqrestore(&ec->polling.lock, flags);
694
695 if (ec->common.global_lock)
696 acpi_release_global_lock(glk);
697
698 return_VALUE(result);
699}
700static int
701acpi_ec_burst_query (
702 union acpi_ec *ec,
425 u32 *data) 703 u32 *data)
426{ 704{
427 int status = 0; 705 int status = 0;
@@ -433,13 +711,13 @@ acpi_ec_query (
433 return_VALUE(-EINVAL); 711 return_VALUE(-EINVAL);
434 *data = 0; 712 *data = 0;
435 713
436 if (ec->global_lock) { 714 if (ec->common.global_lock) {
437 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); 715 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
438 if (ACPI_FAILURE(status)) 716 if (ACPI_FAILURE(status))
439 return_VALUE(-ENODEV); 717 return_VALUE(-ENODEV);
440 } 718 }
441 719
442 down(&ec->sem); 720 down(&ec->burst.sem);
443 if(acpi_ec_enter_burst_mode(ec)) 721 if(acpi_ec_enter_burst_mode(ec))
444 goto end; 722 goto end;
445 /* 723 /*
@@ -447,28 +725,28 @@ acpi_ec_query (
447 * Note that successful completion of the query causes the ACPI_EC_SCI 725 * Note that successful completion of the query causes the ACPI_EC_SCI
448 * bit to be cleared (and thus clearing the interrupt source). 726 * bit to be cleared (and thus clearing the interrupt source).
449 */ 727 */
450 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_QUERY, &ec->command_addr); 728 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_QUERY, &ec->common.command_addr);
451 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); 729 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
452 if (status){ 730 if (status){
453 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); 731 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
454 goto end; 732 goto end;
455 } 733 }
456 734
457 acpi_hw_low_level_read(8, data, &ec->data_addr); 735 acpi_hw_low_level_read(8, data, &ec->common.data_addr);
458 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); 736 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
459 if (!*data) 737 if (!*data)
460 status = -ENODATA; 738 status = -ENODATA;
461 739
462end: 740end:
463 acpi_ec_leave_burst_mode(ec); 741 acpi_ec_leave_burst_mode(ec);
464 up(&ec->sem); 742 up(&ec->burst.sem);
465 743
466 if (ec->global_lock) 744 if (ec->common.global_lock)
467 acpi_release_global_lock(glk); 745 acpi_release_global_lock(glk);
468 746
469 if(atomic_read(&ec->leaving_burst) == 2){ 747 if(atomic_read(&ec->burst.leaving_burst) == 2){
470 ACPI_DEBUG_PRINT((ACPI_DB_INFO,"aborted, retry ...\n")); 748 ACPI_DEBUG_PRINT((ACPI_DB_INFO,"aborted, retry ...\n"));
471 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); 749 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
472 status = -ENODATA; 750 status = -ENODATA;
473 } 751 }
474 return_VALUE(status); 752 return_VALUE(status);
@@ -479,7 +757,7 @@ end:
479 Event Management 757 Event Management
480 -------------------------------------------------------------------------- */ 758 -------------------------------------------------------------------------- */
481 759
482struct acpi_ec_query_data { 760union acpi_ec_query_data {
483 acpi_handle handle; 761 acpi_handle handle;
484 u8 data; 762 u8 data;
485}; 763};
@@ -488,7 +766,59 @@ static void
488acpi_ec_gpe_query ( 766acpi_ec_gpe_query (
489 void *ec_cxt) 767 void *ec_cxt)
490{ 768{
491 struct acpi_ec *ec = (struct acpi_ec *) ec_cxt; 769 if (acpi_ec_polling_mode)
770 acpi_ec_gpe_polling_query(ec_cxt);
771 else
772 acpi_ec_gpe_burst_query(ec_cxt);
773}
774
775static void
776acpi_ec_gpe_polling_query (
777 void *ec_cxt)
778{
779 union acpi_ec *ec = (union acpi_ec *) ec_cxt;
780 u32 value = 0;
781 unsigned long flags = 0;
782 static char object_name[5] = {'_','Q','0','0','\0'};
783 const char hex[] = {'0','1','2','3','4','5','6','7',
784 '8','9','A','B','C','D','E','F'};
785
786 ACPI_FUNCTION_TRACE("acpi_ec_gpe_query");
787
788 if (!ec_cxt)
789 goto end;
790
791 spin_lock_irqsave(&ec->polling.lock, flags);
792 acpi_hw_low_level_read(8, &value, &ec->common.command_addr);
793 spin_unlock_irqrestore(&ec->polling.lock, flags);
794
795 /* TBD: Implement asynch events!
796 * NOTE: All we care about are EC-SCI's. Other EC events are
797 * handled via polling (yuck!). This is because some systems
798 * treat EC-SCIs as level (versus EDGE!) triggered, preventing
799 * a purely interrupt-driven approach (grumble, grumble).
800 */
801 if (!(value & ACPI_EC_FLAG_SCI))
802 goto end;
803
804 if (acpi_ec_query(ec, &value))
805 goto end;
806
807 object_name[2] = hex[((value >> 4) & 0x0F)];
808 object_name[3] = hex[(value & 0x0F)];
809
810 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluating %s\n", object_name));
811
812 acpi_evaluate_object(ec->common.handle, object_name, NULL, NULL);
813
814end:
815 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
816}
817static void
818acpi_ec_gpe_burst_query (
819 void *ec_cxt)
820{
821 union acpi_ec *ec = (union acpi_ec *) ec_cxt;
492 u32 value; 822 u32 value;
493 int result = -ENODATA; 823 int result = -ENODATA;
494 static char object_name[5] = {'_','Q','0','0','\0'}; 824 static char object_name[5] = {'_','Q','0','0','\0'};
@@ -508,9 +838,9 @@ acpi_ec_gpe_query (
508 838
509 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluating %s\n", object_name)); 839 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluating %s\n", object_name));
510 840
511 acpi_evaluate_object(ec->handle, object_name, NULL, NULL); 841 acpi_evaluate_object(ec->common.handle, object_name, NULL, NULL);
512end: 842end:
513 atomic_dec(&ec->pending_gpe); 843 atomic_dec(&ec->burst.pending_gpe);
514 return; 844 return;
515} 845}
516 846
@@ -518,48 +848,77 @@ static u32
518acpi_ec_gpe_handler ( 848acpi_ec_gpe_handler (
519 void *data) 849 void *data)
520{ 850{
851 if (acpi_ec_polling_mode)
852 return acpi_ec_gpe_polling_handler(data);
853 else
854 return acpi_ec_gpe_burst_handler(data);
855}
856static u32
857acpi_ec_gpe_polling_handler (
858 void *data)
859{
860 acpi_status status = AE_OK;
861 union acpi_ec *ec = (union acpi_ec *) data;
862
863 if (!ec)
864 return ACPI_INTERRUPT_NOT_HANDLED;
865
866 acpi_disable_gpe(NULL, ec->common.gpe_bit, ACPI_ISR);
867
868 status = acpi_os_queue_for_execution(OSD_PRIORITY_GPE,
869 acpi_ec_gpe_query, ec);
870
871 if (status == AE_OK)
872 return ACPI_INTERRUPT_HANDLED;
873 else
874 return ACPI_INTERRUPT_NOT_HANDLED;
875}
876static u32
877acpi_ec_gpe_burst_handler (
878 void *data)
879{
521 acpi_status status = AE_OK; 880 acpi_status status = AE_OK;
522 u32 value; 881 u32 value;
523 struct acpi_ec *ec = (struct acpi_ec *) data; 882 union acpi_ec *ec = (union acpi_ec *) data;
524 883
525 if (!ec) 884 if (!ec)
526 return ACPI_INTERRUPT_NOT_HANDLED; 885 return ACPI_INTERRUPT_NOT_HANDLED;
527 886
528 acpi_disable_gpe(NULL, ec->gpe_bit, ACPI_ISR); 887 acpi_disable_gpe(NULL, ec->common.gpe_bit, ACPI_ISR);
529 888
530 value = acpi_ec_read_status(ec); 889 value = acpi_ec_read_status(ec);
531 890
532 if((value & ACPI_EC_FLAG_IBF) && 891 if((value & ACPI_EC_FLAG_IBF) &&
533 !(value & ACPI_EC_FLAG_BURST) && 892 !(value & ACPI_EC_FLAG_BURST) &&
534 (atomic_read(&ec->leaving_burst) == 0)) { 893 (atomic_read(&ec->burst.leaving_burst) == 0)) {
535 /* 894 /*
536 * the embedded controller disables 895 * the embedded controller disables
537 * burst mode for any reason other 896 * burst mode for any reason other
538 * than the burst disable command 897 * than the burst disable command
539 * to process critical event. 898 * to process critical event.
540 */ 899 */
541 atomic_set(&ec->leaving_burst , 2); /* block current pending transaction 900 atomic_set(&ec->burst.leaving_burst , 2); /* block current pending transaction
542 and retry */ 901 and retry */
543 wake_up(&ec->wait); 902 wake_up(&ec->burst.wait);
544 }else { 903 }else {
545 if ((ec->expect_event == ACPI_EC_EVENT_OBF && 904 if ((ec->burst.expect_event == ACPI_EC_EVENT_OBF &&
546 (value & ACPI_EC_FLAG_OBF)) || 905 (value & ACPI_EC_FLAG_OBF)) ||
547 (ec->expect_event == ACPI_EC_EVENT_IBE && 906 (ec->burst.expect_event == ACPI_EC_EVENT_IBE &&
548 !(value & ACPI_EC_FLAG_IBF))) { 907 !(value & ACPI_EC_FLAG_IBF))) {
549 ec->expect_event = 0; 908 ec->burst.expect_event = 0;
550 wake_up(&ec->wait); 909 wake_up(&ec->burst.wait);
551 return ACPI_INTERRUPT_HANDLED; 910 return ACPI_INTERRUPT_HANDLED;
552 } 911 }
553 } 912 }
554 913
555 if (value & ACPI_EC_FLAG_SCI){ 914 if (value & ACPI_EC_FLAG_SCI){
556 atomic_add(1, &ec->pending_gpe) ; 915 atomic_add(1, &ec->burst.pending_gpe) ;
557 status = acpi_os_queue_for_execution(OSD_PRIORITY_GPE, 916 status = acpi_os_queue_for_execution(OSD_PRIORITY_GPE,
558 acpi_ec_gpe_query, ec); 917 acpi_ec_gpe_query, ec);
559 return status == AE_OK ? 918 return status == AE_OK ?
560 ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED; 919 ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED;
561 } 920 }
562 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_ISR); 921 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_ISR);
563 return status == AE_OK ? 922 return status == AE_OK ?
564 ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED; 923 ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED;
565} 924}
@@ -596,7 +955,7 @@ acpi_ec_space_handler (
596 void *region_context) 955 void *region_context)
597{ 956{
598 int result = 0; 957 int result = 0;
599 struct acpi_ec *ec = NULL; 958 union acpi_ec *ec = NULL;
600 u64 temp = *value; 959 u64 temp = *value;
601 acpi_integer f_v = 0; 960 acpi_integer f_v = 0;
602 int i = 0; 961 int i = 0;
@@ -611,7 +970,7 @@ acpi_ec_space_handler (
611 return_VALUE(AE_BAD_PARAMETER); 970 return_VALUE(AE_BAD_PARAMETER);
612 } 971 }
613 972
614 ec = (struct acpi_ec *) handler_context; 973 ec = (union acpi_ec *) handler_context;
615 974
616next_byte: 975next_byte:
617 switch (function) { 976 switch (function) {
@@ -672,7 +1031,7 @@ static struct proc_dir_entry *acpi_ec_dir;
672static int 1031static int
673acpi_ec_read_info (struct seq_file *seq, void *offset) 1032acpi_ec_read_info (struct seq_file *seq, void *offset)
674{ 1033{
675 struct acpi_ec *ec = (struct acpi_ec *) seq->private; 1034 union acpi_ec *ec = (union acpi_ec *) seq->private;
676 1035
677 ACPI_FUNCTION_TRACE("acpi_ec_read_info"); 1036 ACPI_FUNCTION_TRACE("acpi_ec_read_info");
678 1037
@@ -680,12 +1039,12 @@ acpi_ec_read_info (struct seq_file *seq, void *offset)
680 goto end; 1039 goto end;
681 1040
682 seq_printf(seq, "gpe bit: 0x%02x\n", 1041 seq_printf(seq, "gpe bit: 0x%02x\n",
683 (u32) ec->gpe_bit); 1042 (u32) ec->common.gpe_bit);
684 seq_printf(seq, "ports: 0x%02x, 0x%02x\n", 1043 seq_printf(seq, "ports: 0x%02x, 0x%02x\n",
685 (u32) ec->status_addr.address, (u32) ec->data_addr.address); 1044 (u32) ec->common.status_addr.address, (u32) ec->common.data_addr.address);
686 seq_printf(seq, "use global lock: %s\n", 1045 seq_printf(seq, "use global lock: %s\n",
687 ec->global_lock?"yes":"no"); 1046 ec->common.global_lock?"yes":"no");
688 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); 1047 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
689 1048
690end: 1049end:
691 return_VALUE(0); 1050 return_VALUE(0);
@@ -708,7 +1067,7 @@ static int
708acpi_ec_add_fs ( 1067acpi_ec_add_fs (
709 struct acpi_device *device) 1068 struct acpi_device *device)
710{ 1069{
711 struct proc_dir_entry *entry; 1070 struct proc_dir_entry *entry = NULL;
712 1071
713 ACPI_FUNCTION_TRACE("acpi_ec_add_fs"); 1072 ACPI_FUNCTION_TRACE("acpi_ec_add_fs");
714 1073
@@ -755,13 +1114,82 @@ acpi_ec_remove_fs (
755 Driver Interface 1114 Driver Interface
756 -------------------------------------------------------------------------- */ 1115 -------------------------------------------------------------------------- */
757 1116
1117
758static int 1118static int
759acpi_ec_add ( 1119acpi_ec_polling_add (
760 struct acpi_device *device) 1120 struct acpi_device *device)
761{ 1121{
762 int result; 1122 int result = 0;
763 acpi_status status; 1123 acpi_status status = AE_OK;
764 struct acpi_ec *ec; 1124 union acpi_ec *ec = NULL;
1125 unsigned long uid;
1126
1127 ACPI_FUNCTION_TRACE("acpi_ec_add");
1128
1129 if (!device)
1130 return_VALUE(-EINVAL);
1131
1132 ec = kmalloc(sizeof(union acpi_ec), GFP_KERNEL);
1133 if (!ec)
1134 return_VALUE(-ENOMEM);
1135 memset(ec, 0, sizeof(union acpi_ec));
1136
1137 ec->common.handle = device->handle;
1138 ec->common.uid = -1;
1139 spin_lock_init(&ec->polling.lock);
1140 strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME);
1141 strcpy(acpi_device_class(device), ACPI_EC_CLASS);
1142 acpi_driver_data(device) = ec;
1143
1144 /* Use the global lock for all EC transactions? */
1145 acpi_evaluate_integer(ec->common.handle, "_GLK", NULL, &ec->common.global_lock);
1146
1147 /* If our UID matches the UID for the ECDT-enumerated EC,
1148 we now have the *real* EC info, so kill the makeshift one.*/
1149 acpi_evaluate_integer(ec->common.handle, "_UID", NULL, &uid);
1150 if (ec_ecdt && ec_ecdt->common.uid == uid) {
1151 acpi_remove_address_space_handler(ACPI_ROOT_OBJECT,
1152 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler);
1153
1154 acpi_remove_gpe_handler(NULL, ec_ecdt->common.gpe_bit, &acpi_ec_gpe_handler);
1155
1156 kfree(ec_ecdt);
1157 }
1158
1159 /* Get GPE bit assignment (EC events). */
1160 /* TODO: Add support for _GPE returning a package */
1161 status = acpi_evaluate_integer(ec->common.handle, "_GPE", NULL, &ec->common.gpe_bit);
1162 if (ACPI_FAILURE(status)) {
1163 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1164 "Error obtaining GPE bit assignment\n"));
1165 result = -ENODEV;
1166 goto end;
1167 }
1168
1169 result = acpi_ec_add_fs(device);
1170 if (result)
1171 goto end;
1172
1173 printk(KERN_INFO PREFIX "%s [%s] (gpe %d)\n",
1174 acpi_device_name(device), acpi_device_bid(device),
1175 (u32) ec->common.gpe_bit);
1176
1177 if (!first_ec)
1178 first_ec = device;
1179
1180end:
1181 if (result)
1182 kfree(ec);
1183
1184 return_VALUE(result);
1185}
1186static int
1187acpi_ec_burst_add (
1188 struct acpi_device *device)
1189{
1190 int result = 0;
1191 acpi_status status = AE_OK;
1192 union acpi_ec *ec = NULL;
765 unsigned long uid; 1193 unsigned long uid;
766 1194
767 ACPI_FUNCTION_TRACE("acpi_ec_add"); 1195 ACPI_FUNCTION_TRACE("acpi_ec_add");
@@ -769,39 +1197,39 @@ acpi_ec_add (
769 if (!device) 1197 if (!device)
770 return_VALUE(-EINVAL); 1198 return_VALUE(-EINVAL);
771 1199
772 ec = kmalloc(sizeof(struct acpi_ec), GFP_KERNEL); 1200 ec = kmalloc(sizeof(union acpi_ec), GFP_KERNEL);
773 if (!ec) 1201 if (!ec)
774 return_VALUE(-ENOMEM); 1202 return_VALUE(-ENOMEM);
775 memset(ec, 0, sizeof(struct acpi_ec)); 1203 memset(ec, 0, sizeof(union acpi_ec));
776 1204
777 ec->handle = device->handle; 1205 ec->common.handle = device->handle;
778 ec->uid = -1; 1206 ec->common.uid = -1;
779 atomic_set(&ec->pending_gpe, 0); 1207 atomic_set(&ec->burst.pending_gpe, 0);
780 atomic_set(&ec->leaving_burst , 1); 1208 atomic_set(&ec->burst.leaving_burst , 1);
781 init_MUTEX(&ec->sem); 1209 init_MUTEX(&ec->burst.sem);
782 init_waitqueue_head(&ec->wait); 1210 init_waitqueue_head(&ec->burst.wait);
783 strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME); 1211 strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME);
784 strcpy(acpi_device_class(device), ACPI_EC_CLASS); 1212 strcpy(acpi_device_class(device), ACPI_EC_CLASS);
785 acpi_driver_data(device) = ec; 1213 acpi_driver_data(device) = ec;
786 1214
787 /* Use the global lock for all EC transactions? */ 1215 /* Use the global lock for all EC transactions? */
788 acpi_evaluate_integer(ec->handle, "_GLK", NULL, &ec->global_lock); 1216 acpi_evaluate_integer(ec->common.handle, "_GLK", NULL, &ec->common.global_lock);
789 1217
790 /* If our UID matches the UID for the ECDT-enumerated EC, 1218 /* If our UID matches the UID for the ECDT-enumerated EC,
791 we now have the *real* EC info, so kill the makeshift one.*/ 1219 we now have the *real* EC info, so kill the makeshift one.*/
792 acpi_evaluate_integer(ec->handle, "_UID", NULL, &uid); 1220 acpi_evaluate_integer(ec->common.handle, "_UID", NULL, &uid);
793 if (ec_ecdt && ec_ecdt->uid == uid) { 1221 if (ec_ecdt && ec_ecdt->common.uid == uid) {
794 acpi_remove_address_space_handler(ACPI_ROOT_OBJECT, 1222 acpi_remove_address_space_handler(ACPI_ROOT_OBJECT,
795 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler); 1223 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler);
796 1224
797 acpi_remove_gpe_handler(NULL, ec_ecdt->gpe_bit, &acpi_ec_gpe_handler); 1225 acpi_remove_gpe_handler(NULL, ec_ecdt->common.gpe_bit, &acpi_ec_gpe_handler);
798 1226
799 kfree(ec_ecdt); 1227 kfree(ec_ecdt);
800 } 1228 }
801 1229
802 /* Get GPE bit assignment (EC events). */ 1230 /* Get GPE bit assignment (EC events). */
803 /* TODO: Add support for _GPE returning a package */ 1231 /* TODO: Add support for _GPE returning a package */
804 status = acpi_evaluate_integer(ec->handle, "_GPE", NULL, &ec->gpe_bit); 1232 status = acpi_evaluate_integer(ec->common.handle, "_GPE", NULL, &ec->common.gpe_bit);
805 if (ACPI_FAILURE(status)) { 1233 if (ACPI_FAILURE(status)) {
806 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1234 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
807 "Error obtaining GPE bit assignment\n")); 1235 "Error obtaining GPE bit assignment\n"));
@@ -815,7 +1243,7 @@ acpi_ec_add (
815 1243
816 printk(KERN_INFO PREFIX "%s [%s] (gpe %d)\n", 1244 printk(KERN_INFO PREFIX "%s [%s] (gpe %d)\n",
817 acpi_device_name(device), acpi_device_bid(device), 1245 acpi_device_name(device), acpi_device_bid(device),
818 (u32) ec->gpe_bit); 1246 (u32) ec->common.gpe_bit);
819 1247
820 if (!first_ec) 1248 if (!first_ec)
821 first_ec = device; 1249 first_ec = device;
@@ -833,7 +1261,7 @@ acpi_ec_remove (
833 struct acpi_device *device, 1261 struct acpi_device *device,
834 int type) 1262 int type)
835{ 1263{
836 struct acpi_ec *ec; 1264 union acpi_ec *ec = NULL;
837 1265
838 ACPI_FUNCTION_TRACE("acpi_ec_remove"); 1266 ACPI_FUNCTION_TRACE("acpi_ec_remove");
839 1267
@@ -855,7 +1283,7 @@ acpi_ec_io_ports (
855 struct acpi_resource *resource, 1283 struct acpi_resource *resource,
856 void *context) 1284 void *context)
857{ 1285{
858 struct acpi_ec *ec = (struct acpi_ec *) context; 1286 union acpi_ec *ec = (union acpi_ec *) context;
859 struct acpi_generic_address *addr; 1287 struct acpi_generic_address *addr;
860 1288
861 if (resource->id != ACPI_RSTYPE_IO) { 1289 if (resource->id != ACPI_RSTYPE_IO) {
@@ -867,10 +1295,10 @@ acpi_ec_io_ports (
867 * the second address region returned is the status/command 1295 * the second address region returned is the status/command
868 * port. 1296 * port.
869 */ 1297 */
870 if (ec->data_addr.register_bit_width == 0) { 1298 if (ec->common.data_addr.register_bit_width == 0) {
871 addr = &ec->data_addr; 1299 addr = &ec->common.data_addr;
872 } else if (ec->command_addr.register_bit_width == 0) { 1300 } else if (ec->common.command_addr.register_bit_width == 0) {
873 addr = &ec->command_addr; 1301 addr = &ec->common.command_addr;
874 } else { 1302 } else {
875 return AE_CTRL_TERMINATE; 1303 return AE_CTRL_TERMINATE;
876 } 1304 }
@@ -888,8 +1316,8 @@ static int
888acpi_ec_start ( 1316acpi_ec_start (
889 struct acpi_device *device) 1317 struct acpi_device *device)
890{ 1318{
891 acpi_status status; 1319 acpi_status status = AE_OK;
892 struct acpi_ec *ec; 1320 union acpi_ec *ec = NULL;
893 1321
894 ACPI_FUNCTION_TRACE("acpi_ec_start"); 1322 ACPI_FUNCTION_TRACE("acpi_ec_start");
895 1323
@@ -904,35 +1332,36 @@ acpi_ec_start (
904 /* 1332 /*
905 * Get I/O port addresses. Convert to GAS format. 1333 * Get I/O port addresses. Convert to GAS format.
906 */ 1334 */
907 status = acpi_walk_resources(ec->handle, METHOD_NAME__CRS, 1335 status = acpi_walk_resources(ec->common.handle, METHOD_NAME__CRS,
908 acpi_ec_io_ports, ec); 1336 acpi_ec_io_ports, ec);
909 if (ACPI_FAILURE(status) || ec->command_addr.register_bit_width == 0) { 1337 if (ACPI_FAILURE(status) || ec->common.command_addr.register_bit_width == 0) {
910 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error getting I/O port addresses")); 1338 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error getting I/O port addresses"));
911 return_VALUE(-ENODEV); 1339 return_VALUE(-ENODEV);
912 } 1340 }
913 1341
914 ec->status_addr = ec->command_addr; 1342 ec->common.status_addr = ec->common.command_addr;
915 1343
916 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "gpe=0x%02x, ports=0x%2x,0x%2x\n", 1344 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "gpe=0x%02x, ports=0x%2x,0x%2x\n",
917 (u32) ec->gpe_bit, (u32) ec->command_addr.address, 1345 (u32) ec->common.gpe_bit, (u32) ec->common.command_addr.address,
918 (u32) ec->data_addr.address)); 1346 (u32) ec->common.data_addr.address));
1347
919 1348
920 /* 1349 /*
921 * Install GPE handler 1350 * Install GPE handler
922 */ 1351 */
923 status = acpi_install_gpe_handler(NULL, ec->gpe_bit, 1352 status = acpi_install_gpe_handler(NULL, ec->common.gpe_bit,
924 ACPI_GPE_EDGE_TRIGGERED, &acpi_ec_gpe_handler, ec); 1353 ACPI_GPE_EDGE_TRIGGERED, &acpi_ec_gpe_handler, ec);
925 if (ACPI_FAILURE(status)) { 1354 if (ACPI_FAILURE(status)) {
926 return_VALUE(-ENODEV); 1355 return_VALUE(-ENODEV);
927 } 1356 }
928 acpi_set_gpe_type (NULL, ec->gpe_bit, ACPI_GPE_TYPE_RUNTIME); 1357 acpi_set_gpe_type (NULL, ec->common.gpe_bit, ACPI_GPE_TYPE_RUNTIME);
929 acpi_enable_gpe (NULL, ec->gpe_bit, ACPI_NOT_ISR); 1358 acpi_enable_gpe (NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
930 1359
931 status = acpi_install_address_space_handler (ec->handle, 1360 status = acpi_install_address_space_handler (ec->common.handle,
932 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler, 1361 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler,
933 &acpi_ec_space_setup, ec); 1362 &acpi_ec_space_setup, ec);
934 if (ACPI_FAILURE(status)) { 1363 if (ACPI_FAILURE(status)) {
935 acpi_remove_gpe_handler(NULL, ec->gpe_bit, &acpi_ec_gpe_handler); 1364 acpi_remove_gpe_handler(NULL, ec->common.gpe_bit, &acpi_ec_gpe_handler);
936 return_VALUE(-ENODEV); 1365 return_VALUE(-ENODEV);
937 } 1366 }
938 1367
@@ -945,8 +1374,8 @@ acpi_ec_stop (
945 struct acpi_device *device, 1374 struct acpi_device *device,
946 int type) 1375 int type)
947{ 1376{
948 acpi_status status; 1377 acpi_status status = AE_OK;
949 struct acpi_ec *ec; 1378 union acpi_ec *ec = NULL;
950 1379
951 ACPI_FUNCTION_TRACE("acpi_ec_stop"); 1380 ACPI_FUNCTION_TRACE("acpi_ec_stop");
952 1381
@@ -955,12 +1384,12 @@ acpi_ec_stop (
955 1384
956 ec = acpi_driver_data(device); 1385 ec = acpi_driver_data(device);
957 1386
958 status = acpi_remove_address_space_handler(ec->handle, 1387 status = acpi_remove_address_space_handler(ec->common.handle,
959 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler); 1388 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler);
960 if (ACPI_FAILURE(status)) 1389 if (ACPI_FAILURE(status))
961 return_VALUE(-ENODEV); 1390 return_VALUE(-ENODEV);
962 1391
963 status = acpi_remove_gpe_handler(NULL, ec->gpe_bit, &acpi_ec_gpe_handler); 1392 status = acpi_remove_gpe_handler(NULL, ec->common.gpe_bit, &acpi_ec_gpe_handler);
964 if (ACPI_FAILURE(status)) 1393 if (ACPI_FAILURE(status))
965 return_VALUE(-ENODEV); 1394 return_VALUE(-ENODEV);
966 1395
@@ -974,26 +1403,76 @@ acpi_fake_ecdt_callback (
974 void *context, 1403 void *context,
975 void **retval) 1404 void **retval)
976{ 1405{
1406
1407 if (acpi_ec_polling_mode)
1408 return acpi_fake_ecdt_polling_callback(handle,
1409 Level, context, retval);
1410 else
1411 return acpi_fake_ecdt_burst_callback(handle,
1412 Level, context, retval);
1413}
1414
1415static acpi_status __init
1416acpi_fake_ecdt_polling_callback (
1417 acpi_handle handle,
1418 u32 Level,
1419 void *context,
1420 void **retval)
1421{
977 acpi_status status; 1422 acpi_status status;
978 1423
979 status = acpi_walk_resources(handle, METHOD_NAME__CRS, 1424 status = acpi_walk_resources(handle, METHOD_NAME__CRS,
980 acpi_ec_io_ports, ec_ecdt); 1425 acpi_ec_io_ports, ec_ecdt);
981 if (ACPI_FAILURE(status)) 1426 if (ACPI_FAILURE(status))
982 return status; 1427 return status;
983 ec_ecdt->status_addr = ec_ecdt->command_addr; 1428 ec_ecdt->common.status_addr = ec_ecdt->common.command_addr;
984 1429
985 ec_ecdt->uid = -1; 1430 ec_ecdt->common.uid = -1;
986 acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->uid); 1431 acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->common.uid);
987 1432
988 status = acpi_evaluate_integer(handle, "_GPE", NULL, &ec_ecdt->gpe_bit); 1433 status = acpi_evaluate_integer(handle, "_GPE", NULL, &ec_ecdt->common.gpe_bit);
989 if (ACPI_FAILURE(status)) 1434 if (ACPI_FAILURE(status))
990 return status; 1435 return status;
991 ec_ecdt->global_lock = TRUE; 1436 spin_lock_init(&ec_ecdt->polling.lock);
992 ec_ecdt->handle = handle; 1437 ec_ecdt->common.global_lock = TRUE;
1438 ec_ecdt->common.handle = handle;
993 1439
994 printk(KERN_INFO PREFIX "GPE=0x%02x, ports=0x%2x, 0x%2x\n", 1440 printk(KERN_INFO PREFIX "GPE=0x%02x, ports=0x%2x, 0x%2x\n",
995 (u32) ec_ecdt->gpe_bit, (u32) ec_ecdt->command_addr.address, 1441 (u32) ec_ecdt->common.gpe_bit, (u32) ec_ecdt->common.command_addr.address,
996 (u32) ec_ecdt->data_addr.address); 1442 (u32) ec_ecdt->common.data_addr.address);
1443
1444 return AE_CTRL_TERMINATE;
1445}
1446
1447static acpi_status __init
1448acpi_fake_ecdt_burst_callback (
1449 acpi_handle handle,
1450 u32 Level,
1451 void *context,
1452 void **retval)
1453{
1454 acpi_status status;
1455
1456 init_MUTEX(&ec_ecdt->burst.sem);
1457 init_waitqueue_head(&ec_ecdt->burst.wait);
1458 status = acpi_walk_resources(handle, METHOD_NAME__CRS,
1459 acpi_ec_io_ports, ec_ecdt);
1460 if (ACPI_FAILURE(status))
1461 return status;
1462 ec_ecdt->common.status_addr = ec_ecdt->common.command_addr;
1463
1464 ec_ecdt->common.uid = -1;
1465 acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->common.uid);
1466
1467 status = acpi_evaluate_integer(handle, "_GPE", NULL, &ec_ecdt->common.gpe_bit);
1468 if (ACPI_FAILURE(status))
1469 return status;
1470 ec_ecdt->common.global_lock = TRUE;
1471 ec_ecdt->common.handle = handle;
1472
1473 printk(KERN_INFO PREFIX "GPE=0x%02x, ports=0x%2x, 0x%2x\n",
1474 (u32) ec_ecdt->common.gpe_bit, (u32) ec_ecdt->common.command_addr.address,
1475 (u32) ec_ecdt->common.data_addr.address);
997 1476
998 return AE_CTRL_TERMINATE; 1477 return AE_CTRL_TERMINATE;
999} 1478}
@@ -1016,12 +1495,12 @@ acpi_ec_fake_ecdt(void)
1016 1495
1017 printk(KERN_INFO PREFIX "Try to make an fake ECDT\n"); 1496 printk(KERN_INFO PREFIX "Try to make an fake ECDT\n");
1018 1497
1019 ec_ecdt = kmalloc(sizeof(struct acpi_ec), GFP_KERNEL); 1498 ec_ecdt = kmalloc(sizeof(union acpi_ec), GFP_KERNEL);
1020 if (!ec_ecdt) { 1499 if (!ec_ecdt) {
1021 ret = -ENOMEM; 1500 ret = -ENOMEM;
1022 goto error; 1501 goto error;
1023 } 1502 }
1024 memset(ec_ecdt, 0, sizeof(struct acpi_ec)); 1503 memset(ec_ecdt, 0, sizeof(union acpi_ec));
1025 1504
1026 status = acpi_get_devices (ACPI_EC_HID, 1505 status = acpi_get_devices (ACPI_EC_HID,
1027 acpi_fake_ecdt_callback, 1506 acpi_fake_ecdt_callback,
@@ -1042,6 +1521,60 @@ error:
1042static int __init 1521static int __init
1043acpi_ec_get_real_ecdt(void) 1522acpi_ec_get_real_ecdt(void)
1044{ 1523{
1524 if (acpi_ec_polling_mode)
1525 return acpi_ec_polling_get_real_ecdt();
1526 else
1527 return acpi_ec_burst_get_real_ecdt();
1528}
1529
1530static int __init
1531acpi_ec_polling_get_real_ecdt(void)
1532{
1533 acpi_status status;
1534 struct acpi_table_ecdt *ecdt_ptr;
1535
1536 status = acpi_get_firmware_table("ECDT", 1, ACPI_LOGICAL_ADDRESSING,
1537 (struct acpi_table_header **) &ecdt_ptr);
1538 if (ACPI_FAILURE(status))
1539 return -ENODEV;
1540
1541 printk(KERN_INFO PREFIX "Found ECDT\n");
1542
1543 /*
1544 * Generate a temporary ec context to use until the namespace is scanned
1545 */
1546 ec_ecdt = kmalloc(sizeof(union acpi_ec), GFP_KERNEL);
1547 if (!ec_ecdt)
1548 return -ENOMEM;
1549 memset(ec_ecdt, 0, sizeof(union acpi_ec));
1550
1551 ec_ecdt->common.command_addr = ecdt_ptr->ec_control;
1552 ec_ecdt->common.status_addr = ecdt_ptr->ec_control;
1553 ec_ecdt->common.data_addr = ecdt_ptr->ec_data;
1554 ec_ecdt->common.gpe_bit = ecdt_ptr->gpe_bit;
1555 spin_lock_init(&ec_ecdt->polling.lock);
1556 /* use the GL just to be safe */
1557 ec_ecdt->common.global_lock = TRUE;
1558 ec_ecdt->common.uid = ecdt_ptr->uid;
1559
1560 status = acpi_get_handle(NULL, ecdt_ptr->ec_id, &ec_ecdt->common.handle);
1561 if (ACPI_FAILURE(status)) {
1562 goto error;
1563 }
1564
1565 return 0;
1566error:
1567 printk(KERN_ERR PREFIX "Could not use ECDT\n");
1568 kfree(ec_ecdt);
1569 ec_ecdt = NULL;
1570
1571 return -ENODEV;
1572}
1573
1574
1575static int __init
1576acpi_ec_burst_get_real_ecdt(void)
1577{
1045 acpi_status status; 1578 acpi_status status;
1046 struct acpi_table_ecdt *ecdt_ptr; 1579 struct acpi_table_ecdt *ecdt_ptr;
1047 1580
@@ -1055,22 +1588,22 @@ acpi_ec_get_real_ecdt(void)
1055 /* 1588 /*
1056 * Generate a temporary ec context to use until the namespace is scanned 1589 * Generate a temporary ec context to use until the namespace is scanned
1057 */ 1590 */
1058 ec_ecdt = kmalloc(sizeof(struct acpi_ec), GFP_KERNEL); 1591 ec_ecdt = kmalloc(sizeof(union acpi_ec), GFP_KERNEL);
1059 if (!ec_ecdt) 1592 if (!ec_ecdt)
1060 return -ENOMEM; 1593 return -ENOMEM;
1061 memset(ec_ecdt, 0, sizeof(struct acpi_ec)); 1594 memset(ec_ecdt, 0, sizeof(union acpi_ec));
1062 1595
1063 init_MUTEX(&ec_ecdt->sem); 1596 init_MUTEX(&ec_ecdt->burst.sem);
1064 init_waitqueue_head(&ec_ecdt->wait); 1597 init_waitqueue_head(&ec_ecdt->burst.wait);
1065 ec_ecdt->command_addr = ecdt_ptr->ec_control; 1598 ec_ecdt->common.command_addr = ecdt_ptr->ec_control;
1066 ec_ecdt->status_addr = ecdt_ptr->ec_control; 1599 ec_ecdt->common.status_addr = ecdt_ptr->ec_control;
1067 ec_ecdt->data_addr = ecdt_ptr->ec_data; 1600 ec_ecdt->common.data_addr = ecdt_ptr->ec_data;
1068 ec_ecdt->gpe_bit = ecdt_ptr->gpe_bit; 1601 ec_ecdt->common.gpe_bit = ecdt_ptr->gpe_bit;
1069 /* use the GL just to be safe */ 1602 /* use the GL just to be safe */
1070 ec_ecdt->global_lock = TRUE; 1603 ec_ecdt->common.global_lock = TRUE;
1071 ec_ecdt->uid = ecdt_ptr->uid; 1604 ec_ecdt->common.uid = ecdt_ptr->uid;
1072 1605
1073 status = acpi_get_handle(NULL, ecdt_ptr->ec_id, &ec_ecdt->handle); 1606 status = acpi_get_handle(NULL, ecdt_ptr->ec_id, &ec_ecdt->common.handle);
1074 if (ACPI_FAILURE(status)) { 1607 if (ACPI_FAILURE(status)) {
1075 goto error; 1608 goto error;
1076 } 1609 }
@@ -1103,20 +1636,20 @@ acpi_ec_ecdt_probe (void)
1103 /* 1636 /*
1104 * Install GPE handler 1637 * Install GPE handler
1105 */ 1638 */
1106 status = acpi_install_gpe_handler(NULL, ec_ecdt->gpe_bit, 1639 status = acpi_install_gpe_handler(NULL, ec_ecdt->common.gpe_bit,
1107 ACPI_GPE_EDGE_TRIGGERED, &acpi_ec_gpe_handler, 1640 ACPI_GPE_EDGE_TRIGGERED, &acpi_ec_gpe_handler,
1108 ec_ecdt); 1641 ec_ecdt);
1109 if (ACPI_FAILURE(status)) { 1642 if (ACPI_FAILURE(status)) {
1110 goto error; 1643 goto error;
1111 } 1644 }
1112 acpi_set_gpe_type (NULL, ec_ecdt->gpe_bit, ACPI_GPE_TYPE_RUNTIME); 1645 acpi_set_gpe_type (NULL, ec_ecdt->common.gpe_bit, ACPI_GPE_TYPE_RUNTIME);
1113 acpi_enable_gpe (NULL, ec_ecdt->gpe_bit, ACPI_NOT_ISR); 1646 acpi_enable_gpe (NULL, ec_ecdt->common.gpe_bit, ACPI_NOT_ISR);
1114 1647
1115 status = acpi_install_address_space_handler (ACPI_ROOT_OBJECT, 1648 status = acpi_install_address_space_handler (ACPI_ROOT_OBJECT,
1116 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler, 1649 ACPI_ADR_SPACE_EC, &acpi_ec_space_handler,
1117 &acpi_ec_space_setup, ec_ecdt); 1650 &acpi_ec_space_setup, ec_ecdt);
1118 if (ACPI_FAILURE(status)) { 1651 if (ACPI_FAILURE(status)) {
1119 acpi_remove_gpe_handler(NULL, ec_ecdt->gpe_bit, 1652 acpi_remove_gpe_handler(NULL, ec_ecdt->common.gpe_bit,
1120 &acpi_ec_gpe_handler); 1653 &acpi_ec_gpe_handler);
1121 goto error; 1654 goto error;
1122 } 1655 }
@@ -1134,7 +1667,7 @@ error:
1134 1667
1135static int __init acpi_ec_init (void) 1668static int __init acpi_ec_init (void)
1136{ 1669{
1137 int result; 1670 int result = 0;
1138 1671
1139 ACPI_FUNCTION_TRACE("acpi_ec_init"); 1672 ACPI_FUNCTION_TRACE("acpi_ec_init");
1140 1673
@@ -1178,3 +1711,10 @@ static int __init acpi_fake_ecdt_setup(char *str)
1178 return 0; 1711 return 0;
1179} 1712}
1180__setup("acpi_fake_ecdt", acpi_fake_ecdt_setup); 1713__setup("acpi_fake_ecdt", acpi_fake_ecdt_setup);
1714static int __init acpi_ec_set_polling_mode(char *str)
1715{
1716 acpi_ec_polling_mode = EC_POLLING;
1717 acpi_ec_driver.ops.add = acpi_ec_polling_add;
1718 return 0;
1719}
1720__setup("ec_polling", acpi_ec_set_polling_mode);
diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c
index 8093f2e00321..c536ccfc5413 100644
--- a/drivers/acpi/pci_irq.c
+++ b/drivers/acpi/pci_irq.c
@@ -269,7 +269,51 @@ acpi_pci_irq_del_prt (int segment, int bus)
269/* -------------------------------------------------------------------------- 269/* --------------------------------------------------------------------------
270 PCI Interrupt Routing Support 270 PCI Interrupt Routing Support
271 -------------------------------------------------------------------------- */ 271 -------------------------------------------------------------------------- */
272typedef int (*irq_lookup_func)(struct acpi_prt_entry *, int *, int *, char **);
272 273
274static int
275acpi_pci_allocate_irq(struct acpi_prt_entry *entry,
276 int *edge_level,
277 int *active_high_low,
278 char **link)
279{
280 int irq;
281
282 ACPI_FUNCTION_TRACE("acpi_pci_allocate_irq");
283
284 if (entry->link.handle) {
285 irq = acpi_pci_link_allocate_irq(entry->link.handle,
286 entry->link.index, edge_level, active_high_low, link);
287 if (irq < 0) {
288 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid IRQ link routing entry\n"));
289 return_VALUE(-1);
290 }
291 } else {
292 irq = entry->link.index;
293 *edge_level = ACPI_LEVEL_SENSITIVE;
294 *active_high_low = ACPI_ACTIVE_LOW;
295 }
296
297 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found IRQ %d\n", irq));
298 return_VALUE(irq);
299}
300
301static int
302acpi_pci_free_irq(struct acpi_prt_entry *entry,
303 int *edge_level,
304 int *active_high_low,
305 char **link)
306{
307 int irq;
308
309 ACPI_FUNCTION_TRACE("acpi_pci_free_irq");
310 if (entry->link.handle) {
311 irq = acpi_pci_link_free_irq(entry->link.handle);
312 } else {
313 irq = entry->link.index;
314 }
315 return_VALUE(irq);
316}
273/* 317/*
274 * acpi_pci_irq_lookup 318 * acpi_pci_irq_lookup
275 * success: return IRQ >= 0 319 * success: return IRQ >= 0
@@ -282,12 +326,13 @@ acpi_pci_irq_lookup (
282 int pin, 326 int pin,
283 int *edge_level, 327 int *edge_level,
284 int *active_high_low, 328 int *active_high_low,
285 char **link) 329 char **link,
330 irq_lookup_func func)
286{ 331{
287 struct acpi_prt_entry *entry = NULL; 332 struct acpi_prt_entry *entry = NULL;
288 int segment = pci_domain_nr(bus); 333 int segment = pci_domain_nr(bus);
289 int bus_nr = bus->number; 334 int bus_nr = bus->number;
290 int irq; 335 int ret;
291 336
292 ACPI_FUNCTION_TRACE("acpi_pci_irq_lookup"); 337 ACPI_FUNCTION_TRACE("acpi_pci_irq_lookup");
293 338
@@ -301,22 +346,8 @@ acpi_pci_irq_lookup (
301 return_VALUE(-1); 346 return_VALUE(-1);
302 } 347 }
303 348
304 if (entry->link.handle) { 349 ret = func(entry, edge_level, active_high_low, link);
305 irq = acpi_pci_link_get_irq(entry->link.handle, 350 return_VALUE(ret);
306 entry->link.index, edge_level, active_high_low, link);
307 if (irq < 0) {
308 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid IRQ link routing entry\n"));
309 return_VALUE(-1);
310 }
311 } else {
312 irq = entry->link.index;
313 *edge_level = ACPI_LEVEL_SENSITIVE;
314 *active_high_low = ACPI_ACTIVE_LOW;
315 }
316
317 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found IRQ %d\n", irq));
318
319 return_VALUE(irq);
320} 351}
321 352
322/* 353/*
@@ -330,7 +361,8 @@ acpi_pci_irq_derive (
330 int pin, 361 int pin,
331 int *edge_level, 362 int *edge_level,
332 int *active_high_low, 363 int *active_high_low,
333 char **link) 364 char **link,
365 irq_lookup_func func)
334{ 366{
335 struct pci_dev *bridge = dev; 367 struct pci_dev *bridge = dev;
336 int irq = -1; 368 int irq = -1;
@@ -363,7 +395,7 @@ acpi_pci_irq_derive (
363 } 395 }
364 396
365 irq = acpi_pci_irq_lookup(bridge->bus, PCI_SLOT(bridge->devfn), 397 irq = acpi_pci_irq_lookup(bridge->bus, PCI_SLOT(bridge->devfn),
366 pin, edge_level, active_high_low, link); 398 pin, edge_level, active_high_low, link, func);
367 } 399 }
368 400
369 if (irq < 0) { 401 if (irq < 0) {
@@ -415,7 +447,7 @@ acpi_pci_irq_enable (
415 * values override any BIOS-assigned IRQs set during boot. 447 * values override any BIOS-assigned IRQs set during boot.
416 */ 448 */
417 irq = acpi_pci_irq_lookup(dev->bus, PCI_SLOT(dev->devfn), pin, 449 irq = acpi_pci_irq_lookup(dev->bus, PCI_SLOT(dev->devfn), pin,
418 &edge_level, &active_high_low, &link); 450 &edge_level, &active_high_low, &link, acpi_pci_allocate_irq);
419 451
420 /* 452 /*
421 * If no PRT entry was found, we'll try to derive an IRQ from the 453 * If no PRT entry was found, we'll try to derive an IRQ from the
@@ -423,7 +455,7 @@ acpi_pci_irq_enable (
423 */ 455 */
424 if (irq < 0) 456 if (irq < 0)
425 irq = acpi_pci_irq_derive(dev, pin, &edge_level, 457 irq = acpi_pci_irq_derive(dev, pin, &edge_level,
426 &active_high_low, &link); 458 &active_high_low, &link, acpi_pci_allocate_irq);
427 459
428 /* 460 /*
429 * No IRQ known to the ACPI subsystem - maybe the BIOS / 461 * No IRQ known to the ACPI subsystem - maybe the BIOS /
@@ -461,7 +493,9 @@ acpi_pci_irq_enable (
461EXPORT_SYMBOL(acpi_pci_irq_enable); 493EXPORT_SYMBOL(acpi_pci_irq_enable);
462 494
463 495
464#ifdef CONFIG_ACPI_DEALLOCATE_IRQ 496/* FIXME: implement x86/x86_64 version */
497void __attribute__((weak)) acpi_unregister_gsi(u32 i) {}
498
465void 499void
466acpi_pci_irq_disable ( 500acpi_pci_irq_disable (
467 struct pci_dev *dev) 501 struct pci_dev *dev)
@@ -488,14 +522,14 @@ acpi_pci_irq_disable (
488 * First we check the PCI IRQ routing table (PRT) for an IRQ. 522 * First we check the PCI IRQ routing table (PRT) for an IRQ.
489 */ 523 */
490 gsi = acpi_pci_irq_lookup(dev->bus, PCI_SLOT(dev->devfn), pin, 524 gsi = acpi_pci_irq_lookup(dev->bus, PCI_SLOT(dev->devfn), pin,
491 &edge_level, &active_high_low, NULL); 525 &edge_level, &active_high_low, NULL, acpi_pci_free_irq);
492 /* 526 /*
493 * If no PRT entry was found, we'll try to derive an IRQ from the 527 * If no PRT entry was found, we'll try to derive an IRQ from the
494 * device's parent bridge. 528 * device's parent bridge.
495 */ 529 */
496 if (gsi < 0) 530 if (gsi < 0)
497 gsi = acpi_pci_irq_derive(dev, pin, 531 gsi = acpi_pci_irq_derive(dev, pin,
498 &edge_level, &active_high_low, NULL); 532 &edge_level, &active_high_low, NULL, acpi_pci_free_irq);
499 if (gsi < 0) 533 if (gsi < 0)
500 return_VOID; 534 return_VOID;
501 535
@@ -511,4 +545,3 @@ acpi_pci_irq_disable (
511 545
512 return_VOID; 546 return_VOID;
513} 547}
514#endif /* CONFIG_ACPI_DEALLOCATE_IRQ */
diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
index 6ad0e77df9b3..6a29610edc11 100644
--- a/drivers/acpi/pci_link.c
+++ b/drivers/acpi/pci_link.c
@@ -68,6 +68,10 @@ static struct acpi_driver acpi_pci_link_driver = {
68 }, 68 },
69}; 69};
70 70
71/*
72 * If a link is initialized, we never change its active and initialized
73 * later even the link is disable. Instead, we just repick the active irq
74 */
71struct acpi_pci_link_irq { 75struct acpi_pci_link_irq {
72 u8 active; /* Current IRQ */ 76 u8 active; /* Current IRQ */
73 u8 edge_level; /* All IRQs */ 77 u8 edge_level; /* All IRQs */
@@ -76,8 +80,7 @@ struct acpi_pci_link_irq {
76 u8 possible_count; 80 u8 possible_count;
77 u8 possible[ACPI_PCI_LINK_MAX_POSSIBLE]; 81 u8 possible[ACPI_PCI_LINK_MAX_POSSIBLE];
78 u8 initialized:1; 82 u8 initialized:1;
79 u8 suspend_resume:1; 83 u8 reserved:7;
80 u8 reserved:6;
81}; 84};
82 85
83struct acpi_pci_link { 86struct acpi_pci_link {
@@ -85,12 +88,14 @@ struct acpi_pci_link {
85 struct acpi_device *device; 88 struct acpi_device *device;
86 acpi_handle handle; 89 acpi_handle handle;
87 struct acpi_pci_link_irq irq; 90 struct acpi_pci_link_irq irq;
91 int refcnt;
88}; 92};
89 93
90static struct { 94static struct {
91 int count; 95 int count;
92 struct list_head entries; 96 struct list_head entries;
93} acpi_link; 97} acpi_link;
98DECLARE_MUTEX(acpi_link_lock);
94 99
95 100
96/* -------------------------------------------------------------------------- 101/* --------------------------------------------------------------------------
@@ -532,12 +537,12 @@ static int acpi_pci_link_allocate(
532 537
533 ACPI_FUNCTION_TRACE("acpi_pci_link_allocate"); 538 ACPI_FUNCTION_TRACE("acpi_pci_link_allocate");
534 539
535 if (link->irq.suspend_resume) { 540 if (link->irq.initialized) {
536 acpi_pci_link_set(link, link->irq.active); 541 if (link->refcnt == 0)
537 link->irq.suspend_resume = 0; 542 /* This means the link is disabled but initialized */
538 } 543 acpi_pci_link_set(link, link->irq.active);
539 if (link->irq.initialized)
540 return_VALUE(0); 544 return_VALUE(0);
545 }
541 546
542 /* 547 /*
543 * search for active IRQ in list of possible IRQs. 548 * search for active IRQ in list of possible IRQs.
@@ -596,13 +601,13 @@ static int acpi_pci_link_allocate(
596} 601}
597 602
598/* 603/*
599 * acpi_pci_link_get_irq 604 * acpi_pci_link_allocate_irq
600 * success: return IRQ >= 0 605 * success: return IRQ >= 0
601 * failure: return -1 606 * failure: return -1
602 */ 607 */
603 608
604int 609int
605acpi_pci_link_get_irq ( 610acpi_pci_link_allocate_irq (
606 acpi_handle handle, 611 acpi_handle handle,
607 int index, 612 int index,
608 int *edge_level, 613 int *edge_level,
@@ -613,7 +618,7 @@ acpi_pci_link_get_irq (
613 struct acpi_device *device = NULL; 618 struct acpi_device *device = NULL;
614 struct acpi_pci_link *link = NULL; 619 struct acpi_pci_link *link = NULL;
615 620
616 ACPI_FUNCTION_TRACE("acpi_pci_link_get_irq"); 621 ACPI_FUNCTION_TRACE("acpi_pci_link_allocate_irq");
617 622
618 result = acpi_bus_get_device(handle, &device); 623 result = acpi_bus_get_device(handle, &device);
619 if (result) { 624 if (result) {
@@ -633,21 +638,70 @@ acpi_pci_link_get_irq (
633 return_VALUE(-1); 638 return_VALUE(-1);
634 } 639 }
635 640
636 if (acpi_pci_link_allocate(link)) 641 down(&acpi_link_lock);
642 if (acpi_pci_link_allocate(link)) {
643 up(&acpi_link_lock);
637 return_VALUE(-1); 644 return_VALUE(-1);
645 }
638 646
639 if (!link->irq.active) { 647 if (!link->irq.active) {
648 up(&acpi_link_lock);
640 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Link active IRQ is 0!\n")); 649 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Link active IRQ is 0!\n"));
641 return_VALUE(-1); 650 return_VALUE(-1);
642 } 651 }
652 link->refcnt ++;
653 up(&acpi_link_lock);
643 654
644 if (edge_level) *edge_level = link->irq.edge_level; 655 if (edge_level) *edge_level = link->irq.edge_level;
645 if (active_high_low) *active_high_low = link->irq.active_high_low; 656 if (active_high_low) *active_high_low = link->irq.active_high_low;
646 if (name) *name = acpi_device_bid(link->device); 657 if (name) *name = acpi_device_bid(link->device);
658 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
659 "Link %s is referenced\n", acpi_device_bid(link->device)));
647 return_VALUE(link->irq.active); 660 return_VALUE(link->irq.active);
648} 661}
649 662
663/*
664 * We don't change link's irq information here. After it is reenabled, we
665 * continue use the info
666 */
667int
668acpi_pci_link_free_irq(acpi_handle handle)
669{
670 struct acpi_device *device = NULL;
671 struct acpi_pci_link *link = NULL;
672 acpi_status result;
673
674 ACPI_FUNCTION_TRACE("acpi_pci_link_free_irq");
675
676 result = acpi_bus_get_device(handle, &device);
677 if (result) {
678 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link device\n"));
679 return_VALUE(-1);
680 }
650 681
682 link = (struct acpi_pci_link *) acpi_driver_data(device);
683 if (!link) {
684 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link context\n"));
685 return_VALUE(-1);
686 }
687
688 down(&acpi_link_lock);
689 if (!link->irq.initialized) {
690 up(&acpi_link_lock);
691 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Link isn't initialized\n"));
692 return_VALUE(-1);
693 }
694
695 link->refcnt --;
696 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
697 "Link %s is dereferenced\n", acpi_device_bid(link->device)));
698
699 if (link->refcnt == 0) {
700 acpi_ut_evaluate_object(link->handle, "_DIS", 0, NULL);
701 }
702 up(&acpi_link_lock);
703 return_VALUE(link->irq.active);
704}
651/* -------------------------------------------------------------------------- 705/* --------------------------------------------------------------------------
652 Driver Interface 706 Driver Interface
653 -------------------------------------------------------------------------- */ 707 -------------------------------------------------------------------------- */
@@ -677,6 +731,7 @@ acpi_pci_link_add (
677 strcpy(acpi_device_class(device), ACPI_PCI_LINK_CLASS); 731 strcpy(acpi_device_class(device), ACPI_PCI_LINK_CLASS);
678 acpi_driver_data(device) = link; 732 acpi_driver_data(device) = link;
679 733
734 down(&acpi_link_lock);
680 result = acpi_pci_link_get_possible(link); 735 result = acpi_pci_link_get_possible(link);
681 if (result) 736 if (result)
682 goto end; 737 goto end;
@@ -712,6 +767,7 @@ acpi_pci_link_add (
712end: 767end:
713 /* disable all links -- to be activated on use */ 768 /* disable all links -- to be activated on use */
714 acpi_ut_evaluate_object(link->handle, "_DIS", 0, NULL); 769 acpi_ut_evaluate_object(link->handle, "_DIS", 0, NULL);
770 up(&acpi_link_lock);
715 771
716 if (result) 772 if (result)
717 kfree(link); 773 kfree(link);
@@ -726,19 +782,32 @@ irqrouter_suspend(
726{ 782{
727 struct list_head *node = NULL; 783 struct list_head *node = NULL;
728 struct acpi_pci_link *link = NULL; 784 struct acpi_pci_link *link = NULL;
785 int ret = 0;
729 786
730 ACPI_FUNCTION_TRACE("irqrouter_suspend"); 787 ACPI_FUNCTION_TRACE("irqrouter_suspend");
731 788
732 list_for_each(node, &acpi_link.entries) { 789 list_for_each(node, &acpi_link.entries) {
733 link = list_entry(node, struct acpi_pci_link, node); 790 link = list_entry(node, struct acpi_pci_link, node);
734 if (!link) { 791 if (!link) {
735 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link context\n")); 792 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
793 "Invalid link context\n"));
736 continue; 794 continue;
737 } 795 }
738 if (link->irq.active && link->irq.initialized) 796 if (link->irq.initialized && link->refcnt != 0
739 link->irq.suspend_resume = 1; 797 /* We ignore legacy IDE device irq */
798 && link->irq.active != 14 && link->irq.active !=15) {
799 printk(KERN_WARNING PREFIX
800 "%d drivers with interrupt %d neglected to call"
801 " pci_disable_device at .suspend\n",
802 link->refcnt,
803 link->irq.active);
804 printk(KERN_WARNING PREFIX
805 "Fix the driver, or rmmod before suspend\n");
806 link->refcnt = 0;
807 ret = -EINVAL;
808 }
740 } 809 }
741 return_VALUE(0); 810 return_VALUE(ret);
742} 811}
743 812
744 813
@@ -756,8 +825,9 @@ acpi_pci_link_remove (
756 825
757 link = (struct acpi_pci_link *) acpi_driver_data(device); 826 link = (struct acpi_pci_link *) acpi_driver_data(device);
758 827
759 /* TBD: Acquire/release lock */ 828 down(&acpi_link_lock);
760 list_del(&link->node); 829 list_del(&link->node);
830 up(&acpi_link_lock);
761 831
762 kfree(link); 832 kfree(link);
763 833
@@ -849,6 +919,7 @@ int __init acpi_irq_balance_set(char *str)
849__setup("acpi_irq_balance", acpi_irq_balance_set); 919__setup("acpi_irq_balance", acpi_irq_balance_set);
850 920
851 921
922/* FIXME: we will remove this interface after all drivers call pci_disable_device */
852static struct sysdev_class irqrouter_sysdev_class = { 923static struct sysdev_class irqrouter_sysdev_class = {
853 set_kset_name("irqrouter"), 924 set_kset_name("irqrouter"),
854 .suspend = irqrouter_suspend, 925 .suspend = irqrouter_suspend,
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index 8f038cd29477..fd5458947851 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -81,30 +81,33 @@ module_param(bm_history, uint, 0644);
81 * 81 *
82 * To skip this limit, boot/load with a large max_cstate limit. 82 * To skip this limit, boot/load with a large max_cstate limit.
83 */ 83 */
84static int no_c2c3(struct dmi_system_id *id) 84static int set_max_cstate(struct dmi_system_id *id)
85{ 85{
86 if (max_cstate > ACPI_PROCESSOR_MAX_POWER) 86 if (max_cstate > ACPI_PROCESSOR_MAX_POWER)
87 return 0; 87 return 0;
88 88
89 printk(KERN_NOTICE PREFIX "%s detected - C2,C3 disabled." 89 printk(KERN_NOTICE PREFIX "%s detected - %s disabled."
90 " Override with \"processor.max_cstate=%d\"\n", id->ident, 90 " Override with \"processor.max_cstate=%d\"\n", id->ident,
91 ((int)id->driver_data == 1)? "C2,C3":"C3",
91 ACPI_PROCESSOR_MAX_POWER + 1); 92 ACPI_PROCESSOR_MAX_POWER + 1);
92 93
93 max_cstate = 1; 94 max_cstate = (int)id->driver_data;
94 95
95 return 0; 96 return 0;
96} 97}
97 98
98 99
99
100
101static struct dmi_system_id __initdata processor_power_dmi_table[] = { 100static struct dmi_system_id __initdata processor_power_dmi_table[] = {
102 { no_c2c3, "IBM ThinkPad R40e", { 101 { set_max_cstate, "IBM ThinkPad R40e", {
103 DMI_MATCH(DMI_BIOS_VENDOR,"IBM"), 102 DMI_MATCH(DMI_BIOS_VENDOR,"IBM"),
104 DMI_MATCH(DMI_BIOS_VERSION,"1SET60WW") }}, 103 DMI_MATCH(DMI_BIOS_VERSION,"1SET60WW") }, (void*)1},
105 { no_c2c3, "Medion 41700", { 104 { set_max_cstate, "Medion 41700", {
105 DMI_MATCH(DMI_BIOS_VENDOR,"Phoenix Technologies LTD"),
106 DMI_MATCH(DMI_BIOS_VERSION,"R01-A1J") }, (void*)1},
107 { set_max_cstate, "Clevo 5600D", {
106 DMI_MATCH(DMI_BIOS_VENDOR,"Phoenix Technologies LTD"), 108 DMI_MATCH(DMI_BIOS_VENDOR,"Phoenix Technologies LTD"),
107 DMI_MATCH(DMI_BIOS_VERSION,"R01-A1J") }}, 109 DMI_MATCH(DMI_BIOS_VERSION,"SHE845M0.86C.0013.D.0302131307") },
110 (void*)2},
108 {}, 111 {},
109}; 112};
110 113
@@ -549,7 +552,8 @@ static int acpi_processor_get_power_info_default_c1 (struct acpi_processor *pr)
549 ACPI_FUNCTION_TRACE("acpi_processor_get_power_info_default_c1"); 552 ACPI_FUNCTION_TRACE("acpi_processor_get_power_info_default_c1");
550 553
551 for (i = 0; i < ACPI_PROCESSOR_MAX_POWER; i++) 554 for (i = 0; i < ACPI_PROCESSOR_MAX_POWER; i++)
552 memset(pr->power.states, 0, sizeof(struct acpi_processor_cx)); 555 memset(&(pr->power.states[i]), 0,
556 sizeof(struct acpi_processor_cx));
553 557
554 /* if info is obtained from pblk/fadt, type equals state */ 558 /* if info is obtained from pblk/fadt, type equals state */
555 pr->power.states[ACPI_STATE_C1].type = ACPI_STATE_C1; 559 pr->power.states[ACPI_STATE_C1].type = ACPI_STATE_C1;
@@ -580,7 +584,8 @@ static int acpi_processor_get_power_info_cst (struct acpi_processor *pr)
580 584
581 pr->power.count = 0; 585 pr->power.count = 0;
582 for (i = 0; i < ACPI_PROCESSOR_MAX_POWER; i++) 586 for (i = 0; i < ACPI_PROCESSOR_MAX_POWER; i++)
583 memset(pr->power.states, 0, sizeof(struct acpi_processor_cx)); 587 memset(&(pr->power.states[i]), 0,
588 sizeof(struct acpi_processor_cx));
584 589
585 status = acpi_evaluate_object(pr->handle, "_CST", NULL, &buffer); 590 status = acpi_evaluate_object(pr->handle, "_CST", NULL, &buffer);
586 if (ACPI_FAILURE(status)) { 591 if (ACPI_FAILURE(status)) {
@@ -763,7 +768,6 @@ static void acpi_processor_power_verify_c3(
763 } 768 }
764 769
765 if (pr->flags.bm_check) { 770 if (pr->flags.bm_check) {
766 printk("Disabling BM access before entering C3\n");
767 /* bus mastering control is necessary */ 771 /* bus mastering control is necessary */
768 if (!pr->flags.bm_control) { 772 if (!pr->flags.bm_control) {
769 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 773 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
@@ -771,7 +775,6 @@ static void acpi_processor_power_verify_c3(
771 return_VOID; 775 return_VOID;
772 } 776 }
773 } else { 777 } else {
774 printk("Invalidating cache before entering C3\n");
775 /* 778 /*
776 * WBINVD should be set in fadt, for C3 state to be 779 * WBINVD should be set in fadt, for C3 state to be
777 * supported on when bm_check is not required. 780 * supported on when bm_check is not required.
@@ -842,7 +845,7 @@ static int acpi_processor_get_power_info (
842 result = acpi_processor_get_power_info_cst(pr); 845 result = acpi_processor_get_power_info_cst(pr);
843 if ((result) || (acpi_processor_power_verify(pr) < 2)) { 846 if ((result) || (acpi_processor_power_verify(pr) < 2)) {
844 result = acpi_processor_get_power_info_fadt(pr); 847 result = acpi_processor_get_power_info_fadt(pr);
845 if (result) 848 if ((result) || (acpi_processor_power_verify(pr) < 2))
846 result = acpi_processor_get_power_info_default_c1(pr); 849 result = acpi_processor_get_power_info_default_c1(pr);
847 } 850 }
848 851
diff --git a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c
index 05b827f79f54..7bfaef9305b2 100644
--- a/drivers/net/sk98lin/skge.c
+++ b/drivers/net/sk98lin/skge.c
@@ -5134,6 +5134,67 @@ static void __devexit skge_remove_one(struct pci_dev *pdev)
5134 kfree(pAC); 5134 kfree(pAC);
5135} 5135}
5136 5136
5137#ifdef CONFIG_PM
5138static int skge_suspend(struct pci_dev *pdev, pm_message_t state)
5139{
5140 struct net_device *dev = pci_get_drvdata(pdev);
5141 DEV_NET *pNet = netdev_priv(dev);
5142 SK_AC *pAC = pNet->pAC;
5143 struct net_device *otherdev = pAC->dev[1];
5144
5145 if (pNet->Up) {
5146 pAC->WasIfUp[0] = SK_TRUE;
5147 DoPrintInterfaceChange = SK_FALSE;
5148 SkDrvDeInitAdapter(pAC, 0); /* performs SkGeClose */
5149 }
5150 if (otherdev != dev) {
5151 pNet = netdev_priv(otherdev);
5152 if (pNet->Up) {
5153 pAC->WasIfUp[1] = SK_TRUE;
5154 DoPrintInterfaceChange = SK_FALSE;
5155 SkDrvDeInitAdapter(pAC, 1); /* performs SkGeClose */
5156 }
5157 }
5158
5159 pci_save_state(pdev);
5160 pci_enable_wake(pdev, pci_choose_state(pdev, state), 0);
5161 if (pAC->AllocFlag & SK_ALLOC_IRQ) {
5162 free_irq(dev->irq, dev);
5163 }
5164 pci_disable_device(pdev);
5165 pci_set_power_state(pdev, pci_choose_state(pdev, state));
5166
5167 return 0;
5168}
5169
5170static int skge_resume(struct pci_dev *pdev)
5171{
5172 struct net_device *dev = pci_get_drvdata(pdev);
5173 DEV_NET *pNet = netdev_priv(dev);
5174 SK_AC *pAC = pNet->pAC;
5175
5176 pci_set_power_state(pdev, PCI_D0);
5177 pci_restore_state(pdev);
5178 pci_enable_device(pdev);
5179 pci_set_master(pdev);
5180 if (pAC->GIni.GIMacsFound == 2)
5181 request_irq(dev->irq, SkGeIsr, SA_SHIRQ, pAC->Name, dev);
5182 else
5183 request_irq(dev->irq, SkGeIsrOnePort, SA_SHIRQ, pAC->Name, dev);
5184
5185 if (pAC->WasIfUp[0] == SK_TRUE) {
5186 DoPrintInterfaceChange = SK_FALSE;
5187 SkDrvInitAdapter(pAC, 0); /* first device */
5188 }
5189 if (pAC->dev[1] != dev && pAC->WasIfUp[1] == SK_TRUE) {
5190 DoPrintInterfaceChange = SK_FALSE;
5191 SkDrvInitAdapter(pAC, 1); /* first device */
5192 }
5193
5194 return 0;
5195}
5196#endif
5197
5137static struct pci_device_id skge_pci_tbl[] = { 5198static struct pci_device_id skge_pci_tbl[] = {
5138 { PCI_VENDOR_ID_3COM, 0x1700, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, 5199 { PCI_VENDOR_ID_3COM, 0x1700, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
5139 { PCI_VENDOR_ID_3COM, 0x80eb, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, 5200 { PCI_VENDOR_ID_3COM, 0x80eb, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
@@ -5159,6 +5220,8 @@ static struct pci_driver skge_driver = {
5159 .id_table = skge_pci_tbl, 5220 .id_table = skge_pci_tbl,
5160 .probe = skge_probe_one, 5221 .probe = skge_probe_one,
5161 .remove = __devexit_p(skge_remove_one), 5222 .remove = __devexit_p(skge_remove_one),
5223 .suspend = skge_suspend,
5224 .resume = skge_resume,
5162}; 5225};
5163 5226
5164static int __init skge_init(void) 5227static int __init skge_init(void)
diff --git a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c
index caf7159a54be..a8a9d954bcf4 100644
--- a/drivers/pcmcia/yenta_socket.c
+++ b/drivers/pcmcia/yenta_socket.c
@@ -1034,6 +1034,8 @@ static int yenta_dev_suspend (struct pci_dev *dev, pm_message_t state)
1034 pci_read_config_dword(dev, 17*4, &socket->saved_state[1]); 1034 pci_read_config_dword(dev, 17*4, &socket->saved_state[1]);
1035 pci_disable_device(dev); 1035 pci_disable_device(dev);
1036 1036
1037 free_irq(dev->irq, socket);
1038
1037 /* 1039 /*
1038 * Some laptops (IBM T22) do not like us putting the Cardbus 1040 * Some laptops (IBM T22) do not like us putting the Cardbus
1039 * bridge into D3. At a guess, some other laptop will 1041 * bridge into D3. At a guess, some other laptop will
@@ -1059,6 +1061,13 @@ static int yenta_dev_resume (struct pci_dev *dev)
1059 pci_enable_device(dev); 1061 pci_enable_device(dev);
1060 pci_set_master(dev); 1062 pci_set_master(dev);
1061 1063
1064 if (socket->cb_irq)
1065 if (request_irq(socket->cb_irq, yenta_interrupt,
1066 SA_SHIRQ, "yenta", socket)) {
1067 printk(KERN_WARNING "Yenta: request_irq() failed on resume!\n");
1068 socket->cb_irq = 0;
1069 }
1070
1062 if (socket->type && socket->type->restore_state) 1071 if (socket->type && socket->type->restore_state)
1063 socket->type->restore_state(socket); 1072 socket->type->restore_state(socket);
1064 } 1073 }