wistron_btns.c 28 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171
  1. /*
  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>
  6. *
  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
  9. * Foundation.
  10. *
  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.
  15. *
  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.
  19. */
  20. #include <linux/io.h>
  21. #include <linux/dmi.h>
  22. #include <linux/init.h>
  23. #include <linux/input.h>
  24. #include <linux/interrupt.h>
  25. #include <linux/kernel.h>
  26. #include <linux/mc146818rtc.h>
  27. #include <linux/module.h>
  28. #include <linux/preempt.h>
  29. #include <linux/string.h>
  30. #include <linux/timer.h>
  31. #include <linux/types.h>
  32. #include <linux/platform_device.h>
  33. /*
  34. * Number of attempts to read data from queue per poll;
  35. * the queue can hold up to 31 entries
  36. */
  37. #define MAX_POLL_ITERATIONS 64
  38. #define POLL_FREQUENCY 10 /* Number of polls per second */
  39. #if POLL_FREQUENCY > HZ
  40. #error "POLL_FREQUENCY too high"
  41. #endif
  42. /* BIOS subsystem IDs */
  43. #define WIFI 0x35
  44. #define BLUETOOTH 0x34
  45. MODULE_AUTHOR("Miloslav Trmac <mitr@volny.cz>");
  46. MODULE_DESCRIPTION("Wistron laptop button driver");
  47. MODULE_LICENSE("GPL v2");
  48. MODULE_VERSION("0.1");
  49. static int force; /* = 0; */
  50. module_param(force, bool, 0);
  51. MODULE_PARM_DESC(force, "Load even if computer is not in database");
  52. static char *keymap_name; /* = NULL; */
  53. module_param_named(keymap, keymap_name, charp, 0);
  54. MODULE_PARM_DESC(keymap, "Keymap name, if it can't be autodetected");
  55. static struct platform_device *wistron_device;
  56. /* BIOS interface implementation */
  57. static void __iomem *bios_entry_point; /* BIOS routine entry point */
  58. static void __iomem *bios_code_map_base;
  59. static void __iomem *bios_data_map_base;
  60. static u8 cmos_address;
  61. struct regs {
  62. u32 eax, ebx, ecx;
  63. };
  64. static void call_bios(struct regs *regs)
  65. {
  66. unsigned long flags;
  67. preempt_disable();
  68. local_irq_save(flags);
  69. asm volatile ("pushl %%ebp;"
  70. "movl %7, %%ebp;"
  71. "call *%6;"
  72. "popl %%ebp"
  73. : "=a" (regs->eax), "=b" (regs->ebx), "=c" (regs->ecx)
  74. : "0" (regs->eax), "1" (regs->ebx), "2" (regs->ecx),
  75. "m" (bios_entry_point), "m" (bios_data_map_base)
  76. : "edx", "edi", "esi", "memory");
  77. local_irq_restore(flags);
  78. preempt_enable();
  79. }
  80. static ssize_t __init locate_wistron_bios(void __iomem *base)
  81. {
  82. static unsigned char __initdata signature[] =
  83. { 0x42, 0x21, 0x55, 0x30 };
  84. ssize_t offset;
  85. for (offset = 0; offset < 0x10000; offset += 0x10) {
  86. if (check_signature(base + offset, signature,
  87. sizeof(signature)) != 0)
  88. return offset;
  89. }
  90. return -1;
  91. }
  92. static int __init map_bios(void)
  93. {
  94. void __iomem *base;
  95. ssize_t offset;
  96. u32 entry_point;
  97. base = ioremap(0xF0000, 0x10000); /* Can't fail */
  98. offset = locate_wistron_bios(base);
  99. if (offset < 0) {
  100. printk(KERN_ERR "wistron_btns: BIOS entry point not found\n");
  101. iounmap(base);
  102. return -ENODEV;
  103. }
  104. entry_point = readl(base + offset + 5);
  105. printk(KERN_DEBUG
  106. "wistron_btns: BIOS signature found at %p, entry point %08X\n",
  107. base + offset, entry_point);
  108. if (entry_point >= 0xF0000) {
  109. bios_code_map_base = base;
  110. bios_entry_point = bios_code_map_base + (entry_point & 0xFFFF);
  111. } else {
  112. iounmap(base);
  113. bios_code_map_base = ioremap(entry_point & ~0x3FFF, 0x4000);
  114. if (bios_code_map_base == NULL) {
  115. printk(KERN_ERR
  116. "wistron_btns: Can't map BIOS code at %08X\n",
  117. entry_point & ~0x3FFF);
  118. goto err;
  119. }
  120. bios_entry_point = bios_code_map_base + (entry_point & 0x3FFF);
  121. }
  122. /* The Windows driver maps 0x10000 bytes, we keep only one page... */
  123. bios_data_map_base = ioremap(0x400, 0xc00);
  124. if (bios_data_map_base == NULL) {
  125. printk(KERN_ERR "wistron_btns: Can't map BIOS data\n");
  126. goto err_code;
  127. }
  128. return 0;
  129. err_code:
  130. iounmap(bios_code_map_base);
  131. err:
  132. return -ENOMEM;
  133. }
  134. static inline void unmap_bios(void)
  135. {
  136. iounmap(bios_code_map_base);
  137. iounmap(bios_data_map_base);
  138. }
  139. /* BIOS calls */
  140. static u16 bios_pop_queue(void)
  141. {
  142. struct regs regs;
  143. memset(&regs, 0, sizeof (regs));
  144. regs.eax = 0x9610;
  145. regs.ebx = 0x061C;
  146. regs.ecx = 0x0000;
  147. call_bios(&regs);
  148. return regs.eax;
  149. }
  150. static void __devinit bios_attach(void)
  151. {
  152. struct regs regs;
  153. memset(&regs, 0, sizeof (regs));
  154. regs.eax = 0x9610;
  155. regs.ebx = 0x012E;
  156. call_bios(&regs);
  157. }
  158. static void bios_detach(void)
  159. {
  160. struct regs regs;
  161. memset(&regs, 0, sizeof (regs));
  162. regs.eax = 0x9610;
  163. regs.ebx = 0x002E;
  164. call_bios(&regs);
  165. }
  166. static u8 __devinit bios_get_cmos_address(void)
  167. {
  168. struct regs regs;
  169. memset(&regs, 0, sizeof (regs));
  170. regs.eax = 0x9610;
  171. regs.ebx = 0x051C;
  172. call_bios(&regs);
  173. return regs.ecx;
  174. }
  175. static u16 __devinit bios_get_default_setting(u8 subsys)
  176. {
  177. struct regs regs;
  178. memset(&regs, 0, sizeof (regs));
  179. regs.eax = 0x9610;
  180. regs.ebx = 0x0200 | subsys;
  181. call_bios(&regs);
  182. return regs.eax;
  183. }
  184. static void bios_set_state(u8 subsys, int enable)
  185. {
  186. struct regs regs;
  187. memset(&regs, 0, sizeof (regs));
  188. regs.eax = 0x9610;
  189. regs.ebx = (enable ? 0x0100 : 0x0000) | subsys;
  190. call_bios(&regs);
  191. }
  192. /* Hardware database */
  193. struct key_entry {
  194. char type; /* See KE_* below */
  195. u8 code;
  196. union {
  197. u16 keycode; /* For KE_KEY */
  198. struct { /* For KE_SW */
  199. u8 code;
  200. u8 value;
  201. } sw;
  202. };
  203. };
  204. enum { KE_END, KE_KEY, KE_SW, KE_WIFI, KE_BLUETOOTH };
  205. #define FE_MAIL_LED 0x01
  206. #define FE_WIFI_LED 0x02
  207. #define FE_UNTESTED 0x80
  208. static const struct key_entry *keymap; /* = NULL; Current key map */
  209. static int have_wifi;
  210. static int have_bluetooth;
  211. static int __init dmi_matched(struct dmi_system_id *dmi)
  212. {
  213. const struct key_entry *key;
  214. keymap = dmi->driver_data;
  215. for (key = keymap; key->type != KE_END; key++) {
  216. if (key->type == KE_WIFI)
  217. have_wifi = 1;
  218. else if (key->type == KE_BLUETOOTH)
  219. have_bluetooth = 1;
  220. }
  221. return 1;
  222. }
  223. static struct key_entry keymap_empty[] = {
  224. { KE_END, 0 }
  225. };
  226. static struct key_entry keymap_fs_amilo_pro_v2000[] = {
  227. { KE_KEY, 0x01, {KEY_HELP} },
  228. { KE_KEY, 0x11, {KEY_PROG1} },
  229. { KE_KEY, 0x12, {KEY_PROG2} },
  230. { KE_WIFI, 0x30 },
  231. { KE_KEY, 0x31, {KEY_MAIL} },
  232. { KE_KEY, 0x36, {KEY_WWW} },
  233. { KE_END, 0 }
  234. };
  235. static struct key_entry keymap_fujitsu_n3510[] = {
  236. { KE_KEY, 0x11, {KEY_PROG1} },
  237. { KE_KEY, 0x12, {KEY_PROG2} },
  238. { KE_KEY, 0x36, {KEY_WWW} },
  239. { KE_KEY, 0x31, {KEY_MAIL} },
  240. { KE_KEY, 0x71, {KEY_STOPCD} },
  241. { KE_KEY, 0x72, {KEY_PLAYPAUSE} },
  242. { KE_KEY, 0x74, {KEY_REWIND} },
  243. { KE_KEY, 0x78, {KEY_FORWARD} },
  244. { KE_END, 0 }
  245. };
  246. static struct key_entry keymap_wistron_ms2111[] = {
  247. { KE_KEY, 0x11, {KEY_PROG1} },
  248. { KE_KEY, 0x12, {KEY_PROG2} },
  249. { KE_KEY, 0x13, {KEY_PROG3} },
  250. { KE_KEY, 0x31, {KEY_MAIL} },
  251. { KE_KEY, 0x36, {KEY_WWW} },
  252. { KE_END, FE_MAIL_LED }
  253. };
  254. static struct key_entry keymap_wistron_md40100[] = {
  255. { KE_KEY, 0x01, {KEY_HELP} },
  256. { KE_KEY, 0x02, {KEY_CONFIG} },
  257. { KE_KEY, 0x31, {KEY_MAIL} },
  258. { KE_KEY, 0x36, {KEY_WWW} },
  259. { KE_KEY, 0x37, {KEY_DISPLAYTOGGLE} }, /* Display on/off */
  260. { KE_END, FE_MAIL_LED | FE_WIFI_LED | FE_UNTESTED }
  261. };
  262. static struct key_entry keymap_wistron_ms2141[] = {
  263. { KE_KEY, 0x11, {KEY_PROG1} },
  264. { KE_KEY, 0x12, {KEY_PROG2} },
  265. { KE_WIFI, 0x30 },
  266. { KE_KEY, 0x22, {KEY_REWIND} },
  267. { KE_KEY, 0x23, {KEY_FORWARD} },
  268. { KE_KEY, 0x24, {KEY_PLAYPAUSE} },
  269. { KE_KEY, 0x25, {KEY_STOPCD} },
  270. { KE_KEY, 0x31, {KEY_MAIL} },
  271. { KE_KEY, 0x36, {KEY_WWW} },
  272. { KE_END, 0 }
  273. };
  274. static struct key_entry keymap_acer_aspire_1500[] = {
  275. { KE_KEY, 0x01, {KEY_HELP} },
  276. { KE_KEY, 0x03, {KEY_POWER} },
  277. { KE_KEY, 0x11, {KEY_PROG1} },
  278. { KE_KEY, 0x12, {KEY_PROG2} },
  279. { KE_WIFI, 0x30 },
  280. { KE_KEY, 0x31, {KEY_MAIL} },
  281. { KE_KEY, 0x36, {KEY_WWW} },
  282. { KE_KEY, 0x49, {KEY_CONFIG} },
  283. { KE_BLUETOOTH, 0x44 },
  284. { KE_END, FE_UNTESTED }
  285. };
  286. static struct key_entry keymap_acer_aspire_1600[] = {
  287. { KE_KEY, 0x01, {KEY_HELP} },
  288. { KE_KEY, 0x03, {KEY_POWER} },
  289. { KE_KEY, 0x08, {KEY_MUTE} },
  290. { KE_KEY, 0x11, {KEY_PROG1} },
  291. { KE_KEY, 0x12, {KEY_PROG2} },
  292. { KE_KEY, 0x13, {KEY_PROG3} },
  293. { KE_KEY, 0x31, {KEY_MAIL} },
  294. { KE_KEY, 0x36, {KEY_WWW} },
  295. { KE_KEY, 0x49, {KEY_CONFIG} },
  296. { KE_WIFI, 0x30 },
  297. { KE_BLUETOOTH, 0x44 },
  298. { KE_END, FE_MAIL_LED | FE_UNTESTED }
  299. };
  300. /* 3020 has been tested */
  301. static struct key_entry keymap_acer_aspire_5020[] = {
  302. { KE_KEY, 0x01, {KEY_HELP} },
  303. { KE_KEY, 0x03, {KEY_POWER} },
  304. { KE_KEY, 0x05, {KEY_SWITCHVIDEOMODE} }, /* Display selection */
  305. { KE_KEY, 0x11, {KEY_PROG1} },
  306. { KE_KEY, 0x12, {KEY_PROG2} },
  307. { KE_KEY, 0x31, {KEY_MAIL} },
  308. { KE_KEY, 0x36, {KEY_WWW} },
  309. { KE_KEY, 0x6a, {KEY_CONFIG} },
  310. { KE_WIFI, 0x30 },
  311. { KE_BLUETOOTH, 0x44 },
  312. { KE_END, FE_MAIL_LED | FE_UNTESTED }
  313. };
  314. static struct key_entry keymap_acer_travelmate_2410[] = {
  315. { KE_KEY, 0x01, {KEY_HELP} },
  316. { KE_KEY, 0x6d, {KEY_POWER} },
  317. { KE_KEY, 0x11, {KEY_PROG1} },
  318. { KE_KEY, 0x12, {KEY_PROG2} },
  319. { KE_KEY, 0x31, {KEY_MAIL} },
  320. { KE_KEY, 0x36, {KEY_WWW} },
  321. { KE_KEY, 0x6a, {KEY_CONFIG} },
  322. { KE_WIFI, 0x30 },
  323. { KE_BLUETOOTH, 0x44 },
  324. { KE_END, FE_MAIL_LED | FE_UNTESTED }
  325. };
  326. static struct key_entry keymap_acer_travelmate_110[] = {
  327. { KE_KEY, 0x01, {KEY_HELP} },
  328. { KE_KEY, 0x02, {KEY_CONFIG} },
  329. { KE_KEY, 0x03, {KEY_POWER} },
  330. { KE_KEY, 0x08, {KEY_MUTE} },
  331. { KE_KEY, 0x11, {KEY_PROG1} },
  332. { KE_KEY, 0x12, {KEY_PROG2} },
  333. { KE_KEY, 0x20, {KEY_VOLUMEUP} },
  334. { KE_KEY, 0x21, {KEY_VOLUMEDOWN} },
  335. { KE_KEY, 0x31, {KEY_MAIL} },
  336. { KE_KEY, 0x36, {KEY_WWW} },
  337. { KE_SW, 0x4a, {.sw = {SW_LID, 1}} }, /* lid close */
  338. { KE_SW, 0x4b, {.sw = {SW_LID, 0}} }, /* lid open */
  339. { KE_WIFI, 0x30 },
  340. { KE_END, FE_MAIL_LED | FE_UNTESTED }
  341. };
  342. static struct key_entry keymap_acer_travelmate_300[] = {
  343. { KE_KEY, 0x01, {KEY_HELP} },
  344. { KE_KEY, 0x02, {KEY_CONFIG} },
  345. { KE_KEY, 0x03, {KEY_POWER} },
  346. { KE_KEY, 0x08, {KEY_MUTE} },
  347. { KE_KEY, 0x11, {KEY_PROG1} },
  348. { KE_KEY, 0x12, {KEY_PROG2} },
  349. { KE_KEY, 0x20, {KEY_VOLUMEUP} },
  350. { KE_KEY, 0x21, {KEY_VOLUMEDOWN} },
  351. { KE_KEY, 0x31, {KEY_MAIL} },
  352. { KE_KEY, 0x36, {KEY_WWW} },
  353. { KE_WIFI, 0x30 },
  354. { KE_BLUETOOTH, 0x44 },
  355. { KE_END, FE_MAIL_LED | FE_UNTESTED }
  356. };
  357. static struct key_entry keymap_acer_travelmate_380[] = {
  358. { KE_KEY, 0x01, {KEY_HELP} },
  359. { KE_KEY, 0x02, {KEY_CONFIG} },
  360. { KE_KEY, 0x03, {KEY_POWER} }, /* not 370 */
  361. { KE_KEY, 0x11, {KEY_PROG1} },
  362. { KE_KEY, 0x12, {KEY_PROG2} },
  363. { KE_KEY, 0x13, {KEY_PROG3} },
  364. { KE_KEY, 0x31, {KEY_MAIL} },
  365. { KE_KEY, 0x36, {KEY_WWW} },
  366. { KE_WIFI, 0x30 },
  367. { KE_END, FE_MAIL_LED | FE_UNTESTED }
  368. };
  369. /* unusual map */
  370. static struct key_entry keymap_acer_travelmate_220[] = {
  371. { KE_KEY, 0x01, {KEY_HELP} },
  372. { KE_KEY, 0x02, {KEY_CONFIG} },
  373. { KE_KEY, 0x11, {KEY_MAIL} },
  374. { KE_KEY, 0x12, {KEY_WWW} },
  375. { KE_KEY, 0x13, {KEY_PROG2} },
  376. { KE_KEY, 0x31, {KEY_PROG1} },
  377. { KE_END, FE_WIFI_LED | FE_UNTESTED }
  378. };
  379. static struct key_entry keymap_acer_travelmate_230[] = {
  380. { KE_KEY, 0x01, {KEY_HELP} },
  381. { KE_KEY, 0x02, {KEY_CONFIG} },
  382. { KE_KEY, 0x11, {KEY_PROG1} },
  383. { KE_KEY, 0x12, {KEY_PROG2} },
  384. { KE_KEY, 0x31, {KEY_MAIL} },
  385. { KE_KEY, 0x36, {KEY_WWW} },
  386. { KE_END, FE_WIFI_LED | FE_UNTESTED }
  387. };
  388. static struct key_entry keymap_acer_travelmate_240[] = {
  389. { KE_KEY, 0x01, {KEY_HELP} },
  390. { KE_KEY, 0x02, {KEY_CONFIG} },
  391. { KE_KEY, 0x03, {KEY_POWER} },
  392. { KE_KEY, 0x08, {KEY_MUTE} },
  393. { KE_KEY, 0x31, {KEY_MAIL} },
  394. { KE_KEY, 0x36, {KEY_WWW} },
  395. { KE_KEY, 0x11, {KEY_PROG1} },
  396. { KE_KEY, 0x12, {KEY_PROG2} },
  397. { KE_BLUETOOTH, 0x44 },
  398. { KE_WIFI, 0x30 },
  399. { KE_END, FE_UNTESTED }
  400. };
  401. static struct key_entry keymap_acer_travelmate_350[] = {
  402. { KE_KEY, 0x01, {KEY_HELP} },
  403. { KE_KEY, 0x02, {KEY_CONFIG} },
  404. { KE_KEY, 0x11, {KEY_PROG1} },
  405. { KE_KEY, 0x12, {KEY_PROG2} },
  406. { KE_KEY, 0x13, {KEY_MAIL} },
  407. { KE_KEY, 0x14, {KEY_PROG3} },
  408. { KE_KEY, 0x15, {KEY_WWW} },
  409. { KE_END, FE_MAIL_LED | FE_WIFI_LED | FE_UNTESTED }
  410. };
  411. static struct key_entry keymap_acer_travelmate_360[] = {
  412. { KE_KEY, 0x01, {KEY_HELP} },
  413. { KE_KEY, 0x02, {KEY_CONFIG} },
  414. { KE_KEY, 0x11, {KEY_PROG1} },
  415. { KE_KEY, 0x12, {KEY_PROG2} },
  416. { KE_KEY, 0x13, {KEY_MAIL} },
  417. { KE_KEY, 0x14, {KEY_PROG3} },
  418. { KE_KEY, 0x15, {KEY_WWW} },
  419. { KE_KEY, 0x40, {KEY_WLAN} },
  420. { KE_END, FE_WIFI_LED | FE_UNTESTED } /* no mail led */
  421. };
  422. /* Wifi subsystem only activates the led. Therefore we need to pass
  423. * wifi event as a normal key, then userspace can really change the wifi state.
  424. * TODO we need to export led state to userspace (wifi and mail) */
  425. static struct key_entry keymap_acer_travelmate_610[] = {
  426. { KE_KEY, 0x01, {KEY_HELP} },
  427. { KE_KEY, 0x02, {KEY_CONFIG} },
  428. { KE_KEY, 0x11, {KEY_PROG1} },
  429. { KE_KEY, 0x12, {KEY_PROG3} },
  430. { KE_KEY, 0x13, {KEY_PROG3} },
  431. { KE_KEY, 0x14, {KEY_MAIL} },
  432. { KE_KEY, 0x15, {KEY_WWW} },
  433. { KE_KEY, 0x40, {KEY_WLAN} },
  434. { KE_END, FE_MAIL_LED | FE_WIFI_LED }
  435. };
  436. static struct key_entry keymap_acer_travelmate_630[] = {
  437. { KE_KEY, 0x01, {KEY_HELP} },
  438. { KE_KEY, 0x02, {KEY_CONFIG} },
  439. { KE_KEY, 0x03, {KEY_POWER} },
  440. { KE_KEY, 0x08, {KEY_MUTE} }, /* not 620 */
  441. { KE_KEY, 0x11, {KEY_PROG1} },
  442. { KE_KEY, 0x12, {KEY_PROG2} },
  443. { KE_KEY, 0x13, {KEY_PROG3} },
  444. { KE_KEY, 0x20, {KEY_VOLUMEUP} },
  445. { KE_KEY, 0x21, {KEY_VOLUMEDOWN} },
  446. { KE_KEY, 0x31, {KEY_MAIL} },
  447. { KE_KEY, 0x36, {KEY_WWW} },
  448. { KE_WIFI, 0x30 },
  449. { KE_END, FE_MAIL_LED | FE_UNTESTED }
  450. };
  451. static struct key_entry keymap_aopen_1559as[] = {
  452. { KE_KEY, 0x01, {KEY_HELP} },
  453. { KE_KEY, 0x06, {KEY_PROG3} },
  454. { KE_KEY, 0x11, {KEY_PROG1} },
  455. { KE_KEY, 0x12, {KEY_PROG2} },
  456. { KE_WIFI, 0x30 },
  457. { KE_KEY, 0x31, {KEY_MAIL} },
  458. { KE_KEY, 0x36, {KEY_WWW} },
  459. { KE_END, 0 },
  460. };
  461. static struct key_entry keymap_fs_amilo_d88x0[] = {
  462. { KE_KEY, 0x01, {KEY_HELP} },
  463. { KE_KEY, 0x08, {KEY_MUTE} },
  464. { KE_KEY, 0x31, {KEY_MAIL} },
  465. { KE_KEY, 0x36, {KEY_WWW} },
  466. { KE_KEY, 0x11, {KEY_PROG1} },
  467. { KE_KEY, 0x12, {KEY_PROG2} },
  468. { KE_KEY, 0x13, {KEY_PROG3} },
  469. { KE_END, FE_MAIL_LED | FE_WIFI_LED | FE_UNTESTED }
  470. };
  471. static struct key_entry keymap_wistron_md2900[] = {
  472. { KE_KEY, 0x01, {KEY_HELP} },
  473. { KE_KEY, 0x02, {KEY_CONFIG} },
  474. { KE_KEY, 0x11, {KEY_PROG1} },
  475. { KE_KEY, 0x12, {KEY_PROG2} },
  476. { KE_KEY, 0x31, {KEY_MAIL} },
  477. { KE_KEY, 0x36, {KEY_WWW} },
  478. { KE_WIFI, 0x30 },
  479. { KE_END, FE_MAIL_LED | FE_UNTESTED }
  480. };
  481. static struct key_entry keymap_wistron_md96500[] = {
  482. { KE_KEY, 0x01, {KEY_HELP} },
  483. { KE_KEY, 0x02, {KEY_CONFIG} },
  484. { KE_KEY, 0x05, {KEY_SWITCHVIDEOMODE} }, /* Display selection */
  485. { KE_KEY, 0x06, {KEY_DISPLAYTOGGLE} }, /* Display on/off */
  486. { KE_KEY, 0x08, {KEY_MUTE} },
  487. { KE_KEY, 0x11, {KEY_PROG1} },
  488. { KE_KEY, 0x12, {KEY_PROG2} },
  489. { KE_KEY, 0x20, {KEY_VOLUMEUP} },
  490. { KE_KEY, 0x21, {KEY_VOLUMEDOWN} },
  491. { KE_KEY, 0x22, {KEY_REWIND} },
  492. { KE_KEY, 0x23, {KEY_FORWARD} },
  493. { KE_KEY, 0x24, {KEY_PLAYPAUSE} },
  494. { KE_KEY, 0x25, {KEY_STOPCD} },
  495. { KE_KEY, 0x31, {KEY_MAIL} },
  496. { KE_KEY, 0x36, {KEY_WWW} },
  497. { KE_WIFI, 0x30 },
  498. { KE_BLUETOOTH, 0x44 },
  499. { KE_END, FE_UNTESTED }
  500. };
  501. /*
  502. * If your machine is not here (which is currently rather likely), please send
  503. * a list of buttons and their key codes (reported when loading this module
  504. * with force=1) and the output of dmidecode to $MODULE_AUTHOR.
  505. */
  506. static struct dmi_system_id dmi_ids[] __initdata = {
  507. {
  508. .callback = dmi_matched,
  509. .ident = "Fujitsu-Siemens Amilo Pro V2000",
  510. .matches = {
  511. DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
  512. DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Pro V2000"),
  513. },
  514. .driver_data = keymap_fs_amilo_pro_v2000
  515. },
  516. {
  517. .callback = dmi_matched,
  518. .ident = "Fujitsu-Siemens Amilo M7400",
  519. .matches = {
  520. DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
  521. DMI_MATCH(DMI_PRODUCT_NAME, "AMILO M "),
  522. },
  523. .driver_data = keymap_fs_amilo_pro_v2000
  524. },
  525. {
  526. .callback = dmi_matched,
  527. .ident = "Fujitsu N3510",
  528. .matches = {
  529. DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
  530. DMI_MATCH(DMI_PRODUCT_NAME, "N3510"),
  531. },
  532. .driver_data = keymap_fujitsu_n3510
  533. },
  534. {
  535. .callback = dmi_matched,
  536. .ident = "Acer Aspire 1500",
  537. .matches = {
  538. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  539. DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 1500"),
  540. },
  541. .driver_data = keymap_acer_aspire_1500
  542. },
  543. {
  544. .callback = dmi_matched,
  545. .ident = "Acer Aspire 1600",
  546. .matches = {
  547. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  548. DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 1600"),
  549. },
  550. .driver_data = keymap_acer_aspire_1600
  551. },
  552. {
  553. .callback = dmi_matched,
  554. .ident = "Acer Aspire 3020",
  555. .matches = {
  556. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  557. DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 3020"),
  558. },
  559. .driver_data = keymap_acer_aspire_5020
  560. },
  561. {
  562. .callback = dmi_matched,
  563. .ident = "Acer Aspire 5020",
  564. .matches = {
  565. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  566. DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5020"),
  567. },
  568. .driver_data = keymap_acer_aspire_5020
  569. },
  570. {
  571. .callback = dmi_matched,
  572. .ident = "Acer TravelMate 2100",
  573. .matches = {
  574. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  575. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 2100"),
  576. },
  577. .driver_data = keymap_acer_aspire_5020
  578. },
  579. {
  580. .callback = dmi_matched,
  581. .ident = "Acer TravelMate 2410",
  582. .matches = {
  583. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  584. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 2410"),
  585. },
  586. .driver_data = keymap_acer_travelmate_2410
  587. },
  588. {
  589. .callback = dmi_matched,
  590. .ident = "Acer TravelMate C300",
  591. .matches = {
  592. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  593. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate C300"),
  594. },
  595. .driver_data = keymap_acer_travelmate_300
  596. },
  597. {
  598. .callback = dmi_matched,
  599. .ident = "Acer TravelMate C100",
  600. .matches = {
  601. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  602. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate C100"),
  603. },
  604. .driver_data = keymap_acer_travelmate_300
  605. },
  606. {
  607. .callback = dmi_matched,
  608. .ident = "Acer TravelMate C110",
  609. .matches = {
  610. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  611. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate C110"),
  612. },
  613. .driver_data = keymap_acer_travelmate_110
  614. },
  615. {
  616. .callback = dmi_matched,
  617. .ident = "Acer TravelMate 380",
  618. .matches = {
  619. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  620. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 380"),
  621. },
  622. .driver_data = keymap_acer_travelmate_380
  623. },
  624. {
  625. .callback = dmi_matched,
  626. .ident = "Acer TravelMate 370",
  627. .matches = {
  628. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  629. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 370"),
  630. },
  631. .driver_data = keymap_acer_travelmate_380 /* keyboard minus 1 key */
  632. },
  633. {
  634. .callback = dmi_matched,
  635. .ident = "Acer TravelMate 220",
  636. .matches = {
  637. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  638. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 220"),
  639. },
  640. .driver_data = keymap_acer_travelmate_220
  641. },
  642. {
  643. .callback = dmi_matched,
  644. .ident = "Acer TravelMate 260",
  645. .matches = {
  646. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  647. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 260"),
  648. },
  649. .driver_data = keymap_acer_travelmate_220
  650. },
  651. {
  652. .callback = dmi_matched,
  653. .ident = "Acer TravelMate 230",
  654. .matches = {
  655. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  656. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 230"),
  657. /* acerhk looks for "TravelMate F4..." ?! */
  658. },
  659. .driver_data = keymap_acer_travelmate_230
  660. },
  661. {
  662. .callback = dmi_matched,
  663. .ident = "Acer TravelMate 280",
  664. .matches = {
  665. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  666. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 280"),
  667. },
  668. .driver_data = keymap_acer_travelmate_230
  669. },
  670. {
  671. .callback = dmi_matched,
  672. .ident = "Acer TravelMate 240",
  673. .matches = {
  674. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  675. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 240"),
  676. },
  677. .driver_data = keymap_acer_travelmate_240
  678. },
  679. {
  680. .callback = dmi_matched,
  681. .ident = "Acer TravelMate 250",
  682. .matches = {
  683. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  684. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 250"),
  685. },
  686. .driver_data = keymap_acer_travelmate_240
  687. },
  688. {
  689. .callback = dmi_matched,
  690. .ident = "Acer TravelMate 2424NWXCi",
  691. .matches = {
  692. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  693. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 2420"),
  694. },
  695. .driver_data = keymap_acer_travelmate_240
  696. },
  697. {
  698. .callback = dmi_matched,
  699. .ident = "Acer TravelMate 350",
  700. .matches = {
  701. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  702. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 350"),
  703. },
  704. .driver_data = keymap_acer_travelmate_350
  705. },
  706. {
  707. .callback = dmi_matched,
  708. .ident = "Acer TravelMate 360",
  709. .matches = {
  710. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  711. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 360"),
  712. },
  713. .driver_data = keymap_acer_travelmate_360
  714. },
  715. {
  716. .callback = dmi_matched,
  717. .ident = "Acer TravelMate 610",
  718. .matches = {
  719. DMI_MATCH(DMI_SYS_VENDOR, "ACER"),
  720. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 610"),
  721. },
  722. .driver_data = keymap_acer_travelmate_610
  723. },
  724. {
  725. .callback = dmi_matched,
  726. .ident = "Acer TravelMate 620",
  727. .matches = {
  728. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  729. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 620"),
  730. },
  731. .driver_data = keymap_acer_travelmate_630
  732. },
  733. {
  734. .callback = dmi_matched,
  735. .ident = "Acer TravelMate 630",
  736. .matches = {
  737. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  738. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 630"),
  739. },
  740. .driver_data = keymap_acer_travelmate_630
  741. },
  742. {
  743. .callback = dmi_matched,
  744. .ident = "AOpen 1559AS",
  745. .matches = {
  746. DMI_MATCH(DMI_PRODUCT_NAME, "E2U"),
  747. DMI_MATCH(DMI_BOARD_NAME, "E2U"),
  748. },
  749. .driver_data = keymap_aopen_1559as
  750. },
  751. {
  752. .callback = dmi_matched,
  753. .ident = "Medion MD 9783",
  754. .matches = {
  755. DMI_MATCH(DMI_SYS_VENDOR, "MEDIONNB"),
  756. DMI_MATCH(DMI_PRODUCT_NAME, "MD 9783"),
  757. },
  758. .driver_data = keymap_wistron_ms2111
  759. },
  760. {
  761. .callback = dmi_matched,
  762. .ident = "Medion MD 40100",
  763. .matches = {
  764. DMI_MATCH(DMI_SYS_VENDOR, "MEDIONNB"),
  765. DMI_MATCH(DMI_PRODUCT_NAME, "WID2000"),
  766. },
  767. .driver_data = keymap_wistron_md40100
  768. },
  769. {
  770. .callback = dmi_matched,
  771. .ident = "Medion MD 2900",
  772. .matches = {
  773. DMI_MATCH(DMI_SYS_VENDOR, "MEDIONNB"),
  774. DMI_MATCH(DMI_PRODUCT_NAME, "WIM 2000"),
  775. },
  776. .driver_data = keymap_wistron_md2900
  777. },
  778. {
  779. .callback = dmi_matched,
  780. .ident = "Medion MD 96500",
  781. .matches = {
  782. DMI_MATCH(DMI_SYS_VENDOR, "MEDIONPC"),
  783. DMI_MATCH(DMI_PRODUCT_NAME, "WIM 2040"),
  784. },
  785. .driver_data = keymap_wistron_md96500
  786. },
  787. {
  788. .callback = dmi_matched,
  789. .ident = "Medion MD 95400",
  790. .matches = {
  791. DMI_MATCH(DMI_SYS_VENDOR, "MEDIONPC"),
  792. DMI_MATCH(DMI_PRODUCT_NAME, "WIM 2050"),
  793. },
  794. .driver_data = keymap_wistron_md96500
  795. },
  796. {
  797. .callback = dmi_matched,
  798. .ident = "Fujitsu Siemens Amilo D7820",
  799. .matches = {
  800. DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"), /* not sure */
  801. DMI_MATCH(DMI_PRODUCT_NAME, "Amilo D"),
  802. },
  803. .driver_data = keymap_fs_amilo_d88x0
  804. },
  805. {
  806. .callback = dmi_matched,
  807. .ident = "Fujitsu Siemens Amilo D88x0",
  808. .matches = {
  809. DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
  810. DMI_MATCH(DMI_PRODUCT_NAME, "AMILO D"),
  811. },
  812. .driver_data = keymap_fs_amilo_d88x0
  813. },
  814. { NULL, }
  815. };
  816. static int __init select_keymap(void)
  817. {
  818. if (keymap_name != NULL) {
  819. if (strcmp (keymap_name, "1557/MS2141") == 0)
  820. keymap = keymap_wistron_ms2141;
  821. else {
  822. printk(KERN_ERR "wistron_btns: Keymap unknown\n");
  823. return -EINVAL;
  824. }
  825. }
  826. dmi_check_system(dmi_ids);
  827. if (keymap == NULL) {
  828. if (!force) {
  829. printk(KERN_ERR "wistron_btns: System unknown\n");
  830. return -ENODEV;
  831. }
  832. keymap = keymap_empty;
  833. }
  834. return 0;
  835. }
  836. /* Input layer interface */
  837. static struct input_dev *input_dev;
  838. static int __devinit setup_input_dev(void)
  839. {
  840. const struct key_entry *key;
  841. int error;
  842. input_dev = input_allocate_device();
  843. if (!input_dev)
  844. return -ENOMEM;
  845. input_dev->name = "Wistron laptop buttons";
  846. input_dev->phys = "wistron/input0";
  847. input_dev->id.bustype = BUS_HOST;
  848. input_dev->cdev.dev = &wistron_device->dev;
  849. for (key = keymap; key->type != KE_END; key++) {
  850. switch (key->type) {
  851. case KE_KEY:
  852. set_bit(EV_KEY, input_dev->evbit);
  853. set_bit(key->keycode, input_dev->keybit);
  854. break;
  855. case KE_SW:
  856. set_bit(EV_SW, input_dev->evbit);
  857. set_bit(key->sw.code, input_dev->swbit);
  858. break;
  859. default:
  860. ;
  861. }
  862. }
  863. /* reads information flags on KE_END */
  864. if (key->code & FE_UNTESTED)
  865. printk(KERN_WARNING "Untested laptop multimedia keys, "
  866. "please report success or failure to eric.piel"
  867. "@tremplin-utc.net\n");
  868. error = input_register_device(input_dev);
  869. if (error) {
  870. input_free_device(input_dev);
  871. return error;
  872. }
  873. return 0;
  874. }
  875. static void report_key(unsigned keycode)
  876. {
  877. input_report_key(input_dev, keycode, 1);
  878. input_sync(input_dev);
  879. input_report_key(input_dev, keycode, 0);
  880. input_sync(input_dev);
  881. }
  882. static void report_switch(unsigned code, int value)
  883. {
  884. input_report_switch(input_dev, code, value);
  885. input_sync(input_dev);
  886. }
  887. /* Driver core */
  888. static int wifi_enabled;
  889. static int bluetooth_enabled;
  890. static void poll_bios(unsigned long);
  891. static struct timer_list poll_timer = TIMER_INITIALIZER(poll_bios, 0, 0);
  892. static void handle_key(u8 code)
  893. {
  894. const struct key_entry *key;
  895. for (key = keymap; key->type != KE_END; key++) {
  896. if (code == key->code) {
  897. switch (key->type) {
  898. case KE_KEY:
  899. report_key(key->keycode);
  900. break;
  901. case KE_SW:
  902. report_switch(key->sw.code, key->sw.value);
  903. break;
  904. case KE_WIFI:
  905. if (have_wifi) {
  906. wifi_enabled = !wifi_enabled;
  907. bios_set_state(WIFI, wifi_enabled);
  908. }
  909. break;
  910. case KE_BLUETOOTH:
  911. if (have_bluetooth) {
  912. bluetooth_enabled = !bluetooth_enabled;
  913. bios_set_state(BLUETOOTH, bluetooth_enabled);
  914. }
  915. break;
  916. case KE_END:
  917. break;
  918. default:
  919. BUG();
  920. }
  921. return;
  922. }
  923. }
  924. printk(KERN_NOTICE "wistron_btns: Unknown key code %02X\n", code);
  925. }
  926. static void poll_bios(unsigned long discard)
  927. {
  928. u8 qlen;
  929. u16 val;
  930. for (;;) {
  931. qlen = CMOS_READ(cmos_address);
  932. if (qlen == 0)
  933. break;
  934. val = bios_pop_queue();
  935. if (val != 0 && !discard)
  936. handle_key((u8)val);
  937. }
  938. mod_timer(&poll_timer, jiffies + HZ / POLL_FREQUENCY);
  939. }
  940. static int __devinit wistron_probe(struct platform_device *dev)
  941. {
  942. int err = setup_input_dev();
  943. if (err)
  944. return err;
  945. bios_attach();
  946. cmos_address = bios_get_cmos_address();
  947. if (have_wifi) {
  948. u16 wifi = bios_get_default_setting(WIFI);
  949. if (wifi & 1)
  950. wifi_enabled = (wifi & 2) ? 1 : 0;
  951. else
  952. have_wifi = 0;
  953. if (have_wifi)
  954. bios_set_state(WIFI, wifi_enabled);
  955. }
  956. if (have_bluetooth) {
  957. u16 bt = bios_get_default_setting(BLUETOOTH);
  958. if (bt & 1)
  959. bluetooth_enabled = (bt & 2) ? 1 : 0;
  960. else
  961. have_bluetooth = 0;
  962. if (have_bluetooth)
  963. bios_set_state(BLUETOOTH, bluetooth_enabled);
  964. }
  965. poll_bios(1); /* Flush stale event queue and arm timer */
  966. return 0;
  967. }
  968. static int __devexit wistron_remove(struct platform_device *dev)
  969. {
  970. del_timer_sync(&poll_timer);
  971. input_unregister_device(input_dev);
  972. bios_detach();
  973. return 0;
  974. }
  975. #ifdef CONFIG_PM
  976. static int wistron_suspend(struct platform_device *dev, pm_message_t state)
  977. {
  978. del_timer_sync(&poll_timer);
  979. if (have_wifi)
  980. bios_set_state(WIFI, 0);
  981. if (have_bluetooth)
  982. bios_set_state(BLUETOOTH, 0);
  983. return 0;
  984. }
  985. static int wistron_resume(struct platform_device *dev)
  986. {
  987. if (have_wifi)
  988. bios_set_state(WIFI, wifi_enabled);
  989. if (have_bluetooth)
  990. bios_set_state(BLUETOOTH, bluetooth_enabled);
  991. poll_bios(1);
  992. return 0;
  993. }
  994. #else
  995. #define wistron_suspend NULL
  996. #define wistron_resume NULL
  997. #endif
  998. static struct platform_driver wistron_driver = {
  999. .driver = {
  1000. .name = "wistron-bios",
  1001. .owner = THIS_MODULE,
  1002. },
  1003. .probe = wistron_probe,
  1004. .remove = __devexit_p(wistron_remove),
  1005. .suspend = wistron_suspend,
  1006. .resume = wistron_resume,
  1007. };
  1008. static int __init wb_module_init(void)
  1009. {
  1010. int err;
  1011. err = select_keymap();
  1012. if (err)
  1013. return err;
  1014. err = map_bios();
  1015. if (err)
  1016. return err;
  1017. err = platform_driver_register(&wistron_driver);
  1018. if (err)
  1019. goto err_unmap_bios;
  1020. wistron_device = platform_device_alloc("wistron-bios", -1);
  1021. if (!wistron_device) {
  1022. err = -ENOMEM;
  1023. goto err_unregister_driver;
  1024. }
  1025. err = platform_device_add(wistron_device);
  1026. if (err)
  1027. goto err_free_device;
  1028. return 0;
  1029. err_free_device:
  1030. platform_device_put(wistron_device);
  1031. err_unregister_driver:
  1032. platform_driver_unregister(&wistron_driver);
  1033. err_unmap_bios:
  1034. unmap_bios();
  1035. return err;
  1036. }
  1037. static void __exit wb_module_exit(void)
  1038. {
  1039. platform_device_unregister(wistron_device);
  1040. platform_driver_unregister(&wistron_driver);
  1041. unmap_bios();
  1042. }
  1043. module_init(wb_module_init);
  1044. module_exit(wb_module_exit);