diff options
author | Scott Collyer <scollyer@google.com> | 2017-06-01 16:32:57 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-06-06 19:32:29 -0700 |
commit | 16da7b4c8ce82ee06341428a6d5408813316afee (patch) | |
tree | 181fe3a93c8d7a5e514f788cc6f0a3154d82777f | |
parent | cf5555a9ce8e1ef29553ef8ac37111dc4a6a8a8f (diff) | |
download | chrome-ec-16da7b4c8ce82ee06341428a6d5408813316afee.tar.gz |
coral: Modify battery_info struct for 3S + 1P style battery
Initial version of battery.c for coral is just a straight copy from
Reef. Updated this file to include the battery being used for the
first HW build. Removed the profile override config for the starting
point as well.
BUG=b:62272260
BRANCH=none
TEST=Run 'make BOARD=coral' and verify it builds. Can't test on actual
HW yet as the boards aren't build yet.
Change-Id: I15fcf438918c03bf1d459f5806dff04c82fe8b46
Signed-off-by: Scott Collyer <scollyer@google.com>
Reviewed-on: https://chromium-review.googlesource.com/521756
Commit-Ready: Scott Collyer <scollyer@chromium.org>
Tested-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
-rw-r--r-- | board/coral/battery.c | 624 | ||||
-rw-r--r-- | board/coral/board.h | 3 |
2 files changed, 114 insertions, 513 deletions
diff --git a/board/coral/battery.c b/board/coral/battery.c index b42f8c1132..92fc6f56fe 100644 --- a/board/coral/battery.c +++ b/board/coral/battery.c @@ -1,4 +1,4 @@ -/* Copyright 2016 The Chromium OS Authors. All rights reserved. +/* Copyright 2017 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. * @@ -10,7 +10,6 @@ #include "bd9995x.h" #include "charge_ramp.h" #include "charge_state.h" -#include "charger_profile_override.h" #include "common.h" #include "console.h" #include "ec_commands.h" @@ -22,490 +21,45 @@ #define CPRINTS(format, args...) cprints(CC_CHARGER, format, ## args) +/* Shutdown mode parameter to write to manufacturer access register */ +#define SB_SHUTDOWN_DATA 0xC574 + enum battery_type { - BATTERY_SONY_CORP, - BATTERY_PANASONIC, - BATTERY_SMP_COS4870, - BATTERY_SMP_C22N1626, - BATTERY_CPT_C22N1626, + BATTERY_SANYO, BATTERY_TYPE_COUNT, }; -enum fast_chg_voltage_ranges { - VOLTAGE_RANGE_0, - VOLTAGE_RANGE_1, - VOLTAGE_RANGE_2, -}; - -enum temp_range { - TEMP_RANGE_0, - TEMP_RANGE_1, - TEMP_RANGE_2, - TEMP_RANGE_3, - TEMP_RANGE_4, -}; - -struct ship_mode_info { - const int ship_mode_reg; - const int ship_mode_data; - int (*batt_init)(void); -}; - struct board_batt_params { const char *manuf_name; - const struct ship_mode_info *ship_mode_inf; const struct battery_info *batt_info; - const struct fast_charge_params *fast_chg_params; }; -#define DEFAULT_BATTERY_TYPE BATTERY_SONY_CORP -#define SONY_DISCHARGE_DISABLE_FET_BIT (0x01 << 13) -#define PANASONIC_DISCHARGE_ENABLE_FET_BIT (0x01 << 14) -#define C22N1626_DISCHARGE_ENABLE_FET_BIT (0x01 << 0) - -/* keep track of previous charge profile info */ -static const struct fast_charge_profile *prev_chg_profile_info; - +#define DEFAULT_BATTERY_TYPE BATTERY_SANYO static enum battery_present batt_pres_prev = BP_NOT_SURE; - static enum battery_type board_battery_type = BATTERY_TYPE_COUNT; -static const struct fast_charge_profile fast_charge_smp_cos4870_info[] = { - /* < 0C */ - [TEMP_RANGE_0] = { - .temp_c = TEMPC_TENTHS_OF_DEG(-1), - .current_mA = { - [VOLTAGE_RANGE_0] = 0, - [VOLTAGE_RANGE_1] = 0, - }, - }, - - /* 0C >= && <=15C */ - [TEMP_RANGE_1] = { - .temp_c = TEMPC_TENTHS_OF_DEG(15), - .current_mA = { - [VOLTAGE_RANGE_0] = 944, - [VOLTAGE_RANGE_1] = 472, - }, - }, - - /* 15C > && <=20C */ - [TEMP_RANGE_2] = { - .temp_c = TEMPC_TENTHS_OF_DEG(20), - .current_mA = { - [VOLTAGE_RANGE_0] = 1416, - [VOLTAGE_RANGE_1] = 1416, - }, - }, - - /* 20C > && <=45C */ - [TEMP_RANGE_3] = { - .temp_c = TEMPC_TENTHS_OF_DEG(45), - .current_mA = { - [VOLTAGE_RANGE_0] = 3300, - [VOLTAGE_RANGE_1] = 3300, - }, - }, - - /* > 45C */ - [TEMP_RANGE_4] = { - .temp_c = TEMPC_TENTHS_OF_DEG(CHARGER_PROF_TEMP_C_LAST_RANGE), - .current_mA = { - [VOLTAGE_RANGE_0] = 0, - [VOLTAGE_RANGE_1] = 0, - }, - }, -}; - -static const struct fast_charge_params fast_chg_params_smp_cos4870 = { - .total_temp_ranges = ARRAY_SIZE(fast_charge_smp_cos4870_info), - .default_temp_range_profile = TEMP_RANGE_2, - .voltage_mV = { - [VOLTAGE_RANGE_0] = 8000, - [VOLTAGE_RANGE_1] = CHARGER_PROF_VOLTAGE_MV_LAST_RANGE, - }, - .chg_profile_info = &fast_charge_smp_cos4870_info[0], -}; - -const struct battery_info batt_info_smp_cos4870 = { - .voltage_max = TARGET_WITH_MARGIN(8700, 5), - .voltage_normal = 7600, - /* - * Actual value 6000mV, added 100mV for charger accuracy so that - * unwanted low VSYS_Prochot# assertion can be avoided. - */ - .voltage_min = 6100, - .precharge_current = 256, /* mA */ - .start_charging_min_c = 0, - .start_charging_max_c = 46, - .charging_min_c = 0, - .charging_max_c = 45, - .discharging_min_c = 0, - .discharging_max_c = 60, -}; - -static const struct fast_charge_profile fast_charge_sonycorp_info[] = { - /* < 10C */ - [TEMP_RANGE_0] = { - .temp_c = TEMPC_TENTHS_OF_DEG(9), - .current_mA = { - [VOLTAGE_RANGE_0] = 1200, - [VOLTAGE_RANGE_1] = 1200, - }, - }, - - /* >= 10C */ - [TEMP_RANGE_1] = { - .temp_c = TEMPC_TENTHS_OF_DEG(CHARGER_PROF_TEMP_C_LAST_RANGE), - .current_mA = { - [VOLTAGE_RANGE_0] = 2250, - [VOLTAGE_RANGE_1] = 2250, - }, - }, -}; - -static const struct fast_charge_params fast_chg_params_sonycorp = { - .total_temp_ranges = ARRAY_SIZE(fast_charge_sonycorp_info), - .default_temp_range_profile = TEMP_RANGE_1, - .voltage_mV = { - [VOLTAGE_RANGE_0] = 8000, - [VOLTAGE_RANGE_1] = CHARGER_PROF_VOLTAGE_MV_LAST_RANGE, - }, - .chg_profile_info = &fast_charge_sonycorp_info[0], -}; - -const struct battery_info batt_info_sonycorp = { - .voltage_max = TARGET_WITH_MARGIN(8700, 5), - .voltage_normal = 7600, - - /* - * Actual value 6000mV, added 100mV for charger accuracy so that - * unwanted low VSYS_Prochot# assertion can be avoided. - */ - .voltage_min = 6100, - .precharge_current = 256, /* mA */ - .start_charging_min_c = 0, - .start_charging_max_c = 50, - .charging_min_c = 0, - .charging_max_c = 60, - .discharging_min_c = -20, - .discharging_max_c = 75, -}; - -static const struct fast_charge_profile fast_charge_panasonic_info[] = { - /* < 0C */ - [TEMP_RANGE_0] = { - .temp_c = TEMPC_TENTHS_OF_DEG(-1), - .current_mA = { - [VOLTAGE_RANGE_0] = 0, - [VOLTAGE_RANGE_1] = 0, - }, - }, - - /* 0C >= && <= 60C */ - [TEMP_RANGE_1] = { - .temp_c = TEMPC_TENTHS_OF_DEG(60), - .current_mA = { - [VOLTAGE_RANGE_0] = 3072, - [VOLTAGE_RANGE_1] = 3072, - }, - }, - - /* > 60C */ - [TEMP_RANGE_2] = { - .temp_c = TEMPC_TENTHS_OF_DEG(CHARGER_PROF_TEMP_C_LAST_RANGE), - .current_mA = { - [VOLTAGE_RANGE_0] = 0, - [VOLTAGE_RANGE_1] = 0, - }, - }, -}; - -static const struct fast_charge_params fast_chg_params_panasonic = { - .total_temp_ranges = ARRAY_SIZE(fast_charge_panasonic_info), - .default_temp_range_profile = TEMP_RANGE_1, - .voltage_mV = { - [VOLTAGE_RANGE_0] = 8000, - [VOLTAGE_RANGE_1] = CHARGER_PROF_VOLTAGE_MV_LAST_RANGE, - }, - .chg_profile_info = &fast_charge_panasonic_info[0], -}; - -const struct battery_info batt_info_panasoic = { - .voltage_max = TARGET_WITH_MARGIN(8800, 5), - .voltage_normal = 7700, - - /* - * Actual value 6000mV, added 100mV for charger accuracy so that - * unwanted low VSYS_Prochot# assertion can be avoided. - */ - .voltage_min = 6100, - .precharge_current = 256, /* mA */ - .start_charging_min_c = 0, - .start_charging_max_c = 50, - .charging_min_c = 0, - .charging_max_c = 60, - .discharging_min_c = -20, - .discharging_max_c = 75, -}; - -static const struct fast_charge_profile fast_charge_smp_c22n1626_info[] = { - /* < 1C */ - [TEMP_RANGE_0] = { - .temp_c = TEMPC_TENTHS_OF_DEG(0), - .current_mA = { - [VOLTAGE_RANGE_0] = 0, - [VOLTAGE_RANGE_1] = 0, - [VOLTAGE_RANGE_2] = 0, - }, - }, - - /* >=1C && <=10C */ - [TEMP_RANGE_1] = { - .temp_c = TEMPC_TENTHS_OF_DEG(10), - .current_mA = { - [VOLTAGE_RANGE_0] = 1752, - [VOLTAGE_RANGE_1] = 1752, - [VOLTAGE_RANGE_2] = 1752, - }, - }, - - /* 10C > && <=45C */ - [TEMP_RANGE_2] = { - .temp_c = TEMPC_TENTHS_OF_DEG(45), - .current_mA = { - [VOLTAGE_RANGE_0] = 4672, - [VOLTAGE_RANGE_1] = 4672, - [VOLTAGE_RANGE_2] = 2920, - }, - }, - - /* 45C > && <=60C */ - [TEMP_RANGE_3] = { - .temp_c = TEMPC_TENTHS_OF_DEG(60), - .current_mA = { - [VOLTAGE_RANGE_0] = 2920, - [VOLTAGE_RANGE_1] = 0, - [VOLTAGE_RANGE_2] = 0, - }, - }, - - /* > 60C */ - [TEMP_RANGE_4] = { - .temp_c = TEMPC_TENTHS_OF_DEG(CHARGER_PROF_TEMP_C_LAST_RANGE), - .current_mA = { - [VOLTAGE_RANGE_0] = 0, - [VOLTAGE_RANGE_1] = 0, - [VOLTAGE_RANGE_2] = 0, - }, - }, -}; - -static const struct fast_charge_params fast_chg_params_smp_c22n1626 = { - .total_temp_ranges = ARRAY_SIZE(fast_charge_smp_c22n1626_info), - .default_temp_range_profile = TEMP_RANGE_2, - .voltage_mV = { - [VOLTAGE_RANGE_0] = 8200, - [VOLTAGE_RANGE_1] = 8500, - [VOLTAGE_RANGE_2] = CHARGER_PROF_VOLTAGE_MV_LAST_RANGE, - }, - .chg_profile_info = &fast_charge_smp_c22n1626_info[0], -}; - -static const struct fast_charge_profile fast_charge_cpt_c22n1626_info[] = { - /* < 1C */ - [TEMP_RANGE_0] = { - .temp_c = TEMPC_TENTHS_OF_DEG(0), - .current_mA = { - [VOLTAGE_RANGE_0] = 0, - [VOLTAGE_RANGE_1] = 0, - [VOLTAGE_RANGE_2] = 0, - }, - }, - - /* >=1C && <=10C */ - [TEMP_RANGE_1] = { - .temp_c = TEMPC_TENTHS_OF_DEG(10), - .current_mA = { - [VOLTAGE_RANGE_0] = 1752, - [VOLTAGE_RANGE_1] = 1752, - [VOLTAGE_RANGE_2] = 1752, - }, - }, - - /* 10C > && <=45C */ - [TEMP_RANGE_2] = { - .temp_c = TEMPC_TENTHS_OF_DEG(45), - .current_mA = { - [VOLTAGE_RANGE_0] = 4600, - [VOLTAGE_RANGE_1] = 4600, - [VOLTAGE_RANGE_2] = 2920, - }, - }, - - /* 45C > && <=60C */ - [TEMP_RANGE_3] = { - .temp_c = TEMPC_TENTHS_OF_DEG(60), - .current_mA = { - [VOLTAGE_RANGE_0] = 2920, - [VOLTAGE_RANGE_1] = 0, - [VOLTAGE_RANGE_2] = 0, - }, - }, - - /* >60C */ - [TEMP_RANGE_4] = { - .temp_c = TEMPC_TENTHS_OF_DEG(CHARGER_PROF_TEMP_C_LAST_RANGE), - .current_mA = { - [VOLTAGE_RANGE_0] = 0, - [VOLTAGE_RANGE_1] = 0, - [VOLTAGE_RANGE_2] = 0, - }, - }, -}; - -static const struct fast_charge_params fast_chg_params_cpt_c22n1626 = { - .total_temp_ranges = ARRAY_SIZE(fast_charge_cpt_c22n1626_info), - .default_temp_range_profile = TEMP_RANGE_2, - .voltage_mV = { - [VOLTAGE_RANGE_0] = 8200, - [VOLTAGE_RANGE_1] = 8500, - [VOLTAGE_RANGE_2] = CHARGER_PROF_VOLTAGE_MV_LAST_RANGE, - }, - .chg_profile_info = &fast_charge_cpt_c22n1626_info[0], -}; - -const struct battery_info batt_info_c22n1626 = { - .voltage_max = TARGET_WITH_MARGIN(8800, 5), - .voltage_normal = 7700, - - /* - * Actual value 6000mV, added 100mV for charger accuracy so that - * unwanted low VSYS_Prochot# assertion can be avoided. - */ - .voltage_min = 6100, - .precharge_current = 256, /* mA */ - .start_charging_min_c = 0, - .start_charging_max_c = 45, - .charging_min_c = 0, - .charging_max_c = 60, - .discharging_min_c = 0, - .discharging_max_c = 60, -}; - -static int batt_smp_cos4870_init(void) -{ - int batt_status; - - return battery_status(&batt_status) ? 0 : - batt_status & STATUS_INITIALIZED; -} - -static int batt_sony_corp_init(void) -{ - int batt_status; - - /* - * SB_MANUFACTURER_ACCESS: - * [13] : Discharging Disabled - * : 0b - Allowed to Discharge - * : 1b - Not Allowed to Discharge - */ - return sb_read(SB_MANUFACTURER_ACCESS, &batt_status) ? 0 : - !(batt_status & SONY_DISCHARGE_DISABLE_FET_BIT); -} - -static int batt_panasonic_init(void) -{ - int batt_status; - - /* - * SB_MANUFACTURER_ACCESS: - * [14] : Discharging Disabled - * : 0b - Not Allowed to Discharge - * : 1b - Allowed to Discharge - */ - return sb_read(SB_MANUFACTURER_ACCESS, &batt_status) ? 0 : - !!(batt_status & PANASONIC_DISCHARGE_ENABLE_FET_BIT); -} - -static int batt_c22n1626_init(void) -{ - int batt_status; - - /* - * SB_PACK_STATUS: - * [0] : Discharging Enabled - * : 0b - Not Allowed to Discharge - * : 1b - Allowed to Discharge - */ - return sb_read(SB_PACK_STATUS, &batt_status) ? 0 : - !!(batt_status & C22N1626_DISCHARGE_ENABLE_FET_BIT); -} - -static const struct ship_mode_info ship_mode_info_smp_cos4870 = { - .ship_mode_reg = 0x00, - .ship_mode_data = 0x0010, - .batt_init = batt_smp_cos4870_init, -}; - -static const struct ship_mode_info ship_mode_info_sonycorp = { - .ship_mode_reg = 0x3A, - .ship_mode_data = 0xC574, - .batt_init = batt_sony_corp_init, -}; - -static const struct ship_mode_info ship_mode_info_panasonic = { - .ship_mode_reg = 0x3A, - .ship_mode_data = 0xC574, - .batt_init = batt_panasonic_init, -}; - -static const struct ship_mode_info ship_mode_info_c22n1626= { - .ship_mode_reg = 0x00, - .ship_mode_data = 0x0010, - .batt_init = batt_c22n1626_init, +/* + * Battery info for LG A50. Note that the fields start_charging_min/max and + * charging_min/max are not used for the Eve charger. The effective temperature + * limits are given by discharging_min/max_c. + */ +static const struct battery_info batt_info_sanyo = { + .voltage_max = TARGET_WITH_MARGIN(13200, 5), /* mV */ + .voltage_normal = 11550, /* mV */ + .voltage_min = 9000, /* mV */ + .precharge_current = 256, /* mA */ + .start_charging_min_c = 0, + .start_charging_max_c = 46, + .charging_min_c = 0, + .charging_max_c = 60, + .discharging_min_c = 0, + .discharging_max_c = 60, }; static const struct board_batt_params info[] = { - /* BQ40Z555 SONY CORP BATTERY battery specific configurations */ - [BATTERY_SONY_CORP] = { - .manuf_name = "SONYCorp", - .ship_mode_inf = &ship_mode_info_sonycorp, - .fast_chg_params = &fast_chg_params_sonycorp, - .batt_info = &batt_info_sonycorp, - }, - - /* RAJ240045 Panasoic battery specific configurations */ - [BATTERY_PANASONIC] = { - .manuf_name = "PANASONIC", - .ship_mode_inf = &ship_mode_info_panasonic, - .fast_chg_params = &fast_chg_params_panasonic, - .batt_info = &batt_info_panasoic, - }, - - /* BQ40Z55 SMP COS4870 BATTERY battery specific configurations */ - [BATTERY_SMP_COS4870] = { - .manuf_name = "SMP-COS4870", - .ship_mode_inf = &ship_mode_info_smp_cos4870, - .fast_chg_params = &fast_chg_params_smp_cos4870, - .batt_info = &batt_info_smp_cos4870, - }, - - /* BQ40Z55 SMP C22N1626 BATTERY battery specific configurations */ - [BATTERY_SMP_C22N1626] = { - .manuf_name = "AS1FNZD3KD", - .ship_mode_inf = &ship_mode_info_c22n1626, - .fast_chg_params = &fast_chg_params_smp_c22n1626, - .batt_info = &batt_info_c22n1626, - }, - - /* BQ40Z55 CPT C22N1626 BATTERY battery specific configurations */ - [BATTERY_CPT_C22N1626] = { - .manuf_name = "AS1FOAD3KD", - .ship_mode_inf = &ship_mode_info_c22n1626, - .fast_chg_params = &fast_chg_params_cpt_c22n1626, - .batt_info = &batt_info_c22n1626, + [BATTERY_SANYO] = { + .manuf_name = "SANYO", + .batt_info = &batt_info_sanyo, }, }; BUILD_ASSERT(ARRAY_SIZE(info) == BATTERY_TYPE_COUNT); @@ -516,16 +70,9 @@ static inline const struct board_batt_params *board_get_batt_params(void) DEFAULT_BATTERY_TYPE : board_battery_type]; } -static inline enum battery_present battery_hw_present(void) -{ - /* The GPIO is low when the battery is physically present */ - return gpio_get_level(GPIO_EC_BATT_PRES_L) ? BP_NO : BP_YES; -} - /* Get type of the battery connected on the board */ static int board_get_battery_type(void) { - const struct fast_charge_params *chg_params; char name[32]; int i; @@ -538,11 +85,6 @@ static int board_get_battery_type(void) } } - /* Initialize fast charging parameters */ - chg_params = board_get_batt_params()->fast_chg_params; - prev_chg_profile_info = &chg_params->chg_profile_info[ - chg_params->default_temp_range_profile]; - return board_battery_type; } @@ -570,19 +112,66 @@ const struct battery_info *battery_get_info(void) int board_cut_off_battery(void) { int rv; - const struct ship_mode_info *ship_mode_inf = - board_get_batt_params()->ship_mode_inf; /* Ship mode command must be sent twice to take effect */ - rv = sb_write(ship_mode_inf->ship_mode_reg, - ship_mode_inf->ship_mode_data); + rv = sb_write(SB_MANUFACTURER_ACCESS, SB_SHUTDOWN_DATA); if (rv != EC_SUCCESS) - return rv; + return EC_RES_ERROR; + + rv = sb_write(SB_MANUFACTURER_ACCESS, SB_SHUTDOWN_DATA); + return rv ? EC_RES_ERROR : EC_RES_SUCCESS; +} + +enum battery_disconnect_state battery_get_disconnect_state(void) +{ + uint8_t data[6]; + int rv; + + /* + * Take note if we find that the battery isn't in disconnect state, + * and always return NOT_DISCONNECTED without probing the battery. + * This assumes the battery will not go to disconnect state during + * runtime. + */ + static int not_disconnected; + + if (not_disconnected) + return BATTERY_NOT_DISCONNECTED; + + if (extpower_is_present()) { + /* Check if battery charging + discharging is disabled. */ + rv = sb_read_mfgacc(PARAM_OPERATION_STATUS, + SB_ALT_MANUFACTURER_ACCESS, data, sizeof(data)); + if (rv) + return BATTERY_DISCONNECT_ERROR; + + if (~data[3] & (BATTERY_DISCHARGING_DISABLED | + BATTERY_CHARGING_DISABLED)) { + not_disconnected = 1; + return BATTERY_NOT_DISCONNECTED; + } - return sb_write(ship_mode_inf->ship_mode_reg, - ship_mode_inf->ship_mode_data); + /* + * Battery is neither charging nor discharging. Verify that + * we didn't enter this state due to a safety fault. + */ + rv = sb_read_mfgacc(PARAM_SAFETY_STATUS, + SB_ALT_MANUFACTURER_ACCESS, data, sizeof(data)); + if (rv || data[2] || data[3] || data[4] || data[5]) + return BATTERY_DISCONNECT_ERROR; + + /* + * Battery is present and also the status is initialized and + * no safety fault, battery is disconnected. + */ + if (battery_is_present() == BP_YES) + return BATTERY_DISCONNECTED; + } + not_disconnected = 1; + return BATTERY_NOT_DISCONNECTED; } + static int charger_should_discharge_on_ac(struct charge_state_data *curr) { /* can not discharge on AC without battery */ @@ -623,14 +212,6 @@ static int charger_should_discharge_on_ac(struct charge_state_data *curr) return 0; } -/* - * This can override the smart battery's charging profile. To make a change, - * modify one or more of requested_voltage, requested_current, or state. - * Leave everything else unchanged. - * - * Return the next poll period in usec, or zero to use the default (which is - * state dependent). - */ int charger_profile_override(struct charge_state_data *curr) { int disch_on_ac = charger_should_discharge_on_ac(curr); @@ -642,12 +223,25 @@ int charger_profile_override(struct charge_state_data *curr) return 0; } - return charger_profile_override_common(curr, - board_get_batt_params()->fast_chg_params, - &prev_chg_profile_info, - board_get_batt_params()->batt_info->voltage_max); + return 0; +} + +static inline enum battery_present battery_hw_present(void) +{ + /* The GPIO is low when the battery is physically present */ + return gpio_get_level(GPIO_EC_BATT_PRES_L) ? BP_NO : BP_YES; +} + + +static int battery_init(void) +{ + int batt_status; + + return battery_status(&batt_status) ? 0 : + !!(batt_status & STATUS_INITIALIZED); } + /* * Physical detection of battery. */ @@ -671,14 +265,8 @@ enum battery_present battery_is_present(void) * Battery status will be inactive until it is initialized. */ if (batt_pres == BP_YES && batt_pres_prev != batt_pres && - !battery_is_cut_off()) { - /* Re-init board battery if battery presence status changes */ - if (board_get_battery_type() == BATTERY_TYPE_COUNT) { - if (bd9995x_get_battery_voltage() >= - board_get_batt_params()->batt_info->voltage_min) - batt_pres = BP_NO; - } else if (!board_get_batt_params()->ship_mode_inf->batt_init()) - batt_pres = BP_NO; + !battery_is_cut_off() && !battery_init()) { + batt_pres = BP_NO; } batt_pres_prev = batt_pres; @@ -690,3 +278,19 @@ int board_battery_initialized(void) { return battery_hw_present() == batt_pres_prev; } + + +/* Customs options controllable by host command. */ +#define PARAM_FASTCHARGE (CS_PARAM_CUSTOM_PROFILE_MIN + 0) + +enum ec_status charger_profile_override_get_param(uint32_t param, + uint32_t *value) +{ + return EC_RES_INVALID_PARAM; +} + +enum ec_status charger_profile_override_set_param(uint32_t param, + uint32_t value) +{ + return EC_RES_INVALID_PARAM; +} diff --git a/board/coral/board.h b/board/coral/board.h index a9c31ab091..097137b9b0 100644 --- a/board/coral/board.h +++ b/board/coral/board.h @@ -59,9 +59,6 @@ #define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 1 #define CONFIG_USB_CHARGER #define CONFIG_CHARGER_PROFILE_OVERRIDE -#define CONFIG_CHARGER_PROFILE_OVERRIDE_COMMON -#undef CONFIG_CHARGER_PROFILE_VOLTAGE_RANGES -#define CONFIG_CHARGER_PROFILE_VOLTAGE_RANGES 3 #define CONFIG_CHARGE_MANAGER_EXTERNAL_POWER_LIMIT /* USB-A config */ |