summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--board/amenia/board.c2
-rw-r--r--board/chell/board.c2
-rw-r--r--board/elm/board.c2
-rw-r--r--board/glados/board.c2
-rw-r--r--board/kevin/board.c2
-rw-r--r--board/lucid/board.c2
-rw-r--r--board/oak/board.c2
-rw-r--r--board/reef/board.c2
-rw-r--r--board/ryu/board.c2
-rw-r--r--board/ryu/board.h3
-rw-r--r--board/samus_pd/board.c2
-rw-r--r--board/strago/board.c2
-rw-r--r--board/wheatley/board.c2
-rw-r--r--common/charge_manager.c3
-rw-r--r--common/charge_ramp.c6
-rw-r--r--include/charge_manager.h11
-rw-r--r--include/charge_ramp.h3
-rw-r--r--test/charge_manager.c2
-rw-r--r--test/charge_ramp.c2
19 files changed, 28 insertions, 26 deletions
diff --git a/board/amenia/board.c b/board/amenia/board.c
index d6e13b0264..ab3dc2ecff 100644
--- a/board/amenia/board.c
+++ b/board/amenia/board.c
@@ -347,7 +347,7 @@ int board_set_active_charge_port(int charge_port)
* @param supplier Charge supplier type.
* @param charge_ma Desired charge limit (mA).
*/
-void board_set_charge_limit(int port, int supplier, int charge_ma)
+void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma)
{
/* Enable charging trigger by BC1.2 detection */
int bc12_enable = (supplier == CHARGE_SUPPLIER_BC12_CDP ||
diff --git a/board/chell/board.c b/board/chell/board.c
index 73096c4826..e16801b546 100644
--- a/board/chell/board.c
+++ b/board/chell/board.c
@@ -342,7 +342,7 @@ int board_set_active_charge_port(int charge_port)
* @param supplier Charge supplier type.
* @param charge_ma Desired charge limit (mA).
*/
-void board_set_charge_limit(int port, int supplier, int charge_ma)
+void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma)
{
charge_set_input_current_limit(MAX(charge_ma,
CONFIG_CHARGER_INPUT_CURRENT));
diff --git a/board/elm/board.c b/board/elm/board.c
index ce9a0154bc..9548bb71fc 100644
--- a/board/elm/board.c
+++ b/board/elm/board.c
@@ -327,7 +327,7 @@ int board_set_active_charge_port(int charge_port)
* @param supplier Charge supplier type.
* @param charge_ma Desired charge limit (mA).
*/
-void board_set_charge_limit(int port, int supplier, int charge_ma)
+void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma)
{
/* Limit input current 95% ratio on elm board for safety */
charge_ma = (charge_ma * 95) / 100;
diff --git a/board/glados/board.c b/board/glados/board.c
index 83e5520535..3689276fe5 100644
--- a/board/glados/board.c
+++ b/board/glados/board.c
@@ -313,7 +313,7 @@ int board_set_active_charge_port(int charge_port)
* @param supplier Charge supplier type.
* @param charge_ma Desired charge limit (mA).
*/
-void board_set_charge_limit(int port, int supplier, int charge_ma)
+void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma)
{
charge_set_input_current_limit(MAX(charge_ma,
CONFIG_CHARGER_INPUT_CURRENT));
diff --git a/board/kevin/board.c b/board/kevin/board.c
index f425141c20..37e6f646a8 100644
--- a/board/kevin/board.c
+++ b/board/kevin/board.c
@@ -236,7 +236,7 @@ int board_set_active_charge_port(int charge_port)
return bd99955_select_input_port(bd99955_port);
}
-void board_set_charge_limit(int port, int supplier, int charge_ma)
+void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma)
{
charge_set_input_current_limit(MAX(charge_ma,
CONFIG_CHARGER_INPUT_CURRENT));
diff --git a/board/lucid/board.c b/board/lucid/board.c
index ed552cf065..51eb4ec06c 100644
--- a/board/lucid/board.c
+++ b/board/lucid/board.c
@@ -171,7 +171,7 @@ int board_set_active_charge_port(int charge_port)
return EC_SUCCESS;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma)
+void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma)
{
int rv;
diff --git a/board/oak/board.c b/board/oak/board.c
index bdacb78567..2621d98f91 100644
--- a/board/oak/board.c
+++ b/board/oak/board.c
@@ -311,7 +311,7 @@ int board_set_active_charge_port(int charge_port)
* @param supplier Charge supplier type.
* @param charge_ma Desired charge limit (mA).
*/
-void board_set_charge_limit(int port, int supplier, int charge_ma)
+void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma)
{
charge_set_input_current_limit(MAX(charge_ma,
CONFIG_CHARGER_INPUT_CURRENT));
diff --git a/board/reef/board.c b/board/reef/board.c
index 0f3e33055c..88e2472bd0 100644
--- a/board/reef/board.c
+++ b/board/reef/board.c
@@ -519,7 +519,7 @@ int board_set_active_charge_port(int charge_port)
* @param supplier Charge supplier type.
* @param charge_ma Desired charge limit (mA).
*/
-void board_set_charge_limit(int port, int supplier, int charge_ma)
+void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma)
{
/* Enable charging trigger by BC1.2 detection */
int bc12_enable = (supplier == CHARGE_SUPPLIER_BC12_CDP ||
diff --git a/board/ryu/board.c b/board/ryu/board.c
index f860ba057b..d01bdfcfe4 100644
--- a/board/ryu/board.c
+++ b/board/ryu/board.c
@@ -550,7 +550,7 @@ int board_set_active_charge_port(int charge_port)
* @param supplier Charge supplier type.
* @param charge_ma Desired charge limit (mA).
*/
-void board_set_charge_limit(int port, int supplier, int charge_ma)
+void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma)
{
int rv;
diff --git a/board/ryu/board.h b/board/ryu/board.h
index dea35aecc4..1e8be353dc 100644
--- a/board/ryu/board.h
+++ b/board/ryu/board.h
@@ -276,9 +276,6 @@ enum usb_strings {
/* The lower the input voltage, the higher the power efficiency. */
#define PD_PREFER_LOW_VOLTAGE
-/* Set the charge current limit. */
-void board_set_charge_limit(int port, int supplier, int charge_ma);
-
/* PP1800 transition GPIO interrupt handler */
void pp1800_on_off_evt(enum gpio_signal signal);
diff --git a/board/samus_pd/board.c b/board/samus_pd/board.c
index e535881c53..1431c50d32 100644
--- a/board/samus_pd/board.c
+++ b/board/samus_pd/board.c
@@ -499,7 +499,7 @@ static int board_update_charge_limit(int charge_ma)
* @param supplier Charge supplier type.
* @param charge_ma Desired charge limit (mA).
*/
-void board_set_charge_limit(int port, int supplier, int charge_ma)
+void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma)
{
/* Update current limit and notify EC if it changed */
if (board_update_charge_limit(charge_ma))
diff --git a/board/strago/board.c b/board/strago/board.c
index ecef093e41..528b658b93 100644
--- a/board/strago/board.c
+++ b/board/strago/board.c
@@ -336,7 +336,7 @@ int board_set_active_charge_port(int charge_port)
* @param supplier Charge supplier type.
* @param charge_ma Desired charge limit (mA).
*/
-void board_set_charge_limit(int port, int supplier, int charge_ma)
+void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma)
{
charge_set_input_current_limit(MAX(charge_ma,
CONFIG_CHARGER_INPUT_CURRENT));
diff --git a/board/wheatley/board.c b/board/wheatley/board.c
index fa39533de5..2ab07ccd58 100644
--- a/board/wheatley/board.c
+++ b/board/wheatley/board.c
@@ -301,7 +301,7 @@ int board_set_active_charge_port(int charge_port)
* @param supplier Charge supplier type.
* @param charge_ma Desired charge limit (mA).
*/
-void board_set_charge_limit(int port, int supplier, int charge_ma)
+void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma)
{
charge_set_input_current_limit(MAX(charge_ma,
CONFIG_CHARGER_INPUT_CURRENT));
diff --git a/common/charge_manager.c b/common/charge_manager.c
index 578cfff686..eeac1211fb 100644
--- a/common/charge_manager.c
+++ b/common/charge_manager.c
@@ -566,7 +566,8 @@ static void charge_manager_refresh(void)
charger_set_hw_ramp(board_is_ramp_allowed(new_supplier));
#endif
board_set_charge_limit(new_port, new_supplier,
- new_charge_current);
+ new_charge_current,
+ new_charge_current_uncapped);
#endif /* HAS_TASK_CHG_RAMP */
/* notify host of power info change */
diff --git a/common/charge_ramp.c b/common/charge_ramp.c
index 4a1399b54e..e63b37b9bd 100644
--- a/common/charge_ramp.c
+++ b/common/charge_ramp.c
@@ -146,7 +146,7 @@ int chg_ramp_is_stable(void)
void chg_ramp_task(void)
{
int task_wait_time = -1;
- int i;
+ int i, lim;
uint64_t detect_end_time_us = 0, time_us;
int last_active_port = CHARGE_PORT_NONE;
@@ -319,8 +319,8 @@ void chg_ramp_task(void)
active_icl = active_icl_new;
/* Set the input current limit */
- board_set_charge_limit(active_port, active_sup,
- chg_ramp_get_current_limit());
+ lim = chg_ramp_get_current_limit();
+ board_set_charge_limit(active_port, active_sup, lim, lim);
if (ramp_st == CHG_RAMP_STABILIZE)
/*
diff --git a/include/charge_manager.h b/include/charge_manager.h
index 7427d12aca..3623bc1635 100644
--- a/include/charge_manager.h
+++ b/include/charge_manager.h
@@ -110,7 +110,14 @@ int charge_manager_get_source_pdo(const uint32_t **src_pdo);
*/
int board_set_active_charge_port(int charge_port);
-/* Set the charge current limit. */
-void board_set_charge_limit(int port, int supplier, int charge_ma);
+/*
+ * Set the charge current limit.
+ *
+ * @param port PD port.
+ * @param supplier Identified CHARGE_SUPPLIER_*.
+ * @param charge_ma Desired charge current limit, <= max_ma.
+ * @param max_ma Maximum charge current limit, >= charge_ma.
+ */
+void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma);
#endif /* __CROS_EC_CHARGE_MANAGER_H */
diff --git a/include/charge_ramp.h b/include/charge_ramp.h
index a957fa872a..6b7b3ad247 100644
--- a/include/charge_ramp.h
+++ b/include/charge_ramp.h
@@ -89,9 +89,6 @@ void chg_ramp_charge_supplier_change(int port, int supplier, int current,
#else
static inline void chg_ramp_charge_supplier_change(
int port, int supplier, timestamp_t registration_time) { }
-
-/* Point directly to board function to set charge limit */
-#define chg_ramp_set_min_current board_set_charge_limit
#endif
#endif /* __CROS_EC_CHARGE_RAMP_H */
diff --git a/test/charge_manager.c b/test/charge_manager.c
index 962fc98a64..bb65c2a3f0 100644
--- a/test/charge_manager.c
+++ b/test/charge_manager.c
@@ -37,7 +37,7 @@ static int new_power_request[CONFIG_USB_PD_PORT_COUNT];
static int power_role[CONFIG_USB_PD_PORT_COUNT];
/* Callback functions called by CM on state change */
-void board_set_charge_limit(int port, int supplier, int charge_ma)
+void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma)
{
active_charge_limit = charge_ma;
}
diff --git a/test/charge_ramp.c b/test/charge_ramp.c
index a3279663e2..4fc1c5ac63 100644
--- a/test/charge_ramp.c
+++ b/test/charge_ramp.c
@@ -53,7 +53,7 @@ int board_is_vbus_too_low(enum chg_ramp_vbus_state ramp_state)
vbus_low_current_ma;
}
-void board_set_charge_limit(int port, int supplier, int limit_ma)
+void board_set_charge_limit(int port, int supplier, int limit_ma, int max_ma)
{
charge_limit_ma = limit_ma;
if (charge_limit_ma > overcurrent_current_ma)