Skip to contentSkip to conversation

drm/ast: Split POST code per hardware gen

PATCH New Thomas Zimmermann 1 participant 11 messages Jul 6, 2025

Subsystems (3)
lore
Share & tools
lore

Thomas Zimmermann

author maintainer
#0 lore raw

v2 cover drm/ast: Split POST code per hardware gen

Move the POST code for each hardware generation into a separate source file. Split some functions per gen, as necessary. Makes the code more maintainable. Support for future hardware generations can now be added easily in a new source file without interfering with existing code.

Gen3 and Gen5 share their POST code with earlier hardware generations. The other generations have individual POST. Patch 1 makes the few shared cross-gen helpers available.

Patches 2 to 5 move individual POST functionality into separate files, split by hardware generation and addresses some coding-style issues.

Patches 6 and 7 fix the use of struct ast_dramstruct to be less of a blackbox. It's used for DRAM initialization in Gen1 and Gen2 hardware.

Patch 8 splits up default settings for various registers. This brings up an issue with Gen7, which likely uses outdated values from Gen1.

Patches 9 and 10 attempt to fix the default settings for Gen7. It's done separately from the rest, so it can be bisected and reverted easily, if necessary.

Tested on AST2600 (Gen7) and AST2500 (Gen6).

v2:
- gen7: simplify logic (Jocelyn)

Thomas Zimmermann (10):
drm/ast: Declare helpers for POST in header
drm/ast: Move Gen7+ POST code to separate source file drm/ast: Move Gen6+ POST code to separate source file drm/ast: Move Gen4+ POST code to separate source file drm/ast: Move Gen2+ and Gen1 POST code to separate source files drm/ast: Move struct ast_dramstruct to ast_post.h drm/ast: Handle known struct ast_dramstruct with helpers drm/ast: Split ast_set_def_ext_reg() by chip generation drm/ast: Gen7: Disable VGASR0[1] as on Gen4+
drm/ast: Gen7: Switch default registers to gen4+ state

 drivers/gpu/drm/ast/Makefile          |    5 +
 drivers/gpu/drm/ast/ast_2000.c        |  149 ++
 drivers/gpu/drm/ast/ast_2100.c        |  348 +++++
 drivers/gpu/drm/ast/ast_2300.c        | 1328 ++++++++++++++++
 drivers/gpu/drm/ast/ast_2500.c        |  569 +++++++
 drivers/gpu/drm/ast/ast_2600.c        |   44 +
 drivers/gpu/drm/ast/ast_dram_tables.h |  207 ---
 drivers/gpu/drm/ast/ast_drv.c         |    2 +-
 drivers/gpu/drm/ast/ast_drv.h         |   17 +-
 drivers/gpu/drm/ast/ast_post.c        | 2027 +------------------------
 drivers/gpu/drm/ast/ast_post.h        |   50 +
 11 files changed, 2531 insertions(+), 2215 deletions(-)
 create mode 100644 drivers/gpu/drm/ast/ast_2000.c
 create mode 100644 drivers/gpu/drm/ast/ast_2100.c
 create mode 100644 drivers/gpu/drm/ast/ast_2300.c
 create mode 100644 drivers/gpu/drm/ast/ast_2500.c
 create mode 100644 drivers/gpu/drm/ast/ast_2600.c
 delete mode 100644 drivers/gpu/drm/ast/ast_dram_tables.h
 create mode 100644 drivers/gpu/drm/ast/ast_post.h
Signature · 1 line
2.50.0
author maintainer
#1 lore raw

PATCH v2 1/10 drm/ast: Declare helpers for POST in header

Provide POST helpers in header file before splitting up the AST POST code.

---
 drivers/gpu/drm/ast/ast_post.c | 10 +++++-----
 drivers/gpu/drm/ast/ast_post.h | 16 ++++++++++++++++
 2 files changed, 21 insertions(+), 5 deletions(-)
 create mode 100644 drivers/gpu/drm/ast/ast_post.h
drivers/gpu/drm/ast/ast_post.c +5 -5
index 37568cf3822c..36542d266f9c 100644
@@ -33,6 +33,7 @@
 
 #include "ast_dram_tables.h"
 #include "ast_drv.h"
+#include "ast_post.h"
 
 static void ast_post_chip_2300(struct ast_device *ast);
 static void ast_post_chip_2500(struct ast_device *ast);
@@ -75,7 +76,7 @@ static void ast_set_def_ext_reg(struct ast_device *ast)
 	ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xb6, 0xff, reg);
 }
 
-static u32 __ast_mindwm(void __iomem *regs, u32 r)
+u32 __ast_mindwm(void __iomem *regs, u32 r)
 {
 	u32 data;
 
@@ -89,7 +90,7 @@ static u32 __ast_mindwm(void __iomem *regs, u32 r)
 	return __ast_read32(regs, 0x10000 + (r & 0x0000ffff));
 }
 
-static void __ast_moutdwm(void __iomem *regs, u32 r, u32 v)
+void __ast_moutdwm(void __iomem *regs, u32 r, u32 v)
 {
 	u32 data;
 
@@ -438,7 +439,7 @@ static const u32 pattern[8] = {
 	0x7C61D253
 };
 
-static bool mmc_test(struct ast_device *ast, u32 datagen, u8 test_ctl)
+bool mmc_test(struct ast_device *ast, u32 datagen, u8 test_ctl)
 {
 	u32 data, timeout;
 
@@ -478,8 +479,7 @@ static u32 mmc_test2(struct ast_device *ast, u32 datagen, u8 test_ctl)
 	return data;
 }
 
-
-static bool mmc_test_burst(struct ast_device *ast, u32 datagen)
+bool mmc_test_burst(struct ast_device *ast, u32 datagen)
 {
 	return mmc_test(ast, datagen, 0xc1);
 }
drivers/gpu/drm/ast/ast_post.h new file +16 -0
new file mode 100644
index 000000000000..314fa0475c79
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: MIT */
+
+#ifndef AST_POST_H
+#define AST_POST_H
+
+#include <linux/types.h>
+
+struct ast_device;
+
+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);
+
+#endif
Signature · 1 line
2.50.0
author maintainer
#2 lore raw

PATCH v2 2/10 drm/ast: Move Gen7+ POST code to separate source file

In reply to Thomas Zimmermann

Move POST code for Gen7+ to separate source file and hide it in ast_2600_post(). There's not much going on here except for enabling the DP transmitter chip.

v2:
- simplify logic (Jocelyn)

---
 drivers/gpu/drm/ast/Makefile   |  1 +
 drivers/gpu/drm/ast/ast_2600.c | 41 ++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/ast/ast_drv.h  |  3 +++
 drivers/gpu/drm/ast/ast_post.c |  8 +++----
 4 files changed, 48 insertions(+), 5 deletions(-)
 create mode 100644 drivers/gpu/drm/ast/ast_2600.c
drivers/gpu/drm/ast/Makefile +1 -0
index 8d09ba5d5889..0f09e0fa741b 100644
@@ -4,6 +4,7 @@
 # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
 
 ast-y := \
+	ast_2600.o \
 	ast_cursor.o \
 	ast_ddc.o \
 	ast_dp501.o \
drivers/gpu/drm/ast/ast_2600.c new file +41 -0

41 lines not on this page · raw message

drivers/gpu/drm/ast/ast_drv.h +3 -0
index 2ee402096cd9..570c2fe98b58 100644
@@ -417,6 +417,9 @@ struct ast_crtc_state {
 
 int ast_mm_init(struct ast_device *ast);
 
+/* ast_2600.c */
+int ast_2600_post(struct ast_device *ast);
+
 /* ast post */
 int ast_post_gpu(struct ast_device *ast);
 u32 ast_mindwm(struct ast_device *ast, u32 r);
drivers/gpu/drm/ast/ast_post.c +3 -5
index 36542d266f9c..03a7367bdc71 100644
@@ -348,11 +348,9 @@ int ast_post_gpu(struct ast_device *ast)
 	ast_set_def_ext_reg(ast);
 
 	if (AST_GEN(ast) >= 7) {
-		if (ast->tx_chip == AST_TX_ASTDP) {
-			ret = ast_dp_launch(ast);
-			if (ret)
-				return ret;
-		}
+		ret = ast_2600_post(ast);
+		if (ret)
+			return ret;
 	} else if (AST_GEN(ast) >= 6) {
 		if (ast->config_mode == ast_use_p2a) {
 			ast_post_chip_2500(ast);
Signature · 1 line
2.50.0
author maintainer
#3 lore raw

PATCH v2 3/10 drm/ast: Move Gen6+ POST code to separate source file

In reply to Thomas Zimmermann

Move POST code for Gen6+ to separate source file and hide it in ast_2500_post(). With P2A configuration, it performs a full board POST; otherwise it enables the transmitter chip. No changes to the overall logic.

---
 drivers/gpu/drm/ast/Makefile          |   1 +
 drivers/gpu/drm/ast/ast_2500.c        | 567 ++++++++++++++++++++++++++
 drivers/gpu/drm/ast/ast_dram_tables.h |  62 ---
 drivers/gpu/drm/ast/ast_drv.c         |   2 +-
 drivers/gpu/drm/ast/ast_drv.h         |   5 +-
 drivers/gpu/drm/ast/ast_post.c        | 461 +--------------------
 6 files changed, 576 insertions(+), 522 deletions(-)
 create mode 100644 drivers/gpu/drm/ast/ast_2500.c
drivers/gpu/drm/ast/Makefile +1 -0
index 0f09e0fa741b..38374720e32e 100644
@@ -4,6 +4,7 @@
 # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
 
 ast-y := \
+	ast_2500.o \
 	ast_2600.o \
 	ast_cursor.o \
 	ast_ddc.o \
drivers/gpu/drm/ast/ast_2500.c new file +567 -0

567 lines not on this page · raw message

drivers/gpu/drm/ast/ast_dram_tables.h +0 -62

66 lines not on this page · raw message

drivers/gpu/drm/ast/ast_drv.c +1 -1
index 054acda41909..356b3b7e52d2 100644
@@ -171,7 +171,7 @@ static int ast_detect_chip(struct pci_dev *pdev,
 			/* Patch AST2500/AST2510 */
 			if ((pdev->revision & 0xf0) == 0x40) {
 				if (!(vgacrd0 & AST_IO_VGACRD0_VRAM_INIT_STATUS_MASK))
-					ast_patch_ahb_2500(regs);
+					ast_2500_patch_ahb(regs);
 			}
 
 			/* Double check that it's actually working */
drivers/gpu/drm/ast/ast_drv.h +4 -1
index 570c2fe98b58..4a92c377e9bd 100644
@@ -417,6 +417,10 @@ struct ast_crtc_state {
 
 int ast_mm_init(struct ast_device *ast);
 
+/* ast_2500.c */
+void ast_2500_patch_ahb(void __iomem *regs);
+int ast_2500_post(struct ast_device *ast);
+
 /* ast_2600.c */
 int ast_2600_post(struct ast_device *ast);
 
@@ -424,7 +428,6 @@ int ast_2600_post(struct ast_device *ast);
 int ast_post_gpu(struct ast_device *ast);
 u32 ast_mindwm(struct ast_device *ast, u32 r);
 void ast_moutdwm(struct ast_device *ast, u32 r, u32 v);
-void ast_patch_ahb_2500(void __iomem *regs);
 
 int ast_vga_output_init(struct ast_device *ast);
 int ast_sil164_output_init(struct ast_device *ast);
drivers/gpu/drm/ast/ast_post.c +3 -458

482 lines not on this page · raw message

Signature · 1 line
2.50.0
author maintainer
#4 lore raw

PATCH v2 4/10 drm/ast: Move Gen4+ POST code to separate source file

In reply to Thomas Zimmermann

Move POST code for Gen4+ to separate source file and hide it in ast_2300_post(). With P2A configuration, it performs a full board POST and enables the transmitter chip; otherwise it only enables the transmitter chip.

Also fix coding style in several places. No changes to the overall logic.

---
 drivers/gpu/drm/ast/Makefile   |    1 +
 drivers/gpu/drm/ast/ast_2300.c | 1295 ++++++++++++++++++++++++++++++++
 drivers/gpu/drm/ast/ast_drv.h  |    3 +
 drivers/gpu/drm/ast/ast_post.c | 1265 +------------------------------
 4 files changed, 1302 insertions(+), 1262 deletions(-)
 create mode 100644 drivers/gpu/drm/ast/ast_2300.c
drivers/gpu/drm/ast/Makefile +1 -0
index 38374720e32e..ccb2ff3e8eac 100644
@@ -4,6 +4,7 @@
 # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
 
 ast-y := \
+	ast_2300.o \
 	ast_2500.o \
 	ast_2600.o \
 	ast_cursor.o \
drivers/gpu/drm/ast/ast_2300.c new file +1295 -0

1,295 lines not on this page · raw message

drivers/gpu/drm/ast/ast_drv.h +3 -0
index 4a92c377e9bd..653e93b05859 100644
@@ -417,6 +417,9 @@ struct ast_crtc_state {
 
 int ast_mm_init(struct ast_device *ast);
 
+/* ast_2300.c */
+int ast_2300_post(struct ast_device *ast);
+
 /* ast_2500.c */
 void ast_2500_patch_ahb(void __iomem *regs);
 int ast_2500_post(struct ast_device *ast);
drivers/gpu/drm/ast/ast_post.c +3 -1262

1,291 lines not on this page · raw message

Signature · 1 line
2.50.0
author maintainer
#7 lore raw

PATCH v2 7/10 drm/ast: Handle known struct ast_dramstruct with helpers

In reply to Thomas Zimmermann

Most of struct ast_dramstruct stores hardware state. Some index values have known or special meaning. The known values are

- 0xffff - Terminal entry in the array
- 0xff00 - Delays the programming for usecs
- 0x0004 - Sets the type of DRAM

Add constants and helper macros for these cases. Also add a helper macro for testing. Update Gen1 and Gen2+ accordingly.

---
 drivers/gpu/drm/ast/ast_2000.c | 16 ++++++++--------
 drivers/gpu/drm/ast/ast_2100.c | 22 +++++++++++-----------
 drivers/gpu/drm/ast/ast_post.h | 22 ++++++++++++++++++++++
 3 files changed, 41 insertions(+), 19 deletions(-)
drivers/gpu/drm/ast/ast_2000.c +8 -8
index b2ad2ea5056b..93f13ecc74dc 100644
@@ -38,9 +38,9 @@
 static const struct ast_dramstruct ast2000_dram_table_data[] = {
 	{ 0x0108, 0x00000000 },
 	{ 0x0120, 0x00004a21 },
-	{ 0xFF00, 0x00000043 },
+	AST_DRAMSTRUCT_UDELAY(67u),
 	{ 0x0000, 0xFFFFFFFF },
-	{ 0x0004, 0x00000089 },
+	AST_DRAMSTRUCT_INIT(DRAM_TYPE, 0x00000089),
 	{ 0x0008, 0x22331353 },
 	{ 0x000C, 0x0d07000b },
 	{ 0x0010, 0x11113333 },
@@ -49,18 +49,18 @@ static const struct ast_dramstruct ast2000_dram_table_data[] = {
 	{ 0x0024, 0x00000001 },
 	{ 0x001C, 0x00000000 },
 	{ 0x0014, 0x00000003 },
-	{ 0xFF00, 0x00000043 },
+	AST_DRAMSTRUCT_UDELAY(67u),
 	{ 0x0018, 0x00000131 },
 	{ 0x0014, 0x00000001 },
-	{ 0xFF00, 0x00000043 },
+	AST_DRAMSTRUCT_UDELAY(67u),
 	{ 0x0018, 0x00000031 },
 	{ 0x0014, 0x00000001 },
-	{ 0xFF00, 0x00000043 },
+	AST_DRAMSTRUCT_UDELAY(67u),
 	{ 0x0028, 0x1e0828f1 },
 	{ 0x0024, 0x00000003 },
 	{ 0x002C, 0x1f0f28fb },
 	{ 0x0030, 0xFFFFFE01 },
-	{ 0xFFFF, 0xFFFFFFFF }
+	AST_DRAMSTRUCT_INVALID,
 };
 
 static void ast_post_chip_2000(struct ast_device *ast)
@@ -81,8 +81,8 @@ static void ast_post_chip_2000(struct ast_device *ast)
 			;
 		} while (ast_read32(ast, 0x10100) != 0xa8);
 
-		while (dram_reg_info->index != 0xffff) {
-			if (dram_reg_info->index == 0xff00) {/* delay fn */
+		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 {
drivers/gpu/drm/ast/ast_2100.c +11 -11
index ee40f3911ca4..1cabac647584 100644
@@ -38,11 +38,11 @@
 static const struct ast_dramstruct ast1100_dram_table_data[] = {
 	{ 0x2000, 0x1688a8a8 },
 	{ 0x2020, 0x000041f0 },
-	{ 0xFF00, 0x00000043 },
+	AST_DRAMSTRUCT_UDELAY(67u),
 	{ 0x0000, 0xfc600309 },
 	{ 0x006C, 0x00909090 },
 	{ 0x0064, 0x00050000 },
-	{ 0x0004, 0x00000585 },
+	AST_DRAMSTRUCT_INIT(DRAM_TYPE, 0x00000585),
 	{ 0x0008, 0x0011030f },
 	{ 0x0010, 0x22201724 },
 	{ 0x0018, 0x1e29011a },
@@ -68,7 +68,7 @@ static const struct ast_dramstruct ast1100_dram_table_data[] = {
 	{ 0x0078, 0x00000000 },
 	{ 0x007C, 0x00000000 },
 	{ 0x0034, 0x00000001 },
-	{ 0xFF00, 0x00000043 },
+	AST_DRAMSTRUCT_UDELAY(67u),
 	{ 0x002C, 0x00000732 },
 	{ 0x0030, 0x00000040 },
 	{ 0x0028, 0x00000005 },
@@ -85,17 +85,17 @@ static const struct ast_dramstruct ast1100_dram_table_data[] = {
 	{ 0x000C, 0x00005a21 },
 	{ 0x0034, 0x00007c03 },
 	{ 0x0120, 0x00004c41 },
-	{ 0xffff, 0xffffffff },
+	AST_DRAMSTRUCT_INVALID,
 };
 
 static const struct ast_dramstruct ast2100_dram_table_data[] = {
 	{ 0x2000, 0x1688a8a8 },
 	{ 0x2020, 0x00004120 },
-	{ 0xFF00, 0x00000043 },
+	AST_DRAMSTRUCT_UDELAY(67u),
 	{ 0x0000, 0xfc600309 },
 	{ 0x006C, 0x00909090 },
 	{ 0x0064, 0x00070000 },
-	{ 0x0004, 0x00000489 },
+	AST_DRAMSTRUCT_INIT(DRAM_TYPE, 0x00000489),
 	{ 0x0008, 0x0011030f },
 	{ 0x0010, 0x32302926 },
 	{ 0x0018, 0x274c0122 },
@@ -121,7 +121,7 @@ static const struct ast_dramstruct ast2100_dram_table_data[] = {
 	{ 0x0078, 0x00000000 },
 	{ 0x007C, 0x00000000 },
 	{ 0x0034, 0x00000001 },
-	{ 0xFF00, 0x00000043 },
+	AST_DRAMSTRUCT_UDELAY(67u),
 	{ 0x002C, 0x00000942 },
 	{ 0x0030, 0x00000040 },
 	{ 0x0028, 0x00000005 },
@@ -138,7 +138,7 @@ static const struct ast_dramstruct ast2100_dram_table_data[] = {
 	{ 0x000C, 0x00005a21 },
 	{ 0x0034, 0x00007c03 },
 	{ 0x0120, 0x00005061 },
-	{ 0xffff, 0xffffffff },
+	AST_DRAMSTRUCT_INVALID,
 };
 
 /*
@@ -287,11 +287,11 @@ static void ast_post_chip_2100(struct ast_device *ast)
 			;
 		} while (ast_read32(ast, 0x10000) != 0x01);
 
-		while (dram_reg_info->index != 0xffff) {
-			if (dram_reg_info->index == 0xff00) {/* delay fn */
+		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 (dram_reg_info->index == 0x4) {
+			} else if (AST_DRAMSTRUCT_IS(dram_reg_info, DRAM_TYPE)) {
 				data = dram_reg_info->data;
 				if (ast->dram_type == AST_DRAM_1Gx16)
 					data = 0x00000d89;
drivers/gpu/drm/ast/ast_post.h +22 -0
index 3a55c32a7eb7..44136856952f 100644
@@ -3,6 +3,7 @@
 #ifndef AST_POST_H
 #define AST_POST_H
 
+#include <linux/limits.h>
 #include <linux/types.h>
 
 struct ast_device;
@@ -13,6 +14,27 @@ struct ast_dramstruct {
 	u32 data;
 };
 
+/* hardware fields */
+#define __AST_DRAMSTRUCT_DRAM_TYPE      0x0004
+
+/* control commands */
+#define __AST_DRAMSTRUCT_UDELAY         0xff00
+#define __AST_DRAMSTRUCT_INVALID        0xffff
+
+#define __AST_DRAMSTRUCT_INDEX(_name) \
+	(__AST_DRAMSTRUCT_ ## _name)
+
+#define AST_DRAMSTRUCT_INIT(_name, _value) \
+	{ __AST_DRAMSTRUCT_INDEX(_name), (_value) }
+
+#define AST_DRAMSTRUCT_UDELAY(_usecs) \
+	AST_DRAMSTRUCT_INIT(UDELAY, _usecs)
+#define AST_DRAMSTRUCT_INVALID \
+	AST_DRAMSTRUCT_INIT(INVALID, U32_MAX)
+
+#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);
 
Signature · 1 line
2.50.0
author maintainer
#5 lore raw

PATCH v2 5/10 drm/ast: Move Gen2+ and Gen1 POST code to separate source files

In reply to Thomas Zimmermann

Move POST code for Gen2+ and Gen1 to separate source files and hide it in ast_2100_post() ans ast_2000_post(). With P2A configuration, the POST logic for these chip generations has been mingled in ast_init_dram_reg(). Hence, handle all generations in a single change. The split simplifies both cases. Also move the DRAM init tables for each Gen into the respective source file. No changes to the overall logic.

---
 drivers/gpu/drm/ast/Makefile          |   2 +
 drivers/gpu/drm/ast/ast_2000.c        | 117 +++++++++
 drivers/gpu/drm/ast/ast_2100.c        | 346 ++++++++++++++++++++++++++
 drivers/gpu/drm/ast/ast_dram_tables.h | 134 ----------
 drivers/gpu/drm/ast/ast_drv.h         |   6 +
 drivers/gpu/drm/ast/ast_post.c        | 243 +-----------------
 6 files changed, 478 insertions(+), 370 deletions(-)
 create mode 100644 drivers/gpu/drm/ast/ast_2000.c
 create mode 100644 drivers/gpu/drm/ast/ast_2100.c
drivers/gpu/drm/ast/Makefile +2 -0
index ccb2ff3e8eac..2547613155da 100644
@@ -4,6 +4,8 @@
 # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
 
 ast-y := \
+	ast_2000.o \
+	ast_2100.o \
 	ast_2300.o \
 	ast_2500.o \
 	ast_2600.o \
drivers/gpu/drm/ast/ast_2000.c new file +117 -0

117 lines not on this page · raw message

drivers/gpu/drm/ast/ast_2100.c new file +346 -0

346 lines not on this page · raw message

drivers/gpu/drm/ast/ast_dram_tables.h +0 -134

138 lines not on this page · raw message

drivers/gpu/drm/ast/ast_drv.h +6 -0
index 653e93b05859..e37a55295ed7 100644
@@ -417,6 +417,12 @@ struct ast_crtc_state {
 
 int ast_mm_init(struct ast_device *ast);
 
+/* ast_2000.c */
+int ast_2000_post(struct ast_device *ast);
+
+/* ast_2100.c */
+int ast_2100_post(struct ast_device *ast);
+
 /* ast_2300.c */
 int ast_2300_post(struct ast_device *ast);
 
drivers/gpu/drm/ast/ast_post.c +7 -236

262 lines not on this page · raw message

Signature · 1 line
2.50.0
author maintainer
#9 lore raw

PATCH v2 9/10 drm/ast: Gen7: Disable VGASR0[1] as on Gen4+

In reply to Thomas Zimmermann

Set VGACRB6[5], which disables asynchronous sequencer resets via VGASR0[1]. This was most likely an oversight when adding support for Gen7. Aligns Gen7 with the earlier Gen4+.

---
 drivers/gpu/drm/ast/ast_2600.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/ast/ast_2600.c +1 -0
index 08614090068d..01fd0e2d96e1 100644
@@ -60,6 +60,7 @@ void ast_2600_set_def_ext_reg(struct ast_device *ast)
 
 	/* Enable RAMDAC for A1 */
 	reg = 0x04;
+	reg |= 0x20;
 	ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xb6, 0xff, reg);
 }
 
Signature · 1 line
2.50.0
author maintainer
#6 lore raw

PATCH v2 6/10 drm/ast: Move struct ast_dramstruct to ast_post.h

In reply to Thomas Zimmermann

Declare struct ast_dramstruct in ast_post.h and remove its original header file.

---
 drivers/gpu/drm/ast/ast_2000.c        |  2 +-
 drivers/gpu/drm/ast/ast_2100.c        |  2 +-
 drivers/gpu/drm/ast/ast_dram_tables.h | 11 -----------
 drivers/gpu/drm/ast/ast_post.h        |  6 ++++++
 4 files changed, 8 insertions(+), 13 deletions(-)
 delete mode 100644 drivers/gpu/drm/ast/ast_dram_tables.h
drivers/gpu/drm/ast/ast_2000.c +1 -1
index 099c90e1402f..b2ad2ea5056b 100644
@@ -28,8 +28,8 @@
 
 #include <linux/delay.h>
 
-#include "ast_dram_tables.h"
 #include "ast_drv.h"
+#include "ast_post.h"
 
 /*
  * POST
drivers/gpu/drm/ast/ast_2100.c +1 -1
index f41c778e02da..ee40f3911ca4 100644
@@ -28,8 +28,8 @@
 
 #include <linux/delay.h>
 
-#include "ast_dram_tables.h"
 #include "ast_drv.h"
+#include "ast_post.h"
 
 /*
  * POST
drivers/gpu/drm/ast/ast_dram_tables.h deleted +0 -11
deleted file mode 100644
index 6c191e2c4e6c..000000000000
@@ -1,11 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef AST_DRAM_TABLES_H
-#define AST_DRAM_TABLES_H
-
-/* DRAM timing tables */
-struct ast_dramstruct {
-	u16 index;
-	u32 data;
-};
-
-#endif
drivers/gpu/drm/ast/ast_post.h +6 -0
index 314fa0475c79..3a55c32a7eb7 100644
@@ -7,6 +7,12 @@
 
 struct ast_device;
 
+/* DRAM timing tables */
+struct ast_dramstruct {
+	u16 index;
+	u32 data;
+};
+
 u32 __ast_mindwm(void __iomem *regs, u32 r);
 void __ast_moutdwm(void __iomem *regs, u32 r, u32 v);
 
Signature · 1 line
2.50.0
author maintainer
#8 lore raw

PATCH v2 8/10 drm/ast: Split ast_set_def_ext_reg() by chip generation

In reply to Thomas Zimmermann

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.

---
 drivers/gpu/drm/ast/ast_2000.c | 32 +++++++++++++++++++++++++++
 drivers/gpu/drm/ast/ast_2100.c |  2 ++
 drivers/gpu/drm/ast/ast_2300.c | 33 ++++++++++++++++++++++++++++
 drivers/gpu/drm/ast/ast_2500.c |  2 ++
 drivers/gpu/drm/ast/ast_2600.c | 33 ++++++++++++++++++++++++++++
 drivers/gpu/drm/ast/ast_post.c | 40 ----------------------------------
 drivers/gpu/drm/ast/ast_post.h |  9 ++++++++
 7 files changed, 111 insertions(+), 40 deletions(-)
drivers/gpu/drm/ast/ast_2000.c +32 -0
index 93f13ecc74dc..41c2aa1e425a 100644
@@ -35,6 +35,36 @@
  * POST
  */
 
+void ast_2000_set_def_ext_reg(struct ast_device *ast)
+{
+	static const u8 extreginfo[] = { 0x0f, 0x04, 0x1c, 0xff };
+	u8 i, index, reg;
+	const u8 *ext_reg_info;
+
+	/* reset scratch */
+	for (i = 0x81; i <= 0x9f; i++)
+		ast_set_index_reg(ast, AST_IO_VGACRI, i, 0x00);
+
+	ext_reg_info = extreginfo;
+	index = 0xa0;
+	while (*ext_reg_info != 0xff) {
+		ast_set_index_reg_mask(ast, AST_IO_VGACRI, index, 0x00, *ext_reg_info);
+		index++;
+		ext_reg_info++;
+	}
+
+	/* disable standard IO/MEM decode if secondary */
+	/* ast_set_index_reg-mask(ast, AST_IO_VGACRI, 0xa1, 0xff, 0x3); */
+
+	/* Set Ext. Default */
+	ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x8c, 0x00, 0x01);
+	ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xb7, 0x00, 0x00);
+
+	/* Enable RAMDAC for A1 */
+	reg = 0x04;
+	ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xb6, 0xff, reg);
+}
+
 static const struct ast_dramstruct ast2000_dram_table_data[] = {
 	{ 0x0108, 0x00000000 },
 	{ 0x0120, 0x00004a21 },
@@ -104,6 +134,8 @@ static void ast_post_chip_2000(struct ast_device *ast)
 
 int ast_2000_post(struct ast_device *ast)
 {
+	ast_2000_set_def_ext_reg(ast);
+
 	if (ast->config_mode == ast_use_p2a) {
 		ast_post_chip_2000(ast);
 	} else {
drivers/gpu/drm/ast/ast_2100.c +2 -0
index 1cabac647584..477ee15eff5d 100644
@@ -333,6 +333,8 @@ static void ast_post_chip_2100(struct ast_device *ast)
 
 int ast_2100_post(struct ast_device *ast)
 {
+	ast_2000_set_def_ext_reg(ast);
+
 	if (ast->config_mode == ast_use_p2a) {
 		ast_post_chip_2100(ast);
 	} else {
drivers/gpu/drm/ast/ast_2300.c +33 -0
index 7a2c3fde09d2..dc2a32244689 100644
@@ -35,6 +35,37 @@
  *  POST
  */
 
+void ast_2300_set_def_ext_reg(struct ast_device *ast)
+{
+	static const u8 extreginfo[] = { 0x0f, 0x04, 0x1f, 0xff };
+	u8 i, index, reg;
+	const u8 *ext_reg_info;
+
+	/* reset scratch */
+	for (i = 0x81; i <= 0x9f; i++)
+		ast_set_index_reg(ast, AST_IO_VGACRI, i, 0x00);
+
+	ext_reg_info = extreginfo;
+	index = 0xa0;
+	while (*ext_reg_info != 0xff) {
+		ast_set_index_reg_mask(ast, AST_IO_VGACRI, index, 0x00, *ext_reg_info);
+		index++;
+		ext_reg_info++;
+	}
+
+	/* disable standard IO/MEM decode if secondary */
+	/* ast_set_index_reg-mask(ast, AST_IO_VGACRI, 0xa1, 0xff, 0x3); */
+
+	/* Set Ext. Default */
+	ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x8c, 0x00, 0x01);
+	ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xb7, 0x00, 0x00);
+
+	/* Enable RAMDAC for A1 */
+	reg = 0x04;
+	reg |= 0x20;
+	ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xb6, 0xff, reg);
+}
+
 /* AST 2300 DRAM settings */
 #define AST_DDR3 0
 #define AST_DDR2 1
@@ -1281,6 +1312,8 @@ static void ast_post_chip_2300(struct ast_device *ast)
 
 int ast_2300_post(struct ast_device *ast)
 {
+	ast_2300_set_def_ext_reg(ast);
+
 	if (ast->config_mode == ast_use_p2a) {
 		ast_post_chip_2300(ast);
 		ast_init_3rdtx(ast);
drivers/gpu/drm/ast/ast_2500.c +2 -0
index e5b3e0c63222..1e541498ea67 100644
@@ -554,6 +554,8 @@ static void ast_post_chip_2500(struct ast_device *ast)
 
 int ast_2500_post(struct ast_device *ast)
 {
+	ast_2300_set_def_ext_reg(ast);
+
 	if (ast->config_mode == ast_use_p2a) {
 		ast_post_chip_2500(ast);
 	} else {
drivers/gpu/drm/ast/ast_2600.c +33 -0
index f58a2ceddb3a..08614090068d 100644
@@ -27,13 +27,46 @@
  */
 
 #include "ast_drv.h"
+#include "ast_post.h"
 
 /*
  * POST
  */
 
+void ast_2600_set_def_ext_reg(struct ast_device *ast)
+{
+	static const u8 extreginfo[] = { 0x0f, 0x04, 0x1c, 0xff };
+	u8 i, index, reg;
+	const u8 *ext_reg_info;
+
+	/* reset scratch */
+	for (i = 0x81; i <= 0x9f; i++)
+		ast_set_index_reg(ast, AST_IO_VGACRI, i, 0x00);
+
+	ext_reg_info = extreginfo;
+	index = 0xa0;
+	while (*ext_reg_info != 0xff) {
+		ast_set_index_reg_mask(ast, AST_IO_VGACRI, index, 0x00, *ext_reg_info);
+		index++;
+		ext_reg_info++;
+	}
+
+	/* disable standard IO/MEM decode if secondary */
+	/* ast_set_index_reg-mask(ast, AST_IO_VGACRI, 0xa1, 0xff, 0x3); */
+
+	/* Set Ext. Default */
+	ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x8c, 0x00, 0x01);
+	ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xb7, 0x00, 0x00);
+
+	/* Enable RAMDAC for A1 */
+	reg = 0x04;
+	ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xb6, 0xff, reg);
+}
+
 int ast_2600_post(struct ast_device *ast)
 {
+	ast_2600_set_def_ext_reg(ast);
+
 	if (ast->tx_chip == AST_TX_ASTDP)
 		return ast_dp_launch(ast);
 
drivers/gpu/drm/ast/ast_post.c +0 -40
index 8e575e713f19..b72914dbed38 100644
@@ -34,44 +34,6 @@
 #include "ast_drv.h"
 #include "ast_post.h"
 
-static const u8 extreginfo[] = { 0x0f, 0x04, 0x1c, 0xff };
-static const u8 extreginfo_ast2300[] = { 0x0f, 0x04, 0x1f, 0xff };
-
-static void ast_set_def_ext_reg(struct ast_device *ast)
-{
-	u8 i, index, reg;
-	const u8 *ext_reg_info;
-
-	/* reset scratch */
-	for (i = 0x81; i <= 0x9f; i++)
-		ast_set_index_reg(ast, AST_IO_VGACRI, i, 0x00);
-
-	if (IS_AST_GEN4(ast) || IS_AST_GEN5(ast) || IS_AST_GEN6(ast))
-		ext_reg_info = extreginfo_ast2300;
-	else
-		ext_reg_info = extreginfo;
-
-	index = 0xa0;
-	while (*ext_reg_info != 0xff) {
-		ast_set_index_reg_mask(ast, AST_IO_VGACRI, index, 0x00, *ext_reg_info);
-		index++;
-		ext_reg_info++;
-	}
-
-	/* disable standard IO/MEM decode if secondary */
-	/* ast_set_index_reg-mask(ast, AST_IO_VGACRI, 0xa1, 0xff, 0x3); */
-
-	/* Set Ext. Default */
-	ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x8c, 0x00, 0x01);
-	ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xb7, 0x00, 0x00);
-
-	/* Enable RAMDAC for A1 */
-	reg = 0x04;
-	if (IS_AST_GEN4(ast) || IS_AST_GEN5(ast) || IS_AST_GEN6(ast))
-		reg |= 0x20;
-	ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xb6, 0xff, reg);
-}
-
 u32 __ast_mindwm(void __iomem *regs, u32 r)
 {
 	u32 data;
@@ -114,8 +76,6 @@ int ast_post_gpu(struct ast_device *ast)
 {
 	int ret;
 
-	ast_set_def_ext_reg(ast);
-
 	if (AST_GEN(ast) >= 7) {
 		ret = ast_2600_post(ast);
 		if (ret)
drivers/gpu/drm/ast/ast_post.h +9 -0
index 44136856952f..9f3108ddeae8 100644
@@ -41,4 +41,13 @@ 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);
 
+/* ast_2000.c */
+void ast_2000_set_def_ext_reg(struct ast_device *ast);
+
+/* ast_2300.c */
+void ast_2300_set_def_ext_reg(struct ast_device *ast);
+
+/* ast_2600.c */
+void ast_2600_set_def_ext_reg(struct ast_device *ast);
+
 #endif
Signature · 1 line
2.50.0
author maintainer
#10 lore raw

PATCH v2 10/10 drm/ast: Gen7: Switch default registers to gen4+ state

In reply to Thomas Zimmermann

Change the default register settings for Gen7 to mach Gen4 and later. Gen7 currently uses the settings for Gen1, which is most likely incorrect.

Using Gen4+ settings enables E2M linear-access modes in VGACRA2. It appears to be related to the chip's PCIE2MBOX feature, which is unused.

---
 drivers/gpu/drm/ast/ast_2600.c | 33 +--------------------------------
 drivers/gpu/drm/ast/ast_post.h |  3 ---
 2 files changed, 1 insertion(+), 35 deletions(-)
drivers/gpu/drm/ast/ast_2600.c +1 -32
index 01fd0e2d96e1..8d75a47444f5 100644
@@ -33,40 +33,9 @@
  * POST
  */
 
-void ast_2600_set_def_ext_reg(struct ast_device *ast)
-{
-	static const u8 extreginfo[] = { 0x0f, 0x04, 0x1c, 0xff };
-	u8 i, index, reg;
-	const u8 *ext_reg_info;
-
-	/* reset scratch */
-	for (i = 0x81; i <= 0x9f; i++)
-		ast_set_index_reg(ast, AST_IO_VGACRI, i, 0x00);
-
-	ext_reg_info = extreginfo;
-	index = 0xa0;
-	while (*ext_reg_info != 0xff) {
-		ast_set_index_reg_mask(ast, AST_IO_VGACRI, index, 0x00, *ext_reg_info);
-		index++;
-		ext_reg_info++;
-	}
-
-	/* disable standard IO/MEM decode if secondary */
-	/* ast_set_index_reg-mask(ast, AST_IO_VGACRI, 0xa1, 0xff, 0x3); */
-
-	/* Set Ext. Default */
-	ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x8c, 0x00, 0x01);
-	ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xb7, 0x00, 0x00);
-
-	/* Enable RAMDAC for A1 */
-	reg = 0x04;
-	reg |= 0x20;
-	ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xb6, 0xff, reg);
-}
-
 int ast_2600_post(struct ast_device *ast)
 {
-	ast_2600_set_def_ext_reg(ast);
+	ast_2300_set_def_ext_reg(ast);
 
 	if (ast->tx_chip == AST_TX_ASTDP)
 		return ast_dp_launch(ast);
drivers/gpu/drm/ast/ast_post.h +0 -3
index 9f3108ddeae8..aa5d247bebe8 100644
@@ -47,7 +47,4 @@ void ast_2000_set_def_ext_reg(struct ast_device *ast);
 /* ast_2300.c */
 void ast_2300_set_def_ext_reg(struct ast_device *ast);
 
-/* ast_2600.c */
-void ast_2600_set_def_ext_reg(struct ast_device *ast);
-
 #endif
Signature · 1 line
2.50.0