Skip to content

Commit 3987a40

Browse files
ycchen0221gregkh
authored andcommitted
drm/ast: Fixed system hanged if disable P2A
[ Upstream commit 6c971c09f38704513c426ba6515f22fb3d6c87d5 ] The original ast driver will access some BMC configuration through P2A bridge that can be disabled since AST2300 and after. It will cause system hanged if P2A bridge is disabled. Here is the update to fix it. Signed-off-by: Y.C. Chen <yc_chen@aspeedtech.com> Signed-off-by: Dave Airlie <airlied@redhat.com> Signed-off-by: Sasha Levin <alexander.levin@verizon.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent ff20cc9 commit 3987a40

3 files changed

Lines changed: 97 additions & 79 deletions

File tree

drivers/gpu/drm/ast/ast_drv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ struct ast_private {
113113
struct ttm_bo_kmap_obj cache_kmap;
114114
int next_cursor;
115115
bool support_wide_screen;
116+
bool DisableP2A;
116117

117118
enum ast_tx_chip tx_chip_type;
118119
u8 dp501_maxclk;

drivers/gpu/drm/ast/ast_main.c

Lines changed: 83 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@ static int ast_detect_chip(struct drm_device *dev, bool *need_post)
124124
} else
125125
*need_post = false;
126126

127+
/* Check P2A Access */
128+
ast->DisableP2A = true;
129+
data = ast_read32(ast, 0xf004);
130+
if (data != 0xFFFFFFFF)
131+
ast->DisableP2A = false;
132+
127133
/* Check if we support wide screen */
128134
switch (ast->chip) {
129135
case AST1180:
@@ -140,15 +146,17 @@ static int ast_detect_chip(struct drm_device *dev, bool *need_post)
140146
ast->support_wide_screen = true;
141147
else {
142148
ast->support_wide_screen = false;
143-
/* Read SCU7c (silicon revision register) */
144-
ast_write32(ast, 0xf004, 0x1e6e0000);
145-
ast_write32(ast, 0xf000, 0x1);
146-
data = ast_read32(ast, 0x1207c);
147-
data &= 0x300;
148-
if (ast->chip == AST2300 && data == 0x0) /* ast1300 */
149-
ast->support_wide_screen = true;
150-
if (ast->chip == AST2400 && data == 0x100) /* ast1400 */
151-
ast->support_wide_screen = true;
149+
if (ast->DisableP2A == false) {
150+
/* Read SCU7c (silicon revision register) */
151+
ast_write32(ast, 0xf004, 0x1e6e0000);
152+
ast_write32(ast, 0xf000, 0x1);
153+
data = ast_read32(ast, 0x1207c);
154+
data &= 0x300;
155+
if (ast->chip == AST2300 && data == 0x0) /* ast1300 */
156+
ast->support_wide_screen = true;
157+
if (ast->chip == AST2400 && data == 0x100) /* ast1400 */
158+
ast->support_wide_screen = true;
159+
}
152160
}
153161
break;
154162
}
@@ -216,80 +224,81 @@ static int ast_get_dram_info(struct drm_device *dev)
216224
uint32_t data, data2;
217225
uint32_t denum, num, div, ref_pll;
218226

219-
ast_write32(ast, 0xf004, 0x1e6e0000);
220-
ast_write32(ast, 0xf000, 0x1);
221-
222-
223-
ast_write32(ast, 0x10000, 0xfc600309);
224-
225-
do {
226-
if (pci_channel_offline(dev->pdev))
227-
return -EIO;
228-
} while (ast_read32(ast, 0x10000) != 0x01);
229-
data = ast_read32(ast, 0x10004);
230-
231-
if (data & 0x40)
227+
if (ast->DisableP2A)
228+
{
232229
ast->dram_bus_width = 16;
230+
ast->dram_type = AST_DRAM_1Gx16;
231+
ast->mclk = 396;
232+
}
233233
else
234-
ast->dram_bus_width = 32;
234+
{
235+
ast_write32(ast, 0xf004, 0x1e6e0000);
236+
ast_write32(ast, 0xf000, 0x1);
237+
data = ast_read32(ast, 0x10004);
238+
239+
if (data & 0x40)
240+
ast->dram_bus_width = 16;
241+
else
242+
ast->dram_bus_width = 32;
243+
244+
if (ast->chip == AST2300 || ast->chip == AST2400) {
245+
switch (data & 0x03) {
246+
case 0:
247+
ast->dram_type = AST_DRAM_512Mx16;
248+
break;
249+
default:
250+
case 1:
251+
ast->dram_type = AST_DRAM_1Gx16;
252+
break;
253+
case 2:
254+
ast->dram_type = AST_DRAM_2Gx16;
255+
break;
256+
case 3:
257+
ast->dram_type = AST_DRAM_4Gx16;
258+
break;
259+
}
260+
} else {
261+
switch (data & 0x0c) {
262+
case 0:
263+
case 4:
264+
ast->dram_type = AST_DRAM_512Mx16;
265+
break;
266+
case 8:
267+
if (data & 0x40)
268+
ast->dram_type = AST_DRAM_1Gx16;
269+
else
270+
ast->dram_type = AST_DRAM_512Mx32;
271+
break;
272+
case 0xc:
273+
ast->dram_type = AST_DRAM_1Gx32;
274+
break;
275+
}
276+
}
235277

236-
if (ast->chip == AST2300 || ast->chip == AST2400) {
237-
switch (data & 0x03) {
238-
case 0:
239-
ast->dram_type = AST_DRAM_512Mx16;
240-
break;
241-
default:
242-
case 1:
243-
ast->dram_type = AST_DRAM_1Gx16;
244-
break;
245-
case 2:
246-
ast->dram_type = AST_DRAM_2Gx16;
247-
break;
278+
data = ast_read32(ast, 0x10120);
279+
data2 = ast_read32(ast, 0x10170);
280+
if (data2 & 0x2000)
281+
ref_pll = 14318;
282+
else
283+
ref_pll = 12000;
284+
285+
denum = data & 0x1f;
286+
num = (data & 0x3fe0) >> 5;
287+
data = (data & 0xc000) >> 14;
288+
switch (data) {
248289
case 3:
249-
ast->dram_type = AST_DRAM_4Gx16;
250-
break;
251-
}
252-
} else {
253-
switch (data & 0x0c) {
254-
case 0:
255-
case 4:
256-
ast->dram_type = AST_DRAM_512Mx16;
290+
div = 0x4;
257291
break;
258-
case 8:
259-
if (data & 0x40)
260-
ast->dram_type = AST_DRAM_1Gx16;
261-
else
262-
ast->dram_type = AST_DRAM_512Mx32;
292+
case 2:
293+
case 1:
294+
div = 0x2;
263295
break;
264-
case 0xc:
265-
ast->dram_type = AST_DRAM_1Gx32;
296+
default:
297+
div = 0x1;
266298
break;
267299
}
300+
ast->mclk = ref_pll * (num + 2) / (denum + 2) * (div * 1000);
268301
}
269-
270-
data = ast_read32(ast, 0x10120);
271-
data2 = ast_read32(ast, 0x10170);
272-
if (data2 & 0x2000)
273-
ref_pll = 14318;
274-
else
275-
ref_pll = 12000;
276-
277-
denum = data & 0x1f;
278-
num = (data & 0x3fe0) >> 5;
279-
data = (data & 0xc000) >> 14;
280-
switch (data) {
281-
case 3:
282-
div = 0x4;
283-
break;
284-
case 2:
285-
case 1:
286-
div = 0x2;
287-
break;
288-
default:
289-
div = 0x1;
290-
break;
291-
}
292-
ast->mclk = ref_pll * (num + 2) / (denum + 2) * (div * 1000);
293302
return 0;
294303
}
295304

drivers/gpu/drm/ast/ast_post.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -375,12 +375,20 @@ void ast_post_gpu(struct drm_device *dev)
375375
ast_enable_mmio(dev);
376376
ast_set_def_ext_reg(dev);
377377

378-
if (ast->chip == AST2300 || ast->chip == AST2400)
379-
ast_init_dram_2300(dev);
380-
else
381-
ast_init_dram_reg(dev);
378+
if (ast->DisableP2A == false)
379+
{
380+
if (ast->chip == AST2300 || ast->chip == AST2400)
381+
ast_init_dram_2300(dev);
382+
else
383+
ast_init_dram_reg(dev);
382384

383-
ast_init_3rdtx(dev);
385+
ast_init_3rdtx(dev);
386+
}
387+
else
388+
{
389+
if (ast->tx_chip_type != AST_TX_NONE)
390+
ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xa3, 0xcf, 0x80); /* Enable DVO */
391+
}
384392
}
385393

386394
/* AST 2300 DRAM settings */

0 commit comments

Comments
 (0)