diff options
Diffstat (limited to 'driver/retimer/kb800x.c')
-rw-r--r-- | driver/retimer/kb800x.c | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/driver/retimer/kb800x.c b/driver/retimer/kb800x.c index 44bd166c14..35ab5b183d 100644 --- a/driver/retimer/kb800x.c +++ b/driver/retimer/kb800x.c @@ -1,4 +1,4 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. +/* Copyright 2021 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. * @@ -79,14 +79,15 @@ static const uint8_t usb_ss_lane_to_eb[] = { [KB800X_TX0] = KB800X_EB4, /* Assign a phy TX to an elastic buffer */ static int kb800x_assign_tx_to_eb(const struct usb_mux *me, - enum kb800x_phy_lane phy_lane, enum kb800x_eb eb) + enum kb800x_phy_lane phy_lane, + enum kb800x_eb eb) { uint8_t field_value = 0; uint8_t regval; int rv; field_value = KB800X_PHY_IS_AB(phy_lane) ? tx_eb_to_field_ab[eb] : - tx_eb_to_field_cd[eb]; + tx_eb_to_field_cd[eb]; /* For lane1 of each PHY, shift by 3 bits */ field_value <<= 3 * KB800X_LANE_NUMBER_FROM_PHY(phy_lane); @@ -95,20 +96,19 @@ static int kb800x_assign_tx_to_eb(const struct usb_mux *me, if (rv) return rv; return kb800x_write(me, KB800X_REG_TXSEL_FROM_PHY(phy_lane), - regval | field_value); + regval | field_value); } - /* Assign a phy RX to an elastic buffer */ static int kb800x_assign_rx_to_eb(const struct usb_mux *me, - enum kb800x_phy_lane phy_lane, enum kb800x_eb eb) + enum kb800x_phy_lane phy_lane, + enum kb800x_eb eb) { uint16_t address = 0; uint8_t field_value = 0; uint8_t regval = 0; int rv; - field_value = rx_phy_lane_to_field[phy_lane]; address = rx_eb_to_address[eb]; @@ -246,13 +246,11 @@ static int kb800x_xbar_override(const struct usb_mux *me) for (i = KB800X_A0; i < KB800X_PHY_LANE_COUNT; ++i) { rv = kb800x_assign_lane( - me, i, - kb800x_control[me->usb_port].ss_lanes[i]); + me, i, kb800x_control[me->usb_port].ss_lanes[i]); if (rv) return rv; } - return kb800x_write(me, KB800X_REG_XBAR_OVR, - KB800X_XBAR_OVR_EN); + return kb800x_write(me, KB800X_REG_XBAR_OVR, KB800X_XBAR_OVR_EN); } #endif /* CONFIG_KB800X_CUSTOM_XBAR */ @@ -314,8 +312,8 @@ static int kb800x_dp_init(const struct usb_mux *me, mux_state_t mux_state) me, KB800X_REG_ORIENTATION, KB800X_ORIENTATION_DP_DFP | ((mux_state & USB_PD_MUX_POLARITY_INVERTED) ? - KB800X_ORIENTATION_POLARITY : - 0x0)); + KB800X_ORIENTATION_POLARITY : + 0x0)); } static int kb800x_usb3_init(const struct usb_mux *me, mux_state_t mux_state) @@ -356,7 +354,7 @@ static int kb800x_cio_init(const struct usb_mux *me, mux_state_t mux_state) if (!(mux_state & USB_PD_MUX_USB4_ENABLED)) { /* Special configuration only for legacy mode */ if (cable_type == IDH_PTYPE_ACABLE || - cable_resp.tbt_active_passive == TBT_CABLE_ACTIVE) { + cable_resp.tbt_active_passive == TBT_CABLE_ACTIVE) { /* Active cable */ if (cable_resp.lsrx_comm == UNIDIR_LSRX_COMM) { orientation |= @@ -391,7 +389,7 @@ static int kb800x_set_state(const struct usb_mux *me, mux_state_t mux_state, return rv; /* Release memory map reset */ rv = kb800x_write(me, KB800X_REG_RESET, - KB800X_RESET_MASK & ~KB800X_RESET_MM); + KB800X_RESET_MASK & ~KB800X_RESET_MM); if (rv) return rv; @@ -476,11 +474,12 @@ static int kb800x_enter_low_power_mode(const struct usb_mux *me) #ifdef CONFIG_CMD_RETIMER -static int console_command_kb800x_xfer(int argc, char **argv) +static int console_command_kb800x_xfer(int argc, const char **argv) { char rw, *e; int rv, port, reg, val; uint8_t data; + const struct usb_mux_chain *mux_chain; const struct usb_mux *mux; if (argc < 4) @@ -491,16 +490,18 @@ static int console_command_kb800x_xfer(int argc, char **argv) if (*e || !board_is_usb_pd_port_present(port)) return EC_ERROR_PARAM1; - mux = &usb_muxes[port]; - while (mux) { - if (mux->driver == &kb800x_usb_mux_driver) + mux_chain = &usb_muxes[port]; + while (mux_chain) { + if (mux_chain->mux->driver == &kb800x_usb_mux_driver) break; - mux = mux->next_mux; + mux_chain = mux_chain->next; } - if (!mux) + if (!mux_chain) return EC_ERROR_PARAM1; + mux = mux_chain->mux; + /* Validate r/w selection */ rw = argv[2][0]; if (rw != 'w' && rw != 'r') |