summaryrefslogtreecommitdiff
path: root/board/hammer/board.c
diff options
context:
space:
mode:
authorNicolas Boichat <drinkcat@chromium.org>2017-12-11 15:04:04 +0800
committerchrome-bot <chrome-bot@chromium.org>2017-12-12 03:57:19 -0800
commit2f4fd74df5af5885a24d2c1ddc9deb71dd874315 (patch)
tree16ac6f9a219d2f3c15a2aaf776564dcef59c1aaf /board/hammer/board.c
parenta7c08b257fff5420a584d0d8ac5529efcc111403 (diff)
downloadchrome-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/board.c')
-rw-r--r--board/hammer/board.c30
1 files changed, 29 insertions, 1 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.