summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlec Berg <alecaberg@chromium.org>2015-06-09 16:40:33 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-06-10 03:33:38 +0000
commit03f711b8556f891a0418bee474ea71c271010935 (patch)
tree3984ceb36d8106e06699c3871a21f1b768bcff27
parentd2c47812664c13d4330600caadafc59d62b814c9 (diff)
downloadchrome-ec-03f711b8556f891a0418bee474ea71c271010935.tar.gz
ryu: allow charge manager to control CHARGE_EN gpio
Move control of CHARGE_EN from the PD state machine, where it was tied to our CC termination value, to charge manager when charge manager sets the active charge port. This allows ryu to charge from debug accessory where we advertise Rp but still want to charge. BUG=none BRANCH=smaug TEST=load onto ryu and plug in zinger, hoho, and suzyQ and make sure we negotiate a contract with PD partners, and that we charge from power supplies. Change-Id: I81d9997c011eac6d5136fca8e97a5da3470a8e8a Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/276543 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--board/ryu/board.c13
-rw-r--r--board/ryu/usb_pd_config.h2
2 files changed, 5 insertions, 10 deletions
diff --git a/board/ryu/board.c b/board/ryu/board.c
index 9f87faf6b6..24655456ba 100644
--- a/board/ryu/board.c
+++ b/board/ryu/board.c
@@ -540,21 +540,18 @@ DECLARE_DEFERRED(board_charge_manager_override_timeout);
*/
int board_set_active_charge_port(int charge_port)
{
- int ret = EC_SUCCESS;
/* check if we are source vbus on that port */
int src = gpio_get_level(GPIO_CHGR_OTG);
if (charge_port >= 0 && charge_port < CONFIG_USB_PD_PORT_COUNT && src) {
CPRINTS("Port %d is not a sink, skipping enable", charge_port);
- charge_port = CHARGE_PORT_NONE;
- ret = EC_ERROR_INVAL;
- }
- if (charge_port == CHARGE_PORT_NONE) {
- /* Disable charging */
- charge_set_input_current_limit(0);
+ return EC_ERROR_INVAL;
}
- return ret;
+ /* Enable/disable charging */
+ gpio_set_level(GPIO_USBC_CHARGE_EN_L, charge_port == CHARGE_PORT_NONE);
+
+ return EC_SUCCESS;
}
/**
diff --git a/board/ryu/usb_pd_config.h b/board/ryu/usb_pd_config.h
index 6c5252be70..eff6a6b95b 100644
--- a/board/ryu/usb_pd_config.h
+++ b/board/ryu/usb_pd_config.h
@@ -129,7 +129,6 @@ static inline void pd_set_host_mode(int port, int enable)
if (enable) {
/* We never charging in power source mode */
gpio_set_level(GPIO_USBC_CHARGE_EN_L, 1);
- charge_set_input_current_limit(0);
/* High-Z is used for host mode. */
gpio_set_level(GPIO_USBC_CC1_DEVICE_ODL, 1);
gpio_set_level(GPIO_USBC_CC2_DEVICE_ODL, 1);
@@ -146,7 +145,6 @@ static inline void pd_set_host_mode(int port, int enable)
/* Pull low for device mode. */
gpio_set_level(GPIO_USBC_CC1_DEVICE_ODL, 0);
gpio_set_level(GPIO_USBC_CC2_DEVICE_ODL, 0);
- gpio_set_level(GPIO_USBC_CHARGE_EN_L, 0);
}
}