summaryrefslogtreecommitdiff
path: root/drivers/input
diff options
context:
space:
mode:
authorLouis Yung-Chieh Lo <yjlou@chromium.org>2012-10-11 15:15:51 +0000
committerTom Rini <trini@ti.com>2012-10-19 15:25:43 -0700
commit45fe668f5f6065f37836d5e941f36418fa3676cd (patch)
tree7a99c1a78b68eb0d8430f919d8c731afee8b008d /drivers/input
parent48edb304d05d5d8b410db74f6e497adcfb132430 (diff)
input: i8042: Provide feature to disable keyboard before booting kernel
The BIOS leaves the keyboard enabled during boot time so that any keystroke would interfere kernel driver initialization. Add a way to disable the keyboard to make sure no scancode will be generated during the boot time. Note that the keyboard will be re-enabled again after the kernel driver is up. This code can be called from the board functions. Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org> Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org> Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Tom Rini <trini@ti.com>
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/i8042.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/drivers/input/i8042.c b/drivers/input/i8042.c
index 3a4c467c59..691aabf402 100644
--- a/drivers/input/i8042.c
+++ b/drivers/input/i8042.c
@@ -331,6 +331,44 @@ int __weak board_i8042_skip(void)
return 0;
}
+void i8042_flush(void)
+{
+ int timeout;
+
+ /*
+ * The delay is to give the keyboard controller some time to fill the
+ * next byte.
+ */
+ while (1) {
+ timeout = 100; /* wait for no longer than 100us */
+ while (timeout > 0 && !(in8(I8042_STATUS_REG) & 0x01)) {
+ udelay(1);
+ timeout--;
+ }
+
+ /* Try to pull next byte if not timeout. */
+ if (in8(I8042_STATUS_REG) & 0x01)
+ in8(I8042_DATA_REG);
+ else
+ break;
+ }
+}
+
+int i8042_disable(void)
+{
+ if (kbd_input_empty() == 0)
+ return -1;
+
+ /* Disable keyboard */
+ out8(I8042_COMMAND_REG, 0xad);
+
+ if (kbd_input_empty() == 0)
+ return -1;
+
+ return 0;
+}
+
+
/*******************************************************************************
*
* i8042_kbd_init - reset keyboard and init state flags