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