From 447b05b8280d2dba9ec4c227e6cd0928e6065c26 Mon Sep 17 00:00:00 2001 From: Randall Spangler Date: Tue, 19 Mar 2013 16:40:23 -0700 Subject: [PATCH] Move asserting host keyboard interrupt signal to keyboard_scan The implementation is identical on all stm32 hardware, so remove all the duplicate copies from board.c files. mccrosskey doesn't have GPIO_EC_INT so stub it out like we do on bds. No functional change, just moving code. BUG=none BRANCH=none TEST=build mccrosskey,daisy,snow,spring Change-Id: I7d4378650d7b4c640c15180c41459a41620f5bd3 Signed-off-by: Randall Spangler Reviewed-on: https://gerrit.chromium.org/gerrit/45920 --- board/daisy/board.c | 6 ------ board/daisy/board.h | 3 --- board/mccroskey/board.c | 7 ++++--- board/mccroskey/board.h | 7 ++++--- board/snow/board.c | 6 ------ board/snow/board.h | 3 --- board/spring/board.c | 6 ------ board/spring/board.h | 3 --- chip/stm32/keyboard_scan.c | 17 +++++++++++++---- include/gpio.h | 4 ++++ 10 files changed, 25 insertions(+), 37 deletions(-) diff --git a/board/daisy/board.c b/board/daisy/board.c index 89652bfb58..0a7b4bf54e 100644 --- a/board/daisy/board.c +++ b/board/daisy/board.c @@ -181,12 +181,6 @@ void configure_board(void) gpio_set_level(GPIO_EC_INT, 1); } -void board_interrupt_host(int active) -{ - /* interrupt host by using active low EC_INT signal */ - gpio_set_level(GPIO_EC_INT, !active); -} - void board_keyboard_suppress_noise(void) { /* notify audio codec of keypress for noise suppression */ diff --git a/board/daisy/board.h b/board/daisy/board.h index 1007a85b35..105cf46111 100644 --- a/board/daisy/board.h +++ b/board/daisy/board.h @@ -113,9 +113,6 @@ void configure_board(void); /* Signal to the AP that keyboard scan data is available */ void board_keyboard_suppress_noise(void); -/* Signal to AP that data is waiting */ -void board_interrupt_host(int active); - /* Auto detect EC i2c host port */ int board_i2c_host_port(void); diff --git a/board/mccroskey/board.c b/board/mccroskey/board.c index 4635908ac3..1e4d9cfa76 100644 --- a/board/mccroskey/board.c +++ b/board/mccroskey/board.c @@ -81,6 +81,10 @@ const struct gpio_info gpio_list[GPIO_COUNT] = { /* FIXME: make this alt. function */ {"BL_PWM", GPIO_A, (1<<1), GPIO_OUTPUT, NULL}, + + /* Unimplemented signals which we need to emulate for now */ + GPIO_SIGNAL_NOT_IMPLEMENTED("EC_INT"), + #if 0 /* Other GPIOs (probably need to be set up below as alt. function) */ {"STM_USBDM", GPIO_A, (1<<11), GPIO_DEFAULT, NULL}, @@ -165,6 +169,3 @@ void kbd_power_on(enum gpio_signal signal) { /* FIXME: this is just a stub for now... */ } - -/* FIXME: this should not be needed on mccroskey. */ -void board_interrupt_host(int active) { } diff --git a/board/mccroskey/board.h b/board/mccroskey/board.h index 83acec968a..b775c66cd9 100644 --- a/board/mccroskey/board.h +++ b/board/mccroskey/board.h @@ -100,6 +100,10 @@ enum gpio_signal { /* FIXME: this will be an alt. function GPIO, so remove it from here */ GPIO_BL_PWM, + + /* Unimplemented GPIOs */ + GPIO_EC_INT, + #if 0 GPIO_STM_USBDM, GPIO_STM_USBDP, @@ -115,9 +119,6 @@ enum gpio_signal { void configure_board(void); -/* FIXME: this should not be needed on mccroskey. */ -void board_interrupt_host(int active); - #endif /* !__ASSEMBLER__ */ #endif /* __BOARD_H */ diff --git a/board/snow/board.c b/board/snow/board.c index bb76860826..cebdcab1fe 100644 --- a/board/snow/board.c +++ b/board/snow/board.c @@ -177,12 +177,6 @@ void configure_board_late(void) #endif } -void board_interrupt_host(int active) -{ - /* interrupt host by using active low EC_INT signal */ - gpio_set_level(GPIO_EC_INT, !active); -} - void board_keyboard_suppress_noise(void) { /* notify audio codec of keypress for noise suppression */ diff --git a/board/snow/board.h b/board/snow/board.h index 5f2bb4c5c9..a0964a8d05 100644 --- a/board/snow/board.h +++ b/board/snow/board.h @@ -124,9 +124,6 @@ void configure_board(void); void configure_board_late(void); -/* Signal to AP that data is waiting */ -void board_interrupt_host(int active); - /* Initialize PMU registers using board settings */ int board_pmu_init(void); diff --git a/board/spring/board.c b/board/spring/board.c index cdb7abe3d7..e4d361a8ae 100644 --- a/board/spring/board.c +++ b/board/spring/board.c @@ -179,12 +179,6 @@ void board_i2c_post_init(int port) } } -void board_interrupt_host(int active) -{ - /* interrupt host by using active low EC_INT signal */ - gpio_set_level(GPIO_EC_INT, !active); -} - static void board_startup_hook(void) { gpio_set_flags(GPIO_SUSPEND_L, INT_BOTH_PULL_UP); diff --git a/board/spring/board.h b/board/spring/board.h index 2b0f62e54a..67f16e9b44 100644 --- a/board/spring/board.h +++ b/board/spring/board.h @@ -146,9 +146,6 @@ enum charging_state; void configure_board(void); -/* Signal to AP that data is waiting */ -void board_interrupt_host(int active); - /* Initialize PMU registers using board settings */ int board_pmu_init(void); diff --git a/chip/stm32/keyboard_scan.c b/chip/stm32/keyboard_scan.c index b684514a62..c8ca6b0698 100644 --- a/chip/stm32/keyboard_scan.c +++ b/chip/stm32/keyboard_scan.c @@ -210,6 +210,15 @@ static void assert_output(int out) } } +/** + * Assert host keyboard interrupt line. + */ +static void set_host_interrupt(int active) +{ + /* interrupt host by using active low EC_INT signal */ + gpio_set_level(GPIO_EC_INT, !active); +} + /* Set up outputs so that we will get an interrupt when any key changed */ void setup_interrupts(void) { @@ -441,7 +450,7 @@ static int check_keys_changed(uint8_t *state) if (check_runtime_keys(state)) return 0; else if (kb_fifo_add(state) == EC_SUCCESS) - board_interrupt_host(1); + set_host_interrupt(1); else CPRINTF("dropped keystroke\n"); } @@ -619,7 +628,7 @@ static int keyboard_get_scan(struct host_cmd_handler_args *args) { kb_fifo_remove(args->response); if (!kb_fifo_entries) - board_interrupt_host(0); + set_host_interrupt(0); args->response_size = KB_OUTPUTS; @@ -668,7 +677,7 @@ void keyboard_send_battery_key() mutex_lock(&scanning_enabled); debounced_state[BATTERY_KEY_COL] ^= BATTERY_KEY_ROW_MASK; if (kb_fifo_add(debounced_state) == EC_SUCCESS) - board_interrupt_host(1); + set_host_interrupt(1); else CPRINTF("dropped battery keystroke\n"); mutex_unlock(&scanning_enabled); @@ -704,7 +713,7 @@ static int command_keyboard_press(int argc, char **argv) debounced_state[c] &= ~(1 << r); if (kb_fifo_add(debounced_state) == EC_SUCCESS) - board_interrupt_host(1); + set_host_interrupt(1); else ccprintf("dropped keystroke\n"); diff --git a/include/gpio.h b/include/gpio.h index 05470b3f1d..9dd97cb3aa 100644 --- a/include/gpio.h +++ b/include/gpio.h @@ -55,7 +55,11 @@ struct gpio_info { extern const struct gpio_info gpio_list[GPIO_COUNT]; /* Macro for signals which don't exist */ +#ifdef CHIP_lm4 #define GPIO_SIGNAL_NOT_IMPLEMENTED(name) {name, LM4_GPIO_A, 0, 0, NULL} +#else +#define GPIO_SIGNAL_NOT_IMPLEMENTED(name) {name, GPIO_A, 0, 0, NULL} +#endif /** * Pre-initialize GPIOs.