diff mbox series

[v8,3/5] media: renesas: vsp1: Add support for VSP software version

Message ID 20220419181757.63346-4-biju.das.jz@bp.renesas.com (mailing list archive)
State New, archived
Headers show
Series Add support for RZ/G2L VSPD | expand

Commit Message

Biju Das April 19, 2022, 6:17 p.m. UTC
The VSPD block on RZ/G2L 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>
---
v8:
 * New patch
---
 drivers/media/platform/renesas/vsp1/vsp1.h    |  1 +
 .../media/platform/renesas/vsp1/vsp1_drv.c    | 47 ++++++++++++++-----
 .../media/platform/renesas/vsp1/vsp1_regs.h   |  2 +
 3 files changed, 37 insertions(+), 13 deletions(-)

Comments

Geert Uytterhoeven April 27, 2022, 12:40 p.m. UTC | #1
Hi Biju,

On Tue, Apr 19, 2022 at 8:18 PM Biju Das <biju.das.jz@bp.renesas.com> wrote:
> The VSPD block on RZ/G2L 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>
> ---
> v8:
>  * New patch

Thanks for your patch!

> --- a/drivers/media/platform/renesas/vsp1/vsp1_drv.c
> +++ b/drivers/media/platform/renesas/vsp1/vsp1_drv.c
> @@ -812,11 +812,43 @@ 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)
> +                       break;

return info? ...

> +       }
> +
> +       if (i == ARRAY_SIZE(vsp1_device_infos)) {

... so this check is no longer needed.

> +               dev_err(vsp1->dev, "unsupported IP version 0x%08x\n",
> +                       vsp1->version);
> +               return NULL;
> +       }
> +
> +       return info;
> +}

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
Biju Das April 27, 2022, 1:13 p.m. UTC | #2
Hi Geert,

Thanks for the feedback.

> Subject: Re: [PATCH v8 3/5] media: renesas: vsp1: Add support for VSP
> software version
> 
> Hi Biju,
> 
> On Tue, Apr 19, 2022 at 8:18 PM Biju Das <biju.das.jz@bp.renesas.com>
> wrote:
> > The VSPD block on RZ/G2L does not have a version register.

Will update RZ/G2L->RZ/G2L SoCs

> >
> > This patch adds support for adding VSP software version based on
> > device match.
> >
> > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > ---
> > v8:
> >  * New patch
> 
> Thanks for your patch!
> 
> > --- a/drivers/media/platform/renesas/vsp1/vsp1_drv.c
> > +++ b/drivers/media/platform/renesas/vsp1/vsp1_drv.c
> > @@ -812,11 +812,43 @@ 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)
> > +                       break;
> 
> return info? ...

OK.

> 
> > +       }
> > +
> > +       if (i == ARRAY_SIZE(vsp1_device_infos)) {
> 
> ... so this check is no longer needed.

OK. Will fix this in next version.

Cheers,
Biju
> 
> > +               dev_err(vsp1->dev, "unsupported IP version 0x%08x\n",
> > +                       vsp1->version);
> > +               return NULL;
> > +       }
> > +
> > +       return info;
> > +}
> 
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
> 
> Gr{oetje,eeting}s,
> 
>                         Geert
> 
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-
> m68k.org
> 
> In personal conversations with technical people, I call myself a hacker.
> But when I'm talking to journalists I just say "programmer" or something
> like that.
>                                 -- Linus Torvalds
diff mbox series

Patch

diff --git a/drivers/media/platform/renesas/vsp1/vsp1.h b/drivers/media/platform/renesas/vsp1/vsp1.h
index baf898d577ec..ff4435705abb 100644
--- a/drivers/media/platform/renesas/vsp1/vsp1.h
+++ b/drivers/media/platform/renesas/vsp1/vsp1.h
@@ -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;
 };
 
diff --git a/drivers/media/platform/renesas/vsp1/vsp1_drv.c b/drivers/media/platform/renesas/vsp1/vsp1_drv.c
index 159b68fa0829..c2e242c503d2 100644
--- a/drivers/media/platform/renesas/vsp1/vsp1_drv.c
+++ b/drivers/media/platform/renesas/vsp1/vsp1_drv.c
@@ -812,11 +812,43 @@  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)
+			break;
+	}
+
+	if (i == ARRAY_SIZE(vsp1_device_infos)) {
+		dev_err(vsp1->dev, "unsupported IP version 0x%08x\n",
+			vsp1->version);
+		return NULL;
+	}
+
+	return info;
+}
+
 static int vsp1_probe(struct platform_device *pdev)
 {
 	struct vsp1_device *vsp1;
 	struct device_node *fcp_node;
-	unsigned int i;
 	int ret;
 	int irq;
 
@@ -872,19 +904,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;
diff --git a/drivers/media/platform/renesas/vsp1/vsp1_regs.h b/drivers/media/platform/renesas/vsp1/vsp1_regs.h
index fae7286eb01e..4286d13eca32 100644
--- a/drivers/media/platform/renesas/vsp1/vsp1_regs.h
+++ b/drivers/media/platform/renesas/vsp1/vsp1_regs.h
@@ -781,6 +781,8 @@ 
 #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
  */