Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef __USB_TYPEC_DP_H
0003 #define __USB_TYPEC_DP_H
0004 
0005 #include <linux/usb/typec_altmode.h>
0006 
0007 #define USB_TYPEC_DP_SID    0xff01
0008 /* USB IF has not assigned a Standard ID (SID) for VirtualLink,
0009  * so the manufacturers of VirtualLink adapters use their Vendor
0010  * IDs as the SVID.
0011  */
0012 #define USB_TYPEC_NVIDIA_VLINK_SID  0x955   /* NVIDIA VirtualLink */
0013 #define USB_TYPEC_DP_MODE   1
0014 
0015 /*
0016  * Connector states matching the pin assignments in DisplayPort Alt Mode
0017  * Specification.
0018  *
0019  * These values are meant primarily to be used by the mux drivers, but they are
0020  * also used as the "value" part in the alternate mode notification chain, so
0021  * receivers of those notifications will always see them.
0022  *
0023  * Note. DisplayPort USB Type-C Alt Mode Specification version 1.0b deprecated
0024  * pin assignments A, B and F, but they are still defined here for legacy
0025  * purposes.
0026  */
0027 enum {
0028     TYPEC_DP_STATE_A = TYPEC_STATE_MODAL,   /* Not supported after v1.0b */
0029     TYPEC_DP_STATE_B,           /* Not supported after v1.0b */
0030     TYPEC_DP_STATE_C,
0031     TYPEC_DP_STATE_D,
0032     TYPEC_DP_STATE_E,
0033     TYPEC_DP_STATE_F,           /* Not supported after v1.0b */
0034 };
0035 
0036 /*
0037  * struct typec_displayport_data - DisplayPort Alt Mode specific data
0038  * @status: Status Update command VDO content
0039  * @conf: Configure command VDO content
0040  *
0041  * This structure is delivered as the data part with the notifications. It
0042  * contains the VDOs from the two DisplayPort Type-C alternate mode specific
0043  * commands: Status Update and Configure.
0044  *
0045  * @status will show for example the status of the HPD signal.
0046  */
0047 struct typec_displayport_data {
0048     u32 status;
0049     u32 conf;
0050 };
0051 
0052 enum {
0053     DP_PIN_ASSIGN_A, /* Not supported after v1.0b */
0054     DP_PIN_ASSIGN_B, /* Not supported after v1.0b */
0055     DP_PIN_ASSIGN_C,
0056     DP_PIN_ASSIGN_D,
0057     DP_PIN_ASSIGN_E,
0058     DP_PIN_ASSIGN_F, /* Not supported after v1.0b */
0059 };
0060 
0061 /* DisplayPort alt mode specific commands */
0062 #define DP_CMD_STATUS_UPDATE        VDO_CMD_VENDOR(0)
0063 #define DP_CMD_CONFIGURE        VDO_CMD_VENDOR(1)
0064 
0065 /* DisplayPort Capabilities VDO bits (returned with Discover Modes) */
0066 #define DP_CAP_CAPABILITY(_cap_)    ((_cap_) & 3)
0067 #define   DP_CAP_UFP_D          1
0068 #define   DP_CAP_DFP_D          2
0069 #define   DP_CAP_DFP_D_AND_UFP_D    3
0070 #define DP_CAP_DP_SIGNALING     BIT(2) /* Always set */
0071 #define DP_CAP_GEN2         BIT(3) /* Reserved after v1.0b */
0072 #define DP_CAP_RECEPTACLE       BIT(6)
0073 #define DP_CAP_USB          BIT(7)
0074 #define DP_CAP_DFP_D_PIN_ASSIGN(_cap_)  (((_cap_) & GENMASK(15, 8)) >> 8)
0075 #define DP_CAP_UFP_D_PIN_ASSIGN(_cap_)  (((_cap_) & GENMASK(23, 16)) >> 16)
0076 /* Get pin assignment taking plug & receptacle into consideration */
0077 #define DP_CAP_PIN_ASSIGN_UFP_D(_cap_) ((_cap_ & DP_CAP_RECEPTACLE) ? \
0078             DP_CAP_UFP_D_PIN_ASSIGN(_cap_) : DP_CAP_DFP_D_PIN_ASSIGN(_cap_))
0079 #define DP_CAP_PIN_ASSIGN_DFP_D(_cap_) ((_cap_ & DP_CAP_RECEPTACLE) ? \
0080             DP_CAP_DFP_D_PIN_ASSIGN(_cap_) : DP_CAP_UFP_D_PIN_ASSIGN(_cap_))
0081 
0082 /* DisplayPort Status Update VDO bits */
0083 #define DP_STATUS_CONNECTION(_status_)  ((_status_) & 3)
0084 #define   DP_STATUS_CON_DISABLED    0
0085 #define   DP_STATUS_CON_DFP_D       1
0086 #define   DP_STATUS_CON_UFP_D       2
0087 #define   DP_STATUS_CON_BOTH        3
0088 #define DP_STATUS_POWER_LOW     BIT(2)
0089 #define DP_STATUS_ENABLED       BIT(3)
0090 #define DP_STATUS_PREFER_MULTI_FUNC BIT(4)
0091 #define DP_STATUS_SWITCH_TO_USB     BIT(5)
0092 #define DP_STATUS_EXIT_DP_MODE      BIT(6)
0093 #define DP_STATUS_HPD_STATE     BIT(7) /* 0 = HPD_Low, 1 = HPD_High */
0094 #define DP_STATUS_IRQ_HPD       BIT(8)
0095 
0096 /* DisplayPort Configurations VDO bits */
0097 #define DP_CONF_CURRENTLY(_conf_)   ((_conf_) & 3)
0098 #define DP_CONF_UFP_U_AS_DFP_D      BIT(0)
0099 #define DP_CONF_UFP_U_AS_UFP_D      BIT(1)
0100 #define DP_CONF_SIGNALING_DP        BIT(2)
0101 #define DP_CONF_SIGNALING_GEN_2     BIT(3) /* Reserved after v1.0b */
0102 #define DP_CONF_PIN_ASSIGNEMENT_SHIFT   8
0103 #define DP_CONF_PIN_ASSIGNEMENT_MASK    GENMASK(15, 8)
0104 
0105 /* Helper for setting/getting the pin assignment value to the configuration */
0106 #define DP_CONF_SET_PIN_ASSIGN(_a_) ((_a_) << 8)
0107 #define DP_CONF_GET_PIN_ASSIGN(_conf_)  (((_conf_) & GENMASK(15, 8)) >> 8)
0108 
0109 #endif /* __USB_TYPEC_DP_H */