Skip to content

Commit 9485654

Browse files
committed
Merge tag 'topic/phy-compliance-2020-04-08' of git://anongit.freedesktop.org/drm/drm-misc into drm-misc-next
Topic pull request for topic/phy-compliance: - Standardize DP_PHY_TEST_PATTERN name. - Add support for setting/getting test pattern from sink. - Implement DP PHY compliance to i915. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> # gpg: Signatur vom Mi 08 Apr 2020 14:46:42 CEST # gpg: mittels RSA-Schlüssel B97BD6A80CAC4981091AE547FE558C72A67013C3 # gpg: Signatur kann nicht geprüft werden: Kein öffentlicher Schlüssel From: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/efb3d0d9-2cf7-046b-3a9b-2548d086258e@linux.intel.com
2 parents 08d99b2 + 8cdf727 commit 9485654

10 files changed

Lines changed: 337 additions & 8 deletions

File tree

‎drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2530,7 +2530,7 @@ static void dp_test_send_phy_test_pattern(struct dc_link *link)
25302530
/* get phy test pattern and pattern parameters from DP receiver */
25312531
core_link_read_dpcd(
25322532
link,
2533-
DP_TEST_PHY_PATTERN,
2533+
DP_PHY_TEST_PATTERN,
25342534
&dpcd_test_pattern.raw,
25352535
sizeof(dpcd_test_pattern));
25362536
core_link_read_dpcd(

‎drivers/gpu/drm/drm_dp_helper.c‎

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1533,3 +1533,97 @@ int drm_dp_dsc_sink_supported_input_bpcs(const u8 dsc_dpcd[DP_DSC_RECEIVER_CAP_S
15331533
return num_bpc;
15341534
}
15351535
EXPORT_SYMBOL(drm_dp_dsc_sink_supported_input_bpcs);
1536+
1537+
/**
1538+
* drm_dp_get_phy_test_pattern() - get the requested pattern from the sink.
1539+
* @aux: DisplayPort AUX channel
1540+
* @data: DP phy compliance test parameters.
1541+
*
1542+
* Returns 0 on success or a negative error code on failure.
1543+
*/
1544+
int drm_dp_get_phy_test_pattern(struct drm_dp_aux *aux,
1545+
struct drm_dp_phy_test_params *data)
1546+
{
1547+
int err;
1548+
u8 rate, lanes;
1549+
1550+
err = drm_dp_dpcd_readb(aux, DP_TEST_LINK_RATE, &rate);
1551+
if (err < 0)
1552+
return err;
1553+
data->link_rate = drm_dp_bw_code_to_link_rate(rate);
1554+
1555+
err = drm_dp_dpcd_readb(aux, DP_TEST_LANE_COUNT, &lanes);
1556+
if (err < 0)
1557+
return err;
1558+
data->num_lanes = lanes & DP_MAX_LANE_COUNT_MASK;
1559+
1560+
if (lanes & DP_ENHANCED_FRAME_CAP)
1561+
data->enhanced_frame_cap = true;
1562+
1563+
err = drm_dp_dpcd_readb(aux, DP_PHY_TEST_PATTERN, &data->phy_pattern);
1564+
if (err < 0)
1565+
return err;
1566+
1567+
switch (data->phy_pattern) {
1568+
case DP_PHY_TEST_PATTERN_80BIT_CUSTOM:
1569+
err = drm_dp_dpcd_read(aux, DP_TEST_80BIT_CUSTOM_PATTERN_7_0,
1570+
&data->custom80, sizeof(data->custom80));
1571+
if (err < 0)
1572+
return err;
1573+
1574+
break;
1575+
case DP_PHY_TEST_PATTERN_CP2520:
1576+
err = drm_dp_dpcd_read(aux, DP_TEST_HBR2_SCRAMBLER_RESET,
1577+
&data->hbr2_reset,
1578+
sizeof(data->hbr2_reset));
1579+
if (err < 0)
1580+
return err;
1581+
}
1582+
1583+
return 0;
1584+
}
1585+
EXPORT_SYMBOL(drm_dp_get_phy_test_pattern);
1586+
1587+
/**
1588+
* drm_dp_set_phy_test_pattern() - set the pattern to the sink.
1589+
* @aux: DisplayPort AUX channel
1590+
* @data: DP phy compliance test parameters.
1591+
*
1592+
* Returns 0 on success or a negative error code on failure.
1593+
*/
1594+
int drm_dp_set_phy_test_pattern(struct drm_dp_aux *aux,
1595+
struct drm_dp_phy_test_params *data, u8 dp_rev)
1596+
{
1597+
int err, i;
1598+
u8 link_config[2];
1599+
u8 test_pattern;
1600+
1601+
link_config[0] = drm_dp_link_rate_to_bw_code(data->link_rate);
1602+
link_config[1] = data->num_lanes;
1603+
if (data->enhanced_frame_cap)
1604+
link_config[1] |= DP_LANE_COUNT_ENHANCED_FRAME_EN;
1605+
err = drm_dp_dpcd_write(aux, DP_LINK_BW_SET, link_config, 2);
1606+
if (err < 0)
1607+
return err;
1608+
1609+
test_pattern = data->phy_pattern;
1610+
if (dp_rev < 0x12) {
1611+
test_pattern = (test_pattern << 2) &
1612+
DP_LINK_QUAL_PATTERN_11_MASK;
1613+
err = drm_dp_dpcd_writeb(aux, DP_TRAINING_PATTERN_SET,
1614+
test_pattern);
1615+
if (err < 0)
1616+
return err;
1617+
} else {
1618+
for (i = 0; i < data->num_lanes; i++) {
1619+
err = drm_dp_dpcd_writeb(aux,
1620+
DP_LINK_QUAL_LANE0_SET + i,
1621+
test_pattern);
1622+
if (err < 0)
1623+
return err;
1624+
}
1625+
}
1626+
1627+
return 0;
1628+
}
1629+
EXPORT_SYMBOL(drm_dp_set_phy_test_pattern);

‎drivers/gpu/drm/i915/display/intel_display_debugfs.c‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1320,6 +1320,16 @@ static int i915_displayport_test_data_show(struct seq_file *m, void *data)
13201320
intel_dp->compliance.test_data.vdisplay);
13211321
seq_printf(m, "bpc: %u\n",
13221322
intel_dp->compliance.test_data.bpc);
1323+
} else if (intel_dp->compliance.test_type ==
1324+
DP_TEST_LINK_PHY_TEST_PATTERN) {
1325+
seq_printf(m, "pattern: %d\n",
1326+
intel_dp->compliance.test_data.phytest.phy_pattern);
1327+
seq_printf(m, "Number of lanes: %d\n",
1328+
intel_dp->compliance.test_data.phytest.num_lanes);
1329+
seq_printf(m, "Link Rate: %d\n",
1330+
intel_dp->compliance.test_data.phytest.link_rate);
1331+
seq_printf(m, "level: %02x\n",
1332+
intel_dp->train_set[0]);
13231333
}
13241334
} else
13251335
seq_puts(m, "0");
@@ -1352,7 +1362,7 @@ static int i915_displayport_test_type_show(struct seq_file *m, void *data)
13521362

13531363
if (encoder && connector->status == connector_status_connected) {
13541364
intel_dp = enc_to_intel_dp(encoder);
1355-
seq_printf(m, "%02lx", intel_dp->compliance.test_type);
1365+
seq_printf(m, "%02lx\n", intel_dp->compliance.test_type);
13561366
} else
13571367
seq_puts(m, "0");
13581368
}

‎drivers/gpu/drm/i915/display/intel_display_types.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,6 +1238,7 @@ struct intel_dp_compliance_data {
12381238
u8 video_pattern;
12391239
u16 hdisplay, vdisplay;
12401240
u8 bpc;
1241+
struct drm_dp_phy_test_params phytest;
12411242
};
12421243

12431244
struct intel_dp_compliance {

‎drivers/gpu/drm/i915/display/intel_dp.c‎

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5001,9 +5001,180 @@ static u8 intel_dp_autotest_edid(struct intel_dp *intel_dp)
50015001
return test_result;
50025002
}
50035003

5004+
static u8 intel_dp_prepare_phytest(struct intel_dp *intel_dp)
5005+
{
5006+
struct drm_dp_phy_test_params *data =
5007+
&intel_dp->compliance.test_data.phytest;
5008+
5009+
if (drm_dp_get_phy_test_pattern(&intel_dp->aux, data)) {
5010+
DRM_DEBUG_KMS("DP Phy Test pattern AUX read failure\n");
5011+
return DP_TEST_NAK;
5012+
}
5013+
5014+
/*
5015+
* link_mst is set to false to avoid executing mst related code
5016+
* during compliance testing.
5017+
*/
5018+
intel_dp->link_mst = false;
5019+
5020+
return DP_TEST_ACK;
5021+
}
5022+
5023+
static void intel_dp_phy_pattern_update(struct intel_dp *intel_dp)
5024+
{
5025+
struct drm_i915_private *dev_priv =
5026+
to_i915(dp_to_dig_port(intel_dp)->base.base.dev);
5027+
struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
5028+
struct drm_dp_phy_test_params *data =
5029+
&intel_dp->compliance.test_data.phytest;
5030+
struct intel_crtc *crtc = to_intel_crtc(intel_dig_port->base.base.crtc);
5031+
enum pipe pipe = crtc->pipe;
5032+
u32 pattern_val;
5033+
5034+
switch (data->phy_pattern) {
5035+
case DP_PHY_TEST_PATTERN_NONE:
5036+
DRM_DEBUG_KMS("Disable Phy Test Pattern\n");
5037+
intel_de_write(dev_priv, DDI_DP_COMP_CTL(pipe), 0x0);
5038+
break;
5039+
case DP_PHY_TEST_PATTERN_D10_2:
5040+
DRM_DEBUG_KMS("Set D10.2 Phy Test Pattern\n");
5041+
intel_de_write(dev_priv, DDI_DP_COMP_CTL(pipe),
5042+
DDI_DP_COMP_CTL_ENABLE | DDI_DP_COMP_CTL_D10_2);
5043+
break;
5044+
case DP_PHY_TEST_PATTERN_ERROR_COUNT:
5045+
DRM_DEBUG_KMS("Set Error Count Phy Test Pattern\n");
5046+
intel_de_write(dev_priv, DDI_DP_COMP_CTL(pipe),
5047+
DDI_DP_COMP_CTL_ENABLE |
5048+
DDI_DP_COMP_CTL_SCRAMBLED_0);
5049+
break;
5050+
case DP_PHY_TEST_PATTERN_PRBS7:
5051+
DRM_DEBUG_KMS("Set PRBS7 Phy Test Pattern\n");
5052+
intel_de_write(dev_priv, DDI_DP_COMP_CTL(pipe),
5053+
DDI_DP_COMP_CTL_ENABLE | DDI_DP_COMP_CTL_PRBS7);
5054+
break;
5055+
case DP_PHY_TEST_PATTERN_80BIT_CUSTOM:
5056+
/*
5057+
* FIXME: Ideally pattern should come from DPCD 0x250. As
5058+
* current firmware of DPR-100 could not set it, so hardcoding
5059+
* now for complaince test.
5060+
*/
5061+
DRM_DEBUG_KMS("Set 80Bit Custom Phy Test Pattern 0x3e0f83e0 0x0f83e0f8 0x0000f83e\n");
5062+
pattern_val = 0x3e0f83e0;
5063+
intel_de_write(dev_priv, DDI_DP_COMP_PAT(pipe, 0), pattern_val);
5064+
pattern_val = 0x0f83e0f8;
5065+
intel_de_write(dev_priv, DDI_DP_COMP_PAT(pipe, 1), pattern_val);
5066+
pattern_val = 0x0000f83e;
5067+
intel_de_write(dev_priv, DDI_DP_COMP_PAT(pipe, 2), pattern_val);
5068+
intel_de_write(dev_priv, DDI_DP_COMP_CTL(pipe),
5069+
DDI_DP_COMP_CTL_ENABLE |
5070+
DDI_DP_COMP_CTL_CUSTOM80);
5071+
break;
5072+
case DP_PHY_TEST_PATTERN_CP2520:
5073+
/*
5074+
* FIXME: Ideally pattern should come from DPCD 0x24A. As
5075+
* current firmware of DPR-100 could not set it, so hardcoding
5076+
* now for complaince test.
5077+
*/
5078+
DRM_DEBUG_KMS("Set HBR2 compliance Phy Test Pattern\n");
5079+
pattern_val = 0xFB;
5080+
intel_de_write(dev_priv, DDI_DP_COMP_CTL(pipe),
5081+
DDI_DP_COMP_CTL_ENABLE | DDI_DP_COMP_CTL_HBR2 |
5082+
pattern_val);
5083+
break;
5084+
default:
5085+
WARN(1, "Invalid Phy Test Pattern\n");
5086+
}
5087+
}
5088+
5089+
static void
5090+
intel_dp_autotest_phy_ddi_disable(struct intel_dp *intel_dp)
5091+
{
5092+
struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
5093+
struct drm_device *dev = intel_dig_port->base.base.dev;
5094+
struct drm_i915_private *dev_priv = to_i915(dev);
5095+
struct intel_crtc *crtc = to_intel_crtc(intel_dig_port->base.base.crtc);
5096+
enum pipe pipe = crtc->pipe;
5097+
u32 trans_ddi_func_ctl_value, trans_conf_value, dp_tp_ctl_value;
5098+
5099+
trans_ddi_func_ctl_value = intel_de_read(dev_priv,
5100+
TRANS_DDI_FUNC_CTL(pipe));
5101+
trans_conf_value = intel_de_read(dev_priv, PIPECONF(pipe));
5102+
dp_tp_ctl_value = intel_de_read(dev_priv, TGL_DP_TP_CTL(pipe));
5103+
5104+
trans_ddi_func_ctl_value &= ~(TRANS_DDI_FUNC_ENABLE |
5105+
TGL_TRANS_DDI_PORT_MASK);
5106+
trans_conf_value &= ~PIPECONF_ENABLE;
5107+
dp_tp_ctl_value &= ~DP_TP_CTL_ENABLE;
5108+
5109+
intel_de_write(dev_priv, PIPECONF(pipe), trans_conf_value);
5110+
intel_de_write(dev_priv, TRANS_DDI_FUNC_CTL(pipe),
5111+
trans_ddi_func_ctl_value);
5112+
intel_de_write(dev_priv, TGL_DP_TP_CTL(pipe), dp_tp_ctl_value);
5113+
}
5114+
5115+
static void
5116+
intel_dp_autotest_phy_ddi_enable(struct intel_dp *intel_dp, uint8_t lane_cnt)
5117+
{
5118+
struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
5119+
struct drm_device *dev = intel_dig_port->base.base.dev;
5120+
struct drm_i915_private *dev_priv = to_i915(dev);
5121+
enum port port = intel_dig_port->base.port;
5122+
struct intel_crtc *crtc = to_intel_crtc(intel_dig_port->base.base.crtc);
5123+
enum pipe pipe = crtc->pipe;
5124+
u32 trans_ddi_func_ctl_value, trans_conf_value, dp_tp_ctl_value;
5125+
5126+
trans_ddi_func_ctl_value = intel_de_read(dev_priv,
5127+
TRANS_DDI_FUNC_CTL(pipe));
5128+
trans_conf_value = intel_de_read(dev_priv, PIPECONF(pipe));
5129+
dp_tp_ctl_value = intel_de_read(dev_priv, TGL_DP_TP_CTL(pipe));
5130+
5131+
trans_ddi_func_ctl_value |= TRANS_DDI_FUNC_ENABLE |
5132+
TGL_TRANS_DDI_SELECT_PORT(port);
5133+
trans_conf_value |= PIPECONF_ENABLE;
5134+
dp_tp_ctl_value |= DP_TP_CTL_ENABLE;
5135+
5136+
intel_de_write(dev_priv, PIPECONF(pipe), trans_conf_value);
5137+
intel_de_write(dev_priv, TGL_DP_TP_CTL(pipe), dp_tp_ctl_value);
5138+
intel_de_write(dev_priv, TRANS_DDI_FUNC_CTL(pipe),
5139+
trans_ddi_func_ctl_value);
5140+
}
5141+
5142+
void intel_dp_process_phy_request(struct intel_dp *intel_dp)
5143+
{
5144+
struct drm_dp_phy_test_params *data =
5145+
&intel_dp->compliance.test_data.phytest;
5146+
u8 link_status[DP_LINK_STATUS_SIZE];
5147+
5148+
if (!intel_dp_get_link_status(intel_dp, link_status)) {
5149+
DRM_DEBUG_KMS("failed to get link status\n");
5150+
return;
5151+
}
5152+
5153+
/* retrieve vswing & pre-emphasis setting */
5154+
intel_dp_get_adjust_train(intel_dp, link_status);
5155+
5156+
intel_dp_autotest_phy_ddi_disable(intel_dp);
5157+
5158+
intel_dp_set_signal_levels(intel_dp);
5159+
5160+
intel_dp_phy_pattern_update(intel_dp);
5161+
5162+
intel_dp_autotest_phy_ddi_enable(intel_dp, data->num_lanes);
5163+
5164+
drm_dp_set_phy_test_pattern(&intel_dp->aux, data,
5165+
link_status[DP_DPCD_REV]);
5166+
}
5167+
50045168
static u8 intel_dp_autotest_phy_pattern(struct intel_dp *intel_dp)
50055169
{
50065170
u8 test_result = DP_TEST_NAK;
5171+
5172+
test_result = intel_dp_prepare_phytest(intel_dp);
5173+
if (test_result != DP_TEST_ACK)
5174+
DRM_ERROR("Phy test preparation failed\n");
5175+
5176+
intel_dp_process_phy_request(intel_dp);
5177+
50075178
return test_result;
50085179
}
50095180

‎drivers/gpu/drm/i915/display/intel_dp.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ void intel_dp_hdr_metadata_enable(struct intel_dp *intel_dp,
115115
const struct intel_crtc_state *crtc_state,
116116
const struct drm_connector_state *conn_state);
117117
bool intel_digital_port_connected(struct intel_encoder *encoder);
118+
void intel_dp_process_phy_request(struct intel_dp *intel_dp);
118119

119120
static inline unsigned int intel_dp_unused_lane_mask(int lane_count)
120121
{

‎drivers/gpu/drm/i915/display/intel_dp_link_training.c‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,8 @@ intel_dp_dump_link_status(const u8 link_status[DP_LINK_STATUS_SIZE])
3434
link_status[3], link_status[4], link_status[5]);
3535
}
3636

37-
static void
38-
intel_get_adjust_train(struct intel_dp *intel_dp,
39-
const u8 link_status[DP_LINK_STATUS_SIZE])
37+
void intel_dp_get_adjust_train(struct intel_dp *intel_dp,
38+
const u8 link_status[DP_LINK_STATUS_SIZE])
4039
{
4140
u8 v = 0;
4241
u8 p = 0;
@@ -219,7 +218,7 @@ intel_dp_link_training_clock_recovery(struct intel_dp *intel_dp)
219218
voltage = intel_dp->train_set[0] & DP_TRAIN_VOLTAGE_SWING_MASK;
220219

221220
/* Update training set as requested by target */
222-
intel_get_adjust_train(intel_dp, link_status);
221+
intel_dp_get_adjust_train(intel_dp, link_status);
223222
if (!intel_dp_update_link_train(intel_dp)) {
224223
drm_err(&i915->drm,
225224
"failed to update link training\n");
@@ -338,7 +337,7 @@ intel_dp_link_training_channel_equalization(struct intel_dp *intel_dp)
338337
}
339338

340339
/* Update training set as requested by target */
341-
intel_get_adjust_train(intel_dp, link_status);
340+
intel_dp_get_adjust_train(intel_dp, link_status);
342341
if (!intel_dp_update_link_train(intel_dp)) {
343342
drm_err(&i915->drm,
344343
"failed to update link training\n");

‎drivers/gpu/drm/i915/display/intel_dp_link_training.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@
66
#ifndef __INTEL_DP_LINK_TRAINING_H__
77
#define __INTEL_DP_LINK_TRAINING_H__
88

9+
#include <drm/drm_dp_helper.h>
10+
911
struct intel_dp;
1012

13+
void intel_dp_get_adjust_train(struct intel_dp *intel_dp,
14+
const u8 link_status[DP_LINK_STATUS_SIZE]);
1115
void intel_dp_start_link_train(struct intel_dp *intel_dp);
1216
void intel_dp_stop_link_train(struct intel_dp *intel_dp);
1317

‎drivers/gpu/drm/i915/i915_reg.h‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9794,6 +9794,24 @@ enum skl_power_gate {
97949794
#define DDI_BUF_BALANCE_LEG_ENABLE (1 << 31)
97959795
#define DDI_BUF_TRANS_HI(port, i) _MMIO(_PORT(port, _DDI_BUF_TRANS_A, _DDI_BUF_TRANS_B) + (i) * 8 + 4)
97969796

9797+
/* DDI DP Compliance Control */
9798+
#define _DDI_DP_COMP_CTL_A 0x605F0
9799+
#define _DDI_DP_COMP_CTL_B 0x615F0
9800+
#define DDI_DP_COMP_CTL(pipe) _MMIO_PIPE(pipe, _DDI_DP_COMP_CTL_A, _DDI_DP_COMP_CTL_B)
9801+
#define DDI_DP_COMP_CTL_ENABLE (1 << 31)
9802+
#define DDI_DP_COMP_CTL_D10_2 (0 << 28)
9803+
#define DDI_DP_COMP_CTL_SCRAMBLED_0 (1 << 28)
9804+
#define DDI_DP_COMP_CTL_PRBS7 (2 << 28)
9805+
#define DDI_DP_COMP_CTL_CUSTOM80 (3 << 28)
9806+
#define DDI_DP_COMP_CTL_HBR2 (4 << 28)
9807+
#define DDI_DP_COMP_CTL_SCRAMBLED_1 (5 << 28)
9808+
#define DDI_DP_COMP_CTL_HBR2_RESET (0xFC << 0)
9809+
9810+
/* DDI DP Compliance Pattern */
9811+
#define _DDI_DP_COMP_PAT_A 0x605F4
9812+
#define _DDI_DP_COMP_PAT_B 0x615F4
9813+
#define DDI_DP_COMP_PAT(pipe, i) _MMIO(_PIPE(pipe, _DDI_DP_COMP_PAT_A, _DDI_DP_COMP_PAT_B) + (i) * 4)
9814+
97979815
/* Sideband Interface (SBI) is programmed indirectly, via
97989816
* SBI_ADDR, which contains the register offset; and SBI_DATA,
97999817
* which contains the payload */

0 commit comments

Comments
 (0)