From 7f472114fb3c0c2cc48ec4490ec9cc3d5b41eeef Mon Sep 17 00:00:00 2001 From: Shawn Nematbakhsh Date: Wed, 11 Oct 2017 09:16:15 -0700 Subject: cleanup: Use CONFIG_BATTERY to indicate whether a board has a battery BUG=b:35528297 BRANCH=None TEST=`make buildall -j` Change-Id: I9e4814b4172f20711f7edd691c9569f9130aec8e Signed-off-by: Shawn Nematbakhsh Reviewed-on: https://chromium-review.googlesource.com/713395 Commit-Ready: Shawn N Tested-by: Shawn N Reviewed-by: Randall Spangler --- board/samus/board.h | 1 - common/build.mk | 9 +-------- common/ec_features.c | 5 ++--- include/config.h | 14 +++++++++++++- test/test_config.h | 1 + util/genvif.c | 4 +--- 6 files changed, 18 insertions(+), 16 deletions(-) diff --git a/board/samus/board.h b/board/samus/board.h index 26c06b46af..f21f8a874f 100644 --- a/board/samus/board.h +++ b/board/samus/board.h @@ -40,7 +40,6 @@ #define CONFIG_POWER_BUTTON_X86 /* Note: not CONFIG_BACKLIGHT_LID. It's handled specially for Samus. */ #define CONFIG_BACKLIGHT_REQ_GPIO GPIO_PCH_BL_EN -#define CONFIG_BATTERY_SAMUS /* TODO(crosbug.com/p/29467): remove this workaround when possible. */ #define CONFIG_BATTERY_REQUESTS_NIL_WHEN_DEAD #define CONFIG_CHARGER_PROFILE_OVERRIDE diff --git a/common/build.mk b/common/build.mk index 3f49de0a88..5e779a58c2 100644 --- a/common/build.mk +++ b/common/build.mk @@ -21,14 +21,7 @@ common-$(HAS_TASK_ALS)+=als.o common-$(CONFIG_AP_HANG_DETECT)+=ap_hang_detect.o common-$(CONFIG_BACKLIGHT_LID)+=backlight_lid.o common-$(CONFIG_BASE32)+=base32.o -# TODO(crosbug.com/p/23821): Why do these include battery_common but -# the other batteries don't? Perhaps should use CONFIG_CMD_BATTERY -# instead, since all that's in battery.c is the battery console -# command? -common-$(CONFIG_BATTERY_BQ27541)+=battery.o -common-$(CONFIG_BATTERY_BQ27621)+=battery.o -common-$(CONFIG_BATTERY_MAX17055)+=battery.o -common-$(CONFIG_BATTERY_SMART)+=battery.o +common-$(CONFIG_BATTERY)+=battery.o common-$(CONFIG_BLUETOOTH_LE)+=bluetooth_le.o common-$(CONFIG_BLUETOOTH_LE_STACK)+=btle_hci_controller.o btle_ll.o common-$(CONFIG_BUTTON_COUNT)+=button.o diff --git a/common/ec_features.c b/common/ec_features.c index 01d666a9dc..1340727f41 100644 --- a/common/ec_features.c +++ b/common/ec_features.c @@ -46,8 +46,7 @@ uint32_t get_feature_flags0(void) #ifdef CONFIG_TEMP_SENSOR | EC_FEATURE_MASK_0(EC_FEATURE_THERMAL) #endif -/* Hack to uniquely identify Samus ec */ -#if (defined CONFIG_BACKLIGHT_LID) || (defined CONFIG_BATTERY_SAMUS) +#if (defined CONFIG_BACKLIGHT_LID) || (defined CONFIG_BACKLIGHT_REQ_GPIO) | EC_FEATURE_MASK_0(EC_FEATURE_BKLIGHT_SWITCH) #endif #ifdef CONFIG_WIRELESS @@ -65,7 +64,7 @@ uint32_t get_feature_flags0(void) #ifdef CONFIG_CHARGER | EC_FEATURE_MASK_0(EC_FEATURE_CHARGER) #endif -#if (defined CONFIG_BATTERY) || (defined CONFIG_BATTERY_SMART) +#if (defined CONFIG_BATTERY) | EC_FEATURE_MASK_0(EC_FEATURE_BATTERY) #endif #ifdef CONFIG_BATTERY_SMART diff --git a/include/config.h b/include/config.h index 5709cfe1d2..876ff4f5e8 100644 --- a/include/config.h +++ b/include/config.h @@ -211,12 +211,14 @@ * Note that some boards have their own unique battery constants / functions. * In this case, those are provided in board/(boardname)/battery.c, and none of * these are defined. + * Defining one of these will automatically define CONFIG_BATTERY near the end + * of this file. If you add a new config here, you'll need to update that + * check. */ #undef CONFIG_BATTERY_BQ20Z453 #undef CONFIG_BATTERY_BQ27541 #undef CONFIG_BATTERY_BQ27621 #undef CONFIG_BATTERY_MAX17055 -#undef CONFIG_BATTERY_SAMUS /* Compile mock battery support; used by tests. */ #undef CONFIG_BATTERY_MOCK @@ -3050,6 +3052,16 @@ #define CONFIG_ORIENTATION_SENSOR #endif +/*****************************************************************************/ +/* Define CONFIG_BATTERY if board has a battery. */ +#if defined(CONFIG_BATTERY_BQ20Z453) || \ + defined(CONFIG_BATTERY_BQ27541) || \ + defined(CONFIG_BATTERY_BQ27621) || \ + defined(CONFIG_BATTERY_MAX17055) || \ + defined(CONFIG_BATTERY_SMART) +#define CONFIG_BATTERY +#endif + /*****************************************************************************/ /* * Handle task-dependent configs. diff --git a/test/test_config.h b/test/test_config.h index 20cca9806d..61d04c0658 100644 --- a/test/test_config.h +++ b/test/test_config.h @@ -111,6 +111,7 @@ #endif #ifdef TEST_SBS_CHARGING_V2 +#define CONFIG_BATTERY #define CONFIG_BATTERY_MOCK #define CONFIG_BATTERY_SMART #define CONFIG_CHARGER diff --git a/util/genvif.c b/util/genvif.c index f6b59bc1b6..306784a9bc 100644 --- a/util/genvif.c +++ b/util/genvif.c @@ -175,9 +175,7 @@ static char *sources_vconn(void) static char *battery_powered(void) { -#if defined(CONFIG_BATTERY_BQ20Z453) || defined(CONFIG_BATTERY_BQ27541) || \ - defined(CONFIG_BATTERY_BQ27621) || defined(CONFIG_BATTERY_SAMUS) || \ - defined(CONFIG_BATTERY_SMART) +#ifdef CONFIG_BATTERY return "YES"; #else return "NO"; -- cgit v1.2.1