wistron_btns.c 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405
  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-polldev.h>
  24. #include <linux/input/sparse-keymap.h>
  25. #include <linux/interrupt.h>
  26. #include <linux/jiffies.h>
  27. #include <linux/kernel.h>
  28. #include <linux/mc146818rtc.h>
  29. #include <linux/module.h>
  30. #include <linux/preempt.h>
  31. #include <linux/string.h>
  32. #include <linux/slab.h>
  33. #include <linux/types.h>
  34. #include <linux/platform_device.h>
  35. #include <linux/leds.h>
  36. /* How often we poll keys - msecs */
  37. #define POLL_INTERVAL_DEFAULT 500 /* when idle */
  38. #define POLL_INTERVAL_BURST 100 /* when a key was recently pressed */
  39. /* BIOS subsystem IDs */
  40. #define WIFI 0x35
  41. #define BLUETOOTH 0x34
  42. #define MAIL_LED 0x31
  43. MODULE_AUTHOR("Miloslav Trmac <mitr@volny.cz>");
  44. MODULE_DESCRIPTION("Wistron laptop button driver");
  45. MODULE_LICENSE("GPL v2");
  46. static bool force; /* = 0; */
  47. module_param(force, bool, 0);
  48. MODULE_PARM_DESC(force, "Load even if computer is not in database");
  49. static char *keymap_name; /* = NULL; */
  50. module_param_named(keymap, keymap_name, charp, 0);
  51. MODULE_PARM_DESC(keymap, "Keymap name, if it can't be autodetected [generic, 1557/MS2141]");
  52. static struct platform_device *wistron_device;
  53. /* BIOS interface implementation */
  54. static void __iomem *bios_entry_point; /* BIOS routine entry point */
  55. static void __iomem *bios_code_map_base;
  56. static void __iomem *bios_data_map_base;
  57. static u8 cmos_address;
  58. struct regs {
  59. u32 eax, ebx, ecx;
  60. };
  61. static void call_bios(struct regs *regs)
  62. {
  63. unsigned long flags;
  64. preempt_disable();
  65. local_irq_save(flags);
  66. asm volatile ("pushl %%ebp;"
  67. "movl %7, %%ebp;"
  68. "call *%6;"
  69. "popl %%ebp"
  70. : "=a" (regs->eax), "=b" (regs->ebx), "=c" (regs->ecx)
  71. : "0" (regs->eax), "1" (regs->ebx), "2" (regs->ecx),
  72. "m" (bios_entry_point), "m" (bios_data_map_base)
  73. : "edx", "edi", "esi", "memory");
  74. local_irq_restore(flags);
  75. preempt_enable();
  76. }
  77. static ssize_t __init locate_wistron_bios(void __iomem *base)
  78. {
  79. static unsigned char __initdata signature[] =
  80. { 0x42, 0x21, 0x55, 0x30 };
  81. ssize_t offset;
  82. for (offset = 0; offset < 0x10000; offset += 0x10) {
  83. if (check_signature(base + offset, signature,
  84. sizeof(signature)) != 0)
  85. return offset;
  86. }
  87. return -1;
  88. }
  89. static int __init map_bios(void)
  90. {
  91. void __iomem *base;
  92. ssize_t offset;
  93. u32 entry_point;
  94. base = ioremap(0xF0000, 0x10000); /* Can't fail */
  95. offset = locate_wistron_bios(base);
  96. if (offset < 0) {
  97. printk(KERN_ERR "wistron_btns: BIOS entry point not found\n");
  98. iounmap(base);
  99. return -ENODEV;
  100. }
  101. entry_point = readl(base + offset + 5);
  102. printk(KERN_DEBUG
  103. "wistron_btns: BIOS signature found at %p, entry point %08X\n",
  104. base + offset, entry_point);
  105. if (entry_point >= 0xF0000) {
  106. bios_code_map_base = base;
  107. bios_entry_point = bios_code_map_base + (entry_point & 0xFFFF);
  108. } else {
  109. iounmap(base);
  110. bios_code_map_base = ioremap(entry_point & ~0x3FFF, 0x4000);
  111. if (bios_code_map_base == NULL) {
  112. printk(KERN_ERR
  113. "wistron_btns: Can't map BIOS code at %08X\n",
  114. entry_point & ~0x3FFF);
  115. goto err;
  116. }
  117. bios_entry_point = bios_code_map_base + (entry_point & 0x3FFF);
  118. }
  119. /* The Windows driver maps 0x10000 bytes, we keep only one page... */
  120. bios_data_map_base = ioremap(0x400, 0xc00);
  121. if (bios_data_map_base == NULL) {
  122. printk(KERN_ERR "wistron_btns: Can't map BIOS data\n");
  123. goto err_code;
  124. }
  125. return 0;
  126. err_code:
  127. iounmap(bios_code_map_base);
  128. err:
  129. return -ENOMEM;
  130. }
  131. static inline void unmap_bios(void)
  132. {
  133. iounmap(bios_code_map_base);
  134. iounmap(bios_data_map_base);
  135. }
  136. /* BIOS calls */
  137. static u16 bios_pop_queue(void)
  138. {
  139. struct regs regs;
  140. memset(&regs, 0, sizeof (regs));
  141. regs.eax = 0x9610;
  142. regs.ebx = 0x061C;
  143. regs.ecx = 0x0000;
  144. call_bios(&regs);
  145. return regs.eax;
  146. }
  147. static void bios_attach(void)
  148. {
  149. struct regs regs;
  150. memset(&regs, 0, sizeof (regs));
  151. regs.eax = 0x9610;
  152. regs.ebx = 0x012E;
  153. call_bios(&regs);
  154. }
  155. static void bios_detach(void)
  156. {
  157. struct regs regs;
  158. memset(&regs, 0, sizeof (regs));
  159. regs.eax = 0x9610;
  160. regs.ebx = 0x002E;
  161. call_bios(&regs);
  162. }
  163. static u8 bios_get_cmos_address(void)
  164. {
  165. struct regs regs;
  166. memset(&regs, 0, sizeof (regs));
  167. regs.eax = 0x9610;
  168. regs.ebx = 0x051C;
  169. call_bios(&regs);
  170. return regs.ecx;
  171. }
  172. static u16 bios_get_default_setting(u8 subsys)
  173. {
  174. struct regs regs;
  175. memset(&regs, 0, sizeof (regs));
  176. regs.eax = 0x9610;
  177. regs.ebx = 0x0200 | subsys;
  178. call_bios(&regs);
  179. return regs.eax;
  180. }
  181. static void bios_set_state(u8 subsys, int enable)
  182. {
  183. struct regs regs;
  184. memset(&regs, 0, sizeof (regs));
  185. regs.eax = 0x9610;
  186. regs.ebx = (enable ? 0x0100 : 0x0000) | subsys;
  187. call_bios(&regs);
  188. }
  189. /* Hardware database */
  190. #define KE_WIFI (KE_LAST + 1)
  191. #define KE_BLUETOOTH (KE_LAST + 2)
  192. #define FE_MAIL_LED 0x01
  193. #define FE_WIFI_LED 0x02
  194. #define FE_UNTESTED 0x80
  195. static struct key_entry *keymap; /* = NULL; Current key map */
  196. static bool have_wifi;
  197. static bool have_bluetooth;
  198. static int leds_present; /* bitmask of leds present */
  199. static int __init dmi_matched(const struct dmi_system_id *dmi)
  200. {
  201. const struct key_entry *key;
  202. keymap = dmi->driver_data;
  203. for (key = keymap; key->type != KE_END; key++) {
  204. if (key->type == KE_WIFI)
  205. have_wifi = true;
  206. else if (key->type == KE_BLUETOOTH)
  207. have_bluetooth = true;
  208. }
  209. leds_present = key->code & (FE_MAIL_LED | FE_WIFI_LED);
  210. return 1;
  211. }
  212. static struct key_entry keymap_empty[] __initdata = {
  213. { KE_END, 0 }
  214. };
  215. static struct key_entry keymap_fs_amilo_pro_v2000[] __initdata = {
  216. { KE_KEY, 0x01, {KEY_HELP} },
  217. { KE_KEY, 0x11, {KEY_PROG1} },
  218. { KE_KEY, 0x12, {KEY_PROG2} },
  219. { KE_WIFI, 0x30 },
  220. { KE_KEY, 0x31, {KEY_MAIL} },
  221. { KE_KEY, 0x36, {KEY_WWW} },
  222. { KE_END, 0 }
  223. };
  224. static struct key_entry keymap_fs_amilo_pro_v3505[] __initdata = {
  225. { KE_KEY, 0x01, {KEY_HELP} }, /* Fn+F1 */
  226. { KE_KEY, 0x06, {KEY_DISPLAYTOGGLE} }, /* Fn+F4 */
  227. { KE_BLUETOOTH, 0x30 }, /* Fn+F10 */
  228. { KE_KEY, 0x31, {KEY_MAIL} }, /* mail button */
  229. { KE_KEY, 0x36, {KEY_WWW} }, /* www button */
  230. { KE_WIFI, 0x78 }, /* satellite dish button */
  231. { KE_END, 0 }
  232. };
  233. static struct key_entry keymap_fs_amilo_pro_v8210[] __initdata = {
  234. { KE_KEY, 0x01, {KEY_HELP} }, /* Fn+F1 */
  235. { KE_KEY, 0x06, {KEY_DISPLAYTOGGLE} }, /* Fn+F4 */
  236. { KE_BLUETOOTH, 0x30 }, /* Fn+F10 */
  237. { KE_KEY, 0x31, {KEY_MAIL} }, /* mail button */
  238. { KE_KEY, 0x36, {KEY_WWW} }, /* www button */
  239. { KE_WIFI, 0x78 }, /* satelite dish button */
  240. { KE_END, FE_WIFI_LED }
  241. };
  242. static struct key_entry keymap_fujitsu_n3510[] __initdata = {
  243. { KE_KEY, 0x11, {KEY_PROG1} },
  244. { KE_KEY, 0x12, {KEY_PROG2} },
  245. { KE_KEY, 0x36, {KEY_WWW} },
  246. { KE_KEY, 0x31, {KEY_MAIL} },
  247. { KE_KEY, 0x71, {KEY_STOPCD} },
  248. { KE_KEY, 0x72, {KEY_PLAYPAUSE} },
  249. { KE_KEY, 0x74, {KEY_REWIND} },
  250. { KE_KEY, 0x78, {KEY_FORWARD} },
  251. { KE_END, 0 }
  252. };
  253. static struct key_entry keymap_wistron_ms2111[] __initdata = {
  254. { KE_KEY, 0x11, {KEY_PROG1} },
  255. { KE_KEY, 0x12, {KEY_PROG2} },
  256. { KE_KEY, 0x13, {KEY_PROG3} },
  257. { KE_KEY, 0x31, {KEY_MAIL} },
  258. { KE_KEY, 0x36, {KEY_WWW} },
  259. { KE_END, FE_MAIL_LED }
  260. };
  261. static struct key_entry keymap_wistron_md40100[] __initdata = {
  262. { KE_KEY, 0x01, {KEY_HELP} },
  263. { KE_KEY, 0x02, {KEY_CONFIG} },
  264. { KE_KEY, 0x31, {KEY_MAIL} },
  265. { KE_KEY, 0x36, {KEY_WWW} },
  266. { KE_KEY, 0x37, {KEY_DISPLAYTOGGLE} }, /* Display on/off */
  267. { KE_END, FE_MAIL_LED | FE_WIFI_LED | FE_UNTESTED }
  268. };
  269. static struct key_entry keymap_wistron_ms2141[] __initdata = {
  270. { KE_KEY, 0x11, {KEY_PROG1} },
  271. { KE_KEY, 0x12, {KEY_PROG2} },
  272. { KE_WIFI, 0x30 },
  273. { KE_KEY, 0x22, {KEY_REWIND} },
  274. { KE_KEY, 0x23, {KEY_FORWARD} },
  275. { KE_KEY, 0x24, {KEY_PLAYPAUSE} },
  276. { KE_KEY, 0x25, {KEY_STOPCD} },
  277. { KE_KEY, 0x31, {KEY_MAIL} },
  278. { KE_KEY, 0x36, {KEY_WWW} },
  279. { KE_END, 0 }
  280. };
  281. static struct key_entry keymap_acer_aspire_1500[] __initdata = {
  282. { KE_KEY, 0x01, {KEY_HELP} },
  283. { KE_KEY, 0x03, {KEY_POWER} },
  284. { KE_KEY, 0x11, {KEY_PROG1} },
  285. { KE_KEY, 0x12, {KEY_PROG2} },
  286. { KE_WIFI, 0x30 },
  287. { KE_KEY, 0x31, {KEY_MAIL} },
  288. { KE_KEY, 0x36, {KEY_WWW} },
  289. { KE_KEY, 0x49, {KEY_CONFIG} },
  290. { KE_BLUETOOTH, 0x44 },
  291. { KE_END, FE_UNTESTED }
  292. };
  293. static struct key_entry keymap_acer_aspire_1600[] __initdata = {
  294. { KE_KEY, 0x01, {KEY_HELP} },
  295. { KE_KEY, 0x03, {KEY_POWER} },
  296. { KE_KEY, 0x08, {KEY_MUTE} },
  297. { KE_KEY, 0x11, {KEY_PROG1} },
  298. { KE_KEY, 0x12, {KEY_PROG2} },
  299. { KE_KEY, 0x13, {KEY_PROG3} },
  300. { KE_KEY, 0x31, {KEY_MAIL} },
  301. { KE_KEY, 0x36, {KEY_WWW} },
  302. { KE_KEY, 0x49, {KEY_CONFIG} },
  303. { KE_WIFI, 0x30 },
  304. { KE_BLUETOOTH, 0x44 },
  305. { KE_END, FE_MAIL_LED | FE_UNTESTED }
  306. };
  307. /* 3020 has been tested */
  308. static struct key_entry keymap_acer_aspire_5020[] __initdata = {
  309. { KE_KEY, 0x01, {KEY_HELP} },
  310. { KE_KEY, 0x03, {KEY_POWER} },
  311. { KE_KEY, 0x05, {KEY_SWITCHVIDEOMODE} }, /* Display selection */
  312. { KE_KEY, 0x11, {KEY_PROG1} },
  313. { KE_KEY, 0x12, {KEY_PROG2} },
  314. { KE_KEY, 0x31, {KEY_MAIL} },
  315. { KE_KEY, 0x36, {KEY_WWW} },
  316. { KE_KEY, 0x6a, {KEY_CONFIG} },
  317. { KE_WIFI, 0x30 },
  318. { KE_BLUETOOTH, 0x44 },
  319. { KE_END, FE_MAIL_LED | FE_UNTESTED }
  320. };
  321. static struct key_entry keymap_acer_travelmate_2410[] __initdata = {
  322. { KE_KEY, 0x01, {KEY_HELP} },
  323. { KE_KEY, 0x6d, {KEY_POWER} },
  324. { KE_KEY, 0x11, {KEY_PROG1} },
  325. { KE_KEY, 0x12, {KEY_PROG2} },
  326. { KE_KEY, 0x31, {KEY_MAIL} },
  327. { KE_KEY, 0x36, {KEY_WWW} },
  328. { KE_KEY, 0x6a, {KEY_CONFIG} },
  329. { KE_WIFI, 0x30 },
  330. { KE_BLUETOOTH, 0x44 },
  331. { KE_END, FE_MAIL_LED | FE_UNTESTED }
  332. };
  333. static struct key_entry keymap_acer_travelmate_110[] __initdata = {
  334. { KE_KEY, 0x01, {KEY_HELP} },
  335. { KE_KEY, 0x02, {KEY_CONFIG} },
  336. { KE_KEY, 0x03, {KEY_POWER} },
  337. { KE_KEY, 0x08, {KEY_MUTE} },
  338. { KE_KEY, 0x11, {KEY_PROG1} },
  339. { KE_KEY, 0x12, {KEY_PROG2} },
  340. { KE_KEY, 0x20, {KEY_VOLUMEUP} },
  341. { KE_KEY, 0x21, {KEY_VOLUMEDOWN} },
  342. { KE_KEY, 0x31, {KEY_MAIL} },
  343. { KE_KEY, 0x36, {KEY_WWW} },
  344. { KE_SW, 0x4a, {.sw = {SW_LID, 1}} }, /* lid close */
  345. { KE_SW, 0x4b, {.sw = {SW_LID, 0}} }, /* lid open */
  346. { KE_WIFI, 0x30 },
  347. { KE_END, FE_MAIL_LED | FE_UNTESTED }
  348. };
  349. static struct key_entry keymap_acer_travelmate_300[] __initdata = {
  350. { KE_KEY, 0x01, {KEY_HELP} },
  351. { KE_KEY, 0x02, {KEY_CONFIG} },
  352. { KE_KEY, 0x03, {KEY_POWER} },
  353. { KE_KEY, 0x08, {KEY_MUTE} },
  354. { KE_KEY, 0x11, {KEY_PROG1} },
  355. { KE_KEY, 0x12, {KEY_PROG2} },
  356. { KE_KEY, 0x20, {KEY_VOLUMEUP} },
  357. { KE_KEY, 0x21, {KEY_VOLUMEDOWN} },
  358. { KE_KEY, 0x31, {KEY_MAIL} },
  359. { KE_KEY, 0x36, {KEY_WWW} },
  360. { KE_WIFI, 0x30 },
  361. { KE_BLUETOOTH, 0x44 },
  362. { KE_END, FE_MAIL_LED | FE_UNTESTED }
  363. };
  364. static struct key_entry keymap_acer_travelmate_380[] __initdata = {
  365. { KE_KEY, 0x01, {KEY_HELP} },
  366. { KE_KEY, 0x02, {KEY_CONFIG} },
  367. { KE_KEY, 0x03, {KEY_POWER} }, /* not 370 */
  368. { KE_KEY, 0x11, {KEY_PROG1} },
  369. { KE_KEY, 0x12, {KEY_PROG2} },
  370. { KE_KEY, 0x13, {KEY_PROG3} },
  371. { KE_KEY, 0x31, {KEY_MAIL} },
  372. { KE_KEY, 0x36, {KEY_WWW} },
  373. { KE_WIFI, 0x30 },
  374. { KE_END, FE_MAIL_LED | FE_UNTESTED }
  375. };
  376. /* unusual map */
  377. static struct key_entry keymap_acer_travelmate_220[] __initdata = {
  378. { KE_KEY, 0x01, {KEY_HELP} },
  379. { KE_KEY, 0x02, {KEY_CONFIG} },
  380. { KE_KEY, 0x11, {KEY_MAIL} },
  381. { KE_KEY, 0x12, {KEY_WWW} },
  382. { KE_KEY, 0x13, {KEY_PROG2} },
  383. { KE_KEY, 0x31, {KEY_PROG1} },
  384. { KE_END, FE_WIFI_LED | FE_UNTESTED }
  385. };
  386. static struct key_entry keymap_acer_travelmate_230[] __initdata = {
  387. { KE_KEY, 0x01, {KEY_HELP} },
  388. { KE_KEY, 0x02, {KEY_CONFIG} },
  389. { KE_KEY, 0x11, {KEY_PROG1} },
  390. { KE_KEY, 0x12, {KEY_PROG2} },
  391. { KE_KEY, 0x31, {KEY_MAIL} },
  392. { KE_KEY, 0x36, {KEY_WWW} },
  393. { KE_END, FE_WIFI_LED | FE_UNTESTED }
  394. };
  395. static struct key_entry keymap_acer_travelmate_240[] __initdata = {
  396. { KE_KEY, 0x01, {KEY_HELP} },
  397. { KE_KEY, 0x02, {KEY_CONFIG} },
  398. { KE_KEY, 0x03, {KEY_POWER} },
  399. { KE_KEY, 0x08, {KEY_MUTE} },
  400. { KE_KEY, 0x31, {KEY_MAIL} },
  401. { KE_KEY, 0x36, {KEY_WWW} },
  402. { KE_KEY, 0x11, {KEY_PROG1} },
  403. { KE_KEY, 0x12, {KEY_PROG2} },
  404. { KE_BLUETOOTH, 0x44 },
  405. { KE_WIFI, 0x30 },
  406. { KE_END, FE_UNTESTED }
  407. };
  408. static struct key_entry keymap_acer_travelmate_350[] __initdata = {
  409. { KE_KEY, 0x01, {KEY_HELP} },
  410. { KE_KEY, 0x02, {KEY_CONFIG} },
  411. { KE_KEY, 0x11, {KEY_PROG1} },
  412. { KE_KEY, 0x12, {KEY_PROG2} },
  413. { KE_KEY, 0x13, {KEY_MAIL} },
  414. { KE_KEY, 0x14, {KEY_PROG3} },
  415. { KE_KEY, 0x15, {KEY_WWW} },
  416. { KE_END, FE_MAIL_LED | FE_WIFI_LED | FE_UNTESTED }
  417. };
  418. static struct key_entry keymap_acer_travelmate_360[] __initdata = {
  419. { KE_KEY, 0x01, {KEY_HELP} },
  420. { KE_KEY, 0x02, {KEY_CONFIG} },
  421. { KE_KEY, 0x11, {KEY_PROG1} },
  422. { KE_KEY, 0x12, {KEY_PROG2} },
  423. { KE_KEY, 0x13, {KEY_MAIL} },
  424. { KE_KEY, 0x14, {KEY_PROG3} },
  425. { KE_KEY, 0x15, {KEY_WWW} },
  426. { KE_KEY, 0x40, {KEY_WLAN} },
  427. { KE_END, FE_WIFI_LED | FE_UNTESTED } /* no mail led */
  428. };
  429. /* Wifi subsystem only activates the led. Therefore we need to pass
  430. * wifi event as a normal key, then userspace can really change the wifi state.
  431. * TODO we need to export led state to userspace (wifi and mail) */
  432. static struct key_entry keymap_acer_travelmate_610[] __initdata = {
  433. { KE_KEY, 0x01, {KEY_HELP} },
  434. { KE_KEY, 0x02, {KEY_CONFIG} },
  435. { KE_KEY, 0x11, {KEY_PROG1} },
  436. { KE_KEY, 0x12, {KEY_PROG2} },
  437. { KE_KEY, 0x13, {KEY_PROG3} },
  438. { KE_KEY, 0x14, {KEY_MAIL} },
  439. { KE_KEY, 0x15, {KEY_WWW} },
  440. { KE_KEY, 0x40, {KEY_WLAN} },
  441. { KE_END, FE_MAIL_LED | FE_WIFI_LED }
  442. };
  443. static struct key_entry keymap_acer_travelmate_630[] __initdata = {
  444. { KE_KEY, 0x01, {KEY_HELP} },
  445. { KE_KEY, 0x02, {KEY_CONFIG} },
  446. { KE_KEY, 0x03, {KEY_POWER} },
  447. { KE_KEY, 0x08, {KEY_MUTE} }, /* not 620 */
  448. { KE_KEY, 0x11, {KEY_PROG1} },
  449. { KE_KEY, 0x12, {KEY_PROG2} },
  450. { KE_KEY, 0x13, {KEY_PROG3} },
  451. { KE_KEY, 0x20, {KEY_VOLUMEUP} },
  452. { KE_KEY, 0x21, {KEY_VOLUMEDOWN} },
  453. { KE_KEY, 0x31, {KEY_MAIL} },
  454. { KE_KEY, 0x36, {KEY_WWW} },
  455. { KE_WIFI, 0x30 },
  456. { KE_END, FE_MAIL_LED | FE_UNTESTED }
  457. };
  458. static struct key_entry keymap_aopen_1559as[] __initdata = {
  459. { KE_KEY, 0x01, {KEY_HELP} },
  460. { KE_KEY, 0x06, {KEY_PROG3} },
  461. { KE_KEY, 0x11, {KEY_PROG1} },
  462. { KE_KEY, 0x12, {KEY_PROG2} },
  463. { KE_WIFI, 0x30 },
  464. { KE_KEY, 0x31, {KEY_MAIL} },
  465. { KE_KEY, 0x36, {KEY_WWW} },
  466. { KE_END, 0 },
  467. };
  468. static struct key_entry keymap_fs_amilo_d88x0[] __initdata = {
  469. { KE_KEY, 0x01, {KEY_HELP} },
  470. { KE_KEY, 0x08, {KEY_MUTE} },
  471. { KE_KEY, 0x31, {KEY_MAIL} },
  472. { KE_KEY, 0x36, {KEY_WWW} },
  473. { KE_KEY, 0x11, {KEY_PROG1} },
  474. { KE_KEY, 0x12, {KEY_PROG2} },
  475. { KE_KEY, 0x13, {KEY_PROG3} },
  476. { KE_END, FE_MAIL_LED | FE_WIFI_LED | FE_UNTESTED }
  477. };
  478. static struct key_entry keymap_wistron_md2900[] __initdata = {
  479. { KE_KEY, 0x01, {KEY_HELP} },
  480. { KE_KEY, 0x02, {KEY_CONFIG} },
  481. { KE_KEY, 0x11, {KEY_PROG1} },
  482. { KE_KEY, 0x12, {KEY_PROG2} },
  483. { KE_KEY, 0x31, {KEY_MAIL} },
  484. { KE_KEY, 0x36, {KEY_WWW} },
  485. { KE_WIFI, 0x30 },
  486. { KE_END, FE_MAIL_LED | FE_UNTESTED }
  487. };
  488. static struct key_entry keymap_wistron_md96500[] __initdata = {
  489. { KE_KEY, 0x01, {KEY_HELP} },
  490. { KE_KEY, 0x02, {KEY_CONFIG} },
  491. { KE_KEY, 0x05, {KEY_SWITCHVIDEOMODE} }, /* Display selection */
  492. { KE_KEY, 0x06, {KEY_DISPLAYTOGGLE} }, /* Display on/off */
  493. { KE_KEY, 0x08, {KEY_MUTE} },
  494. { KE_KEY, 0x11, {KEY_PROG1} },
  495. { KE_KEY, 0x12, {KEY_PROG2} },
  496. { KE_KEY, 0x20, {KEY_VOLUMEUP} },
  497. { KE_KEY, 0x21, {KEY_VOLUMEDOWN} },
  498. { KE_KEY, 0x22, {KEY_REWIND} },
  499. { KE_KEY, 0x23, {KEY_FORWARD} },
  500. { KE_KEY, 0x24, {KEY_PLAYPAUSE} },
  501. { KE_KEY, 0x25, {KEY_STOPCD} },
  502. { KE_KEY, 0x31, {KEY_MAIL} },
  503. { KE_KEY, 0x36, {KEY_WWW} },
  504. { KE_WIFI, 0x30 },
  505. { KE_BLUETOOTH, 0x44 },
  506. { KE_END, 0 }
  507. };
  508. static struct key_entry keymap_wistron_generic[] __initdata = {
  509. { KE_KEY, 0x01, {KEY_HELP} },
  510. { KE_KEY, 0x02, {KEY_CONFIG} },
  511. { KE_KEY, 0x03, {KEY_POWER} },
  512. { KE_KEY, 0x05, {KEY_SWITCHVIDEOMODE} }, /* Display selection */
  513. { KE_KEY, 0x06, {KEY_DISPLAYTOGGLE} }, /* Display on/off */
  514. { KE_KEY, 0x08, {KEY_MUTE} },
  515. { KE_KEY, 0x11, {KEY_PROG1} },
  516. { KE_KEY, 0x12, {KEY_PROG2} },
  517. { KE_KEY, 0x13, {KEY_PROG3} },
  518. { KE_KEY, 0x14, {KEY_MAIL} },
  519. { KE_KEY, 0x15, {KEY_WWW} },
  520. { KE_KEY, 0x20, {KEY_VOLUMEUP} },
  521. { KE_KEY, 0x21, {KEY_VOLUMEDOWN} },
  522. { KE_KEY, 0x22, {KEY_REWIND} },
  523. { KE_KEY, 0x23, {KEY_FORWARD} },
  524. { KE_KEY, 0x24, {KEY_PLAYPAUSE} },
  525. { KE_KEY, 0x25, {KEY_STOPCD} },
  526. { KE_KEY, 0x31, {KEY_MAIL} },
  527. { KE_KEY, 0x36, {KEY_WWW} },
  528. { KE_KEY, 0x37, {KEY_DISPLAYTOGGLE} }, /* Display on/off */
  529. { KE_KEY, 0x40, {KEY_WLAN} },
  530. { KE_KEY, 0x49, {KEY_CONFIG} },
  531. { KE_SW, 0x4a, {.sw = {SW_LID, 1}} }, /* lid close */
  532. { KE_SW, 0x4b, {.sw = {SW_LID, 0}} }, /* lid open */
  533. { KE_KEY, 0x6a, {KEY_CONFIG} },
  534. { KE_KEY, 0x6d, {KEY_POWER} },
  535. { KE_KEY, 0x71, {KEY_STOPCD} },
  536. { KE_KEY, 0x72, {KEY_PLAYPAUSE} },
  537. { KE_KEY, 0x74, {KEY_REWIND} },
  538. { KE_KEY, 0x78, {KEY_FORWARD} },
  539. { KE_WIFI, 0x30 },
  540. { KE_BLUETOOTH, 0x44 },
  541. { KE_END, 0 }
  542. };
  543. static struct key_entry keymap_aopen_1557[] __initdata = {
  544. { KE_KEY, 0x01, {KEY_HELP} },
  545. { KE_KEY, 0x11, {KEY_PROG1} },
  546. { KE_KEY, 0x12, {KEY_PROG2} },
  547. { KE_WIFI, 0x30 },
  548. { KE_KEY, 0x22, {KEY_REWIND} },
  549. { KE_KEY, 0x23, {KEY_FORWARD} },
  550. { KE_KEY, 0x24, {KEY_PLAYPAUSE} },
  551. { KE_KEY, 0x25, {KEY_STOPCD} },
  552. { KE_KEY, 0x31, {KEY_MAIL} },
  553. { KE_KEY, 0x36, {KEY_WWW} },
  554. { KE_END, 0 }
  555. };
  556. static struct key_entry keymap_prestigio[] __initdata = {
  557. { KE_KEY, 0x11, {KEY_PROG1} },
  558. { KE_KEY, 0x12, {KEY_PROG2} },
  559. { KE_WIFI, 0x30 },
  560. { KE_KEY, 0x22, {KEY_REWIND} },
  561. { KE_KEY, 0x23, {KEY_FORWARD} },
  562. { KE_KEY, 0x24, {KEY_PLAYPAUSE} },
  563. { KE_KEY, 0x25, {KEY_STOPCD} },
  564. { KE_KEY, 0x31, {KEY_MAIL} },
  565. { KE_KEY, 0x36, {KEY_WWW} },
  566. { KE_END, 0 }
  567. };
  568. /*
  569. * If your machine is not here (which is currently rather likely), please send
  570. * a list of buttons and their key codes (reported when loading this module
  571. * with force=1) and the output of dmidecode to $MODULE_AUTHOR.
  572. */
  573. static const struct dmi_system_id dmi_ids[] __initconst = {
  574. {
  575. /* Fujitsu-Siemens Amilo Pro V2000 */
  576. .callback = dmi_matched,
  577. .matches = {
  578. DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
  579. DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Pro V2000"),
  580. },
  581. .driver_data = keymap_fs_amilo_pro_v2000
  582. },
  583. {
  584. /* Fujitsu-Siemens Amilo Pro Edition V3505 */
  585. .callback = dmi_matched,
  586. .matches = {
  587. DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
  588. DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Pro Edition V3505"),
  589. },
  590. .driver_data = keymap_fs_amilo_pro_v3505
  591. },
  592. {
  593. /* Fujitsu-Siemens Amilo Pro Edition V8210 */
  594. .callback = dmi_matched,
  595. .matches = {
  596. DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
  597. DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Pro Series V8210"),
  598. },
  599. .driver_data = keymap_fs_amilo_pro_v8210
  600. },
  601. {
  602. /* Fujitsu-Siemens Amilo M7400 */
  603. .callback = dmi_matched,
  604. .matches = {
  605. DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
  606. DMI_MATCH(DMI_PRODUCT_NAME, "AMILO M "),
  607. },
  608. .driver_data = keymap_fs_amilo_pro_v2000
  609. },
  610. {
  611. /* Maxdata Pro 7000 DX */
  612. .callback = dmi_matched,
  613. .matches = {
  614. DMI_MATCH(DMI_SYS_VENDOR, "MAXDATA"),
  615. DMI_MATCH(DMI_PRODUCT_NAME, "Pro 7000"),
  616. },
  617. .driver_data = keymap_fs_amilo_pro_v2000
  618. },
  619. {
  620. /* Fujitsu N3510 */
  621. .callback = dmi_matched,
  622. .matches = {
  623. DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
  624. DMI_MATCH(DMI_PRODUCT_NAME, "N3510"),
  625. },
  626. .driver_data = keymap_fujitsu_n3510
  627. },
  628. {
  629. /* Acer Aspire 1500 */
  630. .callback = dmi_matched,
  631. .matches = {
  632. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  633. DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 1500"),
  634. },
  635. .driver_data = keymap_acer_aspire_1500
  636. },
  637. {
  638. /* Acer Aspire 1600 */
  639. .callback = dmi_matched,
  640. .matches = {
  641. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  642. DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 1600"),
  643. },
  644. .driver_data = keymap_acer_aspire_1600
  645. },
  646. {
  647. /* Acer Aspire 3020 */
  648. .callback = dmi_matched,
  649. .matches = {
  650. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  651. DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 3020"),
  652. },
  653. .driver_data = keymap_acer_aspire_5020
  654. },
  655. {
  656. /* Acer Aspire 5020 */
  657. .callback = dmi_matched,
  658. .matches = {
  659. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  660. DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5020"),
  661. },
  662. .driver_data = keymap_acer_aspire_5020
  663. },
  664. {
  665. /* Acer TravelMate 2100 */
  666. .callback = dmi_matched,
  667. .matches = {
  668. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  669. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 2100"),
  670. },
  671. .driver_data = keymap_acer_aspire_5020
  672. },
  673. {
  674. /* Acer TravelMate 2410 */
  675. .callback = dmi_matched,
  676. .matches = {
  677. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  678. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 2410"),
  679. },
  680. .driver_data = keymap_acer_travelmate_2410
  681. },
  682. {
  683. /* Acer TravelMate C300 */
  684. .callback = dmi_matched,
  685. .matches = {
  686. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  687. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate C300"),
  688. },
  689. .driver_data = keymap_acer_travelmate_300
  690. },
  691. {
  692. /* Acer TravelMate C100 */
  693. .callback = dmi_matched,
  694. .matches = {
  695. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  696. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate C100"),
  697. },
  698. .driver_data = keymap_acer_travelmate_300
  699. },
  700. {
  701. /* Acer TravelMate C110 */
  702. .callback = dmi_matched,
  703. .matches = {
  704. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  705. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate C110"),
  706. },
  707. .driver_data = keymap_acer_travelmate_110
  708. },
  709. {
  710. /* Acer TravelMate 380 */
  711. .callback = dmi_matched,
  712. .matches = {
  713. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  714. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 380"),
  715. },
  716. .driver_data = keymap_acer_travelmate_380
  717. },
  718. {
  719. /* Acer TravelMate 370 */
  720. .callback = dmi_matched,
  721. .matches = {
  722. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  723. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 370"),
  724. },
  725. .driver_data = keymap_acer_travelmate_380 /* keyboard minus 1 key */
  726. },
  727. {
  728. /* Acer TravelMate 220 */
  729. .callback = dmi_matched,
  730. .matches = {
  731. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  732. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 220"),
  733. },
  734. .driver_data = keymap_acer_travelmate_220
  735. },
  736. {
  737. /* Acer TravelMate 260 */
  738. .callback = dmi_matched,
  739. .matches = {
  740. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  741. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 260"),
  742. },
  743. .driver_data = keymap_acer_travelmate_220
  744. },
  745. {
  746. /* Acer TravelMate 230 */
  747. .callback = dmi_matched,
  748. .matches = {
  749. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  750. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 230"),
  751. /* acerhk looks for "TravelMate F4..." ?! */
  752. },
  753. .driver_data = keymap_acer_travelmate_230
  754. },
  755. {
  756. /* Acer TravelMate 280 */
  757. .callback = dmi_matched,
  758. .matches = {
  759. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  760. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 280"),
  761. },
  762. .driver_data = keymap_acer_travelmate_230
  763. },
  764. {
  765. /* Acer TravelMate 240 */
  766. .callback = dmi_matched,
  767. .matches = {
  768. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  769. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 240"),
  770. },
  771. .driver_data = keymap_acer_travelmate_240
  772. },
  773. {
  774. /* Acer TravelMate 250 */
  775. .callback = dmi_matched,
  776. .matches = {
  777. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  778. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 250"),
  779. },
  780. .driver_data = keymap_acer_travelmate_240
  781. },
  782. {
  783. /* Acer TravelMate 2424NWXCi */
  784. .callback = dmi_matched,
  785. .matches = {
  786. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  787. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 2420"),
  788. },
  789. .driver_data = keymap_acer_travelmate_240
  790. },
  791. {
  792. /* Acer TravelMate 350 */
  793. .callback = dmi_matched,
  794. .matches = {
  795. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  796. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 350"),
  797. },
  798. .driver_data = keymap_acer_travelmate_350
  799. },
  800. {
  801. /* Acer TravelMate 360 */
  802. .callback = dmi_matched,
  803. .matches = {
  804. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  805. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 360"),
  806. },
  807. .driver_data = keymap_acer_travelmate_360
  808. },
  809. {
  810. /* Acer TravelMate 610 */
  811. .callback = dmi_matched,
  812. .matches = {
  813. DMI_MATCH(DMI_SYS_VENDOR, "ACER"),
  814. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 610"),
  815. },
  816. .driver_data = keymap_acer_travelmate_610
  817. },
  818. {
  819. /* Acer TravelMate 620 */
  820. .callback = dmi_matched,
  821. .matches = {
  822. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  823. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 620"),
  824. },
  825. .driver_data = keymap_acer_travelmate_630
  826. },
  827. {
  828. /* Acer TravelMate 630 */
  829. .callback = dmi_matched,
  830. .matches = {
  831. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  832. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 630"),
  833. },
  834. .driver_data = keymap_acer_travelmate_630
  835. },
  836. {
  837. /* AOpen 1559AS */
  838. .callback = dmi_matched,
  839. .matches = {
  840. DMI_MATCH(DMI_PRODUCT_NAME, "E2U"),
  841. DMI_MATCH(DMI_BOARD_NAME, "E2U"),
  842. },
  843. .driver_data = keymap_aopen_1559as
  844. },
  845. {
  846. /* Medion MD 9783 */
  847. .callback = dmi_matched,
  848. .matches = {
  849. DMI_MATCH(DMI_SYS_VENDOR, "MEDIONNB"),
  850. DMI_MATCH(DMI_PRODUCT_NAME, "MD 9783"),
  851. },
  852. .driver_data = keymap_wistron_ms2111
  853. },
  854. {
  855. /* Medion MD 40100 */
  856. .callback = dmi_matched,
  857. .matches = {
  858. DMI_MATCH(DMI_SYS_VENDOR, "MEDIONNB"),
  859. DMI_MATCH(DMI_PRODUCT_NAME, "WID2000"),
  860. },
  861. .driver_data = keymap_wistron_md40100
  862. },
  863. {
  864. /* Medion MD 2900 */
  865. .callback = dmi_matched,
  866. .matches = {
  867. DMI_MATCH(DMI_SYS_VENDOR, "MEDIONNB"),
  868. DMI_MATCH(DMI_PRODUCT_NAME, "WIM 2000"),
  869. },
  870. .driver_data = keymap_wistron_md2900
  871. },
  872. {
  873. /* Medion MD 42200 */
  874. .callback = dmi_matched,
  875. .matches = {
  876. DMI_MATCH(DMI_SYS_VENDOR, "Medion"),
  877. DMI_MATCH(DMI_PRODUCT_NAME, "WIM 2030"),
  878. },
  879. .driver_data = keymap_fs_amilo_pro_v2000
  880. },
  881. {
  882. /* Medion MD 96500 */
  883. .callback = dmi_matched,
  884. .matches = {
  885. DMI_MATCH(DMI_SYS_VENDOR, "MEDIONPC"),
  886. DMI_MATCH(DMI_PRODUCT_NAME, "WIM 2040"),
  887. },
  888. .driver_data = keymap_wistron_md96500
  889. },
  890. {
  891. /* Medion MD 95400 */
  892. .callback = dmi_matched,
  893. .matches = {
  894. DMI_MATCH(DMI_SYS_VENDOR, "MEDIONPC"),
  895. DMI_MATCH(DMI_PRODUCT_NAME, "WIM 2050"),
  896. },
  897. .driver_data = keymap_wistron_md96500
  898. },
  899. {
  900. /* Fujitsu Siemens Amilo D7820 */
  901. .callback = dmi_matched,
  902. .matches = {
  903. DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"), /* not sure */
  904. DMI_MATCH(DMI_PRODUCT_NAME, "Amilo D"),
  905. },
  906. .driver_data = keymap_fs_amilo_d88x0
  907. },
  908. {
  909. /* Fujitsu Siemens Amilo D88x0 */
  910. .callback = dmi_matched,
  911. .matches = {
  912. DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
  913. DMI_MATCH(DMI_PRODUCT_NAME, "AMILO D"),
  914. },
  915. .driver_data = keymap_fs_amilo_d88x0
  916. },
  917. { NULL, }
  918. };
  919. MODULE_DEVICE_TABLE(dmi, dmi_ids);
  920. /* Copy the good keymap, as the original ones are free'd */
  921. static int __init copy_keymap(void)
  922. {
  923. const struct key_entry *key;
  924. struct key_entry *new_keymap;
  925. unsigned int length = 1;
  926. for (key = keymap; key->type != KE_END; key++)
  927. length++;
  928. new_keymap = kmemdup(keymap, length * sizeof(struct key_entry),
  929. GFP_KERNEL);
  930. if (!new_keymap)
  931. return -ENOMEM;
  932. keymap = new_keymap;
  933. return 0;
  934. }
  935. static int __init select_keymap(void)
  936. {
  937. dmi_check_system(dmi_ids);
  938. if (keymap_name != NULL) {
  939. if (strcmp (keymap_name, "1557/MS2141") == 0)
  940. keymap = keymap_wistron_ms2141;
  941. else if (strcmp (keymap_name, "aopen1557") == 0)
  942. keymap = keymap_aopen_1557;
  943. else if (strcmp (keymap_name, "prestigio") == 0)
  944. keymap = keymap_prestigio;
  945. else if (strcmp (keymap_name, "generic") == 0)
  946. keymap = keymap_wistron_generic;
  947. else {
  948. printk(KERN_ERR "wistron_btns: Keymap unknown\n");
  949. return -EINVAL;
  950. }
  951. }
  952. if (keymap == NULL) {
  953. if (!force) {
  954. printk(KERN_ERR "wistron_btns: System unknown\n");
  955. return -ENODEV;
  956. }
  957. keymap = keymap_empty;
  958. }
  959. return copy_keymap();
  960. }
  961. /* Input layer interface */
  962. static struct input_polled_dev *wistron_idev;
  963. static unsigned long jiffies_last_press;
  964. static bool wifi_enabled;
  965. static bool bluetooth_enabled;
  966. /* led management */
  967. static void wistron_mail_led_set(struct led_classdev *led_cdev,
  968. enum led_brightness value)
  969. {
  970. bios_set_state(MAIL_LED, (value != LED_OFF) ? 1 : 0);
  971. }
  972. /* same as setting up wifi card, but for laptops on which the led is managed */
  973. static void wistron_wifi_led_set(struct led_classdev *led_cdev,
  974. enum led_brightness value)
  975. {
  976. bios_set_state(WIFI, (value != LED_OFF) ? 1 : 0);
  977. }
  978. static struct led_classdev wistron_mail_led = {
  979. .name = "wistron:green:mail",
  980. .brightness_set = wistron_mail_led_set,
  981. };
  982. static struct led_classdev wistron_wifi_led = {
  983. .name = "wistron:red:wifi",
  984. .brightness_set = wistron_wifi_led_set,
  985. };
  986. static void wistron_led_init(struct device *parent)
  987. {
  988. if (leds_present & FE_WIFI_LED) {
  989. u16 wifi = bios_get_default_setting(WIFI);
  990. if (wifi & 1) {
  991. wistron_wifi_led.brightness = (wifi & 2) ? LED_FULL : LED_OFF;
  992. if (led_classdev_register(parent, &wistron_wifi_led))
  993. leds_present &= ~FE_WIFI_LED;
  994. else
  995. bios_set_state(WIFI, wistron_wifi_led.brightness);
  996. } else
  997. leds_present &= ~FE_WIFI_LED;
  998. }
  999. if (leds_present & FE_MAIL_LED) {
  1000. /* bios_get_default_setting(MAIL) always retuns 0, so just turn the led off */
  1001. wistron_mail_led.brightness = LED_OFF;
  1002. if (led_classdev_register(parent, &wistron_mail_led))
  1003. leds_present &= ~FE_MAIL_LED;
  1004. else
  1005. bios_set_state(MAIL_LED, wistron_mail_led.brightness);
  1006. }
  1007. }
  1008. static void wistron_led_remove(void)
  1009. {
  1010. if (leds_present & FE_MAIL_LED)
  1011. led_classdev_unregister(&wistron_mail_led);
  1012. if (leds_present & FE_WIFI_LED)
  1013. led_classdev_unregister(&wistron_wifi_led);
  1014. }
  1015. static inline void wistron_led_suspend(void)
  1016. {
  1017. if (leds_present & FE_MAIL_LED)
  1018. led_classdev_suspend(&wistron_mail_led);
  1019. if (leds_present & FE_WIFI_LED)
  1020. led_classdev_suspend(&wistron_wifi_led);
  1021. }
  1022. static inline void wistron_led_resume(void)
  1023. {
  1024. if (leds_present & FE_MAIL_LED)
  1025. led_classdev_resume(&wistron_mail_led);
  1026. if (leds_present & FE_WIFI_LED)
  1027. led_classdev_resume(&wistron_wifi_led);
  1028. }
  1029. static void handle_key(u8 code)
  1030. {
  1031. const struct key_entry *key =
  1032. sparse_keymap_entry_from_scancode(wistron_idev->input, code);
  1033. if (key) {
  1034. switch (key->type) {
  1035. case KE_WIFI:
  1036. if (have_wifi) {
  1037. wifi_enabled = !wifi_enabled;
  1038. bios_set_state(WIFI, wifi_enabled);
  1039. }
  1040. break;
  1041. case KE_BLUETOOTH:
  1042. if (have_bluetooth) {
  1043. bluetooth_enabled = !bluetooth_enabled;
  1044. bios_set_state(BLUETOOTH, bluetooth_enabled);
  1045. }
  1046. break;
  1047. default:
  1048. sparse_keymap_report_entry(wistron_idev->input,
  1049. key, 1, true);
  1050. break;
  1051. }
  1052. jiffies_last_press = jiffies;
  1053. } else
  1054. printk(KERN_NOTICE
  1055. "wistron_btns: Unknown key code %02X\n", code);
  1056. }
  1057. static void poll_bios(bool discard)
  1058. {
  1059. u8 qlen;
  1060. u16 val;
  1061. for (;;) {
  1062. qlen = CMOS_READ(cmos_address);
  1063. if (qlen == 0)
  1064. break;
  1065. val = bios_pop_queue();
  1066. if (val != 0 && !discard)
  1067. handle_key((u8)val);
  1068. }
  1069. }
  1070. static void wistron_flush(struct input_polled_dev *dev)
  1071. {
  1072. /* Flush stale event queue */
  1073. poll_bios(true);
  1074. }
  1075. static void wistron_poll(struct input_polled_dev *dev)
  1076. {
  1077. poll_bios(false);
  1078. /* Increase poll frequency if user is currently pressing keys (< 2s ago) */
  1079. if (time_before(jiffies, jiffies_last_press + 2 * HZ))
  1080. dev->poll_interval = POLL_INTERVAL_BURST;
  1081. else
  1082. dev->poll_interval = POLL_INTERVAL_DEFAULT;
  1083. }
  1084. static int wistron_setup_keymap(struct input_dev *dev,
  1085. struct key_entry *entry)
  1086. {
  1087. switch (entry->type) {
  1088. /* if wifi or bluetooth are not available, create normal keys */
  1089. case KE_WIFI:
  1090. if (!have_wifi) {
  1091. entry->type = KE_KEY;
  1092. entry->keycode = KEY_WLAN;
  1093. }
  1094. break;
  1095. case KE_BLUETOOTH:
  1096. if (!have_bluetooth) {
  1097. entry->type = KE_KEY;
  1098. entry->keycode = KEY_BLUETOOTH;
  1099. }
  1100. break;
  1101. case KE_END:
  1102. if (entry->code & FE_UNTESTED)
  1103. printk(KERN_WARNING "Untested laptop multimedia keys, "
  1104. "please report success or failure to "
  1105. "eric.piel@tremplin-utc.net\n");
  1106. break;
  1107. }
  1108. return 0;
  1109. }
  1110. static int setup_input_dev(void)
  1111. {
  1112. struct input_dev *input_dev;
  1113. int error;
  1114. wistron_idev = input_allocate_polled_device();
  1115. if (!wistron_idev)
  1116. return -ENOMEM;
  1117. wistron_idev->open = wistron_flush;
  1118. wistron_idev->poll = wistron_poll;
  1119. wistron_idev->poll_interval = POLL_INTERVAL_DEFAULT;
  1120. input_dev = wistron_idev->input;
  1121. input_dev->name = "Wistron laptop buttons";
  1122. input_dev->phys = "wistron/input0";
  1123. input_dev->id.bustype = BUS_HOST;
  1124. input_dev->dev.parent = &wistron_device->dev;
  1125. error = sparse_keymap_setup(input_dev, keymap, wistron_setup_keymap);
  1126. if (error)
  1127. goto err_free_dev;
  1128. error = input_register_polled_device(wistron_idev);
  1129. if (error)
  1130. goto err_free_dev;
  1131. return 0;
  1132. err_free_dev:
  1133. input_free_polled_device(wistron_idev);
  1134. return error;
  1135. }
  1136. /* Driver core */
  1137. static int wistron_probe(struct platform_device *dev)
  1138. {
  1139. int err;
  1140. bios_attach();
  1141. cmos_address = bios_get_cmos_address();
  1142. if (have_wifi) {
  1143. u16 wifi = bios_get_default_setting(WIFI);
  1144. if (wifi & 1)
  1145. wifi_enabled = wifi & 2;
  1146. else
  1147. have_wifi = 0;
  1148. if (have_wifi)
  1149. bios_set_state(WIFI, wifi_enabled);
  1150. }
  1151. if (have_bluetooth) {
  1152. u16 bt = bios_get_default_setting(BLUETOOTH);
  1153. if (bt & 1)
  1154. bluetooth_enabled = bt & 2;
  1155. else
  1156. have_bluetooth = false;
  1157. if (have_bluetooth)
  1158. bios_set_state(BLUETOOTH, bluetooth_enabled);
  1159. }
  1160. wistron_led_init(&dev->dev);
  1161. err = setup_input_dev();
  1162. if (err) {
  1163. bios_detach();
  1164. return err;
  1165. }
  1166. return 0;
  1167. }
  1168. static int wistron_remove(struct platform_device *dev)
  1169. {
  1170. wistron_led_remove();
  1171. input_unregister_polled_device(wistron_idev);
  1172. input_free_polled_device(wistron_idev);
  1173. bios_detach();
  1174. return 0;
  1175. }
  1176. #ifdef CONFIG_PM
  1177. static int wistron_suspend(struct device *dev)
  1178. {
  1179. if (have_wifi)
  1180. bios_set_state(WIFI, 0);
  1181. if (have_bluetooth)
  1182. bios_set_state(BLUETOOTH, 0);
  1183. wistron_led_suspend();
  1184. return 0;
  1185. }
  1186. static int wistron_resume(struct device *dev)
  1187. {
  1188. if (have_wifi)
  1189. bios_set_state(WIFI, wifi_enabled);
  1190. if (have_bluetooth)
  1191. bios_set_state(BLUETOOTH, bluetooth_enabled);
  1192. wistron_led_resume();
  1193. poll_bios(true);
  1194. return 0;
  1195. }
  1196. static const struct dev_pm_ops wistron_pm_ops = {
  1197. .suspend = wistron_suspend,
  1198. .resume = wistron_resume,
  1199. .poweroff = wistron_suspend,
  1200. .restore = wistron_resume,
  1201. };
  1202. #endif
  1203. static struct platform_driver wistron_driver = {
  1204. .driver = {
  1205. .name = "wistron-bios",
  1206. #ifdef CONFIG_PM
  1207. .pm = &wistron_pm_ops,
  1208. #endif
  1209. },
  1210. .probe = wistron_probe,
  1211. .remove = wistron_remove,
  1212. };
  1213. static int __init wb_module_init(void)
  1214. {
  1215. int err;
  1216. err = select_keymap();
  1217. if (err)
  1218. return err;
  1219. err = map_bios();
  1220. if (err)
  1221. goto err_free_keymap;
  1222. err = platform_driver_register(&wistron_driver);
  1223. if (err)
  1224. goto err_unmap_bios;
  1225. wistron_device = platform_device_alloc("wistron-bios", -1);
  1226. if (!wistron_device) {
  1227. err = -ENOMEM;
  1228. goto err_unregister_driver;
  1229. }
  1230. err = platform_device_add(wistron_device);
  1231. if (err)
  1232. goto err_free_device;
  1233. return 0;
  1234. err_free_device:
  1235. platform_device_put(wistron_device);
  1236. err_unregister_driver:
  1237. platform_driver_unregister(&wistron_driver);
  1238. err_unmap_bios:
  1239. unmap_bios();
  1240. err_free_keymap:
  1241. kfree(keymap);
  1242. return err;
  1243. }
  1244. static void __exit wb_module_exit(void)
  1245. {
  1246. platform_device_unregister(wistron_device);
  1247. platform_driver_unregister(&wistron_driver);
  1248. unmap_bios();
  1249. kfree(keymap);
  1250. }
  1251. module_init(wb_module_init);
  1252. module_exit(wb_module_exit);