mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-28 02:35:28 +00:00
charge_manager: Pass uncapped / max current to current limit callback
charge_manager may request a charge current limit less than the capability of the supply in certain cases (eg. during PD voltage transition, to make an effort to comply with reduced load spec). Depending on the battery / system state, setting a reduced charge current limit may result in brownout. Pass the uncapped / max negotiated current to board_set_charge_limit() so that boards may use it instead of the requested limit in such circumstances. BUG=chrome-os-partner:56139 BRANCH=gru TEST=Manual on kevin with subsequent commit, boot system with zinger + low-charge battery, verify devices powers up to OS without brownout. Change-Id: I2b8e0d44edcf57ffe4ee0fdec1a1ed35c6becbbd Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/383732 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
This commit is contained in:
committed by
chrome-bot
parent
d8166a8d65
commit
94f2bc0740
@@ -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 ||
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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 ||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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)
|
||||
/*
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user