i8042-io.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. #if defined(__arm__)
  14. /* defined in include/asm-arm/arch-xxx/irqs.h */
  15. #include <asm/irq.h>
  16. #elif defined(CONFIG_PPC)
  17. extern int of_i8042_kbd_irq;
  18. extern int of_i8042_aux_irq;
  19. # define I8042_KBD_IRQ of_i8042_kbd_irq
  20. # define I8042_AUX_IRQ of_i8042_aux_irq
  21. #else
  22. # define I8042_KBD_IRQ 1
  23. # define I8042_AUX_IRQ 12
  24. #endif
  25. /*
  26. * Register numbers.
  27. */
  28. #define I8042_COMMAND_REG 0x64
  29. #define I8042_STATUS_REG 0x64
  30. #define I8042_DATA_REG 0x60
  31. static inline int i8042_read_data(void)
  32. {
  33. return inb(I8042_DATA_REG);
  34. }
  35. static inline int i8042_read_status(void)
  36. {
  37. return inb(I8042_STATUS_REG);
  38. }
  39. static inline void i8042_write_data(int val)
  40. {
  41. outb(val, I8042_DATA_REG);
  42. }
  43. static inline void i8042_write_command(int val)
  44. {
  45. outb(val, I8042_COMMAND_REG);
  46. }
  47. static inline int i8042_platform_init(void)
  48. {
  49. /*
  50. * On some platforms touching the i8042 data register region can do really
  51. * bad things. Because of this the region is always reserved on such boxes.
  52. */
  53. #if defined(CONFIG_PPC)
  54. if (check_legacy_ioport(I8042_DATA_REG))
  55. return -ENODEV;
  56. #endif
  57. #if !defined(__sh__) && !defined(__alpha__)
  58. if (!request_region(I8042_DATA_REG, 16, "i8042"))
  59. return -EBUSY;
  60. #endif
  61. i8042_reset = I8042_RESET_ALWAYS;
  62. return 0;
  63. }
  64. static inline void i8042_platform_exit(void)
  65. {
  66. #if !defined(__sh__) && !defined(__alpha__)
  67. release_region(I8042_DATA_REG, 16);
  68. #endif
  69. }
  70. #endif /* _I8042_IO_H */