i8042-x86ia64io.h 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  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 = "Toshiba P10",
  116. .matches = {
  117. DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
  118. DMI_MATCH(DMI_PRODUCT_NAME, "Satellite P10"),
  119. },
  120. },
  121. { }
  122. };
  123. #endif
  124. #ifdef CONFIG_PNP
  125. #include <linux/pnp.h>
  126. static int i8042_pnp_kbd_registered;
  127. static int i8042_pnp_aux_registered;
  128. static int i8042_pnp_command_reg;
  129. static int i8042_pnp_data_reg;
  130. static int i8042_pnp_kbd_irq;
  131. static int i8042_pnp_aux_irq;
  132. static char i8042_pnp_kbd_name[32];
  133. static char i8042_pnp_aux_name[32];
  134. static int i8042_pnp_kbd_probe(struct pnp_dev *dev, const struct pnp_device_id *did)
  135. {
  136. if (pnp_port_valid(dev, 0) && pnp_port_len(dev, 0) == 1)
  137. i8042_pnp_data_reg = pnp_port_start(dev,0);
  138. if (pnp_port_valid(dev, 1) && pnp_port_len(dev, 1) == 1)
  139. i8042_pnp_command_reg = pnp_port_start(dev, 1);
  140. if (pnp_irq_valid(dev,0))
  141. i8042_pnp_kbd_irq = pnp_irq(dev, 0);
  142. strncpy(i8042_pnp_kbd_name, did->id, sizeof(i8042_pnp_kbd_name));
  143. if (strlen(pnp_dev_name(dev))) {
  144. strncat(i8042_pnp_kbd_name, ":", sizeof(i8042_pnp_kbd_name));
  145. strncat(i8042_pnp_kbd_name, pnp_dev_name(dev), sizeof(i8042_pnp_kbd_name));
  146. }
  147. return 0;
  148. }
  149. static int i8042_pnp_aux_probe(struct pnp_dev *dev, const struct pnp_device_id *did)
  150. {
  151. if (pnp_port_valid(dev, 0) && pnp_port_len(dev, 0) == 1)
  152. i8042_pnp_data_reg = pnp_port_start(dev,0);
  153. if (pnp_port_valid(dev, 1) && pnp_port_len(dev, 1) == 1)
  154. i8042_pnp_command_reg = pnp_port_start(dev, 1);
  155. if (pnp_irq_valid(dev, 0))
  156. i8042_pnp_aux_irq = pnp_irq(dev, 0);
  157. strncpy(i8042_pnp_aux_name, did->id, sizeof(i8042_pnp_aux_name));
  158. if (strlen(pnp_dev_name(dev))) {
  159. strncat(i8042_pnp_aux_name, ":", sizeof(i8042_pnp_aux_name));
  160. strncat(i8042_pnp_aux_name, pnp_dev_name(dev), sizeof(i8042_pnp_aux_name));
  161. }
  162. return 0;
  163. }
  164. static struct pnp_device_id pnp_kbd_devids[] = {
  165. { .id = "PNP0303", .driver_data = 0 },
  166. { .id = "PNP030b", .driver_data = 0 },
  167. { .id = "", },
  168. };
  169. static struct pnp_driver i8042_pnp_kbd_driver = {
  170. .name = "i8042 kbd",
  171. .id_table = pnp_kbd_devids,
  172. .probe = i8042_pnp_kbd_probe,
  173. };
  174. static struct pnp_device_id pnp_aux_devids[] = {
  175. { .id = "PNP0f03", .driver_data = 0 },
  176. { .id = "PNP0f0b", .driver_data = 0 },
  177. { .id = "PNP0f0e", .driver_data = 0 },
  178. { .id = "PNP0f12", .driver_data = 0 },
  179. { .id = "PNP0f13", .driver_data = 0 },
  180. { .id = "PNP0f19", .driver_data = 0 },
  181. { .id = "PNP0f1c", .driver_data = 0 },
  182. { .id = "SYN0801", .driver_data = 0 },
  183. { .id = "", },
  184. };
  185. static struct pnp_driver i8042_pnp_aux_driver = {
  186. .name = "i8042 aux",
  187. .id_table = pnp_aux_devids,
  188. .probe = i8042_pnp_aux_probe,
  189. };
  190. static void i8042_pnp_exit(void)
  191. {
  192. if (i8042_pnp_kbd_registered) {
  193. i8042_pnp_kbd_registered = 0;
  194. pnp_unregister_driver(&i8042_pnp_kbd_driver);
  195. }
  196. if (i8042_pnp_aux_registered) {
  197. i8042_pnp_aux_registered = 0;
  198. pnp_unregister_driver(&i8042_pnp_aux_driver);
  199. }
  200. }
  201. static int i8042_pnp_init(void)
  202. {
  203. int result_kbd, result_aux;
  204. if (i8042_nopnp) {
  205. printk(KERN_INFO "i8042: PNP detection disabled\n");
  206. return 0;
  207. }
  208. if ((result_kbd = pnp_register_driver(&i8042_pnp_kbd_driver)) >= 0)
  209. i8042_pnp_kbd_registered = 1;
  210. if ((result_aux = pnp_register_driver(&i8042_pnp_aux_driver)) >= 0)
  211. i8042_pnp_aux_registered = 1;
  212. if (result_kbd <= 0 && result_aux <= 0) {
  213. i8042_pnp_exit();
  214. #if defined(__ia64__)
  215. return -ENODEV;
  216. #else
  217. printk(KERN_INFO "PNP: No PS/2 controller found. Probing ports directly.\n");
  218. return 0;
  219. #endif
  220. }
  221. if (((i8042_pnp_data_reg & ~0xf) == (i8042_data_reg & ~0xf) &&
  222. i8042_pnp_data_reg != i8042_data_reg) || !i8042_pnp_data_reg) {
  223. printk(KERN_WARNING "PNP: PS/2 controller has invalid data port %#x; using default %#x\n",
  224. i8042_pnp_data_reg, i8042_data_reg);
  225. i8042_pnp_data_reg = i8042_data_reg;
  226. }
  227. if (((i8042_pnp_command_reg & ~0xf) == (i8042_command_reg & ~0xf) &&
  228. i8042_pnp_command_reg != i8042_command_reg) || !i8042_pnp_command_reg) {
  229. printk(KERN_WARNING "PNP: PS/2 controller has invalid command port %#x; using default %#x\n",
  230. i8042_pnp_command_reg, i8042_command_reg);
  231. i8042_pnp_command_reg = i8042_command_reg;
  232. }
  233. if (!i8042_pnp_kbd_irq) {
  234. printk(KERN_WARNING "PNP: PS/2 controller doesn't have KBD irq; using default %#x\n", i8042_kbd_irq);
  235. i8042_pnp_kbd_irq = i8042_kbd_irq;
  236. }
  237. if (!i8042_pnp_aux_irq) {
  238. printk(KERN_WARNING "PNP: PS/2 controller doesn't have AUX irq; using default %#x\n", i8042_aux_irq);
  239. i8042_pnp_aux_irq = i8042_aux_irq;
  240. }
  241. #if defined(__ia64__)
  242. if (result_aux <= 0)
  243. i8042_noaux = 1;
  244. #endif
  245. i8042_data_reg = i8042_pnp_data_reg;
  246. i8042_command_reg = i8042_pnp_command_reg;
  247. i8042_kbd_irq = i8042_pnp_kbd_irq;
  248. i8042_aux_irq = i8042_pnp_aux_irq;
  249. printk(KERN_INFO "PNP: PS/2 Controller [%s%s%s] at %#x,%#x irq %d%s%d\n",
  250. i8042_pnp_kbd_name, (result_kbd > 0 && result_aux > 0) ? "," : "", i8042_pnp_aux_name,
  251. i8042_data_reg, i8042_command_reg, i8042_kbd_irq,
  252. (result_aux > 0) ? "," : "", i8042_aux_irq);
  253. return 0;
  254. }
  255. #endif
  256. static inline int i8042_platform_init(void)
  257. {
  258. /*
  259. * On ix86 platforms touching the i8042 data register region can do really
  260. * bad things. Because of this the region is always reserved on ix86 boxes.
  261. *
  262. * if (!request_region(I8042_DATA_REG, 16, "i8042"))
  263. * return -1;
  264. */
  265. i8042_kbd_irq = I8042_MAP_IRQ(1);
  266. i8042_aux_irq = I8042_MAP_IRQ(12);
  267. #ifdef CONFIG_PNP
  268. if (i8042_pnp_init())
  269. return -1;
  270. #endif
  271. #if defined(__ia64__)
  272. i8042_reset = 1;
  273. #endif
  274. #if defined(__i386__)
  275. if (dmi_check_system(i8042_dmi_noloop_table))
  276. i8042_noloop = 1;
  277. if (dmi_check_system(i8042_dmi_nomux_table))
  278. i8042_nomux = 1;
  279. #endif
  280. return 0;
  281. }
  282. static inline void i8042_platform_exit(void)
  283. {
  284. #ifdef CONFIG_PNP
  285. i8042_pnp_exit();
  286. #endif
  287. }
  288. #endif /* _I8042_X86IA64IO_H */