i8042.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * (C) Copyright 2002 ELTEC Elektronik AG
  3. * Frank Gottschling <fgottschling@eltec.de>
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. /* i8042.h - Intel 8042 keyboard driver header */
  8. #ifndef _I8042_H_
  9. #define _I8042_H_
  10. /* defines */
  11. #define I8042_DATA_REG 0x60 /* keyboard i/o buffer */
  12. #define I8042_STS_REG 0x64 /* keyboard status read */
  13. #define I8042_CMD_REG 0x64 /* keyboard ctrl write */
  14. /* Status register bit defines */
  15. #define STATUS_OBF (1 << 0)
  16. #define STATUS_IBF (1 << 1)
  17. /* Configuration byte bit defines */
  18. #define CONFIG_KIRQ_EN (1 << 0)
  19. #define CONFIG_MIRQ_EN (1 << 1)
  20. #define CONFIG_SET_BIST (1 << 2)
  21. #define CONFIG_KCLK_DIS (1 << 4)
  22. #define CONFIG_MCLK_DIS (1 << 5)
  23. #define CONFIG_AT_TRANS (1 << 6)
  24. /* i8042 commands */
  25. #define CMD_RD_CONFIG 0x20 /* read configuration byte */
  26. #define CMD_WR_CONFIG 0x60 /* write configuration byte */
  27. #define CMD_SELF_TEST 0xaa /* controller self-test */
  28. #define CMD_KBD_DIS 0xad /* keyboard disable */
  29. #define CMD_KBD_EN 0xae /* keyboard enable */
  30. #define CMD_SET_KBD_LED 0xed /* set keyboard led */
  31. #define CMD_DRAIN_OUTPUT 0xf4 /* drain output buffer */
  32. #define CMD_RESET_KBD 0xff /* reset keyboard */
  33. /* i8042 command result */
  34. #define KBC_TEST_OK 0x55
  35. #define KBD_ACK 0xfa
  36. #define KBD_POR 0xaa
  37. /* keyboard scan codes */
  38. #define KBD_US 0 /* default US layout */
  39. #define KBD_GER 1 /* german layout */
  40. #define KBD_TIMEOUT 1000 /* 1 sec */
  41. #define KBD_RESET_TRIES 3
  42. #define AS 0 /* normal character index */
  43. #define SH 1 /* shift index */
  44. #define CN 2 /* control index */
  45. #define NM 3 /* numeric lock index */
  46. #define AK 4 /* right alt key */
  47. #define CP 5 /* capslock index */
  48. #define ST 6 /* stop output index */
  49. #define EX 7 /* extended code index */
  50. #define ES 8 /* escape and extended code index */
  51. #define NORMAL 0x0000 /* normal key */
  52. #define STP 0x0001 /* scroll lock stop output*/
  53. #define NUM 0x0002 /* numeric lock */
  54. #define CAPS 0x0004 /* capslock */
  55. #define SHIFT 0x0008 /* shift */
  56. #define CTRL 0x0010 /* control*/
  57. #define EXT 0x0020 /* extended scan code 0xe0 */
  58. #define ESC 0x0040 /* escape key press */
  59. #define E1 0x0080 /* extended scan code 0xe1 */
  60. #define BRK 0x0100 /* make break flag for keyboard */
  61. #define ALT 0x0200 /* right alt */
  62. /* exports */
  63. /**
  64. * Flush all buffer from keyboard controller to host.
  65. */
  66. void i8042_flush(void);
  67. /**
  68. * Disables the keyboard so that key strokes no longer generate scancodes to
  69. * the host.
  70. *
  71. * @return 0 if ok, -1 if keyboard input was found while disabling
  72. */
  73. int i8042_disable(void);
  74. #endif /* _I8042_H_ */