diff options
author | Ronald G. Minnich <rminnich@gmail.com> | 2003-09-26 15:24:54 +0000 |
---|---|---|
committer | Ronald G. Minnich <rminnich@gmail.com> | 2003-09-26 15:24:54 +0000 |
commit | ef5f21807ac7ca8f0553df1867bfd1c225a82f46 (patch) | |
tree | ae3cc21e2853e8c551d0ed571a9c46ebd0293980 /src | |
parent | e1313fa183dc7bb2806b298e110490a9cfec300d (diff) |
keyboard support
git-svn-id: svn://svn.coreboot.org/coreboot/trunk@1146 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'src')
-rw-r--r-- | src/pc80/Config.lb | 6 | ||||
-rw-r--r-- | src/pc80/keyboard.c | 55 |
2 files changed, 60 insertions, 1 deletions
diff --git a/src/pc80/Config.lb b/src/pc80/Config.lb index 876e902f82..f04ada0e42 100644 --- a/src/pc80/Config.lb +++ b/src/pc80/Config.lb @@ -1,6 +1,6 @@ uses CONFIG_IDE_STREAM +uses CONFIG_KEYBOARD -#object keyboard.o object mc146818rtc.o #object isa-dma.o #object i8259.o CONFIG_I8259 @@ -14,3 +14,7 @@ object mc146818rtc.o if CONFIG_IDE_STREAM dir ide end + +if CONFIG_KEYBOARD + object keyboard.o +end diff --git a/src/pc80/keyboard.c b/src/pc80/keyboard.c new file mode 100644 index 0000000000..9dc56b5698 --- /dev/null +++ b/src/pc80/keyboard.c @@ -0,0 +1,55 @@ +#ifndef lint +static char rcsid[] = "$Id$"; +#endif + +#include <arch/io.h> +#include <subr.h> +/* much better keyboard init courtesy ollie@sis.com.tw + TODO: Typematic Setting, the keyboard is too slow for me */ +void pc_keyboard_init() +{ + volatile unsigned char regval; + + /* send cmd = 0xAA, self test 8042 */ + outb(0xaa, 0x64); + + /* empty input buffer or any other command/data will be lost */ + while ((inb(0x64) & 0x02)) + post_code(0); + /* empty output buffer or any other command/data will be lost */ + while ((inb(0x64) & 0x01) == 0) + post_code(1); + + /* read self-test result, 0x55 should be returned form 0x60 */ + if ((regval = inb(0x60) != 0x55)) + return; + + /* enable keyboard interface */ + outb(0x60, 0x64); + while ((inb(0x64) & 0x02)) + post_code(2); + + /* send cmd: enable IRQ 1 */ + outb(0x61, 0x60); + while ((inb(0x64) & 0x02)) + post_code(3); + + /* reset kerboard and self test (keyboard side) */ + outb(0xff, 0x60); + + /* empty inut bufferm or any other command/data will be lost */ + while ((inb(0x64) & 0x02)) + post_code(4); + /* empty output buffer or any other command/data will be lost */ + while ((inb(0x64) & 0x01) == 0) + post_code(5); + + if ((regval = inb(0x60) != 0xfa)) + return; + + while ((inb(0x64) & 0x01) == 0) + post_code(6); + if ((regval = inb(0x60) != 0xaa)) + return; +} + |