i8042-x86ia64io.h 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  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. .ident = "Compaq Proliant 8500",
  55. .matches = {
  56. DMI_MATCH(DMI_SYS_VENDOR, "Compaq"),
  57. DMI_MATCH(DMI_PRODUCT_NAME , "ProLiant"),
  58. DMI_MATCH(DMI_PRODUCT_VERSION, "8500"),
  59. },
  60. },
  61. {
  62. .ident = "Compaq Proliant DL760",
  63. .matches = {
  64. DMI_MATCH(DMI_SYS_VENDOR, "Compaq"),
  65. DMI_MATCH(DMI_PRODUCT_NAME , "ProLiant"),
  66. DMI_MATCH(DMI_PRODUCT_VERSION, "DL760"),
  67. },
  68. },
  69. {
  70. .ident = "OQO Model 01",
  71. .matches = {
  72. DMI_MATCH(DMI_SYS_VENDOR, "OQO"),
  73. DMI_MATCH(DMI_PRODUCT_NAME, "ZEPTO"),
  74. DMI_MATCH(DMI_PRODUCT_VERSION, "00"),
  75. },
  76. },
  77. { }
  78. };
  79. /*
  80. * Some Fujitsu notebooks are having trouble with touchpads if
  81. * active multiplexing mode is activated. Luckily they don't have
  82. * external PS/2 ports so we can safely disable it.
  83. * ... apparently some Toshibas don't like MUX mode either and
  84. * die horrible death on reboot.
  85. */
  86. static struct dmi_system_id __initdata i8042_dmi_nomux_table[] = {
  87. {
  88. .ident = "Fujitsu Lifebook P7010/P7010D",
  89. .matches = {
  90. DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
  91. DMI_MATCH(DMI_PRODUCT_NAME, "P7010"),
  92. },
  93. },
  94. {
  95. .ident = "Fujitsu Lifebook P5020D",
  96. .matches = {
  97. DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
  98. DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook P Series"),
  99. },
  100. },
  101. {
  102. .ident = "Fujitsu Lifebook S2000",
  103. .matches = {
  104. DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
  105. DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook S Series"),
  106. },
  107. },
  108. {
  109. .ident = "Fujitsu Lifebook S6230",
  110. .matches = {
  111. DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
  112. DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook S6230"),
  113. },
  114. },
  115. {
  116. .ident = "Fujitsu T70H",
  117. .matches = {
  118. DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
  119. DMI_MATCH(DMI_PRODUCT_NAME, "FMVLT70H"),
  120. },
  121. },
  122. {
  123. .ident = "Fujitsu-Siemens Lifebook T3010",
  124. .matches = {
  125. DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
  126. DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK T3010"),
  127. },
  128. },
  129. {
  130. .ident = "Fujitsu-Siemens Lifebook E4010",
  131. .matches = {
  132. DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
  133. DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK E4010"),
  134. },
  135. },
  136. {
  137. .ident = "Toshiba P10",
  138. .matches = {
  139. DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
  140. DMI_MATCH(DMI_PRODUCT_NAME, "Satellite P10"),
  141. },
  142. },
  143. {
  144. .ident = "Alienware Sentia",
  145. .matches = {
  146. DMI_MATCH(DMI_SYS_VENDOR, "ALIENWARE"),
  147. DMI_MATCH(DMI_PRODUCT_NAME, "Sentia"),
  148. },
  149. },
  150. {
  151. .ident = "Sharp Actius MM20",
  152. .matches = {
  153. DMI_MATCH(DMI_SYS_VENDOR, "SHARP"),
  154. DMI_MATCH(DMI_PRODUCT_NAME, "PC-MM20 Series"),
  155. },
  156. },
  157. {
  158. .ident = "Sony Vaio FS-115b",
  159. .matches = {
  160. DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
  161. DMI_MATCH(DMI_PRODUCT_NAME, "VGN-FS115B"),
  162. },
  163. },
  164. { }
  165. };
  166. #endif
  167. #ifdef CONFIG_PNP
  168. #include <linux/pnp.h>
  169. static int i8042_pnp_kbd_registered;
  170. static unsigned int i8042_pnp_kbd_devices;
  171. static int i8042_pnp_aux_registered;
  172. static unsigned int i8042_pnp_aux_devices;
  173. static int i8042_pnp_command_reg;
  174. static int i8042_pnp_data_reg;
  175. static int i8042_pnp_kbd_irq;
  176. static int i8042_pnp_aux_irq;
  177. static char i8042_pnp_kbd_name[32];
  178. static char i8042_pnp_aux_name[32];
  179. static int i8042_pnp_kbd_probe(struct pnp_dev *dev, const struct pnp_device_id *did)
  180. {
  181. if (pnp_port_valid(dev, 0) && pnp_port_len(dev, 0) == 1)
  182. i8042_pnp_data_reg = pnp_port_start(dev,0);
  183. if (pnp_port_valid(dev, 1) && pnp_port_len(dev, 1) == 1)
  184. i8042_pnp_command_reg = pnp_port_start(dev, 1);
  185. if (pnp_irq_valid(dev,0))
  186. i8042_pnp_kbd_irq = pnp_irq(dev, 0);
  187. strncpy(i8042_pnp_kbd_name, did->id, sizeof(i8042_pnp_kbd_name));
  188. if (strlen(pnp_dev_name(dev))) {
  189. strncat(i8042_pnp_kbd_name, ":", sizeof(i8042_pnp_kbd_name));
  190. strncat(i8042_pnp_kbd_name, pnp_dev_name(dev), sizeof(i8042_pnp_kbd_name));
  191. }
  192. i8042_pnp_kbd_devices++;
  193. return 0;
  194. }
  195. static int i8042_pnp_aux_probe(struct pnp_dev *dev, const struct pnp_device_id *did)
  196. {
  197. if (pnp_port_valid(dev, 0) && pnp_port_len(dev, 0) == 1)
  198. i8042_pnp_data_reg = pnp_port_start(dev,0);
  199. if (pnp_port_valid(dev, 1) && pnp_port_len(dev, 1) == 1)
  200. i8042_pnp_command_reg = pnp_port_start(dev, 1);
  201. if (pnp_irq_valid(dev, 0))
  202. i8042_pnp_aux_irq = pnp_irq(dev, 0);
  203. strncpy(i8042_pnp_aux_name, did->id, sizeof(i8042_pnp_aux_name));
  204. if (strlen(pnp_dev_name(dev))) {
  205. strncat(i8042_pnp_aux_name, ":", sizeof(i8042_pnp_aux_name));
  206. strncat(i8042_pnp_aux_name, pnp_dev_name(dev), sizeof(i8042_pnp_aux_name));
  207. }
  208. i8042_pnp_aux_devices++;
  209. return 0;
  210. }
  211. static struct pnp_device_id pnp_kbd_devids[] = {
  212. { .id = "PNP0303", .driver_data = 0 },
  213. { .id = "PNP030b", .driver_data = 0 },
  214. { .id = "", },
  215. };
  216. static struct pnp_driver i8042_pnp_kbd_driver = {
  217. .name = "i8042 kbd",
  218. .id_table = pnp_kbd_devids,
  219. .probe = i8042_pnp_kbd_probe,
  220. };
  221. static struct pnp_device_id pnp_aux_devids[] = {
  222. { .id = "PNP0f03", .driver_data = 0 },
  223. { .id = "PNP0f0b", .driver_data = 0 },
  224. { .id = "PNP0f0e", .driver_data = 0 },
  225. { .id = "PNP0f12", .driver_data = 0 },
  226. { .id = "PNP0f13", .driver_data = 0 },
  227. { .id = "PNP0f19", .driver_data = 0 },
  228. { .id = "PNP0f1c", .driver_data = 0 },
  229. { .id = "SYN0801", .driver_data = 0 },
  230. { .id = "", },
  231. };
  232. static struct pnp_driver i8042_pnp_aux_driver = {
  233. .name = "i8042 aux",
  234. .id_table = pnp_aux_devids,
  235. .probe = i8042_pnp_aux_probe,
  236. };
  237. static void i8042_pnp_exit(void)
  238. {
  239. if (i8042_pnp_kbd_registered) {
  240. i8042_pnp_kbd_registered = 0;
  241. pnp_unregister_driver(&i8042_pnp_kbd_driver);
  242. }
  243. if (i8042_pnp_aux_registered) {
  244. i8042_pnp_aux_registered = 0;
  245. pnp_unregister_driver(&i8042_pnp_aux_driver);
  246. }
  247. }
  248. static int __init i8042_pnp_init(void)
  249. {
  250. char kbd_irq_str[4] = { 0 }, aux_irq_str[4] = { 0 };
  251. int err;
  252. if (i8042_nopnp) {
  253. printk(KERN_INFO "i8042: PNP detection disabled\n");
  254. return 0;
  255. }
  256. err = pnp_register_driver(&i8042_pnp_kbd_driver);
  257. if (!err)
  258. i8042_pnp_kbd_registered = 1;
  259. err = pnp_register_driver(&i8042_pnp_aux_driver);
  260. if (!err)
  261. i8042_pnp_aux_registered = 1;
  262. if (!i8042_pnp_kbd_devices && !i8042_pnp_aux_devices) {
  263. i8042_pnp_exit();
  264. #if defined(__ia64__)
  265. return -ENODEV;
  266. #else
  267. printk(KERN_INFO "PNP: No PS/2 controller found. Probing ports directly.\n");
  268. return 0;
  269. #endif
  270. }
  271. if (i8042_pnp_kbd_devices)
  272. snprintf(kbd_irq_str, sizeof(kbd_irq_str),
  273. "%d", i8042_pnp_kbd_irq);
  274. if (i8042_pnp_aux_devices)
  275. snprintf(aux_irq_str, sizeof(aux_irq_str),
  276. "%d", i8042_pnp_aux_irq);
  277. printk(KERN_INFO "PNP: PS/2 Controller [%s%s%s] at %#x,%#x irq %s%s%s\n",
  278. i8042_pnp_kbd_name, (i8042_pnp_kbd_devices && i8042_pnp_aux_devices) ? "," : "",
  279. i8042_pnp_aux_name,
  280. i8042_pnp_data_reg, i8042_pnp_command_reg,
  281. kbd_irq_str, (i8042_pnp_kbd_devices && i8042_pnp_aux_devices) ? "," : "",
  282. aux_irq_str);
  283. #if defined(__ia64__)
  284. if (!i8042_pnp_kbd_devices)
  285. i8042_nokbd = 1;
  286. if (!i8042_pnp_aux_devices)
  287. i8042_noaux = 1;
  288. #endif
  289. if (((i8042_pnp_data_reg & ~0xf) == (i8042_data_reg & ~0xf) &&
  290. i8042_pnp_data_reg != i8042_data_reg) || !i8042_pnp_data_reg) {
  291. printk(KERN_WARNING "PNP: PS/2 controller has invalid data port %#x; using default %#x\n",
  292. i8042_pnp_data_reg, i8042_data_reg);
  293. i8042_pnp_data_reg = i8042_data_reg;
  294. }
  295. if (((i8042_pnp_command_reg & ~0xf) == (i8042_command_reg & ~0xf) &&
  296. i8042_pnp_command_reg != i8042_command_reg) || !i8042_pnp_command_reg) {
  297. printk(KERN_WARNING "PNP: PS/2 controller has invalid command port %#x; using default %#x\n",
  298. i8042_pnp_command_reg, i8042_command_reg);
  299. i8042_pnp_command_reg = i8042_command_reg;
  300. }
  301. if (!i8042_nokbd && !i8042_pnp_kbd_irq) {
  302. printk(KERN_WARNING "PNP: PS/2 controller doesn't have KBD irq; using default %d\n", i8042_kbd_irq);
  303. i8042_pnp_kbd_irq = i8042_kbd_irq;
  304. }
  305. if (!i8042_noaux && !i8042_pnp_aux_irq) {
  306. printk(KERN_WARNING "PNP: PS/2 controller doesn't have AUX irq; using default %d\n", i8042_aux_irq);
  307. i8042_pnp_aux_irq = i8042_aux_irq;
  308. }
  309. i8042_data_reg = i8042_pnp_data_reg;
  310. i8042_command_reg = i8042_pnp_command_reg;
  311. i8042_kbd_irq = i8042_pnp_kbd_irq;
  312. i8042_aux_irq = i8042_pnp_aux_irq;
  313. return 0;
  314. }
  315. #else
  316. static inline int i8042_pnp_init(void) { return 0; }
  317. static inline void i8042_pnp_exit(void) { }
  318. #endif
  319. static int __init i8042_platform_init(void)
  320. {
  321. int retval;
  322. /*
  323. * On ix86 platforms touching the i8042 data register region can do really
  324. * bad things. Because of this the region is always reserved on ix86 boxes.
  325. *
  326. * if (!request_region(I8042_DATA_REG, 16, "i8042"))
  327. * return -EBUSY;
  328. */
  329. i8042_kbd_irq = I8042_MAP_IRQ(1);
  330. i8042_aux_irq = I8042_MAP_IRQ(12);
  331. retval = i8042_pnp_init();
  332. if (retval)
  333. return retval;
  334. #if defined(__ia64__)
  335. i8042_reset = 1;
  336. #endif
  337. #if defined(__i386__)
  338. if (dmi_check_system(i8042_dmi_noloop_table))
  339. i8042_noloop = 1;
  340. if (dmi_check_system(i8042_dmi_nomux_table))
  341. i8042_nomux = 1;
  342. #endif
  343. return retval;
  344. }
  345. static inline void i8042_platform_exit(void)
  346. {
  347. i8042_pnp_exit();
  348. }
  349. #endif /* _I8042_X86IA64IO_H */