diff options
author | Scott Collyer <scollyer@google.com> | 2018-09-05 16:48:08 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-10-02 05:19:06 -0700 |
commit | 6532316ae9e4ad998325cceec0e819c465f15972 (patch) | |
tree | 640583040b286ba6923493af64bd88e64054dcee /driver/ppc | |
parent | aa6ed242cb720f95b7be4a8316c1011841fb6fc0 (diff) | |
download | chrome-ec-6532316ae9e4ad998325cceec0e819c465f15972.tar.gz |
syv682x: Support USB changer when VBUS status changes
When VBUS changes, the USB charger task needs to be notified. This CL
adds a flag to track the value of vbus so when it's checked, a change
in status can be determined.
BUG=b:113267982
BRANCH=none
TEST=Verfied that when external USB charger is connected/removed the
USB charger task gets notified with the new current state.
Change-Id: I85025586768e68972129fb3438c7e078373c13f4
Signed-off-by: Scott Collyer <scollyer@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1208522
Commit-Ready: Scott Collyer <scollyer@chromium.org>
Tested-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'driver/ppc')
-rw-r--r-- | driver/ppc/syv682x.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/driver/ppc/syv682x.c b/driver/ppc/syv682x.c index c15bb3d19b..be341bb7b2 100644 --- a/driver/ppc/syv682x.c +++ b/driver/ppc/syv682x.c @@ -8,6 +8,7 @@ #include "console.h" #include "driver/ppc/syv682x.h" #include "i2c.h" +#include "usb_charge.h" #include "usb_pd_tcpm.h" #include "usbc_ppc.h" #include "util.h" @@ -15,6 +16,7 @@ #define SYV682X_FLAGS_SOURCE_ENABLED (1 << 0) /* 0 -> CC1, 1 -> CC2 */ #define SYV682X_FLAGS_CC_POLARITY (1 << 1) +#define SYV682X_FLAGS_VBUS_PRESENT (1 << 2) static uint8_t flags[CONFIG_USB_PD_PORT_COUNT]; #define SYV682X_VBUS_DET_THRESH_MV 4000 @@ -91,6 +93,15 @@ static int syv682x_is_vbus_present(int port) if ((val & SYV682X_STATUS_VSAFE_5V) || !(val & (SYV682X_STATUS_VSAFE_5V | SYV682X_STATUS_VSAFE_0V))) vbus = 1; +#ifdef CONFIG_USB_CHARGER + if (!!(flags[port] & SYV682X_FLAGS_VBUS_PRESENT) != vbus) + usb_charger_vbus_change(port, vbus); + + if (vbus) + flags[port] |= SYV682X_FLAGS_VBUS_PRESENT; + else + flags[port] &= ~SYV682X_FLAGS_VBUS_PRESENT; +#endif return vbus; } |