diff options
author | Jett Rink <jettrink@chromium.org> | 2018-04-03 18:50:03 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-04-10 19:12:55 -0700 |
commit | be6a26363871acb3529a30cdcb4189135a372bd7 (patch) | |
tree | 94bd53eb1af91d704b5b4afe03b2308559a331a0 /common | |
parent | db8d6edf26ba3f78bbab2bcda7a98e249331b8c1 (diff) | |
download | chrome-ec-be6a26363871acb3529a30cdcb4189135a372bd7.tar.gz |
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>
Diffstat (limited to 'common')
-rw-r--r-- | common/usb_charger.c | 13 | ||||
-rw-r--r-- | common/usb_pd_protocol.c | 4 |
2 files changed, 5 insertions, 12 deletions
diff --git a/common/usb_charger.c b/common/usb_charger.c index c55f32bbd4..010485afa3 100644 --- a/common/usb_charger.c +++ b/common/usb_charger.c @@ -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); diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index 2f25e06564..6f86eefb65 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -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) { |