blob: 0766488acbb3dcde43bd2e52fa7adb98ccebb91a [file] [log] [blame]
wdenk1df49e22002-09-17 21:37:55 +00001/*
2 * (C) Copyright 2002 ELTEC Elektronik AG
3 * Frank Gottschling <fgottschling@eltec.de>
4 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
wdenk1df49e22002-09-17 21:37:55 +00006 */
7
8/* i8042.h - Intel 8042 keyboard driver header */
9
10#ifndef _I8042_H_
11#define _I8042_H_
12
wdenk1df49e22002-09-17 21:37:55 +000013/* defines */
14
Bin Meng835dd002015-08-24 01:00:05 -070015#define I8042_DATA_REG 0x60 /* keyboard i/o buffer */
16#define I8042_STS_REG 0x64 /* keyboard status read */
17#define I8042_CMD_REG 0x64 /* keyboard ctrl write */
wdenk1df49e22002-09-17 21:37:55 +000018
Bin Meng835dd002015-08-24 01:00:05 -070019/* Status register bit defines */
20#define STATUS_OBF (1 << 0)
21#define STATUS_IBF (1 << 1)
Gabe Blackef94f7f2012-10-12 14:02:01 +000022
Bin Meng835dd002015-08-24 01:00:05 -070023/* Configuration byte bit defines */
24#define CONFIG_KIRQ_EN (1 << 0)
25#define CONFIG_MIRQ_EN (1 << 1)
26#define CONFIG_SET_BIST (1 << 2)
27#define CONFIG_KCLK_DIS (1 << 4)
28#define CONFIG_MCLK_DIS (1 << 5)
29#define CONFIG_AT_TRANS (1 << 6)
wdenk1df49e22002-09-17 21:37:55 +000030
Bin Meng835dd002015-08-24 01:00:05 -070031/* i8042 commands */
32#define CMD_RD_CONFIG 0x20 /* read configuration byte */
33#define CMD_WR_CONFIG 0x60 /* write configuration byte */
34#define CMD_SELF_TEST 0xaa /* controller self-test */
35#define CMD_KBD_DIS 0xad /* keyboard disable */
36#define CMD_KBD_EN 0xae /* keyboard enable */
37#define CMD_SET_KBD_LED 0xed /* set keyboard led */
Simon Glass8226a3e2016-03-11 22:06:50 -070038#define CMD_DRAIN_OUTPUT 0xf4 /* drain output buffer */
Bin Meng835dd002015-08-24 01:00:05 -070039#define CMD_RESET_KBD 0xff /* reset keyboard */
wdenk1df49e22002-09-17 21:37:55 +000040
Bin Meng835dd002015-08-24 01:00:05 -070041/* i8042 command result */
42#define KBC_TEST_OK 0x55
43#define KBD_ACK 0xfa
44#define KBD_POR 0xaa
wdenk1df49e22002-09-17 21:37:55 +000045
Bin Meng835dd002015-08-24 01:00:05 -070046/* keyboard scan codes */
47
48#define KBD_US 0 /* default US layout */
49#define KBD_GER 1 /* german layout */
50
51#define KBD_TIMEOUT 1000 /* 1 sec */
52#define KBD_RESET_TRIES 3
53
54#define AS 0 /* normal character index */
55#define SH 1 /* shift index */
56#define CN 2 /* control index */
57#define NM 3 /* numeric lock index */
58#define AK 4 /* right alt key */
59#define CP 5 /* capslock index */
60#define ST 6 /* stop output index */
61#define EX 7 /* extended code index */
62#define ES 8 /* escape and extended code index */
63
64#define NORMAL 0x0000 /* normal key */
65#define STP 0x0001 /* scroll lock stop output*/
66#define NUM 0x0002 /* numeric lock */
67#define CAPS 0x0004 /* capslock */
68#define SHIFT 0x0008 /* shift */
69#define CTRL 0x0010 /* control*/
70#define EXT 0x0020 /* extended scan code 0xe0 */
71#define ESC 0x0040 /* escape key press */
72#define E1 0x0080 /* extended scan code 0xe1 */
73#define BRK 0x0100 /* make break flag for keyboard */
74#define ALT 0x0200 /* right alt */
wdenk1df49e22002-09-17 21:37:55 +000075
76/* exports */
77
Louis Yung-Chieh Lo45fe6682012-10-11 15:15:51 +000078/**
79 * Flush all buffer from keyboard controller to host.
80 */
81void i8042_flush(void);
82
83/**
84 * Disables the keyboard so that key strokes no longer generate scancodes to
85 * the host.
86 *
87 * @return 0 if ok, -1 if keyboard input was found while disabling
88 */
89int i8042_disable(void);
90
wdenk1df49e22002-09-17 21:37:55 +000091#endif /* _I8042_H_ */