From cdfbe88e9264cf6eb9de687f83cf0dd0b908f76e Mon Sep 17 00:00:00 2001 From: David Hendricks Date: Tue, 12 Mar 2013 18:35:25 -0700 Subject: [PATCH] stm32: list keyboard output ports on a per-board basis This CL moves the keyboard port listing to board.h for each mainboard to reduce board-specific clutter in keyboard_scan.c. Since the info is now exposed outside of keyboard_scan.c, a more descriptive name was chosen. Note: GPIO_D does not need to be included in this list for any current platform. BUG=none BRANCH=none Test=tested on Snow by pressing all number and letter keys Signed-off-by: David Hendricks Change-Id: I1ce924a41cafae557467997ecba9c5abeed86211 Reviewed-on: https://gerrit.chromium.org/gerrit/45284 Reviewed-by: Vincent Palatin Commit-Queue: David Hendricks Tested-by: David Hendricks --- board/daisy/board.h | 1 + board/snow/board.h | 1 + board/spring/board.h | 1 + chip/stm32/keyboard_scan.c | 12 ++++-------- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/board/daisy/board.h b/board/daisy/board.h index 3194a2de70..0f7f2169a4 100644 --- a/board/daisy/board.h +++ b/board/daisy/board.h @@ -38,6 +38,7 @@ /* EC drives 13 outputs to the keyboard matrix and reads 8 inputs/interrupts */ #define KB_INPUTS 8 #define KB_OUTPUTS 13 +#define KB_OUT_PORT_LIST GPIO_B, GPIO_C /* Charging */ #define CONFIG_SMART_BATTERY diff --git a/board/snow/board.h b/board/snow/board.h index 27837b665a..f7f3683322 100644 --- a/board/snow/board.h +++ b/board/snow/board.h @@ -41,6 +41,7 @@ /* EC drives 13 outputs to the keyboard matrix and reads 8 inputs/interrupts */ #define KB_INPUTS 8 #define KB_OUTPUTS 13 +#define KB_OUT_PORT_LIST GPIO_B, GPIO_C /* Charging */ #define CONFIG_SMART_BATTERY diff --git a/board/spring/board.h b/board/spring/board.h index cc1b675141..1132f759c5 100644 --- a/board/spring/board.h +++ b/board/spring/board.h @@ -44,6 +44,7 @@ /* EC drives 13 outputs to the keyboard matrix and reads 8 inputs/interrupts */ #define KB_INPUTS 8 #define KB_OUTPUTS 13 +#define KB_OUT_PORT_LIST GPIO_B, GPIO_C /* Charging */ #define CONFIG_SMART_BATTERY diff --git a/chip/stm32/keyboard_scan.c b/chip/stm32/keyboard_scan.c index d1e46628ea..f1532f6ec5 100644 --- a/chip/stm32/keyboard_scan.c +++ b/chip/stm32/keyboard_scan.c @@ -69,11 +69,7 @@ struct kbc_gpio { int pin; }; -#if defined(BOARD_daisy) || defined(BOARD_snow) || defined(BOARD_spring) -static const uint32_t ports[] = { GPIO_B, GPIO_C, GPIO_D }; -#else -#error "Need to specify GPIO ports used by keyboard" -#endif +static const uint32_t kb_out_ports[] = { KB_OUT_PORT_LIST }; /* Provide a default function in case the board doesn't have one */ void __board_keyboard_suppress_noise(void) @@ -179,12 +175,12 @@ static void assert_output(int out) { int i, done = 0; - for (i = 0; i < ARRAY_SIZE(ports); i++) { + for (i = 0; i < ARRAY_SIZE(kb_out_ports); i++) { uint32_t bsrr = 0; int j; for (j = GPIO_KB_OUT00; j <= GPIO_KB_OUT12; j++) { - if (gpio_list[j].port != ports[i]) + if (gpio_list[j].port != kb_out_ports[i]) continue; if (out == OUTPUT_ASSERT_ALL) { @@ -207,7 +203,7 @@ static void assert_output(int out) } if (bsrr) - STM32_GPIO_BSRR_OFF(ports[i]) = bsrr; + STM32_GPIO_BSRR_OFF(kb_out_ports[i]) = bsrr; if (done) break;