diff options
author | xiong.huang <xiong.huang@bitland.corp-partner.google.com> | 2019-12-02 15:19:57 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-12-13 06:15:11 +0000 |
commit | 605277a471915129d94fdfa368dcac13d0d395aa (patch) | |
tree | 16b8ba92c31110e576523d3fe9e3cb38a36144d1 /board/kodama | |
parent | 4b0723c43c44d37eb3f5aff307a97cbdafdd28b5 (diff) | |
download | chrome-ec-605277a471915129d94fdfa368dcac13d0d395aa.tar.gz |
Kodama: battery cannot be charged to full
When kodama's bitbang driver sometime fails, will reset request voltage and
current, which may trigger charger EOC event and terminate charging. On the
other hand, charger has EOC accuracy issue.
So mt6370's VOREG always be set as 4400mV and minimum value of mt6370's
ICHG is limited as 500mA. Set IEOC as 150mA.
BUG=b:145474380
TEST=Verified on both SMP battery and Celxpert battery, all can be charged
to full.
BRANCH=kukui
Change-Id: Ie1427448e22261d33cb83f4cc6c30e428b97292c
Signed-off-by: Xiong Huang <xiong.huang@bitland.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1943636
Reviewed-by: Eric Yilun Lin <yllin@chromium.org>
Diffstat (limited to 'board/kodama')
-rw-r--r-- | board/kodama/battery.c | 74 | ||||
-rw-r--r-- | board/kodama/board.c | 15 | ||||
-rw-r--r-- | board/kodama/board.h | 4 |
3 files changed, 46 insertions, 47 deletions
diff --git a/board/kodama/battery.c b/board/kodama/battery.c index e64e0c167a..7b7a3d7cb6 100644 --- a/board/kodama/battery.c +++ b/board/kodama/battery.c @@ -95,59 +95,47 @@ int charger_profile_override(struct charge_state_data *curr) * be turned off. Disable EOC and TE when battery stays over discharge * state, otherwise enable EOC and TE. */ - if (curr->batt.voltage < batt_info->voltage_min) { - normal_charge_lock = 0; - - if (!over_discharge_lock && curr->state == ST_CHARGE) { - over_discharge_lock = 1; - rt946x_enable_charge_eoc(0); - rt946x_enable_charge_termination(0); - } - } else { - over_discharge_lock = 0; + if (!(curr->batt.flags & BATT_FLAG_BAD_VOLTAGE)) { + if (curr->batt.voltage < batt_info->voltage_min) { + normal_charge_lock = 0; + + if (!over_discharge_lock && curr->state == ST_CHARGE) { + over_discharge_lock = 1; + rt946x_enable_charge_eoc(0); + rt946x_enable_charge_termination(0); + } + } else { + over_discharge_lock = 0; - if (!normal_charge_lock) { - normal_charge_lock = 1; - rt946x_enable_charge_eoc(1); - rt946x_enable_charge_termination(1); + if (!normal_charge_lock) { + normal_charge_lock = 1; + rt946x_enable_charge_eoc(1); + rt946x_enable_charge_termination(1); + } } } +#ifdef VARIANT_KUKUI_CHARGER_MT6370 + mt6370_charger_profile_override(curr); +#endif /* CONFIG_CHARGER_MT6370 */ + /* * When smart battery temperature is more than 45 deg C, the max * charging voltage is 4100mV. */ - if (curr->state == ST_CHARGE && bat_temp_c >= 450) + if (curr->state == ST_CHARGE && bat_temp_c >= 450 + && !(curr->batt.flags & BATT_FLAG_BAD_TEMPERATURE)) curr->requested_voltage = 4100; + else + curr->requested_voltage = batt_info->voltage_max; -#ifdef VARIANT_KUKUI_CHARGER_MT6370 - mt6370_charger_profile_override(curr); -#endif /* CONFIG_CHARGER_MT6370 */ - - if (IS_ENABLED(CONFIG_CHARGER_MAINTAIN_VBAT)) { - /* Turn charger off if it's not needed */ - if (curr->state == ST_IDLE || curr->state == ST_DISCHARGE) { - curr->requested_voltage = 0; - curr->requested_current = 0; - } - - if (!curr->batt.is_present && - curr->requested_voltage == 0 && - curr->requested_current == 0) { - /* - * b/138978212: With adapter plugged in S0, the system - * will set charging current and voltage as 0V/0A once - * removing battery. Vsys drop to lower voltage - * (Vsys < 2.5V) since Vsys's loading, then system will - * shutdown. Keep max charging voltage as 4.4V when - * remove battery in S0 to not let the system to trigger - * under voltage (Vsys < 2.5V). - */ - CPRINTS("battery disconnected"); - curr->requested_voltage = batt_info->voltage_max; - curr->requested_current = 500; - } - } + /* + * mt6370's minimum regulated current is 500mA REG17[7:2] 0b100, + * values below 0b100 are preserved. In the other hand, it makes sure + * mt6370's VOREG set as 4400mV and minimum value of mt6370's ICHG + * is limited as 500mA. + */ + curr->requested_current = MAX(500, curr->requested_current); return 0; } diff --git a/board/kodama/board.c b/board/kodama/board.c index 953c3e7831..deedea88fd 100644 --- a/board/kodama/board.c +++ b/board/kodama/board.c @@ -100,6 +100,21 @@ static void board_hpd_status(int port, int hpd_lvl, int hpd_irq) host_set_single_event(EC_HOST_EVENT_USB_MUX); } + +__override const struct rt946x_init_setting *board_rt946x_init_setting(void) +{ + static const struct rt946x_init_setting battery_init_setting = { + .eoc_current = 150, + .mivr = 4000, + .ircmp_vclamp = 32, + .ircmp_res = 25, + .boost_voltage = 5050, + .boost_current = 1500, + }; + + return &battery_init_setting; +} + struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .port_addr = IT5205_I2C_ADDR1_FLAGS, diff --git a/board/kodama/board.h b/board/kodama/board.h index c51ebb628b..d6d7a329b1 100644 --- a/board/kodama/board.h +++ b/board/kodama/board.h @@ -29,11 +29,7 @@ #define CONFIG_BATTERY_HW_PRESENT_CUSTOM /* Battery */ -#ifdef BOARD_KRANE -#define BATTERY_DESIRED_CHARGING_CURRENT 3500 /* mA */ -#else #define BATTERY_DESIRED_CHARGING_CURRENT 2000 /* mA */ -#endif /* BOARD_KRANE */ #define CONFIG_CHARGER_MT6370_BACKLIGHT #define CONFIG_CHARGER_MAINTAIN_VBAT |