wistron_btns.c 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407
  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_keymap;
  1131. return 0;
  1132. err_free_keymap:
  1133. sparse_keymap_free(input_dev);
  1134. err_free_dev:
  1135. input_free_polled_device(wistron_idev);
  1136. return error;
  1137. }
  1138. /* Driver core */
  1139. static int wistron_probe(struct platform_device *dev)
  1140. {
  1141. int err;
  1142. bios_attach();
  1143. cmos_address = bios_get_cmos_address();
  1144. if (have_wifi) {
  1145. u16 wifi = bios_get_default_setting(WIFI);
  1146. if (wifi & 1)
  1147. wifi_enabled = wifi & 2;
  1148. else
  1149. have_wifi = 0;
  1150. if (have_wifi)
  1151. bios_set_state(WIFI, wifi_enabled);
  1152. }
  1153. if (have_bluetooth) {
  1154. u16 bt = bios_get_default_setting(BLUETOOTH);
  1155. if (bt & 1)
  1156. bluetooth_enabled = bt & 2;
  1157. else
  1158. have_bluetooth = false;
  1159. if (have_bluetooth)
  1160. bios_set_state(BLUETOOTH, bluetooth_enabled);
  1161. }
  1162. wistron_led_init(&dev->dev);
  1163. err = setup_input_dev();
  1164. if (err) {
  1165. bios_detach();
  1166. return err;
  1167. }
  1168. return 0;
  1169. }
  1170. static int wistron_remove(struct platform_device *dev)
  1171. {
  1172. wistron_led_remove();
  1173. input_unregister_polled_device(wistron_idev);
  1174. sparse_keymap_free(wistron_idev->input);
  1175. input_free_polled_device(wistron_idev);
  1176. bios_detach();
  1177. return 0;
  1178. }
  1179. #ifdef CONFIG_PM
  1180. static int wistron_suspend(struct device *dev)
  1181. {
  1182. if (have_wifi)
  1183. bios_set_state(WIFI, 0);
  1184. if (have_bluetooth)
  1185. bios_set_state(BLUETOOTH, 0);
  1186. wistron_led_suspend();
  1187. return 0;
  1188. }
  1189. static int wistron_resume(struct device *dev)
  1190. {
  1191. if (have_wifi)
  1192. bios_set_state(WIFI, wifi_enabled);
  1193. if (have_bluetooth)
  1194. bios_set_state(BLUETOOTH, bluetooth_enabled);
  1195. wistron_led_resume();
  1196. poll_bios(true);
  1197. return 0;
  1198. }
  1199. static const struct dev_pm_ops wistron_pm_ops = {
  1200. .suspend = wistron_suspend,
  1201. .resume = wistron_resume,
  1202. .poweroff = wistron_suspend,
  1203. .restore = wistron_resume,
  1204. };
  1205. #endif
  1206. static struct platform_driver wistron_driver = {
  1207. .driver = {
  1208. .name = "wistron-bios",
  1209. #ifdef CONFIG_PM
  1210. .pm = &wistron_pm_ops,
  1211. #endif
  1212. },
  1213. .probe = wistron_probe,
  1214. .remove = wistron_remove,
  1215. };
  1216. static int __init wb_module_init(void)
  1217. {
  1218. int err;
  1219. err = select_keymap();
  1220. if (err)
  1221. return err;
  1222. err = map_bios();
  1223. if (err)
  1224. goto err_free_keymap;
  1225. err = platform_driver_register(&wistron_driver);
  1226. if (err)
  1227. goto err_unmap_bios;
  1228. wistron_device = platform_device_alloc("wistron-bios", -1);
  1229. if (!wistron_device) {
  1230. err = -ENOMEM;
  1231. goto err_unregister_driver;
  1232. }
  1233. err = platform_device_add(wistron_device);
  1234. if (err)
  1235. goto err_free_device;
  1236. return 0;
  1237. err_free_device:
  1238. platform_device_put(wistron_device);
  1239. err_unregister_driver:
  1240. platform_driver_unregister(&wistron_driver);
  1241. err_unmap_bios:
  1242. unmap_bios();
  1243. err_free_keymap:
  1244. kfree(keymap);
  1245. return err;
  1246. }
  1247. static void __exit wb_module_exit(void)
  1248. {
  1249. platform_device_unregister(wistron_device);
  1250. platform_driver_unregister(&wistron_driver);
  1251. unmap_bios();
  1252. kfree(keymap);
  1253. }
  1254. module_init(wb_module_init);
  1255. module_exit(wb_module_exit);