drm/ast: Clean up access to non-MMIO registers
Thomas Zimmermann
maintainerv2 cover drm/ast: Clean up access to non-MMIO registers
(was: drm/ast: Clean up access to MMIO registers)
Aspeed devices up to Gen6 contain internal memory that is accessible from the host via the P2A bridge. The helpers ast_moutdwm() and ast_mindwm() pick a 64-KiB segment of the memory to expose to the host, which then has the content available. Content is either registers of the various IP blocks or on-board system memory.
Clean up the driver code involved and provide macro constants for the registers used by the ast driver. Go through the driver and replace the magic values with the constants.
The first patch of the series fixes a bug that has been found while working on these changes. The DP501 writes the content of register SCU2C to the wrong address. The fix is a separate patch to ease backporting.
Smoke-tested on AST2100, AST2300, AST2500 and AST2600.
v2:
- fix typo (Jocelyn)
- fix subject of cover letter
- convert more MCR registers on Gen6
Thomas Zimmermann (15):
drm/ast: dp501: Fix initialization of SCU2C drm/ast: Move 32-bit register-access helpers to ast_drv.{c,h} drm/ast: Use constants for AHBC registers
drm/ast: Use constants for MCR registers
drm/ast: Use constants for SCU registers
drm/ast: Use constants for A2P registers
drm/ast: Use constants for WDT registers
drm/ast: Use constants for SDRAM registers
drm/ast: Store register addresses in struct ast_dramstruct drm/ast: Gen1: Fix open-coded register access drm/ast: Gen2: Fix open-coded register access drm/ast: Gen4: Fix open-coded register access drm/ast: Gen6: Fix open-coded register access drm/ast: dp501: Fix open-coded register access drm/ast: Fix open-coded scu_rev access
drivers/gpu/drm/ast/ast_2000.c | 61 +++-- drivers/gpu/drm/ast/ast_2100.c | 292 +++++++++++------------ drivers/gpu/drm/ast/ast_2300.c | 398 ++++++++++++++++---------------- drivers/gpu/drm/ast/ast_2500.c | 329 +++++++++++++------------- drivers/gpu/drm/ast/ast_dp501.c | 146 ++++++------ drivers/gpu/drm/ast/ast_drv.c | 84 ++++++- drivers/gpu/drm/ast/ast_drv.h | 60 +++-- drivers/gpu/drm/ast/ast_post.c | 48 +--- drivers/gpu/drm/ast/ast_post.h | 20 +- drivers/gpu/drm/ast/ast_reg.h | 156 +++++++++++++ 10 files changed, 891 insertions(+), 703 deletions(-)
base-commit: 5cb7d14d9bd2061386a0192a4649626a3e3a5ec3
Signature · 1 line
2.53.0
Thomas Zimmermann
maintainerPATCH v2 1/15 drm/ast: dp501: Fix initialization of SCU2C
Ast's DP501 initialization reads the register SCU2C at offset 0x1202c and tries to set it to source data from VGA. But writes the update to offset 0x0, with unknown results. Write the result to SCU instead.
The bug only happens in ast_init_analog(). There's similar code in ast_init_dvo(), which works correctly.
--- drivers/gpu/drm/ast/ast_dp501.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/ast/ast_dp501.c +1 -1
@@ -436,7 +436,7 @@ static void ast_init_analog(struct ast_device *ast)/* Finally, clear bits [17:16] of SCU2c */ data =ast_read32 (ast,0x1202c ); data &=0xfffcffff ; -ast_write32 (ast,0 , data); +ast_write32 (ast,0x1202c , data);/* Disable DVO */ ast_set_index_reg_mask (ast,AST_IO_VGACRI ,0xa3 ,0xcf ,0x00 );
Signature · 1 line
2.53.0
Thomas Zimmermann
maintainerPATCH v2 2/15 drm/ast: Move 32-bit register-access helpers to ast_drv.{c, h}
In reply to Thomas ZimmermannThe helpers ast_mindwm() and ast_moutdwm() access the I/O memory of the various IP modules on the Aspeed device. This is based on the "P-Bus to AHB Bridge" interface.
Reimplement the access function with properly defined constants and helper macros.
- Define P2A constants for the related registers and addresses. The P2A interface is located in the memory range at [0x00000000, 0x00010000].
- Memory access is segmented. An address' upper 16-bit select the memory segment, the lower 16-bit select the offset within the segment. Implement segment selection in a shared helper __ast_segsel(). Validate that the segment hs been changes. This logic has previously been part of __ast_moudwm() and __ast_mindwm(). Relax the CPU while busy-waiting.
- Put intra-segment reads and writes in the helpers __ast_rdseg32() and __ast_wrseg32(). The helpers set the segment offset automatically.
- Reimplement the existing interfaces on top of these helpers.
Put the new implementation next to the other I/O helpers.
v2:
- fix typo in commit description (Jocelyn)
--- drivers/gpu/drm/ast/ast_drv.c | 59 ++++++++++++++++++++++++++++++++++ drivers/gpu/drm/ast/ast_drv.h | 59 +++++++++++++++++++++------------- drivers/gpu/drm/ast/ast_post.c | 38 ---------------------- drivers/gpu/drm/ast/ast_post.h | 3 -- drivers/gpu/drm/ast/ast_reg.h | 12 +++++++ 5 files changed, 108 insertions(+), 63 deletions(-)
drivers/gpu/drm/ast/ast_drv.c +59 -0
@@ -47,6 +47,65 @@ static int ast_modeset = -1;MODULE_PARM_DESC (modeset,"Disable/Enable modesetting" );module_param_named (modeset, ast_modeset, int,0400 ); +/* +* Register access +*/ + +/* Select R/W segment */ +static void __ast_selseg (void __iomem *regs,u32 r) +{ +u32 p2a04, p2a04_base; + + p2a04 = r &AST_REG_P2A04_BASE_MASK ; +__ast_write32 (regs,AST_REG_P2A04 , p2a04); +__ast_write32 (regs,AST_REG_P2A00 ,AST_REG_P2A00_PROTECTION_KEY ); + +do { +cpu_relax (); + p2a04_base =__ast_read32 (regs,AST_REG_P2A04 ); + p2a04_base &=AST_REG_P2A04_BASE_MASK ; + }while (p2a04_base != p2a04); +} + +/* Read within segment */ +static u32 __ast_rdseg32 (void __iomem *regs,u32 r) +{ +return __ast_read32 (regs,AST_REG_P2A_ADDR (r)); +} + +/* Write within segment */ +static void __ast_wrseg32 (void __iomem *regs,u32 r,u32 v) +{ +__ast_write32 (regs,AST_REG_P2A_ADDR (r), v); +} + +u32 __ast_mindwm (void __iomem *regs,u32 r) +{ +__ast_selseg (regs, r); + +return __ast_rdseg32 (regs, r); +} + +void __ast_moutdwm (void __iomem *regs,u32 r,u32 v) +{ +__ast_selseg (regs, r); +__ast_wrseg32 (regs, r, v); +} + +u32 ast_mindwm (struct ast_device *ast,u32 r) +{ +return __ast_mindwm (ast->regs, r); +} + +void ast_moutdwm (struct ast_device *ast,u32 r,u32 v) +{ +__ast_moutdwm (ast->regs, r, v); +} + +/* +* AST device +*/ + void ast_device_init(struct ast_device *ast, enum ast_chip chip, enum ast_config_mode config_mode,
drivers/gpu/drm/ast/ast_drv.h +37 -22
93 lines not on this page · raw message
drivers/gpu/drm/ast/ast_post.c +0 -38
@@ -34,44 +34,6 @@#include "ast_drv.h" #include "ast_post.h" -u32 __ast_mindwm (void __iomem *regs,u32 r) -{ -u32 data; - -__ast_write32 (regs,0xf004 , r &0xffff0000 ); -__ast_write32 (regs,0xf000 ,0x1 ); - -do { - data =__ast_read32 (regs,0xf004 ) &0xffff0000 ; - }while (data != (r &0xffff0000 )); - -return __ast_read32 (regs,0x10000 + (r &0x0000ffff )); -} - -void __ast_moutdwm (void __iomem *regs,u32 r,u32 v) -{ -u32 data; - -__ast_write32 (regs,0xf004 , r &0xffff0000 ); -__ast_write32 (regs,0xf000 ,0x1 ); - -do { - data =__ast_read32 (regs,0xf004 ) &0xffff0000 ; - }while (data != (r &0xffff0000 )); - -__ast_write32 (regs,0x10000 + (r &0x0000ffff ), v); -} - -u32 ast_mindwm (struct ast_device *ast,u32 r) -{ -return __ast_mindwm (ast->regs, r); -} - -void ast_moutdwm (struct ast_device *ast,u32 r,u32 v) -{ -__ast_moutdwm (ast->regs, r, v); -} -int ast_post_gpu (struct ast_device *ast) {int ret;
drivers/gpu/drm/ast/ast_post.h +0 -3
@@ -35,9 +35,6 @@ struct ast_dramstruct {#define AST_DRAMSTRUCT_IS (_entry, _name) \ ((_entry)->index == __AST_DRAMSTRUCT_INDEX(_name)) -u32 __ast_mindwm (void __iomem *regs,u32 r); -void __ast_moutdwm (void __iomem *regs,u32 r,u32 v); -bool mmc_test (struct ast_device *ast,u32 datagen,u8 test_ctl);bool mmc_test_burst (struct ast_device *ast,u32 datagen);
drivers/gpu/drm/ast/ast_reg.h +12 -0
@@ -75,4 +75,16 @@#define AST_IO_VGAIR1_R (0x5A)#define AST_IO_VGAIR1_VREFRESH BIT(3) +/* +* P-Bus to AHB Bridge (0x00000000 - 0x0001ffff) +*/ + +#define AST_REG_P2A_BASE (0x00000000) +#define AST_REG_P2A (__offset) (AST_REG_P2A_BASE + (__offset)) +#define AST_REG_P2A_ADDR (__addr) AST_REG_P2A(0x10000 + ((__addr) & GENMASK(15, 0))) +#define AST_REG_P2A00 AST_REG_P2A(0xf000) +#define AST_REG_P2A00_PROTECTION_KEY (0x01) +#define AST_REG_P2A04 AST_REG_P2A(0xf004) +#define AST_REG_P2A04_BASE_MASK GENMASK(31, 16) +#endif
Signature · 1 line
2.53.0
Thomas Zimmermann
maintainerPATCH v2 3/15 drm/ast: Use constants for AHBC registers
In reply to Thomas ZimmermannAHBC is the Advanced High-Speed Bus Controller. AHBC registers are located in the memory range within [0x1e600000, 0x1e61ffff]. Refer to them with constants named AST_REG_AHBC<n>, where <n> is the byte offset into the range.
--- drivers/gpu/drm/ast/ast_2500.c | 6 +++--- drivers/gpu/drm/ast/ast_reg.h | 11 +++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-)
drivers/gpu/drm/ast/ast_2500.c +3 -3
@@ -109,9 +109,9 @@ void ast_2500_patch_ahb(void __iomem *regs)u32 data;/* Clear bus lock condition */ -__ast_moutdwm (regs,0x1e600000 ,0xAEED1A03 ); -__ast_moutdwm (regs,0x1e600084 ,0x00010000 ); -__ast_moutdwm (regs,0x1e600088 ,0x00000000 ); +__ast_moutdwm (regs,AST_REG_AHBC00 ,AST_REG_AHBC00_PROTECT_KEY ); +__ast_moutdwm (regs,AST_REG_AHBC84 ,0x00010000 ); +__ast_moutdwm (regs,AST_REG_AHBC88 ,0x00000000 );__ast_moutdwm (regs,0x1e6e2000 ,0x1688A8A8 ); data =__ast_mindwm (regs,0x1e6e2070 );
drivers/gpu/drm/ast/ast_reg.h +11 -0
@@ -87,4 +87,15 @@#define AST_REG_P2A04 AST_REG_P2A(0xf004)#define AST_REG_P2A04_BASE_MASK GENMASK(31, 16) +/* +* AHB Controller (0x1e600000 - 0x1e61ffff) +*/ + +#define AST_REG_AHBC_BASE (0x1e600000) +#define AST_REG_AHBC (__offset) (AST_REG_AHBC_BASE + (__offset)) +#define AST_REG_AHBC00 AST_REG_AHBC(0x00) +#define AST_REG_AHBC00_PROTECT_KEY (0xaeed1a03) +#define AST_REG_AHBC84 AST_REG_AHBC(0x84) +#define AST_REG_AHBC88 AST_REG_AHBC(0x88) +#endif
Signature · 1 line
2.53.0
Thomas Zimmermann
maintainerPATCH v2 4/15 drm/ast: Use constants for MCR registers
In reply to Thomas ZimmermannSDRAM registers are located in the memory range at [0x1e160000, 0x1e160fff]. Refer to them with constants named AST_REG_MCR<n>, where n is the byte offset into the range.
Replacing the magic values in the ast driver was done with grep and sed as shown below
git grep -l \,\ 0x1e6e00 | xargs sed -i -e 's/, 0x1e6e00/, AST_REG_MCR/g' git grep -l \,\ 0x1E6E00 | xargs sed -i -e 's/, 0x1E6E00/, AST_REG_MCR/g'
plus some manual fixes.
--- drivers/gpu/drm/ast/ast_2000.c | 2 +- drivers/gpu/drm/ast/ast_2100.c | 30 +-- drivers/gpu/drm/ast/ast_2300.c | 330 ++++++++++++++++---------------- drivers/gpu/drm/ast/ast_2500.c | 224 +++++++++++----------- drivers/gpu/drm/ast/ast_dp501.c | 6 +- drivers/gpu/drm/ast/ast_drv.c | 2 +- drivers/gpu/drm/ast/ast_post.c | 10 +- drivers/gpu/drm/ast/ast_reg.h | 71 +++++++ 8 files changed, 373 insertions(+), 302 deletions(-)
drivers/gpu/drm/ast/ast_2000.c +1 -1
@@ -106,7 +106,7 @@ static void ast_post_chip_2000(struct ast_device *ast)if ((j &0x80 ) ==0 ) {/* VGA only */ dram_reg_info = ast2000_dram_table_data; -ast_write32 (ast,0xf004 ,0x1e6e0000 ); +ast_write32 (ast,0xf004 ,AST_REG_MCR00 );ast_write32 (ast,0xf000 ,0x1 );ast_write32 (ast,0x10100 ,0xa8 );
drivers/gpu/drm/ast/ast_2100.c +15 -15
@@ -43,7 +43,7 @@ static enum ast_dram_layout ast_2100_get_dram_layout_p2a(struct ast_device *ast)u32 mcr_cfg;enum ast_dram_layout dram_layout; -ast_write32 (ast,0xf004 ,0x1e6e0000 ); +ast_write32 (ast,0xf004 ,AST_REG_MCR00 );ast_write32 (ast,0xf000 ,0x1 ); mcr_cfg =ast_read32 (ast,0x10004 );
@@ -209,28 +209,28 @@ static u32 mmctestburst2_ast2150(struct ast_device *ast, u32 datagen) {u32 data, timeout; -ast_moutdwm (ast,0x1e6e0070 ,0x00000000 ); -ast_moutdwm (ast,0x1e6e0070 ,0x00000001 | (datagen <<3 )); +ast_moutdwm (ast,AST_REG_MCR70 ,0x00000000 ); +ast_moutdwm (ast,AST_REG_MCR70 ,0x00000001 | (datagen <<3 )); timeout =0 ;do { - data =ast_mindwm (ast,0x1e6e0070 ) &0x40 ; + data =ast_mindwm (ast,AST_REG_MCR70 ) &0x40 ;if (++timeout >TIMEOUT_AST2150 ) { -ast_moutdwm (ast,0x1e6e0070 ,0x00000000 ); +ast_moutdwm (ast,AST_REG_MCR70 ,0x00000000 );return 0xffffffff ; } }while (!data); -ast_moutdwm (ast,0x1e6e0070 ,0x00000000 ); -ast_moutdwm (ast,0x1e6e0070 ,0x00000003 | (datagen <<3 )); +ast_moutdwm (ast,AST_REG_MCR70 ,0x00000000 ); +ast_moutdwm (ast,AST_REG_MCR70 ,0x00000003 | (datagen <<3 )); timeout =0 ;do { - data =ast_mindwm (ast,0x1e6e0070 ) &0x40 ; + data =ast_mindwm (ast,AST_REG_MCR70 ) &0x40 ;if (++timeout >TIMEOUT_AST2150 ) { -ast_moutdwm (ast,0x1e6e0070 ,0x00000000 ); +ast_moutdwm (ast,AST_REG_MCR70 ,0x00000000 );return 0xffffffff ; } }while (!data); - data = (ast_mindwm (ast,0x1e6e0070 ) &0x80 ) >>7 ; -ast_moutdwm (ast,0x1e6e0070 ,0x00000000 ); + data = (ast_mindwm (ast,AST_REG_MCR70 ) &0x80 ) >>7 ; +ast_moutdwm (ast,AST_REG_MCR70 ,0x00000000 );return data; }
@@ -249,7 +249,7 @@ static int cbrscan_ast2150(struct ast_device *ast, int busw)u32 patcnt, loop;for (patcnt =0 ; patcnt <CBR_PATNUM_AST2150 ; patcnt++) { -ast_moutdwm (ast,0x1e6e007c , pattern_AST2150[patcnt]); +ast_moutdwm (ast,AST_REG_MCR7C , pattern_AST2150[patcnt]);for (loop =0 ; loop <CBR_PASSNUM_AST2150 ; loop++) {if (cbrtest_ast2150 (ast))break ;
@@ -276,7 +276,7 @@ static void cbrdlli_ast2150(struct ast_device *ast, int busw) passcnt =0 ;for (dlli =0 ; dlli <100 ; dlli++) { -ast_moutdwm (ast,0x1e6e0068 , dlli | (dlli <<8 ) | (dlli <<16 ) | (dlli <<24 )); +ast_moutdwm (ast,AST_REG_MCR68 , dlli | (dlli <<8 ) | (dlli <<16 ) | (dlli <<24 )); data =cbrscan_ast2150 (ast, busw);if (data !=0 ) {if (data &0x1 ) {
@@ -294,7 +294,7 @@ static void cbrdlli_ast2150(struct ast_device *ast, int busw) goto cbr_start; dlli = dll_min[0 ] + (((dll_max[0 ] - dll_min[0 ]) *7 ) >>4 ); -ast_moutdwm (ast,0x1e6e0068 , dlli | (dlli <<8 ) | (dlli <<16 ) | (dlli <<24 )); +ast_moutdwm (ast,AST_REG_MCR68 , dlli | (dlli <<8 ) | (dlli <<16 ) | (dlli <<24 )); }static void ast_post_chip_2100 (struct ast_device *ast)
@@ -312,7 +312,7 @@ static void ast_post_chip_2100(struct ast_device *ast)else dram_reg_info = ast1100_dram_table_data; -ast_write32 (ast,0xf004 ,0x1e6e0000 ); +ast_write32 (ast,0xf004 ,AST_REG_MCR00 );ast_write32 (ast,0xf000 ,0x1 );ast_write32 (ast,0x12000 ,0x1688A8A8 ); do {
drivers/gpu/drm/ast/ast_2300.c +165 -165
513 lines not on this page · raw message
drivers/gpu/drm/ast/ast_2500.c +112 -112
363 lines not on this page · raw message
drivers/gpu/drm/ast/ast_dp501.c +3 -3
@@ -230,7 +230,7 @@ static bool ast_launch_m68k(struct ast_device *ast) }/* Get BootAddress */ ast_moutdwm (ast,0x1e6e2000 ,0x1688a8a8 ); - data =ast_mindwm (ast,0x1e6e0004 ); + data =ast_mindwm (ast,AST_REG_MCR04 );switch (data &0x03 ) {case 0 : boot_address =0x44000000 ;
@@ -348,7 +348,7 @@ static bool ast_init_dvo(struct ast_device *ast) {u8 jreg;u32 data; -ast_write32 (ast,0xf004 ,0x1e6e0000 ); +ast_write32 (ast,0xf004 ,AST_REG_MCR00 );ast_write32 (ast,0xf000 ,0x1 );ast_write32 (ast,0x12000 ,0x1688a8a8 );
@@ -425,7 +425,7 @@ static void ast_init_analog(struct ast_device *ast)* bridge. First configure the P2U to target the SCU * in case it isn't at this stage. */ -ast_write32 (ast,0xf004 ,0x1e6e0000 ); +ast_write32 (ast,0xf004 ,AST_REG_MCR00 );ast_write32 (ast,0xf000 ,0x1 );/* Then unlock the SCU with the magic password */
drivers/gpu/drm/ast/ast_drv.c +1 -1
@@ -268,7 +268,7 @@ static int ast_detect_chip(struct pci_dev *pdev, config_mode = ast_use_p2a;/* Read SCU7c (silicon revision register) */ -__ast_write32 (regs,0xf004 ,0x1e6e0000 ); +__ast_write32 (regs,0xf004 ,AST_REG_MCR00 );__ast_write32 (regs,0xf000 ,0x1 ); scu_rev =__ast_read32 (regs,0x1207c ); }
drivers/gpu/drm/ast/ast_post.c +5 -5
@@ -69,19 +69,19 @@ bool mmc_test(struct ast_device *ast, u32 datagen, u8 test_ctl) {u32 data, timeout; -ast_moutdwm (ast,0x1e6e0070 ,0x00000000 ); -ast_moutdwm (ast,0x1e6e0070 , (datagen <<3 ) | test_ctl); +ast_moutdwm (ast,AST_REG_MCR70 ,0x00000000 ); +ast_moutdwm (ast,AST_REG_MCR70 , (datagen <<3 ) | test_ctl); timeout =0 ;do { - data =ast_mindwm (ast,0x1e6e0070 ) &0x3000 ; + data =ast_mindwm (ast,AST_REG_MCR70 ) &0x3000 ;if (data &0x2000 )return false;if (++timeout >TIMEOUT ) { -ast_moutdwm (ast,0x1e6e0070 ,0x00000000 ); +ast_moutdwm (ast,AST_REG_MCR70 ,0x00000000 );return false; } }while (!data); -ast_moutdwm (ast,0x1e6e0070 ,0x0 ); +ast_moutdwm (ast,AST_REG_MCR70 ,0x0 );return true; }
drivers/gpu/drm/ast/ast_reg.h +71 -0
75 lines not on this page · raw message
Signature · 1 line
2.53.0
Thomas Zimmermann
maintainerPATCH v2 5/15 drm/ast: Use constants for SCU registers
In reply to Thomas ZimmermannSCU is the System Control Unit. SCU registers are located in the memory range at [0x1e6e2000, 0x1e6e2fff]. Refer to them with constants named AST_REG_SCU<n>, where <n> is the byte offset into the range.
Replacing the magic values in the ast driver was done with grep and sed as shown below
git grep -l \,\ 0x1e6e2 | xargs sed -i -e 's/, 0x1e6e2/, AST_REG_SCU/g' git grep -l \,\ 0x1E6E2 | xargs sed -i -e 's/, 0x1E6E2/, AST_REG_SCU/g'
plus some manual fixes.
--- drivers/gpu/drm/ast/ast_2300.c | 50 ++++++++++++++++----------------- drivers/gpu/drm/ast/ast_2500.c | 44 ++++++++++++++--------------- drivers/gpu/drm/ast/ast_dp501.c | 20 ++++++------- drivers/gpu/drm/ast/ast_reg.h | 19 +++++++++++++ 4 files changed, 76 insertions(+), 57 deletions(-)
drivers/gpu/drm/ast/ast_2300.c +25 -25
@@ -516,10 +516,10 @@ static void get_ddr3_info(struct ast_device *ast, struct ast2300_dram_param *par {u32 trap, trap_AC2, trap_MRS; -ast_moutdwm (ast,0x1E6E2000 ,0x1688A8A8 ); +ast_moutdwm (ast,AST_REG_SCU000 ,AST_REG_SCU000_PROTECTION_KEY );/* Ger trap info */ - trap = (ast_mindwm (ast,0x1E6E2070 ) >>25 ) &0x3 ; + trap = (ast_mindwm (ast,AST_REG_SCU070 ) >>25 ) &0x3 ; trap_AC2 =0x00020000 + (trap <<16 ); trap_AC2 |=0x00300000 + ((trap &0x2 ) <<19 ); trap_MRS =0x00000010 + (trap <<4 );
@@ -533,7 +533,7 @@ static void get_ddr3_info(struct ast_device *ast, struct ast2300_dram_param *parswitch (param->dram_freq) {case 336 : -ast_moutdwm (ast,0x1E6E2020 ,0x0190 ); +ast_moutdwm (ast,AST_REG_SCU020 ,0x0190 ); param->wodt =0 ; param->reg_AC1 =0x22202725 ; param->reg_AC2 =0xAA007613 | trap_AC2;
@@ -561,7 +561,7 @@ static void get_ddr3_info(struct ast_device *ast, struct ast2300_dram_param *parbreak ;default :case 396 : -ast_moutdwm (ast,0x1E6E2020 ,0x03F1 ); +ast_moutdwm (ast,AST_REG_SCU020 ,0x03F1 ); param->wodt =1 ; param->reg_AC1 =0x33302825 ; param->reg_AC2 =0xCC009617 | trap_AC2;
@@ -591,7 +591,7 @@ static void get_ddr3_info(struct ast_device *ast, struct ast2300_dram_param *parbreak ;case 408 : -ast_moutdwm (ast,0x1E6E2020 ,0x01F0 ); +ast_moutdwm (ast,AST_REG_SCU020 ,0x01F0 ); param->wodt =1 ; param->reg_AC1 =0x33302825 ; param->reg_AC2 =0xCC009617 | trap_AC2;
@@ -621,7 +621,7 @@ static void get_ddr3_info(struct ast_device *ast, struct ast2300_dram_param *parbreak ;case 456 : -ast_moutdwm (ast,0x1E6E2020 ,0x0230 ); +ast_moutdwm (ast,AST_REG_SCU020 ,0x0230 ); param->wodt =0 ; param->reg_AC1 =0x33302926 ; param->reg_AC2 =0xCD44961A ;
@@ -635,7 +635,7 @@ static void get_ddr3_info(struct ast_device *ast, struct ast2300_dram_param *par param->dll2_finetune_step =4 ;break ;case 504 : -ast_moutdwm (ast,0x1E6E2020 ,0x0270 ); +ast_moutdwm (ast,AST_REG_SCU020 ,0x0270 ); param->wodt =1 ; param->reg_AC1 =0x33302926 ; param->reg_AC2 =0xDE44A61D ;
@@ -649,7 +649,7 @@ static void get_ddr3_info(struct ast_device *ast, struct ast2300_dram_param *par param->dll2_finetune_step =4 ;break ;case 528 : -ast_moutdwm (ast,0x1E6E2020 ,0x0290 ); +ast_moutdwm (ast,AST_REG_SCU020 ,0x0290 ); param->wodt =1 ; param->rodt =1 ; param->reg_AC1 =0x33302926 ;
@@ -665,7 +665,7 @@ static void get_ddr3_info(struct ast_device *ast, struct ast2300_dram_param *par param->dll2_finetune_step =3 ;break ;case 576 : -ast_moutdwm (ast,0x1E6E2020 ,0x0140 ); +ast_moutdwm (ast,AST_REG_SCU020 ,0x0140 ); param->reg_MADJ =0x00136868 ; param->reg_SADJ =0x00004534 ; param->wodt =1 ;
@@ -683,7 +683,7 @@ static void get_ddr3_info(struct ast_device *ast, struct ast2300_dram_param *par param->dll2_finetune_step =3 ;break ;case 600 : -ast_moutdwm (ast,0x1E6E2020 ,0x02E1 ); +ast_moutdwm (ast,AST_REG_SCU020 ,0x02E1 ); param->reg_MADJ =0x00136868 ; param->reg_SADJ =0x00004534 ; param->wodt =1 ;
@@ -701,7 +701,7 @@ static void get_ddr3_info(struct ast_device *ast, struct ast2300_dram_param *par param->dll2_finetune_step =3 ;break ;case 624 : -ast_moutdwm (ast,0x1E6E2020 ,0x0160 ); +ast_moutdwm (ast,AST_REG_SCU020 ,0x0160 ); param->reg_MADJ =0x00136868 ; param->reg_SADJ =0x00004534 ; param->wodt =1 ;
@@ -874,10 +874,10 @@ static void get_ddr2_info(struct ast_device *ast, struct ast2300_dram_param *par {u32 trap, trap_AC2, trap_MRS; -ast_moutdwm (ast,0x1E6E2000 ,0x1688A8A8 ); +ast_moutdwm (ast,AST_REG_SCU000 ,AST_REG_SCU000_PROTECTION_KEY );/* Ger trap info */ - trap = (ast_mindwm (ast,0x1E6E2070 ) >>25 ) &0x3 ; + trap = (ast_mindwm (ast,AST_REG_SCU070 ) >>25 ) &0x3 ; trap_AC2 = (trap <<20 ) | (trap <<16 ); trap_AC2 +=0x00110000 ; trap_MRS =0x00000040 | (trap <<4 );
@@ -890,7 +890,7 @@ static void get_ddr2_info(struct ast_device *ast, struct ast2300_dram_param *parswitch (param->dram_freq) {case 264 : -ast_moutdwm (ast,0x1E6E2020 ,0x0130 ); +ast_moutdwm (ast,AST_REG_SCU020 ,0x0130 ); param->wodt =0 ; param->reg_AC1 =0x11101513 ; param->reg_AC2 =0x78117011 ;
@@ -905,7 +905,7 @@ static void get_ddr2_info(struct ast_device *ast, struct ast2300_dram_param *par param->dll2_finetune_step =3 ;break ;case 336 : -ast_moutdwm (ast,0x1E6E2020 ,0x0190 ); +ast_moutdwm (ast,AST_REG_SCU020 ,0x0190 ); param->wodt =1 ; param->reg_AC1 =0x22202613 ; param->reg_AC2 =0xAA009016 | trap_AC2;
@@ -936,7 +936,7 @@ static void get_ddr2_info(struct ast_device *ast, struct ast2300_dram_param *parbreak ;default :case 396 : -ast_moutdwm (ast,0x1E6E2020 ,0x03F1 ); +ast_moutdwm (ast,AST_REG_SCU020 ,0x03F1 ); param->wodt =1 ; param->rodt =0 ; param->reg_AC1 =0x33302714 ;
@@ -970,7 +970,7 @@ static void get_ddr2_info(struct ast_device *ast, struct ast2300_dram_param *parbreak ;case 408 : -ast_moutdwm (ast,0x1E6E2020 ,0x01F0 ); +ast_moutdwm (ast,AST_REG_SCU020 ,0x01F0 ); param->wodt =1 ; param->rodt =0 ; param->reg_AC1 =0x33302714 ;
@@ -1003,7 +1003,7 @@ static void get_ddr2_info(struct ast_device *ast, struct ast2300_dram_param *parbreak ;case 456 : -ast_moutdwm (ast,0x1E6E2020 ,0x0230 ); +ast_moutdwm (ast,AST_REG_SCU020 ,0x0230 ); param->wodt =0 ; param->reg_AC1 =0x33302815 ; param->reg_AC2 =0xCD44B01E ;
@@ -1018,7 +1018,7 @@ static void get_ddr2_info(struct ast_device *ast, struct ast2300_dram_param *par param->dll2_finetune_step =3 ;break ;case 504 : -ast_moutdwm (ast,0x1E6E2020 ,0x0261 ); +ast_moutdwm (ast,AST_REG_SCU020 ,0x0261 ); param->wodt =1 ; param->rodt =1 ; param->reg_AC1 =0x33302815 ;
@@ -1034,7 +1034,7 @@ static void get_ddr2_info(struct ast_device *ast, struct ast2300_dram_param *par param->dll2_finetune_step =3 ;break ;case 528 : -ast_moutdwm (ast,0x1E6E2020 ,0x0120 ); +ast_moutdwm (ast,AST_REG_SCU020 ,0x0120 ); param->wodt =1 ; param->rodt =1 ; param->reg_AC1 =0x33302815 ;
@@ -1050,7 +1050,7 @@ static void get_ddr2_info(struct ast_device *ast, struct ast2300_dram_param *par param->dll2_finetune_step =3 ;break ;case 552 : -ast_moutdwm (ast,0x1E6E2020 ,0x02A1 ); +ast_moutdwm (ast,AST_REG_SCU020 ,0x02A1 ); param->wodt =1 ; param->rodt =1 ; param->reg_AC1 =0x43402915 ;
@@ -1066,7 +1066,7 @@ static void get_ddr2_info(struct ast_device *ast, struct ast2300_dram_param *par param->dll2_finetune_step =3 ;break ;case 576 : -ast_moutdwm (ast,0x1E6E2020 ,0x0140 ); +ast_moutdwm (ast,AST_REG_SCU020 ,0x0140 ); param->wodt =1 ; param->rodt =1 ; param->reg_AC1 =0x43402915 ;
@@ -1264,7 +1264,7 @@ static void ast_post_chip_2300(struct ast_device *ast) param.dram_freq =396 ; param.dram_type =AST_DDR3 ; - temp =ast_mindwm (ast,0x1e6e2070 ); + temp =ast_mindwm (ast,AST_REG_SCU070 );if (temp &0x01000000 ) param.dram_type =AST_DDR2 ;switch (temp &0x18000000 ) {
@@ -1306,8 +1306,8 @@ static void ast_post_chip_2300(struct ast_device *ast)ddr2_init (ast, ¶m); } - temp =ast_mindwm (ast,0x1e6e2040 ); -ast_moutdwm (ast,0x1e6e2040 , temp |0x40 ); + temp =ast_mindwm (ast,AST_REG_SCU040 ); +ast_moutdwm (ast,AST_REG_SCU040 , temp |0x40 ); }/* wait ready */
drivers/gpu/drm/ast/ast_2500.c +22 -22
102 lines not on this page · raw message
drivers/gpu/drm/ast/ast_dp501.c +10 -10
@@ -183,7 +183,7 @@ static void ast_set_dp501_video_output(struct ast_device *ast, u8 mode)static u32 get_fw_base (struct ast_device *ast) { -return ast_mindwm (ast,0x1e6e2104 ) &0x7fffffff ; +return ast_mindwm (ast,AST_REG_SCU104 ) &0x7fffffff ; }bool ast_backup_fw (struct ast_device *ast,u8 *addr,u32 size)
@@ -194,7 +194,7 @@ bool ast_backup_fw(struct ast_device *ast, u8 *addr, u32 size)if (ast->config_mode != ast_use_p2a)return false; - data =ast_mindwm (ast,0x1e6e2100 ) &0x01 ; + data =ast_mindwm (ast,AST_REG_SCU100 ) &0x01 ;if (data) { boot_address =get_fw_base (ast);for (i =0 ; i < size; i +=4 )
@@ -214,7 +214,7 @@ static bool ast_launch_m68k(struct ast_device *ast)if (ast->config_mode != ast_use_p2a)return false; - data =ast_mindwm (ast,0x1e6e2100 ) &0x01 ; + data =ast_mindwm (ast,AST_REG_SCU100 ) &0x01 ;if (!data) {if (ast->dp501_fw_addr) {
@@ -229,7 +229,7 @@ static bool ast_launch_m68k(struct ast_device *ast) len = ast->dp501_fw->size; }/* Get BootAddress */ -ast_moutdwm (ast,0x1e6e2000 ,0x1688a8a8 ); +ast_moutdwm (ast,AST_REG_SCU000 ,AST_REG_SCU000_PROTECTION_KEY ); data =ast_mindwm (ast,AST_REG_MCR04 );switch (data &0x03 ) {case 0 :
@@ -255,16 +255,16 @@ static bool ast_launch_m68k(struct ast_device *ast) }/* Init SCU */ -ast_moutdwm (ast,0x1e6e2000 ,0x1688a8a8 ); +ast_moutdwm (ast,AST_REG_SCU000 ,AST_REG_SCU000_PROTECTION_KEY );/* Launch FW */ -ast_moutdwm (ast,0x1e6e2104 ,0x80000000 + boot_address); -ast_moutdwm (ast,0x1e6e2100 ,1 ); +ast_moutdwm (ast,AST_REG_SCU104 ,0x80000000 + boot_address); +ast_moutdwm (ast,AST_REG_SCU100 ,1 );/* Update Scratch */ - data =ast_mindwm (ast,0x1e6e2040 ) &0xfffff1ff ;/* D[11:9] = 100b: UEFI handling */ - data |=0x800 ; -ast_moutdwm (ast,0x1e6e2040 , data); + data =ast_mindwm (ast,AST_REG_SCU040 ) &0xfffff1ff ; + data |=0x800 ;/* D[11:9] = 100b: UEFI handling */ +ast_moutdwm (ast,AST_REG_SCU040 , data); jreg =ast_get_index_reg_mask (ast,AST_IO_VGACRI ,0x99 ,0xfc );/* D[1:0]: Reserved Video Buffer */ jreg |=0x02 ;
drivers/gpu/drm/ast/ast_reg.h +19 -0
@@ -169,4 +169,23 @@#define AST_REG_MCR300 AST_REG_MCR(0x300)#define AST_REG_MCR3D0 AST_REG_MCR(0x3d0) +/* +* System Control Unit (0x1e6e2000 - 0x1e6e2fff) +*/ + +#define AST_REG_SCU_BASE (0x1e6e2000) +#define AST_REG_SCU (__offset) (AST_REG_SCU_BASE + (__offset)) +#define AST_REG_SCU000 AST_REG_SCU(0x000) +#define AST_REG_SCU000_PROTECTION_KEY (0x1688a8a8) +#define AST_REG_SCU00C AST_REG_SCU(0x00c) +#define AST_REG_SCU020 AST_REG_SCU(0x020) +#define AST_REG_SCU040 AST_REG_SCU(0x040) +#define AST_REG_SCU070 AST_REG_SCU(0x070) +#define AST_REG_SCU07C AST_REG_SCU(0x07c) +#define AST_REG_SCU090 AST_REG_SCU(0x090) +#define AST_REG_SCU094 AST_REG_SCU(0x094) +#define AST_REG_SCU100 AST_REG_SCU(0x100) +#define AST_REG_SCU104 AST_REG_SCU(0x104) +#define AST_REG_SCU160 AST_REG_SCU(0x160) +#endif
Signature · 1 line
2.53.0
Thomas Zimmermann
maintainerPATCH v2 6/15 drm/ast: Use constants for A2P registers
In reply to Thomas ZimmermannA2P is the AHB-to-P Bridge. A2P registers are located at the memory range at [0x1e720000, 0x1e73ffff]. Refer to them with constants named AST_REG_A2P<n>, where <n> is the byte offset into the range.
--- drivers/gpu/drm/ast/ast_2300.c | 6 +++--- drivers/gpu/drm/ast/ast_reg.h | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-)
drivers/gpu/drm/ast/ast_2300.c +3 -3
@@ -508,7 +508,7 @@ static bool cbr_dll2(struct ast_device *ast, struct ast2300_dram_param *param) dlli = (dllmin[1 ] + dllmax[1 ]) >>1 ; dlli <<=8 ; dlli += (dllmin[0 ] + dllmax[0 ]) >>1 ; -ast_moutdwm (ast,AST_REG_MCR68 ,ast_mindwm (ast,0x1E720058 ) | (dlli <<16 )); +ast_moutdwm (ast,AST_REG_MCR68 ,ast_mindwm (ast,AST_REG_A2P58 ) | (dlli <<16 ));return status; }/* CBRDLL2 */
@@ -826,7 +826,7 @@ static void ddr3_init(struct ast_device *ast, struct ast2300_dram_param *param) data =ast_mindwm (ast,AST_REG_MCR1C ); data = (data >>8 ) &0xff ; } -ast_moutdwm (ast,0x1E720058 ,ast_mindwm (ast,AST_REG_MCR68 ) &0xffff ); +ast_moutdwm (ast,AST_REG_A2P58 ,ast_mindwm (ast,AST_REG_MCR68 ) &0xffff ); data =ast_mindwm (ast,AST_REG_MCR18 ) |0xC00 ;ast_moutdwm (ast,AST_REG_MCR18 , data);
@@ -1188,7 +1188,7 @@ static void ddr2_init(struct ast_device *ast, struct ast2300_dram_param *param) data =ast_mindwm (ast,AST_REG_MCR1C ); data = (data >>8 ) &0xff ; } -ast_moutdwm (ast,0x1E720058 ,ast_mindwm (ast,AST_REG_MCR08 ) &0xffff ); +ast_moutdwm (ast,AST_REG_A2P58 ,ast_mindwm (ast,AST_REG_MCR08 ) &0xffff ); data =ast_mindwm (ast,AST_REG_MCR18 ) |0xC00 ;ast_moutdwm (ast,AST_REG_MCR18 , data);
drivers/gpu/drm/ast/ast_reg.h +8 -0
@@ -188,4 +188,12 @@#define AST_REG_SCU104 AST_REG_SCU(0x104)#define AST_REG_SCU160 AST_REG_SCU(0x160) +/* +* AHB-to-P Bus Bridge (0x1e720000 - 0x1e73ffff) +*/ + +#define AST_REG_A2P_BASE (0x1e720000) +#define AST_REG_A2P (__offset) (AST_REG_A2P_BASE + (__offset)) +#define AST_REG_A2P58 AST_REG_A2P(0x58) +#endif
Signature · 1 line
2.53.0
Thomas Zimmermann
maintainerPATCH v2 7/15 drm/ast: Use constants for WDT registers
In reply to Thomas ZimmermannWDT is the Watchdog timer. WDC registers are located at the memory range at [0x1e785000, 0x1e785fff]. There are currently up to 8 watchdog timers in the range, of which 2 are being used by AST2500.
Refer to them with macros named AST_REG_WDT<n>, where <n> is the byte offset into the watchdog timer's memory range. Each macro also takes the index of the watchdog timer to access. A new watchdog timer starts at each 0x40 byte offset.
--- drivers/gpu/drm/ast/ast_2500.c | 20 ++++++++++---------- drivers/gpu/drm/ast/ast_reg.h | 13 +++++++++++++ 2 files changed, 23 insertions(+), 10 deletions(-)
drivers/gpu/drm/ast/ast_2500.c +10 -10
@@ -127,9 +127,9 @@ void ast_2500_patch_ahb(void __iomem *regs)* [1]:= 1:WDT will be cleeared and disabled after timeout occurs * [0]:= 1:WDT enable */ -__ast_moutdwm (regs,0x1E785004 ,0x00000010 ); -__ast_moutdwm (regs,0x1E785008 ,0x00004755 ); -__ast_moutdwm (regs,0x1E78500c ,0x00000033 ); +__ast_moutdwm (regs,AST_REG_WDT04 (0 ),0x00000010 ); +__ast_moutdwm (regs,AST_REG_WDT08 (0 ),0x00004755 ); +__ast_moutdwm (regs,AST_REG_WDT0C (0 ),0x00000033 );udelay (1000 ); }
@@ -304,12 +304,12 @@ static void set_mpll_2500(struct ast_device *ast)static void reset_mmc_2500 (struct ast_device *ast) { -ast_moutdwm (ast,0x1E78505C ,0x00000004 ); -ast_moutdwm (ast,0x1E785044 ,0x00000001 ); -ast_moutdwm (ast,0x1E785048 ,0x00004755 ); -ast_moutdwm (ast,0x1E78504C ,0x00000013 ); +ast_moutdwm (ast,AST_REG_WDT1C (1 ),0x00000004 ); +ast_moutdwm (ast,AST_REG_WDT04 (1 ),0x00000001 ); +ast_moutdwm (ast,AST_REG_WDT08 (1 ),0x00004755 ); +ast_moutdwm (ast,AST_REG_WDT0C (1 ),0x00000013 );mdelay (100 ); -ast_moutdwm (ast,0x1E785054 ,0x00000077 ); +ast_moutdwm (ast,AST_REG_WDT14 (1 ),0x00000077 );ast_moutdwm (ast,AST_REG_MCR00 ,AST_REG_MCR00_PROTECTION_KEY ); }
@@ -508,8 +508,8 @@ static void ast_post_chip_2500(struct ast_device *ast)ast_2500_patch_ahb (ast->regs);/* Disable watchdog */ -ast_moutdwm (ast,0x1E78502C ,0x00000000 ); -ast_moutdwm (ast,0x1E78504C ,0x00000000 ); +ast_moutdwm (ast,AST_REG_WDT2C (0 ),0x00000000 ); +ast_moutdwm (ast,AST_REG_WDT0C (1 ),0x00000000 );/* * Reset USB port to patch USB unknown device issue
drivers/gpu/drm/ast/ast_reg.h +13 -0
@@ -196,4 +196,17 @@#define AST_REG_A2P (__offset) (AST_REG_A2P_BASE + (__offset))#define AST_REG_A2P58 AST_REG_A2P(0x58) +/* +* Watchdog timer (0x1e785000 - 0x1e785fff) +*/ + +#define AST_REG_WDT_BASE (__n) (0x1e785000 + (__n) * 0x40) +#define AST_REG_WDT (__n, __offset) (AST_REG_WDT_BASE((__n)) + (__offset)) +#define AST_REG_WDT04 (__n) AST_REG_WDT((__n), 0x04) +#define AST_REG_WDT08 (__n) AST_REG_WDT((__n), 0x08) +#define AST_REG_WDT0C (__n) AST_REG_WDT((__n), 0x0c) +#define AST_REG_WDT14 (__n) AST_REG_WDT((__n), 0x14) +#define AST_REG_WDT1C (__n) AST_REG_WDT((__n), 0x1c) +#define AST_REG_WDT2C (__n) AST_REG_WDT((__n), 0x2c) +#endif
Signature · 1 line
2.53.0
Thomas Zimmermann
maintainerPATCH v2 8/15 drm/ast: Use constants for SDRAM registers
In reply to Thomas ZimmermannAspeed hardware allows for acceessing the SDRAM from the host. SDRAM registers are located at the memory range at [0x80000000, 0xffffffff].
Refer to memory access with the macro AST_SDRAM(). Also add a TODO item for the nonsensical documentation next to its caller.
--- drivers/gpu/drm/ast/ast_2500.c | 17 ++++++++++------- drivers/gpu/drm/ast/ast_reg.h | 7 +++++++ 2 files changed, 17 insertions(+), 7 deletions(-)
drivers/gpu/drm/ast/ast_2500.c +10 -7
@@ -225,6 +225,9 @@ static void ddr_phy_init_2500(struct ast_device *ast) }/* +* TODO: Review and fix the comments. The function below only detects +* up to 1 GiB of SDRAM. +* * Check DRAM Size * 1Gb : 0x80000000 ~ 0x87FFFFFF * 2Gb : 0x80000000 ~ 0x8FFFFFFF
@@ -238,21 +241,21 @@ static void check_dram_size_2500(struct ast_device *ast, u32 tRFC) reg_04 =ast_mindwm (ast,AST_REG_MCR04 ) &0xfffffffc ; reg_14 =ast_mindwm (ast,AST_REG_MCR14 ) &0xffffff00 ; -ast_moutdwm (ast,0xA0100000 ,0x41424344 ); -ast_moutdwm (ast,0x90100000 ,0x35363738 ); -ast_moutdwm (ast,0x88100000 ,0x292A2B2C ); -ast_moutdwm (ast,0x80100000 ,0x1D1E1F10 ); +ast_moutdwm (ast,AST_SDRAM (0x20100000 ),0x41424344 ); +ast_moutdwm (ast,AST_SDRAM (0x10100000 ),0x35363738 ); +ast_moutdwm (ast,AST_SDRAM (0x08100000 ),0x292A2B2C ); +ast_moutdwm (ast,AST_SDRAM (0x00100000 ),0x1D1E1F10 );/* Check 8Gbit */ -if (ast_mindwm (ast,0xA0100000 ) ==0x41424344 ) { +if (ast_mindwm (ast,AST_SDRAM (0x20100000 )) ==0x41424344 ) { reg_04 |=0x03 ; reg_14 |= (tRFC >>24 ) &0xFF ;/* Check 4Gbit */ - }else if (ast_mindwm (ast,0x90100000 ) ==0x35363738 ) { + }else if (ast_mindwm (ast,AST_SDRAM (0x10100000 )) ==0x35363738 ) { reg_04 |=0x02 ; reg_14 |= (tRFC >>16 ) &0xFF ;/* Check 2Gbit */ - }else if (ast_mindwm (ast,0x88100000 ) ==0x292A2B2C ) { + }else if (ast_mindwm (ast,AST_SDRAM (0x08100000 )) ==0x292A2B2C ) { reg_04 |=0x01 ; reg_14 |= (tRFC >>8 ) &0xFF ; }else {
drivers/gpu/drm/ast/ast_reg.h +7 -0
@@ -209,4 +209,11 @@#define AST_REG_WDT1C (__n) AST_REG_WDT((__n), 0x1c)#define AST_REG_WDT2C (__n) AST_REG_WDT((__n), 0x2c) +/* +* SDRAM (0x80000000 - 0xffffffff) +*/ + +#define AST_SDRAM_BASE (0x80000000) +#define AST_SDRAM (__offset) (AST_SDRAM_BASE + (__offset)) +#endif
Signature · 1 line
2.53.0
Thomas Zimmermann
maintainerPATCH v2 9/15 drm/ast: Store register addresses in struct ast_dramstruct
In reply to Thomas ZimmermannStruct ast_dramstruct contains a 16-bit index field that either contains a magic value or serves as index into the P2A address segment at 0x1e600000. This segment serves MCR and SCU registers, which the ast_dramstruct programs. It's fragile and relies upon the ast_post_chip_*() functions to set up the segment correctly.
Replace the 16-bit index with a full 32-bit address of the SCU and MCR addresses. Initialize the DRAM tables with full register constants and write them out with ast_moutdwm(). This sets the correct segment on each write.
Drop __AST_DRAMSTRUCT_DRAM_TYPE as it simply referred to MCR04. Use the latter for initializing the DRAM tables.
--- drivers/gpu/drm/ast/ast_2000.c | 43 ++++---- drivers/gpu/drm/ast/ast_2100.c | 195 ++++++++++++++++----------------- drivers/gpu/drm/ast/ast_post.h | 17 +-- drivers/gpu/drm/ast/ast_reg.h | 4 + 4 files changed, 131 insertions(+), 128 deletions(-)
drivers/gpu/drm/ast/ast_2000.c +21 -22
@@ -69,30 +69,30 @@ void ast_2000_set_def_ext_reg(struct ast_device *ast) }static const struct ast_dramstruct ast2000_dram_table_data[] = { - {0x0108 ,0x00000000 }, - {0x0120 ,0x00004a21 }, +AST_DRAMSTRUCT_REG (AST_REG_MCR108 ,0x00000000 ), +AST_DRAMSTRUCT_REG (AST_REG_MCR120 ,0x00004a21 ),AST_DRAMSTRUCT_UDELAY (67u ), - {0x0000 ,0xFFFFFFFF }, -AST_DRAMSTRUCT_INIT (DRAM_TYPE ,0x00000089 ), - {0x0008 ,0x22331353 }, - {0x000C ,0x0d07000b }, - {0x0010 ,0x11113333 }, - {0x0020 ,0x00110350 }, - {0x0028 ,0x1e0828f0 }, - {0x0024 ,0x00000001 }, - {0x001C ,0x00000000 }, - {0x0014 ,0x00000003 }, +AST_DRAMSTRUCT_REG (AST_REG_MCR00 ,0xffffffff ),/* FIXME: This locks the MCR registers. */ +AST_DRAMSTRUCT_REG (AST_REG_MCR04 ,0x00000089 ),/* DRAM type */ +AST_DRAMSTRUCT_REG (AST_REG_MCR08 ,0x22331353 ), +AST_DRAMSTRUCT_REG (AST_REG_MCR0C ,0x0d07000b ), +AST_DRAMSTRUCT_REG (AST_REG_MCR10 ,0x11113333 ), +AST_DRAMSTRUCT_REG (AST_REG_MCR20 ,0x00110350 ), +AST_DRAMSTRUCT_REG (AST_REG_MCR28 ,0x1e0828f0 ), +AST_DRAMSTRUCT_REG (AST_REG_MCR24 ,0x00000001 ), +AST_DRAMSTRUCT_REG (AST_REG_MCR1C ,0x00000000 ), +AST_DRAMSTRUCT_REG (AST_REG_MCR14 ,0x00000003 ),AST_DRAMSTRUCT_UDELAY (67u ), - {0x0018 ,0x00000131 }, - {0x0014 ,0x00000001 }, +AST_DRAMSTRUCT_REG (AST_REG_MCR18 ,0x00000131 ), +AST_DRAMSTRUCT_REG (AST_REG_MCR14 ,0x00000001 ),AST_DRAMSTRUCT_UDELAY (67u ), - {0x0018 ,0x00000031 }, - {0x0014 ,0x00000001 }, +AST_DRAMSTRUCT_REG (AST_REG_MCR18 ,0x00000031 ), +AST_DRAMSTRUCT_REG (AST_REG_MCR14 ,0x00000001 ),AST_DRAMSTRUCT_UDELAY (67u ), - {0x0028 ,0x1e0828f1 }, - {0x0024 ,0x00000003 }, - {0x002C ,0x1f0f28fb }, - {0x0030 ,0xFFFFFE01 }, +AST_DRAMSTRUCT_REG (AST_REG_MCR28 ,0x1e0828f1 ), +AST_DRAMSTRUCT_REG (AST_REG_MCR24 ,0x00000003 ), +AST_DRAMSTRUCT_REG (AST_REG_MCR2C ,0x1f0f28fb ), +AST_DRAMSTRUCT_REG (AST_REG_MCR30 ,0xfffffe01 ),AST_DRAMSTRUCT_INVALID , };
@@ -119,8 +119,7 @@ static void ast_post_chip_2000(struct ast_device *ast)for (i =0 ; i <15 ; i++)udelay (dram_reg_info->data); }else { -ast_write32 (ast,0x10000 + dram_reg_info->index, - dram_reg_info->data); +ast_moutdwm (ast, dram_reg_info->index, dram_reg_info->data); } dram_reg_info++; }
drivers/gpu/drm/ast/ast_2100.c +97 -98
222 lines not on this page · raw message
drivers/gpu/drm/ast/ast_post.h +9 -8
@@ -10,13 +10,10 @@ struct ast_device;/* DRAM timing tables */ struct ast_dramstruct { -u16 index; +u32 index;u32 data; }; -/* hardware fields */ -#define __AST_DRAMSTRUCT_DRAM_TYPE 0x0004 -/* control commands */ #define __AST_DRAMSTRUCT_UDELAY 0xff00#define __AST_DRAMSTRUCT_INVALID 0xffff
@@ -24,14 +21,18 @@ struct ast_dramstruct {#define __AST_DRAMSTRUCT_INDEX (_name) \ (__AST_DRAMSTRUCT_ ## _name) -#define AST_DRAMSTRUCT_INIT (_name, _value) \ - { __AST_DRAMSTRUCT_INDEX(_name), (_value) } +#define __AST_DRAMSTRUCT_INIT (_index, _value) \ + { (_index), (_value) } +#define AST_DRAMSTRUCT_REG (_reg, _value) \ + __AST_DRAMSTRUCT_INIT(_reg, _value)#define AST_DRAMSTRUCT_UDELAY (_usecs) \ - AST_DRAMSTRUCT_INIT(UDELAY, _usecs) + __AST_DRAMSTRUCT_INIT(__AST_DRAMSTRUCT_UDELAY, _usecs)#define AST_DRAMSTRUCT_INVALID \ - AST_DRAMSTRUCT_INIT(INVALID, U32_MAX) + __AST_DRAMSTRUCT_INIT(__AST_DRAMSTRUCT_INVALID, U32_MAX) +#define AST_DRAMSTRUCT_IS_REG (_entry, _reg) \ + ((_entry)->index == (_reg))#define AST_DRAMSTRUCT_IS (_entry, _name) \ ((_entry)->index == __AST_DRAMSTRUCT_INDEX(_name))
drivers/gpu/drm/ast/ast_reg.h +4 -0
@@ -120,12 +120,15 @@#define AST_REG_MCR30 AST_REG_MCR(0x30)#define AST_REG_MCR34 AST_REG_MCR(0x34)#define AST_REG_MCR38 AST_REG_MCR(0x38) +#define AST_REG_MCR3C AST_REG_MCR(0x3c)#define AST_REG_MCR40 AST_REG_MCR(0x40)#define AST_REG_MCR44 AST_REG_MCR(0x44)#define AST_REG_MCR48 AST_REG_MCR(0x48)#define AST_REG_MCR4C AST_REG_MCR(0x4C)#define AST_REG_MCR50 AST_REG_MCR(0x50)#define AST_REG_MCR54 AST_REG_MCR(0x54) +#define AST_REG_MCR58 AST_REG_MCR(0x58) +#define AST_REG_MCR5C AST_REG_MCR(0x5c)#define AST_REG_MCR60 AST_REG_MCR(0x60)#define AST_REG_MCR64 AST_REG_MCR(0x64)#define AST_REG_MCR68 AST_REG_MCR(0x68)
@@ -137,6 +140,7 @@#define AST_REG_MCR80 AST_REG_MCR(0x80)#define AST_REG_MCR84 AST_REG_MCR(0x84)#define AST_REG_MCR88 AST_REG_MCR(0x88) +#define AST_REG_MCR108 AST_REG_MCR(0x108)#define AST_REG_MCR120 AST_REG_MCR(0x120)#define AST_REG_MCR200 AST_REG_MCR(0x200)#define AST_REG_MCR204 AST_REG_MCR(0x204)
Signature · 1 line
2.53.0
Thomas Zimmermann
maintainerPATCH v2 10/15 drm/ast: Gen1: Fix open-coded register access
In reply to Thomas ZimmermannReplace all open-coded access to MCR registers in Gen1 with the appropriate calls to ast_moutdwm() and ast_mindwm(). Use MCR register constants.
For the poll loop on MCR100, add ast_moutdwm_poll(). The helper polls the register until it has been updated to the given value. Relax the CPU while busy-waiting.
--- drivers/gpu/drm/ast/ast_2000.c | 18 +++++++----------- drivers/gpu/drm/ast/ast_drv.c | 12 ++++++++++++ drivers/gpu/drm/ast/ast_drv.h | 1 + drivers/gpu/drm/ast/ast_reg.h | 2 ++ 4 files changed, 22 insertions(+), 11 deletions(-)
drivers/gpu/drm/ast/ast_2000.c +7 -11
@@ -99,20 +99,15 @@ static const struct ast_dramstruct ast2000_dram_table_data[] = {static void ast_post_chip_2000 (struct ast_device *ast) {u8 j; -u32 temp, i; -const struct ast_dramstruct *dram_reg_info; +u32 i; j =ast_get_index_reg_mask (ast,AST_IO_VGACRI ,0xd0 ,0xff );if ((j &0x80 ) ==0 ) {/* VGA only */ - dram_reg_info = ast2000_dram_table_data; -ast_write32 (ast,0xf004 ,AST_REG_MCR00 ); -ast_write32 (ast,0xf000 ,0x1 ); -ast_write32 (ast,0x10100 ,0xa8 ); +const struct ast_dramstruct *dram_reg_info = ast2000_dram_table_data; +u32 mcr140; -do { - ; - }while (ast_read32 (ast,0x10100 ) !=0xa8 ); +ast_moutdwm_poll (ast,AST_REG_MCR100 ,0xa8 ,0xa8 );while (!AST_DRAMSTRUCT_IS (dram_reg_info,INVALID )) {if (AST_DRAMSTRUCT_IS (dram_reg_info,UDELAY )) {
@@ -124,8 +119,9 @@ static void ast_post_chip_2000(struct ast_device *ast) dram_reg_info++; } - temp =ast_read32 (ast,0x10140 ); -ast_write32 (ast,0x10140 , temp |0x40 ); + mcr140 =ast_mindwm (ast,AST_REG_MCR140 ); + mcr140 |=0x00000040 ; +ast_moutdwm (ast,AST_REG_MCR140 , mcr140); }/* wait ready */
drivers/gpu/drm/ast/ast_drv.c +12 -0
@@ -102,6 +102,18 @@ void ast_moutdwm(struct ast_device *ast, u32 r, u32 v)__ast_moutdwm (ast->regs, r, v); } +void ast_moutdwm_poll (struct ast_device *ast,u32 r,u32 v,u32 res) +{ +void __iomem *regs = ast->regs; + +__ast_selseg (regs, r); +__ast_wrseg32 (regs, r, v); + +do { +cpu_relax (); + }while (__ast_rdseg32 (regs, r) != res); +} +/* * AST device */
drivers/gpu/drm/ast/ast_drv.h +1 -0
@@ -361,6 +361,7 @@ u32 __ast_mindwm(void __iomem *regs, u32 r);void __ast_moutdwm (void __iomem *regs,u32 r,u32 v);u32 ast_mindwm (struct ast_device *ast,u32 r);void ast_moutdwm (struct ast_device *ast,u32 r,u32 v); +void ast_moutdwm_poll (struct ast_device *ast,u32 r,u32 v,u32 res);/* * VBIOS
drivers/gpu/drm/ast/ast_reg.h +2 -0
@@ -140,8 +140,10 @@#define AST_REG_MCR80 AST_REG_MCR(0x80)#define AST_REG_MCR84 AST_REG_MCR(0x84)#define AST_REG_MCR88 AST_REG_MCR(0x88) +#define AST_REG_MCR100 AST_REG_MCR(0x100)#define AST_REG_MCR108 AST_REG_MCR(0x108)#define AST_REG_MCR120 AST_REG_MCR(0x120) +#define AST_REG_MCR140 AST_REG_MCR(0x140)#define AST_REG_MCR200 AST_REG_MCR(0x200)#define AST_REG_MCR204 AST_REG_MCR(0x204)#define AST_REG_MCR208 AST_REG_MCR(0x208)
Signature · 1 line
2.53.0
Thomas Zimmermann
maintainerPATCH v2 11/15 drm/ast: Gen2: Fix open-coded register access
In reply to Thomas ZimmermannReplace all open-coded access to MCR and SCU registers in Gen2 with the appropriate calls to ast_moutdwm() and ast_mindwm(). Use MCR and SCU register constants. Name variables according to registers.
The values in MCR04 that control VRAM allocation do not look correct. Leave a FIXME comment for later investigation.
--- drivers/gpu/drm/ast/ast_2100.c | 73 ++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 35 deletions(-)
drivers/gpu/drm/ast/ast_2100.c +38 -35
@@ -40,21 +40,19 @@static enum ast_dram_layout ast_2100_get_dram_layout_p2a (struct ast_device *ast) { -u32 mcr_cfg; +u32 mcr04;enum ast_dram_layout dram_layout; -ast_write32 (ast,0xf004 ,AST_REG_MCR00 ); -ast_write32 (ast,0xf000 ,0x1 ); - mcr_cfg =ast_read32 (ast,0x10004 ); + mcr04 =ast_mindwm (ast,AST_REG_MCR04 ); -switch (mcr_cfg &0x0c ) { +switch (mcr04 &GENMASK (3 ,2 )) {case 0 :case 4 :default : dram_layout = AST_DRAM_512Mx16;break ;case 8 : -if (mcr_cfg &0x40 ) +if (mcr04 &0x40 ) dram_layout = AST_DRAM_1Gx16;else dram_layout = AST_DRAM_512Mx32;
@@ -300,51 +298,52 @@ static void cbrdlli_ast2150(struct ast_device *ast, int busw)static void ast_post_chip_2100 (struct ast_device *ast) {u8 j; -u32 data, temp, i; -const struct ast_dramstruct *dram_reg_info; -enum ast_dram_layout dram_layout =ast_2100_get_dram_layout_p2a (ast); +u32 i; +enum ast_dram_layout dram_layout =ast_2100_get_dram_layout_p2a (ast); +u32 mcr120; +u32 scu00c, scu040; j =ast_get_index_reg_mask (ast,AST_IO_VGACRI ,0xd0 ,0xff );if ((j &0x80 ) ==0 ) {/* VGA only */ +const struct ast_dramstruct *dram_reg_info; +if (ast->chip ==AST2100 || ast->chip ==AST2200 ) dram_reg_info = ast2100_dram_table_data;else dram_reg_info = ast1100_dram_table_data; -ast_write32 (ast,0xf004 ,AST_REG_MCR00 ); -ast_write32 (ast,0xf000 ,0x1 ); -ast_write32 (ast,0x12000 ,0x1688A8A8 ); -do { - ; - }while (ast_read32 (ast,0x12000 ) !=0x01 ); - -ast_write32 (ast,0x10000 ,0xfc600309 ); -do { - ; - }while (ast_read32 (ast,0x10000 ) !=0x01 ); +ast_moutdwm_poll (ast,AST_REG_SCU000 ,AST_REG_SCU000_PROTECTION_KEY ,0x01 ); +ast_moutdwm_poll (ast,AST_REG_MCR00 ,AST_REG_MCR00_PROTECTION_KEY ,0x01 );while (!AST_DRAMSTRUCT_IS (dram_reg_info,INVALID )) {if (AST_DRAMSTRUCT_IS (dram_reg_info,UDELAY )) {for (i =0 ; i <15 ; i++)udelay (dram_reg_info->data); }else if (AST_DRAMSTRUCT_IS_REG (dram_reg_info,AST_REG_MCR04 )) { +u32 mcr04; +u32 scu070; +switch (dram_layout) {case AST_DRAM_1Gx16: - data =0x00000d89 ; + mcr04 =0x00000d89 ;break ;case AST_DRAM_1Gx32: - data =0x00000c8d ; + mcr04 =0x00000c8d ;break ;default : - data = dram_reg_info->data; + mcr04 = dram_reg_info->data;break ; } - temp =ast_read32 (ast,0x12070 ); - temp &=0xc ; - temp <<=2 ; -ast_moutdwm (ast, dram_reg_info->index, data | temp); +/* +* FIXME: There might be bits already in MCR04[5:4]. Should +* we only do this in the default case? +*/ + scu070 =ast_mindwm (ast,AST_REG_SCU070 ); + mcr04 |= (scu070 &GENMASK (3 ,2 )) <<2 ; + +ast_moutdwm (ast, dram_reg_info->index, mcr04); }else {ast_moutdwm (ast, dram_reg_info->index, dram_reg_info->data); }
@@ -352,19 +351,23 @@ static void ast_post_chip_2100(struct ast_device *ast) }/* AST 2100/2150 DRAM calibration */ - data =ast_read32 (ast,0x10120 ); -if (data ==0x5061 ) {/* 266Mhz */ - data =ast_read32 (ast,0x10004 ); -if (data &0x40 ) + mcr120 =ast_mindwm (ast,AST_REG_MCR120 ); +if (mcr120 ==0x5061 ) {/* 266Mhz */ +u32 mcr04 =ast_mindwm (ast,AST_REG_MCR04 ); + +if (mcr04 &0x40 )cbrdlli_ast2150 (ast,16 );/* 16 bits */ else cbrdlli_ast2150 (ast,32 );/* 32 bits */ } - temp =ast_read32 (ast,0x1200c ); -ast_write32 (ast,0x1200c , temp &0xfffffffd ); - temp =ast_read32 (ast,0x12040 ); -ast_write32 (ast,0x12040 , temp |0x40 ); + scu00c =ast_mindwm (ast,AST_REG_SCU00C ); + scu00c &=0xfffffffd ; +ast_moutdwm (ast,AST_REG_SCU00C , scu00c); + + scu040 =ast_mindwm (ast,AST_REG_SCU040 ); + scu040 |=0x00000040 ; +ast_moutdwm (ast,AST_REG_SCU040 , scu040); }/* wait ready */
Signature · 1 line
2.53.0
Thomas Zimmermann
maintainerPATCH v2 12/15 drm/ast: Gen4: Fix open-coded register access
In reply to Thomas ZimmermannReplace all open-coded access to MCR and SCU registers in Gen4 with the appropriate calls to ast_moutdwm() and ast_mindwm(). Use MCR and SCU register constants. Name variables according to registers.
--- drivers/gpu/drm/ast/ast_2300.c | 24 +++++++++--------------- drivers/gpu/drm/ast/ast_reg.h | 1 + 2 files changed, 10 insertions(+), 15 deletions(-)
drivers/gpu/drm/ast/ast_2300.c +9 -15
@@ -1245,22 +1245,15 @@ static void ast_post_chip_2300(struct ast_device *ast) reg =ast_get_index_reg_mask (ast,AST_IO_VGACRI ,0xd0 ,0xff );if ((reg &0x80 ) ==0 ) {/* vga only */ -ast_write32 (ast,0xf004 ,AST_REG_MCR00 ); -ast_write32 (ast,0xf000 ,0x1 ); -ast_write32 (ast,0x12000 ,0x1688a8a8 ); -do { - ; - }while (ast_read32 (ast,0x12000 ) !=0x1 ); +u32 scu008, scu040; -ast_write32 (ast,0x10000 ,0xfc600309 ); -do { - ; - }while (ast_read32 (ast,0x10000 ) !=0x1 ); +ast_moutdwm_poll (ast,AST_REG_SCU000 ,AST_REG_SCU000_PROTECTION_KEY ,0x01 ); +ast_moutdwm_poll (ast,AST_REG_MCR00 ,AST_REG_MCR00_PROTECTION_KEY ,0x01 );/* Slow down CPU/AHB CLK in VGA only mode */ - temp =ast_read32 (ast,0x12008 ); - temp |=0x73 ; -ast_write32 (ast,0x12008 , temp); + scu008 =ast_mindwm (ast,AST_REG_SCU008 ); + scu008 |=0x00000073 ; +ast_moutdwm (ast,AST_REG_SCU008 , scu008); param.dram_freq =396 ; param.dram_type =AST_DDR3 ;
@@ -1306,8 +1299,9 @@ static void ast_post_chip_2300(struct ast_device *ast)ddr2_init (ast, ¶m); } - temp =ast_mindwm (ast,AST_REG_SCU040 ); -ast_moutdwm (ast,AST_REG_SCU040 , temp |0x40 ); + scu040 =ast_mindwm (ast,AST_REG_SCU040 ); + scu040 |=0x00000040 ; +ast_moutdwm (ast,AST_REG_SCU040 , scu040); }/* wait ready */
drivers/gpu/drm/ast/ast_reg.h +1 -0
@@ -183,6 +183,7 @@#define AST_REG_SCU (__offset) (AST_REG_SCU_BASE + (__offset))#define AST_REG_SCU000 AST_REG_SCU(0x000)#define AST_REG_SCU000_PROTECTION_KEY (0x1688a8a8) +#define AST_REG_SCU008 AST_REG_SCU(0x008)#define AST_REG_SCU00C AST_REG_SCU(0x00c)#define AST_REG_SCU020 AST_REG_SCU(0x020)#define AST_REG_SCU040 AST_REG_SCU(0x040)
Signature · 1 line
2.53.0
Thomas Zimmermann
maintainerPATCH v2 13/15 drm/ast: Gen6: Fix open-coded register access
In reply to Thomas ZimmermannReplace all open-coded access to MCR and SCU registers in Gen6 with the appropriate calls to ast_moutdwm() and ast_mindwm(). Use MCR and SCU register constants. Name variables according to registers.
v2:
- also fix MCR constants
--- drivers/gpu/drm/ast/ast_2500.c | 16 ++++++++-------- drivers/gpu/drm/ast/ast_reg.h | 1 + 2 files changed, 9 insertions(+), 8 deletions(-)
drivers/gpu/drm/ast/ast_2500.c +8 -8
@@ -280,15 +280,13 @@ static void enable_cache_2500(struct ast_device *ast)static void set_mpll_2500 (struct ast_device *ast) { -u32 addr, data, param; +u32 mcr, data, param;/* Reset MMC */ ast_moutdwm (ast,AST_REG_MCR00 ,AST_REG_MCR00_PROTECTION_KEY );ast_moutdwm (ast,AST_REG_MCR34 ,0x00020080 ); -for (addr =0x1e6e0004 ; addr <0x1e6e0090 ;) { -ast_moutdwm (ast, addr,0x0 ); - addr +=4 ; - } +for (mcr =AST_REG_MCR04 ; mcr <=AST_REG_MCR8C ; mcr +=4 ) +ast_moutdwm (ast, mcr,0x00000000 );ast_moutdwm (ast,AST_REG_MCR34 ,0x00020000 );ast_moutdwm (ast,AST_REG_SCU000 ,AST_REG_SCU000_PROTECTION_KEY );
@@ -507,6 +505,8 @@ static void ast_post_chip_2500(struct ast_device *ast) reg =ast_get_index_reg_mask (ast,AST_IO_VGACRI ,0xd0 ,0xff );if ((reg &AST_IO_VGACRD0_VRAM_INIT_STATUS_MASK ) ==0 ) {/* vga only */ +u32 scu008; +/* Clear bus lock condition */ ast_2500_patch_ahb (ast->regs);
@@ -540,9 +540,9 @@ static void ast_post_chip_2500(struct ast_device *ast)ast_moutdwm (ast,AST_REG_SCU07C ,0x00004000 );/* Slow down CPU/AHB CLK in VGA only mode */ - temp =ast_read32 (ast,0x12008 ); - temp |=0x73 ; -ast_write32 (ast,0x12008 , temp); + scu008 =ast_mindwm (ast,AST_REG_SCU008 ); + scu008 |=0x00000073 ; +ast_moutdwm (ast,AST_REG_SCU008 , scu008);if (!ast_dram_init_2500 (ast))drm_err (dev,"DRAM init failed !\n" );
drivers/gpu/drm/ast/ast_reg.h +1 -0
@@ -140,6 +140,7 @@#define AST_REG_MCR80 AST_REG_MCR(0x80)#define AST_REG_MCR84 AST_REG_MCR(0x84)#define AST_REG_MCR88 AST_REG_MCR(0x88) +#define AST_REG_MCR8C AST_REG_MCR(0x8c)#define AST_REG_MCR100 AST_REG_MCR(0x100)#define AST_REG_MCR108 AST_REG_MCR(0x108)#define AST_REG_MCR120 AST_REG_MCR(0x120)
Signature · 1 line
2.53.0
Thomas Zimmermann
maintainerPATCH v2 14/15 drm/ast: dp501: Fix open-coded register access
In reply to Thomas ZimmermannReplace all open-coded access to SCU registers in DP501 support with the appropriate calls to ast_moutdwm() and ast_mindwm(). Use SCU register constants. Name variables according to registers.
--- drivers/gpu/drm/ast/ast_dp501.c | 124 +++++++++++++++----------------- drivers/gpu/drm/ast/ast_reg.h | 6 ++ 2 files changed, 64 insertions(+), 66 deletions(-)
drivers/gpu/drm/ast/ast_dp501.c +58 -66
@@ -347,68 +347,65 @@ static int ast_dp512_read_edid_block(void *data, u8 *buf, unsigned int block, sistatic bool ast_init_dvo (struct ast_device *ast) {u8 jreg; -u32 data; -ast_write32 (ast,0xf004 ,AST_REG_MCR00 ); -ast_write32 (ast,0xf000 ,0x1 ); -ast_write32 (ast,0x12000 ,0x1688a8a8 ); +u32 scu02c; + +ast_moutdwm (ast,AST_REG_SCU000 ,AST_REG_SCU000_PROTECTION_KEY ); jreg =ast_get_index_reg_mask (ast,AST_IO_VGACRI ,0xd0 ,0xff );if (!(jreg &0x80 )) { +u32 scu008; +/* Init SCU DVO Settings */ - data =ast_read32 (ast,0x12008 ); -/* delay phase */ - data &=0xfffff8ff ; - data |=0x00000500 ; -ast_write32 (ast,0x12008 , data); + + scu008 =ast_mindwm (ast,AST_REG_SCU008 ); + scu008 &=0xfffff8ff ; + scu008 |=0x00000500 ;/* delay phase */ +ast_moutdwm (ast,AST_REG_SCU008 , scu008);if (IS_AST_GEN4 (ast)) { - data =ast_read32 (ast,0x12084 ); -/* multi-pins for DVO single-edge */ - data |=0xfffe0000 ; -ast_write32 (ast,0x12084 , data); - - data =ast_read32 (ast,0x12088 ); -/* multi-pins for DVO single-edge */ - data |=0x000fffff ; -ast_write32 (ast,0x12088 , data); - - data =ast_read32 (ast,0x12090 ); -/* multi-pins for DVO single-edge */ - data &=0xffffffcf ; - data |=0x00000020 ; -ast_write32 (ast,0x12090 , data); +u32 scu084, scu088, scu090; + + scu084 =ast_mindwm (ast,AST_REG_SCU084 ); + scu084 |=0xfffe0000 ;/* multi-pins for DVO single-edge */ +ast_moutdwm (ast,AST_REG_SCU084 , scu084); + + scu088 =ast_mindwm (ast,AST_REG_SCU088 ); + scu088 |=0x000fffff ;/* multi-pins for DVO single-edge */ +ast_moutdwm (ast,AST_REG_SCU088 , scu088); + + scu090 =ast_mindwm (ast,AST_REG_SCU090 ); + scu090 &=0xffffffcf ; + scu090 |=0x00000020 ;/* multi-pins for DVO single-edge */ +ast_moutdwm (ast,AST_REG_SCU090 , scu090); }else {/* AST GEN5+ */ - data =ast_read32 (ast,0x12088 ); -/* multi-pins for DVO single-edge */ - data |=0x30000000 ; -ast_write32 (ast,0x12088 , data); - - data =ast_read32 (ast,0x1208c ); -/* multi-pins for DVO single-edge */ - data |=0x000000cf ; -ast_write32 (ast,0x1208c , data); - - data =ast_read32 (ast,0x120a4 ); -/* multi-pins for DVO single-edge */ - data |=0xffff0000 ; -ast_write32 (ast,0x120a4 , data); - - data =ast_read32 (ast,0x120a8 ); -/* multi-pins for DVO single-edge */ - data |=0x0000000f ; -ast_write32 (ast,0x120a8 , data); - - data =ast_read32 (ast,0x12094 ); -/* multi-pins for DVO single-edge */ - data |=0x00000002 ; -ast_write32 (ast,0x12094 , data); +u32 scu088, scu08c, scu0a4, scu0a8, scu094; + + scu088 =ast_mindwm (ast,AST_REG_SCU088 ); + scu088 |=0x30000000 ;/* multi-pins for DVO single-edge */ +ast_moutdwm (ast,AST_REG_SCU088 , scu088); + + scu08c =ast_mindwm (ast,AST_REG_SCU08C ); + scu08c |=0x000000cf ;/* multi-pins for DVO single-edge */ +ast_moutdwm (ast,AST_REG_SCU08C , scu08c); + + scu0a4 =ast_mindwm (ast,AST_REG_SCU0A4 ); + scu0a4 |=0xffff0000 ;/* multi-pins for DVO single-edge */ +ast_moutdwm (ast,AST_REG_SCU0A4 , scu0a4); + + scu0a8 =ast_mindwm (ast,AST_REG_SCU0A8 ); + scu0a8 |=0x0000000f ;/* multi-pins for DVO single-edge */ +ast_moutdwm (ast,AST_REG_SCU0A8 , scu0a8); + + scu094 =ast_mindwm (ast,AST_REG_SCU094 ); + scu094 |=0x00000002 ;/* multi-pins for DVO single-edge */ +ast_moutdwm (ast,AST_REG_SCU094 , scu094); } }/* Force to DVO */ - data =ast_read32 (ast,0x1202c ); - data &=0xfffbffff ; -ast_write32 (ast,0x1202c , data); + scu02c =ast_mindwm (ast,AST_REG_SCU02C ); + scu02c &=0xfffbffff ; +ast_moutdwm (ast,AST_REG_SCU02C , scu02c);/* Init VGA DVO Settings */ ast_set_index_reg_mask (ast,AST_IO_VGACRI ,0xa3 ,0xcf ,0x80 );
@@ -418,25 +415,20 @@ static bool ast_init_dvo(struct ast_device *ast)static void ast_init_analog (struct ast_device *ast) { -u32 data; +u32 scu02c;/* * Set DAC source to VGA mode in SCU2C via the P2A -* bridge. First configure the P2U to target the SCU -* in case it isn't at this stage. +* bridge. */ -ast_write32 (ast,0xf004 ,AST_REG_MCR00 ); -ast_write32 (ast,0xf000 ,0x1 ); - -/* Then unlock the SCU with the magic password */ -ast_write32 (ast,0x12000 ,0x1688a8a8 ); -ast_write32 (ast,0x12000 ,0x1688a8a8 ); -ast_write32 (ast,0x12000 ,0x1688a8a8 ); - -/* Finally, clear bits [17:16] of SCU2c */ - data =ast_read32 (ast,0x1202c ); - data &=0xfffcffff ; -ast_write32 (ast,0x1202c , data); + +/* Unlock the SCU with the magic password */ +ast_moutdwm_poll (ast,AST_REG_SCU000 ,AST_REG_SCU000_PROTECTION_KEY ,0x01 ); + +/* Clear bits [17:16] of SCU2C */ + scu02c =ast_mindwm (ast,AST_REG_SCU02C ); + scu02c &=0xfffcffff ; +ast_moutdwm (ast,AST_REG_SCU02C , scu02c);/* Disable DVO */ ast_set_index_reg_mask (ast,AST_IO_VGACRI ,0xa3 ,0xcf ,0x00 );
drivers/gpu/drm/ast/ast_reg.h +6 -0
@@ -187,11 +187,17 @@#define AST_REG_SCU008 AST_REG_SCU(0x008)#define AST_REG_SCU00C AST_REG_SCU(0x00c)#define AST_REG_SCU020 AST_REG_SCU(0x020) +#define AST_REG_SCU02C AST_REG_SCU(0x02c)#define AST_REG_SCU040 AST_REG_SCU(0x040)#define AST_REG_SCU070 AST_REG_SCU(0x070)#define AST_REG_SCU07C AST_REG_SCU(0x07c) +#define AST_REG_SCU084 AST_REG_SCU(0x084) +#define AST_REG_SCU088 AST_REG_SCU(0x088) +#define AST_REG_SCU08C AST_REG_SCU(0x08c)#define AST_REG_SCU090 AST_REG_SCU(0x090)#define AST_REG_SCU094 AST_REG_SCU(0x094) +#define AST_REG_SCU0A4 AST_REG_SCU(0x0a4) +#define AST_REG_SCU0A8 AST_REG_SCU(0x0a8)#define AST_REG_SCU100 AST_REG_SCU(0x100)#define AST_REG_SCU104 AST_REG_SCU(0x104)#define AST_REG_SCU160 AST_REG_SCU(0x160)
Signature · 1 line
2.53.0
Thomas Zimmermann
maintainerPATCH v2 15/15 drm/ast: Fix open-coded scu_rev access
In reply to Thomas ZimmermannReplace all open-coded access to P2A and SCU registers in the device detection with the appropriate calls to ast_moutdwm() and ast_mindwm(). Use P2A and MCR register constants. Name variables according to registers.
--- drivers/gpu/drm/ast/ast_drv.c | 13 ++++++------- drivers/gpu/drm/ast/ast_reg.h | 1 + 2 files changed, 7 insertions(+), 7 deletions(-)
drivers/gpu/drm/ast/ast_drv.c +6 -7
@@ -242,7 +242,7 @@ static int ast_detect_chip(struct pci_dev *pdev,enum ast_config_mode config_mode = ast_use_defaults;uint32_t scu_rev =0xffffffff ;enum ast_chip chip; -u32 data; +u32 data, p2a04, scu07c;u8 vgacrd0, vgacrd1;/*
@@ -275,14 +275,13 @@ static int ast_detect_chip(struct pci_dev *pdev, }/* Double check that it's actually working */ - data =__ast_read32 (regs,0xf004 ); -if ((data !=0xffffffff ) && (data !=0x00 )) { + p2a04 =__ast_read32 (regs,AST_REG_P2A04 ); +if (p2a04 !=0xffffffff && p2a04 !=0x00000000 ) { config_mode = ast_use_p2a; -/* Read SCU7c (silicon revision register) */ -__ast_write32 (regs,0xf004 ,AST_REG_MCR00 ); -__ast_write32 (regs,0xf000 ,0x1 ); - scu_rev =__ast_read32 (regs,0x1207c ); +/* Read SCU7C (silicon revision register) */ + scu07c =__ast_mindwm (regs,AST_REG_SCU07C ); + scu_rev = scu07c &AST_REG_SCU07C_CHIP_BONDING_MASK ; } } }
drivers/gpu/drm/ast/ast_reg.h +1 -0
@@ -191,6 +191,7 @@#define AST_REG_SCU040 AST_REG_SCU(0x040)#define AST_REG_SCU070 AST_REG_SCU(0x070)#define AST_REG_SCU07C AST_REG_SCU(0x07c) +#define AST_REG_SCU07C_CHIP_BONDING_MASK GENMASK(15, 8)#define AST_REG_SCU084 AST_REG_SCU(0x084)#define AST_REG_SCU088 AST_REG_SCU(0x088)#define AST_REG_SCU08C AST_REG_SCU(0x08c)
Signature · 1 line
2.53.0