Skip to content

Commit 2281475

Browse files
committed
drm/ast: astdp: Perform link training during atomic_enable
The place for link training is in the encoder's atomic_enable helper. Remove all related tests from other helper ASTDP functions; especially ast_astdp_is_connected(), which tests HPD status. DP link training is controlled by the firmware. A status flag reports success or failure. The process can be fragile on Aspeed hardware. Moving the test from connector detection to the atomic_enable allows for several retries and a longer timeout. Signed-off-by: Thomas Zimmermann <[email protected]> Reviewed-by: Jocelyn Falempe <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent cbacb1b commit 2281475

File tree

4 files changed

+26
-25
lines changed

4 files changed

+26
-25
lines changed

drivers/gpu/drm/ast/ast_dp.c

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ bool ast_astdp_is_connected(struct ast_device *ast)
1111
{
1212
if (!ast_get_index_reg_mask(ast, AST_IO_VGACRI, 0xDF, AST_IO_VGACRDF_HPD))
1313
return false;
14-
if (!ast_get_index_reg_mask(ast, AST_IO_VGACRI, 0xDC, ASTDP_LINK_SUCCESS))
15-
return false;
1614
return true;
1715
}
1816

@@ -22,14 +20,10 @@ int ast_astdp_read_edid(struct drm_device *dev, u8 *ediddata)
2220
u8 i = 0, j = 0;
2321

2422
/*
25-
* CRDC[b0]: DP link success
2623
* CRE5[b0]: Host reading EDID process is done
2724
*/
28-
if (!(ast_get_index_reg_mask(ast, AST_IO_VGACRI, 0xDC, ASTDP_LINK_SUCCESS) &&
29-
ast_get_index_reg_mask(ast, AST_IO_VGACRI, 0xE5,
30-
ASTDP_HOST_EDID_READ_DONE_MASK))) {
25+
if (!(ast_get_index_reg_mask(ast, AST_IO_VGACRI, 0xE5, ASTDP_HOST_EDID_READ_DONE_MASK)))
3126
goto err_astdp_edid_not_ready;
32-
}
3327

3428
ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xE5, (u8) ~ASTDP_HOST_EDID_READ_DONE_MASK,
3529
0x00);
@@ -58,11 +52,6 @@ int ast_astdp_read_edid(struct drm_device *dev, u8 *ediddata)
5852
*/
5953
mdelay(j+1);
6054

61-
if (!(ast_get_index_reg_mask(ast, AST_IO_VGACRI, 0xDC,
62-
ASTDP_LINK_SUCCESS))) {
63-
goto err_astdp_jump_out_loop_of_edid;
64-
}
65-
6655
j++;
6756
if (j > 200)
6857
goto err_astdp_jump_out_loop_of_edid;
@@ -106,8 +95,6 @@ int ast_astdp_read_edid(struct drm_device *dev, u8 *ediddata)
10695
return (~(j+256) + 1);
10796

10897
err_astdp_edid_not_ready:
109-
if (!(ast_get_index_reg_mask(ast, AST_IO_VGACRI, 0xDC, ASTDP_LINK_SUCCESS)))
110-
return (~0xDC + 1);
11198
if (!(ast_get_index_reg_mask(ast, AST_IO_VGACRI, 0xE5, ASTDP_HOST_EDID_READ_DONE_MASK)))
11299
return (~0xE5 + 1);
113100

@@ -158,7 +145,22 @@ void ast_dp_power_on_off(struct drm_device *dev, bool on)
158145
ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xE3, (u8) ~AST_DP_PHY_SLEEP, bE3);
159146
}
160147

148+
void ast_dp_link_training(struct ast_device *ast)
149+
{
150+
struct drm_device *dev = &ast->base;
151+
unsigned int i = 10;
152+
153+
while (i--) {
154+
u8 vgacrdc = ast_get_index_reg(ast, AST_IO_VGACRI, 0xdc);
161155

156+
if (vgacrdc & AST_IO_VGACRDC_LINK_SUCCESS)
157+
break;
158+
if (i)
159+
msleep(100);
160+
}
161+
if (!i)
162+
drm_err(dev, "Link training failed\n");
163+
}
162164

163165
void ast_dp_set_on_off(struct drm_device *dev, bool on)
164166
{
@@ -169,16 +171,13 @@ void ast_dp_set_on_off(struct drm_device *dev, bool on)
169171
// Video On/Off
170172
ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xE3, (u8) ~AST_DP_VIDEO_ENABLE, on);
171173

172-
// If DP plug in and link successful then check video on / off status
173-
if (ast_get_index_reg_mask(ast, AST_IO_VGACRI, 0xDC, ASTDP_LINK_SUCCESS)) {
174-
video_on_off <<= 4;
175-
while (ast_get_index_reg_mask(ast, AST_IO_VGACRI, 0xDF,
174+
video_on_off <<= 4;
175+
while (ast_get_index_reg_mask(ast, AST_IO_VGACRI, 0xDF,
176176
ASTDP_MIRROR_VIDEO_ENABLE) != video_on_off) {
177-
// wait 1 ms
178-
mdelay(1);
179-
if (++i > 200)
180-
break;
181-
}
177+
// wait 1 ms
178+
mdelay(1);
179+
if (++i > 200)
180+
break;
182181
}
183182
}
184183

drivers/gpu/drm/ast/ast_drv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,7 @@ bool ast_astdp_is_connected(struct ast_device *ast);
473473
int ast_astdp_read_edid(struct drm_device *dev, u8 *ediddata);
474474
int ast_dp_launch(struct ast_device *ast);
475475
void ast_dp_power_on_off(struct drm_device *dev, bool no);
476+
void ast_dp_link_training(struct ast_device *ast);
476477
void ast_dp_set_on_off(struct drm_device *dev, bool no);
477478
void ast_dp_set_mode(struct drm_crtc *crtc, struct ast_vbios_mode_info *vbios_mode);
478479

drivers/gpu/drm/ast/ast_mode.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1621,6 +1621,8 @@ static void ast_astdp_encoder_helper_atomic_enable(struct drm_encoder *encoder,
16211621
struct ast_device *ast = to_ast_device(dev);
16221622

16231623
ast_dp_power_on_off(dev, AST_DP_POWER_ON);
1624+
ast_dp_link_training(ast);
1625+
16241626
ast_wait_for_vretrace(ast);
16251627
ast_dp_set_on_off(dev, 1);
16261628
}

drivers/gpu/drm/ast/ast_reg.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#define AST_IO_VGACRCB_HWC_ENABLED BIT(1)
3939

4040
#define AST_IO_VGACRD1_MCU_FW_EXECUTING BIT(5)
41+
#define AST_IO_VGACRDC_LINK_SUCCESS BIT(0)
4142
#define AST_IO_VGACRDF_HPD BIT(0)
4243

4344
#define AST_IO_VGAIR1_R (0x5A)
@@ -70,10 +71,8 @@
7071
#define AST_DP_VIDEO_ENABLE BIT(0)
7172

7273
/*
73-
* CRDC[b0]: DP link success
7474
* CRE5[b0]: Host reading EDID process is done
7575
*/
76-
#define ASTDP_LINK_SUCCESS BIT(0)
7776
#define ASTDP_HOST_EDID_READ_DONE BIT(0)
7877
#define ASTDP_HOST_EDID_READ_DONE_MASK GENMASK(0, 0)
7978

0 commit comments

Comments
 (0)