chg_ramp: Add charge_is_consuming_full_input_current().

Most boards had an identical implementation for this function,
previously known as board_is_consuming_full_charge().  To reduce copy
paste, let's just move it to common code.  Boards that charge ramp
without a battery will have to define their own implementation, but
there probably won't be any boards like that in the near future.

BUG=None
BRANCH=None
TEST=make -j buildall

Change-Id: Ic99a378ac26dfd35d7d718bf9376eacfa8609166
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/748919
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
This commit is contained in:
Aseda Aboagye
2017-11-01 09:59:08 -07:00
committed by chrome-bot
parent 030e443094
commit 7bf1696711
15 changed files with 22 additions and 103 deletions

View File

@@ -662,16 +662,6 @@ void board_set_charge_limit(int port, int supplier, int charge_ma,
CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
}
/**
* Return if board is consuming full amount of input current
*/
int board_is_consuming_full_charge(void)
{
int chg_perc = charge_get_percent();
return chg_perc > 2 && chg_perc < 95;
}
/**
* Return if VBUS is sagging too low
*/

View File

@@ -541,16 +541,6 @@ void board_set_charge_limit(int port, int supplier, int charge_ma,
CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
}
/**
* Return if board is consuming full amount of input current
*/
int board_is_consuming_full_charge(void)
{
int chg_perc = charge_get_percent();
return chg_perc > 2 && chg_perc < 95;
}
/**
* Return if VBUS is sagging too low
*/

View File

@@ -416,16 +416,6 @@ void board_set_charge_limit(int port, int supplier, int charge_ma,
CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
}
/**
* Return if board is consuming full amount of input current
*/
int board_is_consuming_full_charge(void)
{
int chg_perc = charge_get_percent();
return chg_perc > 2 && chg_perc < 95;
}
/**
* Return if VBUS is sagging too low
*/

View File

@@ -416,16 +416,6 @@ void board_set_charge_limit(int port, int supplier, int charge_ma,
CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
}
/**
* Return if board is consuming full amount of input current
*/
int board_is_consuming_full_charge(void)
{
int chg_perc = charge_get_percent();
return chg_perc > 2 && chg_perc < 95;
}
/**
* Return if VBUS is sagging too low
*/

View File

@@ -20,13 +20,3 @@ int board_is_vbus_too_low(int port, enum chg_ramp_vbus_state ramp_state)
{
return charger_get_vbus_voltage(port) < BD9995X_BC12_MIN_VOLTAGE;
}
/**
* Return if board is consuming full amount of input current
*/
int board_is_consuming_full_charge(void)
{
int chg_pct = charge_get_percent();
return chg_pct > 2 && chg_pct < 95;
}

View File

@@ -795,17 +795,6 @@ int board_get_ramp_current_limit(int supplier, int sup_curr)
}
}
/**
* Return if board is consuming full amount of input current
*/
int board_is_consuming_full_charge(void)
{
int chg_perc = charge_get_percent();
return chg_perc > 2 && chg_perc < 95;
}
void board_hibernate(void)
{
CPRINTS("Triggering PMIC shutdown.");

View File

@@ -802,17 +802,6 @@ void board_set_charge_limit(int port, int supplier, int charge_ma,
CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
}
/**
* Return if board is consuming full amount of input current
*/
int board_is_consuming_full_charge(void)
{
int chg_perc = charge_get_percent();
return chg_perc > 2 && chg_perc < 95;
}
void board_hibernate(void)
{
CPRINTS("Triggering PMIC shutdown.");

View File

@@ -654,16 +654,6 @@ void board_set_charge_limit(int port, int supplier, int charge_ma,
CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
}
/**
* Return if board is consuming full amount of input current
*/
int board_is_consuming_full_charge(void)
{
int chg_perc = charge_get_percent();
return chg_perc > 2 && chg_perc < 95;
}
/**
* Return if VBUS is sagging too low
*/

View File

@@ -439,16 +439,6 @@ void board_set_charge_limit(int port, int supplier, int charge_ma,
CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
}
/**
* Return if board is consuming full amount of input current
*/
int board_is_consuming_full_charge(void)
{
int chg_perc = charge_get_percent();
return chg_perc > 2 && chg_perc < 95;
}
/**
* Return if VBUS is sagging too low
*/

View File

@@ -363,7 +363,7 @@ int pd_is_max_request_allowed(void)
/**
* Return if board is consuming full amount of input current
*/
int board_is_consuming_full_charge(void)
int charge_is_consuming_full_input_current(void)
{
return batt_soc >= 1 && batt_soc < HIGH_BATT_THRESHOLD;
}

View File

@@ -7,6 +7,7 @@
#include "charge_manager.h"
#include "charge_ramp.h"
#include "charge_state.h"
#include "common.h"
#include "console.h"
#include "ec_commands.h"
@@ -224,7 +225,7 @@ void chg_ramp_task(void *u)
* If we are not drawing full charge, then don't ramp,
* just wait in this state, until we are.
*/
if (!board_is_consuming_full_charge()) {
if (!charge_is_consuming_full_input_current()) {
task_wait_time = CURRENT_DRAW_DELAY;
break;
}
@@ -258,7 +259,7 @@ void chg_ramp_task(void *u)
task_wait_time = RAMP_CURR_DELAY;
/* Pause ramping if we are not drawing full current */
if (!board_is_consuming_full_charge()) {
if (!charge_is_consuming_full_input_current()) {
task_wait_time = CURRENT_DRAW_DELAY;
break;
}

View File

@@ -1101,6 +1101,13 @@ int charge_get_battery_temp(int idx, int *temp_ptr)
return EC_SUCCESS;
}
int charge_is_consuming_full_input_current(void)
{
int chg_pct = charge_get_percent();
return chg_pct > 2 && chg_pct < 95;
}
int charge_set_input_current_limit(int ma, int mv)
{
/*

View File

@@ -16,13 +16,6 @@ enum chg_ramp_vbus_state {
CHG_RAMP_VBUS_STABLE
};
/**
* Check if board is consuming full input current
*
* @return Board is consuming full input current
*/
int board_is_consuming_full_charge(void);
/**
* Check if VBUS is too low
*

View File

@@ -91,6 +91,16 @@ uint32_t charge_get_flags(void);
*/
int charge_get_percent(void);
/**
* Check if board is consuming full input current
*
* This returns true if the battery charge percentage is between 2% and 95%
* exclusive.
*
* @return Board is consuming full input current
*/
int charge_is_consuming_full_input_current(void);
/**
* Return non-zero if discharging and battery so low we should shut down.
*/

View File

@@ -64,7 +64,7 @@ int usb_charger_ramp_max(int supplier, int sup_curr)
return 0;
}
int board_is_consuming_full_charge(void)
int charge_is_consuming_full_input_current(void)
{
return charge_limit_ma <= system_load_current_ma;
}