Message ID | 20230601-topic-sm8x50-upstream-redriver-v2-0-dda89b22b1c0@linaro.org |
---|---|
Headers | show |
Series | typec: add support for the ON Semiconductor nb7vpq904m Type-C Linear Redriver | expand |
Hi, On Wed, Jun 07, 2023 at 09:51:09AM +0200, neil.armstrong@linaro.org wrote: > +static int nb7vpq904m_set(struct nb7vpq904m *nb7) > +{ > + bool reverse = (nb7->orientation == TYPEC_ORIENTATION_REVERSE); > + > + switch (nb7->mode) { > + case TYPEC_STATE_SAFE: > + regmap_write(nb7->regmap, GEN_DEV_SET_REG, > + GEN_DEV_SET_CHIP_EN | > + GEN_DEV_SET_CHNA_EN | > + GEN_DEV_SET_CHNB_EN | > + GEN_DEV_SET_CHNC_EN | > + GEN_DEV_SET_CHND_EN | > + FIELD_PREP(GEN_DEV_SET_OP_MODE_MASK, > + GEN_DEV_SET_OP_MODE_USB)); > + nb7vpq904m_set_channel(nb7, NB7_CHNA, false); > + nb7vpq904m_set_channel(nb7, NB7_CHNB, false); > + nb7vpq904m_set_channel(nb7, NB7_CHNC, false); > + nb7vpq904m_set_channel(nb7, NB7_CHND, false); > + regmap_write(nb7->regmap, AUX_CC_REG, 0x2); > + > + return 0; > + > + case TYPEC_STATE_USB: > + /* > + * Normal Orientation (CC1) > + * A -> USB RX > + * B -> USB TX > + * C -> X > + * D -> X > + * Flipped Orientation (CC2) > + * A -> X > + * B -> X > + * C -> USB TX > + * D -> USB RX > + * > + * Reversed if data lanes are swapped > + */ > + if (reverse ^ nb7->swap_data_lanes) { > + regmap_write(nb7->regmap, GEN_DEV_SET_REG, > + GEN_DEV_SET_CHIP_EN | > + GEN_DEV_SET_CHNA_EN | > + GEN_DEV_SET_CHNB_EN | > + FIELD_PREP(GEN_DEV_SET_OP_MODE_MASK, > + GEN_DEV_SET_OP_MODE_USB)); > + nb7vpq904m_set_channel(nb7, NB7_CHNA, false); > + nb7vpq904m_set_channel(nb7, NB7_CHNB, false); > + } else { > + regmap_write(nb7->regmap, GEN_DEV_SET_REG, > + GEN_DEV_SET_CHIP_EN | > + GEN_DEV_SET_CHNC_EN | > + GEN_DEV_SET_CHND_EN | > + FIELD_PREP(GEN_DEV_SET_OP_MODE_MASK, > + GEN_DEV_SET_OP_MODE_USB)); > + nb7vpq904m_set_channel(nb7, NB7_CHNC, false); > + nb7vpq904m_set_channel(nb7, NB7_CHND, false); > + } > + regmap_write(nb7->regmap, AUX_CC_REG, 0x2); > + > + return 0; > + > + default: > + if (nb7->svid != USB_TYPEC_DP_SID) > + return -EINVAL; > + > + break; > + } > + > + /* DP Altmode Setup */ > + > + regmap_write(nb7->regmap, AUX_CC_REG, reverse ? 0x1 : 0x0); > + > + switch (nb7->mode) { > + case TYPEC_DP_STATE_C: > + case TYPEC_DP_STATE_E: > + /* > + * Normal Orientation (CC1) > + * A -> DP3 > + * B -> DP2 > + * C -> DP1 > + * D -> DP0 > + * Flipped Orientation (CC2) > + * A -> DP0 > + * B -> DP1 > + * C -> DP2 > + * D -> DP3 > + */ > + regmap_write(nb7->regmap, GEN_DEV_SET_REG, > + GEN_DEV_SET_CHIP_EN | > + GEN_DEV_SET_CHNA_EN | > + GEN_DEV_SET_CHNB_EN | > + GEN_DEV_SET_CHNC_EN | > + GEN_DEV_SET_CHND_EN | > + FIELD_PREP(GEN_DEV_SET_OP_MODE_MASK, > + GEN_DEV_SET_OP_MODE_DP_4LANE)); > + nb7vpq904m_set_channel(nb7, NB7_CHNA, true); > + nb7vpq904m_set_channel(nb7, NB7_CHNB, true); > + nb7vpq904m_set_channel(nb7, NB7_CHNC, true); > + nb7vpq904m_set_channel(nb7, NB7_CHND, true); > + break; > + > + case TYPEC_DP_STATE_D: > + case TYPEC_DP_STATE_F: > + regmap_write(nb7->regmap, GEN_DEV_SET_REG, > + GEN_DEV_SET_CHIP_EN | > + GEN_DEV_SET_CHNA_EN | > + GEN_DEV_SET_CHNB_EN | > + GEN_DEV_SET_CHNC_EN | > + GEN_DEV_SET_CHND_EN | > + FIELD_PREP(GEN_DEV_SET_OP_MODE_MASK, > + reverse ^ nb7->swap_data_lanes ? > + GEN_DEV_SET_OP_MODE_DP_CC2 > + : GEN_DEV_SET_OP_MODE_DP_CC1)); > + > + /* > + * Normal Orientation (CC1) > + * A -> USB RX > + * B -> USB TX > + * C -> DP1 > + * D -> DP0 > + * Flipped Orientation (CC2) > + * A -> DP0 > + * B -> DP1 > + * C -> USB TX > + * D -> USB RX > + * > + * Reversed if data lanes are swapped > + */ > + if (nb7->swap_data_lanes) { > + nb7vpq904m_set_channel(nb7, NB7_CHNA, !reverse); > + nb7vpq904m_set_channel(nb7, NB7_CHNB, !reverse); > + nb7vpq904m_set_channel(nb7, NB7_CHNC, reverse); > + nb7vpq904m_set_channel(nb7, NB7_CHND, reverse); > + } else { > + nb7vpq904m_set_channel(nb7, NB7_CHNA, reverse); > + nb7vpq904m_set_channel(nb7, NB7_CHNB, reverse); > + nb7vpq904m_set_channel(nb7, NB7_CHNC, !reverse); > + nb7vpq904m_set_channel(nb7, NB7_CHND, !reverse); > + } > + break; > + > + default: > + return -ENOTSUPP; That should be -EOPNOTSUPP. > + } > + > + return 0; > +} > + > +static int nb7vpq904m_sw_set(struct typec_switch_dev *sw, > + enum typec_orientation orientation) While at it, one line should be enough for this one. thanks,
Add support for the ON Semiconductor NB7VPQ904M Type-C USB SuperSpeed and DisplayPort ALT Mode Linear Redriver chip found on some devices with a Type-C port. The redriver compensates ultra High-Speeed DisplayPort and USB Super Speed signal integrity losses mainly due to PCB & transmission cables. The redriver doesn't support SuperSpeed lines swapping, but can support Type-C SBU lines swapping. Support is designed as a Type-C Switch and Retimer, and can propagate orientation settings to the source endpoint, which is usually a Super Speed PHY which does the data lanes swapping. Bindings are added first and can handle the fact data lanes pairs can be swapped on the PCB. Compile-time dependencies: - svid removal at [1] [1] https://lore.kernel.org/all/20230526131434.46920-1-heikki.krogerus@linux.intel.com/ Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org> --- Changes in v2: - Switch to "retimer" infrastructure - Slight style fixups after switch to retimer - Bindings updates (did not keep Reviewed-by tag for those reasons) - Update maintainer, was using Bjorn with invalid email - Fixed swapped lanes mapping - Switched to retimer-switch - Fixed i2c top node in example - Link to v1: https://lore.kernel.org/r/20230601-topic-sm8x50-upstream-redriver-v1-0-6ad21094ff6f@linaro.org --- Dmitry Baryshkov (1): usb: typec: add support for the nb7vpq904m Type-C Linear Redriver Neil Armstrong (1): dt-bindings: usb: add ON Semiconductor nb7vpq904m Type-C Linear Redriver bindings .../devicetree/bindings/usb/onnn,nb7vpq904m.yaml | 141 ++++++ drivers/usb/typec/mux/Kconfig | 8 + drivers/usb/typec/mux/Makefile | 1 + drivers/usb/typec/mux/nb7vpq904m.c | 529 +++++++++++++++++++++ 4 files changed, 679 insertions(+) --- base-commit: ac9a78681b921877518763ba0e89202254349d1b change-id: 20230601-topic-sm8x50-upstream-redriver-6e261edd5cb4 Best regards,