at_keyboard: Fix falco chromebook case.

EC is slow, so we need few delays for it to toggle the bits correctly.

Command to enable clock and keyboard were not sent.
This commit is contained in:
Vladimir Serbinenko 2017-05-09 14:27:52 +02:00
parent 70b555a52a
commit c4b8bec5fe
2 changed files with 16 additions and 9 deletions

View file

@ -40,6 +40,8 @@ grub_keyboard_controller_init (void);
static void
keyboard_controller_wait_until_ready (void)
{
/* 50 us would be enough but our current time resolution is 1ms. */
grub_millisleep (1);
while (! KEYBOARD_COMMAND_ISREADY (grub_inb (KEYBOARD_REG_STATUS)));
}
@ -50,9 +52,10 @@ wait_ack (void)
grub_uint8_t ack;
endtime = grub_get_time_ms () + 20;
do
do {
keyboard_controller_wait_until_ready ();
ack = grub_inb (KEYBOARD_REG_DATA);
while (ack != GRUB_AT_ACK && ack != GRUB_AT_NACK
} while (ack != GRUB_AT_ACK && ack != GRUB_AT_NACK
&& grub_get_time_ms () < endtime);
return ack;
}
@ -135,12 +138,10 @@ query_mode (void)
if (!e)
return 0;
do {
keyboard_controller_wait_until_ready ();
do
ret = grub_inb (KEYBOARD_REG_DATA);
while (ret == GRUB_AT_ACK);
} while (ret == GRUB_AT_ACK);
/* QEMU translates the set even in no-translate mode. */
if (ret == 0x43 || ret == 1)
return 1;
@ -169,7 +170,11 @@ set_scancodes (void)
#else
grub_keyboard_controller_write (grub_keyboard_controller_orig
& ~KEYBOARD_AT_TRANSLATE);
& ~KEYBOARD_AT_TRANSLATE
& ~KEYBOARD_AT_DISABLE);
keyboard_controller_wait_until_ready ();
grub_outb (KEYBOARD_COMMAND_ENABLE, KEYBOARD_REG_DATA);
write_mode (2);
ps2_state.current_set = query_mode ();

View file

@ -23,9 +23,11 @@
#define KEYBOARD_COMMAND_ISREADY(x) !((x) & 0x02)
#define KEYBOARD_COMMAND_READ 0x20
#define KEYBOARD_COMMAND_WRITE 0x60
#define KEYBOARD_COMMAND_ENABLE 0xf4
#define KEYBOARD_COMMAND_REBOOT 0xfe
#define KEYBOARD_AT_TRANSLATE 0x40
#define KEYBOARD_AT_DISABLE 0x10
#define KEYBOARD_ISMAKE(x) !((x) & 0x80)
#define KEYBOARD_ISREADY(x) ((x) & 0x01)