i8042-io.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. #ifndef _I8042_IO_H
  3. #define _I8042_IO_H
  4. /*
  5. * Names.
  6. */
  7. #define I8042_KBD_PHYS_DESC "isa0060/serio0"
  8. #define I8042_AUX_PHYS_DESC "isa0060/serio1"
  9. #define I8042_MUX_PHYS_DESC "isa0060/serio%d"
  10. /*
  11. * IRQs.
  12. */
  13. #ifdef __alpha__
  14. # define I8042_KBD_IRQ 1
  15. # define I8042_AUX_IRQ (RTC_PORT(0) == 0x170 ? 9 : 12) /* Jensen is special */
  16. #elif defined(__arm__)
  17. /* defined in include/asm-arm/arch-xxx/irqs.h */
  18. #include <asm/irq.h>
  19. #elif defined(CONFIG_PPC)
  20. extern int of_i8042_kbd_irq;
  21. extern int of_i8042_aux_irq;
  22. # define I8042_KBD_IRQ of_i8042_kbd_irq
  23. # define I8042_AUX_IRQ of_i8042_aux_irq
  24. #else
  25. # define I8042_KBD_IRQ 1
  26. # define I8042_AUX_IRQ 12
  27. #endif
  28. /*
  29. * Register numbers.
  30. */
  31. #define I8042_COMMAND_REG 0x64
  32. #define I8042_STATUS_REG 0x64
  33. #define I8042_DATA_REG 0x60
  34. static inline int i8042_read_data(void)
  35. {
  36. return inb(I8042_DATA_REG);
  37. }
  38. static inline int i8042_read_status(void)
  39. {
  40. return inb(I8042_STATUS_REG);
  41. }
  42. static inline void i8042_write_data(int val)
  43. {
  44. outb(val, I8042_DATA_REG);
  45. }
  46. static inline void i8042_write_command(int val)
  47. {
  48. outb(val, I8042_COMMAND_REG);
  49. }
  50. static inline int i8042_platform_init(void)
  51. {
  52. /*
  53. * On some platforms touching the i8042 data register region can do really
  54. * bad things. Because of this the region is always reserved on such boxes.
  55. */
  56. #if defined(CONFIG_PPC)
  57. if (check_legacy_ioport(I8042_DATA_REG))
  58. return -ENODEV;
  59. #endif
  60. #if !defined(__sh__) && !defined(__alpha__)
  61. if (!request_region(I8042_DATA_REG, 16, "i8042"))
  62. return -EBUSY;
  63. #endif
  64. i8042_reset = I8042_RESET_ALWAYS;
  65. return 0;
  66. }
  67. static inline void i8042_platform_exit(void)
  68. {
  69. #if !defined(__sh__) && !defined(__alpha__)
  70. release_region(I8042_DATA_REG, 16);
  71. #endif
  72. }
  73. #endif /* _I8042_IO_H */