Skip to content

Commit

Permalink
drivers/ec/wilco: Put keyboard into translated mode
Browse files Browse the repository at this point in the history
This keyboard controller does not come up in translated mode by
default, so if it is not enabled in firmware then it will never
work properly in the Linux kernel because it will be instantiated
as an "AT Raw" keyboard instead of an "AT Translated" keyboard.

In order to be able to remove the keyboard initialization in
firmware we need to set this bit in the command register before
booting to the OS.

It is necessary to call i8042_probe() first or the later functions
will not succeed.

BUG=b:126633269
BRANCH=none
TEST=boot on sarien and ensure keyboard works in the OS.

Change-Id: I394ab1063ce00ef1df3b42c93ff2ba5c56761eec
Signed-off-by: Duncan Laurie <dlaurie@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1491882
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Reviewed-by: Keith Short <keithshort@chromium.org>
  • Loading branch information
iceblink authored and chrome-bot committed Mar 5, 2019
1 parent b80fb0a commit 0227447
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/drivers/ec/wilco/ec.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,25 @@ static int wilco_ec_cleanup_boot(CleanupFunc *cleanup, CleanupType type)
return wilco_ec_exit_firmware(ec);
}

enum {
I8042_CMD_RD_CMD_BYTE = 0x20,
I8042_CMD_WR_CMD_BYTE = 0x60,
I8042_CMD_BYTE_XLATE = (1 << 6),
};

static void wilco_ec_keyboard_setup(void)
{
i8042_probe();

/* Put keyboard into translated mode for the OS */
if (!i8042_cmd(I8042_CMD_RD_CMD_BYTE)) {
int cmd = i8042_read_data_ps2();
cmd |= I8042_CMD_BYTE_XLATE;
if (!i8042_cmd(I8042_CMD_WR_CMD_BYTE))
i8042_write_data(cmd);
}
}

WilcoEc *new_wilco_ec(uint16_t ec_host_base, uint16_t mec_emi_base)
{
WilcoEc *ec;
Expand Down Expand Up @@ -126,6 +145,8 @@ WilcoEc *new_wilco_ec(uint16_t ec_host_base, uint16_t mec_emi_base)
ec->vboot.check_limit_power = vboot_check_limit_power;
ec->vboot.enable_power_button = vboot_enable_power_button;

wilco_ec_keyboard_setup();

printf("Wilco EC [base 0x%x emi 0x%x]\n",
ec_host_base, mec_emi_base);

Expand Down

0 comments on commit 0227447

Please sign in to comment.