summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Yilun Lin <yllin@chromium.org>2021-04-27 16:53:11 +0800
committerCommit Bot <commit-bot@chromium.org>2021-04-28 05:25:48 +0000
commit688f36f9861874d4cd89b64bcc551a5d19e157c7 (patch)
tree0ea5021298810e8744dd48c4618053ac29aa285f
parentb33d94e0a4ab48c82580eda38a62a93f108836f0 (diff)
downloadchrome-ec-stabilize-13942.B-main.tar.gz
asurada: inform usb_charger of VBUS changestabilize-13942.B-main
Since we do not use PPC for detecting VBUS in the following revision(hayato>=4), we should inform the usb_charger of VBUS status change. BUG=b:186366435 TEST=ectool usbpdpower showed disconnected if unplug adapter BRANCH=ASURADA Change-Id: Iafa37bd926a0f42d660e79a78612819848b738ae Signed-off-by: Eric Yilun Lin <yllin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2853088 Reviewed-by: Ting Shen <phoenixshen@chromium.org> Commit-Queue: Eric Yilun Lin <yllin@google.com> Tested-by: Eric Yilun Lin <yllin@google.com>
-rw-r--r--baseboard/asurada/usb_pd_policy.c21
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)