i8042-sparcio.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. #ifndef _I8042_SPARCIO_H
  2. #define _I8042_SPARCIO_H
  3. #include <asm/io.h>
  4. #include <asm/oplib.h>
  5. #include <asm/prom.h>
  6. #include <asm/of_device.h>
  7. static int i8042_kbd_irq = -1;
  8. static int i8042_aux_irq = -1;
  9. #define I8042_KBD_IRQ i8042_kbd_irq
  10. #define I8042_AUX_IRQ i8042_aux_irq
  11. #define I8042_KBD_PHYS_DESC "sparcps2/serio0"
  12. #define I8042_AUX_PHYS_DESC "sparcps2/serio1"
  13. #define I8042_MUX_PHYS_DESC "sparcps2/serio%d"
  14. static void __iomem *kbd_iobase;
  15. #define I8042_COMMAND_REG (kbd_iobase + 0x64UL)
  16. #define I8042_DATA_REG (kbd_iobase + 0x60UL)
  17. static inline int i8042_read_data(void)
  18. {
  19. return readb(kbd_iobase + 0x60UL);
  20. }
  21. static inline int i8042_read_status(void)
  22. {
  23. return readb(kbd_iobase + 0x64UL);
  24. }
  25. static inline void i8042_write_data(int val)
  26. {
  27. writeb(val, kbd_iobase + 0x60UL);
  28. }
  29. static inline void i8042_write_command(int val)
  30. {
  31. writeb(val, kbd_iobase + 0x64UL);
  32. }
  33. #define OBP_PS2KBD_NAME1 "kb_ps2"
  34. #define OBP_PS2KBD_NAME2 "keyboard"
  35. #define OBP_PS2MS_NAME1 "kdmouse"
  36. #define OBP_PS2MS_NAME2 "mouse"
  37. static int __devinit sparc_i8042_probe(struct of_device *op, const struct of_device_id *match)
  38. {
  39. struct device_node *dp = op->node;
  40. dp = dp->child;
  41. while (dp) {
  42. if (!strcmp(dp->name, OBP_PS2KBD_NAME1) ||
  43. !strcmp(dp->name, OBP_PS2KBD_NAME2)) {
  44. struct of_device *kbd = of_find_device_by_node(dp);
  45. unsigned int irq = kbd->irqs[0];
  46. if (irq == 0xffffffff)
  47. irq = op->irqs[0];
  48. i8042_kbd_irq = irq;
  49. kbd_iobase = of_ioremap(&kbd->resource[0],
  50. 0, 8, "kbd");
  51. } else if (!strcmp(dp->name, OBP_PS2MS_NAME1) ||
  52. !strcmp(dp->name, OBP_PS2MS_NAME2)) {
  53. struct of_device *ms = of_find_device_by_node(dp);
  54. unsigned int irq = ms->irqs[0];
  55. if (irq == 0xffffffff)
  56. irq = op->irqs[0];
  57. i8042_aux_irq = irq;
  58. }
  59. dp = dp->sibling;
  60. }
  61. return 0;
  62. }
  63. static int __devexit sparc_i8042_remove(struct of_device *op)
  64. {
  65. of_iounmap(kbd_iobase, 8);
  66. return 0;
  67. }
  68. static struct of_device_id sparc_i8042_match[] = {
  69. {
  70. .name = "8042",
  71. },
  72. {},
  73. };
  74. MODULE_DEVICE_TABLE(of, sparc_i8042_match);
  75. static struct of_platform_driver sparc_i8042_driver = {
  76. .name = "i8042",
  77. .match_table = sparc_i8042_match,
  78. .probe = sparc_i8042_probe,
  79. .remove = __devexit_p(sparc_i8042_remove),
  80. };
  81. static int __init i8042_platform_init(void)
  82. {
  83. #ifndef CONFIG_PCI
  84. return -ENODEV;
  85. #else
  86. struct device_node *root = of_find_node_by_path("/");
  87. if (!strcmp(root->name, "SUNW,JavaStation-1")) {
  88. /* Hardcoded values for MrCoffee. */
  89. i8042_kbd_irq = i8042_aux_irq = 13 | 0x20;
  90. kbd_iobase = ioremap(0x71300060, 8);
  91. if (!kbd_iobase)
  92. return -ENODEV;
  93. } else {
  94. int err = of_register_driver(&sparc_i8042_driver,
  95. &of_bus_type);
  96. if (err)
  97. return err;
  98. if (i8042_kbd_irq == -1 ||
  99. i8042_aux_irq == -1) {
  100. if (kbd_iobase) {
  101. of_iounmap(kbd_iobase, 8);
  102. kbd_iobase = (void __iomem *) NULL;
  103. }
  104. return -ENODEV;
  105. }
  106. }
  107. i8042_reset = 1;
  108. return 0;
  109. #endif /* CONFIG_PCI */
  110. }
  111. static inline void i8042_platform_exit(void)
  112. {
  113. #ifdef CONFIG_PCI
  114. struct device_node *root = of_find_node_by_path("/");
  115. if (strcmp(root->name, "SUNW,JavaStation-1"))
  116. of_unregister_driver(&sparc_i8042_driver);
  117. #endif
  118. }
  119. #endif /* _I8042_SPARCIO_H */