From 1c929523a2f8077c25cf650ddff983aea4e8ef10 Mon Sep 17 00:00:00 2001 From: Nicolas Boichat Date: Wed, 19 Apr 2017 13:08:36 +0800 Subject: [PATCH] poppy: source 3A on one port Add a new source policy to provide 3A if there is only one port used as a source. Also ensure that the load switch on VBUS when sourcing power is properly configured to limit the current to 1.5A or 3.0A depending on the case. BRANCH=none BUG=b:35585396 BUG=b:35577509 TEST=On soraka (rev1), connect any USB device on port 0. On port 1 attach C-C cable to MacBook Pro. MacBook Pro charges at ~1.5A. Disconnect USB device on port 0, MacBook Pro charges at 3A. TEST=On soraka (rev1), connect USB key on port 0, see it enumerating, plug another USB key on port 1, it enumerates too, and the device on port 0 does NOT disconnect/re-enumerate. TEST=Repeat 2 tests above, but starting with port 1. Change-Id: I48e744c8edec89bc0a53b54c47f666ad53e47551 Reviewed-on: https://chromium-review.googlesource.com/481563 Commit-Ready: Nicolas Boichat Tested-by: Nicolas Boichat Reviewed-by: Vincent Palatin --- board/poppy/usb_pd_policy.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/board/poppy/usb_pd_policy.c b/board/poppy/usb_pd_policy.c index 3e39ac8269..085b86e738 100644 --- a/board/poppy/usb_pd_policy.c +++ b/board/poppy/usb_pd_policy.c @@ -110,9 +110,13 @@ int pd_set_power_supply_ready(int port) /* Disable charging */ gpio_set_level(port ? GPIO_USB_C1_CHARGE_L : GPIO_USB_C0_CHARGE_L, 1); + + /* Ensure we advertise the proper available current quota */ + charge_manager_source_port(port, 1); + /* Provide VBUS */ - gpio_set_level(port ? GPIO_USB_C1_5V_EN : - GPIO_USB_C0_5V_EN, 1); + vbus_en[port] = 1; + board_vbus_update_source_current(port); /* notify host of power info change */ pd_send_host_event(PD_EVENT_POWER_CHANGE); @@ -123,8 +127,11 @@ int pd_set_power_supply_ready(int port) void pd_power_supply_reset(int port) { /* Disable VBUS */ - gpio_set_level(port ? GPIO_USB_C1_5V_EN : - GPIO_USB_C0_5V_EN, 0); + vbus_en[port] = 0; + board_vbus_update_source_current(port); + + /* Give back the current quota we are no longer using */ + charge_manager_source_port(port, 0); /* notify host of power info change */ pd_send_host_event(PD_EVENT_POWER_CHANGE);