i8042-sparcio.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. #ifndef _I8042_SPARCIO_H
  2. #define _I8042_SPARCIO_H
  3. #include <linux/of_device.h>
  4. #include <asm/io.h>
  5. #include <asm/oplib.h>
  6. #include <asm/prom.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. #ifdef CONFIG_PCI
  34. static struct resource *kbd_res;
  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 sparc_i8042_probe(struct platform_device *op)
  40. {
  41. struct device_node *dp = op->dev.of_node;
  42. dp = dp->child;
  43. while (dp) {
  44. if (!strcmp(dp->name, OBP_PS2KBD_NAME1) ||
  45. !strcmp(dp->name, OBP_PS2KBD_NAME2)) {
  46. struct platform_device *kbd = of_find_device_by_node(dp);
  47. unsigned int irq = kbd->archdata.irqs[0];
  48. if (irq == 0xffffffff)
  49. irq = op->archdata.irqs[0];
  50. i8042_kbd_irq = irq;
  51. kbd_iobase = of_ioremap(&kbd->resource[0],
  52. 0, 8, "kbd");
  53. kbd_res = &kbd->resource[0];
  54. } else if (!strcmp(dp->name, OBP_PS2MS_NAME1) ||
  55. !strcmp(dp->name, OBP_PS2MS_NAME2)) {
  56. struct platform_device *ms = of_find_device_by_node(dp);
  57. unsigned int irq = ms->archdata.irqs[0];
  58. if (irq == 0xffffffff)
  59. irq = op->archdata.irqs[0];
  60. i8042_aux_irq = irq;
  61. }
  62. dp = dp->sibling;
  63. }
  64. return 0;
  65. }
  66. static int sparc_i8042_remove(struct platform_device *op)
  67. {
  68. of_iounmap(kbd_res, kbd_iobase, 8);
  69. return 0;
  70. }
  71. static const struct of_device_id sparc_i8042_match[] = {
  72. {
  73. .name = "8042",
  74. },
  75. {},
  76. };
  77. MODULE_DEVICE_TABLE(of, sparc_i8042_match);
  78. static struct platform_driver sparc_i8042_driver = {
  79. .driver = {
  80. .name = "i8042",
  81. .of_match_table = sparc_i8042_match,
  82. },
  83. .probe = sparc_i8042_probe,
  84. .remove = sparc_i8042_remove,
  85. };
  86. static int __init i8042_platform_init(void)
  87. {
  88. struct device_node *root = of_find_node_by_path("/");
  89. if (!strcmp(root->name, "SUNW,JavaStation-1")) {
  90. /* Hardcoded values for MrCoffee. */
  91. i8042_kbd_irq = i8042_aux_irq = 13 | 0x20;
  92. kbd_iobase = ioremap(0x71300060, 8);
  93. if (!kbd_iobase)
  94. return -ENODEV;
  95. } else {
  96. int err = platform_driver_register(&sparc_i8042_driver);
  97. if (err)
  98. return err;
  99. if (i8042_kbd_irq == -1 ||
  100. i8042_aux_irq == -1) {
  101. if (kbd_iobase) {
  102. of_iounmap(kbd_res, kbd_iobase, 8);
  103. kbd_iobase = (void __iomem *) NULL;
  104. }
  105. return -ENODEV;
  106. }
  107. }
  108. i8042_reset = I8042_RESET_ALWAYS;
  109. return 0;
  110. }
  111. static inline void i8042_platform_exit(void)
  112. {
  113. struct device_node *root = of_find_node_by_path("/");
  114. if (strcmp(root->name, "SUNW,JavaStation-1"))
  115. platform_driver_unregister(&sparc_i8042_driver);
  116. }
  117. #else /* !CONFIG_PCI */
  118. static int __init i8042_platform_init(void)
  119. {
  120. return -ENODEV;
  121. }
  122. static inline void i8042_platform_exit(void)
  123. {
  124. }
  125. #endif /* !CONFIG_PCI */
  126. #endif /* _I8042_SPARCIO_H */