i8042-sparcio.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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. static struct resource *kbd_res;
  16. #define I8042_COMMAND_REG (kbd_iobase + 0x64UL)
  17. #define I8042_DATA_REG (kbd_iobase + 0x60UL)
  18. static inline int i8042_read_data(void)
  19. {
  20. return readb(kbd_iobase + 0x60UL);
  21. }
  22. static inline int i8042_read_status(void)
  23. {
  24. return readb(kbd_iobase + 0x64UL);
  25. }
  26. static inline void i8042_write_data(int val)
  27. {
  28. writeb(val, kbd_iobase + 0x60UL);
  29. }
  30. static inline void i8042_write_command(int val)
  31. {
  32. writeb(val, kbd_iobase + 0x64UL);
  33. }
  34. #ifdef CONFIG_PCI
  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 __devinit 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 __devexit 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. .owner = THIS_MODULE,
  82. .of_match_table = sparc_i8042_match,
  83. },
  84. .probe = sparc_i8042_probe,
  85. .remove = __devexit_p(sparc_i8042_remove),
  86. };
  87. static int __init i8042_platform_init(void)
  88. {
  89. struct device_node *root = of_find_node_by_path("/");
  90. if (!strcmp(root->name, "SUNW,JavaStation-1")) {
  91. /* Hardcoded values for MrCoffee. */
  92. i8042_kbd_irq = i8042_aux_irq = 13 | 0x20;
  93. kbd_iobase = ioremap(0x71300060, 8);
  94. if (!kbd_iobase)
  95. return -ENODEV;
  96. } else {
  97. int err = platform_driver_register(&sparc_i8042_driver);
  98. if (err)
  99. return err;
  100. if (i8042_kbd_irq == -1 ||
  101. i8042_aux_irq == -1) {
  102. if (kbd_iobase) {
  103. of_iounmap(kbd_res, kbd_iobase, 8);
  104. kbd_iobase = (void __iomem *) NULL;
  105. }
  106. return -ENODEV;
  107. }
  108. }
  109. i8042_reset = 1;
  110. return 0;
  111. }
  112. static inline void i8042_platform_exit(void)
  113. {
  114. struct device_node *root = of_find_node_by_path("/");
  115. if (strcmp(root->name, "SUNW,JavaStation-1"))
  116. platform_driver_unregister(&sparc_i8042_driver);
  117. }
  118. #else /* !CONFIG_PCI */
  119. static int __init i8042_platform_init(void)
  120. {
  121. return -ENODEV;
  122. }
  123. static inline void i8042_platform_exit(void)
  124. {
  125. }
  126. #endif /* !CONFIG_PCI */
  127. #endif /* _I8042_SPARCIO_H */