mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-27 18:25:05 +00:00
charger/Kunimitsu: Fix for boot from cut-off battery
Battery in cut-off mode wakes when voltage is applied to the PACK
and takes approximately 2 to 3 seconds to initialize before capable
of providing the power. Hence made the battery present status to
BP_NO in case of cut-off mode. Once the battery is ready new status
is updated as BP_YES.
When the battery status changes from BP_NO to BP_YES, charger input
current is set to board specific charger input current which is not
sufficient to boot the AP hence the system reboots. To avoid this
issue, added code to write charger manager negotiated current to
charger input current when the battery status changes from BP_NO to
BP_YES.
BRANCH=none
BUG=chrome-os-partner:49224
TEST=Manually tested on Kunimitsu.
Used console command 'cutoff' to put the battery in cut-off mode.
Inserted the adopter to wake the system, system doesn't reboot &
the battery charges.
Change-Id: Ia5a1457506b4bef0b3dd27993e4b60ae64c8f746
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/322430
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
This commit is contained in:
committed by
chrome-bot
parent
0c50cae42e
commit
33fe5e437d
@@ -5,6 +5,7 @@
|
||||
* Battery pack vendor provided charging profile
|
||||
*/
|
||||
|
||||
#include "adc.h"
|
||||
#include "battery.h"
|
||||
#include "battery_smart.h"
|
||||
#include "util.h"
|
||||
@@ -42,3 +43,41 @@ int board_cut_off_battery(void)
|
||||
|
||||
return sb_write(SB_MANUFACTURER_ACCESS, SB_SHUTDOWN_DATA);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_BATTERY_PRESENT_CUSTOM
|
||||
/*
|
||||
* Physical detection of battery via ADC.
|
||||
*
|
||||
* Upper limit of valid voltage level (mV), when battery is attached to ADC
|
||||
* port, is across the internal thermistor with external pullup resistor.
|
||||
*/
|
||||
#define BATT_PRESENT_MV 1500
|
||||
enum battery_present battery_is_present(void)
|
||||
{
|
||||
enum battery_present batt_pres;
|
||||
int batt_status;
|
||||
|
||||
/*
|
||||
* if voltage is below certain level (dependent on ratio of
|
||||
* internal thermistor and external pullup resister),
|
||||
* battery is attached.
|
||||
*/
|
||||
batt_pres = (adc_read_channel(ADC_BATT_PRESENT) > BATT_PRESENT_MV) ?
|
||||
BP_NO : BP_YES;
|
||||
|
||||
/*
|
||||
* Make sure battery status is implemented, I2C transactions are
|
||||
* success & the battery status is Initialized to find out if it
|
||||
* is a working battery and it is not in the cut-off mode.
|
||||
*
|
||||
* FETs are turned off after Power Shutdown time.
|
||||
* The device will wake up when a voltage is applied to PACK.
|
||||
* Battery status will be inactive until it is initialized.
|
||||
*/
|
||||
if (batt_pres == BP_YES && !battery_status(&batt_status))
|
||||
if (!(batt_status & STATUS_INITIALIZED))
|
||||
batt_pres = BP_NO;
|
||||
|
||||
return batt_pres;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -631,23 +631,3 @@ static void board_handle_reboot(void)
|
||||
; /* wait here */
|
||||
}
|
||||
DECLARE_HOOK(HOOK_INIT, board_handle_reboot, HOOK_PRIO_FIRST);
|
||||
|
||||
#ifdef CONFIG_BATTERY_PRESENT_CUSTOM
|
||||
/*
|
||||
* Physical detection of battery via ADC.
|
||||
*
|
||||
* Uppper limit of valid voltage level(mV), when battery is attached to ADC port,
|
||||
* is across the internal thermistor with external pullup resistor.
|
||||
*/
|
||||
#define BATT_PRESENT_MV 1500
|
||||
enum battery_present battery_is_present(void)
|
||||
{
|
||||
/*
|
||||
* if voltage is below certain level(dependant on ratio of
|
||||
* internal thermistor and external pullup resister),
|
||||
* battery is attached.
|
||||
*/
|
||||
return (adc_read_channel(ADC_BATT_PRESENT) > BATT_PRESENT_MV) ?
|
||||
BP_NO : BP_YES;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -809,6 +809,15 @@ int charge_manager_get_active_charge_port(void)
|
||||
return charge_port;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the charger current (mA) value.
|
||||
*/
|
||||
int charge_manager_get_charger_current(void)
|
||||
{
|
||||
return (charge_current != CHARGE_CURRENT_UNINITIALIZED) ?
|
||||
charge_current : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the power limit (uW) set by charge manager.
|
||||
*/
|
||||
|
||||
@@ -564,9 +564,14 @@ DECLARE_HOOK(HOOK_INIT, charger_init, HOOK_PRIO_DEFAULT);
|
||||
int get_desired_input_current(enum battery_present batt_present,
|
||||
const struct charger_info * const info)
|
||||
{
|
||||
if (batt_present == BP_YES || system_is_locked())
|
||||
if (batt_present == BP_YES || system_is_locked()) {
|
||||
#ifdef CONFIG_CHARGE_MANAGER
|
||||
return MAX(CONFIG_CHARGER_INPUT_CURRENT,
|
||||
charge_manager_get_charger_current());
|
||||
#else
|
||||
return CONFIG_CHARGER_INPUT_CURRENT;
|
||||
else
|
||||
#endif
|
||||
} else
|
||||
return info->input_current_max;
|
||||
}
|
||||
|
||||
|
||||
@@ -77,6 +77,9 @@ int charge_manager_get_active_charge_port(void);
|
||||
/* Return the power limit (uW) set by charge manager. */
|
||||
int charge_manager_get_power_limit_uw(void);
|
||||
|
||||
/* Return the charger current (mA) value. */
|
||||
int charge_manager_get_charger_current(void);
|
||||
|
||||
#ifdef CONFIG_USB_PD_LOGGING
|
||||
/* Save power state log entry for the given port */
|
||||
void charge_manager_save_log(int port);
|
||||
|
||||
Reference in New Issue
Block a user