summaryrefslogtreecommitdiff
path: root/board/hammer
diff options
context:
space:
mode:
authorNicolas Boichat <drinkcat@chromium.org>2019-10-01 15:27:18 +0800
committerCommit Bot <commit-bot@chromium.org>2019-10-02 12:44:34 +0000
commit8915e19a9b373ad87878d67973be6cdcaf5eb2e1 (patch)
tree1a1ba13290796fc0282f76abf547b46e8b9a5d7d /board/hammer
parentc35ab4daf5c67569cc4d0680eb672ba76e0d455b (diff)
downloadchrome-ec-8915e19a9b373ad87878d67973be6cdcaf5eb2e1.tar.gz
board/hammer: Add variant with backlight totally disabled
Some boards lack the external pull-up to indicate absence of keyboard backlight, so add a new HAS_BACKLIGHT define. Also, remove support for long deprecated early staff boards, and move backlight detection to RW only. BRANCH=none BUG=b:67722756 BUG=b:140596094 TEST=make BOARD=masterball -j Change-Id: I20d83ec9df64e2b00eed2ca540e4d302bbbee4d1 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1833034 Reviewed-by: Wei-Han Chen <stimim@chromium.org> Reviewed-by: Yilun Lin <yllin@chromium.org>
Diffstat (limited to 'board/hammer')
-rw-r--r--board/hammer/board.c29
-rw-r--r--board/hammer/board.h8
-rw-r--r--board/hammer/gpio.inc4
-rw-r--r--board/hammer/variants.h18
4 files changed, 34 insertions, 25 deletions
diff --git a/board/hammer/board.c b/board/hammer/board.c
index aec8f457f4..c8ebbd856e 100644
--- a/board/hammer/board.c
+++ b/board/hammer/board.c
@@ -98,17 +98,13 @@ const struct i2c_port_t i2c_ports[] = {
const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
#endif
-#ifdef BOARD_STAFF
-#define KBLIGHT_PWM_FREQ 100 /* Hz */
-#else
-#define KBLIGHT_PWM_FREQ 50000 /* Hz */
-#endif
-
+#ifdef HAS_BACKLIGHT
/* PWM channels. Must be in the exactly same order as in enum pwm_channel. */
const struct pwm_t pwm_channels[] = {
{STM32_TIM(TIM_KBLIGHT), STM32_TIM_CH(1), 0, KBLIGHT_PWM_FREQ},
};
BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT);
+#endif /* HAS_BACKLIGHT */
int usb_i2c_board_is_enabled(void)
{
@@ -163,29 +159,16 @@ static struct usart_config const ec_ec_usart =
*/
static int has_keyboard_backlight;
+#ifdef SECTION_IS_RW
static void board_init(void)
{
+#ifdef HAS_BACKLIGHT
/* 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");
+#endif /* HAS_BACKLIGHT */
-#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 */
-
-#ifdef SECTION_IS_RW
#ifdef BOARD_WAND
/* USB to serial queues */
queue_init(&ec_ec_comm_slave_input);
@@ -221,10 +204,10 @@ static void board_init(void)
gpio_config_module(MODULE_SPI_MASTER, 1);
spi_enable(CONFIG_SPI_TOUCHPAD_PORT, 1);
#endif /* HAS_SPI_TOUCHPAD */
-#endif /* SECTION_IS_RW */
}
/* This needs to happen before PWM is initialized. */
DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_INIT_PWM - 1);
+#endif /* SECTION_IS_RW */
void board_config_pre_init(void)
{
diff --git a/board/hammer/board.h b/board/hammer/board.h
index 82becc803b..5eca65a6f9 100644
--- a/board/hammer/board.h
+++ b/board/hammer/board.h
@@ -188,7 +188,9 @@
#ifdef SECTION_IS_RW
#define CONFIG_USB_HID
#define CONFIG_USB_HID_KEYBOARD
+#ifdef HAS_BACKLIGHT
#define CONFIG_USB_HID_KEYBOARD_BACKLIGHT
+#endif
#ifndef HAS_NO_TOUCHPAD
#define CONFIG_USB_HID_TOUCHPAD
@@ -215,7 +217,9 @@
#endif
/* Enable PWM */
+#ifdef HAS_BACKLIGHT
#define CONFIG_PWM
+#endif
#ifdef CONFIG_GMR_TABLET_MODE
#define CONFIG_TABLET_MODE
@@ -336,17 +340,19 @@ enum usb_strings {
};
#ifdef SECTION_IS_RW
+#ifdef HAS_BACKLIGHT
enum pwm_channel {
PWM_CH_KBLIGHT = 0,
/* Number of PWM channels */
PWM_CH_COUNT
};
+#endif /* HAS_BACKLIGHT */
enum adc_channel {
/* Number of ADC channels */
ADC_CH_COUNT
};
-#endif
+#endif /* SECTION_IS_RW */
#endif /* !__ASSEMBLER__ */
#endif /* __CROS_EC_BOARD_H */
diff --git a/board/hammer/gpio.inc b/board/hammer/gpio.inc
index a687c44390..a94c0aa7e4 100644
--- a/board/hammer/gpio.inc
+++ b/board/hammer/gpio.inc
@@ -93,7 +93,9 @@ GPIO(EN_PP3300_TP_ODL, PIN(A, 14), GPIO_OUT_LOW)
#endif
#endif /* !HAS_NO_TOUCHPAD */
+#ifdef HAS_BACKLIGHT
GPIO(KEYBOARD_BACKLIGHT, PIN(B, 9), GPIO_INPUT)
+#endif
GPIO(WP_L, PIN(A, 13), GPIO_INPUT | GPIO_PULL_UP)
@@ -131,4 +133,6 @@ ALTERNATE(PIN_MASK(B, 0x0038), 0, MODULE_SPI_MASTER, 0) /* SPI MASTER:PB3/4/5 */
ALTERNATE(PIN_MASK(B, 0x00c0), 1, MODULE_I2C, 0) /* I2C TOUCHPAD: PB6/7 GPIO_ODR_HIGH */
#endif
+#ifdef HAS_BACKLIGHT
ALTERNATE(PIN_MASK(B, 0x0200), 2, MODULE_PWM, GPIO_PULL_DOWN) /* PWM: PB9 */
+#endif
diff --git a/board/hammer/variants.h b/board/hammer/variants.h
index c50d0307cb..ac50e5265b 100644
--- a/board/hammer/variants.h
+++ b/board/hammer/variants.h
@@ -80,11 +80,27 @@
#define CONFIG_KEYBOARD_ASSISTANT_KEY
#endif
-/* Backlight driver */
+/* Backlight */
+#if defined(BOARD_HAMMER) || defined(BOARD_STAFF) || \
+ defined(BOARD_WAND) || defined(BOARD_WHISKERS)
+/*
+ * Even with this option, we detect the backlight presence using a PU/PD on the
+ * PWM pin. Not defining this totally disables support.
+ */
+#define HAS_BACKLIGHT
+
#ifdef BOARD_WHISKERS
#define CONFIG_LED_DRIVER_LM3630A
#endif
+#ifdef BOARD_STAFF
+#define KBLIGHT_PWM_FREQ 100 /* Hz */
+#else
+#define KBLIGHT_PWM_FREQ 50000 /* Hz */
+#endif
+
+#endif /* BOARD_HAMMER/WAND/WHISKERS */
+
/* GMR sensor for tablet mode detection */
#if defined(BOARD_MASTERBALL) || defined(BOARD_WHISKERS)
#define CONFIG_GMR_TABLET_MODE