diff options
author | Denis Brockus <dbrockus@chromium.org> | 2019-11-11 13:01:18 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-11-13 15:43:31 +0000 |
commit | 3c315108e549bd6285d2729372151cda913c7b53 (patch) | |
tree | c1e7bde371afa522293d20f88858ca8b0dcf0fa6 /driver | |
parent | 02dd6d5f7c632664929ee76ef75fc9fa443ef6e8 (diff) | |
download | chrome-ec-3c315108e549bd6285d2729372151cda913c7b53.tar.gz |
usb_mux: Change AMD_FP5 mux driver to handle no power
Make sure if we are setting the mux to 0 and no power is
applied, make sure to return back SUCCESS, Also when getting
this with power off, we should return 0 and SUCCESS.
BUG=none
BRANCH=none
TEST=plug in charger into USBC with no power to AP and verify no errors
Change-Id: I3a63961a80c8ecd73dd21cf01e7d7e99b128e189
Signed-off-by: Denis Brockus <dbrockus@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1910485
Reviewed-by: Edward Hill <ecgh@chromium.org>
Diffstat (limited to 'driver')
-rw-r--r-- | driver/usb_mux/amd_fp5.c | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/driver/usb_mux/amd_fp5.c b/driver/usb_mux/amd_fp5.c index f88df52577..a912d03365 100644 --- a/driver/usb_mux/amd_fp5.c +++ b/driver/usb_mux/amd_fp5.c @@ -6,6 +6,7 @@ */ #include "amd_fp5.h" +#include "chipset.h" #include "common.h" #include "i2c.h" #include "usb_mux.h" @@ -40,6 +41,17 @@ static int amd_fp5_set_mux(int port, mux_state_t mux_state) { uint8_t val = 0; + /* + * This MUX is on the FP5 SoC. If that device is not powered then + * we either have to complain that it is not powered or if we were + * setting the state to OFF, then go ahead and report that we did + * it because a powered down MUX is off. + */ + if (chipset_in_state(CHIPSET_STATE_HARD_OFF)) + return (mux_state == TYPEC_MUX_NONE) + ? EC_SUCCESS + : EC_ERROR_NOT_POWERED; + if ((mux_state & MUX_USB_ENABLED) && (mux_state & MUX_DP_ENABLED)) val = (mux_state & MUX_POLARITY_INVERTED) ? AMD_FP5_MUX_DOCK_INVERTED : AMD_FP5_MUX_DOCK; @@ -55,12 +67,21 @@ static int amd_fp5_set_mux(int port, mux_state_t mux_state) static int amd_fp5_get_mux(int port, mux_state_t *mux_state) { - uint8_t val = 0; - int rv; + uint8_t val = AMD_FP5_MUX_SAFE; + + /* + * This MUX is on the FP5 SoC. Only access the device if we + * have power. If that device is not powered then claim the + * state to be NONE, which is SAFE. + */ + if (!chipset_in_state(CHIPSET_STATE_HARD_OFF)) { + int rv; + + rv = amd_fp5_mux_read(port, &val); + if (rv) + return rv; + } - rv = amd_fp5_mux_read(port, &val); - if (rv) - return rv; switch (val) { case AMD_FP5_MUX_USB: @@ -82,8 +103,9 @@ static int amd_fp5_get_mux(int port, mux_state_t *mux_state) case AMD_FP5_MUX_DP_INVERTED: *mux_state = MUX_DP_ENABLED | MUX_POLARITY_INVERTED; break; + case AMD_FP5_MUX_SAFE: default: - *mux_state = 0; + *mux_state = TYPEC_MUX_NONE; break; } |