Skip to content

Commit cef622d

Browse files
Merge tag 'topic/phy-compliance-2020-04-08' of git://anongit.freedesktop.org/drm/drm-misc into drm-intel-next-queued
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. From: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/efb3d0d9-2cf7-046b-3a9b-2548d086258e@linux.intel.com Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
2 parents 2b703bb + 8cdf727 commit cef622d

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
@@ -1535,3 +1535,97 @@ int drm_dp_dsc_sink_supported_input_bpcs(const u8 dsc_dpcd[DP_DSC_RECEIVER_CAP_S
15351535
return num_bpc;
15361536
}
15371537
EXPORT_SYMBOL(drm_dp_dsc_sink_supported_input_bpcs);
1538+
1539+
/**
1540+
* drm_dp_get_phy_test_pattern() - get the requested pattern from the sink.
1541+
* @aux: DisplayPort AUX channel
1542+
* @data: DP phy compliance test parameters.
1543+
*
1544+
* Returns 0 on success or a negative error code on failure.
1545+
*/
1546+
int drm_dp_get_phy_test_pattern(struct drm_dp_aux *aux,
1547+
struct drm_dp_phy_test_params *data)
1548+
{
1549+
int err;
1550+
u8 rate, lanes;
1551+
1552+
err = drm_dp_dpcd_readb(aux, DP_TEST_LINK_RATE, &rate);
1553+
if (err < 0)
1554+
return err;
1555+
data->link_rate = drm_dp_bw_code_to_link_rate(rate);
1556+
1557+
err = drm_dp_dpcd_readb(aux, DP_TEST_LANE_COUNT, &lanes);
1558+
if (err < 0)
1559+
return err;
1560+
data->num_lanes = lanes & DP_MAX_LANE_COUNT_MASK;
1561+
1562+
if (lanes & DP_ENHANCED_FRAME_CAP)
1563+
data->enhanced_frame_cap = true;
1564+
1565+
err = drm_dp_dpcd_readb(aux, DP_PHY_TEST_PATTERN, &data->phy_pattern);
1566+
if (err < 0)
1567+
return err;
1568+
1569+
switch (data->phy_pattern) {
1570+
case DP_PHY_TEST_PATTERN_80BIT_CUSTOM:
1571+
err = drm_dp_dpcd_read(aux, DP_TEST_80BIT_CUSTOM_PATTERN_7_0,
1572+
&data->custom80, sizeof(data->custom80));
1573+
if (err < 0)
1574+
return err;
1575+
1576+
break;
1577+
case DP_PHY_TEST_PATTERN_CP2520:
1578+
err = drm_dp_dpcd_read(aux, DP_TEST_HBR2_SCRAMBLER_RESET,
1579+
&data->hbr2_reset,
1580+
sizeof(data->hbr2_reset));
1581+
if (err < 0)
1582+
return err;
1583+
}
1584+
1585+
return 0;
1586+
}
1587+
EXPORT_SYMBOL(drm_dp_get_phy_test_pattern);
1588+
1589+
/**
1590+
* drm_dp_set_phy_test_pattern() - set the pattern to the sink.
1591+
* @aux: DisplayPort AUX channel
1592+
* @data: DP phy compliance test parameters.
1593+
*
1594+
* Returns 0 on success or a negative error code on failure.
1595+
*/
1596+
int drm_dp_set_phy_test_pattern(struct drm_dp_aux *aux,
1597+
struct drm_dp_phy_test_params *data, u8 dp_rev)
1598+
{
1599+
int err, i;
1600+
u8 link_config[2];
1601+
u8 test_pattern;
1602+
1603+
link_config[0] = drm_dp_link_rate_to_bw_code(data->link_rate);
1604+
link_config[1] = data->num_lanes;
1605+
if (data->enhanced_frame_cap)
1606+
link_config[1] |= DP_LANE_COUNT_ENHANCED_FRAME_EN;
1607+
err = drm_dp_dpcd_write(aux, DP_LINK_BW_SET, link_config, 2);
1608+
if (err < 0)
1609+
return err;
1610+
1611+
test_pattern = data->phy_pattern;
1612+
if (dp_rev < 0x12) {
1613+
test_pattern = (test_pattern << 2) &
1614+
DP_LINK_QUAL_PATTERN_11_MASK;
1615+
err = drm_dp_dpcd_writeb(aux, DP_TRAINING_PATTERN_SET,
1616+
test_pattern);
1617+
if (err < 0)
1618+
return err;
1619+
} else {
1620+
for (i = 0; i < data->num_lanes; i++) {
1621+
err = drm_dp_dpcd_writeb(aux,
1622+
DP_LINK_QUAL_LANE0_SET + i,
1623+
test_pattern);
1624+
if (err < 0)
1625+
return err;
1626+
}
1627+
}
1628+
1629+
return 0;
1630+
}
1631+
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
@@ -1326,6 +1326,16 @@ static int i915_displayport_test_data_show(struct seq_file *m, void *data)
13261326
intel_dp->compliance.test_data.vdisplay);
13271327
seq_printf(m, "bpc: %u\n",
13281328
intel_dp->compliance.test_data.bpc);
1329+
} else if (intel_dp->compliance.test_type ==
1330+
DP_TEST_LINK_PHY_TEST_PATTERN) {
1331+
seq_printf(m, "pattern: %d\n",
1332+
intel_dp->compliance.test_data.phytest.phy_pattern);
1333+
seq_printf(m, "Number of lanes: %d\n",
1334+
intel_dp->compliance.test_data.phytest.num_lanes);
1335+
seq_printf(m, "Link Rate: %d\n",
1336+
intel_dp->compliance.test_data.phytest.link_rate);
1337+
seq_printf(m, "level: %02x\n",
1338+
intel_dp->train_set[0]);
13291339
}
13301340
} else
13311341
seq_puts(m, "0");
@@ -1358,7 +1368,7 @@ static int i915_displayport_test_type_show(struct seq_file *m, void *data)
13581368

13591369
if (encoder && connector->status == connector_status_connected) {
13601370
intel_dp = enc_to_intel_dp(encoder);
1361-
seq_printf(m, "%02lx", intel_dp->compliance.test_type);
1371+
seq_printf(m, "%02lx\n", intel_dp->compliance.test_type);
13621372
} else
13631373
seq_puts(m, "0");
13641374
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,6 +1258,7 @@ struct intel_dp_compliance_data {
12581258
u8 video_pattern;
12591259
u16 hdisplay, vdisplay;
12601260
u8 bpc;
1261+
struct drm_dp_phy_test_params phytest;
12611262
};
12621263

12631264
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
@@ -5401,9 +5401,180 @@ static u8 intel_dp_autotest_edid(struct intel_dp *intel_dp)
54015401
return test_result;
54025402
}
54035403

5404+
static u8 intel_dp_prepare_phytest(struct intel_dp *intel_dp)
5405+
{
5406+
struct drm_dp_phy_test_params *data =
5407+
&intel_dp->compliance.test_data.phytest;
5408+
5409+
if (drm_dp_get_phy_test_pattern(&intel_dp->aux, data)) {
5410+
DRM_DEBUG_KMS("DP Phy Test pattern AUX read failure\n");
5411+
return DP_TEST_NAK;
5412+
}
5413+
5414+
/*
5415+
* link_mst is set to false to avoid executing mst related code
5416+
* during compliance testing.
5417+
*/
5418+
intel_dp->link_mst = false;
5419+
5420+
return DP_TEST_ACK;
5421+
}
5422+
5423+
static void intel_dp_phy_pattern_update(struct intel_dp *intel_dp)
5424+
{
5425+
struct drm_i915_private *dev_priv =
5426+
to_i915(dp_to_dig_port(intel_dp)->base.base.dev);
5427+
struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
5428+
struct drm_dp_phy_test_params *data =
5429+
&intel_dp->compliance.test_data.phytest;
5430+
struct intel_crtc *crtc = to_intel_crtc(intel_dig_port->base.base.crtc);
5431+
enum pipe pipe = crtc->pipe;
5432+
u32 pattern_val;
5433+
5434+
switch (data->phy_pattern) {
5435+
case DP_PHY_TEST_PATTERN_NONE:
5436+
DRM_DEBUG_KMS("Disable Phy Test Pattern\n");
5437+
intel_de_write(dev_priv, DDI_DP_COMP_CTL(pipe), 0x0);
5438+
break;
5439+
case DP_PHY_TEST_PATTERN_D10_2:
5440+
DRM_DEBUG_KMS("Set D10.2 Phy Test Pattern\n");
5441+
intel_de_write(dev_priv, DDI_DP_COMP_CTL(pipe),
5442+
DDI_DP_COMP_CTL_ENABLE | DDI_DP_COMP_CTL_D10_2);
5443+
break;
5444+
case DP_PHY_TEST_PATTERN_ERROR_COUNT:
5445+
DRM_DEBUG_KMS("Set Error Count Phy Test Pattern\n");
5446+
intel_de_write(dev_priv, DDI_DP_COMP_CTL(pipe),
5447+
DDI_DP_COMP_CTL_ENABLE |
5448+
DDI_DP_COMP_CTL_SCRAMBLED_0);
5449+
break;
5450+
case DP_PHY_TEST_PATTERN_PRBS7:
5451+
DRM_DEBUG_KMS("Set PRBS7 Phy Test Pattern\n");
5452+
intel_de_write(dev_priv, DDI_DP_COMP_CTL(pipe),
5453+
DDI_DP_COMP_CTL_ENABLE | DDI_DP_COMP_CTL_PRBS7);
5454+
break;
5455+
case DP_PHY_TEST_PATTERN_80BIT_CUSTOM:
5456+
/*
5457+
* FIXME: Ideally pattern should come from DPCD 0x250. As
5458+
* current firmware of DPR-100 could not set it, so hardcoding
5459+
* now for complaince test.
5460+
*/
5461+
DRM_DEBUG_KMS("Set 80Bit Custom Phy Test Pattern 0x3e0f83e0 0x0f83e0f8 0x0000f83e\n");
5462+
pattern_val = 0x3e0f83e0;
5463+
intel_de_write(dev_priv, DDI_DP_COMP_PAT(pipe, 0), pattern_val);
5464+
pattern_val = 0x0f83e0f8;
5465+
intel_de_write(dev_priv, DDI_DP_COMP_PAT(pipe, 1), pattern_val);
5466+
pattern_val = 0x0000f83e;
5467+
intel_de_write(dev_priv, DDI_DP_COMP_PAT(pipe, 2), pattern_val);
5468+
intel_de_write(dev_priv, DDI_DP_COMP_CTL(pipe),
5469+
DDI_DP_COMP_CTL_ENABLE |
5470+
DDI_DP_COMP_CTL_CUSTOM80);
5471+
break;
5472+
case DP_PHY_TEST_PATTERN_CP2520:
5473+
/*
5474+
* FIXME: Ideally pattern should come from DPCD 0x24A. As
5475+
* current firmware of DPR-100 could not set it, so hardcoding
5476+
* now for complaince test.
5477+
*/
5478+
DRM_DEBUG_KMS("Set HBR2 compliance Phy Test Pattern\n");
5479+
pattern_val = 0xFB;
5480+
intel_de_write(dev_priv, DDI_DP_COMP_CTL(pipe),
5481+
DDI_DP_COMP_CTL_ENABLE | DDI_DP_COMP_CTL_HBR2 |
5482+
pattern_val);
5483+
break;
5484+
default:
5485+
WARN(1, "Invalid Phy Test Pattern\n");
5486+
}
5487+
}
5488+
5489+
static void
5490+
intel_dp_autotest_phy_ddi_disable(struct intel_dp *intel_dp)
5491+
{
5492+
struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
5493+
struct drm_device *dev = intel_dig_port->base.base.dev;
5494+
struct drm_i915_private *dev_priv = to_i915(dev);
5495+
struct intel_crtc *crtc = to_intel_crtc(intel_dig_port->base.base.crtc);
5496+
enum pipe pipe = crtc->pipe;
5497+
u32 trans_ddi_func_ctl_value, trans_conf_value, dp_tp_ctl_value;
5498+
5499+
trans_ddi_func_ctl_value = intel_de_read(dev_priv,
5500+
TRANS_DDI_FUNC_CTL(pipe));
5501+
trans_conf_value = intel_de_read(dev_priv, PIPECONF(pipe));
5502+
dp_tp_ctl_value = intel_de_read(dev_priv, TGL_DP_TP_CTL(pipe));
5503+
5504+
trans_ddi_func_ctl_value &= ~(TRANS_DDI_FUNC_ENABLE |
5505+
TGL_TRANS_DDI_PORT_MASK);
5506+
trans_conf_value &= ~PIPECONF_ENABLE;
5507+
dp_tp_ctl_value &= ~DP_TP_CTL_ENABLE;
5508+
5509+
intel_de_write(dev_priv, PIPECONF(pipe), trans_conf_value);
5510+
intel_de_write(dev_priv, TRANS_DDI_FUNC_CTL(pipe),
5511+
trans_ddi_func_ctl_value);
5512+
intel_de_write(dev_priv, TGL_DP_TP_CTL(pipe), dp_tp_ctl_value);
5513+
}
5514+
5515+
static void
5516+
intel_dp_autotest_phy_ddi_enable(struct intel_dp *intel_dp, uint8_t lane_cnt)
5517+
{
5518+
struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
5519+
struct drm_device *dev = intel_dig_port->base.base.dev;
5520+
struct drm_i915_private *dev_priv = to_i915(dev);
5521+
enum port port = intel_dig_port->base.port;
5522+
struct intel_crtc *crtc = to_intel_crtc(intel_dig_port->base.base.crtc);
5523+
enum pipe pipe = crtc->pipe;
5524+
u32 trans_ddi_func_ctl_value, trans_conf_value, dp_tp_ctl_value;
5525+
5526+
trans_ddi_func_ctl_value = intel_de_read(dev_priv,
5527+
TRANS_DDI_FUNC_CTL(pipe));
5528+
trans_conf_value = intel_de_read(dev_priv, PIPECONF(pipe));
5529+
dp_tp_ctl_value = intel_de_read(dev_priv, TGL_DP_TP_CTL(pipe));
5530+
5531+
trans_ddi_func_ctl_value |= TRANS_DDI_FUNC_ENABLE |
5532+
TGL_TRANS_DDI_SELECT_PORT(port);
5533+
trans_conf_value |= PIPECONF_ENABLE;
5534+
dp_tp_ctl_value |= DP_TP_CTL_ENABLE;
5535+
5536+
intel_de_write(dev_priv, PIPECONF(pipe), trans_conf_value);
5537+
intel_de_write(dev_priv, TGL_DP_TP_CTL(pipe), dp_tp_ctl_value);
5538+
intel_de_write(dev_priv, TRANS_DDI_FUNC_CTL(pipe),
5539+
trans_ddi_func_ctl_value);
5540+
}
5541+
5542+
void intel_dp_process_phy_request(struct intel_dp *intel_dp)
5543+
{
5544+
struct drm_dp_phy_test_params *data =
5545+
&intel_dp->compliance.test_data.phytest;
5546+
u8 link_status[DP_LINK_STATUS_SIZE];
5547+
5548+
if (!intel_dp_get_link_status(intel_dp, link_status)) {
5549+
DRM_DEBUG_KMS("failed to get link status\n");
5550+
return;
5551+
}
5552+
5553+
/* retrieve vswing & pre-emphasis setting */
5554+
intel_dp_get_adjust_train(intel_dp, link_status);
5555+
5556+
intel_dp_autotest_phy_ddi_disable(intel_dp);
5557+
5558+
intel_dp_set_signal_levels(intel_dp);
5559+
5560+
intel_dp_phy_pattern_update(intel_dp);
5561+
5562+
intel_dp_autotest_phy_ddi_enable(intel_dp, data->num_lanes);
5563+
5564+
drm_dp_set_phy_test_pattern(&intel_dp->aux, data,
5565+
link_status[DP_DPCD_REV]);
5566+
}
5567+
54045568
static u8 intel_dp_autotest_phy_pattern(struct intel_dp *intel_dp)
54055569
{
54065570
u8 test_result = DP_TEST_NAK;
5571+
5572+
test_result = intel_dp_prepare_phytest(intel_dp);
5573+
if (test_result != DP_TEST_ACK)
5574+
DRM_ERROR("Phy test preparation failed\n");
5575+
5576+
intel_dp_process_phy_request(intel_dp);
5577+
54075578
return test_result;
54085579
}
54095580

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ void intel_dp_set_infoframes(struct intel_encoder *encoder, bool enable,
118118
const struct intel_crtc_state *crtc_state,
119119
const struct drm_connector_state *conn_state);
120120
bool intel_digital_port_connected(struct intel_encoder *encoder);
121+
void intel_dp_process_phy_request(struct intel_dp *intel_dp);
121122

122123
static inline unsigned int intel_dp_unused_lane_mask(int lane_count)
123124
{

‎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
@@ -9886,6 +9886,24 @@ enum skl_power_gate {
98869886
#define DDI_BUF_BALANCE_LEG_ENABLE (1 << 31)
98879887
#define DDI_BUF_TRANS_HI(port, i) _MMIO(_PORT(port, _DDI_BUF_TRANS_A, _DDI_BUF_TRANS_B) + (i) * 8 + 4)
98889888

9889+
/* DDI DP Compliance Control */
9890+
#define _DDI_DP_COMP_CTL_A 0x605F0
9891+
#define _DDI_DP_COMP_CTL_B 0x615F0
9892+
#define DDI_DP_COMP_CTL(pipe) _MMIO_PIPE(pipe, _DDI_DP_COMP_CTL_A, _DDI_DP_COMP_CTL_B)
9893+
#define DDI_DP_COMP_CTL_ENABLE (1 << 31)
9894+
#define DDI_DP_COMP_CTL_D10_2 (0 << 28)
9895+
#define DDI_DP_COMP_CTL_SCRAMBLED_0 (1 << 28)
9896+
#define DDI_DP_COMP_CTL_PRBS7 (2 << 28)
9897+
#define DDI_DP_COMP_CTL_CUSTOM80 (3 << 28)
9898+
#define DDI_DP_COMP_CTL_HBR2 (4 << 28)
9899+
#define DDI_DP_COMP_CTL_SCRAMBLED_1 (5 << 28)
9900+
#define DDI_DP_COMP_CTL_HBR2_RESET (0xFC << 0)
9901+
9902+
/* DDI DP Compliance Pattern */
9903+
#define _DDI_DP_COMP_PAT_A 0x605F4
9904+
#define _DDI_DP_COMP_PAT_B 0x615F4
9905+
#define DDI_DP_COMP_PAT(pipe, i) _MMIO(_PIPE(pipe, _DDI_DP_COMP_PAT_A, _DDI_DP_COMP_PAT_B) + (i) * 4)
9906+
98899907
/* Sideband Interface (SBI) is programmed indirectly, via
98909908
* SBI_ADDR, which contains the register offset; and SBI_DATA,
98919909
* which contains the payload */

0 commit comments

Comments
 (0)