1 /* SPDX-License-Identifier: MIT */
3 * Copyright 2021 Advanced Micro Devices, Inc.
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
19 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21 * OTHER DEALINGS IN THE SOFTWARE.
27 #ifndef __DC_LINK_DPIA_H__
28 #define __DC_LINK_DPIA_H__
30 /* This module implements functionality for training DPIA links. */
33 struct dc_link_settings;
35 /* The approximate time (us) it takes to transmit 9 USB4 DP clock sync packets. */
36 #define DPIA_CLK_SYNC_DELAY 16000
38 /* Extend interval between training status checks for manual testing. */
39 #define DPIA_DEBUG_EXTENDED_AUX_RD_INTERVAL_US 60000000
41 /** @note Can remove once DP tunneling registers in upstream include/drm/drm_dp_helper.h */
42 /* DPCD DP Tunneling over USB4 */
43 #define DP_TUNNELING_CAPABILITIES_SUPPORT 0xe000d
44 #define DP_IN_ADAPTER_INFO 0xe000e
45 #define DP_USB4_DRIVER_ID 0xe000f
46 #define DP_USB4_ROUTER_TOPOLOGY_ID 0xe001b
48 /* SET_CONFIG message types sent by driver. */
49 enum dpia_set_config_type {
50 DPIA_SET_CFG_SET_LINK = 0x01,
51 DPIA_SET_CFG_SET_PHY_TEST_MODE = 0x05,
52 DPIA_SET_CFG_SET_TRAINING = 0x18,
53 DPIA_SET_CFG_SET_VSPE = 0x19
56 /* Training stages (TS) in SET_CONFIG(SET_TRAINING) message. */
57 enum dpia_set_config_ts {
58 DPIA_TS_DPRX_DONE = 0x00, /* Done training DPRX. */
63 DPIA_TS_UFP_DONE = 0xff /* Done training DPTX-to-DPIA hop. */
66 /* SET_CONFIG message data associated with messages sent by driver. */
67 union dpia_set_config_data {
77 uint8_t max_swing_reached : 1;
79 uint8_t max_pre_emph_reached : 1;
85 /* Read tunneling device capability from DPCD and update link capability
88 enum dc_status dpcd_get_tunneling_device_data(struct dc_link *link);
90 /* Query hot plug status of USB4 DP tunnel.
91 * Returns true if HPD high.
93 bool dc_link_dpia_query_hpd_status(struct dc_link *link);
95 /* Train DP tunneling link for USB4 DPIA display endpoint.
96 * DPIA equivalent of dc_link_dp_perfrorm_link_training.
97 * Aborts link training upon detection of sink unplug.
99 enum link_training_result dc_link_dpia_perform_link_training(
100 struct dc_link *link,
101 const struct link_resource *link_res,
102 const struct dc_link_settings *link_setting,
103 bool skip_video_pattern);
105 #endif /* __DC_LINK_DPIA_H__ */