1*24edb884SFrançois Tigeot /* 2*24edb884SFrançois Tigeot * Copyright © 2014 Red Hat. 3*24edb884SFrançois Tigeot * 4*24edb884SFrançois Tigeot * Permission to use, copy, modify, distribute, and sell this software and its 5*24edb884SFrançois Tigeot * documentation for any purpose is hereby granted without fee, provided that 6*24edb884SFrançois Tigeot * the above copyright notice appear in all copies and that both that copyright 7*24edb884SFrançois Tigeot * notice and this permission notice appear in supporting documentation, and 8*24edb884SFrançois Tigeot * that the name of the copyright holders not be used in advertising or 9*24edb884SFrançois Tigeot * publicity pertaining to distribution of the software without specific, 10*24edb884SFrançois Tigeot * written prior permission. The copyright holders make no representations 11*24edb884SFrançois Tigeot * about the suitability of this software for any purpose. It is provided "as 12*24edb884SFrançois Tigeot * is" without express or implied warranty. 13*24edb884SFrançois Tigeot * 14*24edb884SFrançois Tigeot * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 15*24edb884SFrançois Tigeot * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 16*24edb884SFrançois Tigeot * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR 17*24edb884SFrançois Tigeot * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 18*24edb884SFrançois Tigeot * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 19*24edb884SFrançois Tigeot * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 20*24edb884SFrançois Tigeot * OF THIS SOFTWARE. 21*24edb884SFrançois Tigeot */ 22*24edb884SFrançois Tigeot #ifndef _DRM_DP_MST_HELPER_H_ 23*24edb884SFrançois Tigeot #define _DRM_DP_MST_HELPER_H_ 24*24edb884SFrançois Tigeot 25*24edb884SFrançois Tigeot #include <linux/types.h> 26*24edb884SFrançois Tigeot #include <drm/drm_dp_helper.h> 27*24edb884SFrançois Tigeot 28*24edb884SFrançois Tigeot struct drm_dp_mst_branch; 29*24edb884SFrançois Tigeot 30*24edb884SFrançois Tigeot /** 31*24edb884SFrançois Tigeot * struct drm_dp_vcpi - Virtual Channel Payload Identifer 32*24edb884SFrançois Tigeot * @vcpi: Virtual channel ID. 33*24edb884SFrançois Tigeot * @pbn: Payload Bandwidth Number for this channel 34*24edb884SFrançois Tigeot * @aligned_pbn: PBN aligned with slot size 35*24edb884SFrançois Tigeot * @num_slots: number of slots for this PBN 36*24edb884SFrançois Tigeot */ 37*24edb884SFrançois Tigeot struct drm_dp_vcpi { 38*24edb884SFrançois Tigeot int vcpi; 39*24edb884SFrançois Tigeot int pbn; 40*24edb884SFrançois Tigeot int aligned_pbn; 41*24edb884SFrançois Tigeot int num_slots; 42*24edb884SFrançois Tigeot }; 43*24edb884SFrançois Tigeot 44*24edb884SFrançois Tigeot /** 45*24edb884SFrançois Tigeot * struct drm_dp_mst_port - MST port 46*24edb884SFrançois Tigeot * @kref: reference count for this port. 47*24edb884SFrançois Tigeot * @guid_valid: for DP 1.2 devices if we have validated the GUID. 48*24edb884SFrançois Tigeot * @guid: guid for DP 1.2 device on this port. 49*24edb884SFrançois Tigeot * @port_num: port number 50*24edb884SFrançois Tigeot * @input: if this port is an input port. 51*24edb884SFrançois Tigeot * @mcs: message capability status - DP 1.2 spec. 52*24edb884SFrançois Tigeot * @ddps: DisplayPort Device Plug Status - DP 1.2 53*24edb884SFrançois Tigeot * @pdt: Peer Device Type 54*24edb884SFrançois Tigeot * @ldps: Legacy Device Plug Status 55*24edb884SFrançois Tigeot * @dpcd_rev: DPCD revision of device on this port 56*24edb884SFrançois Tigeot * @num_sdp_streams: Number of simultaneous streams 57*24edb884SFrançois Tigeot * @num_sdp_stream_sinks: Number of stream sinks 58*24edb884SFrançois Tigeot * @available_pbn: Available bandwidth for this port. 59*24edb884SFrançois Tigeot * @next: link to next port on this branch device 60*24edb884SFrançois Tigeot * @mstb: branch device attach below this port 61*24edb884SFrançois Tigeot * @aux: i2c aux transport to talk to device connected to this port. 62*24edb884SFrançois Tigeot * @parent: branch device parent of this port 63*24edb884SFrançois Tigeot * @vcpi: Virtual Channel Payload info for this port. 64*24edb884SFrançois Tigeot * @connector: DRM connector this port is connected to. 65*24edb884SFrançois Tigeot * @mgr: topology manager this port lives under. 66*24edb884SFrançois Tigeot * 67*24edb884SFrançois Tigeot * This structure represents an MST port endpoint on a device somewhere 68*24edb884SFrançois Tigeot * in the MST topology. 69*24edb884SFrançois Tigeot */ 70*24edb884SFrançois Tigeot struct drm_dp_mst_port { 71*24edb884SFrançois Tigeot struct kref kref; 72*24edb884SFrançois Tigeot 73*24edb884SFrançois Tigeot /* if dpcd 1.2 device is on this port - its GUID info */ 74*24edb884SFrançois Tigeot bool guid_valid; 75*24edb884SFrançois Tigeot u8 guid[16]; 76*24edb884SFrançois Tigeot 77*24edb884SFrançois Tigeot u8 port_num; 78*24edb884SFrançois Tigeot bool input; 79*24edb884SFrançois Tigeot bool mcs; 80*24edb884SFrançois Tigeot bool ddps; 81*24edb884SFrançois Tigeot u8 pdt; 82*24edb884SFrançois Tigeot bool ldps; 83*24edb884SFrançois Tigeot u8 dpcd_rev; 84*24edb884SFrançois Tigeot u8 num_sdp_streams; 85*24edb884SFrançois Tigeot u8 num_sdp_stream_sinks; 86*24edb884SFrançois Tigeot uint16_t available_pbn; 87*24edb884SFrançois Tigeot struct list_head next; 88*24edb884SFrançois Tigeot struct drm_dp_mst_branch *mstb; /* pointer to an mstb if this port has one */ 89*24edb884SFrançois Tigeot struct drm_dp_aux aux; /* i2c bus for this port? */ 90*24edb884SFrançois Tigeot struct drm_dp_mst_branch *parent; 91*24edb884SFrançois Tigeot 92*24edb884SFrançois Tigeot struct drm_dp_vcpi vcpi; 93*24edb884SFrançois Tigeot struct drm_connector *connector; 94*24edb884SFrançois Tigeot struct drm_dp_mst_topology_mgr *mgr; 95*24edb884SFrançois Tigeot }; 96*24edb884SFrançois Tigeot 97*24edb884SFrançois Tigeot /** 98*24edb884SFrançois Tigeot * struct drm_dp_mst_branch - MST branch device. 99*24edb884SFrançois Tigeot * @kref: reference count for this port. 100*24edb884SFrançois Tigeot * @rad: Relative Address to talk to this branch device. 101*24edb884SFrançois Tigeot * @lct: Link count total to talk to this branch device. 102*24edb884SFrançois Tigeot * @num_ports: number of ports on the branch. 103*24edb884SFrançois Tigeot * @msg_slots: one bit per transmitted msg slot. 104*24edb884SFrançois Tigeot * @ports: linked list of ports on this branch. 105*24edb884SFrançois Tigeot * @port_parent: pointer to the port parent, NULL if toplevel. 106*24edb884SFrançois Tigeot * @mgr: topology manager for this branch device. 107*24edb884SFrançois Tigeot * @tx_slots: transmission slots for this device. 108*24edb884SFrançois Tigeot * @last_seqno: last sequence number used to talk to this. 109*24edb884SFrançois Tigeot * @link_address_sent: if a link address message has been sent to this device yet. 110*24edb884SFrançois Tigeot * 111*24edb884SFrançois Tigeot * This structure represents an MST branch device, there is one 112*24edb884SFrançois Tigeot * primary branch device at the root, along with any others connected 113*24edb884SFrançois Tigeot * to downstream ports 114*24edb884SFrançois Tigeot */ 115*24edb884SFrançois Tigeot struct drm_dp_mst_branch { 116*24edb884SFrançois Tigeot struct kref kref; 117*24edb884SFrançois Tigeot u8 rad[8]; 118*24edb884SFrançois Tigeot u8 lct; 119*24edb884SFrançois Tigeot int num_ports; 120*24edb884SFrançois Tigeot 121*24edb884SFrançois Tigeot int msg_slots; 122*24edb884SFrançois Tigeot struct list_head ports; 123*24edb884SFrançois Tigeot 124*24edb884SFrançois Tigeot /* list of tx ops queue for this port */ 125*24edb884SFrançois Tigeot struct drm_dp_mst_port *port_parent; 126*24edb884SFrançois Tigeot struct drm_dp_mst_topology_mgr *mgr; 127*24edb884SFrançois Tigeot 128*24edb884SFrançois Tigeot /* slots are protected by mstb->mgr->qlock */ 129*24edb884SFrançois Tigeot struct drm_dp_sideband_msg_tx *tx_slots[2]; 130*24edb884SFrançois Tigeot int last_seqno; 131*24edb884SFrançois Tigeot bool link_address_sent; 132*24edb884SFrançois Tigeot }; 133*24edb884SFrançois Tigeot 134*24edb884SFrançois Tigeot 135*24edb884SFrançois Tigeot /* sideband msg header - not bit struct */ 136*24edb884SFrançois Tigeot struct drm_dp_sideband_msg_hdr { 137*24edb884SFrançois Tigeot u8 lct; 138*24edb884SFrançois Tigeot u8 lcr; 139*24edb884SFrançois Tigeot u8 rad[8]; 140*24edb884SFrançois Tigeot bool broadcast; 141*24edb884SFrançois Tigeot bool path_msg; 142*24edb884SFrançois Tigeot u8 msg_len; 143*24edb884SFrançois Tigeot bool somt; 144*24edb884SFrançois Tigeot bool eomt; 145*24edb884SFrançois Tigeot bool seqno; 146*24edb884SFrançois Tigeot }; 147*24edb884SFrançois Tigeot 148*24edb884SFrançois Tigeot struct drm_dp_nak_reply { 149*24edb884SFrançois Tigeot u8 guid[16]; 150*24edb884SFrançois Tigeot u8 reason; 151*24edb884SFrançois Tigeot u8 nak_data; 152*24edb884SFrançois Tigeot }; 153*24edb884SFrançois Tigeot 154*24edb884SFrançois Tigeot struct drm_dp_link_address_ack_reply { 155*24edb884SFrançois Tigeot u8 guid[16]; 156*24edb884SFrançois Tigeot u8 nports; 157*24edb884SFrançois Tigeot struct drm_dp_link_addr_reply_port { 158*24edb884SFrançois Tigeot bool input_port; 159*24edb884SFrançois Tigeot u8 peer_device_type; 160*24edb884SFrançois Tigeot u8 port_number; 161*24edb884SFrançois Tigeot bool mcs; 162*24edb884SFrançois Tigeot bool ddps; 163*24edb884SFrançois Tigeot bool legacy_device_plug_status; 164*24edb884SFrançois Tigeot u8 dpcd_revision; 165*24edb884SFrançois Tigeot u8 peer_guid[16]; 166*24edb884SFrançois Tigeot u8 num_sdp_streams; 167*24edb884SFrançois Tigeot u8 num_sdp_stream_sinks; 168*24edb884SFrançois Tigeot } ports[16]; 169*24edb884SFrançois Tigeot }; 170*24edb884SFrançois Tigeot 171*24edb884SFrançois Tigeot struct drm_dp_remote_dpcd_read_ack_reply { 172*24edb884SFrançois Tigeot u8 port_number; 173*24edb884SFrançois Tigeot u8 num_bytes; 174*24edb884SFrançois Tigeot u8 bytes[255]; 175*24edb884SFrançois Tigeot }; 176*24edb884SFrançois Tigeot 177*24edb884SFrançois Tigeot struct drm_dp_remote_dpcd_write_ack_reply { 178*24edb884SFrançois Tigeot u8 port_number; 179*24edb884SFrançois Tigeot }; 180*24edb884SFrançois Tigeot 181*24edb884SFrançois Tigeot struct drm_dp_remote_dpcd_write_nak_reply { 182*24edb884SFrançois Tigeot u8 port_number; 183*24edb884SFrançois Tigeot u8 reason; 184*24edb884SFrançois Tigeot u8 bytes_written_before_failure; 185*24edb884SFrançois Tigeot }; 186*24edb884SFrançois Tigeot 187*24edb884SFrançois Tigeot struct drm_dp_remote_i2c_read_ack_reply { 188*24edb884SFrançois Tigeot u8 port_number; 189*24edb884SFrançois Tigeot u8 num_bytes; 190*24edb884SFrançois Tigeot u8 bytes[255]; 191*24edb884SFrançois Tigeot }; 192*24edb884SFrançois Tigeot 193*24edb884SFrançois Tigeot struct drm_dp_remote_i2c_read_nak_reply { 194*24edb884SFrançois Tigeot u8 port_number; 195*24edb884SFrançois Tigeot u8 nak_reason; 196*24edb884SFrançois Tigeot u8 i2c_nak_transaction; 197*24edb884SFrançois Tigeot }; 198*24edb884SFrançois Tigeot 199*24edb884SFrançois Tigeot struct drm_dp_remote_i2c_write_ack_reply { 200*24edb884SFrançois Tigeot u8 port_number; 201*24edb884SFrançois Tigeot }; 202*24edb884SFrançois Tigeot 203*24edb884SFrançois Tigeot 204*24edb884SFrançois Tigeot struct drm_dp_sideband_msg_rx { 205*24edb884SFrançois Tigeot u8 chunk[48]; 206*24edb884SFrançois Tigeot u8 msg[256]; 207*24edb884SFrançois Tigeot u8 curchunk_len; 208*24edb884SFrançois Tigeot u8 curchunk_idx; /* chunk we are parsing now */ 209*24edb884SFrançois Tigeot u8 curchunk_hdrlen; 210*24edb884SFrançois Tigeot u8 curlen; /* total length of the msg */ 211*24edb884SFrançois Tigeot bool have_somt; 212*24edb884SFrançois Tigeot bool have_eomt; 213*24edb884SFrançois Tigeot struct drm_dp_sideband_msg_hdr initial_hdr; 214*24edb884SFrançois Tigeot }; 215*24edb884SFrançois Tigeot 216*24edb884SFrançois Tigeot 217*24edb884SFrançois Tigeot struct drm_dp_allocate_payload { 218*24edb884SFrançois Tigeot u8 port_number; 219*24edb884SFrançois Tigeot u8 number_sdp_streams; 220*24edb884SFrançois Tigeot u8 vcpi; 221*24edb884SFrançois Tigeot u16 pbn; 222*24edb884SFrançois Tigeot u8 sdp_stream_sink[8]; 223*24edb884SFrançois Tigeot }; 224*24edb884SFrançois Tigeot 225*24edb884SFrançois Tigeot struct drm_dp_allocate_payload_ack_reply { 226*24edb884SFrançois Tigeot u8 port_number; 227*24edb884SFrançois Tigeot u8 vcpi; 228*24edb884SFrançois Tigeot u16 allocated_pbn; 229*24edb884SFrançois Tigeot }; 230*24edb884SFrançois Tigeot 231*24edb884SFrançois Tigeot struct drm_dp_connection_status_notify { 232*24edb884SFrançois Tigeot u8 guid[16]; 233*24edb884SFrançois Tigeot u8 port_number; 234*24edb884SFrançois Tigeot bool legacy_device_plug_status; 235*24edb884SFrançois Tigeot bool displayport_device_plug_status; 236*24edb884SFrançois Tigeot bool message_capability_status; 237*24edb884SFrançois Tigeot bool input_port; 238*24edb884SFrançois Tigeot u8 peer_device_type; 239*24edb884SFrançois Tigeot }; 240*24edb884SFrançois Tigeot 241*24edb884SFrançois Tigeot struct drm_dp_remote_dpcd_read { 242*24edb884SFrançois Tigeot u8 port_number; 243*24edb884SFrançois Tigeot u32 dpcd_address; 244*24edb884SFrançois Tigeot u8 num_bytes; 245*24edb884SFrançois Tigeot }; 246*24edb884SFrançois Tigeot 247*24edb884SFrançois Tigeot struct drm_dp_remote_dpcd_write { 248*24edb884SFrançois Tigeot u8 port_number; 249*24edb884SFrançois Tigeot u32 dpcd_address; 250*24edb884SFrançois Tigeot u8 num_bytes; 251*24edb884SFrançois Tigeot u8 *bytes; 252*24edb884SFrançois Tigeot }; 253*24edb884SFrançois Tigeot 254*24edb884SFrançois Tigeot struct drm_dp_remote_i2c_read { 255*24edb884SFrançois Tigeot u8 num_transactions; 256*24edb884SFrançois Tigeot u8 port_number; 257*24edb884SFrançois Tigeot struct { 258*24edb884SFrançois Tigeot u8 i2c_dev_id; 259*24edb884SFrançois Tigeot u8 num_bytes; 260*24edb884SFrançois Tigeot u8 *bytes; 261*24edb884SFrançois Tigeot u8 no_stop_bit; 262*24edb884SFrançois Tigeot u8 i2c_transaction_delay; 263*24edb884SFrançois Tigeot } transactions[4]; 264*24edb884SFrançois Tigeot u8 read_i2c_device_id; 265*24edb884SFrançois Tigeot u8 num_bytes_read; 266*24edb884SFrançois Tigeot }; 267*24edb884SFrançois Tigeot 268*24edb884SFrançois Tigeot struct drm_dp_remote_i2c_write { 269*24edb884SFrançois Tigeot u8 port_number; 270*24edb884SFrançois Tigeot u8 write_i2c_device_id; 271*24edb884SFrançois Tigeot u8 num_bytes; 272*24edb884SFrançois Tigeot u8 *bytes; 273*24edb884SFrançois Tigeot }; 274*24edb884SFrançois Tigeot 275*24edb884SFrançois Tigeot /* this covers ENUM_RESOURCES, POWER_DOWN_PHY, POWER_UP_PHY */ 276*24edb884SFrançois Tigeot struct drm_dp_port_number_req { 277*24edb884SFrançois Tigeot u8 port_number; 278*24edb884SFrançois Tigeot }; 279*24edb884SFrançois Tigeot 280*24edb884SFrançois Tigeot struct drm_dp_enum_path_resources_ack_reply { 281*24edb884SFrançois Tigeot u8 port_number; 282*24edb884SFrançois Tigeot u16 full_payload_bw_number; 283*24edb884SFrançois Tigeot u16 avail_payload_bw_number; 284*24edb884SFrançois Tigeot }; 285*24edb884SFrançois Tigeot 286*24edb884SFrançois Tigeot /* covers POWER_DOWN_PHY, POWER_UP_PHY */ 287*24edb884SFrançois Tigeot struct drm_dp_port_number_rep { 288*24edb884SFrançois Tigeot u8 port_number; 289*24edb884SFrançois Tigeot }; 290*24edb884SFrançois Tigeot 291*24edb884SFrançois Tigeot struct drm_dp_query_payload { 292*24edb884SFrançois Tigeot u8 port_number; 293*24edb884SFrançois Tigeot u8 vcpi; 294*24edb884SFrançois Tigeot }; 295*24edb884SFrançois Tigeot 296*24edb884SFrançois Tigeot struct drm_dp_resource_status_notify { 297*24edb884SFrançois Tigeot u8 port_number; 298*24edb884SFrançois Tigeot u8 guid[16]; 299*24edb884SFrançois Tigeot u16 available_pbn; 300*24edb884SFrançois Tigeot }; 301*24edb884SFrançois Tigeot 302*24edb884SFrançois Tigeot struct drm_dp_query_payload_ack_reply { 303*24edb884SFrançois Tigeot u8 port_number; 304*24edb884SFrançois Tigeot u8 allocated_pbn; 305*24edb884SFrançois Tigeot }; 306*24edb884SFrançois Tigeot 307*24edb884SFrançois Tigeot struct drm_dp_sideband_msg_req_body { 308*24edb884SFrançois Tigeot u8 req_type; 309*24edb884SFrançois Tigeot union ack_req { 310*24edb884SFrançois Tigeot struct drm_dp_connection_status_notify conn_stat; 311*24edb884SFrançois Tigeot struct drm_dp_port_number_req port_num; 312*24edb884SFrançois Tigeot struct drm_dp_resource_status_notify resource_stat; 313*24edb884SFrançois Tigeot 314*24edb884SFrançois Tigeot struct drm_dp_query_payload query_payload; 315*24edb884SFrançois Tigeot struct drm_dp_allocate_payload allocate_payload; 316*24edb884SFrançois Tigeot 317*24edb884SFrançois Tigeot struct drm_dp_remote_dpcd_read dpcd_read; 318*24edb884SFrançois Tigeot struct drm_dp_remote_dpcd_write dpcd_write; 319*24edb884SFrançois Tigeot 320*24edb884SFrançois Tigeot struct drm_dp_remote_i2c_read i2c_read; 321*24edb884SFrançois Tigeot struct drm_dp_remote_i2c_write i2c_write; 322*24edb884SFrançois Tigeot } u; 323*24edb884SFrançois Tigeot }; 324*24edb884SFrançois Tigeot 325*24edb884SFrançois Tigeot struct drm_dp_sideband_msg_reply_body { 326*24edb884SFrançois Tigeot u8 reply_type; 327*24edb884SFrançois Tigeot u8 req_type; 328*24edb884SFrançois Tigeot union ack_replies { 329*24edb884SFrançois Tigeot struct drm_dp_nak_reply nak; 330*24edb884SFrançois Tigeot struct drm_dp_link_address_ack_reply link_addr; 331*24edb884SFrançois Tigeot struct drm_dp_port_number_rep port_number; 332*24edb884SFrançois Tigeot 333*24edb884SFrançois Tigeot struct drm_dp_enum_path_resources_ack_reply path_resources; 334*24edb884SFrançois Tigeot struct drm_dp_allocate_payload_ack_reply allocate_payload; 335*24edb884SFrançois Tigeot struct drm_dp_query_payload_ack_reply query_payload; 336*24edb884SFrançois Tigeot 337*24edb884SFrançois Tigeot struct drm_dp_remote_dpcd_read_ack_reply remote_dpcd_read_ack; 338*24edb884SFrançois Tigeot struct drm_dp_remote_dpcd_write_ack_reply remote_dpcd_write_ack; 339*24edb884SFrançois Tigeot struct drm_dp_remote_dpcd_write_nak_reply remote_dpcd_write_nack; 340*24edb884SFrançois Tigeot 341*24edb884SFrançois Tigeot struct drm_dp_remote_i2c_read_ack_reply remote_i2c_read_ack; 342*24edb884SFrançois Tigeot struct drm_dp_remote_i2c_read_nak_reply remote_i2c_read_nack; 343*24edb884SFrançois Tigeot struct drm_dp_remote_i2c_write_ack_reply remote_i2c_write_ack; 344*24edb884SFrançois Tigeot } u; 345*24edb884SFrançois Tigeot }; 346*24edb884SFrançois Tigeot 347*24edb884SFrançois Tigeot /* msg is queued to be put into a slot */ 348*24edb884SFrançois Tigeot #define DRM_DP_SIDEBAND_TX_QUEUED 0 349*24edb884SFrançois Tigeot /* msg has started transmitting on a slot - still on msgq */ 350*24edb884SFrançois Tigeot #define DRM_DP_SIDEBAND_TX_START_SEND 1 351*24edb884SFrançois Tigeot /* msg has finished transmitting on a slot - removed from msgq only in slot */ 352*24edb884SFrançois Tigeot #define DRM_DP_SIDEBAND_TX_SENT 2 353*24edb884SFrançois Tigeot /* msg has received a response - removed from slot */ 354*24edb884SFrançois Tigeot #define DRM_DP_SIDEBAND_TX_RX 3 355*24edb884SFrançois Tigeot #define DRM_DP_SIDEBAND_TX_TIMEOUT 4 356*24edb884SFrançois Tigeot 357*24edb884SFrançois Tigeot struct drm_dp_sideband_msg_tx { 358*24edb884SFrançois Tigeot u8 msg[256]; 359*24edb884SFrançois Tigeot u8 chunk[48]; 360*24edb884SFrançois Tigeot u8 cur_offset; 361*24edb884SFrançois Tigeot u8 cur_len; 362*24edb884SFrançois Tigeot struct drm_dp_mst_branch *dst; 363*24edb884SFrançois Tigeot struct list_head next; 364*24edb884SFrançois Tigeot int seqno; 365*24edb884SFrançois Tigeot int state; 366*24edb884SFrançois Tigeot bool path_msg; 367*24edb884SFrançois Tigeot struct drm_dp_sideband_msg_reply_body reply; 368*24edb884SFrançois Tigeot }; 369*24edb884SFrançois Tigeot 370*24edb884SFrançois Tigeot /* sideband msg handler */ 371*24edb884SFrançois Tigeot struct drm_dp_mst_topology_mgr; 372*24edb884SFrançois Tigeot struct drm_dp_mst_topology_cbs { 373*24edb884SFrançois Tigeot /* create a connector for a port */ 374*24edb884SFrançois Tigeot struct drm_connector *(*add_connector)(struct drm_dp_mst_topology_mgr *mgr, struct drm_dp_mst_port *port, char *path); 375*24edb884SFrançois Tigeot void (*destroy_connector)(struct drm_dp_mst_topology_mgr *mgr, 376*24edb884SFrançois Tigeot struct drm_connector *connector); 377*24edb884SFrançois Tigeot void (*hotplug)(struct drm_dp_mst_topology_mgr *mgr); 378*24edb884SFrançois Tigeot 379*24edb884SFrançois Tigeot }; 380*24edb884SFrançois Tigeot 381*24edb884SFrançois Tigeot #define DP_MAX_PAYLOAD (sizeof(unsigned long) * 8) 382*24edb884SFrançois Tigeot 383*24edb884SFrançois Tigeot #define DP_PAYLOAD_LOCAL 1 384*24edb884SFrançois Tigeot #define DP_PAYLOAD_REMOTE 2 385*24edb884SFrançois Tigeot #define DP_PAYLOAD_DELETE_LOCAL 3 386*24edb884SFrançois Tigeot 387*24edb884SFrançois Tigeot struct drm_dp_payload { 388*24edb884SFrançois Tigeot int payload_state; 389*24edb884SFrançois Tigeot int start_slot; 390*24edb884SFrançois Tigeot int num_slots; 391*24edb884SFrançois Tigeot }; 392*24edb884SFrançois Tigeot 393*24edb884SFrançois Tigeot /** 394*24edb884SFrançois Tigeot * struct drm_dp_mst_topology_mgr - DisplayPort MST manager 395*24edb884SFrançois Tigeot * @dev: device pointer for adding i2c devices etc. 396*24edb884SFrançois Tigeot * @cbs: callbacks for connector addition and destruction. 397*24edb884SFrançois Tigeot * @max_dpcd_transaction_bytes - maximum number of bytes to read/write in one go. 398*24edb884SFrançois Tigeot * @aux: aux channel for the DP connector. 399*24edb884SFrançois Tigeot * @max_payloads: maximum number of payloads the GPU can generate. 400*24edb884SFrançois Tigeot * @conn_base_id: DRM connector ID this mgr is connected to. 401*24edb884SFrançois Tigeot * @down_rep_recv: msg receiver state for down replies. 402*24edb884SFrançois Tigeot * @up_req_recv: msg receiver state for up requests. 403*24edb884SFrançois Tigeot * @lock: protects mst state, primary, guid, dpcd. 404*24edb884SFrançois Tigeot * @mst_state: if this manager is enabled for an MST capable port. 405*24edb884SFrançois Tigeot * @mst_primary: pointer to the primary branch device. 406*24edb884SFrançois Tigeot * @guid_valid: GUID valid for the primary branch device. 407*24edb884SFrançois Tigeot * @guid: GUID for primary port. 408*24edb884SFrançois Tigeot * @dpcd: cache of DPCD for primary port. 409*24edb884SFrançois Tigeot * @pbn_div: PBN to slots divisor. 410*24edb884SFrançois Tigeot * 411*24edb884SFrançois Tigeot * This struct represents the toplevel displayport MST topology manager. 412*24edb884SFrançois Tigeot * There should be one instance of this for every MST capable DP connector 413*24edb884SFrançois Tigeot * on the GPU. 414*24edb884SFrançois Tigeot */ 415*24edb884SFrançois Tigeot struct drm_dp_mst_topology_mgr { 416*24edb884SFrançois Tigeot 417*24edb884SFrançois Tigeot struct device *dev; 418*24edb884SFrançois Tigeot struct drm_dp_mst_topology_cbs *cbs; 419*24edb884SFrançois Tigeot int max_dpcd_transaction_bytes; 420*24edb884SFrançois Tigeot struct drm_dp_aux *aux; /* auxch for this topology mgr to use */ 421*24edb884SFrançois Tigeot int max_payloads; 422*24edb884SFrançois Tigeot int conn_base_id; 423*24edb884SFrançois Tigeot 424*24edb884SFrançois Tigeot /* only ever accessed from the workqueue - which should be serialised */ 425*24edb884SFrançois Tigeot struct drm_dp_sideband_msg_rx down_rep_recv; 426*24edb884SFrançois Tigeot struct drm_dp_sideband_msg_rx up_req_recv; 427*24edb884SFrançois Tigeot 428*24edb884SFrançois Tigeot /* pointer to info about the initial MST device */ 429*24edb884SFrançois Tigeot struct lock lock; /* protects mst_state + primary + guid + dpcd */ 430*24edb884SFrançois Tigeot 431*24edb884SFrançois Tigeot bool mst_state; 432*24edb884SFrançois Tigeot struct drm_dp_mst_branch *mst_primary; 433*24edb884SFrançois Tigeot /* primary MST device GUID */ 434*24edb884SFrançois Tigeot bool guid_valid; 435*24edb884SFrançois Tigeot u8 guid[16]; 436*24edb884SFrançois Tigeot u8 dpcd[DP_RECEIVER_CAP_SIZE]; 437*24edb884SFrançois Tigeot u8 sink_count; 438*24edb884SFrançois Tigeot int pbn_div; 439*24edb884SFrançois Tigeot int total_slots; 440*24edb884SFrançois Tigeot int avail_slots; 441*24edb884SFrançois Tigeot int total_pbn; 442*24edb884SFrançois Tigeot 443*24edb884SFrançois Tigeot /* messages to be transmitted */ 444*24edb884SFrançois Tigeot /* qlock protects the upq/downq and in_progress, 445*24edb884SFrançois Tigeot the mstb tx_slots and txmsg->state once they are queued */ 446*24edb884SFrançois Tigeot struct lock qlock; 447*24edb884SFrançois Tigeot struct list_head tx_msg_downq; 448*24edb884SFrançois Tigeot struct list_head tx_msg_upq; 449*24edb884SFrançois Tigeot bool tx_down_in_progress; 450*24edb884SFrançois Tigeot bool tx_up_in_progress; 451*24edb884SFrançois Tigeot 452*24edb884SFrançois Tigeot /* payload info + lock for it */ 453*24edb884SFrançois Tigeot struct lock payload_lock; 454*24edb884SFrançois Tigeot struct drm_dp_vcpi **proposed_vcpis; 455*24edb884SFrançois Tigeot struct drm_dp_payload *payloads; 456*24edb884SFrançois Tigeot unsigned long payload_mask; 457*24edb884SFrançois Tigeot 458*24edb884SFrançois Tigeot wait_queue_head_t tx_waitq; 459*24edb884SFrançois Tigeot struct work_struct work; 460*24edb884SFrançois Tigeot 461*24edb884SFrançois Tigeot struct work_struct tx_work; 462*24edb884SFrançois Tigeot }; 463*24edb884SFrançois Tigeot 464*24edb884SFrançois Tigeot int drm_dp_mst_topology_mgr_init(struct drm_dp_mst_topology_mgr *mgr, struct device *dev, struct drm_dp_aux *aux, int max_dpcd_transaction_bytes, int max_payloads, int conn_base_id); 465*24edb884SFrançois Tigeot 466*24edb884SFrançois Tigeot void drm_dp_mst_topology_mgr_destroy(struct drm_dp_mst_topology_mgr *mgr); 467*24edb884SFrançois Tigeot 468*24edb884SFrançois Tigeot 469*24edb884SFrançois Tigeot int drm_dp_mst_topology_mgr_set_mst(struct drm_dp_mst_topology_mgr *mgr, bool mst_state); 470*24edb884SFrançois Tigeot 471*24edb884SFrançois Tigeot 472*24edb884SFrançois Tigeot int drm_dp_mst_hpd_irq(struct drm_dp_mst_topology_mgr *mgr, u8 *esi, bool *handled); 473*24edb884SFrançois Tigeot 474*24edb884SFrançois Tigeot 475*24edb884SFrançois Tigeot enum drm_connector_status drm_dp_mst_detect_port(struct drm_dp_mst_topology_mgr *mgr, struct drm_dp_mst_port *port); 476*24edb884SFrançois Tigeot 477*24edb884SFrançois Tigeot struct edid *drm_dp_mst_get_edid(struct drm_connector *connector, struct drm_dp_mst_topology_mgr *mgr, struct drm_dp_mst_port *port); 478*24edb884SFrançois Tigeot 479*24edb884SFrançois Tigeot 480*24edb884SFrançois Tigeot int drm_dp_calc_pbn_mode(int clock, int bpp); 481*24edb884SFrançois Tigeot 482*24edb884SFrançois Tigeot 483*24edb884SFrançois Tigeot bool drm_dp_mst_allocate_vcpi(struct drm_dp_mst_topology_mgr *mgr, struct drm_dp_mst_port *port, int pbn, int *slots); 484*24edb884SFrançois Tigeot 485*24edb884SFrançois Tigeot 486*24edb884SFrançois Tigeot void drm_dp_mst_reset_vcpi_slots(struct drm_dp_mst_topology_mgr *mgr, struct drm_dp_mst_port *port); 487*24edb884SFrançois Tigeot 488*24edb884SFrançois Tigeot 489*24edb884SFrançois Tigeot void drm_dp_mst_deallocate_vcpi(struct drm_dp_mst_topology_mgr *mgr, 490*24edb884SFrançois Tigeot struct drm_dp_mst_port *port); 491*24edb884SFrançois Tigeot 492*24edb884SFrançois Tigeot 493*24edb884SFrançois Tigeot int drm_dp_find_vcpi_slots(struct drm_dp_mst_topology_mgr *mgr, 494*24edb884SFrançois Tigeot int pbn); 495*24edb884SFrançois Tigeot 496*24edb884SFrançois Tigeot 497*24edb884SFrançois Tigeot int drm_dp_update_payload_part1(struct drm_dp_mst_topology_mgr *mgr); 498*24edb884SFrançois Tigeot 499*24edb884SFrançois Tigeot 500*24edb884SFrançois Tigeot int drm_dp_update_payload_part2(struct drm_dp_mst_topology_mgr *mgr); 501*24edb884SFrançois Tigeot 502*24edb884SFrançois Tigeot int drm_dp_check_act_status(struct drm_dp_mst_topology_mgr *mgr); 503*24edb884SFrançois Tigeot 504*24edb884SFrançois Tigeot void drm_dp_mst_dump_topology(struct seq_file *m, 505*24edb884SFrançois Tigeot struct drm_dp_mst_topology_mgr *mgr); 506*24edb884SFrançois Tigeot 507*24edb884SFrançois Tigeot void drm_dp_mst_topology_mgr_suspend(struct drm_dp_mst_topology_mgr *mgr); 508*24edb884SFrançois Tigeot int drm_dp_mst_topology_mgr_resume(struct drm_dp_mst_topology_mgr *mgr); 509*24edb884SFrançois Tigeot #endif 510