Skip to content

Commit c91d75a

Browse files
committed
drm/ast: astdp: Test firmware status once during probing
Test for running ASTDP firmware during probe. Do not bother testing this later. We cannot do much anyway if the firmware fails. Do not initialize the ASTDP conenctor if the test fails during device probing. Signed-off-by: Thomas Zimmermann <[email protected]> Reported-by: Shixiong Ou <[email protected]> Tested-by: Shixiong Ou <[email protected]> Reviewed-by: Jocelyn Falempe <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent e2fc288 commit c91d75a

File tree

5 files changed

+23
-32
lines changed

5 files changed

+23
-32
lines changed

drivers/gpu/drm/ast/ast_dp.c

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
bool ast_astdp_is_connected(struct ast_device *ast)
1111
{
12-
if (!ast_get_index_reg_mask(ast, AST_IO_VGACRI, 0xD1, ASTDP_MCU_FW_EXECUTING))
13-
return false;
1412
if (!ast_get_index_reg_mask(ast, AST_IO_VGACRI, 0xDF, ASTDP_HPD))
1513
return false;
1614
if (!ast_get_index_reg_mask(ast, AST_IO_VGACRI, 0xDC, ASTDP_LINK_SUCCESS))
@@ -24,13 +22,11 @@ int ast_astdp_read_edid(struct drm_device *dev, u8 *ediddata)
2422
u8 i = 0, j = 0;
2523

2624
/*
27-
* CRD1[b5]: DP MCU FW is executing
2825
* CRDC[b0]: DP link success
2926
* CRDF[b0]: DP HPD
3027
* CRE5[b0]: Host reading EDID process is done
3128
*/
32-
if (!(ast_get_index_reg_mask(ast, AST_IO_VGACRI, 0xD1, ASTDP_MCU_FW_EXECUTING) &&
33-
ast_get_index_reg_mask(ast, AST_IO_VGACRI, 0xDC, ASTDP_LINK_SUCCESS) &&
29+
if (!(ast_get_index_reg_mask(ast, AST_IO_VGACRI, 0xDC, ASTDP_LINK_SUCCESS) &&
3430
ast_get_index_reg_mask(ast, AST_IO_VGACRI, 0xDF, ASTDP_HPD) &&
3531
ast_get_index_reg_mask(ast, AST_IO_VGACRI, 0xE5,
3632
ASTDP_HOST_EDID_READ_DONE_MASK))) {
@@ -64,9 +60,7 @@ int ast_astdp_read_edid(struct drm_device *dev, u8 *ediddata)
6460
*/
6561
mdelay(j+1);
6662

67-
if (!(ast_get_index_reg_mask(ast, AST_IO_VGACRI, 0xD1,
68-
ASTDP_MCU_FW_EXECUTING) &&
69-
ast_get_index_reg_mask(ast, AST_IO_VGACRI, 0xDC,
63+
if (!(ast_get_index_reg_mask(ast, AST_IO_VGACRI, 0xDC,
7064
ASTDP_LINK_SUCCESS) &&
7165
ast_get_index_reg_mask(ast, AST_IO_VGACRI, 0xDF, ASTDP_HPD))) {
7266
goto err_astdp_jump_out_loop_of_edid;
@@ -115,8 +109,6 @@ int ast_astdp_read_edid(struct drm_device *dev, u8 *ediddata)
115109
return (~(j+256) + 1);
116110

117111
err_astdp_edid_not_ready:
118-
if (!(ast_get_index_reg_mask(ast, AST_IO_VGACRI, 0xD1, ASTDP_MCU_FW_EXECUTING)))
119-
return (~0xD1 + 1);
120112
if (!(ast_get_index_reg_mask(ast, AST_IO_VGACRI, 0xDC, ASTDP_LINK_SUCCESS)))
121113
return (~0xDC + 1);
122114
if (!(ast_get_index_reg_mask(ast, AST_IO_VGACRI, 0xDF, ASTDP_HPD)))
@@ -130,32 +122,29 @@ int ast_astdp_read_edid(struct drm_device *dev, u8 *ediddata)
130122
/*
131123
* Launch Aspeed DP
132124
*/
133-
void ast_dp_launch(struct drm_device *dev)
125+
int ast_dp_launch(struct ast_device *ast)
134126
{
135-
u32 i = 0;
136-
u8 bDPExecute = 1;
137-
struct ast_device *ast = to_ast_device(dev);
127+
struct drm_device *dev = &ast->base;
128+
unsigned int i = 10;
138129

139-
// Wait one second then timeout.
140-
while (ast_get_index_reg_mask(ast, AST_IO_VGACRI, 0xD1, ASTDP_MCU_FW_EXECUTING) !=
141-
ASTDP_MCU_FW_EXECUTING) {
142-
i++;
143-
// wait 100 ms
144-
msleep(100);
130+
while (i) {
131+
u8 vgacrd1 = ast_get_index_reg(ast, AST_IO_VGACRI, 0xd1);
145132

146-
if (i >= 10) {
147-
// DP would not be ready.
148-
bDPExecute = 0;
133+
if (vgacrd1 & AST_IO_VGACRD1_MCU_FW_EXECUTING)
149134
break;
150-
}
135+
--i;
136+
msleep(100);
151137
}
152-
153-
if (!bDPExecute)
138+
if (!i) {
154139
drm_err(dev, "Wait DPMCU executing timeout\n");
140+
return -ENODEV;
141+
}
155142

156143
ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xE5,
157144
(u8) ~ASTDP_HOST_EDID_READ_DONE_MASK,
158145
ASTDP_HOST_EDID_READ_DONE);
146+
147+
return 0;
159148
}
160149

161150

drivers/gpu/drm/ast/ast_drv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ void ast_init_3rdtx(struct drm_device *dev);
471471
/* aspeed DP */
472472
bool ast_astdp_is_connected(struct ast_device *ast);
473473
int ast_astdp_read_edid(struct drm_device *dev, u8 *ediddata);
474-
void ast_dp_launch(struct drm_device *dev);
474+
int ast_dp_launch(struct ast_device *ast);
475475
void ast_dp_power_on_off(struct drm_device *dev, bool no);
476476
void ast_dp_set_on_off(struct drm_device *dev, bool no);
477477
void ast_dp_set_mode(struct drm_crtc *crtc, struct ast_vbios_mode_info *vbios_mode);

drivers/gpu/drm/ast/ast_main.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,10 @@ static void ast_detect_tx_chip(struct ast_device *ast, bool need_post)
115115
} else if (IS_AST_GEN7(ast)) {
116116
if (ast_get_index_reg_mask(ast, AST_IO_VGACRI, 0xD1, TX_TYPE_MASK) ==
117117
ASTDP_DPMCU_TX) {
118-
ast->tx_chip_types = AST_TX_ASTDP_BIT;
119-
ast_dp_launch(&ast->base);
118+
int ret = ast_dp_launch(ast);
119+
120+
if (!ret)
121+
ast->tx_chip_types = AST_TX_ASTDP_BIT;
120122
}
121123
}
122124

drivers/gpu/drm/ast/ast_post.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ void ast_post_gpu(struct drm_device *dev)
351351

352352
if (IS_AST_GEN7(ast)) {
353353
if (ast->tx_chip_types & AST_TX_ASTDP_BIT)
354-
ast_dp_launch(dev);
354+
ast_dp_launch(ast);
355355
} else if (ast->config_mode == ast_use_p2a) {
356356
if (IS_AST_GEN6(ast))
357357
ast_post_chip_2500(dev);

drivers/gpu/drm/ast/ast_reg.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
#define AST_IO_VGACRCB_HWC_16BPP BIT(0) /* set: ARGB4444, cleared: 2bpp palette */
3838
#define AST_IO_VGACRCB_HWC_ENABLED BIT(1)
3939

40+
#define AST_IO_VGACRD1_MCU_FW_EXECUTING BIT(5)
41+
4042
#define AST_IO_VGAIR1_R (0x5A)
4143
#define AST_IO_VGAIR1_VREFRESH BIT(3)
4244

@@ -67,12 +69,10 @@
6769
#define AST_DP_VIDEO_ENABLE BIT(0)
6870

6971
/*
70-
* CRD1[b5]: DP MCU FW is executing
7172
* CRDC[b0]: DP link success
7273
* CRDF[b0]: DP HPD
7374
* CRE5[b0]: Host reading EDID process is done
7475
*/
75-
#define ASTDP_MCU_FW_EXECUTING BIT(5)
7676
#define ASTDP_LINK_SUCCESS BIT(0)
7777
#define ASTDP_HPD BIT(0)
7878
#define ASTDP_HOST_EDID_READ_DONE BIT(0)

0 commit comments

Comments
 (0)