summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Palatin <vpalatin@chromium.org>2011-12-07 00:18:39 +0000
committerGerrit <chrome-bot@google.com>2011-12-08 09:08:26 -0800
commitfeebb63ce5a7031bc7b9e6bbfbe7f52c864a3af6 (patch)
tree68d1552ff2022fea7380717fa86963df992f2a1f
parent37044352d10b38aa52ce6572b40fe81fdd83df97 (diff)
add USB keyboard support for vboot.
If the primary input of the device is a USB keyboard (as defined by the FDT) and we are in developer mode, enumerate the USB devices at startup and get key strokes from USB keyboard. The keyboard reading is not working correctly yet on the recovery path due to the USB mass storage polling code doing continuous re-enumeration on the USB controller. BUG=chrome-os-partner:5752 TEST=tested on Stumpy and Lumpy, with and without usb-keyboard set in the device tree, check Ctrl+U, Ctrl+D and space are working as expected. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> Change-Id: Ib46d6086ae5e5ce631d5f91b467f7b2bf90644d0 Reviewed-on: https://gerrit.chromium.org/gerrit/12543 Commit-Ready: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org>
-rw-r--r--board/chromebook-x86/coreboot/coreboot.c17
-rw-r--r--common/cmd_vboot_twostop.c22
2 files changed, 39 insertions, 0 deletions
diff --git a/board/chromebook-x86/coreboot/coreboot.c b/board/chromebook-x86/coreboot/coreboot.c
index e633f3b4b27..8574dad4ca7 100644
--- a/board/chromebook-x86/coreboot/coreboot.c
+++ b/board/chromebook-x86/coreboot/coreboot.c
@@ -36,6 +36,7 @@
#include <chromeos/fdt_decode.h>
#include <chromeos/firmware_storage.h>
#include <chromeos/cros_gpio.h>
+#include <chromeos/crossystem_data.h>
#include <chromeos/common.h>
#include <asm/io.h>
#include <asm/msr.h>
@@ -194,6 +195,22 @@ int board_i8042_skip(void)
return fdt_decode_get_config_int(gd->blob, "skip-i8042", 0);
}
+int board_use_usb_keyboard(int boot_mode)
+{
+ cros_gpio_t devsw;
+
+ /* the keyboard is needed only in developer mode and recovery mode */
+ cros_gpio_fetch(CROS_GPIO_DEVSW, &devsw);
+ if (!devsw.value && (boot_mode != FIRMWARE_TYPE_RECOVERY))
+ return 0;
+
+ /* does this machine have a USB keyboard as primary input ? */
+ if (fdt_decode_get_config_bool(gd->blob, "usb-keyboard"))
+ return 1;
+
+ return 0;
+}
+
#define MTRRphysBase_MSR(reg) (0x200 + 2 * (reg))
#define MTRRphysMask_MSR(reg) (0x200 + 2 * (reg) + 1)
diff --git a/common/cmd_vboot_twostop.c b/common/cmd_vboot_twostop.c
index 3ac71850659..bf19763d0f2 100644
--- a/common/cmd_vboot_twostop.c
+++ b/common/cmd_vboot_twostop.c
@@ -23,6 +23,7 @@
#include <chromeos/hasher_state.h>
#include <chromeos/memory_wipe.h>
#include <chromeos/power_management.h>
+#include <usb.h>
#include <gbb_header.h> /* for GoogleBinaryBlockHeader */
#include <tss_constants.h>
@@ -111,6 +112,18 @@ str_selection(uint32_t selection)
#endif /* VBOOT_DEBUG */
/*
+ * Implement a weak default function for boards that optionally
+ * need to initialize the USB stack to detect their keyboard.
+ */
+int __board_use_usb_keyboard(void)
+{
+ /* default: no USB keyboard as primary input */
+ return 0;
+}
+int board_use_usb_keyboard(int boot_mode)
+ __attribute__((weak, alias("__board_use_usb_keyboard")));
+
+/*
* Check if two stop boot secuence can be interrupted. If configured - use the
* device tree contents to determine it. Some other means (like checking the
* environment) could be added later.
@@ -731,6 +744,15 @@ twostop_boot(void)
/*
* TODO: Now, load drivers for rec/normal/dev main firmware.
*/
+#ifdef CONFIG_USB_KEYBOARD
+ if (board_use_usb_keyboard(boot_mode)) {
+ int cnt;
+ /* enumerate USB devices to find the keyboard */
+ cnt = usb_init();
+ if (cnt >= 0)
+ drv_usb_kbd_init();
+ }
+#endif
VBDEBUG(PREFIX "boot_mode: %d\n", boot_mode);