summaryrefslogtreecommitdiff
path: root/include/charge_state.h
diff options
context:
space:
mode:
authorZhuohao Lee <zhuohao@chromium.org>2022-09-01 12:28:22 +0800
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-09-08 00:35:31 +0000
commit948b420b65eb88eac579dcab343d8d7ab2ddf1a7 (patch)
treeb88f1b57d487fea321336c45121b59b2dfa64c22 /include/charge_state.h
parent37e35d3aff2809c2eda33b053278e918a5e9cdc0 (diff)
downloadchrome-ec-948b420b65eb88eac579dcab343d8d7ab2ddf1a7.tar.gz
charger: support the charger without battery
In order to support the HW design with charger but doesn't include the a battery, we exclude the charge_state_v2.c if we define the CONFIG_CHARGER but not define the CONFIG_BATTERY. Besides, we also implement some default functions to avoid the link error. Note: remove the charge_prevent_power_on from the board.c of rainier/mchpevb1 and use the default function. BUG=b:242949656 BRANCH=none TEST=build pass with 1. CONFIG_CHARGER + CONFIG_BATTERY 2. CONFIG_CHARGER + no CONFIG_BATTERY 3. make buildall Change-Id: I32c9b03aaf87b641af2b337db1f3bae838464a41 Signed-off-by: Zhuohao Lee <zhuohao@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3865186 Reviewed-by: Diana Z <dzigterman@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
Diffstat (limited to 'include/charge_state.h')
-rw-r--r--include/charge_state.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/include/charge_state.h b/include/charge_state.h
index a06f4aa4c8..b29135aa45 100644
--- a/include/charge_state.h
+++ b/include/charge_state.h
@@ -94,7 +94,14 @@ uint32_t charge_get_flags(void);
/**
* Return current battery charge percentage.
*/
+#if defined(CONFIG_BATTERY) || defined(TEST_BUILD)
int charge_get_percent(void);
+#else
+static inline int charge_get_percent(void)
+{
+ return 100;
+}
+#endif
/**
* Return current battery charge if not using charge manager sub-system.
@@ -119,7 +126,7 @@ __override_proto int charge_is_consuming_full_input_current(void);
/**
* Return non-zero if discharging and battery so low we should shut down.
*/
-#ifdef CONFIG_CHARGER
+#if defined(CONFIG_CHARGER) && defined(CONFIG_BATTERY)
int charge_want_shutdown(void);
#else
static inline int charge_want_shutdown(void)
@@ -135,7 +142,14 @@ static inline int charge_want_shutdown(void)
* @param power_button_pressed True if the power-up attempt is caused by a
* power button press.
*/
+#ifdef CONFIG_BATTERY
int charge_prevent_power_on(int power_button_pressed);
+#else
+static inline int charge_prevent_power_on(int power_button_pressed)
+{
+ return 0;
+}
+#endif
/**
* Get the last polled battery/charger temperature.