diff options
-rw-r--r-- | board/bds/board.h | 3 | ||||
-rw-r--r-- | board/discovery/board.c | 1 | ||||
-rw-r--r-- | board/discovery/board.h | 3 | ||||
-rw-r--r-- | board/link/board.h | 3 | ||||
-rw-r--r-- | chip/lm4/keyboard_scan.c | 21 | ||||
-rw-r--r-- | common/i8042.c | 5 | ||||
-rw-r--r-- | include/keyboard.h | 5 |
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 */ |