media: renesas: vsp1: Add support for VSP software version
authorBiju Das <biju.das.jz@bp.renesas.com>
Sun, 28 Aug 2022 08:13:32 +0000 (10:13 +0200)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Tue, 30 Aug 2022 13:32:49 +0000 (15:32 +0200)
The VSPD block on RZ/G2L SoCs does not have a version register.

This patch adds support for adding VSP software version based on
device match.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
drivers/media/platform/renesas/vsp1/vsp1.h
drivers/media/platform/renesas/vsp1/vsp1_drv.c
drivers/media/platform/renesas/vsp1/vsp1_regs.h

index baf898d577eca0a1e5de6270eedb42191cc0e837..ff4435705abb0d11d089a6d725a61222416bf8d2 100644 (file)
@@ -67,6 +67,7 @@ struct vsp1_device_info {
        unsigned int uif_count;
        unsigned int wpf_count;
        unsigned int num_bru_inputs;
+       u8 soc;
        bool uapi;
 };
 
index ef4bcf86092373dd2f460e35c1691475ebf581f3..fd75788a5a36f36c73ad1dab60cf01d3f06381f7 100644 (file)
@@ -818,11 +818,39 @@ static const struct vsp1_device_info vsp1_device_infos[] = {
        },
 };
 
+static const struct vsp1_device_info *vsp1_lookup_info(struct vsp1_device *vsp1)
+{
+       const struct vsp1_device_info *info;
+       unsigned int i;
+
+       /*
+        * Try the info stored in match data first for devices that don't have
+        * a version register.
+        */
+       info = of_device_get_match_data(vsp1->dev);
+       if (info) {
+               vsp1->version = VI6_IP_VERSION_VSP_SW | info->version | info->soc;
+               return info;
+       }
+
+       vsp1->version = vsp1_read(vsp1, VI6_IP_VERSION);
+
+       for (i = 0; i < ARRAY_SIZE(vsp1_device_infos); ++i) {
+               info = &vsp1_device_infos[i];
+
+               if ((vsp1->version & VI6_IP_VERSION_MODEL_MASK) == info->version)
+                       return info;
+       }
+
+       dev_err(vsp1->dev, "unsupported IP version 0x%08x\n", vsp1->version);
+
+       return NULL;
+}
+
 static int vsp1_probe(struct platform_device *pdev)
 {
        struct vsp1_device *vsp1;
        struct device_node *fcp_node;
-       unsigned int i;
        int ret;
        int irq;
 
@@ -878,19 +906,8 @@ static int vsp1_probe(struct platform_device *pdev)
        if (ret < 0)
                goto done;
 
-       vsp1->version = vsp1_read(vsp1, VI6_IP_VERSION);
-
-       for (i = 0; i < ARRAY_SIZE(vsp1_device_infos); ++i) {
-               if ((vsp1->version & VI6_IP_VERSION_MODEL_MASK) ==
-                   vsp1_device_infos[i].version) {
-                       vsp1->info = &vsp1_device_infos[i];
-                       break;
-               }
-       }
-
+       vsp1->info = vsp1_lookup_info(vsp1);
        if (!vsp1->info) {
-               dev_err(&pdev->dev, "unsupported IP version 0x%08x\n",
-                       vsp1->version);
                vsp1_device_put(vsp1);
                ret = -ENXIO;
                goto done;
index fae7286eb01eb8266775cf738b4e7bd2befce005..4286d13eca328b3ad806e8acce9d445a09bb6d41 100644 (file)
 #define VI6_IP_VERSION_SOC_E3          (0x04 << 0)
 #define VI6_IP_VERSION_SOC_V3U         (0x05 << 0)
 
+#define VI6_IP_VERSION_VSP_SW          (0xfffe << 16) /* SW VSP version */
+
 /* -----------------------------------------------------------------------------
  * RPF CLUT Registers
  */