mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-13 03:15:06 +00:00
usb_charger: initialize VBUS supplier at startup
When using VBUS_DETECT_TCPC the charger code relied on the TCPC alert to initialize the VBUS supply, but that happens too late in board startup sequence to allow an initally plugged in USB-C power supply to be chosen as the active charging port. We can and should initialize the the supplier sooner as to prevent the charge_manager_is_seeded() check from failing thus preventing the board from choosing a charging port. BRANCH=none BUG=b:77458917 TEST=PS8751 on yorp will negotiate 20V over USB-C (which was prevent by the charge_manager not being seeded) Change-Id: I6f612c508932a90ece0036ce8310a20de02d8467 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/994707 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Divya S Sasidharan <divya.s.sasidharan@intel.com> Reviewed-by: Divya S Sasidharan <divya.s.sasidharan@intel.com> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
@@ -468,11 +468,6 @@ int board_get_version(void)
|
||||
|
||||
static void board_init(void)
|
||||
{
|
||||
#ifdef BOARD_ZOOMBINI
|
||||
struct charge_port_info chg;
|
||||
int i;
|
||||
#endif /* defined(BOARD_ZOOMBINI) */
|
||||
|
||||
#ifdef BOARD_ZOOMBINI
|
||||
/* Enable PPC interrupts. */
|
||||
gpio_enable_interrupt(GPIO_USB_C0_PPC_INT_L);
|
||||
@@ -488,18 +483,6 @@ static void board_init(void)
|
||||
gpio_enable_interrupt(GPIO_USB_C1_PD_INT_L);
|
||||
#ifdef BOARD_ZOOMBINI
|
||||
gpio_enable_interrupt(GPIO_USB_C2_PD_INT_L);
|
||||
|
||||
/* Initialize VBUS suppliers. */
|
||||
for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) {
|
||||
if (tcpm_get_vbus_level(i)) {
|
||||
chg.voltage = 5000;
|
||||
chg.current = USB_CHARGER_MIN_CURR_MA;
|
||||
} else {
|
||||
chg.voltage = 0;
|
||||
chg.current = 0;
|
||||
}
|
||||
charge_manager_update_charge(CHARGE_SUPPLIER_VBUS, i, &chg);
|
||||
}
|
||||
#endif /* defined(BOARD_ZOOMBINI) */
|
||||
}
|
||||
DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
|
||||
|
||||
@@ -88,7 +88,7 @@ static void usb_charger_init(void)
|
||||
int i;
|
||||
struct charge_port_info charge_none;
|
||||
|
||||
/* Initialize all charge suppliers to 0 */
|
||||
/* Initialize all charge suppliers */
|
||||
charge_none.voltage = USB_CHARGER_VOLTAGE_MV;
|
||||
charge_none.current = 0;
|
||||
for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) {
|
||||
@@ -107,15 +107,8 @@ static void usb_charger_init(void)
|
||||
charge_manager_update_charge(CHARGE_SUPPLIER_OTHER,
|
||||
i,
|
||||
&charge_none);
|
||||
|
||||
#ifndef CONFIG_USB_PD_VBUS_DETECT_TCPC
|
||||
/*
|
||||
* Initialize VBUS supplier based on whether VBUS is present.
|
||||
* For CONFIG_USB_PD_VBUS_DETECT_TCPC, usb_charger_vbus_change()
|
||||
* will be called directly from TCPC alert.
|
||||
*/
|
||||
update_vbus_supplier(i, pd_snk_is_vbus_provided(i));
|
||||
#endif
|
||||
/* Initialize VBUS supplier based on whether VBUS is present. */
|
||||
update_vbus_supplier(i, pd_is_vbus_present(i));
|
||||
}
|
||||
}
|
||||
DECLARE_HOOK(HOOK_INIT, usb_charger_init, HOOK_PRIO_CHARGE_MANAGER_INIT + 1);
|
||||
|
||||
@@ -307,8 +307,9 @@ void pd_vbus_low(int port)
|
||||
{
|
||||
pd[port].flags &= ~PD_FLAGS_VBUS_NEVER_LOW;
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline int pd_is_vbus_present(int port)
|
||||
int pd_is_vbus_present(int port)
|
||||
{
|
||||
#ifdef CONFIG_USB_PD_VBUS_DETECT_TCPC
|
||||
return tcpm_get_vbus_level(port);
|
||||
@@ -316,7 +317,6 @@ static inline int pd_is_vbus_present(int port)
|
||||
return pd_snk_is_vbus_provided(port);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
static void set_polarity(int port, int polarity)
|
||||
{
|
||||
|
||||
@@ -1746,6 +1746,13 @@ int pd_ts_dts_plugged(int port);
|
||||
*/
|
||||
int pd_capable(int port);
|
||||
|
||||
/**
|
||||
* Return true if vbus is present on the specified port.
|
||||
*
|
||||
* @param port USB-C port number
|
||||
*/
|
||||
int pd_is_vbus_present(int port);
|
||||
|
||||
/* ----- Logging ----- */
|
||||
#ifdef CONFIG_USB_PD_LOGGING
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user