usb: typec: Generalize mux mode names
RFC 1/7 usb: typec: Generalize mux mode names
Hi Mats,
Quoted 6 lines · Mats Karrman
The current naming used for
tcpc_mux_modeconstants makes too much assumptioms about the usage of the signals. This patch replaces the names with generic names more closely tied to the Type-C specifications and also adds some new ones. At the same time TCPC_MUX_* defines are removed as they do not fit the new concept and currently have no in-tree users.
I'm afraid trying to generalize the modal connector states even like this is not going to work. We can't make any assumptions about how the alternate modes configure the pins, or the connector in general.
The only way this will work is that every alternate mode has its own configurations defined separately, and I'm talking about the actual pin configurations that the specifications for each alternate mode defines, so something like TYPEC_MUX_DP and TYPEC_MUX_DOCK will not work for sure.
The connector states that are defined in USB Type-C specification (so basically USB Operation and USB Safe State) can be generalized, but those states just should not be defined in tcpm.h. We need to use them in other drivers as well.
I'm in the middle of preparing more complete support for alternate modes. If you check the RFC [1] I send previously, in the first patch of the series I'm adding documentation that should explain the plan.
Quoted 72 lines
Signed-off-by Mats Karrman <[email protected]>--- drivers/usb/typec/mux/pi3usb30532.c | 7 ++++--- drivers/usb/typec/tcpm.c | 2 +- include/linux/usb/tcpm.h | 21 ++++++++++----------- 3 files changed, 15 insertions(+), 15 deletions(-)drivers/usb/typec/mux/pi3usb30532.c +4
-3@@ -83,18 +83,19 @@ static int pi3usb30532_mux_set(struct typec_mux *mux, int state) new_conf = pi->conf;switch (state) { +default :case TYPEC_MUX_NONE : new_conf =PI3USB30532_CONF_OPEN ;break ; -case TYPEC_MUX_USB : +case TYPEC_MUX_2CH_USBSS : new_conf = (new_conf &PI3USB30532_CONF_SWAP ) |PI3USB30532_CONF_USB3 ;break ; -case TYPEC_MUX_DP : +case TYPEC_MUX_4CH_AM : new_conf = (new_conf &PI3USB30532_CONF_SWAP ) |PI3USB30532_CONF_4LANE_DP ;break ; -case TYPEC_MUX_DOCK : +case TYPEC_MUX_2CH_USBSS_2CH_AM : new_conf = (new_conf &PI3USB30532_CONF_SWAP ) |PI3USB30532_CONF_USB3_AND_2LANE_DP ;break ;drivers/usb/typec/tcpm.c +1
-1@@ -790,7 +790,7 @@ static int tcpm_set_roles(struct tcpm_port *port, bool attached,else usb_role =USB_ROLE_DEVICE ; - ret =tcpm_mux_set (port,TYPEC_MUX_USB , usb_role, orientation); + ret =tcpm_mux_set (port,TYPEC_MUX_2CH_USBSS , usb_role, orientation);if (ret <0 )return ret;include/linux/usb/tcpm.h +5
-11@@ -93,20 +93,19 @@ struct tcpc_config {const struct typec_altmode_desc *alt_modes; }; -/* Mux state attributes */ -#define TCPC_MUX_USB_ENABLED BIT(0)/* USB enabled */ -#define TCPC_MUX_DP_ENABLED BIT(1)/* DP enabled */ -#define TCPC_MUX_POLARITY_INVERTED BIT(2)/* Polarity inverted */ - -/* Mux modes, decoded to attributes */ +/* Mux modes */ enum tcpc_mux_mode { -TYPEC_MUX_NONE =0 ,/* Open switch */ -TYPEC_MUX_USB =TCPC_MUX_USB_ENABLED ,/* USB only */ -TYPEC_MUX_DP =TCPC_MUX_DP_ENABLED ,/* DP only */ -TYPEC_MUX_DOCK =TCPC_MUX_USB_ENABLED |/* Both USB and DP */ -TCPC_MUX_DP_ENABLED , +TYPEC_MUX_NONE ,/* Open switch */ +TYPEC_MUX_2CH_USBSS ,/* 2ch USB SS */ +TYPEC_MUX_4CH_AM ,/* 4ch Alt Mode */ +TYPEC_MUX_2CH_USBSS_2CH_AM ,/* 2ch USB SS + 2ch Alt Mode */
include/linux/usb/tcpm.h struct tcpc_config { · line 111
Quoted 10 lines
include/linux/usb/tcpm.h +5
-0+ +// Example of additional modes that may be needed in future: +TYPEC_MUX_4CH_USBSS ,/* 4ch USB SS */ + TYPEC_MUX_2CH_USBSS_2CH_AM_B, /* 2ch USB SS + 2ch Alt Mode (e.g. DP GPU2) */ }; +/** * struct tcpc_dev - Port configuration and callback functions * @config: Pointer to port configuration
Thanks,