summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2023-05-05 16:41:43 -0600
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-05-09 22:29:46 +0000
commitdb79044cfe8eb8e486e8e50cd5bebbdec3a143ec (patch)
tree56cea48c3bfdff97436fd247326426ccc0d4d176
parentbd727adec5fa606d88773035eed12b198e587399 (diff)
downloadchrome-ec-db79044cfe8eb8e486e8e50cd5bebbdec3a143ec.tar.gz
charger: Move setup of input_voltage to charger_base.c
Add a way to set the base input-voltage in the charger_base.c file. Use this for the two accesses required in charger_base.c, thus removing the final two base-related #ifdefs in that file. With this we can drop the inclusion of the ec_ec_comm_client/server headers. This makes no functional change. BUG=b:218332694 TEST=zmake build dev-posix Check size on lux: *** 69552 bytes in flash and 1152 bytes in RAM lux RO **** *** 69460 bytes in flash and 1120 bytes in RAM lux RW **** Check size on brya: *** 33464 bytes in flash and 23136 bytes in RAM brya RO **** *** 33428 bytes in flash and 23136 bytes in RAM brya RW **** Change-Id: I8b747b8d7dbe890ce071027aaeed23b879ae8070 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4510250 Commit-Queue: Simon Glass <sjg@chromium.org> Tested-by: Simon Glass <sjg@chromium.org> Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
-rw-r--r--common/charge_state_v2.c15
-rw-r--r--common/charger_base.c6
-rw-r--r--include/charger_base.h4
3 files changed, 16 insertions, 9 deletions
diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c
index 052d49ea1a..404983d4e8 100644
--- a/common/charge_state_v2.c
+++ b/common/charge_state_v2.c
@@ -17,8 +17,6 @@
#include "common.h"
#include "console.h"
#include "ec_commands.h"
-#include "ec_ec_comm_client.h"
-#include "ec_ec_comm_server.h"
#include "extpower.h"
#include "gpio.h"
#include "hooks.h"
@@ -1106,11 +1104,11 @@ static void charger_setup(const struct charger_info *info)
chg_ctl_mode = CHARGE_CONTROL_NORMAL;
shutdown_target_time.val = 0UL;
battery_seems_dead = 0;
- if (IS_ENABLED(CONFIG_EC_EC_COMM_BATTERY_CLIENT))
+ if (IS_ENABLED(CONFIG_EC_EC_COMM_BATTERY_CLIENT)) {
charger_base_setup();
-#ifdef CONFIG_EC_EC_COMM_BATTERY_CLIENT
- curr.input_voltage = CHARGE_VOLTAGE_UNINITIALIZED;
-#endif
+ charger_base_set_input_voltage(&curr,
+ CHARGE_VOLTAGE_UNINITIALIZED);
+ }
#ifdef CONFIG_OCPC
ocpc_init(&curr.ocpc);
charge_set_active_chg_chip(CHARGE_PORT_NONE);
@@ -1869,9 +1867,8 @@ int charge_set_input_current_limit(int ma, int mv)
if (IS_ENABLED(CONFIG_OCPC))
chgnum = charge_get_active_chg_chip();
-#ifdef CONFIG_EC_EC_COMM_BATTERY_CLIENT
- curr.input_voltage = mv;
-#endif
+ if (IS_ENABLED(CONFIG_EC_EC_COMM_BATTERY_CLIENT))
+ charger_base_set_input_voltage(&curr, mv);
/*
* If battery is not present, we are not locked, and base is not
* connected then allow system to pull as much input current as needed.
diff --git a/common/charger_base.c b/common/charger_base.c
index 6f4f4da917..74a45bb5ea 100644
--- a/common/charger_base.c
+++ b/common/charger_base.c
@@ -677,5 +677,11 @@ int charger_base_get_input_voltage(const struct charge_state_data *curr)
return curr->input_voltage;
}
+void charger_base_set_input_voltage(struct charge_state_data *curr,
+ int input_voltage)
+{
+ curr->input_voltage = input_voltage;
+}
+
/* Reset the base on S5->S0 transition. */
DECLARE_HOOK(HOOK_CHIPSET_STARTUP, board_base_reset, HOOK_PRIO_DEFAULT);
diff --git a/include/charger_base.h b/include/charger_base.h
index 272dde9e26..efe4a6885f 100644
--- a/include/charger_base.h
+++ b/include/charger_base.h
@@ -57,4 +57,8 @@ bool charger_base_charge_near_full(void);
/* Get the base input-voltage */
int charger_base_get_input_voltage(const struct charge_state_data *curr);
+/* Set the input voltage for the base */
+void charger_base_set_input_voltage(struct charge_state_data *curr,
+ int input_voltage);
+
#endif /* __CROS_EC_CHARGER_BASE_H */