diff options
-rw-r--r-- | baseboard/asurada/usb_pd_policy.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/baseboard/asurada/usb_pd_policy.c b/baseboard/asurada/usb_pd_policy.c index f9b8bb6cd1..1dbdd0cf40 100644 --- a/baseboard/asurada/usb_pd_policy.c +++ b/baseboard/asurada/usb_pd_policy.c @@ -3,6 +3,7 @@ * found in the LICENSE file. */ #include "adc.h" +#include "atomic.h" #include "charge_manager.h" #include "chipset.h" #include "timer.h" @@ -149,6 +150,9 @@ __override void svdm_exit_dp_mode(int port) int pd_snk_is_vbus_provided(int port) { + static int vbus_prev[CONFIG_USB_PD_PORT_MAX_COUNT]; + int vbus; + if ((IS_ENABLED(BOARD_HAYATO) && board_get_version() < 4) || (IS_ENABLED(BOARD_SPHERION) && board_get_version() < 1)) return ppc_is_vbus_present(port); @@ -157,8 +161,23 @@ int pd_snk_is_vbus_provided(int port) * (b:181203590#comment20) TODO(yllin): use * PD_VSINK_DISCONNECT_PD for non-5V case. */ - return adc_read_channel(board_get_vbus_adc(port)) >= + vbus = adc_read_channel(board_get_vbus_adc(port)) >= PD_V_SINK_DISCONNECT_MAX; + +#ifdef CONFIG_USB_CHARGER + /* + * There's no PPC to inform VBUS change for usb_charger, so inform + * the usb_charger now. + */ + if (!!(vbus_prev[port] != vbus)) + usb_charger_vbus_change(port, vbus); + + if (vbus) + atomic_or(&vbus_prev[port], 1); + else + atomic_clear(&vbus_prev[port]); +#endif + return vbus; } void pd_power_supply_reset(int port) |