Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: typec: ps883x: Add USB4 mode and TBT3 altmode support

This chip can do some more than the driver currently describes. Add
support for configuring it for various flavors of TBT3/USB4 operation.

Reviewed-by: Jack Pham <jack.pham@oss.qualcomm.com>
Signed-off-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://patch.msgid.link/20251014-topic-ps883x_usb4-v1-3-e6adb1a4296e@oss.qualcomm.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Konrad Dybcio and committed by
Greg Kroah-Hartman
832c8d3f 6bebd9b7

+30
+29
drivers/usb/typec/mux/ps883x.c
··· 14 14 #include <linux/mutex.h> 15 15 #include <linux/regmap.h> 16 16 #include <linux/regulator/consumer.h> 17 + #include <linux/usb/pd.h> 17 18 #include <linux/usb/typec_altmode.h> 18 19 #include <linux/usb/typec_dp.h> 19 20 #include <linux/usb/typec_mux.h> 20 21 #include <linux/usb/typec_retimer.h> 22 + #include <linux/usb/typec_tbt.h> 21 23 22 24 #define REG_USB_PORT_CONN_STATUS_0 0x00 23 25 24 26 #define CONN_STATUS_0_CONNECTION_PRESENT BIT(0) 25 27 #define CONN_STATUS_0_ORIENTATION_REVERSED BIT(1) 28 + #define CONN_STATUS_0_ACTIVE_CABLE BIT(2) 26 29 #define CONN_STATUS_0_USB_3_1_CONNECTED BIT(5) 27 30 28 31 #define REG_USB_PORT_CONN_STATUS_1 0x01 ··· 36 33 #define CONN_STATUS_1_DP_HPD_LEVEL BIT(7) 37 34 38 35 #define REG_USB_PORT_CONN_STATUS_2 0x02 36 + 37 + #define CONN_STATUS_2_TBT_CONNECTED BIT(0) 38 + #define CONN_STATUS_2_TBT_UNIDIR_LSRX_ACT_LT BIT(4) 39 + #define CONN_STATUS_2_USB4_CONNECTED BIT(7) 39 40 40 41 struct ps883x_retimer { 41 42 struct i2c_client *client; ··· 102 95 103 96 static int ps883x_set(struct ps883x_retimer *retimer, struct typec_retimer_state *state) 104 97 { 98 + struct typec_thunderbolt_data *tb_data; 99 + const struct enter_usb_data *eudo_data; 105 100 int cfg0 = CONN_STATUS_0_CONNECTION_PRESENT; 106 101 int cfg1 = 0x00; 107 102 int cfg2 = 0x00; ··· 129 120 break; 130 121 } 131 122 break; 123 + case USB_TYPEC_TBT_SID: 124 + tb_data = state->data; 125 + 126 + /* Unconditional */ 127 + cfg2 |= CONN_STATUS_2_TBT_CONNECTED; 128 + 129 + if (tb_data->cable_mode & TBT_CABLE_ACTIVE_PASSIVE) 130 + cfg0 |= CONN_STATUS_0_ACTIVE_CABLE; 131 + 132 + if (tb_data->enter_vdo & TBT_ENTER_MODE_UNI_DIR_LSRX) 133 + cfg2 |= CONN_STATUS_2_TBT_UNIDIR_LSRX_ACT_LT; 134 + break; 132 135 default: 133 136 dev_err(&retimer->client->dev, "Got unsupported SID: 0x%x\n", 134 137 state->alt->svid); ··· 155 134 case TYPEC_STATE_USB: 156 135 case TYPEC_MODE_USB3: 157 136 cfg0 |= CONN_STATUS_0_USB_3_1_CONNECTED; 137 + break; 138 + case TYPEC_MODE_USB4: 139 + eudo_data = state->data; 140 + 141 + cfg2 |= CONN_STATUS_2_USB4_CONNECTED; 142 + 143 + if (FIELD_GET(EUDO_CABLE_TYPE_MASK, eudo_data->eudo) != EUDO_CABLE_TYPE_PASSIVE) 144 + cfg0 |= CONN_STATUS_0_ACTIVE_CABLE; 158 145 break; 159 146 default: 160 147 dev_err(&retimer->client->dev, "Got unsupported mode: %lu\n",
+1
include/linux/usb/typec_tbt.h
··· 55 55 56 56 /* TBT3 Device Enter Mode VDO bits */ 57 57 #define TBT_ENTER_MODE_CABLE_SPEED(s) TBT_SET_CABLE_SPEED(s) 58 + #define TBT_ENTER_MODE_UNI_DIR_LSRX BIT(23) 58 59 #define TBT_ENTER_MODE_ACTIVE_CABLE BIT(24) 59 60 60 61 #endif /* __USB_TYPEC_TBT_H */