From 09136dea764dbe482392c29b3c8d1763149df3e6 Mon Sep 17 00:00:00 2001 From: Patrick Georgi Date: Thu, 24 Aug 2017 23:10:53 +0200 Subject: [PATCH] ec_features / coral: Allow disabling keyboard backlight feature Allow reporting that keyboard backlight doesn't exist even when the code is compiled in. Useful if there are multiple device models that should share firmware. BUG=b:64705535 BRANCH=none TEST=none Change-Id: I9c1fc370aedf66ef856a571f73831095d27e3d39 Signed-off-by: Patrick Georgi Reviewed-on: https://chromium-review.googlesource.com/633926 Commit-Ready: Patrick Georgi Tested-by: Patrick Georgi Reviewed-by: Aaron Durbin --- board/coral/board.c | 24 ++++++++++++++++++++++++ board/coral/board.h | 1 + common/ec_features.c | 14 ++++++++++++-- include/board_config.h | 6 ++++++ include/config.h | 6 ++++++ 5 files changed, 49 insertions(+), 2 deletions(-) diff --git a/board/coral/board.c b/board/coral/board.c index 6c1768ce6e..a1ebd18e7b 100644 --- a/board/coral/board.c +++ b/board/coral/board.c @@ -1170,3 +1170,27 @@ struct keyboard_scan_config keyscan_config = { 0xa4, 0xff, 0xfe, 0x55, 0xfa, 0xca /* full set */ }, }; + +uint32_t board_override_feature_flags0(uint32_t flags0) +{ + uint32_t sku = system_get_sku_id(); + + /* + * We always compile in backlight support for coral, but only some + * models come with the hardware. Therefore, check if the current + * device is one of them and return the default value - with backlight + * here. + */ + if (sku == 8) + return flags0; + + // Report that there is no keyboard backlight + flags0 &= ~EC_FEATURE_MASK_0(EC_FEATURE_PWM_KEYB); + + return flags0; +} + +uint32_t board_override_feature_flags1(uint32_t flags1) +{ + return flags1; +} diff --git a/board/coral/board.h b/board/coral/board.h index f0f0f47801..6dccddb61b 100644 --- a/board/coral/board.h +++ b/board/coral/board.h @@ -151,6 +151,7 @@ #define CONFIG_WLAN_POWER_ACTIVE_LOW #define WIRELESS_GPIO_WLAN_POWER GPIO_WIRELESS_GPIO_WLAN_POWER #define CONFIG_PWR_STATE_DISCHARGE_FULL +#define CONFIG_EC_FEATURE_BOARD_OVERRIDE /* * During shutdown sequence TPS65094x PMIC turns off the sensor rails diff --git a/common/ec_features.c b/common/ec_features.c index 9a630e6f17..01d666a9dc 100644 --- a/common/ec_features.c +++ b/common/ec_features.c @@ -6,11 +6,13 @@ /* Present Chrome EC device features to the outside world */ #include "common.h" +#include "config.h" #include "ec_commands.h" +#include "board_config.h" uint32_t get_feature_flags0(void) { - return 0 + uint32_t result = 0 #ifdef CONFIG_FW_LIMITED_IMAGE | EC_FEATURE_MASK_0(EC_FEATURE_LIMITED) #endif @@ -106,9 +108,17 @@ uint32_t get_feature_flags0(void) | EC_FEATURE_MASK_0(EC_FEATURE_DEVICE_EVENT) #endif ; +#ifdef CONFIG_EC_FEATURE_BOARD_OVERRIDE + result = board_override_feature_flags0(result); +#endif + return result; } uint32_t get_feature_flags1(void) { - return 0; + uint32_t result = 0; +#ifdef CONFIG_EC_FEATURE_BOARD_OVERRIDE + result = board_override_feature_flags1(result); +#endif + return result; } diff --git a/include/board_config.h b/include/board_config.h index f408db8cd6..f3f42ea795 100644 --- a/include/board_config.h +++ b/include/board_config.h @@ -61,4 +61,10 @@ void board_before_rsmrst(int rsmrst); */ void chip_pre_init(void); +#ifdef CONFIG_EC_FEATURE_BOARD_OVERRIDE +/* function for board specific overrides to default feature flags */ +uint32_t board_override_feature_flags0(uint32_t flags0); +uint32_t board_override_feature_flags1(uint32_t flags1); +#endif + #endif /* __CROS_EC_BOARD_CONFIG_H */ diff --git a/include/config.h b/include/config.h index 6d7c8439d3..270783ef48 100644 --- a/include/config.h +++ b/include/config.h @@ -1010,6 +1010,12 @@ /* EC capable of sensor speeds up to 200000 mHz */ #define CONFIG_EC_MAX_SENSOR_FREQ_MILLIHZ 200000 +/* + * Allow board to override the feature bitmap provided through host command + * and ACPI. + */ +#undef CONFIG_EC_FEATURE_BOARD_OVERRIDE + /* Support EC chip internal data EEPROM */ #undef CONFIG_EEPROM