blob: 963061920cbb3b94a28f54b0b20699842bf78b0b [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
wdenk7a8e9bed2003-05-31 18:35:21 +000013#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
wdenk1df49e22002-09-17 21:37:55 +000020/* defines */
21
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020022#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 */
wdenk1df49e22002-09-17 21:37:55 +000025
Gabe Blackef94f7f2012-10-12 14:02:01 +000026enum {
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
wdenk1df49e22002-09-17 21:37:55 +000032#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 Lo45fe6682012-10-11 15:15:51 +000062/**
63 * Flush all buffer from keyboard controller to host.
64 */
65void 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 */
73int i8042_disable(void);
74
wdenk1df49e22002-09-17 21:37:55 +000075int i8042_kbd_init(void);
76int i8042_tstc(void);
77int i8042_getc(void);
78
79#endif /* _I8042_H_ */