Skip to content

Commit b1ce4ab

Browse files
author
Thomas Zimmermann
committed
drm/ast: Split ast_set_def_ext_reg() by chip generation
Duplicate ast_set_def_ext_reg() for individual chip generations and move call it into per-chip source files. Remove the original code. AST2100 and AST2500 reuse the function from earlier chips. AST2600 appears to be incorrect as it uses an older function. Keep this behavior for now. Signed-off-by: Thomas Zimmermann <[email protected]> Reviewed-by: Jocelyn Falempe <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent eb104c6 commit b1ce4ab

File tree

7 files changed

+111
-40
lines changed

7 files changed

+111
-40
lines changed

drivers/gpu/drm/ast/ast_2000.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,36 @@
3535
* POST
3636
*/
3737

38+
void ast_2000_set_def_ext_reg(struct ast_device *ast)
39+
{
40+
static const u8 extreginfo[] = { 0x0f, 0x04, 0x1c, 0xff };
41+
u8 i, index, reg;
42+
const u8 *ext_reg_info;
43+
44+
/* reset scratch */
45+
for (i = 0x81; i <= 0x9f; i++)
46+
ast_set_index_reg(ast, AST_IO_VGACRI, i, 0x00);
47+
48+
ext_reg_info = extreginfo;
49+
index = 0xa0;
50+
while (*ext_reg_info != 0xff) {
51+
ast_set_index_reg_mask(ast, AST_IO_VGACRI, index, 0x00, *ext_reg_info);
52+
index++;
53+
ext_reg_info++;
54+
}
55+
56+
/* disable standard IO/MEM decode if secondary */
57+
/* ast_set_index_reg-mask(ast, AST_IO_VGACRI, 0xa1, 0xff, 0x3); */
58+
59+
/* Set Ext. Default */
60+
ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x8c, 0x00, 0x01);
61+
ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xb7, 0x00, 0x00);
62+
63+
/* Enable RAMDAC for A1 */
64+
reg = 0x04;
65+
ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xb6, 0xff, reg);
66+
}
67+
3868
static const struct ast_dramstruct ast2000_dram_table_data[] = {
3969
{ 0x0108, 0x00000000 },
4070
{ 0x0120, 0x00004a21 },
@@ -104,6 +134,8 @@ static void ast_post_chip_2000(struct ast_device *ast)
104134

105135
int ast_2000_post(struct ast_device *ast)
106136
{
137+
ast_2000_set_def_ext_reg(ast);
138+
107139
if (ast->config_mode == ast_use_p2a) {
108140
ast_post_chip_2000(ast);
109141
} else {

drivers/gpu/drm/ast/ast_2100.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,8 @@ static void ast_post_chip_2100(struct ast_device *ast)
333333

334334
int ast_2100_post(struct ast_device *ast)
335335
{
336+
ast_2000_set_def_ext_reg(ast);
337+
336338
if (ast->config_mode == ast_use_p2a) {
337339
ast_post_chip_2100(ast);
338340
} else {

drivers/gpu/drm/ast/ast_2300.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,37 @@
3535
* POST
3636
*/
3737

38+
void ast_2300_set_def_ext_reg(struct ast_device *ast)
39+
{
40+
static const u8 extreginfo[] = { 0x0f, 0x04, 0x1f, 0xff };
41+
u8 i, index, reg;
42+
const u8 *ext_reg_info;
43+
44+
/* reset scratch */
45+
for (i = 0x81; i <= 0x9f; i++)
46+
ast_set_index_reg(ast, AST_IO_VGACRI, i, 0x00);
47+
48+
ext_reg_info = extreginfo;
49+
index = 0xa0;
50+
while (*ext_reg_info != 0xff) {
51+
ast_set_index_reg_mask(ast, AST_IO_VGACRI, index, 0x00, *ext_reg_info);
52+
index++;
53+
ext_reg_info++;
54+
}
55+
56+
/* disable standard IO/MEM decode if secondary */
57+
/* ast_set_index_reg-mask(ast, AST_IO_VGACRI, 0xa1, 0xff, 0x3); */
58+
59+
/* Set Ext. Default */
60+
ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x8c, 0x00, 0x01);
61+
ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xb7, 0x00, 0x00);
62+
63+
/* Enable RAMDAC for A1 */
64+
reg = 0x04;
65+
reg |= 0x20;
66+
ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xb6, 0xff, reg);
67+
}
68+
3869
/* AST 2300 DRAM settings */
3970
#define AST_DDR3 0
4071
#define AST_DDR2 1
@@ -1281,6 +1312,8 @@ static void ast_post_chip_2300(struct ast_device *ast)
12811312

12821313
int ast_2300_post(struct ast_device *ast)
12831314
{
1315+
ast_2300_set_def_ext_reg(ast);
1316+
12841317
if (ast->config_mode == ast_use_p2a) {
12851318
ast_post_chip_2300(ast);
12861319
ast_init_3rdtx(ast);

drivers/gpu/drm/ast/ast_2500.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,8 @@ static void ast_post_chip_2500(struct ast_device *ast)
554554

555555
int ast_2500_post(struct ast_device *ast)
556556
{
557+
ast_2300_set_def_ext_reg(ast);
558+
557559
if (ast->config_mode == ast_use_p2a) {
558560
ast_post_chip_2500(ast);
559561
} else {

drivers/gpu/drm/ast/ast_2600.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,46 @@
2727
*/
2828

2929
#include "ast_drv.h"
30+
#include "ast_post.h"
3031

3132
/*
3233
* POST
3334
*/
3435

36+
void ast_2600_set_def_ext_reg(struct ast_device *ast)
37+
{
38+
static const u8 extreginfo[] = { 0x0f, 0x04, 0x1c, 0xff };
39+
u8 i, index, reg;
40+
const u8 *ext_reg_info;
41+
42+
/* reset scratch */
43+
for (i = 0x81; i <= 0x9f; i++)
44+
ast_set_index_reg(ast, AST_IO_VGACRI, i, 0x00);
45+
46+
ext_reg_info = extreginfo;
47+
index = 0xa0;
48+
while (*ext_reg_info != 0xff) {
49+
ast_set_index_reg_mask(ast, AST_IO_VGACRI, index, 0x00, *ext_reg_info);
50+
index++;
51+
ext_reg_info++;
52+
}
53+
54+
/* disable standard IO/MEM decode if secondary */
55+
/* ast_set_index_reg-mask(ast, AST_IO_VGACRI, 0xa1, 0xff, 0x3); */
56+
57+
/* Set Ext. Default */
58+
ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x8c, 0x00, 0x01);
59+
ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xb7, 0x00, 0x00);
60+
61+
/* Enable RAMDAC for A1 */
62+
reg = 0x04;
63+
ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xb6, 0xff, reg);
64+
}
65+
3566
int ast_2600_post(struct ast_device *ast)
3667
{
68+
ast_2600_set_def_ext_reg(ast);
69+
3770
if (ast->tx_chip == AST_TX_ASTDP)
3871
return ast_dp_launch(ast);
3972

drivers/gpu/drm/ast/ast_post.c

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -34,44 +34,6 @@
3434
#include "ast_drv.h"
3535
#include "ast_post.h"
3636

37-
static const u8 extreginfo[] = { 0x0f, 0x04, 0x1c, 0xff };
38-
static const u8 extreginfo_ast2300[] = { 0x0f, 0x04, 0x1f, 0xff };
39-
40-
static void ast_set_def_ext_reg(struct ast_device *ast)
41-
{
42-
u8 i, index, reg;
43-
const u8 *ext_reg_info;
44-
45-
/* reset scratch */
46-
for (i = 0x81; i <= 0x9f; i++)
47-
ast_set_index_reg(ast, AST_IO_VGACRI, i, 0x00);
48-
49-
if (IS_AST_GEN4(ast) || IS_AST_GEN5(ast) || IS_AST_GEN6(ast))
50-
ext_reg_info = extreginfo_ast2300;
51-
else
52-
ext_reg_info = extreginfo;
53-
54-
index = 0xa0;
55-
while (*ext_reg_info != 0xff) {
56-
ast_set_index_reg_mask(ast, AST_IO_VGACRI, index, 0x00, *ext_reg_info);
57-
index++;
58-
ext_reg_info++;
59-
}
60-
61-
/* disable standard IO/MEM decode if secondary */
62-
/* ast_set_index_reg-mask(ast, AST_IO_VGACRI, 0xa1, 0xff, 0x3); */
63-
64-
/* Set Ext. Default */
65-
ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x8c, 0x00, 0x01);
66-
ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xb7, 0x00, 0x00);
67-
68-
/* Enable RAMDAC for A1 */
69-
reg = 0x04;
70-
if (IS_AST_GEN4(ast) || IS_AST_GEN5(ast) || IS_AST_GEN6(ast))
71-
reg |= 0x20;
72-
ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xb6, 0xff, reg);
73-
}
74-
7537
u32 __ast_mindwm(void __iomem *regs, u32 r)
7638
{
7739
u32 data;
@@ -114,8 +76,6 @@ int ast_post_gpu(struct ast_device *ast)
11476
{
11577
int ret;
11678

117-
ast_set_def_ext_reg(ast);
118-
11979
if (AST_GEN(ast) >= 7) {
12080
ret = ast_2600_post(ast);
12181
if (ret)

drivers/gpu/drm/ast/ast_post.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,13 @@ void __ast_moutdwm(void __iomem *regs, u32 r, u32 v);
4141
bool mmc_test(struct ast_device *ast, u32 datagen, u8 test_ctl);
4242
bool mmc_test_burst(struct ast_device *ast, u32 datagen);
4343

44+
/* ast_2000.c */
45+
void ast_2000_set_def_ext_reg(struct ast_device *ast);
46+
47+
/* ast_2300.c */
48+
void ast_2300_set_def_ext_reg(struct ast_device *ast);
49+
50+
/* ast_2600.c */
51+
void ast_2600_set_def_ext_reg(struct ast_device *ast);
52+
4453
#endif

0 commit comments

Comments
 (0)