diff options
author | Nicolas Boichat <drinkcat@chromium.org> | 2017-12-11 15:04:04 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-12-12 03:57:19 -0800 |
commit | 2f4fd74df5af5885a24d2c1ddc9deb71dd874315 (patch) | |
tree | 16ac6f9a219d2f3c15a2aaf776564dcef59c1aaf /board/hammer | |
parent | a7c08b257fff5420a584d0d8ac5529efcc111403 (diff) | |
download | chrome-ec-2f4fd74df5af5885a24d2c1ddc9deb71dd874315.tar.gz |
hammer: Detect backlight circuitry
Pull-down means backlight is present, pull-up means backlight
is absent.
After detection, we still apply internal pull-down on the GPIO,
to make sure old boards with both pull-up and pull-down stuffed
do not always keep backlight on.
BRANCH=none
BUG=b:67722756
TEST=On reworked board with pull-down on backlight pin,
backlight works, and "Backlight present" shown in console.
TEST=On old board with both pull-up and pull-down, backlight is
off by default, and "Backlight not present" shown in console.
Change-Id: I6988c6ef8f4d155a08967db34f72d7ea4c835306
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/538458
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'board/hammer')
-rw-r--r-- | board/hammer/board.c | 30 | ||||
-rw-r--r-- | board/hammer/gpio.inc | 4 |
2 files changed, 31 insertions, 3 deletions
diff --git a/board/hammer/board.c b/board/hammer/board.c index c32341aa01..acb5ccb29d 100644 --- a/board/hammer/board.c +++ b/board/hammer/board.c @@ -37,6 +37,8 @@ #define CROS_EC_SECTION "RO" #endif +#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ## args) + /****************************************************************************** * Define the strings used in our USB descriptors. */ @@ -102,11 +104,32 @@ struct keyboard_scan_config keyscan_config = { /****************************************************************************** * Initialize board. */ +static int has_keyboard_backlight; + static void board_init(void) { + /* Detect keyboard backlight: pull-down means it is present. */ + has_keyboard_backlight = !gpio_get_level(GPIO_KEYBOARD_BACKLIGHT); + CPRINTS("Backlight%s present", has_keyboard_backlight ? "" : " not"); + +#ifdef BOARD_STAFF + if (!has_keyboard_backlight) { + /* + * Earlier staff boards have both PU and PD stuffed, and end up + * being detected as not have keyboard backlight. However, we + * need to enable internal PD on the pin, otherwise backlight + * will always be on. + * TODO(b:67722756): Remove this hack when old boards are + * deprecated. + */ + gpio_set_flags(GPIO_KEYBOARD_BACKLIGHT, + GPIO_PULL_DOWN | GPIO_INPUT); + } +#endif /* BOARD_STAFF */ } -DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); +/* This needs to happen before PWM is initialized. */ +DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_INIT_PWM - 1); void board_config_pre_init(void) { @@ -122,6 +145,11 @@ void board_config_pre_init(void) STM32_SYSCFG_CFGR1 |= (1 << 9) | (1 << 10); /* Remap USART1 RX/TX DMA */ } +int board_has_keyboard_backlight(void) +{ + return has_keyboard_backlight; +} + /* * Side-band USB wake, to be able to wake lid even in deep S3, when USB * controller is off. diff --git a/board/hammer/gpio.inc b/board/hammer/gpio.inc index 1fdf46fa9b..3b16f643ef 100644 --- a/board/hammer/gpio.inc +++ b/board/hammer/gpio.inc @@ -60,9 +60,9 @@ GPIO(EN_PP3300_TP_ODL, PIN(A, 14), GPIO_OUT_LOW) #endif #ifdef BOARD_WHISKERS -GPIO(KEYBOARD_BACKLIGHT, PIN(B, 8), GPIO_OUT_LOW) +GPIO(KEYBOARD_BACKLIGHT, PIN(B, 8), GPIO_INPUT) #else -GPIO(KEYBOARD_BACKLIGHT, PIN(B, 9), GPIO_OUT_LOW) +GPIO(KEYBOARD_BACKLIGHT, PIN(B, 9), GPIO_INPUT) #endif GPIO(WP_L, PIN(A, 13), GPIO_INPUT | GPIO_PULL_UP) |