i8042-x86ia64io.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  1. #ifndef _I8042_X86IA64IO_H
  2. #define _I8042_X86IA64IO_H
  3. /*
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of the GNU General Public License version 2 as published by
  6. * the Free Software Foundation.
  7. */
  8. /*
  9. * Names.
  10. */
  11. #define I8042_KBD_PHYS_DESC "isa0060/serio0"
  12. #define I8042_AUX_PHYS_DESC "isa0060/serio1"
  13. #define I8042_MUX_PHYS_DESC "isa0060/serio%d"
  14. /*
  15. * IRQs.
  16. */
  17. #if defined(__ia64__)
  18. # define I8042_MAP_IRQ(x) isa_irq_to_vector((x))
  19. #else
  20. # define I8042_MAP_IRQ(x) (x)
  21. #endif
  22. #define I8042_KBD_IRQ i8042_kbd_irq
  23. #define I8042_AUX_IRQ i8042_aux_irq
  24. static int i8042_kbd_irq;
  25. static int i8042_aux_irq;
  26. /*
  27. * Register numbers.
  28. */
  29. #define I8042_COMMAND_REG i8042_command_reg
  30. #define I8042_STATUS_REG i8042_command_reg
  31. #define I8042_DATA_REG i8042_data_reg
  32. static int i8042_command_reg = 0x64;
  33. static int i8042_data_reg = 0x60;
  34. static inline int i8042_read_data(void)
  35. {
  36. return inb(I8042_DATA_REG);
  37. }
  38. static inline int i8042_read_status(void)
  39. {
  40. return inb(I8042_STATUS_REG);
  41. }
  42. static inline void i8042_write_data(int val)
  43. {
  44. outb(val, I8042_DATA_REG);
  45. }
  46. static inline void i8042_write_command(int val)
  47. {
  48. outb(val, I8042_COMMAND_REG);
  49. }
  50. #if defined(__i386__)
  51. #include <linux/dmi.h>
  52. static struct dmi_system_id __initdata i8042_dmi_noloop_table[] = {
  53. {
  54. /* AUX LOOP command does not raise AUX IRQ */
  55. .ident = "ASUS P65UP5",
  56. .matches = {
  57. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
  58. DMI_MATCH(DMI_BOARD_NAME, "P/I-P65UP5"),
  59. DMI_MATCH(DMI_BOARD_VERSION, "REV 2.X"),
  60. },
  61. },
  62. {
  63. .ident = "Compaq Proliant 8500",
  64. .matches = {
  65. DMI_MATCH(DMI_SYS_VENDOR, "Compaq"),
  66. DMI_MATCH(DMI_PRODUCT_NAME , "ProLiant"),
  67. DMI_MATCH(DMI_PRODUCT_VERSION, "8500"),
  68. },
  69. },
  70. {
  71. .ident = "Compaq Proliant DL760",
  72. .matches = {
  73. DMI_MATCH(DMI_SYS_VENDOR, "Compaq"),
  74. DMI_MATCH(DMI_PRODUCT_NAME , "ProLiant"),
  75. DMI_MATCH(DMI_PRODUCT_VERSION, "DL760"),
  76. },
  77. },
  78. {
  79. .ident = "OQO Model 01",
  80. .matches = {
  81. DMI_MATCH(DMI_SYS_VENDOR, "OQO"),
  82. DMI_MATCH(DMI_PRODUCT_NAME, "ZEPTO"),
  83. DMI_MATCH(DMI_PRODUCT_VERSION, "00"),
  84. },
  85. },
  86. {
  87. /* AUX LOOP does not work properly */
  88. .ident = "ULI EV4873",
  89. .matches = {
  90. DMI_MATCH(DMI_SYS_VENDOR, "ULI"),
  91. DMI_MATCH(DMI_PRODUCT_NAME, "EV4873"),
  92. DMI_MATCH(DMI_PRODUCT_VERSION, "5a"),
  93. },
  94. },
  95. {
  96. .ident = "Microsoft Virtual Machine",
  97. .matches = {
  98. DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
  99. DMI_MATCH(DMI_PRODUCT_NAME, "Virtual Machine"),
  100. DMI_MATCH(DMI_PRODUCT_VERSION, "VS2005R2"),
  101. },
  102. },
  103. { }
  104. };
  105. /*
  106. * Some Fujitsu notebooks are having trouble with touchpads if
  107. * active multiplexing mode is activated. Luckily they don't have
  108. * external PS/2 ports so we can safely disable it.
  109. * ... apparently some Toshibas don't like MUX mode either and
  110. * die horrible death on reboot.
  111. */
  112. static struct dmi_system_id __initdata i8042_dmi_nomux_table[] = {
  113. {
  114. .ident = "Fujitsu Lifebook P7010/P7010D",
  115. .matches = {
  116. DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
  117. DMI_MATCH(DMI_PRODUCT_NAME, "P7010"),
  118. },
  119. },
  120. {
  121. .ident = "Fujitsu Lifebook P7010",
  122. .matches = {
  123. DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
  124. DMI_MATCH(DMI_PRODUCT_NAME, "0000000000"),
  125. },
  126. },
  127. {
  128. .ident = "Fujitsu Lifebook P5020D",
  129. .matches = {
  130. DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
  131. DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook P Series"),
  132. },
  133. },
  134. {
  135. .ident = "Fujitsu Lifebook S2000",
  136. .matches = {
  137. DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
  138. DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook S Series"),
  139. },
  140. },
  141. {
  142. .ident = "Fujitsu Lifebook S6230",
  143. .matches = {
  144. DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
  145. DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook S6230"),
  146. },
  147. },
  148. {
  149. .ident = "Fujitsu T70H",
  150. .matches = {
  151. DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
  152. DMI_MATCH(DMI_PRODUCT_NAME, "FMVLT70H"),
  153. },
  154. },
  155. {
  156. .ident = "Fujitsu-Siemens Lifebook T3010",
  157. .matches = {
  158. DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
  159. DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK T3010"),
  160. },
  161. },
  162. {
  163. .ident = "Fujitsu-Siemens Lifebook E4010",
  164. .matches = {
  165. DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
  166. DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK E4010"),
  167. },
  168. },
  169. {
  170. /*
  171. * No data is coming from the touchscreen unless KBC
  172. * is in legacy mode.
  173. */
  174. .ident = "Panasonic CF-29",
  175. .matches = {
  176. DMI_MATCH(DMI_SYS_VENDOR, "Matsushita"),
  177. DMI_MATCH(DMI_PRODUCT_NAME, "CF-29"),
  178. },
  179. },
  180. {
  181. /*
  182. * Errors on MUX ports are reported without raising AUXDATA
  183. * causing "spurious NAK" messages.
  184. */
  185. .ident = "HP Pavilion DV4017EA",
  186. .matches = {
  187. DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
  188. DMI_MATCH(DMI_PRODUCT_NAME, "Pavilion dv4000 (EA032EA#ABF)"),
  189. },
  190. },
  191. {
  192. /*
  193. * Like DV4017EA does not raise AUXERR for errors on MUX ports.
  194. */
  195. .ident = "HP Pavilion ZT1000",
  196. .matches = {
  197. DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
  198. DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion Notebook PC"),
  199. DMI_MATCH(DMI_PRODUCT_VERSION, "HP Pavilion Notebook ZT1000"),
  200. },
  201. },
  202. {
  203. /*
  204. * Like DV4017EA does not raise AUXERR for errors on MUX ports.
  205. */
  206. .ident = "HP Pavilion DV4270ca",
  207. .matches = {
  208. DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
  209. DMI_MATCH(DMI_PRODUCT_NAME, "Pavilion dv4000 (EH476UA#ABL)"),
  210. },
  211. },
  212. {
  213. .ident = "Toshiba P10",
  214. .matches = {
  215. DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
  216. DMI_MATCH(DMI_PRODUCT_NAME, "Satellite P10"),
  217. },
  218. },
  219. {
  220. .ident = "Toshiba Equium A110",
  221. .matches = {
  222. DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
  223. DMI_MATCH(DMI_PRODUCT_NAME, "EQUIUM A110"),
  224. },
  225. },
  226. {
  227. .ident = "Alienware Sentia",
  228. .matches = {
  229. DMI_MATCH(DMI_SYS_VENDOR, "ALIENWARE"),
  230. DMI_MATCH(DMI_PRODUCT_NAME, "Sentia"),
  231. },
  232. },
  233. {
  234. .ident = "Sharp Actius MM20",
  235. .matches = {
  236. DMI_MATCH(DMI_SYS_VENDOR, "SHARP"),
  237. DMI_MATCH(DMI_PRODUCT_NAME, "PC-MM20 Series"),
  238. },
  239. },
  240. {
  241. .ident = "Sony Vaio FS-115b",
  242. .matches = {
  243. DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
  244. DMI_MATCH(DMI_PRODUCT_NAME, "VGN-FS115B"),
  245. },
  246. },
  247. {
  248. .ident = "Amoi M636/A737",
  249. .matches = {
  250. DMI_MATCH(DMI_SYS_VENDOR, "Amoi Electronics CO.,LTD."),
  251. DMI_MATCH(DMI_PRODUCT_NAME, "M636/A737 platform"),
  252. },
  253. },
  254. { }
  255. };
  256. #endif
  257. #ifdef CONFIG_PNP
  258. #include <linux/pnp.h>
  259. static int i8042_pnp_kbd_registered;
  260. static unsigned int i8042_pnp_kbd_devices;
  261. static int i8042_pnp_aux_registered;
  262. static unsigned int i8042_pnp_aux_devices;
  263. static int i8042_pnp_command_reg;
  264. static int i8042_pnp_data_reg;
  265. static int i8042_pnp_kbd_irq;
  266. static int i8042_pnp_aux_irq;
  267. static char i8042_pnp_kbd_name[32];
  268. static char i8042_pnp_aux_name[32];
  269. static int i8042_pnp_kbd_probe(struct pnp_dev *dev, const struct pnp_device_id *did)
  270. {
  271. if (pnp_port_valid(dev, 0) && pnp_port_len(dev, 0) == 1)
  272. i8042_pnp_data_reg = pnp_port_start(dev,0);
  273. if (pnp_port_valid(dev, 1) && pnp_port_len(dev, 1) == 1)
  274. i8042_pnp_command_reg = pnp_port_start(dev, 1);
  275. if (pnp_irq_valid(dev,0))
  276. i8042_pnp_kbd_irq = pnp_irq(dev, 0);
  277. strncpy(i8042_pnp_kbd_name, did->id, sizeof(i8042_pnp_kbd_name));
  278. if (strlen(pnp_dev_name(dev))) {
  279. strncat(i8042_pnp_kbd_name, ":", sizeof(i8042_pnp_kbd_name));
  280. strncat(i8042_pnp_kbd_name, pnp_dev_name(dev), sizeof(i8042_pnp_kbd_name));
  281. }
  282. i8042_pnp_kbd_devices++;
  283. return 0;
  284. }
  285. static int i8042_pnp_aux_probe(struct pnp_dev *dev, const struct pnp_device_id *did)
  286. {
  287. if (pnp_port_valid(dev, 0) && pnp_port_len(dev, 0) == 1)
  288. i8042_pnp_data_reg = pnp_port_start(dev,0);
  289. if (pnp_port_valid(dev, 1) && pnp_port_len(dev, 1) == 1)
  290. i8042_pnp_command_reg = pnp_port_start(dev, 1);
  291. if (pnp_irq_valid(dev, 0))
  292. i8042_pnp_aux_irq = pnp_irq(dev, 0);
  293. strncpy(i8042_pnp_aux_name, did->id, sizeof(i8042_pnp_aux_name));
  294. if (strlen(pnp_dev_name(dev))) {
  295. strncat(i8042_pnp_aux_name, ":", sizeof(i8042_pnp_aux_name));
  296. strncat(i8042_pnp_aux_name, pnp_dev_name(dev), sizeof(i8042_pnp_aux_name));
  297. }
  298. i8042_pnp_aux_devices++;
  299. return 0;
  300. }
  301. static struct pnp_device_id pnp_kbd_devids[] = {
  302. { .id = "PNP0303", .driver_data = 0 },
  303. { .id = "PNP030b", .driver_data = 0 },
  304. { .id = "", },
  305. };
  306. static struct pnp_driver i8042_pnp_kbd_driver = {
  307. .name = "i8042 kbd",
  308. .id_table = pnp_kbd_devids,
  309. .probe = i8042_pnp_kbd_probe,
  310. };
  311. static struct pnp_device_id pnp_aux_devids[] = {
  312. { .id = "FJC6000", .driver_data = 0 },
  313. { .id = "FJC6001", .driver_data = 0 },
  314. { .id = "PNP0f03", .driver_data = 0 },
  315. { .id = "PNP0f0b", .driver_data = 0 },
  316. { .id = "PNP0f0e", .driver_data = 0 },
  317. { .id = "PNP0f12", .driver_data = 0 },
  318. { .id = "PNP0f13", .driver_data = 0 },
  319. { .id = "PNP0f19", .driver_data = 0 },
  320. { .id = "PNP0f1c", .driver_data = 0 },
  321. { .id = "SYN0801", .driver_data = 0 },
  322. { .id = "", },
  323. };
  324. static struct pnp_driver i8042_pnp_aux_driver = {
  325. .name = "i8042 aux",
  326. .id_table = pnp_aux_devids,
  327. .probe = i8042_pnp_aux_probe,
  328. };
  329. static void i8042_pnp_exit(void)
  330. {
  331. if (i8042_pnp_kbd_registered) {
  332. i8042_pnp_kbd_registered = 0;
  333. pnp_unregister_driver(&i8042_pnp_kbd_driver);
  334. }
  335. if (i8042_pnp_aux_registered) {
  336. i8042_pnp_aux_registered = 0;
  337. pnp_unregister_driver(&i8042_pnp_aux_driver);
  338. }
  339. }
  340. static int __init i8042_pnp_init(void)
  341. {
  342. char kbd_irq_str[4] = { 0 }, aux_irq_str[4] = { 0 };
  343. int pnp_data_busted = 0;
  344. int err;
  345. if (i8042_nopnp) {
  346. printk(KERN_INFO "i8042: PNP detection disabled\n");
  347. return 0;
  348. }
  349. err = pnp_register_driver(&i8042_pnp_kbd_driver);
  350. if (!err)
  351. i8042_pnp_kbd_registered = 1;
  352. err = pnp_register_driver(&i8042_pnp_aux_driver);
  353. if (!err)
  354. i8042_pnp_aux_registered = 1;
  355. if (!i8042_pnp_kbd_devices && !i8042_pnp_aux_devices) {
  356. i8042_pnp_exit();
  357. #if defined(__ia64__)
  358. return -ENODEV;
  359. #else
  360. printk(KERN_INFO "PNP: No PS/2 controller found. Probing ports directly.\n");
  361. return 0;
  362. #endif
  363. }
  364. if (i8042_pnp_kbd_devices)
  365. snprintf(kbd_irq_str, sizeof(kbd_irq_str),
  366. "%d", i8042_pnp_kbd_irq);
  367. if (i8042_pnp_aux_devices)
  368. snprintf(aux_irq_str, sizeof(aux_irq_str),
  369. "%d", i8042_pnp_aux_irq);
  370. printk(KERN_INFO "PNP: PS/2 Controller [%s%s%s] at %#x,%#x irq %s%s%s\n",
  371. i8042_pnp_kbd_name, (i8042_pnp_kbd_devices && i8042_pnp_aux_devices) ? "," : "",
  372. i8042_pnp_aux_name,
  373. i8042_pnp_data_reg, i8042_pnp_command_reg,
  374. kbd_irq_str, (i8042_pnp_kbd_devices && i8042_pnp_aux_devices) ? "," : "",
  375. aux_irq_str);
  376. #if defined(__ia64__)
  377. if (!i8042_pnp_kbd_devices)
  378. i8042_nokbd = 1;
  379. if (!i8042_pnp_aux_devices)
  380. i8042_noaux = 1;
  381. #endif
  382. if (((i8042_pnp_data_reg & ~0xf) == (i8042_data_reg & ~0xf) &&
  383. i8042_pnp_data_reg != i8042_data_reg) ||
  384. !i8042_pnp_data_reg) {
  385. printk(KERN_WARNING
  386. "PNP: PS/2 controller has invalid data port %#x; "
  387. "using default %#x\n",
  388. i8042_pnp_data_reg, i8042_data_reg);
  389. i8042_pnp_data_reg = i8042_data_reg;
  390. pnp_data_busted = 1;
  391. }
  392. if (((i8042_pnp_command_reg & ~0xf) == (i8042_command_reg & ~0xf) &&
  393. i8042_pnp_command_reg != i8042_command_reg) ||
  394. !i8042_pnp_command_reg) {
  395. printk(KERN_WARNING
  396. "PNP: PS/2 controller has invalid command port %#x; "
  397. "using default %#x\n",
  398. i8042_pnp_command_reg, i8042_command_reg);
  399. i8042_pnp_command_reg = i8042_command_reg;
  400. pnp_data_busted = 1;
  401. }
  402. if (!i8042_nokbd && !i8042_pnp_kbd_irq) {
  403. printk(KERN_WARNING
  404. "PNP: PS/2 controller doesn't have KBD irq; "
  405. "using default %d\n", i8042_kbd_irq);
  406. i8042_pnp_kbd_irq = i8042_kbd_irq;
  407. pnp_data_busted = 1;
  408. }
  409. if (!i8042_noaux && !i8042_pnp_aux_irq) {
  410. if (!pnp_data_busted && i8042_pnp_kbd_irq) {
  411. printk(KERN_WARNING
  412. "PNP: PS/2 appears to have AUX port disabled, "
  413. "if this is incorrect please boot with "
  414. "i8042.nopnp\n");
  415. i8042_noaux = 1;
  416. } else {
  417. printk(KERN_WARNING
  418. "PNP: PS/2 controller doesn't have AUX irq; "
  419. "using default %d\n", i8042_aux_irq);
  420. i8042_pnp_aux_irq = i8042_aux_irq;
  421. }
  422. }
  423. i8042_data_reg = i8042_pnp_data_reg;
  424. i8042_command_reg = i8042_pnp_command_reg;
  425. i8042_kbd_irq = i8042_pnp_kbd_irq;
  426. i8042_aux_irq = i8042_pnp_aux_irq;
  427. return 0;
  428. }
  429. #else
  430. static inline int i8042_pnp_init(void) { return 0; }
  431. static inline void i8042_pnp_exit(void) { }
  432. #endif
  433. static int __init i8042_platform_init(void)
  434. {
  435. int retval;
  436. /*
  437. * On ix86 platforms touching the i8042 data register region can do really
  438. * bad things. Because of this the region is always reserved on ix86 boxes.
  439. *
  440. * if (!request_region(I8042_DATA_REG, 16, "i8042"))
  441. * return -EBUSY;
  442. */
  443. i8042_kbd_irq = I8042_MAP_IRQ(1);
  444. i8042_aux_irq = I8042_MAP_IRQ(12);
  445. retval = i8042_pnp_init();
  446. if (retval)
  447. return retval;
  448. #if defined(__ia64__)
  449. i8042_reset = 1;
  450. #endif
  451. #if defined(__i386__)
  452. if (dmi_check_system(i8042_dmi_noloop_table))
  453. i8042_noloop = 1;
  454. if (dmi_check_system(i8042_dmi_nomux_table))
  455. i8042_nomux = 1;
  456. #endif
  457. return retval;
  458. }
  459. static inline void i8042_platform_exit(void)
  460. {
  461. i8042_pnp_exit();
  462. }
  463. #endif /* _I8042_X86IA64IO_H */