diff options
author | Shawn Nematbakhsh <shawnn@chromium.org> | 2014-12-05 16:23:11 -0800 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-12-09 02:06:56 +0000 |
commit | c8f98e80fdbe85fc0bc0f892d4b22dad19186aef (patch) | |
tree | d384b4c3ff27506a7442a91a7bc3d185c71d52a7 /driver | |
parent | 4b8be2f7786c2cd32eafc895016a721fc8d29074 (diff) | |
download | chrome-ec-c8f98e80fdbe85fc0bc0f892d4b22dad19186aef.tar.gz |
samus_pd: Open USB data switches in UFP mode
Samus USB ports can't actually act as UFPs, so open switches when in
UFP mode.
BUG=chrome-os-partner:32003
TEST=Manual on Samus. Connect two Samus units, run `pd 1 swap data`,
verify that switches are opened on switch to UFP. Unplug samus and
connect a USB 2.0 device instead, verify that ports are again closed.
BRANCH=samus
Change-Id: I9e1ca58089caf29e419698c8426bf8b72500833a
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/233711
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Diffstat (limited to 'driver')
-rw-r--r-- | driver/pi3usb9281.h | 5 | ||||
-rw-r--r-- | driver/usb_switch_pi3usb9281.c | 11 |
2 files changed, 15 insertions, 1 deletions
diff --git a/driver/pi3usb9281.h b/driver/pi3usb9281.h index 392c02ae52..38f1125535 100644 --- a/driver/pi3usb9281.h +++ b/driver/pi3usb9281.h @@ -82,9 +82,12 @@ int pi3usb9281_get_ilim(int device_type, int charger_status); /* Set switch configuration to manual. */ int pi3usb9281_set_switch_manual(uint8_t chip_idx, int val); -/* Set bits to enable pins in manual switch register */ +/* Set bits to enable pins in manual switch register. */ int pi3usb9281_set_pins(uint8_t chip_idx, uint8_t mask); +/* Set D+/D-/Vbus switches to open or closed/auto-control. */ +int pi3usb9281_set_switches(uint8_t chip_idx, int open); + /* Reset PI3USB9281. */ int pi3usb9281_reset(uint8_t chip_idx); diff --git a/driver/usb_switch_pi3usb9281.c b/driver/usb_switch_pi3usb9281.c index 78580fc7a8..329c476708 100644 --- a/driver/usb_switch_pi3usb9281.c +++ b/driver/usb_switch_pi3usb9281.c @@ -185,6 +185,17 @@ int pi3usb9281_set_pins(uint8_t chip_idx, uint8_t val) return pi3usb9281_write(chip_idx, PI3USB9281_REG_MANUAL, val); } +int pi3usb9281_set_switches(uint8_t chip_idx, int open) +{ + uint8_t ctrl = pi3usb9281_read(chip_idx, PI3USB9281_REG_CONTROL) & 0x15; + if (open) + ctrl &= ~PI3USB9281_CTRL_SWITCH_AUTO; + else + ctrl |= PI3USB9281_CTRL_SWITCH_AUTO; + + return pi3usb9281_write(chip_idx, PI3USB9281_REG_CONTROL, ctrl); +} + static void pi3usb9281_init(void) { uint8_t dev_id; |