wdenk | 1df49e2 | 2002-09-17 21:37:55 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2002 ELTEC Elektronik AG |
| 3 | * Frank Gottschling <fgottschling@eltec.de> |
| 4 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | 1df49e2 | 2002-09-17 21:37:55 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | /* i8042.h - Intel 8042 keyboard driver header */ |
| 9 | |
| 10 | #ifndef _I8042_H_ |
| 11 | #define _I8042_H_ |
| 12 | |
wdenk | 7a8e9bed | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 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 | |
wdenk | 1df49e2 | 2002-09-17 21:37:55 +0000 | [diff] [blame] | 20 | /* defines */ |
| 21 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 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 */ |
wdenk | 1df49e2 | 2002-09-17 21:37:55 +0000 | [diff] [blame] | 25 | |
Gabe Black | ef94f7f | 2012-10-12 14:02:01 +0000 | [diff] [blame] | 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 | |
wdenk | 1df49e2 | 2002-09-17 21:37:55 +0000 | [diff] [blame] | 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 | |
Louis Yung-Chieh Lo | 45fe668 | 2012-10-11 15:15:51 +0000 | [diff] [blame] | 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 | |
Simon Glass | 709ea54 | 2014-07-23 06:54:59 -0600 | [diff] [blame] | 75 | struct stdio_dev; |
| 76 | |
wdenk | 1df49e2 | 2002-09-17 21:37:55 +0000 | [diff] [blame] | 77 | int i8042_kbd_init(void); |
Simon Glass | 709ea54 | 2014-07-23 06:54:59 -0600 | [diff] [blame] | 78 | int i8042_tstc(struct stdio_dev *dev); |
| 79 | int i8042_getc(struct stdio_dev *dev); |
wdenk | 1df49e2 | 2002-09-17 21:37:55 +0000 | [diff] [blame] | 80 | |
| 81 | #endif /* _I8042_H_ */ |