xref: /openbmc/u-boot/include/i8042.h (revision da4105df)
1  /*
2   * (C) Copyright 2002 ELTEC Elektronik AG
3   * Frank Gottschling <fgottschling@eltec.de>
4   *
5   * SPDX-License-Identifier:	GPL-2.0+
6   */
7  
8  /* i8042.h - Intel 8042 keyboard driver header */
9  
10  #ifndef _I8042_H_
11  #define _I8042_H_
12  
13  #ifdef __I386__
14  #include <common.h>
15  #include <asm/io.h>
16  #define in8(p) inb(p)
17  #define out8(p,v) outb(v,p)
18  #endif
19  
20  /* defines */
21  
22  #define I8042_DATA_REG      (CONFIG_SYS_ISA_IO + 0x0060)    /* keyboard i/o buffer */
23  #define I8042_STATUS_REG    (CONFIG_SYS_ISA_IO + 0x0064)    /* keyboard status read */
24  #define I8042_COMMAND_REG   (CONFIG_SYS_ISA_IO + 0x0064)    /* keyboard ctrl write */
25  
26  enum {
27  	/* Output register (I8042_DATA_REG) has data for system */
28  	I8042_STATUS_OUT_DATA	= 1 << 0,
29  	I8042_STATUS_IN_DATA	= 1 << 1,
30  };
31  
32  #define KBD_US              0        /* default US layout */
33  #define KBD_GER             1        /* german layout */
34  
35  #define KBD_TIMEOUT         1000     /* 1 sec */
36  #define KBD_RESET_TRIES     3
37  
38  #define AS                  0        /* normal character index */
39  #define SH                  1        /* shift index */
40  #define CN                  2        /* control index */
41  #define NM                  3        /* numeric lock index */
42  #define AK                  4        /* right alt key */
43  #define CP                  5        /* capslock index */
44  #define ST                  6        /* stop output index */
45  #define EX                  7        /* extended code index */
46  #define ES                  8        /* escape and extended code index */
47  
48  #define NORMAL              0x0000    /* normal key */
49  #define STP                 0x0001    /* scroll lock stop output*/
50  #define NUM                 0x0002    /* numeric lock */
51  #define CAPS                0x0004    /* capslock */
52  #define SHIFT               0x0008    /* shift */
53  #define CTRL                0x0010    /* control*/
54  #define EXT                 0x0020    /* extended scan code 0xe0 */
55  #define ESC                 0x0040    /* escape key press */
56  #define E1                  0x0080    /* extended scan code 0xe1 */
57  #define BRK                 0x0100    /* make break flag for keyboard */
58  #define ALT                 0x0200    /* right alt */
59  
60  /* exports */
61  
62  /**
63   * Flush all buffer from keyboard controller to host.
64   */
65  void i8042_flush(void);
66  
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  
75  int i8042_kbd_init(void);
76  int i8042_tstc(void);
77  int i8042_getc(void);
78  
79  #endif /* _I8042_H_ */
80