i8042-ppcio.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. #ifndef _I8042_PPCIO_H
  2. #define _I8042_PPCIO_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. #if defined(CONFIG_WALNUT)
  9. #define I8042_KBD_IRQ 25
  10. #define I8042_AUX_IRQ 26
  11. #define I8042_KBD_PHYS_DESC "walnutps2/serio0"
  12. #define I8042_AUX_PHYS_DESC "walnutps2/serio1"
  13. #define I8042_MUX_PHYS_DESC "walnutps2/serio%d"
  14. extern void *kb_cs;
  15. extern void *kb_data;
  16. #define I8042_COMMAND_REG (*(int *)kb_cs)
  17. #define I8042_DATA_REG (*(int *)kb_data)
  18. static inline int i8042_read_data(void)
  19. {
  20. return readb(kb_data);
  21. }
  22. static inline int i8042_read_status(void)
  23. {
  24. return readb(kb_cs);
  25. }
  26. static inline void i8042_write_data(int val)
  27. {
  28. writeb(val, kb_data);
  29. }
  30. static inline void i8042_write_command(int val)
  31. {
  32. writeb(val, kb_cs);
  33. }
  34. static inline int i8042_platform_init(void)
  35. {
  36. i8042_reset = 1;
  37. return 0;
  38. }
  39. static inline void i8042_platform_exit(void)
  40. {
  41. }
  42. #elif defined(CONFIG_SPRUCE)
  43. #define I8042_KBD_IRQ 22
  44. #define I8042_AUX_IRQ 21
  45. #define I8042_KBD_PHYS_DESC "spruceps2/serio0"
  46. #define I8042_AUX_PHYS_DESC "spruceps2/serio1"
  47. #define I8042_MUX_PHYS_DESC "spruceps2/serio%d"
  48. #define I8042_COMMAND_REG 0xff810000
  49. #define I8042_DATA_REG 0xff810001
  50. static inline int i8042_read_data(void)
  51. {
  52. unsigned long kbd_data;
  53. __raw_writel(0x00000088, 0xff500008);
  54. eieio();
  55. __raw_writel(0x03000000, 0xff50000c);
  56. eieio();
  57. asm volatile("lis 7,0xff88 \n\
  58. lswi 6,7,0x8 \n\
  59. mr %0,6"
  60. : "=r" (kbd_data) :: "6", "7");
  61. __raw_writel(0x00000000, 0xff50000c);
  62. eieio();
  63. return (unsigned char)(kbd_data >> 24);
  64. }
  65. static inline int i8042_read_status(void)
  66. {
  67. unsigned long kbd_status;
  68. __raw_writel(0x00000088, 0xff500008);
  69. eieio();
  70. __raw_writel(0x03000000, 0xff50000c);
  71. eieio();
  72. asm volatile("lis 7,0xff88 \n\
  73. ori 7,7,0x8 \n\
  74. lswi 6,7,0x8 \n\
  75. mr %0,6"
  76. : "=r" (kbd_status) :: "6", "7");
  77. __raw_writel(0x00000000, 0xff50000c);
  78. eieio();
  79. return (unsigned char)(kbd_status >> 24);
  80. }
  81. static inline void i8042_write_data(int val)
  82. {
  83. *((unsigned char *)0xff810000) = (char)val;
  84. }
  85. static inline void i8042_write_command(int val)
  86. {
  87. *((unsigned char *)0xff810001) = (char)val;
  88. }
  89. static inline int i8042_platform_init(void)
  90. {
  91. i8042_reset = 1;
  92. return 0;
  93. }
  94. static inline void i8042_platform_exit(void)
  95. {
  96. }
  97. #else
  98. #include "i8042-io.h"
  99. #endif
  100. #endif /* _I8042_PPCIO_H */