diff options
Diffstat (limited to 'driver/usb_mux/amd_fp5.c')
-rw-r--r-- | driver/usb_mux/amd_fp5.c | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/driver/usb_mux/amd_fp5.c b/driver/usb_mux/amd_fp5.c index c32e6992c2..ca042b0fa0 100644 --- a/driver/usb_mux/amd_fp5.c +++ b/driver/usb_mux/amd_fp5.c @@ -1,4 +1,4 @@ -/* Copyright 2019 The Chromium OS Authors. All rights reserved. +/* Copyright 2019 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. * @@ -22,8 +22,7 @@ static inline int amd_fp5_mux_read(const struct usb_mux *me, uint8_t *val) uint8_t buf[3] = { 0 }; int rv; - rv = i2c_xfer(me->i2c_port, me->i2c_addr_flags, - NULL, 0, buf, 3); + rv = i2c_xfer(me->i2c_port, me->i2c_addr_flags, NULL, 0, buf, 3); if (rv) return rv; @@ -34,8 +33,7 @@ static inline int amd_fp5_mux_read(const struct usb_mux *me, uint8_t *val) static inline int amd_fp5_mux_write(const struct usb_mux *me, uint8_t val) { - return i2c_write8(me->i2c_port, me->i2c_addr_flags, - me->usb_port, val); + return i2c_write8(me->i2c_port, me->i2c_addr_flags, me->usb_port, val); } static int amd_fp5_init(const struct usb_mux *me) @@ -51,6 +49,10 @@ static int amd_fp5_set_mux(const struct usb_mux *me, mux_state_t mux_state, /* This driver does not use host command ACKs */ *ack_required = false; + /* This driver treats safe mode as none */ + if (mux_state == USB_PD_MUX_SAFE_MODE) + mux_state = USB_PD_MUX_NONE; + saved_mux_state[me->usb_port] = mux_state; /* @@ -60,20 +62,22 @@ static int amd_fp5_set_mux(const struct usb_mux *me, mux_state_t mux_state, * it because a powered down MUX is off. */ if (chipset_in_state(CHIPSET_STATE_HARD_OFF)) - return (mux_state == USB_PD_MUX_NONE) - ? EC_SUCCESS - : EC_ERROR_NOT_POWERED; + return (mux_state == USB_PD_MUX_NONE) ? EC_SUCCESS : + EC_ERROR_NOT_POWERED; if ((mux_state & USB_PD_MUX_USB_ENABLED) && - (mux_state & USB_PD_MUX_DP_ENABLED)) - val = (mux_state & USB_PD_MUX_POLARITY_INVERTED) - ? AMD_FP5_MUX_DOCK_INVERTED : AMD_FP5_MUX_DOCK; + (mux_state & USB_PD_MUX_DP_ENABLED)) + val = (mux_state & USB_PD_MUX_POLARITY_INVERTED) ? + AMD_FP5_MUX_DOCK_INVERTED : + AMD_FP5_MUX_DOCK; else if (mux_state & USB_PD_MUX_USB_ENABLED) - val = (mux_state & USB_PD_MUX_POLARITY_INVERTED) - ? AMD_FP5_MUX_USB_INVERTED : AMD_FP5_MUX_USB; + val = (mux_state & USB_PD_MUX_POLARITY_INVERTED) ? + AMD_FP5_MUX_USB_INVERTED : + AMD_FP5_MUX_USB; else if (mux_state & USB_PD_MUX_DP_ENABLED) - val = (mux_state & USB_PD_MUX_POLARITY_INVERTED) - ? AMD_FP5_MUX_DP_INVERTED : AMD_FP5_MUX_DP; + val = (mux_state & USB_PD_MUX_POLARITY_INVERTED) ? + AMD_FP5_MUX_DP_INVERTED : + AMD_FP5_MUX_DP; return amd_fp5_mux_write(me, val); } @@ -101,21 +105,21 @@ static int amd_fp5_get_mux(const struct usb_mux *me, mux_state_t *mux_state) break; case AMD_FP5_MUX_USB_INVERTED: *mux_state = USB_PD_MUX_USB_ENABLED | - USB_PD_MUX_POLARITY_INVERTED; + USB_PD_MUX_POLARITY_INVERTED; break; case AMD_FP5_MUX_DOCK: *mux_state = USB_PD_MUX_USB_ENABLED | USB_PD_MUX_DP_ENABLED; break; case AMD_FP5_MUX_DOCK_INVERTED: - *mux_state = USB_PD_MUX_USB_ENABLED | USB_PD_MUX_DP_ENABLED - | USB_PD_MUX_POLARITY_INVERTED; + *mux_state = USB_PD_MUX_USB_ENABLED | USB_PD_MUX_DP_ENABLED | + USB_PD_MUX_POLARITY_INVERTED; break; case AMD_FP5_MUX_DP: *mux_state = USB_PD_MUX_DP_ENABLED; break; case AMD_FP5_MUX_DP_INVERTED: *mux_state = USB_PD_MUX_DP_ENABLED | - USB_PD_MUX_POLARITY_INVERTED; + USB_PD_MUX_POLARITY_INVERTED; break; case AMD_FP5_MUX_SAFE: default: @@ -126,8 +130,8 @@ static int amd_fp5_get_mux(const struct usb_mux *me, mux_state_t *mux_state) return EC_SUCCESS; } -static struct queue const chipset_reset_queue - = QUEUE_NULL(CONFIG_USB_PD_PORT_MAX_COUNT, struct usb_mux *); +static struct queue const chipset_reset_queue = + QUEUE_NULL(CONFIG_USB_PD_PORT_MAX_COUNT, struct usb_mux *); static void amd_fp5_chipset_reset_delay(void) { |