mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-30 18:41:11 +00:00
amenia: reject charge port on init till battery is initialized
Ported from the below patch Change-Id: I981f9dbf3d84390550bb696e561f5fa51ffc573a Reviewed-on: https://chromium-review.googlesource.com/351224 BUG=chrome-os-partner:54058 BRANCH=none TEST=Amenia system does not reboot before booting to OS. Active port is set once battery is available. Change-Id: If8fd84f82f5a7fb7ca3736031a161d90e5e77c12 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/349853 Commit-Ready: Kevin K Wong <kevin.k.wong@intel.com> Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Shawn N <shawnn@chromium.org>
This commit is contained in:
committed by
chrome-bot
parent
65a8032258
commit
96fbb35687
@@ -72,7 +72,7 @@ int board_cut_off_battery(void)
|
||||
enum battery_present battery_is_present(void)
|
||||
{
|
||||
enum battery_present batt_pres;
|
||||
const struct batt_params *batt = charger_current_battery_params();
|
||||
int batt_status;
|
||||
|
||||
/* The GPIO is low when the battery is physically present */
|
||||
batt_pres = gpio_get_level(GPIO_BAT_PRESENT_L) ? BP_NO : BP_YES;
|
||||
@@ -86,8 +86,8 @@ enum battery_present battery_is_present(void)
|
||||
* 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 && !(batt->flags & BATT_FLAG_BAD_STATUS))
|
||||
if (!(batt->status & STATUS_INITIALIZED))
|
||||
if (batt_pres == BP_YES && !battery_status(&batt_status))
|
||||
if (!(batt_status & STATUS_INITIALIZED))
|
||||
batt_pres = BP_NO;
|
||||
|
||||
return batt_pres;
|
||||
|
||||
@@ -245,6 +245,12 @@ const struct button_config buttons[CONFIG_BUTTON_COUNT] = {
|
||||
30 * MSEC, 0},
|
||||
};
|
||||
|
||||
static const enum bd99955_charge_port
|
||||
pd_port_to_bd99955_port[CONFIG_USB_PD_PORT_COUNT] = {
|
||||
[0] = BD99955_CHARGE_PORT_VBUS,
|
||||
[1] = BD99955_CHARGE_PORT_VCC,
|
||||
};
|
||||
|
||||
/* Called by APL power state machine when transitioning from G3 to S5 */
|
||||
static void chipset_pre_init(void)
|
||||
{
|
||||
@@ -270,6 +276,23 @@ static void board_init(void)
|
||||
}
|
||||
DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
|
||||
|
||||
int pd_snk_is_vbus_provided(int port)
|
||||
{
|
||||
enum bd99955_charge_port bd99955_port;
|
||||
|
||||
switch (port) {
|
||||
case 0:
|
||||
case 1:
|
||||
bd99955_port = pd_port_to_bd99955_port[port];
|
||||
break;
|
||||
default:
|
||||
panic("Invalid charge port\n");
|
||||
break;
|
||||
}
|
||||
|
||||
return bd99955_is_vbus_provided(bd99955_port);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set active charge port -- only one port can be active at a time.
|
||||
*
|
||||
@@ -281,6 +304,7 @@ DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
|
||||
int board_set_active_charge_port(int charge_port)
|
||||
{
|
||||
enum bd99955_charge_port bd99955_port;
|
||||
static int initialized;
|
||||
|
||||
/* charge port is a realy physical port */
|
||||
int is_real_port = (charge_port >= 0 &&
|
||||
@@ -293,14 +317,24 @@ int board_set_active_charge_port(int charge_port)
|
||||
return EC_ERROR_INVAL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Reject charge port disable if our battery is critical and we
|
||||
* have yet to initialize a charge port - continue to charge using
|
||||
* charger ROM / POR settings.
|
||||
*/
|
||||
if (!initialized &&
|
||||
charge_port == CHARGE_PORT_NONE &&
|
||||
charge_get_percent() < 2) {
|
||||
CPRINTS("Battery critical, don't disable charging");
|
||||
return -1;
|
||||
}
|
||||
|
||||
CPRINTS("New chg p%d", charge_port);
|
||||
|
||||
switch (charge_port) {
|
||||
case 0:
|
||||
bd99955_port = BD99955_CHARGE_PORT_VBUS;
|
||||
break;
|
||||
case 1:
|
||||
bd99955_port = BD99955_CHARGE_PORT_VCC;
|
||||
bd99955_port = pd_port_to_bd99955_port[charge_port];
|
||||
break;
|
||||
case CHARGE_PORT_NONE:
|
||||
bd99955_port = BD99955_CHARGE_PORT_NONE;
|
||||
@@ -310,6 +344,8 @@ int board_set_active_charge_port(int charge_port)
|
||||
break;
|
||||
}
|
||||
|
||||
initialized = 1;
|
||||
|
||||
return bd99955_select_input_port(bd99955_port);
|
||||
}
|
||||
|
||||
|
||||
@@ -103,11 +103,6 @@ void typec_set_input_current_limit(int port, uint32_t max_ma,
|
||||
pd_send_host_event(PD_EVENT_POWER_CHANGE);
|
||||
}
|
||||
|
||||
int pd_snk_is_vbus_provided(int port)
|
||||
{
|
||||
return bd99955_is_vbus_provided(port);
|
||||
}
|
||||
|
||||
int pd_board_checks(void)
|
||||
{
|
||||
return EC_SUCCESS;
|
||||
|
||||
Reference in New Issue
Block a user