aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/misc/wistron_btns.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/misc/wistron_btns.c')
-rw-r--r--drivers/input/misc/wistron_btns.c133
1 files changed, 87 insertions, 46 deletions
diff --git a/drivers/input/misc/wistron_btns.c b/drivers/input/misc/wistron_btns.c
index bac3085185fe..a05b8557842f 100644
--- a/drivers/input/misc/wistron_btns.c
+++ b/drivers/input/misc/wistron_btns.c
@@ -174,7 +174,7 @@ static u16 bios_pop_queue(void)
174 return regs.eax; 174 return regs.eax;
175} 175}
176 176
177static void __init bios_attach(void) 177static void __devinit bios_attach(void)
178{ 178{
179 struct regs regs; 179 struct regs regs;
180 180
@@ -194,7 +194,7 @@ static void bios_detach(void)
194 call_bios(&regs); 194 call_bios(&regs);
195} 195}
196 196
197static u8 __init bios_get_cmos_address(void) 197static u8 __devinit bios_get_cmos_address(void)
198{ 198{
199 struct regs regs; 199 struct regs regs;
200 200
@@ -206,7 +206,7 @@ static u8 __init bios_get_cmos_address(void)
206 return regs.ecx; 206 return regs.ecx;
207} 207}
208 208
209static u16 __init bios_get_default_setting(u8 subsys) 209static u16 __devinit bios_get_default_setting(u8 subsys)
210{ 210{
211 struct regs regs; 211 struct regs regs;
212 212
@@ -296,6 +296,16 @@ static struct key_entry keymap_acer_aspire_1500[] = {
296 { KE_END, 0 } 296 { KE_END, 0 }
297}; 297};
298 298
299static struct key_entry keymap_acer_travelmate_240[] = {
300 { KE_KEY, 0x31, KEY_MAIL },
301 { KE_KEY, 0x36, KEY_WWW },
302 { KE_KEY, 0x11, KEY_PROG1 },
303 { KE_KEY, 0x12, KEY_PROG2 },
304 { KE_BLUETOOTH, 0x44, 0 },
305 { KE_WIFI, 0x30, 0 },
306 { KE_END, 0 }
307};
308
299/* 309/*
300 * If your machine is not here (which is currently rather likely), please send 310 * If your machine is not here (which is currently rather likely), please send
301 * a list of buttons and their key codes (reported when loading this module 311 * a list of buttons and their key codes (reported when loading this module
@@ -320,6 +330,15 @@ static struct dmi_system_id dmi_ids[] = {
320 }, 330 },
321 .driver_data = keymap_acer_aspire_1500 331 .driver_data = keymap_acer_aspire_1500
322 }, 332 },
333 {
334 .callback = dmi_matched,
335 .ident = "Acer TravelMate 240",
336 .matches = {
337 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
338 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 240"),
339 },
340 .driver_data = keymap_acer_travelmate_240
341 },
323 { NULL, } 342 { NULL, }
324}; 343};
325 344
@@ -348,7 +367,7 @@ static int __init select_keymap(void)
348 367
349static struct input_dev *input_dev; 368static struct input_dev *input_dev;
350 369
351static int __init setup_input_dev(void) 370static int __devinit setup_input_dev(void)
352{ 371{
353 const struct key_entry *key; 372 const struct key_entry *key;
354 int error; 373 int error;
@@ -447,6 +466,52 @@ static void poll_bios(unsigned long discard)
447 mod_timer(&poll_timer, jiffies + HZ / POLL_FREQUENCY); 466 mod_timer(&poll_timer, jiffies + HZ / POLL_FREQUENCY);
448} 467}
449 468
469static int __devinit wistron_probe(struct platform_device *dev)
470{
471 int err = setup_input_dev();
472 if (err)
473 return err;
474
475 bios_attach();
476 cmos_address = bios_get_cmos_address();
477
478 if (have_wifi) {
479 u16 wifi = bios_get_default_setting(WIFI);
480 if (wifi & 1)
481 wifi_enabled = (wifi & 2) ? 1 : 0;
482 else
483 have_wifi = 0;
484
485 if (have_wifi)
486 bios_set_state(WIFI, wifi_enabled);
487 }
488
489 if (have_bluetooth) {
490 u16 bt = bios_get_default_setting(BLUETOOTH);
491 if (bt & 1)
492 bluetooth_enabled = (bt & 2) ? 1 : 0;
493 else
494 have_bluetooth = 0;
495
496 if (have_bluetooth)
497 bios_set_state(BLUETOOTH, bluetooth_enabled);
498 }
499
500 poll_bios(1); /* Flush stale event queue and arm timer */
501
502 return 0;
503}
504
505static int __devexit wistron_remove(struct platform_device *dev)
506{
507 del_timer_sync(&poll_timer);
508 input_unregister_device(input_dev);
509 bios_detach();
510
511 return 0;
512}
513
514#ifdef CONFIG_PM
450static int wistron_suspend(struct platform_device *dev, pm_message_t state) 515static int wistron_suspend(struct platform_device *dev, pm_message_t state)
451{ 516{
452 del_timer_sync(&poll_timer); 517 del_timer_sync(&poll_timer);
@@ -472,13 +537,20 @@ static int wistron_resume(struct platform_device *dev)
472 537
473 return 0; 538 return 0;
474} 539}
540#else
541#define wistron_suspend NULL
542#define wistron_resume NULL
543#endif
475 544
476static struct platform_driver wistron_driver = { 545static struct platform_driver wistron_driver = {
477 .suspend = wistron_suspend,
478 .resume = wistron_resume,
479 .driver = { 546 .driver = {
480 .name = "wistron-bios", 547 .name = "wistron-bios",
548 .owner = THIS_MODULE,
481 }, 549 },
550 .probe = wistron_probe,
551 .remove = __devexit_p(wistron_remove),
552 .suspend = wistron_suspend,
553 .resume = wistron_resume,
482}; 554};
483 555
484static int __init wb_module_init(void) 556static int __init wb_module_init(void)
@@ -493,55 +565,27 @@ static int __init wb_module_init(void)
493 if (err) 565 if (err)
494 return err; 566 return err;
495 567
496 bios_attach();
497 cmos_address = bios_get_cmos_address();
498
499 err = platform_driver_register(&wistron_driver); 568 err = platform_driver_register(&wistron_driver);
500 if (err) 569 if (err)
501 goto err_detach_bios; 570 goto err_unmap_bios;
502 571
503 wistron_device = platform_device_register_simple("wistron-bios", -1, NULL, 0); 572 wistron_device = platform_device_alloc("wistron-bios", -1);
504 if (IS_ERR(wistron_device)) { 573 if (!wistron_device) {
505 err = PTR_ERR(wistron_device); 574 err = -ENOMEM;
506 goto err_unregister_driver; 575 goto err_unregister_driver;
507 } 576 }
508 577
509 if (have_wifi) { 578 err = platform_device_add(wistron_device);
510 u16 wifi = bios_get_default_setting(WIFI);
511 if (wifi & 1)
512 wifi_enabled = (wifi & 2) ? 1 : 0;
513 else
514 have_wifi = 0;
515
516 if (have_wifi)
517 bios_set_state(WIFI, wifi_enabled);
518 }
519
520 if (have_bluetooth) {
521 u16 bt = bios_get_default_setting(BLUETOOTH);
522 if (bt & 1)
523 bluetooth_enabled = (bt & 2) ? 1 : 0;
524 else
525 have_bluetooth = 0;
526
527 if (have_bluetooth)
528 bios_set_state(BLUETOOTH, bluetooth_enabled);
529 }
530
531 err = setup_input_dev();
532 if (err) 579 if (err)
533 goto err_unregister_device; 580 goto err_free_device;
534
535 poll_bios(1); /* Flush stale event queue and arm timer */
536 581
537 return 0; 582 return 0;
538 583
539 err_unregister_device: 584 err_free_device:
540 platform_device_unregister(wistron_device); 585 platform_device_put(wistron_device);
541 err_unregister_driver: 586 err_unregister_driver:
542 platform_driver_unregister(&wistron_driver); 587 platform_driver_unregister(&wistron_driver);
543 err_detach_bios: 588 err_unmap_bios:
544 bios_detach();
545 unmap_bios(); 589 unmap_bios();
546 590
547 return err; 591 return err;
@@ -549,11 +593,8 @@ static int __init wb_module_init(void)
549 593
550static void __exit wb_module_exit(void) 594static void __exit wb_module_exit(void)
551{ 595{
552 del_timer_sync(&poll_timer);
553 input_unregister_device(input_dev);
554 platform_device_unregister(wistron_device); 596 platform_device_unregister(wistron_device);
555 platform_driver_unregister(&wistron_driver); 597 platform_driver_unregister(&wistron_driver);
556 bios_detach();
557 unmap_bios(); 598 unmap_bios();
558} 599}
559 600