summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Hendricks <dhendrix@chromium.org>2012-02-07 14:30:03 -0800
committerDavid Hendricks <dhendrix@chromium.org>2012-02-15 18:20:28 -0800
commit05f0eb3005934c1d6593066555e175d96148953f (patch)
tree497561547560be70e16e185db24d8e32d2a89d7e
parent30fc5d72849de5fc791db06b432969096f76469c (diff)
downloadchrome-ec-05f0eb3005934c1d6593066555e175d96148953f.tar.gz
Make i8042 independent of host <--> KBC bus.
This CL attempts to abstract underlying bus from i8042 code. Nearly all i8042 logic is isolated already. This patch is intended to allow us to use i8042 logic for processing keys and commands on boards which do not necessarily use LPC as the host <--> KBC bus interface. This CL does the following: - Define KBC bus <--> host (kbc_host_bus) on a per-board basis in board.c. - Add generic wrappers in place of lpc_keyboard_* in i8042 code. - Define the behavior of generic wrappers in EC-specific keyboard sources. If board.c specifies LPC, then send via LPC. TODO: This needs to be tested on real hardware... Signed-off-by: David Hendricks <dhendrix@chromium.org> BUG=None TEST=Locally compiled for Link, BDS and Discovery. Change-Id: I9cabd514bd44fd6b508c26994eccc3011eedbc0f
-rw-r--r--board/bds/board.h3
-rw-r--r--board/discovery/board.c1
-rw-r--r--board/discovery/board.h3
-rw-r--r--board/link/board.h3
-rw-r--r--chip/lm4/keyboard_scan.c21
-rw-r--r--common/i8042.c5
-rw-r--r--include/keyboard.h5
7 files changed, 37 insertions, 4 deletions
diff --git a/board/bds/board.h b/board/bds/board.h
index 854650aa37..7bd484edaf 100644
--- a/board/bds/board.h
+++ b/board/bds/board.h
@@ -72,6 +72,9 @@ enum adc_channel
#define KB_SCAN_ROW_IRQ LM4_IRQ_GPIOH
#define KB_SCAN_ROW_GPIO LM4_GPIO_H
+/* Host connects to keyboard controller module via LPC */
+#define HOST_KB_BUS_LPC
+
/* USB charge port */
#define USB_CHARGE_PORT_COUNT 0
diff --git a/board/discovery/board.c b/board/discovery/board.c
index e516dc4278..4b4cd676ca 100644
--- a/board/discovery/board.c
+++ b/board/discovery/board.c
@@ -5,7 +5,6 @@
/* STM32L Discovery board-specific configuration */
#include "board.h"
-#include "common.h"
#include "gpio.h"
#include "registers.h"
#include "util.h"
diff --git a/board/discovery/board.h b/board/discovery/board.h
index 72fca4690a..69cc237d62 100644
--- a/board/discovery/board.h
+++ b/board/discovery/board.h
@@ -16,6 +16,9 @@
#define USB_CHARGE_PORT_COUNT 0
+/* Host connects to keyboard controller module via I2C */
+#define HOST_KB_BUS_I2C
+
/* GPIO signal list */
enum gpio_signal {
/* Inputs with interrupt handlers are first for efficiency */
diff --git a/board/link/board.h b/board/link/board.h
index 467915817a..eec67588c9 100644
--- a/board/link/board.h
+++ b/board/link/board.h
@@ -96,6 +96,9 @@ enum adc_channel
#define KB_SCAN_ROW_IRQ LM4_IRQ_GPION
#define KB_SCAN_ROW_GPIO LM4_GPIO_N
+/* Host connects to keyboard controller module via LPC */
+#define HOST_KB_BUS_LPC
+
/* USB charge port */
#define USB_CHARGE_PORT_COUNT 2
diff --git a/chip/lm4/keyboard_scan.c b/chip/lm4/keyboard_scan.c
index 08456f2333..3da4cbbf13 100644
--- a/chip/lm4/keyboard_scan.c
+++ b/chip/lm4/keyboard_scan.c
@@ -9,6 +9,9 @@
#include "console.h"
#include "keyboard.h"
#include "keyboard_scan.h"
+#ifdef HOST_KB_BUS_LPC
+#include "lpc.h"
+#endif
#include "registers.h"
#include "task.h"
#include "timer.h"
@@ -393,3 +396,21 @@ static void matrix_interrupt(void)
}
}
DECLARE_IRQ(KB_SCAN_ROW_IRQ, matrix_interrupt, 3);
+
+int keyboard_has_char()
+{
+#if defined(HOST_KB_BUS_LPC)
+ return lpc_keyboard_has_char();
+#else
+#error "keyboard_scan needs to know what bus to use for keyboard interface"
+#endif
+}
+
+void keyboard_put_char(uint8_t chr, int send_irq)
+{
+#if defined(HOST_KB_BUS_LPC)
+ lpc_keyboard_put_char(chr, send_irq);
+#else
+#error "keyboard_scan needs to know what bus to use for keyboard interface"
+#endif
+}
diff --git a/common/i8042.c b/common/i8042.c
index 785e6a761e..da4f7ea2ac 100644
--- a/common/i8042.c
+++ b/common/i8042.c
@@ -9,7 +9,6 @@
#include "common.h"
#include "i8042.h"
#include "keyboard.h"
-#include "lpc.h"
#include "task.h"
#include "timer.h"
#include "uart.h"
@@ -115,7 +114,7 @@ void i8042_command_task(void)
/* if the host still didn't read that away,
try next time. */
- if (lpc_keyboard_has_char()) {
+ if (keyboard_has_char()) {
#if I8042_DEBUG >= 5
uart_printf("[%d] i8042_command_task() "
"cannot send to host due to host "
@@ -132,7 +131,7 @@ void i8042_command_task(void)
/* end of atomic protection */
/* Write to host. */
- lpc_keyboard_put_char(chr, i8042_irq_enabled);
+ keyboard_put_char(chr, i8042_irq_enabled);
#if I8042_DEBUG >= 4
uart_printf("[%d] i8042_command_task() "
"sends to host: 0x%02x\n",
diff --git a/include/keyboard.h b/include/keyboard.h
index b00ebfe05e..f715ab2bba 100644
--- a/include/keyboard.h
+++ b/include/keyboard.h
@@ -95,5 +95,10 @@ enum ec_error_list keyboard_register_callback(keyboard_callback cb);
*/
enum ec_error_list keyboard_get_state(uint8_t *bit_array);
+/* Return true if the TOH is still set */
+extern int keyboard_has_char(void);
+
+extern void keyboard_put_char(uint8_t chr, int send_irq);
+
#endif /* __INCLUDE_KEYBOARD_H */