i8042-x86ia64io.h 8.6 KB

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