diff options
Diffstat (limited to 'include/linux/usb')
| -rw-r--r-- | include/linux/usb/audio-v3.h | 19 | ||||
| -rw-r--r-- | include/linux/usb/hcd.h | 1 | ||||
| -rw-r--r-- | include/linux/usb/pd.h | 1 | ||||
| -rw-r--r-- | include/linux/usb/tcpm.h | 11 | ||||
| -rw-r--r-- | include/linux/usb/typec.h | 55 | ||||
| -rw-r--r-- | include/linux/usb/typec_altmode.h | 160 | ||||
| -rw-r--r-- | include/linux/usb/typec_dp.h | 95 | ||||
| -rw-r--r-- | include/linux/usb/typec_mux.h | 2 |
8 files changed, 295 insertions, 49 deletions
diff --git a/include/linux/usb/audio-v3.h b/include/linux/usb/audio-v3.h index a710e28b5215..6b708434b7f9 100644 --- a/include/linux/usb/audio-v3.h +++ b/include/linux/usb/audio-v3.h | |||
| @@ -387,6 +387,12 @@ struct uac3_interrupt_data_msg { | |||
| 387 | #define UAC3_CONNECTORS 0x0f | 387 | #define UAC3_CONNECTORS 0x0f |
| 388 | #define UAC3_POWER_DOMAIN 0x10 | 388 | #define UAC3_POWER_DOMAIN 0x10 |
| 389 | 389 | ||
| 390 | /* A.20 PROCESSING UNIT PROCESS TYPES */ | ||
| 391 | #define UAC3_PROCESS_UNDEFINED 0x00 | ||
| 392 | #define UAC3_PROCESS_UP_DOWNMIX 0x01 | ||
| 393 | #define UAC3_PROCESS_STEREO_EXTENDER 0x02 | ||
| 394 | #define UAC3_PROCESS_MULTI_FUNCTION 0x03 | ||
| 395 | |||
| 390 | /* A.22 AUDIO CLASS-SPECIFIC REQUEST CODES */ | 396 | /* A.22 AUDIO CLASS-SPECIFIC REQUEST CODES */ |
| 391 | /* see audio-v2.h for the rest, which is identical to v2 */ | 397 | /* see audio-v2.h for the rest, which is identical to v2 */ |
| 392 | #define UAC3_CS_REQ_INTEN 0x04 | 398 | #define UAC3_CS_REQ_INTEN 0x04 |
| @@ -406,6 +412,15 @@ struct uac3_interrupt_data_msg { | |||
| 406 | #define UAC3_TE_OVERFLOW 0x04 | 412 | #define UAC3_TE_OVERFLOW 0x04 |
| 407 | #define UAC3_TE_LATENCY 0x05 | 413 | #define UAC3_TE_LATENCY 0x05 |
| 408 | 414 | ||
| 415 | /* A.23.10 PROCESSING UNITS CONTROL SELECTROS */ | ||
| 416 | |||
| 417 | /* Up/Down Mixer */ | ||
| 418 | #define UAC3_UD_MODE_SELECT 0x01 | ||
| 419 | |||
| 420 | /* Stereo Extender */ | ||
| 421 | #define UAC3_EXT_WIDTH_CONTROL 0x01 | ||
| 422 | |||
| 423 | |||
| 409 | /* BADD predefined Unit/Terminal values */ | 424 | /* BADD predefined Unit/Terminal values */ |
| 410 | #define UAC3_BADD_IT_ID1 1 /* Input Terminal ID1: bTerminalID = 1 */ | 425 | #define UAC3_BADD_IT_ID1 1 /* Input Terminal ID1: bTerminalID = 1 */ |
| 411 | #define UAC3_BADD_FU_ID2 2 /* Feature Unit ID2: bUnitID = 2 */ | 426 | #define UAC3_BADD_FU_ID2 2 /* Feature Unit ID2: bUnitID = 2 */ |
| @@ -432,4 +447,8 @@ struct uac3_interrupt_data_msg { | |||
| 432 | /* BADD sample rate is always fixed to 48kHz */ | 447 | /* BADD sample rate is always fixed to 48kHz */ |
| 433 | #define UAC3_BADD_SAMPLING_RATE 48000 | 448 | #define UAC3_BADD_SAMPLING_RATE 48000 |
| 434 | 449 | ||
| 450 | /* BADD power domains recovery times in 50us increments */ | ||
| 451 | #define UAC3_BADD_PD_RECOVER_D1D0 0x0258 /* 30ms */ | ||
| 452 | #define UAC3_BADD_PD_RECOVER_D2D0 0x1770 /* 300ms */ | ||
| 453 | |||
| 435 | #endif /* __LINUX_USB_AUDIO_V3_H */ | 454 | #endif /* __LINUX_USB_AUDIO_V3_H */ |
diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h index 34a6ded6f319..97e2ddec18b1 100644 --- a/include/linux/usb/hcd.h +++ b/include/linux/usb/hcd.h | |||
| @@ -322,6 +322,7 @@ struct hc_driver { | |||
| 322 | int (*bus_suspend)(struct usb_hcd *); | 322 | int (*bus_suspend)(struct usb_hcd *); |
| 323 | int (*bus_resume)(struct usb_hcd *); | 323 | int (*bus_resume)(struct usb_hcd *); |
| 324 | int (*start_port_reset)(struct usb_hcd *, unsigned port_num); | 324 | int (*start_port_reset)(struct usb_hcd *, unsigned port_num); |
| 325 | unsigned long (*get_resuming_ports)(struct usb_hcd *); | ||
| 325 | 326 | ||
| 326 | /* force handover of high-speed port to full-speed companion */ | 327 | /* force handover of high-speed port to full-speed companion */ |
| 327 | void (*relinquish_port)(struct usb_hcd *, int); | 328 | void (*relinquish_port)(struct usb_hcd *, int); |
diff --git a/include/linux/usb/pd.h b/include/linux/usb/pd.h index 09b570feb297..f2162e0fe531 100644 --- a/include/linux/usb/pd.h +++ b/include/linux/usb/pd.h | |||
| @@ -15,6 +15,7 @@ | |||
| 15 | #ifndef __LINUX_USB_PD_H | 15 | #ifndef __LINUX_USB_PD_H |
| 16 | #define __LINUX_USB_PD_H | 16 | #define __LINUX_USB_PD_H |
| 17 | 17 | ||
| 18 | #include <linux/kernel.h> | ||
| 18 | #include <linux/types.h> | 19 | #include <linux/types.h> |
| 19 | #include <linux/usb/typec.h> | 20 | #include <linux/usb/typec.h> |
| 20 | 21 | ||
diff --git a/include/linux/usb/tcpm.h b/include/linux/usb/tcpm.h index b231b9314240..7e7fbfb84e8e 100644 --- a/include/linux/usb/tcpm.h +++ b/include/linux/usb/tcpm.h | |||
| @@ -98,18 +98,10 @@ struct tcpc_config { | |||
| 98 | #define TCPC_MUX_DP_ENABLED BIT(1) /* DP enabled */ | 98 | #define TCPC_MUX_DP_ENABLED BIT(1) /* DP enabled */ |
| 99 | #define TCPC_MUX_POLARITY_INVERTED BIT(2) /* Polarity inverted */ | 99 | #define TCPC_MUX_POLARITY_INVERTED BIT(2) /* Polarity inverted */ |
| 100 | 100 | ||
| 101 | /* Mux modes, decoded to attributes */ | ||
| 102 | enum tcpc_mux_mode { | ||
| 103 | TYPEC_MUX_NONE = 0, /* Open switch */ | ||
| 104 | TYPEC_MUX_USB = TCPC_MUX_USB_ENABLED, /* USB only */ | ||
| 105 | TYPEC_MUX_DP = TCPC_MUX_DP_ENABLED, /* DP only */ | ||
| 106 | TYPEC_MUX_DOCK = TCPC_MUX_USB_ENABLED | /* Both USB and DP */ | ||
| 107 | TCPC_MUX_DP_ENABLED, | ||
| 108 | }; | ||
| 109 | |||
| 110 | /** | 101 | /** |
| 111 | * struct tcpc_dev - Port configuration and callback functions | 102 | * struct tcpc_dev - Port configuration and callback functions |
| 112 | * @config: Pointer to port configuration | 103 | * @config: Pointer to port configuration |
| 104 | * @fwnode: Pointer to port fwnode | ||
| 113 | * @get_vbus: Called to read current VBUS state | 105 | * @get_vbus: Called to read current VBUS state |
| 114 | * @get_current_limit: | 106 | * @get_current_limit: |
| 115 | * Optional; called by the tcpm core when configured as a snk | 107 | * Optional; called by the tcpm core when configured as a snk |
| @@ -138,6 +130,7 @@ enum tcpc_mux_mode { | |||
| 138 | */ | 130 | */ |
| 139 | struct tcpc_dev { | 131 | struct tcpc_dev { |
| 140 | const struct tcpc_config *config; | 132 | const struct tcpc_config *config; |
| 133 | struct fwnode_handle *fwnode; | ||
| 141 | 134 | ||
| 142 | int (*init)(struct tcpc_dev *dev); | 135 | int (*init)(struct tcpc_dev *dev); |
| 143 | int (*get_vbus)(struct tcpc_dev *dev); | 136 | int (*get_vbus)(struct tcpc_dev *dev); |
diff --git a/include/linux/usb/typec.h b/include/linux/usb/typec.h index 672b39bb0adc..7df4ecabc78a 100644 --- a/include/linux/usb/typec.h +++ b/include/linux/usb/typec.h | |||
| @@ -5,21 +5,18 @@ | |||
| 5 | 5 | ||
| 6 | #include <linux/types.h> | 6 | #include <linux/types.h> |
| 7 | 7 | ||
| 8 | /* XXX: Once we have a header for USB Power Delivery, this belongs there */ | ||
| 9 | #define ALTMODE_MAX_MODES 6 | ||
| 10 | |||
| 11 | /* USB Type-C Specification releases */ | 8 | /* USB Type-C Specification releases */ |
| 12 | #define USB_TYPEC_REV_1_0 0x100 /* 1.0 */ | 9 | #define USB_TYPEC_REV_1_0 0x100 /* 1.0 */ |
| 13 | #define USB_TYPEC_REV_1_1 0x110 /* 1.1 */ | 10 | #define USB_TYPEC_REV_1_1 0x110 /* 1.1 */ |
| 14 | #define USB_TYPEC_REV_1_2 0x120 /* 1.2 */ | 11 | #define USB_TYPEC_REV_1_2 0x120 /* 1.2 */ |
| 15 | 12 | ||
| 16 | struct typec_altmode; | ||
| 17 | struct typec_partner; | 13 | struct typec_partner; |
| 18 | struct typec_cable; | 14 | struct typec_cable; |
| 19 | struct typec_plug; | 15 | struct typec_plug; |
| 20 | struct typec_port; | 16 | struct typec_port; |
| 21 | 17 | ||
| 22 | struct fwnode_handle; | 18 | struct fwnode_handle; |
| 19 | struct device; | ||
| 23 | 20 | ||
| 24 | enum typec_port_type { | 21 | enum typec_port_type { |
| 25 | TYPEC_PORT_SRC, | 22 | TYPEC_PORT_SRC, |
| @@ -93,39 +90,21 @@ int typec_partner_set_identity(struct typec_partner *partner); | |||
| 93 | int typec_cable_set_identity(struct typec_cable *cable); | 90 | int typec_cable_set_identity(struct typec_cable *cable); |
| 94 | 91 | ||
| 95 | /* | 92 | /* |
| 96 | * struct typec_mode_desc - Individual Mode of an Alternate Mode | ||
| 97 | * @index: Index of the Mode within the SVID | ||
| 98 | * @vdo: VDO returned by Discover Modes USB PD command | ||
| 99 | * @desc: Optional human readable description of the mode | ||
| 100 | * @roles: Only for ports. DRP if the mode is available in both roles | ||
| 101 | * | ||
| 102 | * Description of a mode of an Alternate Mode which a connector, cable plug or | ||
| 103 | * partner supports. Every mode will have it's own sysfs group. The details are | ||
| 104 | * the VDO returned by discover modes command, description for the mode and | ||
| 105 | * active flag telling has the mode being entered or not. | ||
| 106 | */ | ||
| 107 | struct typec_mode_desc { | ||
| 108 | int index; | ||
| 109 | u32 vdo; | ||
| 110 | char *desc; | ||
| 111 | /* Only used with ports */ | ||
| 112 | enum typec_port_type roles; | ||
| 113 | }; | ||
| 114 | |||
| 115 | /* | ||
| 116 | * struct typec_altmode_desc - USB Type-C Alternate Mode Descriptor | 93 | * struct typec_altmode_desc - USB Type-C Alternate Mode Descriptor |
| 117 | * @svid: Standard or Vendor ID | 94 | * @svid: Standard or Vendor ID |
| 118 | * @n_modes: Number of modes | 95 | * @mode: Index of the Mode |
| 119 | * @modes: Array of modes supported by the Alternate Mode | 96 | * @vdo: VDO returned by Discover Modes USB PD command |
| 97 | * @roles: Only for ports. DRP if the mode is available in both roles | ||
| 120 | * | 98 | * |
| 121 | * Representation of an Alternate Mode that has SVID assigned by USB-IF. The | 99 | * Description of an Alternate Mode which a connector, cable plug or partner |
| 122 | * array of modes will list the modes of a particular SVID that are supported by | 100 | * supports. |
| 123 | * a connector, partner of a cable plug. | ||
| 124 | */ | 101 | */ |
| 125 | struct typec_altmode_desc { | 102 | struct typec_altmode_desc { |
| 126 | u16 svid; | 103 | u16 svid; |
| 127 | int n_modes; | 104 | u8 mode; |
| 128 | struct typec_mode_desc modes[ALTMODE_MAX_MODES]; | 105 | u32 vdo; |
| 106 | /* Only used with ports */ | ||
| 107 | enum typec_port_data roles; | ||
| 129 | }; | 108 | }; |
| 130 | 109 | ||
| 131 | struct typec_altmode | 110 | struct typec_altmode |
| @@ -141,8 +120,7 @@ void typec_unregister_altmode(struct typec_altmode *altmode); | |||
| 141 | 120 | ||
| 142 | struct typec_port *typec_altmode2port(struct typec_altmode *alt); | 121 | struct typec_port *typec_altmode2port(struct typec_altmode *alt); |
| 143 | 122 | ||
| 144 | void typec_altmode_update_active(struct typec_altmode *alt, int mode, | 123 | void typec_altmode_update_active(struct typec_altmode *alt, bool active); |
| 145 | bool active); | ||
| 146 | 124 | ||
| 147 | enum typec_plug_index { | 125 | enum typec_plug_index { |
| 148 | TYPEC_PLUG_SOP_P, | 126 | TYPEC_PLUG_SOP_P, |
| @@ -205,7 +183,6 @@ struct typec_partner_desc { | |||
| 205 | * @dr_set: Set Data Role | 183 | * @dr_set: Set Data Role |
| 206 | * @pr_set: Set Power Role | 184 | * @pr_set: Set Power Role |
| 207 | * @vconn_set: Set VCONN Role | 185 | * @vconn_set: Set VCONN Role |
| 208 | * @activate_mode: Enter/exit given Alternate Mode | ||
| 209 | * @port_type_set: Set port type | 186 | * @port_type_set: Set port type |
| 210 | * | 187 | * |
| 211 | * Static capabilities of a single USB Type-C port. | 188 | * Static capabilities of a single USB Type-C port. |
| @@ -231,12 +208,8 @@ struct typec_capability { | |||
| 231 | enum typec_role); | 208 | enum typec_role); |
| 232 | int (*vconn_set)(const struct typec_capability *, | 209 | int (*vconn_set)(const struct typec_capability *, |
| 233 | enum typec_role); | 210 | enum typec_role); |
| 234 | |||
| 235 | int (*activate_mode)(const struct typec_capability *, | ||
| 236 | int mode, int activate); | ||
| 237 | int (*port_type_set)(const struct typec_capability *, | 211 | int (*port_type_set)(const struct typec_capability *, |
| 238 | enum typec_port_type); | 212 | enum typec_port_type); |
| 239 | |||
| 240 | }; | 213 | }; |
| 241 | 214 | ||
| 242 | /* Specific to try_role(). Indicates the user want's to clear the preference. */ | 215 | /* Specific to try_role(). Indicates the user want's to clear the preference. */ |
| @@ -265,6 +238,10 @@ void typec_set_pwr_opmode(struct typec_port *port, enum typec_pwr_opmode mode); | |||
| 265 | 238 | ||
| 266 | int typec_set_orientation(struct typec_port *port, | 239 | int typec_set_orientation(struct typec_port *port, |
| 267 | enum typec_orientation orientation); | 240 | enum typec_orientation orientation); |
| 241 | enum typec_orientation typec_get_orientation(struct typec_port *port); | ||
| 268 | int typec_set_mode(struct typec_port *port, int mode); | 242 | int typec_set_mode(struct typec_port *port, int mode); |
| 269 | 243 | ||
| 244 | int typec_find_port_power_role(const char *name); | ||
| 245 | int typec_find_power_role(const char *name); | ||
| 246 | int typec_find_port_data_role(const char *name); | ||
| 270 | #endif /* __LINUX_USB_TYPEC_H */ | 247 | #endif /* __LINUX_USB_TYPEC_H */ |
diff --git a/include/linux/usb/typec_altmode.h b/include/linux/usb/typec_altmode.h new file mode 100644 index 000000000000..9a88c74a1d0d --- /dev/null +++ b/include/linux/usb/typec_altmode.h | |||
| @@ -0,0 +1,160 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
| 2 | |||
| 3 | #ifndef __USB_TYPEC_ALTMODE_H | ||
| 4 | #define __USB_TYPEC_ALTMODE_H | ||
| 5 | |||
| 6 | #include <linux/mod_devicetable.h> | ||
| 7 | #include <linux/usb/typec.h> | ||
| 8 | #include <linux/device.h> | ||
| 9 | |||
| 10 | #define MODE_DISCOVERY_MAX 6 | ||
| 11 | |||
| 12 | struct typec_altmode_ops; | ||
| 13 | |||
| 14 | /** | ||
| 15 | * struct typec_altmode - USB Type-C alternate mode device | ||
| 16 | * @dev: Driver model's view of this device | ||
| 17 | * @svid: Standard or Vendor ID (SVID) of the alternate mode | ||
| 18 | * @mode: Index of the Mode | ||
| 19 | * @vdo: VDO returned by Discover Modes USB PD command | ||
| 20 | * @active: Tells has the mode been entered or not | ||
| 21 | * @desc: Optional human readable description of the mode | ||
| 22 | * @ops: Operations vector from the driver | ||
| 23 | */ | ||
| 24 | struct typec_altmode { | ||
| 25 | struct device dev; | ||
| 26 | u16 svid; | ||
| 27 | int mode; | ||
| 28 | u32 vdo; | ||
| 29 | unsigned int active:1; | ||
| 30 | |||
| 31 | char *desc; | ||
| 32 | const struct typec_altmode_ops *ops; | ||
| 33 | }; | ||
| 34 | |||
| 35 | #define to_typec_altmode(d) container_of(d, struct typec_altmode, dev) | ||
| 36 | |||
| 37 | static inline void typec_altmode_set_drvdata(struct typec_altmode *altmode, | ||
| 38 | void *data) | ||
| 39 | { | ||
| 40 | dev_set_drvdata(&altmode->dev, data); | ||
| 41 | } | ||
| 42 | |||
| 43 | static inline void *typec_altmode_get_drvdata(struct typec_altmode *altmode) | ||
| 44 | { | ||
| 45 | return dev_get_drvdata(&altmode->dev); | ||
| 46 | } | ||
| 47 | |||
| 48 | /** | ||
| 49 | * struct typec_altmode_ops - Alternate mode specific operations vector | ||
| 50 | * @enter: Operations to be executed with Enter Mode Command | ||
| 51 | * @exit: Operations to be executed with Exit Mode Command | ||
| 52 | * @attention: Callback for Attention Command | ||
| 53 | * @vdm: Callback for SVID specific commands | ||
| 54 | * @notify: Communication channel for platform and the alternate mode | ||
| 55 | * @activate: User callback for Enter/Exit Mode | ||
| 56 | */ | ||
| 57 | struct typec_altmode_ops { | ||
| 58 | int (*enter)(struct typec_altmode *altmode); | ||
| 59 | int (*exit)(struct typec_altmode *altmode); | ||
| 60 | void (*attention)(struct typec_altmode *altmode, u32 vdo); | ||
| 61 | int (*vdm)(struct typec_altmode *altmode, const u32 hdr, | ||
| 62 | const u32 *vdo, int cnt); | ||
| 63 | int (*notify)(struct typec_altmode *altmode, unsigned long conf, | ||
| 64 | void *data); | ||
| 65 | int (*activate)(struct typec_altmode *altmode, int activate); | ||
| 66 | }; | ||
| 67 | |||
| 68 | int typec_altmode_enter(struct typec_altmode *altmode); | ||
| 69 | int typec_altmode_exit(struct typec_altmode *altmode); | ||
| 70 | void typec_altmode_attention(struct typec_altmode *altmode, u32 vdo); | ||
| 71 | int typec_altmode_vdm(struct typec_altmode *altmode, | ||
| 72 | const u32 header, const u32 *vdo, int count); | ||
| 73 | int typec_altmode_notify(struct typec_altmode *altmode, unsigned long conf, | ||
| 74 | void *data); | ||
| 75 | const struct typec_altmode * | ||
| 76 | typec_altmode_get_partner(struct typec_altmode *altmode); | ||
| 77 | |||
| 78 | /* | ||
| 79 | * These are the connector states (USB, Safe and Alt Mode) defined in USB Type-C | ||
| 80 | * Specification. SVID specific connector states are expected to follow and | ||
| 81 | * start from the value TYPEC_STATE_MODAL. | ||
| 82 | */ | ||
| 83 | enum { | ||
| 84 | TYPEC_STATE_SAFE, /* USB Safe State */ | ||
| 85 | TYPEC_STATE_USB, /* USB Operation */ | ||
| 86 | TYPEC_STATE_MODAL, /* Alternate Modes */ | ||
| 87 | }; | ||
| 88 | |||
| 89 | /* | ||
| 90 | * For the muxes there is no difference between Accessory Modes and Alternate | ||
| 91 | * Modes, so the Accessory Modes are supplied with specific modal state values | ||
| 92 | * here. Unlike with Alternate Modes, where the mux will be linked with the | ||
| 93 | * alternate mode device, the mux for Accessory Modes will be linked with the | ||
| 94 | * port device instead. | ||
| 95 | * | ||
| 96 | * Port drivers can use TYPEC_MODE_AUDIO and TYPEC_MODE_DEBUG as the mode | ||
| 97 | * value for typec_set_mode() when accessory modes are supported. | ||
| 98 | */ | ||
| 99 | enum { | ||
| 100 | TYPEC_MODE_AUDIO = TYPEC_STATE_MODAL, /* Audio Accessory */ | ||
| 101 | TYPEC_MODE_DEBUG, /* Debug Accessory */ | ||
| 102 | }; | ||
| 103 | |||
| 104 | #define TYPEC_MODAL_STATE(_state_) ((_state_) + TYPEC_STATE_MODAL) | ||
| 105 | |||
| 106 | struct typec_altmode *typec_altmode_get_plug(struct typec_altmode *altmode, | ||
| 107 | enum typec_plug_index index); | ||
| 108 | void typec_altmode_put_plug(struct typec_altmode *plug); | ||
| 109 | |||
| 110 | struct typec_altmode *typec_match_altmode(struct typec_altmode **altmodes, | ||
| 111 | size_t n, u16 svid, u8 mode); | ||
| 112 | |||
| 113 | struct typec_altmode * | ||
| 114 | typec_altmode_register_notifier(struct device *dev, u16 svid, u8 mode, | ||
| 115 | struct notifier_block *nb); | ||
| 116 | |||
| 117 | void typec_altmode_unregister_notifier(struct typec_altmode *adev, | ||
| 118 | struct notifier_block *nb); | ||
| 119 | |||
| 120 | /** | ||
| 121 | * typec_altmode_get_orientation - Get cable plug orientation | ||
| 122 | * altmode: Handle to the alternate mode | ||
| 123 | */ | ||
| 124 | static inline enum typec_orientation | ||
| 125 | typec_altmode_get_orientation(struct typec_altmode *altmode) | ||
| 126 | { | ||
| 127 | return typec_get_orientation(typec_altmode2port(altmode)); | ||
| 128 | } | ||
| 129 | |||
| 130 | /** | ||
| 131 | * struct typec_altmode_driver - USB Type-C alternate mode device driver | ||
| 132 | * @id_table: Null terminated array of SVIDs | ||
| 133 | * @probe: Callback for device binding | ||
| 134 | * @remove: Callback for device unbinding | ||
| 135 | * @driver: Device driver model driver | ||
| 136 | * | ||
| 137 | * These drivers will be bind to the partner alternate mode devices. They will | ||
| 138 | * handle all SVID specific communication. | ||
| 139 | */ | ||
| 140 | struct typec_altmode_driver { | ||
| 141 | const struct typec_device_id *id_table; | ||
| 142 | int (*probe)(struct typec_altmode *altmode); | ||
| 143 | void (*remove)(struct typec_altmode *altmode); | ||
| 144 | struct device_driver driver; | ||
| 145 | }; | ||
| 146 | |||
| 147 | #define to_altmode_driver(d) container_of(d, struct typec_altmode_driver, \ | ||
| 148 | driver) | ||
| 149 | |||
| 150 | #define typec_altmode_register_driver(drv) \ | ||
| 151 | __typec_altmode_register_driver(drv, THIS_MODULE) | ||
| 152 | int __typec_altmode_register_driver(struct typec_altmode_driver *drv, | ||
| 153 | struct module *module); | ||
| 154 | void typec_altmode_unregister_driver(struct typec_altmode_driver *drv); | ||
| 155 | |||
| 156 | #define module_typec_altmode_driver(__typec_altmode_driver) \ | ||
| 157 | module_driver(__typec_altmode_driver, typec_altmode_register_driver, \ | ||
| 158 | typec_altmode_unregister_driver) | ||
| 159 | |||
| 160 | #endif /* __USB_TYPEC_ALTMODE_H */ | ||
diff --git a/include/linux/usb/typec_dp.h b/include/linux/usb/typec_dp.h new file mode 100644 index 000000000000..55ae781d60a9 --- /dev/null +++ b/include/linux/usb/typec_dp.h | |||
| @@ -0,0 +1,95 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
| 2 | #ifndef __USB_TYPEC_DP_H | ||
| 3 | #define __USB_TYPEC_DP_H | ||
| 4 | |||
| 5 | #include <linux/usb/typec_altmode.h> | ||
| 6 | |||
| 7 | #define USB_TYPEC_DP_SID 0xff01 | ||
| 8 | #define USB_TYPEC_DP_MODE 1 | ||
| 9 | |||
| 10 | /* | ||
| 11 | * Connector states matching the pin assignments in DisplayPort Alt Mode | ||
| 12 | * Specification. | ||
| 13 | * | ||
| 14 | * These values are meant primarily to be used by the mux drivers, but they are | ||
| 15 | * also used as the "value" part in the alternate mode notification chain, so | ||
| 16 | * receivers of those notifications will always see them. | ||
| 17 | * | ||
| 18 | * Note. DisplayPort USB Type-C Alt Mode Specification version 1.0b deprecated | ||
| 19 | * pin assignments A, B and F, but they are still defined here for legacy | ||
| 20 | * purposes. | ||
| 21 | */ | ||
| 22 | enum { | ||
| 23 | TYPEC_DP_STATE_A = TYPEC_STATE_MODAL, /* Not supported after v1.0b */ | ||
| 24 | TYPEC_DP_STATE_B, /* Not supported after v1.0b */ | ||
| 25 | TYPEC_DP_STATE_C, | ||
| 26 | TYPEC_DP_STATE_D, | ||
| 27 | TYPEC_DP_STATE_E, | ||
| 28 | TYPEC_DP_STATE_F, /* Not supported after v1.0b */ | ||
| 29 | }; | ||
| 30 | |||
| 31 | /* | ||
| 32 | * struct typec_displayport_data - DisplayPort Alt Mode specific data | ||
| 33 | * @status: Status Update command VDO content | ||
| 34 | * @conf: Configure command VDO content | ||
| 35 | * | ||
| 36 | * This structure is delivered as the data part with the notifications. It | ||
| 37 | * contains the VDOs from the two DisplayPort Type-C alternate mode specific | ||
| 38 | * commands: Status Update and Configure. | ||
| 39 | * | ||
| 40 | * @status will show for example the status of the HPD signal. | ||
| 41 | */ | ||
| 42 | struct typec_displayport_data { | ||
| 43 | u32 status; | ||
| 44 | u32 conf; | ||
| 45 | }; | ||
| 46 | |||
| 47 | enum { | ||
| 48 | DP_PIN_ASSIGN_A, /* Not supported after v1.0b */ | ||
| 49 | DP_PIN_ASSIGN_B, /* Not supported after v1.0b */ | ||
| 50 | DP_PIN_ASSIGN_C, | ||
| 51 | DP_PIN_ASSIGN_D, | ||
| 52 | DP_PIN_ASSIGN_E, | ||
| 53 | DP_PIN_ASSIGN_F, /* Not supported after v1.0b */ | ||
| 54 | }; | ||
| 55 | |||
| 56 | /* DisplayPort alt mode specific commands */ | ||
| 57 | #define DP_CMD_STATUS_UPDATE VDO_CMD_VENDOR(0) | ||
| 58 | #define DP_CMD_CONFIGURE VDO_CMD_VENDOR(1) | ||
| 59 | |||
| 60 | /* DisplayPort Capabilities VDO bits (returned with Discover Modes) */ | ||
| 61 | #define DP_CAP_CAPABILITY(_cap_) ((_cap_) & 3) | ||
| 62 | #define DP_CAP_UFP_D 1 | ||
| 63 | #define DP_CAP_DFP_D 2 | ||
| 64 | #define DP_CAP_DFP_D_AND_UFP_D 3 | ||
| 65 | #define DP_CAP_DP_SIGNALING BIT(2) /* Always set */ | ||
| 66 | #define DP_CAP_GEN2 BIT(3) /* Reserved after v1.0b */ | ||
| 67 | #define DP_CAP_RECEPTACLE BIT(6) | ||
| 68 | #define DP_CAP_USB BIT(7) | ||
| 69 | #define DP_CAP_DFP_D_PIN_ASSIGN(_cap_) (((_cap_) & GENMASK(15, 8)) >> 8) | ||
| 70 | #define DP_CAP_UFP_D_PIN_ASSIGN(_cap_) (((_cap_) & GENMASK(23, 16)) >> 16) | ||
| 71 | |||
| 72 | /* DisplayPort Status Update VDO bits */ | ||
| 73 | #define DP_STATUS_CONNECTION(_status_) ((_status_) & 3) | ||
| 74 | #define DP_STATUS_CON_DISABLED 0 | ||
| 75 | #define DP_STATUS_CON_DFP_D 1 | ||
| 76 | #define DP_STATUS_CON_UFP_D 2 | ||
| 77 | #define DP_STATUS_CON_BOTH 3 | ||
| 78 | #define DP_STATUS_POWER_LOW BIT(2) | ||
| 79 | #define DP_STATUS_ENABLED BIT(3) | ||
| 80 | #define DP_STATUS_PREFER_MULTI_FUNC BIT(4) | ||
| 81 | #define DP_STATUS_SWITCH_TO_USB BIT(5) | ||
| 82 | #define DP_STATUS_EXIT_DP_MODE BIT(6) | ||
| 83 | #define DP_STATUS_HPD_STATE BIT(7) /* 0 = HPD_Low, 1 = HPD_High */ | ||
| 84 | #define DP_STATUS_IRQ_HPD BIT(8) | ||
| 85 | |||
| 86 | /* DisplayPort Configurations VDO bits */ | ||
| 87 | #define DP_CONF_CURRENTLY(_conf_) ((_conf_) & 3) | ||
| 88 | #define DP_CONF_UFP_U_AS_DFP_D BIT(0) | ||
| 89 | #define DP_CONF_UFP_U_AS_UFP_D BIT(1) | ||
| 90 | #define DP_CONF_SIGNALING_DP BIT(2) | ||
| 91 | #define DP_CONF_SIGNALING_GEN_2 BIT(3) /* Reserved after v1.0b */ | ||
| 92 | #define DP_CONF_PIN_ASSIGNEMENT_SHIFT 8 | ||
| 93 | #define DP_CONF_PIN_ASSIGNEMENT_MASK GENMASK(15, 8) | ||
| 94 | |||
| 95 | #endif /* __USB_TYPEC_DP_H */ | ||
diff --git a/include/linux/usb/typec_mux.h b/include/linux/usb/typec_mux.h index 12c1b057834b..79293f630ee1 100644 --- a/include/linux/usb/typec_mux.h +++ b/include/linux/usb/typec_mux.h | |||
| @@ -47,7 +47,7 @@ void typec_switch_put(struct typec_switch *sw); | |||
| 47 | int typec_switch_register(struct typec_switch *sw); | 47 | int typec_switch_register(struct typec_switch *sw); |
| 48 | void typec_switch_unregister(struct typec_switch *sw); | 48 | void typec_switch_unregister(struct typec_switch *sw); |
| 49 | 49 | ||
| 50 | struct typec_mux *typec_mux_get(struct device *dev); | 50 | struct typec_mux *typec_mux_get(struct device *dev, const char *name); |
| 51 | void typec_mux_put(struct typec_mux *mux); | 51 | void typec_mux_put(struct typec_mux *mux); |
| 52 | int typec_mux_register(struct typec_mux *mux); | 52 | int typec_mux_register(struct typec_mux *mux); |
| 53 | void typec_mux_unregister(struct typec_mux *mux); | 53 | void typec_mux_unregister(struct typec_mux *mux); |
