]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/ast: Use constants for SDRAM registers
authorThomas Zimmermann <tzimmermann@suse.de>
Fri, 27 Mar 2026 13:33:00 +0000 (14:33 +0100)
committerThomas Zimmermann <tzimmermann@suse.de>
Wed, 8 Apr 2026 09:04:49 +0000 (11:04 +0200)
Aspeed 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.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>
Link: https://patch.msgid.link/20260327133532.79696-9-tzimmermann@suse.de
drivers/gpu/drm/ast/ast_2500.c
drivers/gpu/drm/ast/ast_reg.h

index f0639f1ef062a8cd2845f7cffa95b7c602bc8796..39f401dd1f4783b8f426800e1d03d44347981c80 100644 (file)
@@ -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 {
index 5effe6897b51a37fd937d6b3e4baad20025abc25..78fabe2a9c8104f61381281cf63d2d55668371f0 100644 (file)
 #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