drm/ingenic: prepare ingenic drm for later addition of JZ4780
authorH. Nikolaus Schaller <hns@goldelico.com>
Thu, 2 Dec 2021 18:39:46 +0000 (19:39 +0100)
committerPaul Cercueil <paul@crapouillou.net>
Thu, 16 Dec 2021 15:22:16 +0000 (15:22 +0000)
This changes the way the regmap is allocated to prepare for the
later addition of the JZ4780 which has more registers and bits
than the others.

Therefore we make the regmap as big as the reg property in
the device tree tells.

Suggested-by: Paul Cercueil <paul@crapouillou.net>
Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Link: https://patchwork.freedesktop.org/patch/msgid/ee65e70e91268b3963f8a6581c8aa6c3b643c53e.1638470392.git.hns@goldelico.com
drivers/gpu/drm/ingenic/ingenic-drm-drv.c

index b4943a56be09bc84ea0ce4d98cd3334bec691e26..9c60fc4605e4b7494b97ed35ae16c041599676a6 100644 (file)
@@ -173,7 +173,6 @@ static const struct regmap_config ingenic_drm_regmap_config = {
        .val_bits = 32,
        .reg_stride = 4,
 
-       .max_register = JZ_REG_LCD_SIZE1,
        .writeable_reg = ingenic_drm_writeable_reg,
 };
 
@@ -1011,6 +1010,8 @@ static int ingenic_drm_bind(struct device *dev, bool has_components)
        struct ingenic_drm_bridge *ib;
        struct drm_device *drm;
        void __iomem *base;
+       struct resource *res;
+       struct regmap_config regmap_config;
        long parent_rate;
        unsigned int i, clone_mask = 0;
        int ret, irq;
@@ -1056,14 +1057,16 @@ static int ingenic_drm_bind(struct device *dev, bool has_components)
        drm->mode_config.funcs = &ingenic_drm_mode_config_funcs;
        drm->mode_config.helper_private = &ingenic_drm_mode_config_helpers;
 
-       base = devm_platform_ioremap_resource(pdev, 0);
+       base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
        if (IS_ERR(base)) {
                dev_err(dev, "Failed to get memory resource\n");
                return PTR_ERR(base);
        }
 
+       regmap_config = ingenic_drm_regmap_config;
+       regmap_config.max_register = res->end - res->start;
        priv->map = devm_regmap_init_mmio(dev, base,
-                                         &ingenic_drm_regmap_config);
+                                         &regmap_config);
        if (IS_ERR(priv->map)) {
                dev_err(dev, "Failed to create regmap\n");
                return PTR_ERR(priv->map);