2 * Wistron laptop button driver
3 * Copyright (C) 2005 Miloslav Trmac <mitr@volny.cz>
4 * Copyright (C) 2005 Bernhard Rosenkraenzer <bero@arklinux.org>
5 * Copyright (C) 2005 Dmitry Torokhov <dtor@mail.ru>
7 * You can redistribute and/or modify this program under the terms of the
8 * GNU General Public License version 2 as published by the Free Software
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
14 * Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 59 Temple Place Suite 330, Boston, MA 02111-1307, USA.
21 #include <linux/dmi.h>
22 #include <linux/init.h>
23 #include <linux/input-polldev.h>
24 #include <linux/interrupt.h>
25 #include <linux/jiffies.h>
26 #include <linux/kernel.h>
27 #include <linux/mc146818rtc.h>
28 #include <linux/module.h>
29 #include <linux/preempt.h>
30 #include <linux/string.h>
31 #include <linux/types.h>
32 #include <linux/platform_device.h>
33 #include <linux/leds.h>
35 /* How often we poll keys - msecs */
36 #define POLL_INTERVAL_DEFAULT 500 /* when idle */
37 #define POLL_INTERVAL_BURST 100 /* when a key was recently pressed */
39 /* BIOS subsystem IDs */
41 #define BLUETOOTH 0x34
44 MODULE_AUTHOR("Miloslav Trmac <mitr@volny.cz>");
45 MODULE_DESCRIPTION("Wistron laptop button driver");
46 MODULE_LICENSE("GPL v2");
47 MODULE_VERSION("0.3");
49 static int force
; /* = 0; */
50 module_param(force
, bool, 0);
51 MODULE_PARM_DESC(force
, "Load even if computer is not in database");
53 static char *keymap_name
; /* = NULL; */
54 module_param_named(keymap
, keymap_name
, charp
, 0);
55 MODULE_PARM_DESC(keymap
, "Keymap name, if it can't be autodetected [generic, 1557/MS2141]");
57 static struct platform_device
*wistron_device
;
59 /* BIOS interface implementation */
61 static void __iomem
*bios_entry_point
; /* BIOS routine entry point */
62 static void __iomem
*bios_code_map_base
;
63 static void __iomem
*bios_data_map_base
;
65 static u8 cmos_address
;
71 static void call_bios(struct regs
*regs
)
76 local_irq_save(flags
);
77 asm volatile ("pushl %%ebp;"
81 : "=a" (regs
->eax
), "=b" (regs
->ebx
), "=c" (regs
->ecx
)
82 : "0" (regs
->eax
), "1" (regs
->ebx
), "2" (regs
->ecx
),
83 "m" (bios_entry_point
), "m" (bios_data_map_base
)
84 : "edx", "edi", "esi", "memory");
85 local_irq_restore(flags
);
89 static ssize_t __init
locate_wistron_bios(void __iomem
*base
)
91 static unsigned char __initdata signature
[] =
92 { 0x42, 0x21, 0x55, 0x30 };
95 for (offset
= 0; offset
< 0x10000; offset
+= 0x10) {
96 if (check_signature(base
+ offset
, signature
,
97 sizeof(signature
)) != 0)
103 static int __init
map_bios(void)
109 base
= ioremap(0xF0000, 0x10000); /* Can't fail */
110 offset
= locate_wistron_bios(base
);
112 printk(KERN_ERR
"wistron_btns: BIOS entry point not found\n");
117 entry_point
= readl(base
+ offset
+ 5);
119 "wistron_btns: BIOS signature found at %p, entry point %08X\n",
120 base
+ offset
, entry_point
);
122 if (entry_point
>= 0xF0000) {
123 bios_code_map_base
= base
;
124 bios_entry_point
= bios_code_map_base
+ (entry_point
& 0xFFFF);
127 bios_code_map_base
= ioremap(entry_point
& ~0x3FFF, 0x4000);
128 if (bios_code_map_base
== NULL
) {
130 "wistron_btns: Can't map BIOS code at %08X\n",
131 entry_point
& ~0x3FFF);
134 bios_entry_point
= bios_code_map_base
+ (entry_point
& 0x3FFF);
136 /* The Windows driver maps 0x10000 bytes, we keep only one page... */
137 bios_data_map_base
= ioremap(0x400, 0xc00);
138 if (bios_data_map_base
== NULL
) {
139 printk(KERN_ERR
"wistron_btns: Can't map BIOS data\n");
145 iounmap(bios_code_map_base
);
150 static inline void unmap_bios(void)
152 iounmap(bios_code_map_base
);
153 iounmap(bios_data_map_base
);
158 static u16
bios_pop_queue(void)
162 memset(®s
, 0, sizeof (regs
));
171 static void __devinit
bios_attach(void)
175 memset(®s
, 0, sizeof (regs
));
181 static void bios_detach(void)
185 memset(®s
, 0, sizeof (regs
));
191 static u8 __devinit
bios_get_cmos_address(void)
195 memset(®s
, 0, sizeof (regs
));
203 static u16 __devinit
bios_get_default_setting(u8 subsys
)
207 memset(®s
, 0, sizeof (regs
));
209 regs
.ebx
= 0x0200 | subsys
;
215 static void bios_set_state(u8 subsys
, int enable
)
219 memset(®s
, 0, sizeof (regs
));
221 regs
.ebx
= (enable
? 0x0100 : 0x0000) | subsys
;
225 /* Hardware database */
228 char type
; /* See KE_* below */
231 u16 keycode
; /* For KE_KEY */
232 struct { /* For KE_SW */
239 enum { KE_END
, KE_KEY
, KE_SW
, KE_WIFI
, KE_BLUETOOTH
};
241 #define FE_MAIL_LED 0x01
242 #define FE_WIFI_LED 0x02
243 #define FE_UNTESTED 0x80
245 static struct key_entry
*keymap
; /* = NULL; Current key map */
246 static bool have_wifi
;
247 static bool have_bluetooth
;
248 static int leds_present
; /* bitmask of leds present */
250 static int __init
dmi_matched(const struct dmi_system_id
*dmi
)
252 const struct key_entry
*key
;
254 keymap
= dmi
->driver_data
;
255 for (key
= keymap
; key
->type
!= KE_END
; key
++) {
256 if (key
->type
== KE_WIFI
)
258 else if (key
->type
== KE_BLUETOOTH
)
259 have_bluetooth
= true;
261 leds_present
= key
->code
& (FE_MAIL_LED
| FE_WIFI_LED
);
266 static struct key_entry keymap_empty
[] __initdata
= {
270 static struct key_entry keymap_fs_amilo_pro_v2000
[] __initdata
= {
271 { KE_KEY
, 0x01, {KEY_HELP
} },
272 { KE_KEY
, 0x11, {KEY_PROG1
} },
273 { KE_KEY
, 0x12, {KEY_PROG2
} },
275 { KE_KEY
, 0x31, {KEY_MAIL
} },
276 { KE_KEY
, 0x36, {KEY_WWW
} },
280 static struct key_entry keymap_fs_amilo_pro_v3505
[] __initdata
= {
281 { KE_KEY
, 0x01, {KEY_HELP
} }, /* Fn+F1 */
282 { KE_KEY
, 0x06, {KEY_DISPLAYTOGGLE
} }, /* Fn+F4 */
283 { KE_BLUETOOTH
, 0x30 }, /* Fn+F10 */
284 { KE_KEY
, 0x31, {KEY_MAIL
} }, /* mail button */
285 { KE_KEY
, 0x36, {KEY_WWW
} }, /* www button */
286 { KE_WIFI
, 0x78 }, /* satelite dish button */
290 static struct key_entry keymap_fujitsu_n3510
[] __initdata
= {
291 { KE_KEY
, 0x11, {KEY_PROG1
} },
292 { KE_KEY
, 0x12, {KEY_PROG2
} },
293 { KE_KEY
, 0x36, {KEY_WWW
} },
294 { KE_KEY
, 0x31, {KEY_MAIL
} },
295 { KE_KEY
, 0x71, {KEY_STOPCD
} },
296 { KE_KEY
, 0x72, {KEY_PLAYPAUSE
} },
297 { KE_KEY
, 0x74, {KEY_REWIND
} },
298 { KE_KEY
, 0x78, {KEY_FORWARD
} },
302 static struct key_entry keymap_wistron_ms2111
[] __initdata
= {
303 { KE_KEY
, 0x11, {KEY_PROG1
} },
304 { KE_KEY
, 0x12, {KEY_PROG2
} },
305 { KE_KEY
, 0x13, {KEY_PROG3
} },
306 { KE_KEY
, 0x31, {KEY_MAIL
} },
307 { KE_KEY
, 0x36, {KEY_WWW
} },
308 { KE_END
, FE_MAIL_LED
}
311 static struct key_entry keymap_wistron_md40100
[] __initdata
= {
312 { KE_KEY
, 0x01, {KEY_HELP
} },
313 { KE_KEY
, 0x02, {KEY_CONFIG
} },
314 { KE_KEY
, 0x31, {KEY_MAIL
} },
315 { KE_KEY
, 0x36, {KEY_WWW
} },
316 { KE_KEY
, 0x37, {KEY_DISPLAYTOGGLE
} }, /* Display on/off */
317 { KE_END
, FE_MAIL_LED
| FE_WIFI_LED
| FE_UNTESTED
}
320 static struct key_entry keymap_wistron_ms2141
[] __initdata
= {
321 { KE_KEY
, 0x11, {KEY_PROG1
} },
322 { KE_KEY
, 0x12, {KEY_PROG2
} },
324 { KE_KEY
, 0x22, {KEY_REWIND
} },
325 { KE_KEY
, 0x23, {KEY_FORWARD
} },
326 { KE_KEY
, 0x24, {KEY_PLAYPAUSE
} },
327 { KE_KEY
, 0x25, {KEY_STOPCD
} },
328 { KE_KEY
, 0x31, {KEY_MAIL
} },
329 { KE_KEY
, 0x36, {KEY_WWW
} },
333 static struct key_entry keymap_acer_aspire_1500
[] __initdata
= {
334 { KE_KEY
, 0x01, {KEY_HELP
} },
335 { KE_KEY
, 0x03, {KEY_POWER
} },
336 { KE_KEY
, 0x11, {KEY_PROG1
} },
337 { KE_KEY
, 0x12, {KEY_PROG2
} },
339 { KE_KEY
, 0x31, {KEY_MAIL
} },
340 { KE_KEY
, 0x36, {KEY_WWW
} },
341 { KE_KEY
, 0x49, {KEY_CONFIG
} },
342 { KE_BLUETOOTH
, 0x44 },
343 { KE_END
, FE_UNTESTED
}
346 static struct key_entry keymap_acer_aspire_1600
[] __initdata
= {
347 { KE_KEY
, 0x01, {KEY_HELP
} },
348 { KE_KEY
, 0x03, {KEY_POWER
} },
349 { KE_KEY
, 0x08, {KEY_MUTE
} },
350 { KE_KEY
, 0x11, {KEY_PROG1
} },
351 { KE_KEY
, 0x12, {KEY_PROG2
} },
352 { KE_KEY
, 0x13, {KEY_PROG3
} },
353 { KE_KEY
, 0x31, {KEY_MAIL
} },
354 { KE_KEY
, 0x36, {KEY_WWW
} },
355 { KE_KEY
, 0x49, {KEY_CONFIG
} },
357 { KE_BLUETOOTH
, 0x44 },
358 { KE_END
, FE_MAIL_LED
| FE_UNTESTED
}
361 /* 3020 has been tested */
362 static struct key_entry keymap_acer_aspire_5020
[] __initdata
= {
363 { KE_KEY
, 0x01, {KEY_HELP
} },
364 { KE_KEY
, 0x03, {KEY_POWER
} },
365 { KE_KEY
, 0x05, {KEY_SWITCHVIDEOMODE
} }, /* Display selection */
366 { KE_KEY
, 0x11, {KEY_PROG1
} },
367 { KE_KEY
, 0x12, {KEY_PROG2
} },
368 { KE_KEY
, 0x31, {KEY_MAIL
} },
369 { KE_KEY
, 0x36, {KEY_WWW
} },
370 { KE_KEY
, 0x6a, {KEY_CONFIG
} },
372 { KE_BLUETOOTH
, 0x44 },
373 { KE_END
, FE_MAIL_LED
| FE_UNTESTED
}
376 static struct key_entry keymap_acer_travelmate_2410
[] __initdata
= {
377 { KE_KEY
, 0x01, {KEY_HELP
} },
378 { KE_KEY
, 0x6d, {KEY_POWER
} },
379 { KE_KEY
, 0x11, {KEY_PROG1
} },
380 { KE_KEY
, 0x12, {KEY_PROG2
} },
381 { KE_KEY
, 0x31, {KEY_MAIL
} },
382 { KE_KEY
, 0x36, {KEY_WWW
} },
383 { KE_KEY
, 0x6a, {KEY_CONFIG
} },
385 { KE_BLUETOOTH
, 0x44 },
386 { KE_END
, FE_MAIL_LED
| FE_UNTESTED
}
389 static struct key_entry keymap_acer_travelmate_110
[] __initdata
= {
390 { KE_KEY
, 0x01, {KEY_HELP
} },
391 { KE_KEY
, 0x02, {KEY_CONFIG
} },
392 { KE_KEY
, 0x03, {KEY_POWER
} },
393 { KE_KEY
, 0x08, {KEY_MUTE
} },
394 { KE_KEY
, 0x11, {KEY_PROG1
} },
395 { KE_KEY
, 0x12, {KEY_PROG2
} },
396 { KE_KEY
, 0x20, {KEY_VOLUMEUP
} },
397 { KE_KEY
, 0x21, {KEY_VOLUMEDOWN
} },
398 { KE_KEY
, 0x31, {KEY_MAIL
} },
399 { KE_KEY
, 0x36, {KEY_WWW
} },
400 { KE_SW
, 0x4a, {.sw
= {SW_LID
, 1}} }, /* lid close */
401 { KE_SW
, 0x4b, {.sw
= {SW_LID
, 0}} }, /* lid open */
403 { KE_END
, FE_MAIL_LED
| FE_UNTESTED
}
406 static struct key_entry keymap_acer_travelmate_300
[] __initdata
= {
407 { KE_KEY
, 0x01, {KEY_HELP
} },
408 { KE_KEY
, 0x02, {KEY_CONFIG
} },
409 { KE_KEY
, 0x03, {KEY_POWER
} },
410 { KE_KEY
, 0x08, {KEY_MUTE
} },
411 { KE_KEY
, 0x11, {KEY_PROG1
} },
412 { KE_KEY
, 0x12, {KEY_PROG2
} },
413 { KE_KEY
, 0x20, {KEY_VOLUMEUP
} },
414 { KE_KEY
, 0x21, {KEY_VOLUMEDOWN
} },
415 { KE_KEY
, 0x31, {KEY_MAIL
} },
416 { KE_KEY
, 0x36, {KEY_WWW
} },
418 { KE_BLUETOOTH
, 0x44 },
419 { KE_END
, FE_MAIL_LED
| FE_UNTESTED
}
422 static struct key_entry keymap_acer_travelmate_380
[] __initdata
= {
423 { KE_KEY
, 0x01, {KEY_HELP
} },
424 { KE_KEY
, 0x02, {KEY_CONFIG
} },
425 { KE_KEY
, 0x03, {KEY_POWER
} }, /* not 370 */
426 { KE_KEY
, 0x11, {KEY_PROG1
} },
427 { KE_KEY
, 0x12, {KEY_PROG2
} },
428 { KE_KEY
, 0x13, {KEY_PROG3
} },
429 { KE_KEY
, 0x31, {KEY_MAIL
} },
430 { KE_KEY
, 0x36, {KEY_WWW
} },
432 { KE_END
, FE_MAIL_LED
| FE_UNTESTED
}
436 static struct key_entry keymap_acer_travelmate_220
[] __initdata
= {
437 { KE_KEY
, 0x01, {KEY_HELP
} },
438 { KE_KEY
, 0x02, {KEY_CONFIG
} },
439 { KE_KEY
, 0x11, {KEY_MAIL
} },
440 { KE_KEY
, 0x12, {KEY_WWW
} },
441 { KE_KEY
, 0x13, {KEY_PROG2
} },
442 { KE_KEY
, 0x31, {KEY_PROG1
} },
443 { KE_END
, FE_WIFI_LED
| FE_UNTESTED
}
446 static struct key_entry keymap_acer_travelmate_230
[] __initdata
= {
447 { KE_KEY
, 0x01, {KEY_HELP
} },
448 { KE_KEY
, 0x02, {KEY_CONFIG
} },
449 { KE_KEY
, 0x11, {KEY_PROG1
} },
450 { KE_KEY
, 0x12, {KEY_PROG2
} },
451 { KE_KEY
, 0x31, {KEY_MAIL
} },
452 { KE_KEY
, 0x36, {KEY_WWW
} },
453 { KE_END
, FE_WIFI_LED
| FE_UNTESTED
}
456 static struct key_entry keymap_acer_travelmate_240
[] __initdata
= {
457 { KE_KEY
, 0x01, {KEY_HELP
} },
458 { KE_KEY
, 0x02, {KEY_CONFIG
} },
459 { KE_KEY
, 0x03, {KEY_POWER
} },
460 { KE_KEY
, 0x08, {KEY_MUTE
} },
461 { KE_KEY
, 0x31, {KEY_MAIL
} },
462 { KE_KEY
, 0x36, {KEY_WWW
} },
463 { KE_KEY
, 0x11, {KEY_PROG1
} },
464 { KE_KEY
, 0x12, {KEY_PROG2
} },
465 { KE_BLUETOOTH
, 0x44 },
467 { KE_END
, FE_UNTESTED
}
470 static struct key_entry keymap_acer_travelmate_350
[] __initdata
= {
471 { KE_KEY
, 0x01, {KEY_HELP
} },
472 { KE_KEY
, 0x02, {KEY_CONFIG
} },
473 { KE_KEY
, 0x11, {KEY_PROG1
} },
474 { KE_KEY
, 0x12, {KEY_PROG2
} },
475 { KE_KEY
, 0x13, {KEY_MAIL
} },
476 { KE_KEY
, 0x14, {KEY_PROG3
} },
477 { KE_KEY
, 0x15, {KEY_WWW
} },
478 { KE_END
, FE_MAIL_LED
| FE_WIFI_LED
| FE_UNTESTED
}
481 static struct key_entry keymap_acer_travelmate_360
[] __initdata
= {
482 { KE_KEY
, 0x01, {KEY_HELP
} },
483 { KE_KEY
, 0x02, {KEY_CONFIG
} },
484 { KE_KEY
, 0x11, {KEY_PROG1
} },
485 { KE_KEY
, 0x12, {KEY_PROG2
} },
486 { KE_KEY
, 0x13, {KEY_MAIL
} },
487 { KE_KEY
, 0x14, {KEY_PROG3
} },
488 { KE_KEY
, 0x15, {KEY_WWW
} },
489 { KE_KEY
, 0x40, {KEY_WLAN
} },
490 { KE_END
, FE_WIFI_LED
| FE_UNTESTED
} /* no mail led */
493 /* Wifi subsystem only activates the led. Therefore we need to pass
494 * wifi event as a normal key, then userspace can really change the wifi state.
495 * TODO we need to export led state to userspace (wifi and mail) */
496 static struct key_entry keymap_acer_travelmate_610
[] __initdata
= {
497 { KE_KEY
, 0x01, {KEY_HELP
} },
498 { KE_KEY
, 0x02, {KEY_CONFIG
} },
499 { KE_KEY
, 0x11, {KEY_PROG1
} },
500 { KE_KEY
, 0x12, {KEY_PROG2
} },
501 { KE_KEY
, 0x13, {KEY_PROG3
} },
502 { KE_KEY
, 0x14, {KEY_MAIL
} },
503 { KE_KEY
, 0x15, {KEY_WWW
} },
504 { KE_KEY
, 0x40, {KEY_WLAN
} },
505 { KE_END
, FE_MAIL_LED
| FE_WIFI_LED
}
508 static struct key_entry keymap_acer_travelmate_630
[] __initdata
= {
509 { KE_KEY
, 0x01, {KEY_HELP
} },
510 { KE_KEY
, 0x02, {KEY_CONFIG
} },
511 { KE_KEY
, 0x03, {KEY_POWER
} },
512 { KE_KEY
, 0x08, {KEY_MUTE
} }, /* not 620 */
513 { KE_KEY
, 0x11, {KEY_PROG1
} },
514 { KE_KEY
, 0x12, {KEY_PROG2
} },
515 { KE_KEY
, 0x13, {KEY_PROG3
} },
516 { KE_KEY
, 0x20, {KEY_VOLUMEUP
} },
517 { KE_KEY
, 0x21, {KEY_VOLUMEDOWN
} },
518 { KE_KEY
, 0x31, {KEY_MAIL
} },
519 { KE_KEY
, 0x36, {KEY_WWW
} },
521 { KE_END
, FE_MAIL_LED
| FE_UNTESTED
}
524 static struct key_entry keymap_aopen_1559as
[] __initdata
= {
525 { KE_KEY
, 0x01, {KEY_HELP
} },
526 { KE_KEY
, 0x06, {KEY_PROG3
} },
527 { KE_KEY
, 0x11, {KEY_PROG1
} },
528 { KE_KEY
, 0x12, {KEY_PROG2
} },
530 { KE_KEY
, 0x31, {KEY_MAIL
} },
531 { KE_KEY
, 0x36, {KEY_WWW
} },
535 static struct key_entry keymap_fs_amilo_d88x0
[] __initdata
= {
536 { KE_KEY
, 0x01, {KEY_HELP
} },
537 { KE_KEY
, 0x08, {KEY_MUTE
} },
538 { KE_KEY
, 0x31, {KEY_MAIL
} },
539 { KE_KEY
, 0x36, {KEY_WWW
} },
540 { KE_KEY
, 0x11, {KEY_PROG1
} },
541 { KE_KEY
, 0x12, {KEY_PROG2
} },
542 { KE_KEY
, 0x13, {KEY_PROG3
} },
543 { KE_END
, FE_MAIL_LED
| FE_WIFI_LED
| FE_UNTESTED
}
546 static struct key_entry keymap_wistron_md2900
[] __initdata
= {
547 { KE_KEY
, 0x01, {KEY_HELP
} },
548 { KE_KEY
, 0x02, {KEY_CONFIG
} },
549 { KE_KEY
, 0x11, {KEY_PROG1
} },
550 { KE_KEY
, 0x12, {KEY_PROG2
} },
551 { KE_KEY
, 0x31, {KEY_MAIL
} },
552 { KE_KEY
, 0x36, {KEY_WWW
} },
554 { KE_END
, FE_MAIL_LED
| FE_UNTESTED
}
557 static struct key_entry keymap_wistron_md96500
[] __initdata
= {
558 { KE_KEY
, 0x01, {KEY_HELP
} },
559 { KE_KEY
, 0x02, {KEY_CONFIG
} },
560 { KE_KEY
, 0x05, {KEY_SWITCHVIDEOMODE
} }, /* Display selection */
561 { KE_KEY
, 0x06, {KEY_DISPLAYTOGGLE
} }, /* Display on/off */
562 { KE_KEY
, 0x08, {KEY_MUTE
} },
563 { KE_KEY
, 0x11, {KEY_PROG1
} },
564 { KE_KEY
, 0x12, {KEY_PROG2
} },
565 { KE_KEY
, 0x20, {KEY_VOLUMEUP
} },
566 { KE_KEY
, 0x21, {KEY_VOLUMEDOWN
} },
567 { KE_KEY
, 0x22, {KEY_REWIND
} },
568 { KE_KEY
, 0x23, {KEY_FORWARD
} },
569 { KE_KEY
, 0x24, {KEY_PLAYPAUSE
} },
570 { KE_KEY
, 0x25, {KEY_STOPCD
} },
571 { KE_KEY
, 0x31, {KEY_MAIL
} },
572 { KE_KEY
, 0x36, {KEY_WWW
} },
574 { KE_BLUETOOTH
, 0x44 },
575 { KE_END
, FE_UNTESTED
}
578 static struct key_entry keymap_wistron_generic
[] __initdata
= {
579 { KE_KEY
, 0x01, {KEY_HELP
} },
580 { KE_KEY
, 0x02, {KEY_CONFIG
} },
581 { KE_KEY
, 0x03, {KEY_POWER
} },
582 { KE_KEY
, 0x05, {KEY_SWITCHVIDEOMODE
} }, /* Display selection */
583 { KE_KEY
, 0x06, {KEY_DISPLAYTOGGLE
} }, /* Display on/off */
584 { KE_KEY
, 0x08, {KEY_MUTE
} },
585 { KE_KEY
, 0x11, {KEY_PROG1
} },
586 { KE_KEY
, 0x12, {KEY_PROG2
} },
587 { KE_KEY
, 0x13, {KEY_PROG3
} },
588 { KE_KEY
, 0x14, {KEY_MAIL
} },
589 { KE_KEY
, 0x15, {KEY_WWW
} },
590 { KE_KEY
, 0x20, {KEY_VOLUMEUP
} },
591 { KE_KEY
, 0x21, {KEY_VOLUMEDOWN
} },
592 { KE_KEY
, 0x22, {KEY_REWIND
} },
593 { KE_KEY
, 0x23, {KEY_FORWARD
} },
594 { KE_KEY
, 0x24, {KEY_PLAYPAUSE
} },
595 { KE_KEY
, 0x25, {KEY_STOPCD
} },
596 { KE_KEY
, 0x31, {KEY_MAIL
} },
597 { KE_KEY
, 0x36, {KEY_WWW
} },
598 { KE_KEY
, 0x37, {KEY_DISPLAYTOGGLE
} }, /* Display on/off */
599 { KE_KEY
, 0x40, {KEY_WLAN
} },
600 { KE_KEY
, 0x49, {KEY_CONFIG
} },
601 { KE_SW
, 0x4a, {.sw
= {SW_LID
, 1}} }, /* lid close */
602 { KE_SW
, 0x4b, {.sw
= {SW_LID
, 0}} }, /* lid open */
603 { KE_KEY
, 0x6a, {KEY_CONFIG
} },
604 { KE_KEY
, 0x6d, {KEY_POWER
} },
605 { KE_KEY
, 0x71, {KEY_STOPCD
} },
606 { KE_KEY
, 0x72, {KEY_PLAYPAUSE
} },
607 { KE_KEY
, 0x74, {KEY_REWIND
} },
608 { KE_KEY
, 0x78, {KEY_FORWARD
} },
610 { KE_BLUETOOTH
, 0x44 },
614 static struct key_entry keymap_aopen_1557
[] __initdata
= {
615 { KE_KEY
, 0x01, {KEY_HELP
} },
616 { KE_KEY
, 0x11, {KEY_PROG1
} },
617 { KE_KEY
, 0x12, {KEY_PROG2
} },
619 { KE_KEY
, 0x22, {KEY_REWIND
} },
620 { KE_KEY
, 0x23, {KEY_FORWARD
} },
621 { KE_KEY
, 0x24, {KEY_PLAYPAUSE
} },
622 { KE_KEY
, 0x25, {KEY_STOPCD
} },
623 { KE_KEY
, 0x31, {KEY_MAIL
} },
624 { KE_KEY
, 0x36, {KEY_WWW
} },
628 static struct key_entry keymap_prestigio
[] __initdata
= {
629 { KE_KEY
, 0x11, {KEY_PROG1
} },
630 { KE_KEY
, 0x12, {KEY_PROG2
} },
632 { KE_KEY
, 0x22, {KEY_REWIND
} },
633 { KE_KEY
, 0x23, {KEY_FORWARD
} },
634 { KE_KEY
, 0x24, {KEY_PLAYPAUSE
} },
635 { KE_KEY
, 0x25, {KEY_STOPCD
} },
636 { KE_KEY
, 0x31, {KEY_MAIL
} },
637 { KE_KEY
, 0x36, {KEY_WWW
} },
643 * If your machine is not here (which is currently rather likely), please send
644 * a list of buttons and their key codes (reported when loading this module
645 * with force=1) and the output of dmidecode to $MODULE_AUTHOR.
647 static struct dmi_system_id dmi_ids
[] __initdata
= {
649 .callback
= dmi_matched
,
650 .ident
= "Fujitsu-Siemens Amilo Pro V2000",
652 DMI_MATCH(DMI_SYS_VENDOR
, "FUJITSU SIEMENS"),
653 DMI_MATCH(DMI_PRODUCT_NAME
, "AMILO Pro V2000"),
655 .driver_data
= keymap_fs_amilo_pro_v2000
658 .callback
= dmi_matched
,
659 .ident
= "Fujitsu-Siemens Amilo Pro Edition V3505",
661 DMI_MATCH(DMI_SYS_VENDOR
, "FUJITSU SIEMENS"),
662 DMI_MATCH(DMI_PRODUCT_NAME
, "AMILO Pro Edition V3505"),
664 .driver_data
= keymap_fs_amilo_pro_v3505
667 .callback
= dmi_matched
,
668 .ident
= "Fujitsu-Siemens Amilo M7400",
670 DMI_MATCH(DMI_SYS_VENDOR
, "FUJITSU SIEMENS"),
671 DMI_MATCH(DMI_PRODUCT_NAME
, "AMILO M "),
673 .driver_data
= keymap_fs_amilo_pro_v2000
676 .callback
= dmi_matched
,
677 .ident
= "Maxdata Pro 7000 DX",
679 DMI_MATCH(DMI_SYS_VENDOR
, "MAXDATA"),
680 DMI_MATCH(DMI_PRODUCT_NAME
, "Pro 7000"),
682 .driver_data
= keymap_fs_amilo_pro_v2000
685 .callback
= dmi_matched
,
686 .ident
= "Fujitsu N3510",
688 DMI_MATCH(DMI_SYS_VENDOR
, "FUJITSU"),
689 DMI_MATCH(DMI_PRODUCT_NAME
, "N3510"),
691 .driver_data
= keymap_fujitsu_n3510
694 .callback
= dmi_matched
,
695 .ident
= "Acer Aspire 1500",
697 DMI_MATCH(DMI_SYS_VENDOR
, "Acer"),
698 DMI_MATCH(DMI_PRODUCT_NAME
, "Aspire 1500"),
700 .driver_data
= keymap_acer_aspire_1500
703 .callback
= dmi_matched
,
704 .ident
= "Acer Aspire 1600",
706 DMI_MATCH(DMI_SYS_VENDOR
, "Acer"),
707 DMI_MATCH(DMI_PRODUCT_NAME
, "Aspire 1600"),
709 .driver_data
= keymap_acer_aspire_1600
712 .callback
= dmi_matched
,
713 .ident
= "Acer Aspire 3020",
715 DMI_MATCH(DMI_SYS_VENDOR
, "Acer"),
716 DMI_MATCH(DMI_PRODUCT_NAME
, "Aspire 3020"),
718 .driver_data
= keymap_acer_aspire_5020
721 .callback
= dmi_matched
,
722 .ident
= "Acer Aspire 5020",
724 DMI_MATCH(DMI_SYS_VENDOR
, "Acer"),
725 DMI_MATCH(DMI_PRODUCT_NAME
, "Aspire 5020"),
727 .driver_data
= keymap_acer_aspire_5020
730 .callback
= dmi_matched
,
731 .ident
= "Acer TravelMate 2100",
733 DMI_MATCH(DMI_SYS_VENDOR
, "Acer"),
734 DMI_MATCH(DMI_PRODUCT_NAME
, "TravelMate 2100"),
736 .driver_data
= keymap_acer_aspire_5020
739 .callback
= dmi_matched
,
740 .ident
= "Acer TravelMate 2410",
742 DMI_MATCH(DMI_SYS_VENDOR
, "Acer"),
743 DMI_MATCH(DMI_PRODUCT_NAME
, "TravelMate 2410"),
745 .driver_data
= keymap_acer_travelmate_2410
748 .callback
= dmi_matched
,
749 .ident
= "Acer TravelMate C300",
751 DMI_MATCH(DMI_SYS_VENDOR
, "Acer"),
752 DMI_MATCH(DMI_PRODUCT_NAME
, "TravelMate C300"),
754 .driver_data
= keymap_acer_travelmate_300
757 .callback
= dmi_matched
,
758 .ident
= "Acer TravelMate C100",
760 DMI_MATCH(DMI_SYS_VENDOR
, "Acer"),
761 DMI_MATCH(DMI_PRODUCT_NAME
, "TravelMate C100"),
763 .driver_data
= keymap_acer_travelmate_300
766 .callback
= dmi_matched
,
767 .ident
= "Acer TravelMate C110",
769 DMI_MATCH(DMI_SYS_VENDOR
, "Acer"),
770 DMI_MATCH(DMI_PRODUCT_NAME
, "TravelMate C110"),
772 .driver_data
= keymap_acer_travelmate_110
775 .callback
= dmi_matched
,
776 .ident
= "Acer TravelMate 380",
778 DMI_MATCH(DMI_SYS_VENDOR
, "Acer"),
779 DMI_MATCH(DMI_PRODUCT_NAME
, "TravelMate 380"),
781 .driver_data
= keymap_acer_travelmate_380
784 .callback
= dmi_matched
,
785 .ident
= "Acer TravelMate 370",
787 DMI_MATCH(DMI_SYS_VENDOR
, "Acer"),
788 DMI_MATCH(DMI_PRODUCT_NAME
, "TravelMate 370"),
790 .driver_data
= keymap_acer_travelmate_380
/* keyboard minus 1 key */
793 .callback
= dmi_matched
,
794 .ident
= "Acer TravelMate 220",
796 DMI_MATCH(DMI_SYS_VENDOR
, "Acer"),
797 DMI_MATCH(DMI_PRODUCT_NAME
, "TravelMate 220"),
799 .driver_data
= keymap_acer_travelmate_220
802 .callback
= dmi_matched
,
803 .ident
= "Acer TravelMate 260",
805 DMI_MATCH(DMI_SYS_VENDOR
, "Acer"),
806 DMI_MATCH(DMI_PRODUCT_NAME
, "TravelMate 260"),
808 .driver_data
= keymap_acer_travelmate_220
811 .callback
= dmi_matched
,
812 .ident
= "Acer TravelMate 230",
814 DMI_MATCH(DMI_SYS_VENDOR
, "Acer"),
815 DMI_MATCH(DMI_PRODUCT_NAME
, "TravelMate 230"),
816 /* acerhk looks for "TravelMate F4..." ?! */
818 .driver_data
= keymap_acer_travelmate_230
821 .callback
= dmi_matched
,
822 .ident
= "Acer TravelMate 280",
824 DMI_MATCH(DMI_SYS_VENDOR
, "Acer"),
825 DMI_MATCH(DMI_PRODUCT_NAME
, "TravelMate 280"),
827 .driver_data
= keymap_acer_travelmate_230
830 .callback
= dmi_matched
,
831 .ident
= "Acer TravelMate 240",
833 DMI_MATCH(DMI_SYS_VENDOR
, "Acer"),
834 DMI_MATCH(DMI_PRODUCT_NAME
, "TravelMate 240"),
836 .driver_data
= keymap_acer_travelmate_240
839 .callback
= dmi_matched
,
840 .ident
= "Acer TravelMate 250",
842 DMI_MATCH(DMI_SYS_VENDOR
, "Acer"),
843 DMI_MATCH(DMI_PRODUCT_NAME
, "TravelMate 250"),
845 .driver_data
= keymap_acer_travelmate_240
848 .callback
= dmi_matched
,
849 .ident
= "Acer TravelMate 2424NWXCi",
851 DMI_MATCH(DMI_SYS_VENDOR
, "Acer"),
852 DMI_MATCH(DMI_PRODUCT_NAME
, "TravelMate 2420"),
854 .driver_data
= keymap_acer_travelmate_240
857 .callback
= dmi_matched
,
858 .ident
= "Acer TravelMate 350",
860 DMI_MATCH(DMI_SYS_VENDOR
, "Acer"),
861 DMI_MATCH(DMI_PRODUCT_NAME
, "TravelMate 350"),
863 .driver_data
= keymap_acer_travelmate_350
866 .callback
= dmi_matched
,
867 .ident
= "Acer TravelMate 360",
869 DMI_MATCH(DMI_SYS_VENDOR
, "Acer"),
870 DMI_MATCH(DMI_PRODUCT_NAME
, "TravelMate 360"),
872 .driver_data
= keymap_acer_travelmate_360
875 .callback
= dmi_matched
,
876 .ident
= "Acer TravelMate 610",
878 DMI_MATCH(DMI_SYS_VENDOR
, "ACER"),
879 DMI_MATCH(DMI_PRODUCT_NAME
, "TravelMate 610"),
881 .driver_data
= keymap_acer_travelmate_610
884 .callback
= dmi_matched
,
885 .ident
= "Acer TravelMate 620",
887 DMI_MATCH(DMI_SYS_VENDOR
, "Acer"),
888 DMI_MATCH(DMI_PRODUCT_NAME
, "TravelMate 620"),
890 .driver_data
= keymap_acer_travelmate_630
893 .callback
= dmi_matched
,
894 .ident
= "Acer TravelMate 630",
896 DMI_MATCH(DMI_SYS_VENDOR
, "Acer"),
897 DMI_MATCH(DMI_PRODUCT_NAME
, "TravelMate 630"),
899 .driver_data
= keymap_acer_travelmate_630
902 .callback
= dmi_matched
,
903 .ident
= "AOpen 1559AS",
905 DMI_MATCH(DMI_PRODUCT_NAME
, "E2U"),
906 DMI_MATCH(DMI_BOARD_NAME
, "E2U"),
908 .driver_data
= keymap_aopen_1559as
911 .callback
= dmi_matched
,
912 .ident
= "Medion MD 9783",
914 DMI_MATCH(DMI_SYS_VENDOR
, "MEDIONNB"),
915 DMI_MATCH(DMI_PRODUCT_NAME
, "MD 9783"),
917 .driver_data
= keymap_wistron_ms2111
920 .callback
= dmi_matched
,
921 .ident
= "Medion MD 40100",
923 DMI_MATCH(DMI_SYS_VENDOR
, "MEDIONNB"),
924 DMI_MATCH(DMI_PRODUCT_NAME
, "WID2000"),
926 .driver_data
= keymap_wistron_md40100
929 .callback
= dmi_matched
,
930 .ident
= "Medion MD 2900",
932 DMI_MATCH(DMI_SYS_VENDOR
, "MEDIONNB"),
933 DMI_MATCH(DMI_PRODUCT_NAME
, "WIM 2000"),
935 .driver_data
= keymap_wistron_md2900
938 .callback
= dmi_matched
,
939 .ident
= "Medion MD 42200",
941 DMI_MATCH(DMI_SYS_VENDOR
, "Medion"),
942 DMI_MATCH(DMI_PRODUCT_NAME
, "WIM 2030"),
944 .driver_data
= keymap_fs_amilo_pro_v2000
947 .callback
= dmi_matched
,
948 .ident
= "Medion MD 96500",
950 DMI_MATCH(DMI_SYS_VENDOR
, "MEDIONPC"),
951 DMI_MATCH(DMI_PRODUCT_NAME
, "WIM 2040"),
953 .driver_data
= keymap_wistron_md96500
956 .callback
= dmi_matched
,
957 .ident
= "Medion MD 95400",
959 DMI_MATCH(DMI_SYS_VENDOR
, "MEDIONPC"),
960 DMI_MATCH(DMI_PRODUCT_NAME
, "WIM 2050"),
962 .driver_data
= keymap_wistron_md96500
965 .callback
= dmi_matched
,
966 .ident
= "Fujitsu Siemens Amilo D7820",
968 DMI_MATCH(DMI_SYS_VENDOR
, "FUJITSU SIEMENS"), /* not sure */
969 DMI_MATCH(DMI_PRODUCT_NAME
, "Amilo D"),
971 .driver_data
= keymap_fs_amilo_d88x0
974 .callback
= dmi_matched
,
975 .ident
= "Fujitsu Siemens Amilo D88x0",
977 DMI_MATCH(DMI_SYS_VENDOR
, "FUJITSU SIEMENS"),
978 DMI_MATCH(DMI_PRODUCT_NAME
, "AMILO D"),
980 .driver_data
= keymap_fs_amilo_d88x0
985 /* Copy the good keymap, as the original ones are free'd */
986 static int __init
copy_keymap(void)
988 const struct key_entry
*key
;
989 struct key_entry
*new_keymap
;
990 unsigned int length
= 1;
992 for (key
= keymap
; key
->type
!= KE_END
; key
++)
995 new_keymap
= kmalloc(length
* sizeof(struct key_entry
), GFP_KERNEL
);
999 memcpy(new_keymap
, keymap
, length
* sizeof(struct key_entry
));
1000 keymap
= new_keymap
;
1005 static int __init
select_keymap(void)
1007 dmi_check_system(dmi_ids
);
1008 if (keymap_name
!= NULL
) {
1009 if (strcmp (keymap_name
, "1557/MS2141") == 0)
1010 keymap
= keymap_wistron_ms2141
;
1011 else if (strcmp (keymap_name
, "aopen1557") == 0)
1012 keymap
= keymap_aopen_1557
;
1013 else if (strcmp (keymap_name
, "prestigio") == 0)
1014 keymap
= keymap_prestigio
;
1015 else if (strcmp (keymap_name
, "generic") == 0)
1016 keymap
= keymap_wistron_generic
;
1018 printk(KERN_ERR
"wistron_btns: Keymap unknown\n");
1022 if (keymap
== NULL
) {
1024 printk(KERN_ERR
"wistron_btns: System unknown\n");
1027 keymap
= keymap_empty
;
1030 return copy_keymap();
1033 /* Input layer interface */
1035 static struct input_polled_dev
*wistron_idev
;
1036 static unsigned long jiffies_last_press
;
1037 static bool wifi_enabled
;
1038 static bool bluetooth_enabled
;
1040 static void report_key(struct input_dev
*dev
, unsigned int keycode
)
1042 input_report_key(dev
, keycode
, 1);
1044 input_report_key(dev
, keycode
, 0);
1048 static void report_switch(struct input_dev
*dev
, unsigned int code
, int value
)
1050 input_report_switch(dev
, code
, value
);
1055 /* led management */
1056 static void wistron_mail_led_set(struct led_classdev
*led_cdev
,
1057 enum led_brightness value
)
1059 bios_set_state(MAIL_LED
, (value
!= LED_OFF
) ? 1 : 0);
1062 /* same as setting up wifi card, but for laptops on which the led is managed */
1063 static void wistron_wifi_led_set(struct led_classdev
*led_cdev
,
1064 enum led_brightness value
)
1066 bios_set_state(WIFI
, (value
!= LED_OFF
) ? 1 : 0);
1069 static struct led_classdev wistron_mail_led
= {
1070 .name
= "wistron:green:mail",
1071 .brightness_set
= wistron_mail_led_set
,
1074 static struct led_classdev wistron_wifi_led
= {
1075 .name
= "wistron:red:wifi",
1076 .brightness_set
= wistron_wifi_led_set
,
1079 static void __devinit
wistron_led_init(struct device
*parent
)
1081 if (leds_present
& FE_WIFI_LED
) {
1082 u16 wifi
= bios_get_default_setting(WIFI
);
1084 wistron_wifi_led
.brightness
= (wifi
& 2) ? LED_FULL
: LED_OFF
;
1085 if (led_classdev_register(parent
, &wistron_wifi_led
))
1086 leds_present
&= ~FE_WIFI_LED
;
1088 bios_set_state(WIFI
, wistron_wifi_led
.brightness
);
1091 leds_present
&= ~FE_WIFI_LED
;
1094 if (leds_present
& FE_MAIL_LED
) {
1095 /* bios_get_default_setting(MAIL) always retuns 0, so just turn the led off */
1096 wistron_mail_led
.brightness
= LED_OFF
;
1097 if (led_classdev_register(parent
, &wistron_mail_led
))
1098 leds_present
&= ~FE_MAIL_LED
;
1100 bios_set_state(MAIL_LED
, wistron_mail_led
.brightness
);
1104 static void __devexit
wistron_led_remove(void)
1106 if (leds_present
& FE_MAIL_LED
)
1107 led_classdev_unregister(&wistron_mail_led
);
1109 if (leds_present
& FE_WIFI_LED
)
1110 led_classdev_unregister(&wistron_wifi_led
);
1113 static inline void wistron_led_suspend(void)
1115 if (leds_present
& FE_MAIL_LED
)
1116 led_classdev_suspend(&wistron_mail_led
);
1118 if (leds_present
& FE_WIFI_LED
)
1119 led_classdev_suspend(&wistron_wifi_led
);
1122 static inline void wistron_led_resume(void)
1124 if (leds_present
& FE_MAIL_LED
)
1125 led_classdev_resume(&wistron_mail_led
);
1127 if (leds_present
& FE_WIFI_LED
)
1128 led_classdev_resume(&wistron_wifi_led
);
1131 static struct key_entry
*wistron_get_entry_by_scancode(int code
)
1133 struct key_entry
*key
;
1135 for (key
= keymap
; key
->type
!= KE_END
; key
++)
1136 if (code
== key
->code
)
1142 static struct key_entry
*wistron_get_entry_by_keycode(int keycode
)
1144 struct key_entry
*key
;
1146 for (key
= keymap
; key
->type
!= KE_END
; key
++)
1147 if (key
->type
== KE_KEY
&& keycode
== key
->keycode
)
1153 static void handle_key(u8 code
)
1155 const struct key_entry
*key
= wistron_get_entry_by_scancode(code
);
1158 switch (key
->type
) {
1160 report_key(wistron_idev
->input
, key
->keycode
);
1164 report_switch(wistron_idev
->input
,
1165 key
->sw
.code
, key
->sw
.value
);
1170 wifi_enabled
= !wifi_enabled
;
1171 bios_set_state(WIFI
, wifi_enabled
);
1176 if (have_bluetooth
) {
1177 bluetooth_enabled
= !bluetooth_enabled
;
1178 bios_set_state(BLUETOOTH
, bluetooth_enabled
);
1185 jiffies_last_press
= jiffies
;
1188 "wistron_btns: Unknown key code %02X\n", code
);
1191 static void poll_bios(bool discard
)
1197 qlen
= CMOS_READ(cmos_address
);
1200 val
= bios_pop_queue();
1201 if (val
!= 0 && !discard
)
1202 handle_key((u8
)val
);
1206 static void wistron_flush(struct input_polled_dev
*dev
)
1208 /* Flush stale event queue */
1212 static void wistron_poll(struct input_polled_dev
*dev
)
1216 /* Increase poll frequency if user is currently pressing keys (< 2s ago) */
1217 if (time_before(jiffies
, jiffies_last_press
+ 2 * HZ
))
1218 dev
->poll_interval
= POLL_INTERVAL_BURST
;
1220 dev
->poll_interval
= POLL_INTERVAL_DEFAULT
;
1223 static int wistron_getkeycode(struct input_dev
*dev
, int scancode
, int *keycode
)
1225 const struct key_entry
*key
= wistron_get_entry_by_scancode(scancode
);
1227 if (key
&& key
->type
== KE_KEY
) {
1228 *keycode
= key
->keycode
;
1235 static int wistron_setkeycode(struct input_dev
*dev
, int scancode
, int keycode
)
1237 struct key_entry
*key
;
1240 if (keycode
< 0 || keycode
> KEY_MAX
)
1243 key
= wistron_get_entry_by_scancode(scancode
);
1244 if (key
&& key
->type
== KE_KEY
) {
1245 old_keycode
= key
->keycode
;
1246 key
->keycode
= keycode
;
1247 set_bit(keycode
, dev
->keybit
);
1248 if (!wistron_get_entry_by_keycode(old_keycode
))
1249 clear_bit(old_keycode
, dev
->keybit
);
1256 static int __devinit
setup_input_dev(void)
1258 struct key_entry
*key
;
1259 struct input_dev
*input_dev
;
1262 wistron_idev
= input_allocate_polled_device();
1266 wistron_idev
->flush
= wistron_flush
;
1267 wistron_idev
->poll
= wistron_poll
;
1268 wistron_idev
->poll_interval
= POLL_INTERVAL_DEFAULT
;
1270 input_dev
= wistron_idev
->input
;
1271 input_dev
->name
= "Wistron laptop buttons";
1272 input_dev
->phys
= "wistron/input0";
1273 input_dev
->id
.bustype
= BUS_HOST
;
1274 input_dev
->dev
.parent
= &wistron_device
->dev
;
1276 input_dev
->getkeycode
= wistron_getkeycode
;
1277 input_dev
->setkeycode
= wistron_setkeycode
;
1279 for (key
= keymap
; key
->type
!= KE_END
; key
++) {
1280 switch (key
->type
) {
1282 set_bit(EV_KEY
, input_dev
->evbit
);
1283 set_bit(key
->keycode
, input_dev
->keybit
);
1287 set_bit(EV_SW
, input_dev
->evbit
);
1288 set_bit(key
->sw
.code
, input_dev
->swbit
);
1291 /* if wifi or bluetooth are not available, create normal keys */
1295 key
->keycode
= KEY_WLAN
;
1301 if (!have_bluetooth
) {
1303 key
->keycode
= KEY_BLUETOOTH
;
1313 /* reads information flags on KE_END */
1314 if (key
->code
& FE_UNTESTED
)
1315 printk(KERN_WARNING
"Untested laptop multimedia keys, "
1316 "please report success or failure to eric.piel"
1317 "@tremplin-utc.net\n");
1319 error
= input_register_polled_device(wistron_idev
);
1321 input_free_polled_device(wistron_idev
);
1330 static int __devinit
wistron_probe(struct platform_device
*dev
)
1335 cmos_address
= bios_get_cmos_address();
1338 u16 wifi
= bios_get_default_setting(WIFI
);
1340 wifi_enabled
= wifi
& 2;
1345 bios_set_state(WIFI
, wifi_enabled
);
1348 if (have_bluetooth
) {
1349 u16 bt
= bios_get_default_setting(BLUETOOTH
);
1351 bluetooth_enabled
= bt
& 2;
1353 have_bluetooth
= false;
1356 bios_set_state(BLUETOOTH
, bluetooth_enabled
);
1359 wistron_led_init(&dev
->dev
);
1361 err
= setup_input_dev();
1370 static int __devexit
wistron_remove(struct platform_device
*dev
)
1372 wistron_led_remove();
1373 input_unregister_polled_device(wistron_idev
);
1374 input_free_polled_device(wistron_idev
);
1381 static int wistron_suspend(struct device
*dev
)
1384 bios_set_state(WIFI
, 0);
1387 bios_set_state(BLUETOOTH
, 0);
1389 wistron_led_suspend();
1394 static int wistron_resume(struct device
*dev
)
1397 bios_set_state(WIFI
, wifi_enabled
);
1400 bios_set_state(BLUETOOTH
, bluetooth_enabled
);
1402 wistron_led_resume();
1409 static const struct dev_pm_ops wistron_pm_ops
= {
1410 .suspend
= wistron_suspend
,
1411 .resume
= wistron_resume
,
1412 .poweroff
= wistron_suspend
,
1413 .restore
= wistron_resume
,
1417 static struct platform_driver wistron_driver
= {
1419 .name
= "wistron-bios",
1420 .owner
= THIS_MODULE
,
1422 .pm
= &wistron_pm_ops
,
1425 .probe
= wistron_probe
,
1426 .remove
= __devexit_p(wistron_remove
),
1429 static int __init
wb_module_init(void)
1433 err
= select_keymap();
1441 err
= platform_driver_register(&wistron_driver
);
1443 goto err_unmap_bios
;
1445 wistron_device
= platform_device_alloc("wistron-bios", -1);
1446 if (!wistron_device
) {
1448 goto err_unregister_driver
;
1451 err
= platform_device_add(wistron_device
);
1453 goto err_free_device
;
1458 platform_device_put(wistron_device
);
1459 err_unregister_driver
:
1460 platform_driver_unregister(&wistron_driver
);
1467 static void __exit
wb_module_exit(void)
1469 platform_device_unregister(wistron_device
);
1470 platform_driver_unregister(&wistron_driver
);
1475 module_init(wb_module_init
);
1476 module_exit(wb_module_exit
);