drm/tegra: sor: Use DP link training helpers
Make use of the DP link training helpers to implement full and fast link training. While at it, refactor some of the code and remove various code sequences that are not necessary. Signed-off-by: Thierry Reding <treding@nvidia.com>
This commit is contained in:
@@ -821,72 +821,3 @@ int drm_dp_aux_disable(struct drm_dp_aux *aux)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int drm_dp_aux_prepare(struct drm_dp_aux *aux, u8 encoding)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = drm_dp_dpcd_writeb(aux, DP_MAIN_LINK_CHANNEL_CODING_SET,
|
||||
encoding);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int drm_dp_aux_train(struct drm_dp_aux *aux, struct drm_dp_link *link,
|
||||
u8 pattern)
|
||||
{
|
||||
u8 tp = pattern & DP_TRAINING_PATTERN_MASK;
|
||||
u8 status[DP_LINK_STATUS_SIZE], values[4];
|
||||
unsigned int i;
|
||||
int err;
|
||||
|
||||
err = drm_dp_dpcd_writeb(aux, DP_TRAINING_PATTERN_SET, pattern);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
if (tp == DP_TRAINING_PATTERN_DISABLE)
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < link->lanes; i++)
|
||||
values[i] = DP_TRAIN_MAX_PRE_EMPHASIS_REACHED |
|
||||
DP_TRAIN_PRE_EMPH_LEVEL_0 |
|
||||
DP_TRAIN_MAX_SWING_REACHED |
|
||||
DP_TRAIN_VOLTAGE_SWING_LEVEL_0;
|
||||
|
||||
err = drm_dp_dpcd_write(aux, DP_TRAINING_LANE0_SET, values,
|
||||
link->lanes);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
usleep_range(500, 1000);
|
||||
|
||||
err = drm_dp_dpcd_read_link_status(aux, status);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
switch (tp) {
|
||||
case DP_TRAINING_PATTERN_1:
|
||||
if (!drm_dp_clock_recovery_ok(status, link->lanes))
|
||||
return -EAGAIN;
|
||||
|
||||
break;
|
||||
|
||||
case DP_TRAINING_PATTERN_2:
|
||||
if (!drm_dp_channel_eq_ok(status, link->lanes))
|
||||
return -EAGAIN;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
dev_err(aux->dev, "unsupported training pattern %u\n", tp);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
err = drm_dp_dpcd_writeb(aux, DP_EDP_CONFIGURATION_SET, 0);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Fai riferimento in un nuovo problema
Block a user