i8042-sparcio.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. #ifndef _I8042_SPARCIO_H
  2. #define _I8042_SPARCIO_H
  3. #include <linux/config.h>
  4. #include <asm/io.h>
  5. #ifdef CONFIG_PCI
  6. #include <asm/oplib.h>
  7. #include <asm/ebus.h>
  8. #endif
  9. static int i8042_kbd_irq = -1;
  10. static int i8042_aux_irq = -1;
  11. #define I8042_KBD_IRQ i8042_kbd_irq
  12. #define I8042_AUX_IRQ i8042_aux_irq
  13. #define I8042_KBD_PHYS_DESC "sparcps2/serio0"
  14. #define I8042_AUX_PHYS_DESC "sparcps2/serio1"
  15. #define I8042_MUX_PHYS_DESC "sparcps2/serio%d"
  16. static void __iomem *kbd_iobase;
  17. #define I8042_COMMAND_REG (kbd_iobase + 0x64UL)
  18. #define I8042_DATA_REG (kbd_iobase + 0x60UL)
  19. static inline int i8042_read_data(void)
  20. {
  21. return readb(kbd_iobase + 0x60UL);
  22. }
  23. static inline int i8042_read_status(void)
  24. {
  25. return readb(kbd_iobase + 0x64UL);
  26. }
  27. static inline void i8042_write_data(int val)
  28. {
  29. writeb(val, kbd_iobase + 0x60UL);
  30. }
  31. static inline void i8042_write_command(int val)
  32. {
  33. writeb(val, kbd_iobase + 0x64UL);
  34. }
  35. #define OBP_PS2KBD_NAME1 "kb_ps2"
  36. #define OBP_PS2KBD_NAME2 "keyboard"
  37. #define OBP_PS2MS_NAME1 "kdmouse"
  38. #define OBP_PS2MS_NAME2 "mouse"
  39. static int i8042_platform_init(void)
  40. {
  41. #ifndef CONFIG_PCI
  42. return -1;
  43. #else
  44. char prop[128];
  45. int len;
  46. len = prom_getproperty(prom_root_node, "name", prop, sizeof(prop));
  47. if (len < 0) {
  48. printk("i8042: Cannot get name property of root OBP node.\n");
  49. return -1;
  50. }
  51. if (strncmp(prop, "SUNW,JavaStation-1", len) == 0) {
  52. /* Hardcoded values for MrCoffee. */
  53. i8042_kbd_irq = i8042_aux_irq = 13 | 0x20;
  54. kbd_iobase = ioremap(0x71300060, 8);
  55. if (!kbd_iobase)
  56. return -1;
  57. } else {
  58. struct linux_ebus *ebus;
  59. struct linux_ebus_device *edev;
  60. struct linux_ebus_child *child;
  61. for_each_ebus(ebus) {
  62. for_each_ebusdev(edev, ebus) {
  63. if (!strcmp(edev->prom_name, "8042"))
  64. goto edev_found;
  65. }
  66. }
  67. return -1;
  68. edev_found:
  69. for_each_edevchild(edev, child) {
  70. if (!strcmp(child->prom_name, OBP_PS2KBD_NAME1) ||
  71. !strcmp(child->prom_name, OBP_PS2KBD_NAME2)) {
  72. i8042_kbd_irq = child->irqs[0];
  73. kbd_iobase =
  74. ioremap(child->resource[0].start, 8);
  75. }
  76. if (!strcmp(child->prom_name, OBP_PS2MS_NAME1) ||
  77. !strcmp(child->prom_name, OBP_PS2MS_NAME2))
  78. i8042_aux_irq = child->irqs[0];
  79. }
  80. if (i8042_kbd_irq == -1 ||
  81. i8042_aux_irq == -1) {
  82. printk("i8042: Error, 8042 device lacks both kbd and "
  83. "mouse nodes.\n");
  84. return -1;
  85. }
  86. }
  87. i8042_reset = 1;
  88. return 0;
  89. #endif /* CONFIG_PCI */
  90. }
  91. static inline void i8042_platform_exit(void)
  92. {
  93. #ifdef CONFIG_PCI
  94. iounmap(kbd_iobase);
  95. #endif
  96. }
  97. #endif /* _I8042_SPARCIO_H */