blob: c48c0573749637830c2b601982df83b903c4423d [file] [log] [blame]
wdenk1df49e22002-09-17 21:37:55 +00001/*
2 * (C) Copyright 2002 ELTEC Elektronik AG
3 * Frank Gottschling <fgottschling@eltec.de>
4 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA
22 */
23
24/* i8042.h - Intel 8042 keyboard driver header */
25
26#ifndef _I8042_H_
27#define _I8042_H_
28
wdenk7a8e9bed2003-05-31 18:35:21 +000029#ifdef __I386__
30#include <common.h>
31#include <asm/io.h>
32#define in8(p) inb(p)
33#define out8(p,v) outb(v,p)
34#endif
35
wdenk1df49e22002-09-17 21:37:55 +000036/* defines */
37
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020038#define I8042_DATA_REG (CONFIG_SYS_ISA_IO + 0x0060) /* keyboard i/o buffer */
39#define I8042_STATUS_REG (CONFIG_SYS_ISA_IO + 0x0064) /* keyboard status read */
40#define I8042_COMMAND_REG (CONFIG_SYS_ISA_IO + 0x0064) /* keyboard ctrl write */
wdenk1df49e22002-09-17 21:37:55 +000041
Gabe Blackef94f7f2012-10-12 14:02:01 +000042enum {
43 /* Output register (I8042_DATA_REG) has data for system */
44 I8042_STATUS_OUT_DATA = 1 << 0,
45 I8042_STATUS_IN_DATA = 1 << 1,
46};
47
wdenk1df49e22002-09-17 21:37:55 +000048#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 */
75
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 +000091int i8042_kbd_init(void);
92int i8042_tstc(void);
93int i8042_getc(void);
94
95#endif /* _I8042_H_ */