diff options
author | Jordan Crouse <jordan.crouse@amd.com> | 2008-04-25 23:09:39 +0000 |
---|---|---|
committer | Jordan Crouse <jordan.crouse@amd.com> | 2008-04-25 23:09:39 +0000 |
commit | 63f181f97c0b89f5fe80f96df7b6288a59f5ad42 (patch) | |
tree | 94b8ac341edc88512413adf32922469156c7b268 /payloads/libpayload/drivers/keyboard.c | |
parent | 24a040475918ad2977a52677f59b10f7ce085afc (diff) | |
download | coreboot-63f181f97c0b89f5fe80f96df7b6288a59f5ad42.tar.xz |
libpayload: Enable keyboard translation so that we can use scancode set 1
The qemu keyboard controller defaults to using scancode set 2, we use set 1.
Turn on the translate mode in the keyboard controller to force the issue.
Signed-off-by: Jordan Crouse <jordan.crouse@amd.com>
Acked-by: Peter Stuge <peter@stuge.se>
git-svn-id: svn://svn.coreboot.org/coreboot/trunk@3270 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'payloads/libpayload/drivers/keyboard.c')
-rw-r--r-- | payloads/libpayload/drivers/keyboard.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/payloads/libpayload/drivers/keyboard.c b/payloads/libpayload/drivers/keyboard.c index 1049b9ccec..540936dae5 100644 --- a/payloads/libpayload/drivers/keyboard.c +++ b/payloads/libpayload/drivers/keyboard.c @@ -29,6 +29,11 @@ #include <libpayload.h> +#define I8042_CMD_READ_MODE 0x20 +#define I8042_CMD_WRITE_MODE 0x60 + +#define I8042_MODE_XLATE 0x40 + unsigned char map[2][0x57] = { { 0x00, 0x1B, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, @@ -118,3 +123,54 @@ int keyboard_getchar(void) return ret; } + +static int keyboard_wait_read(void) +{ + int timeout = 10000; + + while(timeout-- && !(inb(0x64) & 0x01)) + udelay(50); + + return (timeout <= 0) ? -1 : 0; +} + +static int keyboard_wait_write(void) +{ + int timeout = 10000; + + while(timeout-- && (inb(0x64) & 0x02)) + udelay(50); + + return (timeout <= 0) ? -1 : 0; +} + +static unsigned char keyboard_get_mode(void) +{ + outb(I8042_CMD_READ_MODE, 0x64); + keyboard_wait_read(); + return inb(0x60); +} + +static void keyboard_set_mode(unsigned char mode) +{ + outb(I8042_CMD_WRITE_MODE, 0x64); + keyboard_wait_write(); + outb(mode, 0x60); +} + +void keyboard_init(void) +{ + u8 mode; + + /* Read the current mode */ + mode = keyboard_get_mode(); + + /* Turn on scancode translate mode so that we can + use the scancode set 1 tables */ + + mode |= I8042_MODE_XLATE; + + /* Write the new mode */ + keyboard_set_mode(mode); +} + |