]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/ast: Prepare per-Gen device initialization
authorThomas Zimmermann <tzimmermann@suse.de>
Mon, 22 Sep 2025 08:36:04 +0000 (10:36 +0200)
committerThomas Zimmermann <tzimmermann@suse.de>
Mon, 29 Sep 2025 11:28:10 +0000 (13:28 +0200)
Switch device creation by hardware Gen. Return the value from the
call to ast_detect_chip(). All generations are still initialized
by ast_device_create().

Also add ast_device_init() for setting some common fields in struct
ast_device.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>
Link: https://lore.kernel.org/r/20250922083708.45564-5-tzimmermann@suse.de
drivers/gpu/drm/ast/ast_drv.c
drivers/gpu/drm/ast/ast_drv.h
drivers/gpu/drm/ast/ast_main.c

index c653ea5570d80b0541cb5338f94169ae030e1dd8..a1b3c25ded20cb39cd28710b7b7fdc35909fee55 100644 (file)
@@ -47,6 +47,18 @@ static int ast_modeset = -1;
 MODULE_PARM_DESC(modeset, "Disable/Enable modesetting");
 module_param_named(modeset, ast_modeset, int, 0400);
 
+void ast_device_init(struct ast_device *ast,
+                    enum ast_chip chip,
+                    enum ast_config_mode config_mode,
+                    void __iomem *regs,
+                    void __iomem *ioregs)
+{
+       ast->chip = chip;
+       ast->config_mode = config_mode;
+       ast->regs = regs;
+       ast->ioregs = ioregs;
+}
+
 void __ast_device_set_tx_chip(struct ast_device *ast, enum ast_tx_chip tx_chip)
 {
        static const char * const info_str[] = {
@@ -281,7 +293,7 @@ static int ast_detect_chip(struct pci_dev *pdev,
        *chip_out = chip;
        *config_mode_out = config_mode;
 
-       return 0;
+       return __AST_CHIP_GEN(chip);
 }
 
 static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
@@ -292,6 +304,7 @@ static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        void __iomem *ioregs;
        enum ast_config_mode config_mode;
        enum ast_chip chip;
+       unsigned int chip_gen;
        struct drm_device *drm;
        bool need_post = false;
 
@@ -364,10 +377,16 @@ static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                return ret;
 
        ret = ast_detect_chip(pdev, regs, ioregs, &chip, &config_mode);
-       if (ret)
+       if (ret < 0)
                return ret;
+       chip_gen = ret;
 
-       drm = ast_device_create(pdev, &ast_driver, chip, config_mode, regs, ioregs, need_post);
+       switch (chip_gen) {
+       default:
+               drm = ast_device_create(pdev, &ast_driver, chip, config_mode, regs, ioregs,
+                                       need_post);
+               break;
+       }
        if (IS_ERR(drm))
                return PTR_ERR(drm);
        pci_set_drvdata(pdev, drm);
index ae8e6083bc2bbf209c164884eadf5a78dfc95be0..8868cbdd99d024e8e7c66adcf616097f959e2011 100644 (file)
@@ -416,6 +416,11 @@ struct ast_crtc_state {
 int ast_mm_init(struct ast_device *ast);
 
 /* ast_drv.c */
+void ast_device_init(struct ast_device *ast,
+                    enum ast_chip chip,
+                    enum ast_config_mode config_mode,
+                    void __iomem *regs,
+                    void __iomem *ioregs);
 void __ast_device_set_tx_chip(struct ast_device *ast, enum ast_tx_chip tx_chip);
 
 /* ast_2000.c */
index 8ed15563173cbc4eaa898217041bc26544476260..d1c54700686bc3db2e3762f1551c84c90e649e6a 100644 (file)
@@ -112,10 +112,7 @@ struct drm_device *ast_device_create(struct pci_dev *pdev,
                return ERR_CAST(ast);
        dev = &ast->base;
 
-       ast->chip = chip;
-       ast->config_mode = config_mode;
-       ast->regs = regs;
-       ast->ioregs = ioregs;
+       ast_device_init(ast, chip, config_mode, regs, ioregs);
 
        if (AST_GEN(ast) >= 4)
                ast_2300_detect_tx_chip(ast);