libpayload: Remove unnecessary keyboard mode setting code
keyboard_init attempts to read the existing mode register, set the 'XLATE' bit, and write it back. The implementation is buggy because the keyboard may be active at the time we read the mode, and we can misinterpret scancode data as the reply to our command. It leads to problems where the KB gets disabled in firmware. In fact, setting the 'XLATE' bit is completely unnecessary, even if we desire QEMU keyboard support. We already set this bit when we initialize the keyboard in pc_keyboard_init. Basically, this code does nothing (or worse), so just remove it. Change-Id: Iab23f03fa8bced74842c33a7d263de5f449bb983 Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: http://review.coreboot.org/3883 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
This commit is contained in:
parent
5a7e127cd4
commit
dd6c4ec1ed
|
@ -31,11 +31,6 @@
|
||||||
#include <libpayload-config.h>
|
#include <libpayload-config.h>
|
||||||
#include <libpayload.h>
|
#include <libpayload.h>
|
||||||
|
|
||||||
#define I8042_CMD_READ_MODE 0x20
|
|
||||||
#define I8042_CMD_WRITE_MODE 0x60
|
|
||||||
|
|
||||||
#define I8042_MODE_XLATE 0x40
|
|
||||||
|
|
||||||
struct layout_maps {
|
struct layout_maps {
|
||||||
const char *country;
|
const char *country;
|
||||||
const unsigned short map[4][0x57];
|
const unsigned short map[4][0x57];
|
||||||
|
@ -261,40 +256,6 @@ int keyboard_getchar(void)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int keyboard_wait_read(void)
|
|
||||||
{
|
|
||||||
int retries = 10000;
|
|
||||||
|
|
||||||
while(retries-- && !(inb(0x64) & 0x01))
|
|
||||||
udelay(50);
|
|
||||||
|
|
||||||
return (retries <= 0) ? -1 : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int keyboard_wait_write(void)
|
|
||||||
{
|
|
||||||
int retries = 10000;
|
|
||||||
|
|
||||||
while(retries-- && (inb(0x64) & 0x02))
|
|
||||||
udelay(50);
|
|
||||||
|
|
||||||
return (retries <= 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set keyboard layout
|
* Set keyboard layout
|
||||||
* @param country string describing the keyboard layout language.
|
* @param country string describing the keyboard layout language.
|
||||||
|
@ -326,29 +287,16 @@ static struct console_input_driver cons = {
|
||||||
|
|
||||||
void keyboard_init(void)
|
void keyboard_init(void)
|
||||||
{
|
{
|
||||||
u8 mode;
|
|
||||||
map = &keyboard_layouts[0];
|
map = &keyboard_layouts[0];
|
||||||
|
|
||||||
/* If 0x64 returns 0xff, then we have no keyboard
|
/* If 0x64 returns 0xff, then we have no keyboard
|
||||||
* controller */
|
* controller */
|
||||||
|
|
||||||
if (inb(0x64) == 0xFF)
|
if (inb(0x64) == 0xFF)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Empty keyboard buffer */
|
/* Empty keyboard buffer */
|
||||||
while (keyboard_havechar()) keyboard_getchar();
|
while (keyboard_havechar()) keyboard_getchar();
|
||||||
|
|
||||||
/* 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);
|
|
||||||
|
|
||||||
console_add_input_driver(&cons);
|
console_add_input_driver(&cons);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue