summaryrefslogtreecommitdiff
path: root/baseboard
diff options
context:
space:
mode:
authorPeter Marheine <pmarheine@chromium.org>2022-11-10 16:37:09 +1100
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-11-23 03:58:51 +0000
commitb75dc90677f29424e6f0d63f294dce4b39782135 (patch)
tree17002ffbd6b6f660b1a5a1a1e1911e741fa4ac73 /baseboard
parentf1b563c350acf6a1b687c682f07770aa8210dc01 (diff)
downloadchrome-ec-b75dc90677f29424e6f0d63f294dce4b39782135.tar.gz
Add CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT
This splits the dual use of CONFIG_CHARGER_INPUT_CURRENT into two different symbols, changing the uses of that which are used to set a minimum current limit to be CONFIG_CHARGER_MAX_INPUT_CURRENT_LIMIT. Most boards implement this in the same way within either the board or baseboard, so handling of the new option is moved into charge_set_input_current_limit (which is called by every user of the option) and every board which repeated this pattern has the new symbol set to the same value as the old one, with the duplicated code deleted. One functional change to the charge manager is made: when charging stops, the input current limit is set to the default value (CONFIG_CHARGER_INPUT_CURRENT) rather than 0. This captures the intent that the default current is appropriate at any time, which was previously configured by individual boards' implementation of board_set_charge_limit() while still allowing the limit to be set lower as needed. To verify that all changes are appropriate, the following has been manually checked: * All boards with a change to a .c file also have a .h change * All boards without a changed .h file have a changed baseboard.h * For Zephyr projects, those with a changed .c file have config added for the minimum limit and others (only corsola) are unchanged to leave it off. This is intended to verify that each board that duplicated the MAX() logic has its configuration updated to use the shared copy, and that boards with that code in the baseboard also update their configuration. BUG=b:163093572 TEST=make buildall; zmake build -a BRANCH=none LOW_COVERAGE_REASON=added lines will soon be deleted Change-Id: Ia460a16293c1fb82aac3784fd9be57ba0985f2fe Signed-off-by: Peter Marheine <pmarheine@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4019703 Reviewed-by: Keith Short <keithshort@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
Diffstat (limited to 'baseboard')
-rw-r--r--baseboard/asurada/baseboard.h1
-rw-r--r--baseboard/asurada/usbc_config.c3
-rw-r--r--baseboard/brya/baseboard.h1
-rw-r--r--baseboard/cherry/baseboard.h1
-rw-r--r--baseboard/dedede/baseboard.h1
-rw-r--r--baseboard/goroh/baseboard.c3
-rw-r--r--baseboard/goroh/baseboard.h1
-rw-r--r--baseboard/grunt/baseboard.c3
-rw-r--r--baseboard/grunt/baseboard.h1
-rw-r--r--baseboard/guybrush/baseboard.c3
-rw-r--r--baseboard/guybrush/baseboard.h1
-rw-r--r--baseboard/hatch/baseboard.c3
-rw-r--r--baseboard/hatch/baseboard.h1
-rw-r--r--baseboard/herobrine/baseboard.h1
-rw-r--r--baseboard/intelrvp/baseboard.h1
-rw-r--r--baseboard/intelrvp/chg_usb_pd.c3
-rw-r--r--baseboard/kukui/baseboard.h1
-rw-r--r--baseboard/octopus/baseboard.c3
-rw-r--r--baseboard/octopus/baseboard.h1
-rw-r--r--baseboard/trogdor/baseboard.h1
-rw-r--r--baseboard/volteer/baseboard.h1
-rw-r--r--baseboard/volteer/charger.c3
-rw-r--r--baseboard/zork/baseboard.c3
-rw-r--r--baseboard/zork/baseboard.h1
24 files changed, 24 insertions, 18 deletions
diff --git a/baseboard/asurada/baseboard.h b/baseboard/asurada/baseboard.h
index b40f2f50de..597515363c 100644
--- a/baseboard/asurada/baseboard.h
+++ b/baseboard/asurada/baseboard.h
@@ -61,6 +61,7 @@
#define CONFIG_CHARGE_RAMP_HW
#define CONFIG_CHARGER_DISCHARGE_ON_AC
#define CONFIG_CHARGER_INPUT_CURRENT 512
+#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512
#define CONFIG_CHARGER_ISL9238C
#define CONFIG_CHARGER_MAINTAIN_VBAT
#define CONFIG_CHARGER_OTG
diff --git a/baseboard/asurada/usbc_config.c b/baseboard/asurada/usbc_config.c
index ecc882659f..57396121f5 100644
--- a/baseboard/asurada/usbc_config.c
+++ b/baseboard/asurada/usbc_config.c
@@ -311,8 +311,7 @@ void board_reset_pd_mcu(void)
void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
int charge_mv)
{
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
+ charge_set_input_current_limit(charge_ma, charge_mv);
}
void board_pd_vconn_ctrl(int port, enum usbpd_cc_pin cc_pin, int enabled)
diff --git a/baseboard/brya/baseboard.h b/baseboard/brya/baseboard.h
index 6748a8a777..b2d722fcd9 100644
--- a/baseboard/brya/baseboard.h
+++ b/baseboard/brya/baseboard.h
@@ -69,6 +69,7 @@
#define CONFIG_CHARGER
#define CONFIG_CHARGER_DISCHARGE_ON_AC
#define CONFIG_CHARGER_INPUT_CURRENT 512
+#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512
#define CONFIG_CMD_CHARGER_DUMP
diff --git a/baseboard/cherry/baseboard.h b/baseboard/cherry/baseboard.h
index de3acda1d3..8cd2aacd1f 100644
--- a/baseboard/cherry/baseboard.h
+++ b/baseboard/cherry/baseboard.h
@@ -71,6 +71,7 @@
#define CONFIG_CHARGE_RAMP_HW
#define CONFIG_CHARGER_DISCHARGE_ON_AC
#define CONFIG_CHARGER_INPUT_CURRENT 512
+#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512
#define CONFIG_CHARGER_ISL9238C
#define CONFIG_CHARGER_MAINTAIN_VBAT
/* Not used in boot flow, set to 0 to suppress system_can_boot_ap warning */
diff --git a/baseboard/dedede/baseboard.h b/baseboard/dedede/baseboard.h
index e581a0e8d0..e03d41ae21 100644
--- a/baseboard/dedede/baseboard.h
+++ b/baseboard/dedede/baseboard.h
@@ -165,6 +165,7 @@
#define CONFIG_CHARGER
#define CONFIG_CHARGER_DISCHARGE_ON_AC
#define CONFIG_CHARGER_INPUT_CURRENT 256
+#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 256
#define CONFIG_USB_CHARGER
#define CONFIG_TRICKLE_CHARGING
diff --git a/baseboard/goroh/baseboard.c b/baseboard/goroh/baseboard.c
index 8422030619..d1474f78a7 100644
--- a/baseboard/goroh/baseboard.c
+++ b/baseboard/goroh/baseboard.c
@@ -163,8 +163,7 @@ const struct cc_para_t *board_get_cc_tuning_parameter(enum usbpd_port port)
void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
int charge_mv)
{
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
+ charge_set_input_current_limit(charge_ma, charge_mv);
}
void board_pd_vconn_ctrl(int port, enum usbpd_cc_pin cc_pin, int enabled)
diff --git a/baseboard/goroh/baseboard.h b/baseboard/goroh/baseboard.h
index 05c26d74a0..205621e040 100644
--- a/baseboard/goroh/baseboard.h
+++ b/baseboard/goroh/baseboard.h
@@ -58,6 +58,7 @@
#define CONFIG_CHARGE_RAMP_HW
#define CONFIG_CHARGER_DISCHARGE_ON_AC
#define CONFIG_CHARGER_INPUT_CURRENT 512
+#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512
#define CONFIG_CHARGER_ISL9238C
#define CONFIG_CHARGER_MAINTAIN_VBAT
#define CONFIG_CHARGER_OTG
diff --git a/baseboard/grunt/baseboard.c b/baseboard/grunt/baseboard.c
index 50db1887f1..aef91f5e30 100644
--- a/baseboard/grunt/baseboard.c
+++ b/baseboard/grunt/baseboard.c
@@ -467,8 +467,7 @@ int board_set_active_charge_port(int port)
void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
int charge_mv)
{
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
+ charge_set_input_current_limit(charge_ma, charge_mv);
}
/* Keyboard scan setting */
diff --git a/baseboard/grunt/baseboard.h b/baseboard/grunt/baseboard.h
index b83b274d49..e385b11b86 100644
--- a/baseboard/grunt/baseboard.h
+++ b/baseboard/grunt/baseboard.h
@@ -73,6 +73,7 @@
* See also b/111214767
*/
#define CONFIG_CHARGER_INPUT_CURRENT 512
+#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512
#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5
#define CONFIG_CHARGER_ISL9238
#define CONFIG_CHARGER_SENSE_RESISTOR 10
diff --git a/baseboard/guybrush/baseboard.c b/baseboard/guybrush/baseboard.c
index 654f73e7fe..b8b4b775a6 100644
--- a/baseboard/guybrush/baseboard.c
+++ b/baseboard/guybrush/baseboard.c
@@ -537,8 +537,7 @@ int board_aoz1380_set_vbus_source_current_limit(int port, enum tcpc_rp_value rp)
void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
int charge_mv)
{
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
+ charge_set_input_current_limit(charge_ma, charge_mv);
}
void sbu_fault_interrupt(enum ioex_signal signal)
diff --git a/baseboard/guybrush/baseboard.h b/baseboard/guybrush/baseboard.h
index 04b1e10c97..883bf27847 100644
--- a/baseboard/guybrush/baseboard.h
+++ b/baseboard/guybrush/baseboard.h
@@ -163,6 +163,7 @@
#define CONFIG_CHARGE_MANAGER
#define CONFIG_CHARGER_DISCHARGE_ON_AC
#define CONFIG_CHARGER_INPUT_CURRENT 512
+#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512
#define CONFIG_CHARGER_ISL9241
#define CONFIG_CHARGER_SENSE_RESISTOR 10
#define CONFIG_CHARGER_SENSE_RESISTOR_AC 20
diff --git a/baseboard/hatch/baseboard.c b/baseboard/hatch/baseboard.c
index f5376700c5..9910f21880 100644
--- a/baseboard/hatch/baseboard.c
+++ b/baseboard/hatch/baseboard.c
@@ -351,8 +351,7 @@ int ppc_get_alert_status(int port)
void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
int charge_mv)
{
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
+ charge_set_input_current_limit(charge_ma, charge_mv);
}
#ifdef USB_PD_PORT_TCPC_MST
diff --git a/baseboard/hatch/baseboard.h b/baseboard/hatch/baseboard.h
index d5d680e7bf..9ba148e91e 100644
--- a/baseboard/hatch/baseboard.h
+++ b/baseboard/hatch/baseboard.h
@@ -97,6 +97,7 @@
#define CONFIG_CHARGER_BQ25710
#define CONFIG_CHARGER_DISCHARGE_ON_AC
#define CONFIG_CHARGER_INPUT_CURRENT 512 /* Allow low-current USB charging */
+#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512
#undef CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON
#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 1
#define CONFIG_CHARGE_RAMP_HW
diff --git a/baseboard/herobrine/baseboard.h b/baseboard/herobrine/baseboard.h
index 0782612cb8..b1aabc6bd6 100644
--- a/baseboard/herobrine/baseboard.h
+++ b/baseboard/herobrine/baseboard.h
@@ -89,6 +89,7 @@
#define CONFIG_CHARGER_DISCHARGE_ON_AC
#define CONFIG_CHARGER_INPUT_CURRENT 512
+#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512
#define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON 10000
#define CONFIG_CHARGER_SENSE_RESISTOR 10
#define CONFIG_CHARGER_SENSE_RESISTOR_AC 20
diff --git a/baseboard/intelrvp/baseboard.h b/baseboard/intelrvp/baseboard.h
index b927632fc5..96acf8c562 100644
--- a/baseboard/intelrvp/baseboard.h
+++ b/baseboard/intelrvp/baseboard.h
@@ -69,6 +69,7 @@
#define CONFIG_CHARGER
#define CONFIG_CHARGER_DISCHARGE_ON_AC
#define CONFIG_CHARGER_INPUT_CURRENT 512
+#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512
#define CONFIG_CHARGER_SENSE_RESISTOR 5
#define CONFIG_CHARGER_SENSE_RESISTOR_AC 10
#undef CONFIG_EXTPOWER_DEBOUNCE_MS
diff --git a/baseboard/intelrvp/chg_usb_pd.c b/baseboard/intelrvp/chg_usb_pd.c
index 95aeea0441..9fa7c60f44 100644
--- a/baseboard/intelrvp/chg_usb_pd.c
+++ b/baseboard/intelrvp/chg_usb_pd.c
@@ -129,6 +129,5 @@ int board_set_active_charge_port(int port)
void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
int charge_mv)
{
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
+ charge_set_input_current_limit(charge_ma, charge_mv);
}
diff --git a/baseboard/kukui/baseboard.h b/baseboard/kukui/baseboard.h
index 9afc726861..4a5562fb04 100644
--- a/baseboard/kukui/baseboard.h
+++ b/baseboard/kukui/baseboard.h
@@ -62,6 +62,7 @@
#define CONFIG_CHARGER_SENSE_RESISTOR 10 /* BOARD_RS2 */
#define CONFIG_CHARGER_OTG
#define CONFIG_CHARGE_RAMP_HW
+#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512
/* TCPC FUSB302 */
#define PD_POWER_SUPPLY_TURN_ON_DELAY 160000 /* us */
diff --git a/baseboard/octopus/baseboard.c b/baseboard/octopus/baseboard.c
index b35bbcd67b..c852d1fad5 100644
--- a/baseboard/octopus/baseboard.c
+++ b/baseboard/octopus/baseboard.c
@@ -301,8 +301,7 @@ int board_set_active_charge_port(int port)
void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
int charge_mv)
{
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
+ charge_set_input_current_limit(charge_ma, charge_mv);
}
void board_hibernate(void)
diff --git a/baseboard/octopus/baseboard.h b/baseboard/octopus/baseboard.h
index 8662749c98..9c6e2a14e6 100644
--- a/baseboard/octopus/baseboard.h
+++ b/baseboard/octopus/baseboard.h
@@ -155,6 +155,7 @@
#define CONFIG_CHARGE_RAMP_HW
#define CONFIG_CHARGER
#define CONFIG_CHARGER_INPUT_CURRENT 512 /* Allow low-current USB charging */
+#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512
#define CONFIG_CHARGER_SENSE_RESISTOR 10
#define CONFIG_CHARGER_DISCHARGE_ON_AC
#define CONFIG_USB_CHARGER
diff --git a/baseboard/trogdor/baseboard.h b/baseboard/trogdor/baseboard.h
index 2dedf8f330..901466fec1 100644
--- a/baseboard/trogdor/baseboard.h
+++ b/baseboard/trogdor/baseboard.h
@@ -93,6 +93,7 @@
#define CONFIG_CHARGER_DISCHARGE_ON_AC
#define CONFIG_CHARGER_INPUT_CURRENT 512
+#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512
#define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON 10000
#define CONFIG_CHARGER_SENSE_RESISTOR 10
#define CONFIG_CHARGER_SENSE_RESISTOR_AC 20
diff --git a/baseboard/volteer/baseboard.h b/baseboard/volteer/baseboard.h
index 10bea07eeb..4df7d5fc73 100644
--- a/baseboard/volteer/baseboard.h
+++ b/baseboard/volteer/baseboard.h
@@ -108,6 +108,7 @@
#define CONFIG_CHARGER
#define CONFIG_CHARGER_DISCHARGE_ON_AC
#define CONFIG_CHARGER_INPUT_CURRENT 512
+#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512
/*
* Hardware based charge ramp is broken in the ISL9241 (b/169350714).
diff --git a/baseboard/volteer/charger.c b/baseboard/volteer/charger.c
index 73b80e17b8..252e8795d3 100644
--- a/baseboard/volteer/charger.c
+++ b/baseboard/volteer/charger.c
@@ -83,8 +83,7 @@ int board_set_active_charge_port(int port)
__overridable void board_set_charge_limit(int port, int supplier, int charge_ma,
int max_ma, int charge_mv)
{
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
+ charge_set_input_current_limit(charge_ma, charge_mv);
}
void board_overcurrent_event(int port, int is_overcurrented)
diff --git a/baseboard/zork/baseboard.c b/baseboard/zork/baseboard.c
index a9e4324aad..0ad8339591 100644
--- a/baseboard/zork/baseboard.c
+++ b/baseboard/zork/baseboard.c
@@ -99,8 +99,7 @@ DECLARE_HOOK(HOOK_CHIPSET_RESUME, baseboard_chipset_resume, HOOK_PRIO_DEFAULT);
__overridable void board_set_charge_limit(int port, int supplier, int charge_ma,
int max_ma, int charge_mv)
{
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
+ charge_set_input_current_limit(charge_ma, charge_mv);
}
/* Keyboard scan setting */
diff --git a/baseboard/zork/baseboard.h b/baseboard/zork/baseboard.h
index 2289c1891b..528aa44a91 100644
--- a/baseboard/zork/baseboard.h
+++ b/baseboard/zork/baseboard.h
@@ -77,6 +77,7 @@
#define CONFIG_CHARGE_MANAGER
#define CONFIG_CHARGER_DISCHARGE_ON_AC
#define CONFIG_CHARGER_INPUT_CURRENT 512
+#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512
#define CONFIG_CHARGER_ISL9241
#define CONFIG_CHARGER_SENSE_RESISTOR 10
#define CONFIG_CHARGER_SENSE_RESISTOR_AC 20