From 5725f4f0ef8a86e81ec3bd5b5f91a74c556e003c Mon Sep 17 00:00:00 2001 From: Vincent Palatin Date: Thu, 22 May 2014 08:51:51 -0700 Subject: samus_pd: provide VBUS in host mode When we are a USB host (and a power source), provide 5V VBUS on the type-C receptacle. Signed-off-by: Vincent Palatin BRANCH=none BUG=chrome-os-partner:28782 TEST=on Samus, put port0 in host mode (by doing "pd charger" on the PD MCU command line), then insert a type-C to type-A cable and observe we have VBUS on the other side. Change-Id: I5c6cd78b54dc1c651420eaaf122b8545b9f0b0de Reviewed-on: https://chromium-review.googlesource.com/201066 Reviewed-by: Alec Berg Tested-by: Vincent Palatin Commit-Queue: Vincent Palatin --- board/samus_pd/usb_pd_config.h | 6 ++++++ board/samus_pd/usb_pd_policy.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/board/samus_pd/usb_pd_config.h b/board/samus_pd/usb_pd_config.h index 767c104e71..d425984357 100644 --- a/board/samus_pd/usb_pd_config.h +++ b/board/samus_pd/usb_pd_config.h @@ -92,13 +92,19 @@ static inline void pd_tx_init(void) static inline void pd_set_host_mode(int enable) { if (enable) { + /* We never charging in power source mode */ + gpio_set_level(GPIO_USB_C0_CHARGE_EN_L, 1); /* High-Z is used for host mode. */ gpio_set_level(GPIO_USB_C0_CC1_ODL, 1); gpio_set_level(GPIO_USB_C0_CC2_ODL, 1); } else { + /* Kill VBUS power supply */ + gpio_set_level(GPIO_USB_C0_5V_EN, 0); /* Pull low for device mode. */ gpio_set_level(GPIO_USB_C0_CC1_ODL, 0); gpio_set_level(GPIO_USB_C0_CC2_ODL, 0); + /* Enable the charging path*/ + gpio_set_level(GPIO_USB_C0_CHARGE_EN_L, 0); } } diff --git a/board/samus_pd/usb_pd_policy.c b/board/samus_pd/usb_pd_policy.c index 3d6b30250c..ea5f2d1703 100644 --- a/board/samus_pd/usb_pd_policy.c +++ b/board/samus_pd/usb_pd_policy.c @@ -6,6 +6,7 @@ #include "board.h" #include "common.h" #include "console.h" +#include "gpio.h" #include "hooks.h" #include "registers.h" #include "task.h" @@ -106,11 +107,16 @@ int pd_request_voltage(uint32_t rdo) int pd_set_power_supply_ready(void) { + /* provide VBUS */ + gpio_set_level(GPIO_USB_C0_5V_EN, 1); + return EC_SUCCESS; /* we are ready */ } void pd_power_supply_reset(void) { + /* Kill VBUS */ + gpio_set_level(GPIO_USB_C0_5V_EN, 0); } int pd_board_checks(void) -- cgit v1.2.1