summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/ast/ast_drv.h
diff options
context:
space:
mode:
authorThomas Zimmermann <tzimmermann@suse.de>2023-06-21 15:53:43 +0300
committerThomas Zimmermann <tzimmermann@suse.de>2023-06-27 15:26:34 +0300
commitecf64579fe3dda39bf986686a181027b80c9d075 (patch)
tree1277d093c2bc7ab38ecbeb12a0f4b04ca3adcc5a /drivers/gpu/drm/ast/ast_drv.h
parenta74ec2bcdc2298ab025a75b9d5683aabf4e4c043 (diff)
downloadlinux-ecf64579fe3dda39bf986686a181027b80c9d075.tar.xz
drm/ast: Distinguish among chip generations
ASpeed distinguishes among various generations of the AST graphics chipset with various models. [1] The most-recent model AST 2600 is of the 7th generation, the AST 2500 is of the 6th generation, and so on. The ast driver simply picks one of the models as representative for the whole generation. In several places, individual models of the same generation need to be handled differently, which then requires additional code for detecting the model. Introduce different generations of the Aspeed chipset. In the source code, refer to the generation instead of the representation model where possible. The few places that require per-model handling are now clearly marked. In the enum ast_chip, we arrange each model's value such that it encodes the generation. This allows for an easy test. The actual values are ordered, but not of interest to the driver. v2: * use __ast_gen_is_eq() (Jingfeng) Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Link: https://web.archive.org/web/20141007093258/http://www.aspeedtech.com/products.php?fPath=20 # 1 Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com> Tested-by: Jocelyn Falempe <jfalempe@redhat.com> # AST2600 Reviewed-by: Sui Jingfeng <suijingfeng@loongson.cn> Link: https://patchwork.freedesktop.org/patch/msgid/20230621130032.3568-10-tzimmermann@suse.de
Diffstat (limited to 'drivers/gpu/drm/ast/ast_drv.h')
-rw-r--r--drivers/gpu/drm/ast/ast_drv.h56
1 files changed, 47 insertions, 9 deletions
diff --git a/drivers/gpu/drm/ast/ast_drv.h b/drivers/gpu/drm/ast/ast_drv.h
index 31fead32b19c..803d72a60506 100644
--- a/drivers/gpu/drm/ast/ast_drv.h
+++ b/drivers/gpu/drm/ast/ast_drv.h
@@ -52,18 +52,38 @@
#define PCI_CHIP_AST2000 0x2000
#define PCI_CHIP_AST2100 0x2010
+#define __AST_CHIP(__gen, __index) ((__gen) << 16 | (__index))
+
enum ast_chip {
- AST2000,
- AST2100,
- AST1100,
- AST2200,
- AST2150,
- AST2300,
- AST2400,
- AST2500,
- AST2600,
+ /* 1st gen */
+ AST1000 = __AST_CHIP(1, 0), // unused
+ AST2000 = __AST_CHIP(1, 1),
+ /* 2nd gen */
+ AST1100 = __AST_CHIP(2, 0),
+ AST2100 = __AST_CHIP(2, 1),
+ AST2050 = __AST_CHIP(2, 2), // unused
+ /* 3rd gen */
+ AST2200 = __AST_CHIP(3, 0),
+ AST2150 = __AST_CHIP(3, 1),
+ /* 4th gen */
+ AST2300 = __AST_CHIP(4, 0),
+ AST1300 = __AST_CHIP(4, 1), // unused
+ AST1050 = __AST_CHIP(4, 2), // unused
+ /* 5th gen */
+ AST2400 = __AST_CHIP(5, 0),
+ AST1400 = __AST_CHIP(5, 1), // unused
+ AST1250 = __AST_CHIP(5, 2), // unused
+ /* 6th gen */
+ AST2500 = __AST_CHIP(6, 0),
+ AST2510 = __AST_CHIP(6, 1), // unused
+ AST2520 = __AST_CHIP(6, 2), // unused
+ /* 7th gen */
+ AST2600 = __AST_CHIP(7, 0),
+ AST2620 = __AST_CHIP(7, 1), // unused
};
+#define __AST_CHIP_GEN(__chip) (((unsigned long)(__chip)) >> 16)
+
enum ast_tx_chip {
AST_TX_NONE,
AST_TX_SIL164,
@@ -217,6 +237,24 @@ struct ast_device *ast_device_create(const struct drm_driver *drv,
struct pci_dev *pdev,
unsigned long flags);
+static inline unsigned long __ast_gen(struct ast_device *ast)
+{
+ return __AST_CHIP_GEN(ast->chip);
+}
+#define AST_GEN(__ast) __ast_gen(__ast)
+
+static inline bool __ast_gen_is_eq(struct ast_device *ast, unsigned long gen)
+{
+ return __ast_gen(ast) == gen;
+}
+#define IS_AST_GEN1(__ast) __ast_gen_is_eq(__ast, 1)
+#define IS_AST_GEN2(__ast) __ast_gen_is_eq(__ast, 2)
+#define IS_AST_GEN3(__ast) __ast_gen_is_eq(__ast, 3)
+#define IS_AST_GEN4(__ast) __ast_gen_is_eq(__ast, 4)
+#define IS_AST_GEN5(__ast) __ast_gen_is_eq(__ast, 5)
+#define IS_AST_GEN6(__ast) __ast_gen_is_eq(__ast, 6)
+#define IS_AST_GEN7(__ast) __ast_gen_is_eq(__ast, 7)
+
#define AST_IO_AR_PORT_WRITE (0x40)
#define AST_IO_MISC_PORT_WRITE (0x42)
#define AST_IO_VGA_ENABLE_PORT (0x43)