mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-04 22:11:41 +00:00
cleanup: Remove charge_state_v1
All boards have been transitioned to charge_state_v2.c So charge_state_v1.c, HOOK_CHARGE_STATE_CHANGE, and CONFIG_CHARGER_TIMEOUT_HOURS can be removed BUG=chrome-os-partner:36272 TEST=make -j buildall BRANCH=none Change-Id: I3f20c5198ea75185f9894deb792575a1be31432a Reviewed-on: https://chromium-review.googlesource.com/435467 Commit-Ready: Sam Hurst <shurst@google.com> Tested-by: Sam Hurst <shurst@google.com> Reviewed-by: Shawn N <shawnn@chromium.org>
This commit is contained in:
@@ -169,103 +169,6 @@ static struct battery_device support_batteries[] = {
|
||||
},
|
||||
};
|
||||
|
||||
#ifdef CONFIG_BATTERY_OVERRIDE_PARAMS
|
||||
/*
|
||||
* The following parameters are for 2S battery.
|
||||
* There is no corresponding params for 3S battery.
|
||||
*/
|
||||
enum {
|
||||
TEMP_RANGE_10,
|
||||
TEMP_RANGE_23,
|
||||
TEMP_RANGE_35,
|
||||
TEMP_RANGE_45,
|
||||
TEMP_RANGE_50,
|
||||
TEMP_RANGE_MAX
|
||||
};
|
||||
|
||||
enum {
|
||||
VOLT_RANGE_7200,
|
||||
VOLT_RANGE_8000,
|
||||
VOLT_RANGE_8400,
|
||||
VOLT_RANGE_MAX
|
||||
};
|
||||
|
||||
/*
|
||||
* Vendor provided charging method
|
||||
* temp : < 7.2V, 7.2V ~ 8.0V, 8.0V ~ 8.4V
|
||||
* - 0 ~ 10 : 0.8A 1.6A 0.8A
|
||||
* - 10 ~ 23 : 1.6A 4.0A 1.6A
|
||||
* - 23 ~ 35 : 4.0A 4.0A 4.0A
|
||||
* - 35 ~ 45 : 1.6A 4.0A 1.6A
|
||||
* - 45 ~ 50 : 0.8A 1.6A 0.8A
|
||||
*/
|
||||
static const int const current_limit[TEMP_RANGE_MAX][VOLT_RANGE_MAX] = {
|
||||
{ 800, 1600, 800},
|
||||
{1600, 4000, 1600},
|
||||
{4000, 4000, 4000},
|
||||
{1600, 4000, 1600},
|
||||
{ 800, 1600, 800},
|
||||
};
|
||||
|
||||
static inline void limit_value(int *val, int limit)
|
||||
{
|
||||
if (*val > limit)
|
||||
*val = limit;
|
||||
}
|
||||
|
||||
void battery_override_params(struct batt_params *batt)
|
||||
{
|
||||
int *desired_current = &batt->desired_current;
|
||||
int temp_range, volt_range;
|
||||
int bat_temp_c = DECI_KELVIN_TO_CELSIUS(batt->temperature);
|
||||
|
||||
if (battery_info == NULL)
|
||||
return;
|
||||
|
||||
/* Return if the battery is not a 2S battery */
|
||||
if (battery_info->voltage_max != info_2s.voltage_max)
|
||||
return;
|
||||
|
||||
/* Limit charging voltage */
|
||||
if (batt->desired_voltage > battery_info->voltage_max)
|
||||
batt->desired_voltage = battery_info->voltage_max;
|
||||
|
||||
/* Don't charge if outside of allowable temperature range */
|
||||
if (bat_temp_c >= battery_info->charging_max_c ||
|
||||
bat_temp_c < battery_info->charging_min_c) {
|
||||
batt->desired_voltage = 0;
|
||||
batt->desired_current = 0;
|
||||
batt->flags &= ~BATT_FLAG_WANT_CHARGE;
|
||||
return;
|
||||
}
|
||||
|
||||
if (bat_temp_c <= 10)
|
||||
temp_range = TEMP_RANGE_10;
|
||||
else if (bat_temp_c <= 23)
|
||||
temp_range = TEMP_RANGE_23;
|
||||
else if (bat_temp_c <= 35)
|
||||
temp_range = TEMP_RANGE_35;
|
||||
else if (bat_temp_c <= 45)
|
||||
temp_range = TEMP_RANGE_45;
|
||||
else
|
||||
temp_range = TEMP_RANGE_50;
|
||||
|
||||
if (batt->voltage < 7200)
|
||||
volt_range = VOLT_RANGE_7200;
|
||||
else if (batt->voltage < 8000)
|
||||
volt_range = VOLT_RANGE_8000;
|
||||
else
|
||||
volt_range = VOLT_RANGE_8400;
|
||||
|
||||
limit_value(desired_current, current_limit[temp_range][volt_range]);
|
||||
|
||||
/* If battery wants current, give it at least the precharge current */
|
||||
if (*desired_current > 0 &&
|
||||
*desired_current < battery_info->precharge_current)
|
||||
*desired_current = battery_info->precharge_current;
|
||||
}
|
||||
#endif /* CONFIG_BATTERY_OVERRIDE_PARAMS */
|
||||
|
||||
const struct battery_info *battery_get_info(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -35,7 +35,6 @@ common-$(CONFIG_CHARGE_MANAGER)+=charge_manager.o
|
||||
common-$(CONFIG_CHARGE_RAMP)+=charge_ramp.o
|
||||
common-$(CONFIG_CHARGER)+=charger.o
|
||||
common-$(CONFIG_CHARGER_PROFILE_OVERRIDE_COMMON)+=charger_profile_override.o
|
||||
common-$(CONFIG_CHARGER_V1)+=charge_state_v1.o
|
||||
common-$(CONFIG_CHARGER_V2)+=charge_state_v2.o
|
||||
common-$(CONFIG_CMD_I2CWEDGE)+=i2c_wedge.o
|
||||
common-$(CONFIG_COMMON_GPIO)+=gpio.o gpio_commands.o
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -854,11 +854,6 @@ void charger_task(void)
|
||||
curr.state = ST_CHARGE;
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO(crosbug.com/p/27643): Quit trying if charging too long
|
||||
* without getting full (CONFIG_CHARGER_TIMEOUT_HOURS).
|
||||
*/
|
||||
|
||||
wait_for_it:
|
||||
#ifdef CONFIG_CHARGER_PROFILE_OVERRIDE
|
||||
if (chg_ctl_mode == CHARGE_CONTROL_NORMAL) {
|
||||
|
||||
@@ -46,7 +46,6 @@ static const struct hook_ptrs hook_list[] = {
|
||||
{__hooks_lid_change, __hooks_lid_change_end},
|
||||
{__hooks_tablet_mode_change, __hooks_tablet_mode_change_end},
|
||||
{__hooks_pwrbtn_change, __hooks_pwrbtn_change_end},
|
||||
{__hooks_charge_state_change, __hooks_charge_state_change_end},
|
||||
{__hooks_battery_soc_change, __hooks_battery_soc_change_end},
|
||||
{__hooks_tick, __hooks_tick_end},
|
||||
{__hooks_second, __hooks_second_end},
|
||||
|
||||
@@ -458,20 +458,6 @@ static void powerbtn_x86_changed(void)
|
||||
}
|
||||
DECLARE_HOOK(HOOK_POWER_BUTTON_CHANGE, powerbtn_x86_changed, HOOK_PRIO_DEFAULT);
|
||||
|
||||
/**
|
||||
* Handle charge state changes
|
||||
*/
|
||||
static void powerbtn_x86_charge(void)
|
||||
{
|
||||
/*
|
||||
* If we were waiting for the charge state machine to init before we
|
||||
* powered on the chipset, we can stop waiting.
|
||||
*/
|
||||
if (pwrbtn_state == PWRBTN_STATE_INIT_ON)
|
||||
task_wake(TASK_ID_POWERBTN);
|
||||
}
|
||||
DECLARE_HOOK(HOOK_CHARGE_STATE_CHANGE, powerbtn_x86_charge, HOOK_PRIO_DEFAULT);
|
||||
|
||||
/**
|
||||
* Handle configuring the power button behavior through a host command
|
||||
*/
|
||||
|
||||
@@ -188,10 +188,6 @@ SECTIONS
|
||||
KEEP(*(.rodata.HOOK_POWER_BUTTON_CHANGE))
|
||||
__hooks_pwrbtn_change_end = .;
|
||||
|
||||
__hooks_charge_state_change = .;
|
||||
KEEP(*(.rodata.HOOK_CHARGE_STATE_CHANGE))
|
||||
__hooks_charge_state_change_end = .;
|
||||
|
||||
__hooks_battery_soc_change = .;
|
||||
KEEP(*(.rodata.HOOK_BATTERY_SOC_CHANGE))
|
||||
__hooks_battery_soc_change_end = .;
|
||||
|
||||
@@ -135,10 +135,6 @@ SECTIONS
|
||||
KEEP(*(.rodata.HOOK_POWER_BUTTON_CHANGE))
|
||||
__hooks_pwrbtn_change_end = .;
|
||||
|
||||
__hooks_charge_state_change = .;
|
||||
KEEP(*(.rodata.HOOK_CHARGE_STATE_CHANGE))
|
||||
__hooks_charge_state_change_end = .;
|
||||
|
||||
__hooks_battery_soc_change = .;
|
||||
KEEP(*(.rodata.HOOK_BATTERY_SOC_CHANGE))
|
||||
__hooks_battery_soc_change_end = .;
|
||||
|
||||
@@ -81,10 +81,6 @@ SECTIONS {
|
||||
*(.rodata.HOOK_POWER_BUTTON_CHANGE)
|
||||
__hooks_pwrbtn_change_end = .;
|
||||
|
||||
__hooks_charge_state_change = .;
|
||||
*(.rodata.HOOK_CHARGE_STATE_CHANGE)
|
||||
__hooks_charge_state_change_end = .;
|
||||
|
||||
__hooks_battery_soc_change = .;
|
||||
*(.rodata.HOOK_BATTERY_SOC_CHANGE)
|
||||
__hooks_battery_soc_change_end = .;
|
||||
|
||||
@@ -106,10 +106,6 @@ SECTIONS
|
||||
KEEP(*(.rodata.HOOK_POWER_BUTTON_CHANGE))
|
||||
__hooks_pwrbtn_change_end = .;
|
||||
|
||||
__hooks_charge_state_change = .;
|
||||
KEEP(*(.rodata.HOOK_CHARGE_STATE_CHANGE))
|
||||
__hooks_charge_state_change_end = .;
|
||||
|
||||
__hooks_battery_soc_change = .;
|
||||
KEEP(*(.rodata.HOOK_BATTERY_SOC_CHANGE))
|
||||
__hooks_battery_soc_change_end = .;
|
||||
|
||||
@@ -133,10 +133,6 @@ SECTIONS
|
||||
KEEP(*(.rodata.HOOK_POWER_BUTTON_CHANGE))
|
||||
__hooks_pwrbtn_change_end = .;
|
||||
|
||||
__hooks_charge_state_change = .;
|
||||
KEEP(*(.rodata.HOOK_CHARGE_STATE_CHANGE))
|
||||
__hooks_charge_state_change_end = .;
|
||||
|
||||
__hooks_battery_soc_change = .;
|
||||
KEEP(*(.rodata.HOOK_BATTERY_SOC_CHANGE))
|
||||
__hooks_battery_soc_change_end = .;
|
||||
|
||||
@@ -392,7 +392,7 @@ int battery_wait_for_stable(void)
|
||||
return EC_ERROR_NOT_POWERED;
|
||||
}
|
||||
|
||||
#if !defined(CONFIG_CHARGER_V1) && defined(CONFIG_CMD_BATTFAKE)
|
||||
#if defined(CONFIG_CMD_BATTFAKE)
|
||||
static int command_battfake(int argc, char **argv)
|
||||
{
|
||||
char *e;
|
||||
|
||||
@@ -120,17 +120,9 @@ int charge_get_battery_temp(int idx, int *temp_ptr);
|
||||
const struct batt_params *charger_current_battery_params(void);
|
||||
|
||||
|
||||
/* Pick the right implementation */
|
||||
#ifdef CONFIG_CHARGER_V1
|
||||
#ifdef CONFIG_CHARGER_V2
|
||||
#error "Choose either CONFIG_CHARGER_V1 or CONFIG_CHARGER_V2, not both"
|
||||
#else
|
||||
#include "charge_state_v1.h"
|
||||
#endif
|
||||
#else /* not V1 */
|
||||
/* Config Charger */
|
||||
#ifdef CONFIG_CHARGER_V2
|
||||
#include "charge_state_v2.h"
|
||||
#endif
|
||||
#endif /* CONFIG_CHARGER_V1 */
|
||||
#endif /* CONFIG_CHARGER_V2 */
|
||||
|
||||
#endif /* __CROS_EC_CHARGE_STATE_H */
|
||||
|
||||
@@ -188,14 +188,6 @@
|
||||
/* Compile mock battery support; used by tests. */
|
||||
#undef CONFIG_BATTERY_MOCK
|
||||
|
||||
/*
|
||||
* Charger should call battery_override_params() to limit/correct the voltage
|
||||
* and current requested by the battery pack before acting on the request.
|
||||
*
|
||||
* This is valid with CONFIG_CHARGER_V1 only.
|
||||
*/
|
||||
#undef CONFIG_BATTERY_OVERRIDE_PARAMS
|
||||
|
||||
/* Maximum time to wake a non-responsive battery, in second */
|
||||
#define CONFIG_BATTERY_PRECHARGE_TIMEOUT 30
|
||||
|
||||
@@ -386,7 +378,6 @@
|
||||
|
||||
/* Compile common charge state code. You must pick an implementation. */
|
||||
#undef CONFIG_CHARGER
|
||||
#undef CONFIG_CHARGER_V1
|
||||
#undef CONFIG_CHARGER_V2
|
||||
|
||||
/* Compile charger-specific code for these chargers (pick at most one) */
|
||||
@@ -519,8 +510,10 @@
|
||||
#undef CONFIG_CHARGER_LIMIT_POWER_THRESH_CHG_MW
|
||||
|
||||
/*
|
||||
* Equivalent of CONFIG_BATTERY_OVERRIDE_PARAMS for use with
|
||||
* CONFIG_CHARGER_V2
|
||||
* Charger should call battery_override_params() to limit/correct the voltage
|
||||
* and current requested by the battery pack before acting on the request.
|
||||
*
|
||||
* This is valid with CONFIG_CHARGER_V2 only.
|
||||
*/
|
||||
#undef CONFIG_CHARGER_PROFILE_OVERRIDE
|
||||
|
||||
@@ -536,15 +529,6 @@
|
||||
/* Value of the input current sense resistor, in mOhms */
|
||||
#undef CONFIG_CHARGER_SENSE_RESISTOR_AC
|
||||
|
||||
/*
|
||||
* Maximum time to charge the battery, in hours.
|
||||
*
|
||||
* If this timeout is reached, the charger will enter force-idle state.
|
||||
* If not defined, charger will provide current until the battery asks it to
|
||||
* stop.
|
||||
*/
|
||||
#undef CONFIG_CHARGER_TIMEOUT_HOURS
|
||||
|
||||
/*
|
||||
* Board has an GPIO pin to enable or disable charging.
|
||||
*
|
||||
|
||||
@@ -153,13 +153,6 @@ enum hook_type {
|
||||
*/
|
||||
HOOK_POWER_BUTTON_CHANGE,
|
||||
|
||||
/*
|
||||
* Charge state machine status changed.
|
||||
*
|
||||
* Hook routines are called from the charger task.
|
||||
*/
|
||||
HOOK_CHARGE_STATE_CHANGE,
|
||||
|
||||
/*
|
||||
* Battery state of charge changed
|
||||
*
|
||||
|
||||
@@ -52,8 +52,6 @@ extern const struct hook_data __hooks_tablet_mode_change[];
|
||||
extern const struct hook_data __hooks_tablet_mode_change_end[];
|
||||
extern const struct hook_data __hooks_pwrbtn_change[];
|
||||
extern const struct hook_data __hooks_pwrbtn_change_end[];
|
||||
extern const struct hook_data __hooks_charge_state_change[];
|
||||
extern const struct hook_data __hooks_charge_state_change_end[];
|
||||
extern const struct hook_data __hooks_battery_soc_change[];
|
||||
extern const struct hook_data __hooks_battery_soc_change_end[];
|
||||
extern const struct hook_data __hooks_tick[];
|
||||
|
||||
@@ -65,7 +65,6 @@ test-list-host += power_button
|
||||
test-list-host += queue
|
||||
test-list-host += rsa
|
||||
test-list-host += rsa3
|
||||
test-list-host += sbs_charging
|
||||
test-list-host += sbs_charging_v2
|
||||
test-list-host += shmalloc
|
||||
test-list-host += system
|
||||
|
||||
@@ -1,241 +0,0 @@
|
||||
/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*
|
||||
* Test lid switch.
|
||||
*/
|
||||
|
||||
#include "battery_smart.h"
|
||||
#include "charge_state.h"
|
||||
#include "chipset.h"
|
||||
#include "common.h"
|
||||
#include "gpio.h"
|
||||
#include "hooks.h"
|
||||
#include "host_command.h"
|
||||
#include "task.h"
|
||||
#include "test_util.h"
|
||||
#include "util.h"
|
||||
|
||||
#define WAIT_CHARGER_TASK 500
|
||||
#define BATTERY_DETACH_DELAY 35000
|
||||
|
||||
static int mock_chipset_state = CHIPSET_STATE_ON;
|
||||
static int is_shutdown;
|
||||
static int is_force_discharge;
|
||||
static int is_hibernated;
|
||||
|
||||
void chipset_force_shutdown(void)
|
||||
{
|
||||
is_shutdown = 1;
|
||||
}
|
||||
|
||||
int chipset_in_state(int state_mask)
|
||||
{
|
||||
return state_mask & mock_chipset_state;
|
||||
}
|
||||
|
||||
int board_discharge_on_ac(int enabled)
|
||||
{
|
||||
is_force_discharge = enabled;
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
|
||||
void system_hibernate(int sec, int usec)
|
||||
{
|
||||
is_hibernated = 1;
|
||||
}
|
||||
|
||||
/* Setup init condition */
|
||||
static void test_setup(void)
|
||||
{
|
||||
const struct battery_info *bat_info = battery_get_info();
|
||||
|
||||
/* 50% of charge */
|
||||
sb_write(SB_RELATIVE_STATE_OF_CHARGE, 50);
|
||||
sb_write(SB_ABSOLUTE_STATE_OF_CHARGE, 50);
|
||||
/* 25 degree Celsius */
|
||||
sb_write(SB_TEMPERATURE, 250 + 2731);
|
||||
/* Normal voltage */
|
||||
sb_write(SB_VOLTAGE, bat_info->voltage_normal);
|
||||
sb_write(SB_CHARGING_VOLTAGE, bat_info->voltage_max);
|
||||
sb_write(SB_CHARGING_CURRENT, 4000);
|
||||
/* Discharging at 100mAh */
|
||||
sb_write(SB_CURRENT, -100);
|
||||
/* Unplug AC */
|
||||
gpio_set_level(GPIO_AC_PRESENT, 0);
|
||||
}
|
||||
|
||||
static int wait_charging_state(void)
|
||||
{
|
||||
enum charge_state state;
|
||||
task_wake(TASK_ID_CHARGER);
|
||||
msleep(WAIT_CHARGER_TASK);
|
||||
state = charge_get_state();
|
||||
ccprintf("[CHARGING TEST] state = %d\n", state);
|
||||
return state;
|
||||
}
|
||||
|
||||
static int charge_control(enum ec_charge_control_mode mode)
|
||||
{
|
||||
struct ec_params_charge_control params;
|
||||
params.mode = mode;
|
||||
return test_send_host_command(EC_CMD_CHARGE_CONTROL, 1, ¶ms,
|
||||
sizeof(params), NULL, 0);
|
||||
}
|
||||
|
||||
static int test_charge_state(void)
|
||||
{
|
||||
enum charge_state state;
|
||||
|
||||
state = wait_charging_state();
|
||||
/* Plug AC, charging at 1000mAh */
|
||||
ccprintf("[CHARGING TEST] AC on\n");
|
||||
gpio_set_level(GPIO_AC_PRESENT, 1);
|
||||
sb_write(SB_CURRENT, 1000);
|
||||
state = wait_charging_state();
|
||||
TEST_ASSERT(state == PWR_STATE_CHARGE);
|
||||
|
||||
/* Detach battery, charging error */
|
||||
ccprintf("[CHARGING TEST] Detach battery\n");
|
||||
TEST_ASSERT(test_detach_i2c(I2C_PORT_BATTERY, BATTERY_ADDR) ==
|
||||
EC_SUCCESS);
|
||||
msleep(BATTERY_DETACH_DELAY);
|
||||
state = wait_charging_state();
|
||||
TEST_ASSERT(state == PWR_STATE_ERROR);
|
||||
|
||||
/* Attach battery again, charging */
|
||||
ccprintf("[CHARGING TEST] Attach battery\n");
|
||||
test_attach_i2c(I2C_PORT_BATTERY, BATTERY_ADDR);
|
||||
state = wait_charging_state();
|
||||
TEST_ASSERT(state == PWR_STATE_CHARGE);
|
||||
|
||||
/* Unplug AC, discharging at 1000mAh */
|
||||
ccprintf("[CHARGING TEST] AC off\n");
|
||||
gpio_set_level(GPIO_AC_PRESENT, 0);
|
||||
sb_write(SB_CURRENT, -1000);
|
||||
state = wait_charging_state();
|
||||
TEST_ASSERT(state == PWR_STATE_DISCHARGE);
|
||||
|
||||
/* Discharging overtemp */
|
||||
ccprintf("[CHARGING TEST] AC off, batt temp = 90 C\n");
|
||||
gpio_set_level(GPIO_AC_PRESENT, 0);
|
||||
sb_write(SB_CURRENT, -1000);
|
||||
|
||||
state = wait_charging_state();
|
||||
TEST_ASSERT(state == PWR_STATE_DISCHARGE);
|
||||
sb_write(SB_TEMPERATURE, CELSIUS_TO_DECI_KELVIN(90));
|
||||
state = wait_charging_state();
|
||||
TEST_ASSERT(is_shutdown);
|
||||
TEST_ASSERT(state == PWR_STATE_DISCHARGE);
|
||||
sb_write(SB_TEMPERATURE, CELSIUS_TO_DECI_KELVIN(40));
|
||||
|
||||
/* Force idle */
|
||||
ccprintf("[CHARGING TEST] AC on, force idle\n");
|
||||
gpio_set_level(GPIO_AC_PRESENT, 1);
|
||||
sb_write(SB_CURRENT, 1000);
|
||||
state = wait_charging_state();
|
||||
TEST_ASSERT(state == PWR_STATE_CHARGE);
|
||||
charge_control(CHARGE_CONTROL_IDLE);
|
||||
state = wait_charging_state();
|
||||
TEST_ASSERT(state == PWR_STATE_IDLE);
|
||||
charge_control(CHARGE_CONTROL_NORMAL);
|
||||
state = wait_charging_state();
|
||||
TEST_ASSERT(state == PWR_STATE_CHARGE);
|
||||
|
||||
/* Force discharge */
|
||||
ccprintf("[CHARGING TEST] AC on, force discharge\n");
|
||||
gpio_set_level(GPIO_AC_PRESENT, 1);
|
||||
sb_write(SB_CURRENT, 1000);
|
||||
charge_control(CHARGE_CONTROL_DISCHARGE);
|
||||
state = wait_charging_state();
|
||||
TEST_ASSERT(state == PWR_STATE_IDLE);
|
||||
TEST_ASSERT(is_force_discharge);
|
||||
charge_control(CHARGE_CONTROL_NORMAL);
|
||||
state = wait_charging_state();
|
||||
TEST_ASSERT(state == PWR_STATE_CHARGE);
|
||||
TEST_ASSERT(!is_force_discharge);
|
||||
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
|
||||
static int test_low_battery(void)
|
||||
{
|
||||
ccprintf("[CHARGING TEST] Low battery with AC\n");
|
||||
gpio_set_level(GPIO_AC_PRESENT, 1);
|
||||
is_hibernated = 0;
|
||||
sb_write(SB_CURRENT, 1000);
|
||||
sb_write(SB_RELATIVE_STATE_OF_CHARGE, 2);
|
||||
wait_charging_state();
|
||||
mock_chipset_state = CHIPSET_STATE_SOFT_OFF;
|
||||
hook_notify(HOOK_CHIPSET_SHUTDOWN);
|
||||
TEST_ASSERT(!is_hibernated);
|
||||
|
||||
ccprintf("[CHARGING TEST] Low battery shutdown S0->S5\n");
|
||||
mock_chipset_state = CHIPSET_STATE_ON;
|
||||
hook_notify(HOOK_CHIPSET_PRE_INIT);
|
||||
hook_notify(HOOK_CHIPSET_STARTUP);
|
||||
gpio_set_level(GPIO_AC_PRESENT, 0);
|
||||
is_hibernated = 0;
|
||||
sb_write(SB_CURRENT, -1000);
|
||||
sb_write(SB_RELATIVE_STATE_OF_CHARGE, 2);
|
||||
wait_charging_state();
|
||||
mock_chipset_state = CHIPSET_STATE_SOFT_OFF;
|
||||
hook_notify(HOOK_CHIPSET_SHUTDOWN);
|
||||
TEST_ASSERT(is_hibernated);
|
||||
|
||||
ccprintf("[CHARGING TEST] Low battery shutdown S5\n");
|
||||
is_hibernated = 0;
|
||||
sb_write(SB_RELATIVE_STATE_OF_CHARGE, 10);
|
||||
wait_charging_state();
|
||||
sb_write(SB_RELATIVE_STATE_OF_CHARGE, 2);
|
||||
wait_charging_state();
|
||||
TEST_ASSERT(is_hibernated);
|
||||
|
||||
ccprintf("[CHARGING TEST] Low battery AP shutdown\n");
|
||||
is_shutdown = 0;
|
||||
mock_chipset_state = CHIPSET_STATE_ON;
|
||||
sb_write(SB_RELATIVE_STATE_OF_CHARGE, 10);
|
||||
gpio_set_level(GPIO_AC_PRESENT, 1);
|
||||
sb_write(SB_CURRENT, 1000);
|
||||
wait_charging_state();
|
||||
gpio_set_level(GPIO_AC_PRESENT, 0);
|
||||
sb_write(SB_CURRENT, -1000);
|
||||
sb_write(SB_RELATIVE_STATE_OF_CHARGE, 2);
|
||||
wait_charging_state();
|
||||
usleep(32 * SECOND);
|
||||
wait_charging_state();
|
||||
TEST_ASSERT(is_shutdown);
|
||||
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
|
||||
static int test_batt_fake(void)
|
||||
{
|
||||
ccprintf("[CHARGING TEST] Fake battery command\n");
|
||||
mock_chipset_state = CHIPSET_STATE_ON;
|
||||
hook_notify(HOOK_CHIPSET_PRE_INIT);
|
||||
hook_notify(HOOK_CHIPSET_STARTUP);
|
||||
gpio_set_level(GPIO_AC_PRESENT, 0);
|
||||
is_hibernated = 0;
|
||||
sb_write(SB_CURRENT, -1000);
|
||||
sb_write(SB_RELATIVE_STATE_OF_CHARGE, 30);
|
||||
wait_charging_state();
|
||||
UART_INJECT("battfake 2\n");
|
||||
msleep(50);
|
||||
mock_chipset_state = CHIPSET_STATE_SOFT_OFF;
|
||||
hook_notify(HOOK_CHIPSET_SHUTDOWN);
|
||||
TEST_ASSERT(is_hibernated);
|
||||
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
|
||||
void run_test(void)
|
||||
{
|
||||
test_setup();
|
||||
|
||||
RUN_TEST(test_charge_state);
|
||||
RUN_TEST(test_low_battery);
|
||||
RUN_TEST(test_batt_fake);
|
||||
|
||||
test_print_result();
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
/**
|
||||
* List of enabled tasks in the priority order
|
||||
*
|
||||
* The first one has the lowest priority.
|
||||
*
|
||||
* For each task, use the macro TASK_TEST(n, r, d, s) where :
|
||||
* 'n' in the name of the task
|
||||
* 'r' in the main routine of the task
|
||||
* 'd' in an opaque parameter passed to the routine at startup
|
||||
* 's' is the stack size in bytes; must be a multiple of 8
|
||||
*/
|
||||
#define CONFIG_TEST_TASK_LIST \
|
||||
TASK_TEST(CHARGER, charger_task, NULL, TASK_STACK_SIZE) \
|
||||
TASK_TEST(CHIPSET, chipset_task, NULL, TASK_STACK_SIZE)
|
||||
@@ -65,22 +65,6 @@
|
||||
#define CONFIG_RSA_EXPONENT_3
|
||||
#endif
|
||||
|
||||
#ifdef TEST_SBS_CHARGING
|
||||
#define CONFIG_BATTERY_MOCK
|
||||
#define CONFIG_BATTERY_SMART
|
||||
#define CONFIG_CHARGER
|
||||
#define CONFIG_CHARGER_V1
|
||||
#define CONFIG_CHARGER_INPUT_CURRENT 4032
|
||||
#define CONFIG_CHARGER_DISCHARGE_ON_AC
|
||||
#define CONFIG_CHARGER_DISCHARGE_ON_AC_CUSTOM
|
||||
#define CONFIG_I2C
|
||||
#define CONFIG_I2C_MASTER
|
||||
int board_discharge_on_ac(int enabled);
|
||||
#define I2C_PORT_MASTER 0
|
||||
#define I2C_PORT_BATTERY 0
|
||||
#define I2C_PORT_CHARGER 0
|
||||
#endif
|
||||
|
||||
#ifdef TEST_SHMALLOC
|
||||
#define CONFIG_MALLOC
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user