Re: [PATCH v3 0/7] clocksource: sh_cmt: Update driver for DT binding rework

2017-09-25 Thread Daniel Lezcano

Hi all,

last call for comments before I merge this series.

Thanks.

  -- Daniel


-- 
  Linaro.org │ Open source software for ARM SoCs

Follow Linaro:   Facebook |
 Twitter |
 Blog



Re: [PATCH] v4l: vsp1: Start and stop DRM pipeline independently of planes

2017-09-25 Thread Laurent Pinchart
Hi Kieran,

On Monday, 25 September 2017 20:25:14 EEST Kieran Bingham wrote:
> On 15/08/17 23:57, Laurent Pinchart wrote:
> > The KMS API supports enabling a CRTC without any plane. To enable that
> > use case, we need to start the pipeline when configuring the LIF,
> > instead of when enabling the first plane.
> 
> Tested and verified on Salvator-X ES1.0 using the KMS Test suite, including
> suspend/resume, in combination with the "[PATCH 0/3] R-Car DU: Clip planes
> to screen boundaries" series.
> 
> Tested-by: Kieran Bingham 
> 
> > Signed-off-by: Laurent Pinchart
> > 
> 
> Reviewed-by: Kieran Bingham 
> 
> > ---
> > 
> >  drivers/media/platform/vsp1/vsp1_drm.c | 37 -
> >  1 file changed, 27 insertions(+), 10 deletions(-)
> > 
> > This patch is based on top of the VSP+DU large patch series queued through
> > Dave's DRM tree for v4.14-rc1. It doesn't can't be merged independently
> > through the linux-media tree for the same kernel version. As the change is
> > not urgent, it can be delayed until v4.15-rc1.
> > 
> > diff --git a/drivers/media/platform/vsp1/vsp1_drm.c
> > b/drivers/media/platform/vsp1/vsp1_drm.c index 4dfbeac8f42c..7ce69f23f50a
> > 100644
> > --- a/drivers/media/platform/vsp1/vsp1_drm.c
> > +++ b/drivers/media/platform/vsp1/vsp1_drm.c
> > @@ -84,8 +84,12 @@ int vsp1_du_setup_lif(struct device *dev, unsigned int
> > pipe_index,> 
> > struct vsp1_drm_pipeline *drm_pipe;
> > struct vsp1_pipeline *pipe;
> > struct vsp1_bru *bru;
> > 
> > +   struct vsp1_entity *entity;
> > +   struct vsp1_entity *next;
> > +   struct vsp1_dl_list *dl;
> > 
> > struct v4l2_subdev_format format;
> > const char *bru_name;
> > 
> > +   unsigned long flags;
> > 
> > unsigned int i;
> > int ret;
> > 
> > @@ -250,6 +254,29 @@ int vsp1_du_setup_lif(struct device *dev, unsigned
> > int pipe_index,> 
> > vsp1_write(vsp1, VI6_DISP_IRQ_STA, 0);
> > vsp1_write(vsp1, VI6_DISP_IRQ_ENB, 0);
> > 
> > +   /* Configure all entities in the pipeline. */
> > +   dl = vsp1_dl_list_get(pipe->output->dlm);
> > +
> > +   list_for_each_entry_safe(entity, next, >entities, list_pipe) {
> > +   vsp1_entity_route_setup(entity, pipe, dl);
> > +
> > +   if (entity->ops->configure) {
> > +   entity->ops->configure(entity, pipe, dl,
> > +  VSP1_ENTITY_PARAMS_INIT);
> > +   entity->ops->configure(entity, pipe, dl,
> > +  VSP1_ENTITY_PARAMS_RUNTIME);
> > +   entity->ops->configure(entity, pipe, dl,
> > +  VSP1_ENTITY_PARAMS_PARTITION);
> > +   }
> 
> Hrm ... this configure section now has quite a lot duplicated from the
> vsp1_du_atomic_flush(). Perhaps we could abstract that part out to a common
> function - but I don't think that's essential.

Let's do so on top of your pending patches then. Feel free to give it a go if 
you want to ;-)

> > +   }
> > +
> > +   vsp1_dl_list_commit(dl);
> > +
> > +   /* Start the pipeline. */
> > +   spin_lock_irqsave(>irqlock, flags);
> > +   vsp1_pipeline_run(pipe);
> > +   spin_unlock_irqrestore(>irqlock, flags);
> > +
> > 
> > dev_dbg(vsp1->dev, "%s: pipeline enabled\n", __func__);
> > 
> > return 0;
> > 
> > @@ -488,7 +515,6 @@ void vsp1_du_atomic_flush(struct device *dev, unsigned
> > int pipe_index)> 
> > struct vsp1_entity *next;
> > struct vsp1_dl_list *dl;
> > const char *bru_name;
> > 
> > -   unsigned long flags;
> > 
> > unsigned int i;
> > int ret;
> > 
> > @@ -570,15 +596,6 @@ void vsp1_du_atomic_flush(struct device *dev,
> > unsigned int pipe_index)> 
> > }
> > 
> > vsp1_dl_list_commit(dl);
> > 
> > -
> > -   /* Start or stop the pipeline if needed. */
> > -   if (!drm_pipe->enabled && pipe->num_inputs) {
> > -   spin_lock_irqsave(>irqlock, flags);
> > -   vsp1_pipeline_run(pipe);
> > -   spin_unlock_irqrestore(>irqlock, flags);
> > -   } else if (drm_pipe->enabled && !pipe->num_inputs) {
> > -   vsp1_pipeline_stop(pipe);
> > -   }
> > 
> >  }
> >  EXPORT_SYMBOL_GPL(vsp1_du_atomic_flush);

-- 
Regards,

Laurent Pinchart



Re: Applied "spi: sh-msiof: Add compatible strings for r8a774[35]" to the spi tree

2017-09-25 Thread Geert Uytterhoeven
Hi Mark,

On Mon, Sep 25, 2017 at 8:45 PM, Mark Brown  wrote:
> On Mon, Sep 25, 2017 at 07:48:44PM +0200, Geert Uytterhoeven wrote:
>> Please drop this patch, as there's no need to add explicit matching for these
>> compatible values. The family-specific compatible values (which the driver
>> already matches against) are sufficient.
>
> While the patch is not needed if people list the fallback property it
> also does no harm and provides a marginal documentation benefit in
> saying that someone has considered if any special handling is useful and
> decided that it isn't.

All true.

My rebuttal is threefold:
  1. Listing the fallback property is mandatory for new SoCs. We only keep
 the per-SoC compatible values in the driver for older SoCs that predate
 the introduction of fallback properties.
  2. Some harm is involved, in the form of increased kernel image size.
  3. When updating DT bindings for new SoCs, we usually add "No driver
 update is needed" to the patch description to clarify. Unfortunately
 that was missed here.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@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


Re: Applied "spi: sh-msiof: Add compatible strings for r8a774[35]" to the spi tree

2017-09-25 Thread Mark Brown
On Mon, Sep 25, 2017 at 07:48:44PM +0200, Geert Uytterhoeven wrote:

> Please drop this patch, as there's no need to add explicit matching for these
> compatible values. The family-specific compatible values (which the driver
> already matches against) are sufficient.

While the patch is not needed if people list the fallback property it
also does no harm and provides a marginal documentation benefit in
saying that someone has considered if any special handling is useful and
decided that it isn't.


signature.asc
Description: PGP signature


Re: Applied "spi: sh-msiof: Add compatible strings for r8a774[35]" to the spi tree

2017-09-25 Thread Geert Uytterhoeven
Hi Mark,

On Mon, Sep 25, 2017 at 6:16 PM, Mark Brown  wrote:
> The patch
>
>spi: sh-msiof: Add compatible strings for r8a774[35]
>
> has been applied to the spi tree at
>
>git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git
>
> All being well this means that it will be integrated into the linux-next
> tree (usually sometime in the next 24 hours) and sent to Linus during
> the next merge window (or sooner if it is a bug fix), however if
> problems are discovered then the patch may be dropped or reverted.
>
> You may get further e-mails resulting from automated or manual testing
> and review of the tree, please engage with people reporting problems and
> send followup patches addressing any issues that are reported if needed.
>
> If any updates are required or you are submitting further changes they
> should be sent as incremental updates against current git, existing
> patches will not be replaced.
>
> Please add any relevant lists and maintainers to the CCs when replying
> to this mail.

Please drop this patch, as there's no need to add explicit matching for these
compatible values. The family-specific compatible values (which the driver
already matches against) are sufficient.

Thanks!

> From bdacfc7b6216dd30d07c10732fd4c0a660c62853 Mon Sep 17 00:00:00 2001
> From: Fabrizio Castro 
> Date: Mon, 25 Sep 2017 09:54:19 +0100
> Subject: [PATCH] spi: sh-msiof: Add compatible strings for r8a774[35]
>
> Signed-off-by: Fabrizio Castro 
> Signed-off-by: Mark Brown 
> ---
>  drivers/spi/spi-sh-msiof.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
> index 0eb1e9583485..00808448cf35 100644
> --- a/drivers/spi/spi-sh-msiof.c
> +++ b/drivers/spi/spi-sh-msiof.c
> @@ -1021,6 +1021,8 @@ static const struct sh_msiof_chipdata rcar_gen3_data = {
>
>  static const struct of_device_id sh_msiof_match[] = {
> { .compatible = "renesas,sh-mobile-msiof", .data = _data },
> +   { .compatible = "renesas,msiof-r8a7743",   .data = _gen2_data },
> +   { .compatible = "renesas,msiof-r8a7745",   .data = _gen2_data },
> { .compatible = "renesas,msiof-r8a7790",   .data = _gen2_data },
> { .compatible = "renesas,msiof-r8a7791",   .data = _gen2_data },
> { .compatible = "renesas,msiof-r8a7792",   .data = _gen2_data },

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@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


Re: [PATCH 1/3] drm: rcar-du: Share plane atomic check code between Gen2 and Gen3

2017-09-25 Thread Kieran Bingham
Hi Laurent,

On 16/08/17 00:03, Laurent Pinchart wrote:
> The plane atomic check implementation is identical on Gen2 (DU planes)
> and Gen3 (VSP planes), but two separate functions exist as they operate
> on different data structures. Refactor the code to share the
> implementation.
> 
> Signed-off-by: Laurent Pinchart 

This looks good to me.

Reviewed-by: Kieran Bingham 

> ---
>  drivers/gpu/drm/rcar-du/rcar_du_plane.c | 27 +--
>  drivers/gpu/drm/rcar-du/rcar_du_plane.h |  4 
>  drivers/gpu/drm/rcar-du/rcar_du_vsp.c   | 22 +-
>  3 files changed, 22 insertions(+), 31 deletions(-)
> 
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_plane.c 
> b/drivers/gpu/drm/rcar-du/rcar_du_plane.c
> index 61833cc1c699..4f076c364f25 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_plane.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_plane.c
> @@ -565,27 +565,26 @@ void __rcar_du_plane_setup(struct rcar_du_group *rgrp,
>   }
>  }
>  
> -static int rcar_du_plane_atomic_check(struct drm_plane *plane,
> -   struct drm_plane_state *state)
> +int __rcar_du_plane_atomic_check(struct drm_plane *plane,
> +  struct drm_plane_state *state,
> +  const struct rcar_du_format_info **format)
>  {
> - struct rcar_du_plane_state *rstate = to_rcar_plane_state(state);
> - struct rcar_du_plane *rplane = to_rcar_plane(plane);
> - struct rcar_du_device *rcdu = rplane->group->dev;
> + struct drm_device *dev = plane->dev;
>  
>   if (!state->fb || !state->crtc) {
> - rstate->format = NULL;
> + *format = NULL;
>   return 0;
>   }
>  
>   if (state->src_w >> 16 != state->crtc_w ||
>   state->src_h >> 16 != state->crtc_h) {
> - dev_dbg(rcdu->dev, "%s: scaling not supported\n", __func__);
> + dev_dbg(dev->dev, "%s: scaling not supported\n", __func__);
>   return -EINVAL;
>   }
>  
> - rstate->format = rcar_du_format_info(state->fb->format->format);
> - if (rstate->format == NULL) {
> - dev_dbg(rcdu->dev, "%s: unsupported format %08x\n", __func__,
> + *format = rcar_du_format_info(state->fb->format->format);
> + if (*format == NULL) {
> + dev_dbg(dev->dev, "%s: unsupported format %08x\n", __func__,
>   state->fb->format->format);
>   return -EINVAL;
>   }
> @@ -593,6 +592,14 @@ static int rcar_du_plane_atomic_check(struct drm_plane 
> *plane,
>   return 0;
>  }
>  
> +static int rcar_du_plane_atomic_check(struct drm_plane *plane,
> +   struct drm_plane_state *state)
> +{
> + struct rcar_du_plane_state *rstate = to_rcar_plane_state(state);
> +
> + return __rcar_du_plane_atomic_check(plane, state, >format);
> +}
> +
>  static void rcar_du_plane_atomic_update(struct drm_plane *plane,
>   struct drm_plane_state *old_state)
>  {
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_plane.h 
> b/drivers/gpu/drm/rcar-du/rcar_du_plane.h
> index f62e09f195de..890321b4665d 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_plane.h
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_plane.h
> @@ -73,6 +73,10 @@ to_rcar_plane_state(struct drm_plane_state *state)
>  int rcar_du_atomic_check_planes(struct drm_device *dev,
>   struct drm_atomic_state *state);
>  
> +int __rcar_du_plane_atomic_check(struct drm_plane *plane,
> +  struct drm_plane_state *state,
> +  const struct rcar_du_format_info **format);
> +
>  int rcar_du_planes_init(struct rcar_du_group *rgrp);
>  
>  void __rcar_du_plane_setup(struct rcar_du_group *rgrp,
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c 
> b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
> index 2c96147bc444..dd66dcb8da23 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
> @@ -268,28 +268,8 @@ static int rcar_du_vsp_plane_atomic_check(struct 
> drm_plane *plane,
> struct drm_plane_state *state)
>  {
>   struct rcar_du_vsp_plane_state *rstate = to_rcar_vsp_plane_state(state);
> - struct rcar_du_vsp_plane *rplane = to_rcar_vsp_plane(plane);
> - struct rcar_du_device *rcdu = rplane->vsp->dev;
> -
> - if (!state->fb || !state->crtc) {
> - rstate->format = NULL;
> - return 0;
> - }
>  
> - if (state->src_w >> 16 != state->crtc_w ||
> - state->src_h >> 16 != state->crtc_h) {
> - dev_dbg(rcdu->dev, "%s: scaling not supported\n", __func__);
> - return -EINVAL;
> - }
> -
> - rstate->format = rcar_du_format_info(state->fb->format->format);
> - if (rstate->format == NULL) {
> - dev_dbg(rcdu->dev, "%s: unsupported 

Re: [PATCH 0/3] R-Car DU: Clip planes to screen boundaries

2017-09-25 Thread Kieran Bingham
Hi Laurent,

Thankyou for the patches,

On 16/08/17 00:03, Laurent Pinchart wrote:
> Hello,
> 
> This patch series fixes support for planes that cross the screen boundaries.
> The KMS API supports such a configuration, but the DU and VSP hardware
> doesn't. This leads to different kind of dispay artifacts or hangs.
> 
> The series starts with a bit of refactoring to share existing code and make it
> easier to share new code (1/3). Patch 2/3 then reject planes that are fully
> off-screen as they don't work properly and we have currently no use case for
> them. Finally, patch 3/3 clips planes to screen boundaries to fix the main
> issue.
> 
> The patches are based on top of Dave's latest master branch.

Series tested and verified on Salvator-X ES1.0 using the KMS Test suite,
including suspend/resume, in combination with the "v4l: vsp1: Start and stop DRM
pipeline independently of planes" patch.

Tested-by: Kieran Bingham 

> Laurent Pinchart (3):
>   drm: rcar-du: Share plane atomic check code between Gen2 and Gen3
>   drm: rcar-du: Reject planes located fully off-screen
>   drm: rcar-du: Clip planes to screen boundaries
> 
>  drivers/gpu/drm/rcar-du/rcar_du_plane.c | 109 
> 
>  drivers/gpu/drm/rcar-du/rcar_du_plane.h |   8 +++
>  drivers/gpu/drm/rcar-du/rcar_du_vsp.c   |  43 -
>  3 files changed, 105 insertions(+), 55 deletions(-)
> 


Re: [PATCH] v4l: vsp1: Start and stop DRM pipeline independently of planes

2017-09-25 Thread Kieran Bingham
Hi Laurent,

Thankyou for the patch.

On 15/08/17 23:57, Laurent Pinchart wrote:
> The KMS API supports enabling a CRTC without any plane. To enable that
> use case, we need to start the pipeline when configuring the LIF,
> instead of when enabling the first plane.

Tested and verified on Salvator-X ES1.0 using the KMS Test suite, including
suspend/resume, in combination with the "[PATCH 0/3] R-Car DU: Clip planes to
screen boundaries" series.

Tested-by: Kieran Bingham 

> Signed-off-by: Laurent Pinchart 

Reviewed-by: Kieran Bingham 

> ---
>  drivers/media/platform/vsp1/vsp1_drm.c | 37 
> +-
>  1 file changed, 27 insertions(+), 10 deletions(-)
> 
> This patch is based on top of the VSP+DU large patch series queued through
> Dave's DRM tree for v4.14-rc1. It doesn't can't be merged independently
> through the linux-media tree for the same kernel version. As the change is not
> urgent, it can be delayed until v4.15-rc1.
> 
> diff --git a/drivers/media/platform/vsp1/vsp1_drm.c 
> b/drivers/media/platform/vsp1/vsp1_drm.c
> index 4dfbeac8f42c..7ce69f23f50a 100644
> --- a/drivers/media/platform/vsp1/vsp1_drm.c
> +++ b/drivers/media/platform/vsp1/vsp1_drm.c
> @@ -84,8 +84,12 @@ int vsp1_du_setup_lif(struct device *dev, unsigned int 
> pipe_index,
>   struct vsp1_drm_pipeline *drm_pipe;
>   struct vsp1_pipeline *pipe;
>   struct vsp1_bru *bru;
> + struct vsp1_entity *entity;
> + struct vsp1_entity *next;
> + struct vsp1_dl_list *dl;
>   struct v4l2_subdev_format format;
>   const char *bru_name;
> + unsigned long flags;
>   unsigned int i;
>   int ret;
>  
> @@ -250,6 +254,29 @@ int vsp1_du_setup_lif(struct device *dev, unsigned int 
> pipe_index,
>   vsp1_write(vsp1, VI6_DISP_IRQ_STA, 0);
>   vsp1_write(vsp1, VI6_DISP_IRQ_ENB, 0);
>  
> + /* Configure all entities in the pipeline. */
> + dl = vsp1_dl_list_get(pipe->output->dlm);
> +
> + list_for_each_entry_safe(entity, next, >entities, list_pipe) {
> + vsp1_entity_route_setup(entity, pipe, dl);
> +
> + if (entity->ops->configure) {
> + entity->ops->configure(entity, pipe, dl,
> +VSP1_ENTITY_PARAMS_INIT);
> + entity->ops->configure(entity, pipe, dl,
> +VSP1_ENTITY_PARAMS_RUNTIME);
> + entity->ops->configure(entity, pipe, dl,
> +VSP1_ENTITY_PARAMS_PARTITION);
> + }

Hrm ... this configure section now has quite a lot duplicated from the
vsp1_du_atomic_flush(). Perhaps we could abstract that part out to a common
function - but I don't think that's essential.


> + }
> +
> + vsp1_dl_list_commit(dl);
> +
> + /* Start the pipeline. */
> + spin_lock_irqsave(>irqlock, flags);
> + vsp1_pipeline_run(pipe);
> + spin_unlock_irqrestore(>irqlock, flags);
> +
>   dev_dbg(vsp1->dev, "%s: pipeline enabled\n", __func__);
>  
>   return 0;
> @@ -488,7 +515,6 @@ void vsp1_du_atomic_flush(struct device *dev, unsigned 
> int pipe_index)
>   struct vsp1_entity *next;
>   struct vsp1_dl_list *dl;
>   const char *bru_name;
> - unsigned long flags;
>   unsigned int i;
>   int ret;
>  
> @@ -570,15 +596,6 @@ void vsp1_du_atomic_flush(struct device *dev, unsigned 
> int pipe_index)
>   }
>  
>   vsp1_dl_list_commit(dl);
> -
> - /* Start or stop the pipeline if needed. */
> - if (!drm_pipe->enabled && pipe->num_inputs) {
> - spin_lock_irqsave(>irqlock, flags);
> - vsp1_pipeline_run(pipe);
> - spin_unlock_irqrestore(>irqlock, flags);
> - } else if (drm_pipe->enabled && !pipe->num_inputs) {
> - vsp1_pipeline_stop(pipe);
> - }
>  }
>  EXPORT_SYMBOL_GPL(vsp1_du_atomic_flush);
>  
> 


Applied "spi: sh-msiof: Add compatible strings for r8a774[35]" to the spi tree

2017-09-25 Thread Mark Brown
The patch

   spi: sh-msiof: Add compatible strings for r8a774[35]

has been applied to the spi tree at

   git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From bdacfc7b6216dd30d07c10732fd4c0a660c62853 Mon Sep 17 00:00:00 2001
From: Fabrizio Castro 
Date: Mon, 25 Sep 2017 09:54:19 +0100
Subject: [PATCH] spi: sh-msiof: Add compatible strings for r8a774[35]

Signed-off-by: Fabrizio Castro 
Signed-off-by: Mark Brown 
---
 drivers/spi/spi-sh-msiof.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
index 0eb1e9583485..00808448cf35 100644
--- a/drivers/spi/spi-sh-msiof.c
+++ b/drivers/spi/spi-sh-msiof.c
@@ -1021,6 +1021,8 @@ static const struct sh_msiof_chipdata rcar_gen3_data = {
 
 static const struct of_device_id sh_msiof_match[] = {
{ .compatible = "renesas,sh-mobile-msiof", .data = _data },
+   { .compatible = "renesas,msiof-r8a7743",   .data = _gen2_data },
+   { .compatible = "renesas,msiof-r8a7745",   .data = _gen2_data },
{ .compatible = "renesas,msiof-r8a7790",   .data = _gen2_data },
{ .compatible = "renesas,msiof-r8a7791",   .data = _gen2_data },
{ .compatible = "renesas,msiof-r8a7792",   .data = _gen2_data },
-- 
2.14.1



Applied "spi: sh-msiof: Add r8a774[35] to the compatible list" to the spi tree

2017-09-25 Thread Mark Brown
The patch

   spi: sh-msiof: Add r8a774[35] to the compatible list

has been applied to the spi tree at

   git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 4702f4b23a2fc6196abacf515a959e69176da40e Mon Sep 17 00:00:00 2001
From: Fabrizio Castro 
Date: Mon, 25 Sep 2017 09:54:20 +0100
Subject: [PATCH] spi: sh-msiof: Add r8a774[35] to the compatible list

Signed-off-by: Fabrizio Castro 
Reviewed-by: Geert Uytterhoeven 
Signed-off-by: Mark Brown 
---
 Documentation/devicetree/bindings/spi/sh-msiof.txt | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/spi/sh-msiof.txt 
b/Documentation/devicetree/bindings/spi/sh-msiof.txt
index e865855726a2..bdd83959019c 100644
--- a/Documentation/devicetree/bindings/spi/sh-msiof.txt
+++ b/Documentation/devicetree/bindings/spi/sh-msiof.txt
@@ -1,7 +1,9 @@
 Renesas MSIOF spi controller
 
 Required properties:
-- compatible   : "renesas,msiof-r8a7790" (R-Car H2)
+- compatible   : "renesas,msiof-r8a7743" (RZ/G1M)
+"renesas,msiof-r8a7745" (RZ/G1E)
+"renesas,msiof-r8a7790" (R-Car H2)
 "renesas,msiof-r8a7791" (R-Car M2-W)
 "renesas,msiof-r8a7792" (R-Car V2H)
 "renesas,msiof-r8a7793" (R-Car M2-N)
@@ -10,7 +12,7 @@ Required properties:
 "renesas,msiof-r8a7796" (R-Car M3-W)
 "renesas,msiof-sh73a0" (SH-Mobile AG5)
 "renesas,sh-mobile-msiof" (generic SH-Mobile 
compatibile device)
-"renesas,rcar-gen2-msiof" (generic R-Car Gen2 
compatible device)
+"renesas,rcar-gen2-msiof" (generic R-Car Gen2 and 
RZ/G1 compatible device)
 "renesas,rcar-gen3-msiof" (generic R-Car Gen3 
compatible device)
 "renesas,sh-msiof"  (deprecated)
 
-- 
2.14.1



RE: [PATCH 1/2] spi: sh-msiof: Add compatible strings for r8a774[35]

2017-09-25 Thread Fabrizio Castro
Hello Geert,

Thank you for getting back to me.

> -Original Message-
> From: geert.uytterhoe...@gmail.com [mailto:geert.uytterhoe...@gmail.com] On 
> Behalf Of Geert Uytterhoeven
> Sent: 25 September 2017 12:22
> To: Fabrizio Castro 
> Cc: Mark Brown ; Rob Herring ; Mark 
> Rutland ; linux-spi
> ; devicet...@vger.kernel.org; Linux-Renesas 
> ; Chris Paterson
> ; Biju Das 
> Subject: Re: [PATCH 1/2] spi: sh-msiof: Add compatible strings for r8a774[35]
>
> Hi Fabrizio,
>
> On Mon, Sep 25, 2017 at 10:54 AM, Fabrizio Castro
>  wrote:
> > Signed-off-by: Fabrizio Castro 
>
> This patch is not needed...
>
> > ---
> >  drivers/spi/spi-sh-msiof.c | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
> > index 0eb1e95..0080844 100644
> > --- a/drivers/spi/spi-sh-msiof.c
> > +++ b/drivers/spi/spi-sh-msiof.c
> > @@ -1021,6 +1021,8 @@ static const struct sh_msiof_chipdata rcar_gen3_data 
> > = {
> >
> >  static const struct of_device_id sh_msiof_match[] = {
> > { .compatible = "renesas,sh-mobile-msiof", .data = _data },
> > +   { .compatible = "renesas,msiof-r8a7743",   .data = _gen2_data 
> > },
> > +   { .compatible = "renesas,msiof-r8a7745",   .data = _gen2_data 
> > },
> > { .compatible = "renesas,msiof-r8a7790",   .data = _gen2_data 
> > },
> > { .compatible = "renesas,msiof-r8a7791",   .data = _gen2_data 
> > },
> > { .compatible = "renesas,msiof-r8a7792",   .data = _gen2_data 
> > },
>
> ... as the driver already matches against the family-specific compatible value
> below:
>
> { .compatible = "renesas,rcar-gen2-msiof", .data = _gen2_data },

We suspected this was the case, but we weren't sure.
I apologize for wasting your time.

Cheers,
Fabrizio

>
> Gr{oetje,eeting}s,
>
> Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- 
> ge...@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



Renesas Electronics Europe Ltd, Dukes Meadow, Millboard Road, Bourne End, 
Buckinghamshire, SL8 5FH, UK. Registered in England & Wales under Registered 
No. 04586709.


Re: [PATCH 1/2] spi: sh-msiof: Add compatible strings for r8a774[35]

2017-09-25 Thread Geert Uytterhoeven
Hi Fabrizio,

On Mon, Sep 25, 2017 at 10:54 AM, Fabrizio Castro
 wrote:
> Signed-off-by: Fabrizio Castro 

This patch is not needed...

> ---
>  drivers/spi/spi-sh-msiof.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
> index 0eb1e95..0080844 100644
> --- a/drivers/spi/spi-sh-msiof.c
> +++ b/drivers/spi/spi-sh-msiof.c
> @@ -1021,6 +1021,8 @@ static const struct sh_msiof_chipdata rcar_gen3_data = {
>
>  static const struct of_device_id sh_msiof_match[] = {
> { .compatible = "renesas,sh-mobile-msiof", .data = _data },
> +   { .compatible = "renesas,msiof-r8a7743",   .data = _gen2_data },
> +   { .compatible = "renesas,msiof-r8a7745",   .data = _gen2_data },
> { .compatible = "renesas,msiof-r8a7790",   .data = _gen2_data },
> { .compatible = "renesas,msiof-r8a7791",   .data = _gen2_data },
> { .compatible = "renesas,msiof-r8a7792",   .data = _gen2_data },

... as the driver already matches against the family-specific compatible value
below:

{ .compatible = "renesas,rcar-gen2-msiof", .data = _gen2_data },

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@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


Re: [PATCH 2/2] dt-bindings: spi: sh-msiof: Add r8a774[35] to the compatible list

2017-09-25 Thread Geert Uytterhoeven
On Mon, Sep 25, 2017 at 10:54 AM, Fabrizio Castro
 wrote:
> Signed-off-by: Fabrizio Castro 
> ---
>  Documentation/devicetree/bindings/spi/sh-msiof.txt | 6 --

Reviewed-by: Geert Uytterhoeven 

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@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


Re: [PATCH v6 25/25] rcar-vin: enable support for r8a7796

2017-09-25 Thread Hans Verkuil
On 23/08/17 01:26, Niklas Söderlund wrote:
> Add the SoC specific information for Renesas r8a7796.
> 
> Signed-off-by: Niklas Söderlund 

Reviewed-by: Hans Verkuil 

Regards,

Hans

> ---
>  .../devicetree/bindings/media/rcar_vin.txt |  1 +
>  drivers/media/platform/rcar-vin/rcar-core.c| 64 
> ++
>  2 files changed, 65 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/media/rcar_vin.txt 
> b/Documentation/devicetree/bindings/media/rcar_vin.txt
> index be38ad89d71ad05d..767358f39512aa17 100644
> --- a/Documentation/devicetree/bindings/media/rcar_vin.txt
> +++ b/Documentation/devicetree/bindings/media/rcar_vin.txt
> @@ -10,6 +10,7 @@ always slaves and support multiple input channels which can 
> be either RGB,
>  YUVU, BT656 or CSI-2.
>  
>   - compatible: Must be one or more of the following
> +   - "renesas,vin-r8a7796" for the R8A7796 device
> - "renesas,vin-r8a7795" for the R8A7795 device
> - "renesas,vin-r8a7794" for the R8A7794 device
> - "renesas,vin-r8a7793" for the R8A7793 device
> diff --git a/drivers/media/platform/rcar-vin/rcar-core.c 
> b/drivers/media/platform/rcar-vin/rcar-core.c
> index 58d903ab9fb83faf..e01edd5f5925d26c 100644
> --- a/drivers/media/platform/rcar-vin/rcar-core.c
> +++ b/drivers/media/platform/rcar-vin/rcar-core.c
> @@ -1116,7 +1116,71 @@ static const struct rvin_info rcar_info_r8a7795es1 = {
>   },
>  };
>  
> +static const struct rvin_info rcar_info_r8a7796 = {
> + .chip = RCAR_GEN3,
> + .use_mc = true,
> + .max_width = 4096,
> + .max_height = 4096,
> +
> + .num_chsels = 5,
> + .chsels = {
> + {
> + { .csi = RVIN_CSI40, .chan = 0 },
> + { .csi = RVIN_CSI20, .chan = 0 },
> + { .csi = RVIN_NC, .chan = 0 },
> + { .csi = RVIN_CSI40, .chan = 0 },
> + { .csi = RVIN_CSI20, .chan = 0 },
> + }, {
> + { .csi = RVIN_CSI20, .chan = 0 },
> + { .csi = RVIN_NC, .chan = 0 },
> + { .csi = RVIN_CSI40, .chan = 0 },
> + { .csi = RVIN_CSI40, .chan = 1 },
> + { .csi = RVIN_CSI20, .chan = 1 },
> + }, {
> + { .csi = RVIN_NC, .chan = 0 },
> + { .csi = RVIN_CSI40, .chan = 0 },
> + { .csi = RVIN_CSI20, .chan = 0 },
> + { .csi = RVIN_CSI40, .chan = 2 },
> + { .csi = RVIN_CSI20, .chan = 2 },
> + }, {
> + { .csi = RVIN_CSI40, .chan = 1 },
> + { .csi = RVIN_CSI20, .chan = 1 },
> + { .csi = RVIN_NC, .chan = 1 },
> + { .csi = RVIN_CSI40, .chan = 3 },
> + { .csi = RVIN_CSI20, .chan = 3 },
> + }, {
> + { .csi = RVIN_CSI40, .chan = 0 },
> + { .csi = RVIN_CSI20, .chan = 0 },
> + { .csi = RVIN_NC, .chan = 0 },
> + { .csi = RVIN_CSI40, .chan = 0 },
> + { .csi = RVIN_CSI20, .chan = 0 },
> + }, {
> + { .csi = RVIN_CSI20, .chan = 0 },
> + { .csi = RVIN_NC, .chan = 0 },
> + { .csi = RVIN_CSI40, .chan = 0 },
> + { .csi = RVIN_CSI40, .chan = 1 },
> + { .csi = RVIN_CSI20, .chan = 1 },
> + }, {
> + { .csi = RVIN_NC, .chan = 0 },
> + { .csi = RVIN_CSI40, .chan = 0 },
> + { .csi = RVIN_CSI20, .chan = 0 },
> + { .csi = RVIN_CSI40, .chan = 2 },
> + { .csi = RVIN_CSI20, .chan = 2 },
> + }, {
> + { .csi = RVIN_CSI40, .chan = 1 },
> + { .csi = RVIN_CSI20, .chan = 1 },
> + { .csi = RVIN_NC, .chan = 1 },
> + { .csi = RVIN_CSI40, .chan = 3 },
> + { .csi = RVIN_CSI20, .chan = 3 },
> + },
> + },
> +};
> +
>  static const struct of_device_id rvin_of_id_table[] = {
> + {
> + .compatible = "renesas,vin-r8a7796",
> + .data = _info_r8a7796,
> + },
>   {
>   .compatible = "renesas,vin-r8a7795",
>   .data = _info_r8a7795,
> 



Re: [PATCH v6 24/25] rcar-vin: enable support for r8a7795

2017-09-25 Thread Hans Verkuil
On 23/08/17 01:26, Niklas Söderlund wrote:
> Add the SoC specific information for Renesas r8a7795.
> 
> Signed-off-by: Niklas Söderlund 

Reviewed-by: Hans Verkuil 

Regards,

Hans

> ---
>  drivers/media/platform/rcar-vin/Kconfig |   2 +-
>  drivers/media/platform/rcar-vin/rcar-core.c | 145 
> 
>  2 files changed, 146 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/rcar-vin/Kconfig 
> b/drivers/media/platform/rcar-vin/Kconfig
> index af4c98b44d2e22cb..8fa7ee468c63afb9 100644
> --- a/drivers/media/platform/rcar-vin/Kconfig
> +++ b/drivers/media/platform/rcar-vin/Kconfig
> @@ -6,7 +6,7 @@ config VIDEO_RCAR_VIN
>   select V4L2_FWNODE
>   ---help---
> Support for Renesas R-Car Video Input (VIN) driver.
> -   Supports R-Car Gen2 SoCs.
> +   Supports R-Car Gen2 and Gen3 SoCs.
>  
> To compile this driver as a module, choose M here: the
> module will be called rcar-vin.
> diff --git a/drivers/media/platform/rcar-vin/rcar-core.c 
> b/drivers/media/platform/rcar-vin/rcar-core.c
> index dec91e2f3ccdbd93..58d903ab9fb83faf 100644
> --- a/drivers/media/platform/rcar-vin/rcar-core.c
> +++ b/drivers/media/platform/rcar-vin/rcar-core.c
> @@ -21,6 +21,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  #include 
>  
> @@ -987,7 +988,139 @@ static const struct rvin_info rcar_info_gen2 = {
>   .max_height = 2048,
>  };
>  
> +static const struct rvin_info rcar_info_r8a7795 = {
> + .chip = RCAR_GEN3,
> + .use_mc = true,
> + .max_width = 4096,
> + .max_height = 4096,
> +
> + .num_chsels = 5,
> + .chsels = {
> + {
> + { .csi = RVIN_CSI40, .chan = 0 },
> + { .csi = RVIN_CSI20, .chan = 0 },
> + { .csi = RVIN_CSI40, .chan = 1 },
> + { .csi = RVIN_CSI40, .chan = 0 },
> + { .csi = RVIN_CSI20, .chan = 0 },
> + }, {
> + { .csi = RVIN_CSI20, .chan = 0 },
> + { .csi = RVIN_CSI40, .chan = 1 },
> + { .csi = RVIN_CSI40, .chan = 0 },
> + { .csi = RVIN_CSI40, .chan = 1 },
> + { .csi = RVIN_CSI20, .chan = 1 },
> + }, {
> + { .csi = RVIN_CSI20, .chan = 1 },
> + { .csi = RVIN_CSI40, .chan = 0 },
> + { .csi = RVIN_CSI20, .chan = 0 },
> + { .csi = RVIN_CSI40, .chan = 2 },
> + { .csi = RVIN_CSI20, .chan = 2 },
> + }, {
> + { .csi = RVIN_CSI40, .chan = 1 },
> + { .csi = RVIN_CSI20, .chan = 1 },
> + { .csi = RVIN_CSI20, .chan = 1 },
> + { .csi = RVIN_CSI40, .chan = 3 },
> + { .csi = RVIN_CSI20, .chan = 3 },
> + }, {
> + { .csi = RVIN_CSI41, .chan = 0 },
> + { .csi = RVIN_CSI20, .chan = 0 },
> + { .csi = RVIN_CSI41, .chan = 1 },
> + { .csi = RVIN_CSI41, .chan = 0 },
> + { .csi = RVIN_CSI20, .chan = 0 },
> + }, {
> + { .csi = RVIN_CSI20, .chan = 0 },
> + { .csi = RVIN_CSI41, .chan = 1 },
> + { .csi = RVIN_CSI41, .chan = 0 },
> + { .csi = RVIN_CSI41, .chan = 1 },
> + { .csi = RVIN_CSI20, .chan = 1 },
> + }, {
> + { .csi = RVIN_CSI20, .chan = 1 },
> + { .csi = RVIN_CSI41, .chan = 0 },
> + { .csi = RVIN_CSI20, .chan = 0 },
> + { .csi = RVIN_CSI41, .chan = 2 },
> + { .csi = RVIN_CSI20, .chan = 2 },
> + }, {
> + { .csi = RVIN_CSI41, .chan = 1 },
> + { .csi = RVIN_CSI20, .chan = 1 },
> + { .csi = RVIN_CSI20, .chan = 1 },
> + { .csi = RVIN_CSI41, .chan = 3 },
> + { .csi = RVIN_CSI20, .chan = 3 },
> + },
> + },
> +};
> +
> +static const struct rvin_info rcar_info_r8a7795es1 = {
> + .chip = RCAR_GEN3,
> + .use_mc = true,
> + .max_width = 4096,
> + .max_height = 4096,
> +
> + .num_chsels = 6,
> + .chsels = {
> + {
> + { .csi = RVIN_CSI40, .chan = 0 },
> + { .csi = RVIN_CSI20, .chan = 0 },
> + { .csi = RVIN_CSI21, .chan = 0 },
> + { .csi = RVIN_CSI40, .chan = 0 },
> + { .csi = RVIN_CSI20, .chan = 0 },
> + { .csi = RVIN_CSI21, .chan = 0 },
> + }, {
> + { .csi = RVIN_CSI20, .chan = 0 },
> + { .csi = RVIN_CSI21, .chan = 0 },
> + { .csi = 

Re: [PATCH v6 23/25] rcar-vin: extend {start,stop}_streaming to work with media controller

2017-09-25 Thread Hans Verkuil
On 23/08/17 01:26, Niklas Söderlund wrote:
> The procedure to start or stop streaming using the none MC single

none MC -> non-MC

> subdevice and the MC graph and multiple subdevices are quiet different.

quiet -> quite

> Create a new function to abstract which method is used based on which
> mode the driver is running in and add logic to start the MC graph.
> 
> Signed-off-by: Niklas Söderlund 
> ---
>  drivers/media/platform/rcar-vin/rcar-dma.c | 112 
> +++--
>  1 file changed, 105 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/media/platform/rcar-vin/rcar-dma.c 
> b/drivers/media/platform/rcar-vin/rcar-dma.c
> index de1486ee2786b499..499253f94390f43e 100644
> --- a/drivers/media/platform/rcar-vin/rcar-dma.c
> +++ b/drivers/media/platform/rcar-vin/rcar-dma.c
> @@ -1087,15 +1087,115 @@ static void rvin_buffer_queue(struct vb2_buffer *vb)
>   spin_unlock_irqrestore(>qlock, flags);
>  }
>  
> +static int rvin_set_stream(struct rvin_dev *vin, int on)
> +{
> + struct v4l2_subdev_format fmt = {
> + .which = V4L2_SUBDEV_FORMAT_ACTIVE,
> + };
> + struct media_pipeline *pipe;
> + struct  v4l2_subdev *sd;
> + struct media_pad *pad;
> + int ret;
> +
> + /* Not media controller used, simply pass operation to subdevice */
> + if (!vin->info->use_mc) {
> + ret = v4l2_subdev_call(vin->digital.subdev, video, s_stream,
> +on);
> +
> + return ret == -ENOIOCTLCMD ? 0 : ret;
> + }
> +
> + pad = media_entity_remote_pad(>pad);
> + if (!pad)
> + return -EPIPE;
> +
> + sd = media_entity_to_v4l2_subdev(pad->entity);
> + if (!sd)
> + return -EPIPE;
> +
> + if (on) {

Handle !on first and return.

The remaining code then has one indent level less.

> + fmt.pad = pad->index;
> + if (v4l2_subdev_call(sd, pad, get_fmt, NULL, ))
> + return -EPIPE;
> +
> + switch (fmt.format.code) {
> + case MEDIA_BUS_FMT_YUYV8_1X16:
> + case MEDIA_BUS_FMT_UYVY8_2X8:
> + case MEDIA_BUS_FMT_UYVY10_2X10:
> + case MEDIA_BUS_FMT_RGB888_1X24:
> + vin->code = fmt.format.code;
> + break;
> + default:
> + return -EPIPE;
> + }
> +
> + switch (fmt.format.field) {
> + case V4L2_FIELD_TOP:
> + case V4L2_FIELD_BOTTOM:
> + case V4L2_FIELD_NONE:
> + case V4L2_FIELD_INTERLACED_TB:
> + case V4L2_FIELD_INTERLACED_BT:
> + case V4L2_FIELD_INTERLACED:
> + case V4L2_FIELD_SEQ_TB:
> + case V4L2_FIELD_SEQ_BT:
> + /* Supported nativly */
> + break;
> + case V4L2_FIELD_ALTERNATE:
> + switch (vin->format.field) {
> + case V4L2_FIELD_TOP:
> + case V4L2_FIELD_BOTTOM:
> + case V4L2_FIELD_NONE:
> + break;
> + case V4L2_FIELD_INTERLACED_TB:
> + case V4L2_FIELD_INTERLACED_BT:
> + case V4L2_FIELD_INTERLACED:
> + case V4L2_FIELD_SEQ_TB:
> + case V4L2_FIELD_SEQ_BT:
> + /* Use VIN hardware to combine the two fields */
> + fmt.format.height *= 2;
> + break;
> + default:
> + return -EPIPE;
> + }
> + break;
> + default:
> + return -EPIPE;
> + }
> +
> + if (fmt.format.width != vin->format.width ||
> + fmt.format.height != vin->format.height)
> + return -EPIPE;
> +
> + pipe = sd->entity.pipe ? sd->entity.pipe : >vdev.pipe;
> + if (media_pipeline_start(>vdev.entity, pipe))
> + return -EPIPE;
> +
> + ret = v4l2_subdev_call(sd, video, s_stream, 1);
> + if (ret == -ENOIOCTLCMD)
> + ret = 0;
> + if (ret)
> + media_pipeline_stop(>vdev.entity);
> + } else {
> + media_pipeline_stop(>vdev.entity);
> + ret = v4l2_subdev_call(sd, video, s_stream, 0);
> + }
> +
> + return ret;
> +}
> +
>  static int rvin_start_streaming(struct vb2_queue *vq, unsigned int count)
>  {
>   struct rvin_dev *vin = vb2_get_drv_priv(vq);
> - struct v4l2_subdev *sd;
>   unsigned long flags;
>   int ret;
>  
> - sd = vin_to_source(vin);
> - v4l2_subdev_call(sd, video, s_stream, 1);
> + ret = rvin_set_stream(vin, 1);
> + if (ret) {
> + spin_lock_irqsave(>qlock, flags);
> + 

Re: [PATCH v6 22/25] rcar-vin: add link notify for Gen3

2017-09-25 Thread Hans Verkuil
On 23/08/17 01:26, Niklas Söderlund wrote:
> Add the ability to process media device link change request. Link
> enablement are a bit complicated on Gen3, if it's possible to enable a

enablement are -> enabling is

if -> whether or not

> link depends on what other links already are enabled. On Gen3 the 8 VIN

VIN -> VINs

> are split into two subgroups (VIN0-3 and VIN4-7) and from a routing
> perspective these two groups are independent of each other. Each
> subgroups routing is controlled by the subgroup VIN master instance

subgroups -> subgroup's

> (VIN0 and VIN4).
> 
> There are a limited number of possible route setups available for each
> subgroup and the configuration of each setup is dictated by the
> hardware. On H3 for example there are 6 possible route setups for each
> subgroup to choose from.
> 
> This leads to the media device link notification code being rather large
> since it will find the best routing configuration to try and accommodate
> as many links as possible. When it's not possible to enable a new link
> due to hardware constrains the link_notifier callback will return
> -EMLINK.
> 
> Signed-off-by: Niklas Söderlund 

See various comments below.

> ---
>  drivers/media/platform/rcar-vin/rcar-core.c | 203 
> 
>  1 file changed, 203 insertions(+)
> 
> diff --git a/drivers/media/platform/rcar-vin/rcar-core.c 
> b/drivers/media/platform/rcar-vin/rcar-core.c
> index 2aba442a0750e91a..dec91e2f3ccdbd93 100644
> --- a/drivers/media/platform/rcar-vin/rcar-core.c
> +++ b/drivers/media/platform/rcar-vin/rcar-core.c
> @@ -26,6 +26,207 @@
>  
>  #include "rcar-vin.h"
>  
> +/* 
> -
> + * Media Controller link notification
> + */
> +
> +static unsigned int rvin_group_csi_pad_to_chan(unsigned int pad)
> +{
> + /*
> +  * The CSI2 driver is rcar-csi2 and we know it's pad layout are

it's -> its

> +  * 0: Source 1-4: Sinks so if we remove one from the pad we

I don't follow. '0: Source 1-4: Sinks' is too cryptic for me.

> +  * get the rcar-vin internal CSI2 channel number
> +  */
> + return pad - 1;
> +}
> +
> +/* group lock should be held when calling this function */
> +static int rvin_group_entity_to_vin_num(struct rvin_group *group,
> + struct media_entity *entity)
> +{
> + struct video_device *vdev;
> + int i;
> +
> + if (!is_media_entity_v4l2_video_device(entity))
> + return -ENODEV;
> +
> + vdev = media_entity_to_video_device(entity);
> +
> + for (i = 0; i < RCAR_VIN_NUM; i++) {
> + if (!group->vin[i])
> + continue;
> +
> + if (>vin[i]->vdev == vdev)
> + return i;
> + }
> +
> + return -ENODEV;
> +}
> +
> +/* group lock should be held when calling this function */
> +static int rvin_group_entity_to_csi_num(struct rvin_group *group,
> + struct media_entity *entity)
> +{
> + struct v4l2_subdev *sd;
> + int i;
> +
> + if (!is_media_entity_v4l2_subdev(entity))
> + return -ENODEV;
> +
> + sd = media_entity_to_v4l2_subdev(entity);
> +
> + for (i = 0; i < RVIN_CSI_MAX; i++)
> + if (group->csi[i].subdev == sd)
> + return i;
> +
> + return -ENODEV;
> +}
> +
> +/* group lock should be held when calling this function */
> +static void __rvin_group_build_link_list(struct rvin_group *group,
> +  struct rvin_group_chsel *map,
> +  int start, int len)
> +{
> + struct media_pad *vin_pad, *remote_pad;
> + unsigned int n;
> +
> + for (n = 0; n < len; n++) {
> + map[n].csi = -1;
> + map[n].chan = -1;
> +
> + if (!group->vin[start + n])
> + continue;
> +
> + vin_pad = >vin[start + n]->vdev.entity.pads[0];
> +
> + remote_pad = media_entity_remote_pad(vin_pad);
> + if (!remote_pad)
> + continue;
> +
> + map[n].csi =
> + rvin_group_entity_to_csi_num(group, remote_pad->entity);
> + map[n].chan = rvin_group_csi_pad_to_chan(remote_pad->index);
> + }
> +}
> +
> +/* group lock should be held when calling this function */
> +static int __rvin_group_try_get_chsel(struct rvin_group *group,
> +   struct rvin_group_chsel *map,
> +   int start, int len)
> +{
> + const struct rvin_group_chsel *sel;
> + unsigned int i, n;
> + int chsel;
> +
> + for (i = 0; i < group->vin[start]->info->num_chsels; i++) {
> + chsel = i;
> + for (n = 0; n < len; n++) {
> +
> + /* If the link is not active it's OK */
> + if (map[n].csi == -1)
> +   

Re: [PATCH v6 20/25] rcar-vin: add chsel information to rvin_info

2017-09-25 Thread Hans Verkuil
On 23/08/17 01:26, Niklas Söderlund wrote:
> Each Gen3 SoC has a limited set of predefined routing possibilities for
> which CSI-2 device and virtual channel can be routed to which VIN
> instance. Prepare to store this information in the struct rvin_info.
> 
> Signed-off-by: Niklas Söderlund 

I think I know what you are doing here, but the comments for struct
rvin_group_chsel need more work, they are confusing.

> ---
>  drivers/media/platform/rcar-vin/rcar-vin.h | 22 ++
>  1 file changed, 22 insertions(+)
> 
> diff --git a/drivers/media/platform/rcar-vin/rcar-vin.h 
> b/drivers/media/platform/rcar-vin/rcar-vin.h
> index 88683aaee3b6acd5..617f254b52fe106d 100644
> --- a/drivers/media/platform/rcar-vin/rcar-vin.h
> +++ b/drivers/media/platform/rcar-vin/rcar-vin.h
> @@ -35,6 +35,9 @@
>  /* Max number on VIN instances that can be in a system */
>  #define RCAR_VIN_NUM 8
>  
> +/* Max number of CHSEL values for any Gen3 SoC */
> +#define RCAR_CHSEL_MAX 6
> +
>  enum chip_id {
>   RCAR_H1,
>   RCAR_M1,
> @@ -91,6 +94,19 @@ struct rvin_graph_entity {
>  
>  struct rvin_group;
>  
> +
> +/** struct rvin_group_chsel - Map a CSI2 device and channel for a CHSEL value
> + * @csi: VIN internal number for CSI2 device
> + * @chan:CSI-2 channel number on remote. Note that channel

remote? I don't know what you mean here.

> + *   is not the same as VC. The CSI-2 hardware have 4

have -> has

> + *   channels it can output on but which VC is outputted

output to what?

> + *   on which channel is configurable inside the CSI-2.
> + */
> +struct rvin_group_chsel {
> + enum rvin_csi_id csi;
> + unsigned int chan;
> +};
> +
>  /**
>   * struct rvin_info - Information about the particular VIN implementation
>   * @chip:type of VIN chip
> @@ -98,6 +114,9 @@ struct rvin_group;
>   *
>   * max_width:max input width the VIN supports
>   * max_height:   max input height the VIN supports
> + *
> + * num_chsels:   number of possible chsel values for this VIN
> + * chsels:   routing table VIN <-> CSI-2 for the chsel values
>   */
>  struct rvin_info {
>   enum chip_id chip;
> @@ -105,6 +124,9 @@ struct rvin_info {
>  
>   unsigned int max_width;
>   unsigned int max_height;
> +
> + unsigned int num_chsels;
> + struct rvin_group_chsel chsels[RCAR_VIN_NUM][RCAR_CHSEL_MAX];
>  };
>  
>  /**
> 

Regards,

Hans


Re: [PATCH v6 19/25] rcar-vin: add group allocator functions

2017-09-25 Thread Hans Verkuil
On 23/08/17 01:26, Niklas Söderlund wrote:
> In media controller mode all VIN instances needs to be part of the same
> media graph. There is also a need to each VIN instance to know and in
> some cases be able to communicate with other VIN instances.
> 
> Add a allocator framework where the first VIN instance to be probed

Add a -> Add an

> creates a shared data structure and creates a media device.
> 
> Signed-off-by: Niklas Söderlund 


Reviewed-by: Hans Verkuil 

Note the small typo below.

Regards,

Hans


> ---
>  drivers/media/platform/rcar-vin/rcar-core.c | 179 
> +++-
>  drivers/media/platform/rcar-vin/rcar-vin.h  |  38 ++
>  2 files changed, 216 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/rcar-vin/rcar-core.c 
> b/drivers/media/platform/rcar-vin/rcar-core.c
> index dd0525f2ba336bc2..4218a73eb6885486 100644
> --- a/drivers/media/platform/rcar-vin/rcar-core.c
> +++ b/drivers/media/platform/rcar-vin/rcar-core.c
> @@ -20,11 +20,170 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  #include 
>  
>  #include "rcar-vin.h"
>  
> +/* 
> -
> + * Gen3 CSI2 Group Allocator
> + */
> +
> +static int rvin_group_read_id(struct rvin_dev *vin, struct device_node *np)
> +{
> + u32 val;
> + int ret;
> +
> + ret = of_property_read_u32(np, "renesas,id", );
> + if (ret) {
> + vin_err(vin, "%s: No renesas,id property found\n",
> + of_node_full_name(np));
> + return -EINVAL;
> + }
> +
> + if (val >= RCAR_VIN_NUM) {
> + vin_err(vin, "%s: Invalid renesas,id '%u'\n",
> + of_node_full_name(np), val);
> + return -EINVAL;
> + }
> +
> + return val;
> +}
> +
> +static DEFINE_MUTEX(rvin_group_lock);
> +static struct rvin_group *rvin_group_data;
> +
> +static void rvin_group_release(struct kref *kref)
> +{
> + struct rvin_group *group =
> + container_of(kref, struct rvin_group, refcount);
> +
> + mutex_lock(_group_lock);
> +
> + media_device_unregister(>mdev);
> + media_device_cleanup(>mdev);
> +
> + rvin_group_data = NULL;
> +
> + mutex_unlock(_group_lock);
> +
> + kfree(group);
> +}
> +
> +static struct rvin_group *__rvin_group_allocate(struct rvin_dev *vin)
> +{
> + struct rvin_group *group;
> +
> + if (rvin_group_data) {
> + group = rvin_group_data;
> + kref_get(>refcount);
> + vin_dbg(vin, "%s: get group=%p\n", __func__, group);
> + return group;
> + }
> +
> + group = kzalloc(sizeof(*group), GFP_KERNEL);
> + if (!group)
> + return NULL;
> +
> + kref_init(>refcount);
> + rvin_group_data = group;
> +
> + vin_dbg(vin, "%s: alloc group=%p\n", __func__, group);
> + return group;
> +}
> +
> +static int rvin_group_add_vin(struct rvin_dev *vin)
> +{
> + int ret;
> +
> + ret = rvin_group_read_id(vin, vin->dev->of_node);
> + if (ret < 0)
> + return ret;
> +
> + mutex_lock(>group->lock);
> +
> + if (vin->group->vin[ret]) {
> + mutex_unlock(>group->lock);
> + vin_err(vin, "VIN number %d already occupied\n", ret);
> + return -EINVAL;
> + }
> +
> + vin->group->vin[ret] = vin;
> +
> + mutex_unlock(>group->lock);
> +
> + vin_dbg(vin, "I'm VIN number %d", ret);
> +
> + return 0;
> +}
> +
> +static int rvin_group_allocate(struct rvin_dev *vin)
> +{
> + struct rvin_group *group;
> + struct media_device *mdev;
> + int ret;
> +
> + mutex_lock(_group_lock);
> +
> + group = __rvin_group_allocate(vin);
> + if (!group) {
> + mutex_unlock(_group_lock);
> + return -ENOMEM;
> + }
> +
> + /* Init group data if its not already initialized */

its -> it is

> + mdev = >mdev;
> + if (!mdev->dev) {
> + mutex_init(>lock);
> + mdev->dev = vin->dev;
> +
> + strlcpy(mdev->driver_name, "Renesas VIN",
> + sizeof(mdev->driver_name));
> + strlcpy(mdev->model, vin->dev->of_node->name,
> + sizeof(mdev->model));
> + strlcpy(mdev->bus_info, of_node_full_name(vin->dev->of_node),
> + sizeof(mdev->bus_info));
> + media_device_init(mdev);
> +
> + ret = media_device_register(mdev);
> + if (ret) {
> + vin_err(vin, "Failed to register media device\n");
> + kref_put(>refcount, rvin_group_release);
> + mutex_unlock(_group_lock);
> + return ret;
> + }
> + }
> +
> + vin->group = group;
> + vin->v4l2_dev.mdev = mdev;
> +
> + ret = rvin_group_add_vin(vin);
> + if (ret) {
> + kref_put(>refcount, 

Re: [PATCH v6 18/25] rcar-vin: prepare for media controller mode initialization

2017-09-25 Thread Hans Verkuil
On 23/08/17 01:26, Niklas Söderlund wrote:
> When running in media controller mode a media pad is needed, register
> one. Also set the media bus format to CSI-2.
> 
> Signed-off-by: Niklas Söderlund 


Reviewed-by: Hans Verkuil 

Regards,

Hans


> ---
>  drivers/media/platform/rcar-vin/rcar-core.c | 23 ++-
>  drivers/media/platform/rcar-vin/rcar-vin.h  |  4 
>  2 files changed, 26 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/rcar-vin/rcar-core.c 
> b/drivers/media/platform/rcar-vin/rcar-core.c
> index fbbb22924cf3a045..dd0525f2ba336bc2 100644
> --- a/drivers/media/platform/rcar-vin/rcar-core.c
> +++ b/drivers/media/platform/rcar-vin/rcar-core.c
> @@ -45,6 +45,10 @@ static int rvin_find_pad(struct v4l2_subdev *sd, int 
> direction)
>   return -EINVAL;
>  }
>  
> +/* 
> -
> + * Digital async notifier
> + */
> +
>  static bool rvin_mbus_supported(struct rvin_dev *vin)
>  {
>   struct v4l2_subdev *sd = vin->digital.subdev;
> @@ -273,6 +277,20 @@ static int rvin_digital_graph_init(struct rvin_dev *vin)
>   return 0;
>  }
>  
> +/* 
> -
> + * Group async notifier
> + */
> +
> +static int rvin_group_init(struct rvin_dev *vin)
> +{
> + /* All our sources are CSI-2 */
> + vin->mbus_cfg.type = V4L2_MBUS_CSI2;
> + vin->mbus_cfg.flags = 0;
> +
> + vin->pad.flags = MEDIA_PAD_FL_SINK;
> + return media_entity_pads_init(>vdev.entity, 1, >pad);
> +}
> +
>  /* 
> -
>   * Platform Device Driver
>   */
> @@ -365,7 +383,10 @@ static int rcar_vin_probe(struct platform_device *pdev)
>   if (ret)
>   return ret;
>  
> - ret = rvin_digital_graph_init(vin);
> + if (vin->info->use_mc)
> + ret = rvin_group_init(vin);
> + else
> + ret = rvin_digital_graph_init(vin);
>   if (ret < 0)
>   goto error;
>  
> diff --git a/drivers/media/platform/rcar-vin/rcar-vin.h 
> b/drivers/media/platform/rcar-vin/rcar-vin.h
> index 12daff804bb6f77f..9c47669669c0469c 100644
> --- a/drivers/media/platform/rcar-vin/rcar-vin.h
> +++ b/drivers/media/platform/rcar-vin/rcar-vin.h
> @@ -103,6 +103,8 @@ struct rvin_info {
>   * @notifier:V4L2 asynchronous subdevs notifier
>   * @digital: entity in the DT for local digital subdevice
>   *
> + * @pad: pad for media controller
> + *
>   * @lock:protects @queue
>   * @queue:   vb2 buffers queue
>   *
> @@ -132,6 +134,8 @@ struct rvin_dev {
>   struct v4l2_async_notifier notifier;
>   struct rvin_graph_entity digital;
>  
> + struct media_pad pad;
> +
>   struct mutex lock;
>   struct vb2_queue queue;
>  
> 



Re: [PATCH v6 17/25] rcar-vin: use different v4l2 operations in media controller mode

2017-09-25 Thread Hans Verkuil
On 23/08/17 01:26, Niklas Söderlund wrote:
> When the driver runs in media controller mode it should not directly
> control the subdevice instead userspace will be responsible for
> configuring the pipeline. To be able to run in this mode a different set
> of v4l2 operations needs to be used.
> 
> Add a new set of v4l2 operations to support the running without directly
> interacting with the source subdevice.
> 
> Signed-off-by: Niklas Söderlund 

Reviewed-by: Hans Verkuil 

Regards,

Hans

> ---
>  drivers/media/platform/rcar-vin/rcar-dma.c  |   3 +-
>  drivers/media/platform/rcar-vin/rcar-v4l2.c | 155 
> +++-
>  drivers/media/platform/rcar-vin/rcar-vin.h  |   1 +
>  3 files changed, 155 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/media/platform/rcar-vin/rcar-dma.c 
> b/drivers/media/platform/rcar-vin/rcar-dma.c
> index 6206fab7b6cdc55a..de1486ee2786b499 100644
> --- a/drivers/media/platform/rcar-vin/rcar-dma.c
> +++ b/drivers/media/platform/rcar-vin/rcar-dma.c
> @@ -628,7 +628,8 @@ static int rvin_setup(struct rvin_dev *vin)
>   /* Default to TB */
>   vnmc = VNMC_IM_FULL;
>   /* Use BT if video standard can be read and is 60 Hz format */
> - if (!v4l2_subdev_call(vin_to_source(vin), video, g_std, )) {
> + if (!vin->info->use_mc &&
> + !v4l2_subdev_call(vin_to_source(vin), video, g_std, )) {
>   if (std & V4L2_STD_525_60)
>   vnmc = VNMC_IM_FULL | VNMC_FOC;
>   }
> diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c 
> b/drivers/media/platform/rcar-vin/rcar-v4l2.c
> index f71dea8d5d40323a..9d540644bbe446f6 100644
> --- a/drivers/media/platform/rcar-vin/rcar-v4l2.c
> +++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c
> @@ -23,6 +23,9 @@
>  #include "rcar-vin.h"
>  
>  #define RVIN_DEFAULT_FORMAT  V4L2_PIX_FMT_YUYV
> +#define RVIN_DEFAULT_WIDTH   800
> +#define RVIN_DEFAULT_HEIGHT  600
> +#define RVIN_DEFAULT_COLORSPACE  V4L2_COLORSPACE_SRGB
>  
>  /* 
> -
>   * Format Conversions
> @@ -671,6 +674,84 @@ static const struct v4l2_ioctl_ops rvin_ioctl_ops = {
>   .vidioc_unsubscribe_event   = v4l2_event_unsubscribe,
>  };
>  
> +/* 
> -
> + * V4L2 Media Controller
> + */
> +
> +static int __rvin_mc_try_format(struct rvin_dev *vin,
> + struct v4l2_pix_format *pix)
> +{
> + /* Keep current field if no specific one is asked for */
> + if (pix->field == V4L2_FIELD_ANY)
> + pix->field = vin->format.field;
> +
> + return rvin_format_align(vin, pix);
> +}
> +
> +static int rvin_mc_try_fmt_vid_cap(struct file *file, void *priv,
> +struct v4l2_format *f)
> +{
> + struct rvin_dev *vin = video_drvdata(file);
> +
> + return __rvin_mc_try_format(vin, >fmt.pix);
> +}
> +
> +static int rvin_mc_s_fmt_vid_cap(struct file *file, void *priv,
> +  struct v4l2_format *f)
> +{
> + struct rvin_dev *vin = video_drvdata(file);
> + int ret;
> +
> + if (vb2_is_busy(>queue))
> + return -EBUSY;
> +
> + ret = __rvin_mc_try_format(vin, >fmt.pix);
> + if (ret)
> + return ret;
> +
> + vin->format = f->fmt.pix;
> +
> + return 0;
> +}
> +
> +static int rvin_mc_enum_input(struct file *file, void *priv,
> +   struct v4l2_input *i)
> +{
> + if (i->index != 0)
> + return -EINVAL;
> +
> + i->type = V4L2_INPUT_TYPE_CAMERA;
> + strlcpy(i->name, "Camera", sizeof(i->name));
> +
> + return 0;
> +}
> +
> +static const struct v4l2_ioctl_ops rvin_mc_ioctl_ops = {
> + .vidioc_querycap= rvin_querycap,
> + .vidioc_try_fmt_vid_cap = rvin_mc_try_fmt_vid_cap,
> + .vidioc_g_fmt_vid_cap   = rvin_g_fmt_vid_cap,
> + .vidioc_s_fmt_vid_cap   = rvin_mc_s_fmt_vid_cap,
> + .vidioc_enum_fmt_vid_cap= rvin_enum_fmt_vid_cap,
> +
> + .vidioc_enum_input  = rvin_mc_enum_input,
> + .vidioc_g_input = rvin_g_input,
> + .vidioc_s_input = rvin_s_input,
> +
> + .vidioc_reqbufs = vb2_ioctl_reqbufs,
> + .vidioc_create_bufs = vb2_ioctl_create_bufs,
> + .vidioc_querybuf= vb2_ioctl_querybuf,
> + .vidioc_qbuf= vb2_ioctl_qbuf,
> + .vidioc_dqbuf   = vb2_ioctl_dqbuf,
> + .vidioc_expbuf  = vb2_ioctl_expbuf,
> + .vidioc_prepare_buf = vb2_ioctl_prepare_buf,
> + .vidioc_streamon= vb2_ioctl_streamon,
> + .vidioc_streamoff   = vb2_ioctl_streamoff,
> +
> + .vidioc_log_status

Re: [PATCH v6 16/25] rcar-vin: break out format alignment and checking

2017-09-25 Thread Hans Verkuil
On 23/08/17 01:26, Niklas Söderlund wrote:
> Part of the format aliment and checking can be shared with the Gen3

aliment -> alignment

> format handling. Break that part out to it's own function. While doing

it's -> its

> this clean up the checking and add more checks.
> 
> Signed-off-by: Niklas Söderlund 

Reviewed-by: Hans Verkuil 

Please note the small typo in a comment below.

Regards,

Hans


> ---
>  drivers/media/platform/rcar-vin/rcar-v4l2.c | 98 
> +++--
>  1 file changed, 51 insertions(+), 47 deletions(-)
> 
> diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c 
> b/drivers/media/platform/rcar-vin/rcar-v4l2.c
> index fb9f802e553e9b80..f71dea8d5d40323a 100644
> --- a/drivers/media/platform/rcar-vin/rcar-v4l2.c
> +++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c
> @@ -86,6 +86,56 @@ static u32 rvin_format_sizeimage(struct v4l2_pix_format 
> *pix)
>   return pix->bytesperline * pix->height;
>  }
>  
> +static int rvin_format_align(struct rvin_dev *vin, struct v4l2_pix_format 
> *pix)
> +{
> + u32 walign;
> +
> + /* If requested format is not supported fallback to the default */
> + if (!rvin_format_from_pixel(pix->pixelformat)) {
> + vin_dbg(vin, "Format 0x%x not found, using default 0x%x\n",
> + pix->pixelformat, RVIN_DEFAULT_FORMAT);
> + pix->pixelformat = RVIN_DEFAULT_FORMAT;
> + }
> +
> + switch (pix->field) {
> + case V4L2_FIELD_TOP:
> + case V4L2_FIELD_BOTTOM:
> + case V4L2_FIELD_NONE:
> + case V4L2_FIELD_INTERLACED_TB:
> + case V4L2_FIELD_INTERLACED_BT:
> + case V4L2_FIELD_INTERLACED:
> + break;
> + default:
> + pix->field = V4L2_FIELD_NONE;
> + break;
> + }
> +
> + /* Check that colorspace is resonable, if not keep current */

resonable -> reasonable

> + if (!pix->colorspace || pix->colorspace >= 0xff)
> + pix->colorspace = vin->format.colorspace;
> +
> + /* HW limit width to a multiple of 32 (2^5) for NV16 else 2 (2^1) */
> + walign = vin->format.pixelformat == V4L2_PIX_FMT_NV16 ? 5 : 1;
> +
> + /* Limit to VIN capabilities */
> + v4l_bound_align_image(>width, 2, vin->info->max_width, walign,
> +   >height, 4, vin->info->max_height, 2, 0);
> +
> + pix->bytesperline = rvin_format_bytesperline(pix);
> + pix->sizeimage = rvin_format_sizeimage(pix);
> +
> + if (vin->info->chip == RCAR_M1 &&
> + pix->pixelformat == V4L2_PIX_FMT_XBGR32) {
> + vin_err(vin, "pixel format XBGR32 not supported on M1\n");
> + return -EINVAL;
> + }
> +
> + vin_dbg(vin, "Format %ux%u bpl: %d size: %d\n",
> + pix->width, pix->height, pix->bytesperline, pix->sizeimage);
> +
> + return 0;
> +}
> +
>  /* 
> -
>   * V4L2
>   */
> @@ -191,64 +241,18 @@ static int __rvin_try_format_source(struct rvin_dev 
> *vin,
>  static int __rvin_try_format(struct rvin_dev *vin,
>u32 which, struct v4l2_pix_format *pix)
>  {
> - u32 walign;
>   int ret;
>  
>   /* Keep current field if no specific one is asked for */
>   if (pix->field == V4L2_FIELD_ANY)
>   pix->field = vin->format.field;
>  
> - /* If requested format is not supported fallback to the default */
> - if (!rvin_format_from_pixel(pix->pixelformat)) {
> - vin_dbg(vin, "Format 0x%x not found, using default 0x%x\n",
> - pix->pixelformat, RVIN_DEFAULT_FORMAT);
> - pix->pixelformat = RVIN_DEFAULT_FORMAT;
> - }
> -
> - /* Always recalculate */
> - pix->bytesperline = 0;
> - pix->sizeimage = 0;
> -
>   /* Limit to source capabilities */
>   ret = __rvin_try_format_source(vin, which, pix);
>   if (ret)
>   return ret;
>  
> - switch (pix->field) {
> - case V4L2_FIELD_TOP:
> - case V4L2_FIELD_BOTTOM:
> - case V4L2_FIELD_NONE:
> - case V4L2_FIELD_INTERLACED_TB:
> - case V4L2_FIELD_INTERLACED_BT:
> - case V4L2_FIELD_INTERLACED:
> - break;
> - default:
> - pix->field = V4L2_FIELD_NONE;
> - break;
> - }
> -
> - /* HW limit width to a multiple of 32 (2^5) for NV16 else 2 (2^1) */
> - walign = vin->format.pixelformat == V4L2_PIX_FMT_NV16 ? 5 : 1;
> -
> - /* Limit to VIN capabilities */
> - v4l_bound_align_image(>width, 2, vin->info->max_width, walign,
> -   >height, 4, vin->info->max_height, 2, 0);
> -
> - pix->bytesperline = max_t(u32, pix->bytesperline,
> -   rvin_format_bytesperline(pix));
> - pix->sizeimage = max_t(u32, pix->sizeimage,
> -rvin_format_sizeimage(pix));
> -
> - if (vin->info->chip == RCAR_M1 &&
> - 

Re: [PATCH] clk/Renesas: Delete an error message for a failed memory allocation in three functions

2017-09-25 Thread Geert Uytterhoeven
Hi Markus,

On Mon, Sep 25, 2017 at 10:34 AM, SF Markus Elfring
 wrote:
> From: Markus Elfring 
> Date: Mon, 25 Sep 2017 10:10:51 +0200
>
> The script "checkpatch.pl" pointed information out like the following.
>
> WARNING: Possible unnecessary 'out of memory' message
>
> Thus fix affected source code places.
>
> Signed-off-by: Markus Elfring 

Reviewed-by: Geert Uytterhoeven 
i.e. will queue in clk-renesas-for-v4.15, split in two commits:
  - clk: renesas: rcar-gen2: Delete error message for failed memory allocation
  - clk: renesas: mstp: Delete error messages for failed memory allocations

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@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


Re: [PATCH v6 14/25] rcar-vin: add functions to manipulate Gen3 CHSEL value

2017-09-25 Thread Hans Verkuil
On 23/08/17 01:26, Niklas Söderlund wrote:
> On Gen3 the CSI-2 routing is controlled by the VnCSI_IFMD register. One
> feature of this register is that it's only present in the VIN0 and VIN4
> instances. The register in VIN0 controls the routing for VIN0-3 and the
> register in VIN4 controls routing for VIN4-7.
> 
> To be able to control routing from a media device these functions need
> to control runtime PM for the subgroup master (VIN0 and VIN4). The
> subgroup master must be switched on before the register is manipulated,
> once the operation is complete it's safe to switch the master off and
> the new routing will still be in effect.
> 
> Signed-off-by: Niklas Söderlund 

Reviewed-by: Hans Verkuil 

Regards,

Hans


> ---
>  drivers/media/platform/rcar-vin/rcar-dma.c | 41 
> ++
>  drivers/media/platform/rcar-vin/rcar-vin.h |  3 +++
>  2 files changed, 44 insertions(+)
> 
> diff --git a/drivers/media/platform/rcar-vin/rcar-dma.c 
> b/drivers/media/platform/rcar-vin/rcar-dma.c
> index c4f8e81e88c99e28..6206fab7b6cdc55a 100644
> --- a/drivers/media/platform/rcar-vin/rcar-dma.c
> +++ b/drivers/media/platform/rcar-vin/rcar-dma.c
> @@ -16,6 +16,7 @@
>  
>  #include 
>  #include 
> +#include 
>  
>  #include 
>  
> @@ -1228,3 +1229,43 @@ int rvin_dma_probe(struct rvin_dev *vin, int irq)
>  
>   return ret;
>  }
> +
> +/* 
> -
> + * Gen3 CHSEL manipulation
> + */
> +
> +void rvin_set_chsel(struct rvin_dev *vin, u8 chsel)
> +{
> + u32 ifmd;
> +
> + pm_runtime_get_sync(vin->dev);
> +
> + /*
> +  * Undocumented feature: Writing to VNCSI_IFMD_REG will go
> +  * through and on read back look correct but won't have
> +  * any effect if VNMC_REG is not first set to 0.
> +  */
> + rvin_write(vin, 0, VNMC_REG);
> +
> + ifmd = VNCSI_IFMD_DES2 | VNCSI_IFMD_DES1 | VNCSI_IFMD_DES0 |
> + VNCSI_IFMD_CSI_CHSEL(chsel);
> +
> + rvin_write(vin, ifmd, VNCSI_IFMD_REG);
> +
> + vin_dbg(vin, "Set IFMD 0x%x\n", ifmd);
> +
> + pm_runtime_put(vin->dev);
> +}
> +
> +int rvin_get_chsel(struct rvin_dev *vin)
> +{
> + int chsel;
> +
> + pm_runtime_get_sync(vin->dev);
> +
> + chsel = rvin_read(vin, VNCSI_IFMD_REG) & VNCSI_IFMD_CSI_CHSEL_MASK;
> +
> + pm_runtime_put(vin->dev);
> +
> + return chsel;
> +}
> diff --git a/drivers/media/platform/rcar-vin/rcar-vin.h 
> b/drivers/media/platform/rcar-vin/rcar-vin.h
> index c460868d2d81..94c606f2b8f2f246 100644
> --- a/drivers/media/platform/rcar-vin/rcar-vin.h
> +++ b/drivers/media/platform/rcar-vin/rcar-vin.h
> @@ -164,4 +164,7 @@ int rvin_reset_format(struct rvin_dev *vin);
>  
>  const struct rvin_video_format *rvin_format_from_pixel(u32 pixelformat);
>  
> +void rvin_set_chsel(struct rvin_dev *vin, u8 chsel);
> +int rvin_get_chsel(struct rvin_dev *vin);
> +
>  #endif
> 



Re: [PATCH v6 15/25] rcar-vin: add flag to switch to media controller mode

2017-09-25 Thread Hans Verkuil
On 23/08/17 01:26, Niklas Söderlund wrote:
> On Gen3 a media controller API needs to be used to allow userspace to
> configure the subdevices in the pipeline instead of directly controlling
> a single source subdevice, which is and will continue to be the mode of
> operation on Gen2.
> 
> Prepare for these two modes of operation by adding a flag to struct
> rvin_graph_entity which will control which mode to use.
> 
> Signed-off-by: Niklas Söderlund 

Reviewed-by: Hans Verkuil 

Regards,

Hans


> ---
>  drivers/media/platform/rcar-vin/rcar-core.c | 6 +-
>  drivers/media/platform/rcar-vin/rcar-vin.h  | 2 ++
>  2 files changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/rcar-vin/rcar-core.c 
> b/drivers/media/platform/rcar-vin/rcar-core.c
> index 65f01b6781c0aefd..fbbb22924cf3a045 100644
> --- a/drivers/media/platform/rcar-vin/rcar-core.c
> +++ b/drivers/media/platform/rcar-vin/rcar-core.c
> @@ -279,18 +279,21 @@ static int rvin_digital_graph_init(struct rvin_dev *vin)
>  
>  static const struct rvin_info rcar_info_h1 = {
>   .chip = RCAR_H1,
> + .use_mc = false,
>   .max_width = 2048,
>   .max_height = 2048,
>  };
>  
>  static const struct rvin_info rcar_info_m1 = {
>   .chip = RCAR_M1,
> + .use_mc = false,
>   .max_width = 2048,
>   .max_height = 2048,
>  };
>  
>  static const struct rvin_info rcar_info_gen2 = {
>   .chip = RCAR_GEN2,
> + .use_mc = false,
>   .max_width = 2048,
>   .max_height = 2048,
>  };
> @@ -387,7 +390,8 @@ static int rcar_vin_remove(struct platform_device *pdev)
>   v4l2_async_notifier_unregister(>notifier);
>  
>   /* Checks internaly if handlers have been init or not */
> - v4l2_ctrl_handler_free(>ctrl_handler);
> + if (!vin->info->use_mc)
> + v4l2_ctrl_handler_free(>ctrl_handler);
>  
>   rvin_v4l2_remove(vin);
>  
> diff --git a/drivers/media/platform/rcar-vin/rcar-vin.h 
> b/drivers/media/platform/rcar-vin/rcar-vin.h
> index 94c606f2b8f2f246..819d9c04ed8ffb36 100644
> --- a/drivers/media/platform/rcar-vin/rcar-vin.h
> +++ b/drivers/media/platform/rcar-vin/rcar-vin.h
> @@ -77,12 +77,14 @@ struct rvin_graph_entity {
>  /**
>   * struct rvin_info - Information about the particular VIN implementation
>   * @chip:type of VIN chip
> + * @use_mc:  use media controller instead of controlling subdevice
>   *
>   * max_width:max input width the VIN supports
>   * max_height:   max input height the VIN supports
>   */
>  struct rvin_info {
>   enum chip_id chip;
> + bool use_mc;
>  
>   unsigned int max_width;
>   unsigned int max_height;
> 



Re: [PATCH v6 13/25] rcar-vin: enable Gen3 hardware configuration

2017-09-25 Thread Hans Verkuil
On 23/08/17 01:26, Niklas Söderlund wrote:
> Add the register needed to work with Gen3 hardware. This patch adds
> the logic for how to work with the Gen3 hardware. More work is required
> to enable the subdevice structure needed to configure capturing.
> 
> Signed-off-by: Niklas Söderlund 

Reviewed-by: Hans Verkuil 

Regards,

Hans


> ---
>  drivers/media/platform/rcar-vin/rcar-dma.c | 94 
> --
>  drivers/media/platform/rcar-vin/rcar-vin.h |  1 +
>  2 files changed, 64 insertions(+), 31 deletions(-)
> 
> diff --git a/drivers/media/platform/rcar-vin/rcar-dma.c 
> b/drivers/media/platform/rcar-vin/rcar-dma.c
> index 9362e7dba5e3ba95..c4f8e81e88c99e28 100644
> --- a/drivers/media/platform/rcar-vin/rcar-dma.c
> +++ b/drivers/media/platform/rcar-vin/rcar-dma.c
> @@ -33,21 +33,23 @@
>  #define VNELPRC_REG  0x10/* Video n End Line Pre-Clip Register */
>  #define VNSPPRC_REG  0x14/* Video n Start Pixel Pre-Clip Register */
>  #define VNEPPRC_REG  0x18/* Video n End Pixel Pre-Clip Register */
> -#define VNSLPOC_REG  0x1C/* Video n Start Line Post-Clip Register */
> -#define VNELPOC_REG  0x20/* Video n End Line Post-Clip Register */
> -#define VNSPPOC_REG  0x24/* Video n Start Pixel Post-Clip Register */
> -#define VNEPPOC_REG  0x28/* Video n End Pixel Post-Clip Register */
>  #define VNIS_REG 0x2C/* Video n Image Stride Register */
>  #define VNMB_REG(m)  (0x30 + ((m) << 2)) /* Video n Memory Base m Register */
>  #define VNIE_REG 0x40/* Video n Interrupt Enable Register */
>  #define VNINTS_REG   0x44/* Video n Interrupt Status Register */
>  #define VNSI_REG 0x48/* Video n Scanline Interrupt Register */
>  #define VNMTC_REG0x4C/* Video n Memory Transfer Control Register */
> -#define VNYS_REG 0x50/* Video n Y Scale Register */
> -#define VNXS_REG 0x54/* Video n X Scale Register */
>  #define VNDMR_REG0x58/* Video n Data Mode Register */
>  #define VNDMR2_REG   0x5C/* Video n Data Mode Register 2 */
>  #define VNUVAOF_REG  0x60/* Video n UV Address Offset Register */
> +
> +/* Register offsets specific for Gen2 */
> +#define VNSLPOC_REG  0x1C/* Video n Start Line Post-Clip Register */
> +#define VNELPOC_REG  0x20/* Video n End Line Post-Clip Register */
> +#define VNSPPOC_REG  0x24/* Video n Start Pixel Post-Clip Register */
> +#define VNEPPOC_REG  0x28/* Video n End Pixel Post-Clip Register */
> +#define VNYS_REG 0x50/* Video n Y Scale Register */
> +#define VNXS_REG 0x54/* Video n X Scale Register */
>  #define VNC1A_REG0x80/* Video n Coefficient Set C1A Register */
>  #define VNC1B_REG0x84/* Video n Coefficient Set C1B Register */
>  #define VNC1C_REG0x88/* Video n Coefficient Set C1C Register */
> @@ -73,9 +75,13 @@
>  #define VNC8B_REG0xF4/* Video n Coefficient Set C8B Register */
>  #define VNC8C_REG0xF8/* Video n Coefficient Set C8C Register */
>  
> +/* Register offsets specific for Gen3 */
> +#define VNCSI_IFMD_REG   0x20 /* Video n CSI2 Interface Mode 
> Register */
>  
>  /* Register bit fields for R-Car VIN */
>  /* Video n Main Control Register bits */
> +#define VNMC_DPINE   (1 << 27) /* Gen3 specific */
> +#define VNMC_SCLE(1 << 26) /* Gen3 specific */
>  #define VNMC_FOC (1 << 21)
>  #define VNMC_YCAL(1 << 19)
>  #define VNMC_INF_YUV8_BT656  (0 << 16)
> @@ -119,6 +125,13 @@
>  #define VNDMR2_FTEV  (1 << 17)
>  #define VNDMR2_VLV(n)((n & 0xf) << 12)
>  
> +/* Video n CSI2 Interface Mode Register (Gen3) */
> +#define VNCSI_IFMD_DES2  (1 << 27)
> +#define VNCSI_IFMD_DES1  (1 << 26)
> +#define VNCSI_IFMD_DES0  (1 << 25)
> +#define VNCSI_IFMD_CSI_CHSEL(n) ((n & 0xf) << 0)
> +#define VNCSI_IFMD_CSI_CHSEL_MASK 0xf
> +
>  struct rvin_buffer {
>   struct vb2_v4l2_buffer vb;
>   struct list_head list;
> @@ -514,28 +527,10 @@ static void rvin_set_coeff(struct rvin_dev *vin, 
> unsigned short xs)
>   rvin_write(vin, p_set->coeff_set[23], VNC8C_REG);
>  }
>  
> -static void rvin_crop_scale_comp(struct rvin_dev *vin)
> +static void rvin_crop_scale_comp_gen2(struct rvin_dev *vin)
>  {
>   u32 xs, ys;
>  
> - /* Set Start/End Pixel/Line Pre-Clip */
> - rvin_write(vin, vin->crop.left, VNSPPRC_REG);
> - rvin_write(vin, vin->crop.left + vin->crop.width - 1, VNEPPRC_REG);
> - switch (vin->format.field) {
> - case V4L2_FIELD_INTERLACED:
> - case V4L2_FIELD_INTERLACED_TB:
> - case V4L2_FIELD_INTERLACED_BT:
> - rvin_write(vin, vin->crop.top / 2, VNSLPRC_REG);
> - rvin_write(vin, (vin->crop.top + vin->crop.height) / 2 - 1,
> -VNELPRC_REG);
> - break;
> - default:
> - rvin_write(vin, vin->crop.top, VNSLPRC_REG);
> -   

Re: [PATCH v6 12/25] rcar-vin: move media bus configuration to struct rvin_info

2017-09-25 Thread Hans Verkuil
On 23/08/17 01:26, Niklas Söderlund wrote:
> Bus configuration will once the driver is extended to to support Gen3

to to -> to

> contain information not specific to only the directly connected parallel
> subdevice. Move it to struct rvin_info to show it's not always coupled
> to the parallel subdevice.
> 
> Signed-off-by: Niklas Söderlund 

Reviewed-by: Hans Verkuil 

Regards,

Hans

> ---
>  drivers/media/platform/rcar-vin/rcar-core.c | 14 +++---
>  drivers/media/platform/rcar-vin/rcar-dma.c  | 11 ++-
>  drivers/media/platform/rcar-vin/rcar-v4l2.c |  2 +-
>  drivers/media/platform/rcar-vin/rcar-vin.h  |  9 -
>  4 files changed, 18 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/media/platform/rcar-vin/rcar-core.c 
> b/drivers/media/platform/rcar-vin/rcar-core.c
> index 4dc148e7835439ab..65f01b6781c0aefd 100644
> --- a/drivers/media/platform/rcar-vin/rcar-core.c
> +++ b/drivers/media/platform/rcar-vin/rcar-core.c
> @@ -45,15 +45,15 @@ static int rvin_find_pad(struct v4l2_subdev *sd, int 
> direction)
>   return -EINVAL;
>  }
>  
> -static bool rvin_mbus_supported(struct rvin_graph_entity *entity)
> +static bool rvin_mbus_supported(struct rvin_dev *vin)
>  {
> - struct v4l2_subdev *sd = entity->subdev;
> + struct v4l2_subdev *sd = vin->digital.subdev;
>   struct v4l2_subdev_mbus_code_enum code = {
>   .which = V4L2_SUBDEV_FORMAT_ACTIVE,
>   };
>  
>   code.index = 0;
> - code.pad = entity->source_pad;
> + code.pad = vin->digital.source_pad;
>   while (!v4l2_subdev_call(sd, pad, enum_mbus_code, NULL, )) {
>   code.index++;
>   switch (code.code) {
> @@ -61,7 +61,7 @@ static bool rvin_mbus_supported(struct rvin_graph_entity 
> *entity)
>   case MEDIA_BUS_FMT_UYVY8_2X8:
>   case MEDIA_BUS_FMT_UYVY10_2X10:
>   case MEDIA_BUS_FMT_RGB888_1X24:
> - entity->code = code.code;
> + vin->code = code.code;
>   return true;
>   default:
>   break;
> @@ -78,14 +78,14 @@ static int rvin_digital_notify_complete(struct 
> v4l2_async_notifier *notifier)
>   int ret;
>  
>   /* Verify subdevices mbus format */
> - if (!rvin_mbus_supported(>digital)) {
> + if (!rvin_mbus_supported(vin)) {
>   vin_err(vin, "Unsupported media bus format for %s\n",
>   vin->digital.subdev->name);
>   return -EINVAL;
>   }
>  
>   vin_dbg(vin, "Found media bus format for %s: %d\n",
> - vin->digital.subdev->name, vin->digital.code);
> + vin->digital.subdev->name, vin->code);
>  
>   ret = v4l2_device_register_subdev_nodes(>v4l2_dev);
>   if (ret < 0) {
> @@ -219,7 +219,7 @@ static int rvin_digital_graph_parse(struct rvin_dev *vin)
>   }
>   of_node_put(np);
>  
> - ret = rvin_digitial_parse_v4l2(vin, ep, >digital.mbus_cfg);
> + ret = rvin_digitial_parse_v4l2(vin, ep, >mbus_cfg);
>   of_node_put(ep);
>   if (ret)
>   return ret;
> diff --git a/drivers/media/platform/rcar-vin/rcar-dma.c 
> b/drivers/media/platform/rcar-vin/rcar-dma.c
> index f22bec062db31772..9362e7dba5e3ba95 100644
> --- a/drivers/media/platform/rcar-vin/rcar-dma.c
> +++ b/drivers/media/platform/rcar-vin/rcar-dma.c
> @@ -633,7 +633,7 @@ static int rvin_setup(struct rvin_dev *vin)
>   /*
>* Input interface
>*/
> - switch (vin->digital.code) {
> + switch (vin->code) {
>   case MEDIA_BUS_FMT_YUYV8_1X16:
>   /* BT.601/BT.1358 16bit YCbCr422 */
>   vnmc |= VNMC_INF_YUV16;
> @@ -641,7 +641,7 @@ static int rvin_setup(struct rvin_dev *vin)
>   break;
>   case MEDIA_BUS_FMT_UYVY8_2X8:
>   /* BT.656 8bit YCbCr422 or BT.601 8bit YCbCr422 */
> - vnmc |= vin->digital.mbus_cfg.type == V4L2_MBUS_BT656 ?
> + vnmc |= vin->mbus_cfg.type == V4L2_MBUS_BT656 ?
>   VNMC_INF_YUV8_BT656 : VNMC_INF_YUV8_BT601;
>   input_is_yuv = true;
>   break;
> @@ -650,7 +650,7 @@ static int rvin_setup(struct rvin_dev *vin)
>   break;
>   case MEDIA_BUS_FMT_UYVY10_2X10:
>   /* BT.656 10bit YCbCr422 or BT.601 10bit YCbCr422 */
> - vnmc |= vin->digital.mbus_cfg.type == V4L2_MBUS_BT656 ?
> + vnmc |= vin->mbus_cfg.type == V4L2_MBUS_BT656 ?
>   VNMC_INF_YUV10_BT656 : VNMC_INF_YUV10_BT601;
>   input_is_yuv = true;
>   break;
> @@ -662,11 +662,11 @@ static int rvin_setup(struct rvin_dev *vin)
>   dmr2 = VNDMR2_FTEV | VNDMR2_VLV(1);
>  
>   /* Hsync Signal Polarity Select */
> - if (!(vin->digital.mbus_cfg.flags & V4L2_MBUS_HSYNC_ACTIVE_LOW))
> + if (!(vin->mbus_cfg.flags & V4L2_MBUS_HSYNC_ACTIVE_LOW))
>   dmr2 |= 

Re: [PATCH v6 11/25] rcar-vin: fix handling of single field frames (top, bottom and alternate fields)

2017-09-25 Thread Hans Verkuil
On 23/08/17 01:26, Niklas Söderlund wrote:
> It was never proper support in the VIN driver to deliver ALTERNATING

It -> There

> field format to user-space, remove this field option. For sources using
> this field format instead use the VIN hardware feature of combining the
> fields to an interlaced format. This mode of operation was previously
> the default behavior and ALTERNATING was only delivered to user-space if
> explicitly requested. Allowing this to be explicitly requested was a
> mistake and was never properly tested and never worked due to the
> constrains put on the field format when it comes to sequence numbers and

contrains -> constraints

> timestamps etc.
> 
> The height should not be cut in half for the format for TOP or BOTTOM
> fields settings. This was a mistake and it was made visible by the
> scaling refactoring. Correct behavior is that the user should request a
> frame size that fits the half height frame reflected in the field
> setting. If not the VIN will do it's best to scale the top or bottom to

it's -> its

> the requested format and cropping and scaling do not work as expected.
> 
> Signed-off-by: Niklas Söderlund 

Reviewed-by: Hans Verkuil 

Regards,

Hans

> ---
>  drivers/media/platform/rcar-vin/rcar-dma.c  | 15 +
>  drivers/media/platform/rcar-vin/rcar-v4l2.c | 48 
> +++--
>  2 files changed, 19 insertions(+), 44 deletions(-)
> 
> diff --git a/drivers/media/platform/rcar-vin/rcar-dma.c 
> b/drivers/media/platform/rcar-vin/rcar-dma.c
> index 6cc880e5ef7e0718..f22bec062db31772 100644
> --- a/drivers/media/platform/rcar-vin/rcar-dma.c
> +++ b/drivers/media/platform/rcar-vin/rcar-dma.c
> @@ -617,7 +617,6 @@ static int rvin_setup(struct rvin_dev *vin)
>   case V4L2_FIELD_INTERLACED_BT:
>   vnmc = VNMC_IM_FULL | VNMC_FOC;
>   break;
> - case V4L2_FIELD_ALTERNATE:
>   case V4L2_FIELD_NONE:
>   if (vin->continuous) {
>   vnmc = VNMC_IM_ODD_EVEN;
> @@ -757,18 +756,6 @@ static int rvin_get_active_slot(struct rvin_dev *vin, 
> u32 vnms)
>   return 0;
>  }
>  
> -static enum v4l2_field rvin_get_active_field(struct rvin_dev *vin, u32 vnms)
> -{
> - if (vin->format.field == V4L2_FIELD_ALTERNATE) {
> - /* If FS is set it's a Even field */
> - if (vnms & VNMS_FS)
> - return V4L2_FIELD_BOTTOM;
> - return V4L2_FIELD_TOP;
> - }
> -
> - return vin->format.field;
> -}
> -
>  static void rvin_set_slot_addr(struct rvin_dev *vin, int slot, dma_addr_t 
> addr)
>  {
>   const struct rvin_video_format *fmt;
> @@ -941,7 +928,7 @@ static irqreturn_t rvin_irq(int irq, void *data)
>   goto done;
>  
>   /* Capture frame */
> - vin->queue_buf[slot]->field = rvin_get_active_field(vin, vnms);
> + vin->queue_buf[slot]->field = vin->format.field;
>   vin->queue_buf[slot]->sequence = sequence;
>   vin->queue_buf[slot]->vb2_buf.timestamp = ktime_get_ns();
>   vb2_buffer_done(>queue_buf[slot]->vb2_buf, VB2_BUF_STATE_DONE);
> diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c 
> b/drivers/media/platform/rcar-vin/rcar-v4l2.c
> index c8c764188b85a926..9f0aac9c3398d613 100644
> --- a/drivers/media/platform/rcar-vin/rcar-v4l2.c
> +++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c
> @@ -102,6 +102,24 @@ static int rvin_get_sd_format(struct rvin_dev *vin, 
> struct v4l2_pix_format *pix)
>   if (ret)
>   return ret;
>  
> + switch (fmt.format.field) {
> + case V4L2_FIELD_TOP:
> + case V4L2_FIELD_BOTTOM:
> + case V4L2_FIELD_NONE:
> + case V4L2_FIELD_INTERLACED_TB:
> + case V4L2_FIELD_INTERLACED_BT:
> + case V4L2_FIELD_INTERLACED:
> + break;
> + case V4L2_FIELD_ALTERNATE:
> + /* Use VIN hardware to combine the two fields */
> + fmt.format.field = V4L2_FIELD_INTERLACED;
> + fmt.format.height *= 2;
> + break;
> + default:
> + vin->format.field = V4L2_FIELD_NONE;
> + break;
> + }
> +
>   v4l2_fill_pix_format(pix, );
>  
>   return 0;
> @@ -115,33 +133,6 @@ int rvin_reset_format(struct rvin_dev *vin)
>   if (ret)
>   return ret;
>  
> - /*
> -  * If the subdevice uses ALTERNATE field mode and G_STD is
> -  * implemented use the VIN HW to combine the two fields to
> -  * one INTERLACED frame. The ALTERNATE field mode can still
> -  * be requested in S_FMT and be respected, this is just the
> -  * default which is applied at probing or when S_STD is called.
> -  */
> - if (vin->format.field == V4L2_FIELD_ALTERNATE &&
> - v4l2_subdev_has_op(vin_to_source(vin), video, g_std))
> - vin->format.field = V4L2_FIELD_INTERLACED;
> -
> - switch (vin->format.field) {
> - case V4L2_FIELD_TOP:
> - case V4L2_FIELD_BOTTOM:
> -

Re: [PATCH v6 10/25] rcar-vin: read subdevice format for crop only when needed

2017-09-25 Thread Hans Verkuil
On 23/08/17 01:26, Niklas Söderlund wrote:
> Instead of caching the subdevice format each time the video device
> format is set read it directly when its needed. As it turns out the

its -> it's

> format is only needed when figuring out the max rectangle for cropping.
> 
> This simplify the code and makes it clearer what the source format is

simplify -> simplifies

> used for.
> 
> Signed-off-by: Niklas Söderlund 

Reviewed-by: Hans Verkuil 

Regards,

Hans

> ---
>  drivers/media/platform/rcar-vin/rcar-v4l2.c | 88 
> ++---
>  drivers/media/platform/rcar-vin/rcar-vin.h  | 12 
>  2 files changed, 42 insertions(+), 58 deletions(-)
> 
> diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c 
> b/drivers/media/platform/rcar-vin/rcar-v4l2.c
> index 305a74d033b2d9c5..c8c764188b85a926 100644
> --- a/drivers/media/platform/rcar-vin/rcar-v4l2.c
> +++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c
> @@ -90,24 +90,30 @@ static u32 rvin_format_sizeimage(struct v4l2_pix_format 
> *pix)
>   * V4L2
>   */
>  
> -int rvin_reset_format(struct rvin_dev *vin)
> +static int rvin_get_sd_format(struct rvin_dev *vin, struct v4l2_pix_format 
> *pix)
>  {
>   struct v4l2_subdev_format fmt = {
>   .which = V4L2_SUBDEV_FORMAT_ACTIVE,
> + .pad = vin->digital.source_pad,
>   };
> - struct v4l2_mbus_framefmt *mf = 
>   int ret;
>  
> - fmt.pad = vin->digital.source_pad;
> -
>   ret = v4l2_subdev_call(vin_to_source(vin), pad, get_fmt, NULL, );
>   if (ret)
>   return ret;
>  
> - vin->format.width   = mf->width;
> - vin->format.height  = mf->height;
> - vin->format.colorspace  = mf->colorspace;
> - vin->format.field   = mf->field;
> + v4l2_fill_pix_format(pix, );
> +
> + return 0;
> +}
> +
> +int rvin_reset_format(struct rvin_dev *vin)
> +{
> + int ret;
> +
> + ret = rvin_get_sd_format(vin, >format);
> + if (ret)
> + return ret;
>  
>   /*
>* If the subdevice uses ALTERNATE field mode and G_STD is
> @@ -137,12 +143,12 @@ int rvin_reset_format(struct rvin_dev *vin)
>   }
>  
>   vin->crop.top = vin->crop.left = 0;
> - vin->crop.width = mf->width;
> - vin->crop.height = mf->height;
> + vin->crop.width = vin->format.width;
> + vin->crop.height = vin->format.height;
>  
>   vin->compose.top = vin->compose.left = 0;
> - vin->compose.width = mf->width;
> - vin->compose.height = mf->height;
> + vin->compose.width = vin->format.width;
> + vin->compose.height = vin->format.height;
>  
>   vin->format.bytesperline = rvin_format_bytesperline(>format);
>   vin->format.sizeimage = rvin_format_sizeimage(>format);
> @@ -151,9 +157,7 @@ int rvin_reset_format(struct rvin_dev *vin)
>  }
>  
>  static int __rvin_try_format_source(struct rvin_dev *vin,
> - u32 which,
> - struct v4l2_pix_format *pix,
> - struct rvin_source_fmt *source)
> + u32 which, struct v4l2_pix_format *pix)
>  {
>   struct v4l2_subdev *sd;
>   struct v4l2_subdev_pad_config *pad_cfg;
> @@ -186,25 +190,15 @@ static int __rvin_try_format_source(struct rvin_dev 
> *vin,
>   v4l2_fill_pix_format(pix, );
>  
>   pix->field = field;
> -
> - source->width = pix->width;
> - source->height = pix->height;
> -
>   pix->width = width;
>   pix->height = height;
> -
> - vin_dbg(vin, "Source resolution: %ux%u\n", source->width,
> - source->height);
> -
>  done:
>   v4l2_subdev_free_pad_config(pad_cfg);
>   return ret;
>  }
>  
>  static int __rvin_try_format(struct rvin_dev *vin,
> -  u32 which,
> -  struct v4l2_pix_format *pix,
> -  struct rvin_source_fmt *source)
> +  u32 which, struct v4l2_pix_format *pix)
>  {
>   u32 walign;
>   int ret;
> @@ -225,7 +219,7 @@ static int __rvin_try_format(struct rvin_dev *vin,
>   pix->sizeimage = 0;
>  
>   /* Limit to source capabilities */
> - ret = __rvin_try_format_source(vin, which, pix, source);
> + ret = __rvin_try_format_source(vin, which, pix);
>   if (ret)
>   return ret;
>  
> @@ -234,7 +228,6 @@ static int __rvin_try_format(struct rvin_dev *vin,
>   case V4L2_FIELD_BOTTOM:
>   case V4L2_FIELD_ALTERNATE:
>   pix->height /= 2;
> - source->height /= 2;
>   break;
>   case V4L2_FIELD_NONE:
>   case V4L2_FIELD_INTERLACED_TB:
> @@ -286,30 +279,23 @@ static int rvin_try_fmt_vid_cap(struct file *file, void 
> *priv,
>   struct v4l2_format *f)
>  {
>   struct rvin_dev *vin = video_drvdata(file);
> - struct rvin_source_fmt source;
>  
> - return __rvin_try_format(vin, 

Re: [PATCH v6 09/25] rcar-vin: do not allow changing scaling and composing while streaming

2017-09-25 Thread Hans Verkuil
On 23/08/17 01:26, Niklas Söderlund wrote:
> It is possible on Gen2 to change the registers controlling composing and
> scaling while the stream is running. Is however not a good idea to do so

Is -> It

> and could result in trouble. There are also no good reason to allow

reason -> reasons

> this, remove immediate reflection in hardware registers from
> vidioc_s_selection and only configure scaling and composing when the
> stream starts.
> 
> Signed-off-by: Niklas Söderlund 

Reviewed-by: Hans Verkuil 

Regards,

Hans

> ---
>  drivers/media/platform/rcar-vin/rcar-dma.c  | 2 +-
>  drivers/media/platform/rcar-vin/rcar-v4l2.c | 3 ---
>  drivers/media/platform/rcar-vin/rcar-vin.h  | 3 ---
>  3 files changed, 1 insertion(+), 7 deletions(-)
> 
> diff --git a/drivers/media/platform/rcar-vin/rcar-dma.c 
> b/drivers/media/platform/rcar-vin/rcar-dma.c
> index 5f9674dc898305ba..6cc880e5ef7e0718 100644
> --- a/drivers/media/platform/rcar-vin/rcar-dma.c
> +++ b/drivers/media/platform/rcar-vin/rcar-dma.c
> @@ -514,7 +514,7 @@ static void rvin_set_coeff(struct rvin_dev *vin, unsigned 
> short xs)
>   rvin_write(vin, p_set->coeff_set[23], VNC8C_REG);
>  }
>  
> -void rvin_crop_scale_comp(struct rvin_dev *vin)
> +static void rvin_crop_scale_comp(struct rvin_dev *vin)
>  {
>   u32 xs, ys;
>  
> diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c 
> b/drivers/media/platform/rcar-vin/rcar-v4l2.c
> index 421820caf275b066..305a74d033b2d9c5 100644
> --- a/drivers/media/platform/rcar-vin/rcar-v4l2.c
> +++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c
> @@ -436,9 +436,6 @@ static int rvin_s_selection(struct file *file, void *fh,
>   return -EINVAL;
>   }
>  
> - /* HW supports modifying configuration while running */
> - rvin_crop_scale_comp(vin);
> -
>   return 0;
>  }
>  
> diff --git a/drivers/media/platform/rcar-vin/rcar-vin.h 
> b/drivers/media/platform/rcar-vin/rcar-vin.h
> index b2bac06c0a3cfcb7..fc70ded462ed3244 100644
> --- a/drivers/media/platform/rcar-vin/rcar-vin.h
> +++ b/drivers/media/platform/rcar-vin/rcar-vin.h
> @@ -176,7 +176,4 @@ int rvin_reset_format(struct rvin_dev *vin);
>  
>  const struct rvin_video_format *rvin_format_from_pixel(u32 pixelformat);
>  
> -/* Cropping, composing and scaling */
> -void rvin_crop_scale_comp(struct rvin_dev *vin);
> -
>  #endif
> 



Re: [PATCH v6 08/25] rcar-vin: do not reset crop and compose when setting format

2017-09-25 Thread Hans Verkuil
On 23/08/17 01:26, Niklas Söderlund wrote:
> It was a bad idea to reset the crop and compose settings when a new
> format is set. This would overwrite any crop/compose set by s_select and
> cause unexpected behaviors, remove it. Also fold the reset helper in to
> the only remaining caller.
> 
> Signed-off-by: Niklas Söderlund 

Reviewed-by: Hans Verkuil 

Regards,

Hans

> ---
>  drivers/media/platform/rcar-vin/rcar-v4l2.c | 21 +++--
>  1 file changed, 7 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c 
> b/drivers/media/platform/rcar-vin/rcar-v4l2.c
> index affdc128a75e502e..421820caf275b066 100644
> --- a/drivers/media/platform/rcar-vin/rcar-v4l2.c
> +++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c
> @@ -90,17 +90,6 @@ static u32 rvin_format_sizeimage(struct v4l2_pix_format 
> *pix)
>   * V4L2
>   */
>  
> -static void rvin_reset_crop_compose(struct rvin_dev *vin)
> -{
> - vin->crop.top = vin->crop.left = 0;
> - vin->crop.width = vin->source.width;
> - vin->crop.height = vin->source.height;
> -
> - vin->compose.top = vin->compose.left = 0;
> - vin->compose.width = vin->format.width;
> - vin->compose.height = vin->format.height;
> -}
> -
>  int rvin_reset_format(struct rvin_dev *vin)
>  {
>   struct v4l2_subdev_format fmt = {
> @@ -147,7 +136,13 @@ int rvin_reset_format(struct rvin_dev *vin)
>   break;
>   }
>  
> - rvin_reset_crop_compose(vin);
> + vin->crop.top = vin->crop.left = 0;
> + vin->crop.width = mf->width;
> + vin->crop.height = mf->height;
> +
> + vin->compose.top = vin->compose.left = 0;
> + vin->compose.width = mf->width;
> + vin->compose.height = mf->height;
>  
>   vin->format.bytesperline = rvin_format_bytesperline(>format);
>   vin->format.sizeimage = rvin_format_sizeimage(>format);
> @@ -317,8 +312,6 @@ static int rvin_s_fmt_vid_cap(struct file *file, void 
> *priv,
>  
>   vin->format = f->fmt.pix;
>  
> - rvin_reset_crop_compose(vin);
> -
>   return 0;
>  }
>  
> 



Re: [PATCH v6 07/25] rcar-vin: all Gen2 boards can scale simplify logic

2017-09-25 Thread Hans Verkuil
On 23/08/17 01:26, Niklas Söderlund wrote:
> The logic to preserve the requested format width and height are too
> complex and come from a premature optimization for Gen3. All Gen2 SoC
> can scale and the Gen3 implementation will not use these functions at
> all so simply preserve the width and hight when interacting with the

hight -> height

> subdevice much like the field is preserved simplifies the logic quiet a

quiet -> quite

> bit.
> 
> Signed-off-by: Niklas Söderlund 

Reviewed-by: Hans Verkuil 

Regards,

Hans


> ---
>  drivers/media/platform/rcar-vin/rcar-dma.c  |  8 
>  drivers/media/platform/rcar-vin/rcar-v4l2.c | 22 ++
>  drivers/media/platform/rcar-vin/rcar-vin.h  |  2 --
>  3 files changed, 10 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/media/platform/rcar-vin/rcar-dma.c 
> b/drivers/media/platform/rcar-vin/rcar-dma.c
> index 03a79de197d19e43..5f9674dc898305ba 100644
> --- a/drivers/media/platform/rcar-vin/rcar-dma.c
> +++ b/drivers/media/platform/rcar-vin/rcar-dma.c
> @@ -585,14 +585,6 @@ void rvin_crop_scale_comp(struct rvin_dev *vin)
>   0, 0);
>  }
>  
> -void rvin_scale_try(struct rvin_dev *vin, struct v4l2_pix_format *pix,
> - u32 width, u32 height)
> -{
> - /* All VIN channels on Gen2 have scalers */
> - pix->width = width;
> - pix->height = height;
> -}
> -
>  /* 
> -
>   * Hardware setup
>   */
> diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c 
> b/drivers/media/platform/rcar-vin/rcar-v4l2.c
> index ba88774bd5379a98..affdc128a75e502e 100644
> --- a/drivers/media/platform/rcar-vin/rcar-v4l2.c
> +++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c
> @@ -166,6 +166,7 @@ static int __rvin_try_format_source(struct rvin_dev *vin,
>   .which = which,
>   };
>   enum v4l2_field field;
> + u32 width, height;
>   int ret;
>  
>   sd = vin_to_source(vin);
> @@ -178,7 +179,10 @@ static int __rvin_try_format_source(struct rvin_dev *vin,
>  
>   format.pad = vin->digital.source_pad;
>  
> + /* Allow the video device to override field and to scale */
>   field = pix->field;
> + width = pix->width;
> + height = pix->height;
>  
>   ret = v4l2_subdev_call(sd, pad, set_fmt, pad_cfg, );
>   if (ret < 0 && ret != -ENOIOCTLCMD)
> @@ -191,6 +195,9 @@ static int __rvin_try_format_source(struct rvin_dev *vin,
>   source->width = pix->width;
>   source->height = pix->height;
>  
> + pix->width = width;
> + pix->height = height;
> +
>   vin_dbg(vin, "Source resolution: %ux%u\n", source->width,
>   source->height);
>  
> @@ -204,13 +211,9 @@ static int __rvin_try_format(struct rvin_dev *vin,
>struct v4l2_pix_format *pix,
>struct rvin_source_fmt *source)
>  {
> - u32 rwidth, rheight, walign;
> + u32 walign;
>   int ret;
>  
> - /* Requested */
> - rwidth = pix->width;
> - rheight = pix->height;
> -
>   /* Keep current field if no specific one is asked for */
>   if (pix->field == V4L2_FIELD_ANY)
>   pix->field = vin->format.field;
> @@ -248,10 +251,6 @@ static int __rvin_try_format(struct rvin_dev *vin,
>   break;
>   }
>  
> - /* If source can't match format try if VIN can scale */
> - if (source->width != rwidth || source->height != rheight)
> - rvin_scale_try(vin, pix, rwidth, rheight);
> -
>   /* HW limit width to a multiple of 32 (2^5) for NV16 else 2 (2^1) */
>   walign = vin->format.pixelformat == V4L2_PIX_FMT_NV16 ? 5 : 1;
>  
> @@ -270,9 +269,8 @@ static int __rvin_try_format(struct rvin_dev *vin,
>   return -EINVAL;
>   }
>  
> - vin_dbg(vin, "Requested %ux%u Got %ux%u bpl: %d size: %d\n",
> - rwidth, rheight, pix->width, pix->height,
> - pix->bytesperline, pix->sizeimage);
> + vin_dbg(vin, "Format %ux%u bpl: %d size: %d\n",
> + pix->width, pix->height, pix->bytesperline, pix->sizeimage);
>  
>   return 0;
>  }
> diff --git a/drivers/media/platform/rcar-vin/rcar-vin.h 
> b/drivers/media/platform/rcar-vin/rcar-vin.h
> index 2d8b362012ea46a3..b2bac06c0a3cfcb7 100644
> --- a/drivers/media/platform/rcar-vin/rcar-vin.h
> +++ b/drivers/media/platform/rcar-vin/rcar-vin.h
> @@ -177,8 +177,6 @@ int rvin_reset_format(struct rvin_dev *vin);
>  const struct rvin_video_format *rvin_format_from_pixel(u32 pixelformat);
>  
>  /* Cropping, composing and scaling */
> -void rvin_scale_try(struct rvin_dev *vin, struct v4l2_pix_format *pix,
> - u32 width, u32 height);
>  void rvin_crop_scale_comp(struct rvin_dev *vin);
>  
>  #endif
> 



Re: [PATCH v6 06/25] rcar-vin: move functions regarding scaling

2017-09-25 Thread Hans Verkuil
On 23/08/17 01:26, Niklas Söderlund wrote:
> In preparation of refactoring the scaling code move the code regarding
> scaling to to the top of the file to avoid the need to add forward
> declarations. No code is changed in this commit only whole functions
> moved inside the same file.
> 
> Signed-off-by: Niklas Söderlund 

Reviewed-by: Hans Verkuil 

Regards,

Hans

> ---
>  drivers/media/platform/rcar-vin/rcar-dma.c | 806 
> +++--
>  1 file changed, 405 insertions(+), 401 deletions(-)
> 
> diff --git a/drivers/media/platform/rcar-vin/rcar-dma.c 
> b/drivers/media/platform/rcar-vin/rcar-dma.c
> index b136844499f677cf..03a79de197d19e43 100644
> --- a/drivers/media/platform/rcar-vin/rcar-dma.c
> +++ b/drivers/media/platform/rcar-vin/rcar-dma.c
> @@ -138,305 +138,6 @@ static u32 rvin_read(struct rvin_dev *vin, u32 offset)
>   return ioread32(vin->base + offset);
>  }
>  
> -static int rvin_setup(struct rvin_dev *vin)
> -{
> - u32 vnmc, dmr, dmr2, interrupts;
> - v4l2_std_id std;
> - bool progressive = false, output_is_yuv = false, input_is_yuv = false;
> -
> - switch (vin->format.field) {
> - case V4L2_FIELD_TOP:
> - vnmc = VNMC_IM_ODD;
> - break;
> - case V4L2_FIELD_BOTTOM:
> - vnmc = VNMC_IM_EVEN;
> - break;
> - case V4L2_FIELD_INTERLACED:
> - /* Default to TB */
> - vnmc = VNMC_IM_FULL;
> - /* Use BT if video standard can be read and is 60 Hz format */
> - if (!v4l2_subdev_call(vin_to_source(vin), video, g_std, )) {
> - if (std & V4L2_STD_525_60)
> - vnmc = VNMC_IM_FULL | VNMC_FOC;
> - }
> - break;
> - case V4L2_FIELD_INTERLACED_TB:
> - vnmc = VNMC_IM_FULL;
> - break;
> - case V4L2_FIELD_INTERLACED_BT:
> - vnmc = VNMC_IM_FULL | VNMC_FOC;
> - break;
> - case V4L2_FIELD_ALTERNATE:
> - case V4L2_FIELD_NONE:
> - if (vin->continuous) {
> - vnmc = VNMC_IM_ODD_EVEN;
> - progressive = true;
> - } else {
> - vnmc = VNMC_IM_ODD;
> - }
> - break;
> - default:
> - vnmc = VNMC_IM_ODD;
> - break;
> - }
> -
> - /*
> -  * Input interface
> -  */
> - switch (vin->digital.code) {
> - case MEDIA_BUS_FMT_YUYV8_1X16:
> - /* BT.601/BT.1358 16bit YCbCr422 */
> - vnmc |= VNMC_INF_YUV16;
> - input_is_yuv = true;
> - break;
> - case MEDIA_BUS_FMT_UYVY8_2X8:
> - /* BT.656 8bit YCbCr422 or BT.601 8bit YCbCr422 */
> - vnmc |= vin->digital.mbus_cfg.type == V4L2_MBUS_BT656 ?
> - VNMC_INF_YUV8_BT656 : VNMC_INF_YUV8_BT601;
> - input_is_yuv = true;
> - break;
> - case MEDIA_BUS_FMT_RGB888_1X24:
> - vnmc |= VNMC_INF_RGB888;
> - break;
> - case MEDIA_BUS_FMT_UYVY10_2X10:
> - /* BT.656 10bit YCbCr422 or BT.601 10bit YCbCr422 */
> - vnmc |= vin->digital.mbus_cfg.type == V4L2_MBUS_BT656 ?
> - VNMC_INF_YUV10_BT656 : VNMC_INF_YUV10_BT601;
> - input_is_yuv = true;
> - break;
> - default:
> - break;
> - }
> -
> - /* Enable VSYNC Field Toogle mode after one VSYNC input */
> - dmr2 = VNDMR2_FTEV | VNDMR2_VLV(1);
> -
> - /* Hsync Signal Polarity Select */
> - if (!(vin->digital.mbus_cfg.flags & V4L2_MBUS_HSYNC_ACTIVE_LOW))
> - dmr2 |= VNDMR2_HPS;
> -
> - /* Vsync Signal Polarity Select */
> - if (!(vin->digital.mbus_cfg.flags & V4L2_MBUS_VSYNC_ACTIVE_LOW))
> - dmr2 |= VNDMR2_VPS;
> -
> - /*
> -  * Output format
> -  */
> - switch (vin->format.pixelformat) {
> - case V4L2_PIX_FMT_NV16:
> - rvin_write(vin,
> -ALIGN(vin->format.width * vin->format.height, 0x80),
> -VNUVAOF_REG);
> - dmr = VNDMR_DTMD_YCSEP;
> - output_is_yuv = true;
> - break;
> - case V4L2_PIX_FMT_YUYV:
> - dmr = VNDMR_BPSM;
> - output_is_yuv = true;
> - break;
> - case V4L2_PIX_FMT_UYVY:
> - dmr = 0;
> - output_is_yuv = true;
> - break;
> - case V4L2_PIX_FMT_XRGB555:
> - dmr = VNDMR_DTMD_ARGB1555;
> - break;
> - case V4L2_PIX_FMT_RGB565:
> - dmr = 0;
> - break;
> - case V4L2_PIX_FMT_XBGR32:
> - /* Note: not supported on M1 */
> - dmr = VNDMR_EXRGB;
> - break;
> - default:
> - vin_err(vin, "Invalid pixelformat (0x%x)\n",
> - vin->format.pixelformat);
> - return 

Re: [PATCH v6 05/25] rcar-vin: change name of video device

2017-09-25 Thread Hans Verkuil
On 23/08/17 01:26, Niklas Söderlund wrote:
> The rcar-vin driver needs to be part of a media controller to support
> Gen3. Give each VIN instance a unique name so it can be referenced from
> userspace.
> 
> Signed-off-by: Niklas Söderlund 
> Reviewed-by: Kieran Bingham 

Reviewed-by: Hans Verkuil 

Regards,

Hans

> ---
>  drivers/media/platform/rcar-vin/rcar-v4l2.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c 
> b/drivers/media/platform/rcar-vin/rcar-v4l2.c
> index 3c4dd08261a0d3f5..ba88774bd5379a98 100644
> --- a/drivers/media/platform/rcar-vin/rcar-v4l2.c
> +++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c
> @@ -878,7 +878,8 @@ int rvin_v4l2_probe(struct rvin_dev *vin)
>   vdev->fops = _fops;
>   vdev->v4l2_dev = >v4l2_dev;
>   vdev->queue = >queue;
> - strlcpy(vdev->name, KBUILD_MODNAME, sizeof(vdev->name));
> + snprintf(vdev->name, sizeof(vdev->name), "%s %s", KBUILD_MODNAME,
> +  dev_name(vin->dev));
>   vdev->release = video_device_release_empty;
>   vdev->ioctl_ops = _ioctl_ops;
>   vdev->lock = >lock;
> 



Re: [PATCH v6 04/25] rcar-vin: move max width and height information to chip information

2017-09-25 Thread Hans Verkuil
On 23/08/17 01:26, Niklas Söderlund wrote:
> On Gen3 the max supported width and height will be different from Gen2.
> Move the limits to the struct rvin_info to prepare for Gen3 support.
> 
> Signed-off-by: Niklas Söderlund 
> Reviewed-by: Kieran Bingham 

Reviewed-by: Hans Verkuil 

Regards,

Hans

> ---
>  drivers/media/platform/rcar-vin/rcar-core.c | 6 ++
>  drivers/media/platform/rcar-vin/rcar-v4l2.c | 6 ++
>  drivers/media/platform/rcar-vin/rcar-vin.h  | 6 ++
>  3 files changed, 14 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/media/platform/rcar-vin/rcar-core.c 
> b/drivers/media/platform/rcar-vin/rcar-core.c
> index dae38de706b66b64..4dc148e7835439ab 100644
> --- a/drivers/media/platform/rcar-vin/rcar-core.c
> +++ b/drivers/media/platform/rcar-vin/rcar-core.c
> @@ -279,14 +279,20 @@ static int rvin_digital_graph_init(struct rvin_dev *vin)
>  
>  static const struct rvin_info rcar_info_h1 = {
>   .chip = RCAR_H1,
> + .max_width = 2048,
> + .max_height = 2048,
>  };
>  
>  static const struct rvin_info rcar_info_m1 = {
>   .chip = RCAR_M1,
> + .max_width = 2048,
> + .max_height = 2048,
>  };
>  
>  static const struct rvin_info rcar_info_gen2 = {
>   .chip = RCAR_GEN2,
> + .max_width = 2048,
> + .max_height = 2048,
>  };
>  
>  static const struct of_device_id rvin_of_id_table[] = {
> diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c 
> b/drivers/media/platform/rcar-vin/rcar-v4l2.c
> index 02a08cf5acfce1ce..3c4dd08261a0d3f5 100644
> --- a/drivers/media/platform/rcar-vin/rcar-v4l2.c
> +++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c
> @@ -23,8 +23,6 @@
>  #include "rcar-vin.h"
>  
>  #define RVIN_DEFAULT_FORMAT  V4L2_PIX_FMT_YUYV
> -#define RVIN_MAX_WIDTH   2048
> -#define RVIN_MAX_HEIGHT  2048
>  
>  /* 
> -
>   * Format Conversions
> @@ -258,8 +256,8 @@ static int __rvin_try_format(struct rvin_dev *vin,
>   walign = vin->format.pixelformat == V4L2_PIX_FMT_NV16 ? 5 : 1;
>  
>   /* Limit to VIN capabilities */
> - v4l_bound_align_image(>width, 2, RVIN_MAX_WIDTH, walign,
> -   >height, 4, RVIN_MAX_HEIGHT, 2, 0);
> + v4l_bound_align_image(>width, 2, vin->info->max_width, walign,
> +   >height, 4, vin->info->max_height, 2, 0);
>  
>   pix->bytesperline = max_t(u32, pix->bytesperline,
> rvin_format_bytesperline(pix));
> diff --git a/drivers/media/platform/rcar-vin/rcar-vin.h 
> b/drivers/media/platform/rcar-vin/rcar-vin.h
> index 13466dfd72292fc0..2d8b362012ea46a3 100644
> --- a/drivers/media/platform/rcar-vin/rcar-vin.h
> +++ b/drivers/media/platform/rcar-vin/rcar-vin.h
> @@ -91,9 +91,15 @@ struct rvin_graph_entity {
>  /**
>   * struct rvin_info - Information about the particular VIN implementation
>   * @chip:type of VIN chip
> + *
> + * max_width:max input width the VIN supports
> + * max_height:   max input height the VIN supports
>   */
>  struct rvin_info {
>   enum chip_id chip;
> +
> + unsigned int max_width;
> + unsigned int max_height;
>  };
>  
>  /**
> 



Re: [PATCH v6 03/25] rcar-vin: move chip information to own struct

2017-09-25 Thread Hans Verkuil
On 23/08/17 01:26, Niklas Söderlund wrote:
> When Gen3 support is added to the driver more then chip id will be

then -> than

> different for the different Soc. To avoid a lot of if statements in the
> code create a struct chip_info to contain this information.
> 
> Signed-off-by: Niklas Söderlund 
> Reviewed-by: Kieran Bingham 

Reviewed-by: Hans Verkuil 

Regards,

Hans

> ---
>  drivers/media/platform/rcar-vin/rcar-core.c | 49 
> -
>  drivers/media/platform/rcar-vin/rcar-v4l2.c |  3 +-
>  drivers/media/platform/rcar-vin/rcar-vin.h  | 12 +--
>  3 files changed, 53 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/media/platform/rcar-vin/rcar-core.c 
> b/drivers/media/platform/rcar-vin/rcar-core.c
> index aefbe8e3ccddb3e4..dae38de706b66b64 100644
> --- a/drivers/media/platform/rcar-vin/rcar-core.c
> +++ b/drivers/media/platform/rcar-vin/rcar-core.c
> @@ -277,14 +277,47 @@ static int rvin_digital_graph_init(struct rvin_dev *vin)
>   * Platform Device Driver
>   */
>  
> +static const struct rvin_info rcar_info_h1 = {
> + .chip = RCAR_H1,
> +};
> +
> +static const struct rvin_info rcar_info_m1 = {
> + .chip = RCAR_M1,
> +};
> +
> +static const struct rvin_info rcar_info_gen2 = {
> + .chip = RCAR_GEN2,
> +};
> +
>  static const struct of_device_id rvin_of_id_table[] = {
> - { .compatible = "renesas,vin-r8a7794", .data = (void *)RCAR_GEN2 },
> - { .compatible = "renesas,vin-r8a7793", .data = (void *)RCAR_GEN2 },
> - { .compatible = "renesas,vin-r8a7791", .data = (void *)RCAR_GEN2 },
> - { .compatible = "renesas,vin-r8a7790", .data = (void *)RCAR_GEN2 },
> - { .compatible = "renesas,vin-r8a7779", .data = (void *)RCAR_H1 },
> - { .compatible = "renesas,vin-r8a7778", .data = (void *)RCAR_M1 },
> - { .compatible = "renesas,rcar-gen2-vin", .data = (void *)RCAR_GEN2 },
> + {
> + .compatible = "renesas,vin-r8a7794",
> + .data = _info_gen2,
> + },
> + {
> + .compatible = "renesas,vin-r8a7793",
> + .data = _info_gen2,
> + },
> + {
> + .compatible = "renesas,vin-r8a7791",
> + .data = _info_gen2,
> + },
> + {
> + .compatible = "renesas,vin-r8a7790",
> + .data = _info_gen2,
> + },
> + {
> + .compatible = "renesas,vin-r8a7779",
> + .data = _info_h1,
> + },
> + {
> + .compatible = "renesas,vin-r8a7778",
> + .data = _info_m1,
> + },
> + {
> + .compatible = "renesas,rcar-gen2-vin",
> + .data = _info_gen2,
> + },
>   { },
>  };
>  MODULE_DEVICE_TABLE(of, rvin_of_id_table);
> @@ -305,7 +338,7 @@ static int rcar_vin_probe(struct platform_device *pdev)
>   return -ENODEV;
>  
>   vin->dev = >dev;
> - vin->chip = (enum chip_id)match->data;
> + vin->info = match->data;
>  
>   mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>   if (mem == NULL)
> diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c 
> b/drivers/media/platform/rcar-vin/rcar-v4l2.c
> index 81ff59c3b4744075..02a08cf5acfce1ce 100644
> --- a/drivers/media/platform/rcar-vin/rcar-v4l2.c
> +++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c
> @@ -266,7 +266,8 @@ static int __rvin_try_format(struct rvin_dev *vin,
>   pix->sizeimage = max_t(u32, pix->sizeimage,
>  rvin_format_sizeimage(pix));
>  
> - if (vin->chip == RCAR_M1 && pix->pixelformat == V4L2_PIX_FMT_XBGR32) {
> + if (vin->info->chip == RCAR_M1 &&
> + pix->pixelformat == V4L2_PIX_FMT_XBGR32) {
>   vin_err(vin, "pixel format XBGR32 not supported on M1\n");
>   return -EINVAL;
>   }
> diff --git a/drivers/media/platform/rcar-vin/rcar-vin.h 
> b/drivers/media/platform/rcar-vin/rcar-vin.h
> index 9d0d4a5001b6ccd8..13466dfd72292fc0 100644
> --- a/drivers/media/platform/rcar-vin/rcar-vin.h
> +++ b/drivers/media/platform/rcar-vin/rcar-vin.h
> @@ -88,11 +88,19 @@ struct rvin_graph_entity {
>   unsigned int sink_pad;
>  };
>  
> +/**
> + * struct rvin_info - Information about the particular VIN implementation
> + * @chip:type of VIN chip
> + */
> +struct rvin_info {
> + enum chip_id chip;
> +};
> +
>  /**
>   * struct rvin_dev - Renesas VIN device structure
>   * @dev: (OF) device
>   * @base:device I/O register space remapped to virtual memory
> - * @chip:type of VIN chip
> + * @info:info about VIN instance
>   *
>   * @vdev:V4L2 video device associated with VIN
>   * @v4l2_dev:V4L2 device
> @@ -120,7 +128,7 @@ struct rvin_graph_entity {
>  struct rvin_dev {
>   struct device *dev;
>   void __iomem *base;
> - enum chip_id chip;
> + const struct rvin_info *info;
>  
>   struct 

[PATCH 2/2] dt-bindings: spi: sh-msiof: Add r8a774[35] to the compatible list

2017-09-25 Thread Fabrizio Castro
Signed-off-by: Fabrizio Castro 
---
 Documentation/devicetree/bindings/spi/sh-msiof.txt | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/spi/sh-msiof.txt 
b/Documentation/devicetree/bindings/spi/sh-msiof.txt
index e865855..bdd8395 100644
--- a/Documentation/devicetree/bindings/spi/sh-msiof.txt
+++ b/Documentation/devicetree/bindings/spi/sh-msiof.txt
@@ -1,7 +1,9 @@
 Renesas MSIOF spi controller
 
 Required properties:
-- compatible   : "renesas,msiof-r8a7790" (R-Car H2)
+- compatible   : "renesas,msiof-r8a7743" (RZ/G1M)
+"renesas,msiof-r8a7745" (RZ/G1E)
+"renesas,msiof-r8a7790" (R-Car H2)
 "renesas,msiof-r8a7791" (R-Car M2-W)
 "renesas,msiof-r8a7792" (R-Car V2H)
 "renesas,msiof-r8a7793" (R-Car M2-N)
@@ -10,7 +12,7 @@ Required properties:
 "renesas,msiof-r8a7796" (R-Car M3-W)
 "renesas,msiof-sh73a0" (SH-Mobile AG5)
 "renesas,sh-mobile-msiof" (generic SH-Mobile 
compatibile device)
-"renesas,rcar-gen2-msiof" (generic R-Car Gen2 
compatible device)
+"renesas,rcar-gen2-msiof" (generic R-Car Gen2 and 
RZ/G1 compatible device)
 "renesas,rcar-gen3-msiof" (generic R-Car Gen3 
compatible device)
 "renesas,sh-msiof"  (deprecated)
 
-- 
2.7.4



[PATCH 0/2] spi: sh-msiof: Add r8a774[35] bindings

2017-09-25 Thread Fabrizio Castro
This series adds compatible strings and device tree bindings in order to enable
msiof support for r8a7743 and r8a7745.

Fabrizio Castro (2):
  spi: sh-msiof: Add compatible strings for r8a774[35]
  dt-bindings: spi: sh-msiof: Add r8a774[35] to the compatible list

 Documentation/devicetree/bindings/spi/sh-msiof.txt | 6 --
 drivers/spi/spi-sh-msiof.c | 2 ++
 2 files changed, 6 insertions(+), 2 deletions(-)

-- 
2.7.4



[PATCH 1/2] spi: sh-msiof: Add compatible strings for r8a774[35]

2017-09-25 Thread Fabrizio Castro
Signed-off-by: Fabrizio Castro 
---
 drivers/spi/spi-sh-msiof.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
index 0eb1e95..0080844 100644
--- a/drivers/spi/spi-sh-msiof.c
+++ b/drivers/spi/spi-sh-msiof.c
@@ -1021,6 +1021,8 @@ static const struct sh_msiof_chipdata rcar_gen3_data = {
 
 static const struct of_device_id sh_msiof_match[] = {
{ .compatible = "renesas,sh-mobile-msiof", .data = _data },
+   { .compatible = "renesas,msiof-r8a7743",   .data = _gen2_data },
+   { .compatible = "renesas,msiof-r8a7745",   .data = _gen2_data },
{ .compatible = "renesas,msiof-r8a7790",   .data = _gen2_data },
{ .compatible = "renesas,msiof-r8a7791",   .data = _gen2_data },
{ .compatible = "renesas,msiof-r8a7792",   .data = _gen2_data },
-- 
2.7.4



[PATCH] clk/Renesas: Delete an error message for a failed memory allocation in three functions

2017-09-25 Thread SF Markus Elfring
From: Markus Elfring 
Date: Mon, 25 Sep 2017 10:10:51 +0200

The script "checkpatch.pl" pointed information out like the following.

WARNING: Possible unnecessary 'out of memory' message

Thus fix affected source code places.

Signed-off-by: Markus Elfring 
---
 drivers/clk/renesas/clk-mstp.c  | 5 +
 drivers/clk/renesas/clk-rcar-gen2.c | 1 -
 2 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/clk/renesas/clk-mstp.c b/drivers/clk/renesas/clk-mstp.c
index 500a9e4e03c4..c944cc421e30 100644
--- a/drivers/clk/renesas/clk-mstp.c
+++ b/drivers/clk/renesas/clk-mstp.c
@@ -156,10 +156,8 @@ static struct clk * __init cpg_mstp_clock_register(const 
char *name,
struct clk *clk;
 
clock = kzalloc(sizeof(*clock), GFP_KERNEL);
-   if (!clock) {
-   pr_err("%s: failed to allocate MSTP clock.\n", __func__);
+   if (!clock)
return ERR_PTR(-ENOMEM);
-   }
 
init.name = name;
init.ops = _mstp_clock_ops;
@@ -196,7 +194,6 @@ static void __init cpg_mstp_clocks_init(struct device_node 
*np)
if (group == NULL || clks == NULL) {
kfree(group);
kfree(clks);
-   pr_err("%s: failed to allocate group\n", __func__);
return;
}
 
diff --git a/drivers/clk/renesas/clk-rcar-gen2.c 
b/drivers/clk/renesas/clk-rcar-gen2.c
index 0b2e56d0d94b..d14cbe1ca29a 100644
--- a/drivers/clk/renesas/clk-rcar-gen2.c
+++ b/drivers/clk/renesas/clk-rcar-gen2.c
@@ -423,7 +423,6 @@ static void __init rcar_gen2_cpg_clocks_init(struct 
device_node *np)
/* We're leaking memory on purpose, there's no point in cleaning
 * up as the system won't boot anyway.
 */
-   pr_err("%s: failed to allocate cpg\n", __func__);
return;
}
 
-- 
2.14.1



[PATCH 2/3] usb: gadget: udc: renesas_usb3: fix Pn_RAMMAP.Pn_MPKT value

2017-09-25 Thread Yoshihiro Shimoda
According to the datasheet of R-Car Gen3, the Pn_RAMMAP.Pn_MPKT should
be set to one of 8, 16, 32, 64, 512 and 1024. Otherwise, when a gadget
driver uses an interrupt endpoint, unexpected behavior happens. So,
this patch fixes it.

Fixes: 746bfe63bba3 ("usb: gadget: renesas_usb3: add support for Renesas USB3.0 
peripheral controller")
Cc:  # v4.5+
Signed-off-by: Yoshihiro Shimoda 
---
 drivers/usb/gadget/udc/renesas_usb3.c | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/udc/renesas_usb3.c 
b/drivers/usb/gadget/udc/renesas_usb3.c
index 555c105..7e0c534 100644
--- a/drivers/usb/gadget/udc/renesas_usb3.c
+++ b/drivers/usb/gadget/udc/renesas_usb3.c
@@ -2054,7 +2054,16 @@ static u32 usb3_calc_ramarea(int ram_size)
 static u32 usb3_calc_rammap_val(struct renesas_usb3_ep *usb3_ep,
const struct usb_endpoint_descriptor *desc)
 {
-   return usb3_ep->rammap_val | PN_RAMMAP_MPKT(usb_endpoint_maxp(desc));
+   int i;
+   const u32 max_packet_array[] = {8, 16, 32, 64, 512};
+   u32 mpkt = PN_RAMMAP_MPKT(1024);
+
+   for (i = 0; i < ARRAY_SIZE(max_packet_array); i++) {
+   if (usb_endpoint_maxp(desc) <= max_packet_array[i])
+   mpkt = PN_RAMMAP_MPKT(max_packet_array[i]);
+   }
+
+   return usb3_ep->rammap_val | mpkt;
 }
 
 static int usb3_enable_pipe_n(struct renesas_usb3_ep *usb3_ep,
-- 
1.9.1



[PATCH 3/3] usb: gadget: udc: renesas_usb3: Fix return value of usb3_write_pipe()

2017-09-25 Thread Yoshihiro Shimoda
This patch fixes an issue that this driver cannot go status stage
in control read when the req.zero is set to 1 and the len in
usb3_write_pipe() is set to 0. Otherwise, if we use g_ncm driver,
usb enumeration takes long time (5 seconds or more).

Fixes: 746bfe63bba3 ("usb: gadget: renesas_usb3: add support for Renesas USB3.0 
peripheral controller")
Cc:  # v4.5+
Signed-off-by: Yoshihiro Shimoda 
---
 drivers/usb/gadget/udc/renesas_usb3.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/udc/renesas_usb3.c 
b/drivers/usb/gadget/udc/renesas_usb3.c
index 7e0c534..63a2061 100644
--- a/drivers/usb/gadget/udc/renesas_usb3.c
+++ b/drivers/usb/gadget/udc/renesas_usb3.c
@@ -1038,7 +1038,7 @@ static int usb3_write_pipe(struct renesas_usb3_ep 
*usb3_ep,
usb3_ep->ep.maxpacket);
u8 *buf = usb3_req->req.buf + usb3_req->req.actual;
u32 tmp = 0;
-   bool is_last;
+   bool is_last = !len ? true : false;
 
if (usb3_wait_pipe_status(usb3_ep, PX_STA_BUFSTS) < 0)
return -EBUSY;
@@ -1059,7 +1059,8 @@ static int usb3_write_pipe(struct renesas_usb3_ep 
*usb3_ep,
usb3_write(usb3, tmp, fifo_reg);
}
 
-   is_last = usb3_is_transfer_complete(usb3_ep, usb3_req);
+   if (!is_last)
+   is_last = usb3_is_transfer_complete(usb3_ep, usb3_req);
/* Send the data */
usb3_set_px_con_send(usb3_ep, len, is_last);
 
-- 
1.9.1



[PATCH 0/3] usb: gadget: udc: renesas_usb3: bugfix for v4.14

2017-09-25 Thread Yoshihiro Shimoda
This patch set is based on the Felipe's usb.git / testing/fixes branch
(The commit is 7661ca09b2ff98f48693f431bb01fed62830e433).

Yoshihiro Shimoda (3):
  usb: gadget: udc: renesas_usb3: fix for no-data control transfer
  usb: gadget: udc: renesas_usb3: fix Pn_RAMMAP.Pn_MPKT value
  usb: gadget: udc: renesas_usb3: Fix return value of usb3_write_pipe()

 drivers/usb/gadget/udc/renesas_usb3.c | 19 +++
 1 file changed, 15 insertions(+), 4 deletions(-)

-- 
1.9.1



[PATCH 1/3] usb: gadget: udc: renesas_usb3: fix for no-data control transfer

2017-09-25 Thread Yoshihiro Shimoda
When bRequestType & USB_DIR_IN is false and req.length is 0 in control
transfer, since it means non-data, this driver should not set the mode
as control write. So, this patch fixes it.

Fixes: 746bfe63bba3 ("usb: gadget: renesas_usb3: add support for Renesas USB3.0 
peripheral controller")
Cc:  # v4.5+
Signed-off-by: Yoshihiro Shimoda 
---
 drivers/usb/gadget/udc/renesas_usb3.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/udc/renesas_usb3.c 
b/drivers/usb/gadget/udc/renesas_usb3.c
index df37c1e..555c105 100644
--- a/drivers/usb/gadget/udc/renesas_usb3.c
+++ b/drivers/usb/gadget/udc/renesas_usb3.c
@@ -1150,7 +1150,8 @@ static void usb3_start_pipe0(struct renesas_usb3_ep 
*usb3_ep,
usb3_set_p0_con_for_ctrl_read_data(usb3);
} else {
usb3_clear_bit(usb3, P0_MOD_DIR, USB3_P0_MOD);
-   usb3_set_p0_con_for_ctrl_write_data(usb3);
+   if (usb3_req->req.length)
+   usb3_set_p0_con_for_ctrl_write_data(usb3);
}
 
usb3_p0_xfer(usb3_ep, usb3_req);
-- 
1.9.1



[PATCH 3/3] soc: renesas: rcar-sysc: add R8A77970 support

2017-09-25 Thread Simon Horman
From: Sergei Shtylyov 

Add support for R-Car V3M (R8A77970) SoC power areas to the R-Car SYSC
driver.

Based on the original (and large) patch by Daisuke Matsushita
.

Signed-off-by: Vladimir Barinov 
Signed-off-by: Sergei Shtylyov 
Reviewed-by: Geert Uytterhoeven 
Signed-off-by: Simon Horman 
---
 .../bindings/power/renesas,rcar-sysc.txt   |  1 +
 drivers/soc/renesas/Kconfig|  5 +++
 drivers/soc/renesas/Makefile   |  1 +
 drivers/soc/renesas/r8a77970-sysc.c| 39 ++
 drivers/soc/renesas/rcar-sysc.c|  3 ++
 drivers/soc/renesas/rcar-sysc.h|  1 +
 6 files changed, 50 insertions(+)
 create mode 100644 drivers/soc/renesas/r8a77970-sysc.c

diff --git a/Documentation/devicetree/bindings/power/renesas,rcar-sysc.txt 
b/Documentation/devicetree/bindings/power/renesas,rcar-sysc.txt
index 98cc8c09d02d..8690f10426a3 100644
--- a/Documentation/devicetree/bindings/power/renesas,rcar-sysc.txt
+++ b/Documentation/devicetree/bindings/power/renesas,rcar-sysc.txt
@@ -17,6 +17,7 @@ Required properties:
   - "renesas,r8a7794-sysc" (R-Car E2)
   - "renesas,r8a7795-sysc" (R-Car H3)
   - "renesas,r8a7796-sysc" (R-Car M3-W)
+  - "renesas,r8a77970-sysc" (R-Car V3M)
   - "renesas,r8a77995-sysc" (R-Car D3)
   - reg: Address start and address range for the device.
   - #power-domain-cells: Must be 1.
diff --git a/drivers/soc/renesas/Kconfig b/drivers/soc/renesas/Kconfig
index f0d562a7c4d3..09550b1da56d 100644
--- a/drivers/soc/renesas/Kconfig
+++ b/drivers/soc/renesas/Kconfig
@@ -14,6 +14,7 @@ config SOC_RENESAS
select SYSC_R8A7794 if ARCH_R8A7794
select SYSC_R8A7795 if ARCH_R8A7795
select SYSC_R8A7796 if ARCH_R8A7796
+   select SYSC_R8A77970 if ARCH_R8A77970
select SYSC_R8A77995 if ARCH_R8A77995
 
 if SOC_RENESAS
@@ -55,6 +56,10 @@ config SYSC_R8A7796
bool "R-Car M3-W System Controller support" if COMPILE_TEST
select SYSC_RCAR
 
+config SYSC_R8A77970
+   bool "R-Car V3M System Controller support" if COMPILE_TEST
+   select SYSC_RCAR
+
 config SYSC_R8A77995
bool "R-Car D3 System Controller support" if COMPILE_TEST
select SYSC_RCAR
diff --git a/drivers/soc/renesas/Makefile b/drivers/soc/renesas/Makefile
index 6b6e7f16104c..8334af1d231b 100644
--- a/drivers/soc/renesas/Makefile
+++ b/drivers/soc/renesas/Makefile
@@ -11,6 +11,7 @@ obj-$(CONFIG_SYSC_R8A7792)+= r8a7792-sysc.o
 obj-$(CONFIG_SYSC_R8A7794) += r8a7794-sysc.o
 obj-$(CONFIG_SYSC_R8A7795) += r8a7795-sysc.o
 obj-$(CONFIG_SYSC_R8A7796) += r8a7796-sysc.o
+obj-$(CONFIG_SYSC_R8A77970)+= r8a77970-sysc.o
 obj-$(CONFIG_SYSC_R8A77995)+= r8a77995-sysc.o
 
 # Family
diff --git a/drivers/soc/renesas/r8a77970-sysc.c 
b/drivers/soc/renesas/r8a77970-sysc.c
new file mode 100644
index ..8c614164718e
--- /dev/null
+++ b/drivers/soc/renesas/r8a77970-sysc.c
@@ -0,0 +1,39 @@
+/*
+ * Renesas R-Car V3M System Controller
+ *
+ * Copyright (C) 2017 Cogent Embedded Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+#include 
+
+#include 
+
+#include "rcar-sysc.h"
+
+static const struct rcar_sysc_area r8a77970_areas[] __initconst = {
+   { "always-on",  0, 0, R8A77970_PD_ALWAYS_ON, -1, PD_ALWAYS_ON },
+   { "ca53-scu",   0x140, 0, R8A77970_PD_CA53_SCU, R8A77970_PD_ALWAYS_ON,
+ PD_SCU },
+   { "ca53-cpu0",  0x200, 0, R8A77970_PD_CA53_CPU0, R8A77970_PD_CA53_SCU,
+ PD_CPU_NOCR },
+   { "ca53-cpu1",  0x200, 1, R8A77970_PD_CA53_CPU1, R8A77970_PD_CA53_SCU,
+ PD_CPU_NOCR },
+   { "cr7",0x240, 0, R8A77970_PD_CR7,  R8A77970_PD_ALWAYS_ON },
+   { "a3ir",   0x180, 0, R8A77970_PD_A3IR, R8A77970_PD_ALWAYS_ON },
+   { "a2ir0",  0x400, 0, R8A77970_PD_A2IR0,R8A77970_PD_ALWAYS_ON },
+   { "a2ir1",  0x400, 1, R8A77970_PD_A2IR1,R8A77970_PD_A2IR0 },
+   { "a2ir2",  0x400, 2, R8A77970_PD_A2IR2,R8A77970_PD_A2IR0 },
+   { "a2ir3",  0x400, 3, R8A77970_PD_A2IR3,R8A77970_PD_A2IR0 },
+   { "a2sc0",  0x400, 4, R8A77970_PD_A2SC0,R8A77970_PD_ALWAYS_ON },
+   { "a2sc1",  0x400, 5, R8A77970_PD_A2SC1,R8A77970_PD_A2SC0 },
+};
+
+const struct rcar_sysc_info r8a77970_sysc_info __initconst = {
+   .areas = r8a77970_areas,
+   .num_areas = ARRAY_SIZE(r8a77970_areas),
+};
diff --git a/drivers/soc/renesas/rcar-sysc.c b/drivers/soc/renesas/rcar-sysc.c
index c8406e81640f..55a47e509e49 100644
--- a/drivers/soc/renesas/rcar-sysc.c
+++ b/drivers/soc/renesas/rcar-sysc.c
@@ -284,6 +284,9 @@ 

[PATCH 2/3] ARM: Add definition for monitor mode

2017-09-25 Thread Simon Horman
From: Geert Uytterhoeven 

 provides *_MODE definitions for the various processor
modes, but monitor mode was missing.

Add MON_MODE to avoid code using the hardcoded value.

Suggested-by: Marc Zyngier 
Signed-off-by: Geert Uytterhoeven 
Tested-by: Fabrizio Castro 
Signed-off-by: Simon Horman 
---
 arch/arm/include/uapi/asm/ptrace.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/include/uapi/asm/ptrace.h 
b/arch/arm/include/uapi/asm/ptrace.h
index 5af0ed1b825a..70ff6bf489f3 100644
--- a/arch/arm/include/uapi/asm/ptrace.h
+++ b/arch/arm/include/uapi/asm/ptrace.h
@@ -53,6 +53,7 @@
 #endif
 #define FIQ_MODE   0x0011
 #define IRQ_MODE   0x0012
+#define MON_MODE   0x0016
 #define ABT_MODE   0x0017
 #define HYP_MODE   0x001a
 #define UND_MODE   0x001b
-- 
2.1.4



[PATCH 1/3] ARM: debug-ll: Add support for r8a7745

2017-09-25 Thread Simon Horman
From: Fabrizio Castro 

Enable low-level debugging support for RZ/G1E (r8a7745). RZ/G1E uses
SCIF4 for the debug console.

Signed-off-by: Fabrizio Castro 
Reviewed-by: Chris Paterson 
Reviewed-by: Geert Uytterhoeven 
Signed-off-by: Simon Horman 
---
 arch/arm/Kconfig.debug | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug
index 6dcea8e8e941..31bf312be7d5 100644
--- a/arch/arm/Kconfig.debug
+++ b/arch/arm/Kconfig.debug
@@ -911,6 +911,13 @@ choice
  Say Y here if you want kernel low-level debugging support
  via SCIF2 on Renesas R-Car E2 (R8A7794).
 
+   config DEBUG_RCAR_GEN2_SCIF4
+   bool "Kernel low-level debugging messages via SCIF4 on R8A7745"
+   depends on ARCH_R8A7745
+   help
+ Say Y here if you want kernel low-level debugging support
+ via SCIF4 on Renesas RZ/G1E (R8A7745).
+
config DEBUG_RMOBILE_SCIFA0
bool "Kernel low-level debugging messages via SCIFA0 on R8A73A4"
depends on ARCH_R8A73A4
@@ -1451,6 +1458,7 @@ config DEBUG_LL_INCLUDE
default "debug/renesas-scif.S" if DEBUG_RCAR_GEN1_SCIF2
default "debug/renesas-scif.S" if DEBUG_RCAR_GEN2_SCIF0
default "debug/renesas-scif.S" if DEBUG_RCAR_GEN2_SCIF2
+   default "debug/renesas-scif.S" if DEBUG_RCAR_GEN2_SCIF4
default "debug/renesas-scif.S" if DEBUG_RMOBILE_SCIFA0
default "debug/renesas-scif.S" if DEBUG_RMOBILE_SCIFA1
default "debug/renesas-scif.S" if DEBUG_RMOBILE_SCIFA4
@@ -1570,6 +1578,7 @@ config DEBUG_UART_PHYS
default 0xe6c8 if DEBUG_RMOBILE_SCIFA4
default 0xe6e58000 if DEBUG_RCAR_GEN2_SCIF2
default 0xe6e6 if DEBUG_RCAR_GEN2_SCIF0
+   default 0xe6ee if DEBUG_RCAR_GEN2_SCIF4
default 0xe8008000 if DEBUG_R7S72100_SCIF2
default 0xfbe0 if ARCH_EBSA110
default 0xf1012000 if DEBUG_MVEBU_UART0_ALTERNATE
@@ -1604,6 +1613,7 @@ config DEBUG_UART_PHYS
DEBUG_QCOM_UARTDM || DEBUG_R7S72100_SCIF2 || \
DEBUG_RCAR_GEN1_SCIF0 || DEBUG_RCAR_GEN1_SCIF2 || \
DEBUG_RCAR_GEN2_SCIF0 || DEBUG_RCAR_GEN2_SCIF2 || \
+   DEBUG_RCAR_GEN2_SCIF4 || \
DEBUG_RMOBILE_SCIFA0 || DEBUG_RMOBILE_SCIFA1 || \
DEBUG_RMOBILE_SCIFA4 || DEBUG_S3C24XX_UART || \
DEBUG_S3C64XX_UART || \
-- 
2.1.4



[PATCH 2/3] soc: renesas: identify R-Car V3M

2017-09-25 Thread Simon Horman
From: Sergei Shtylyov 

Add support for identifying the R-Car V3M (R8A77970) SoC.

Signed-off-by: Sergei Shtylyov 
Reviewed-by: Geert Uytterhoeven 
Signed-off-by: Simon Horman 
---
 drivers/soc/renesas/renesas-soc.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/soc/renesas/renesas-soc.c 
b/drivers/soc/renesas/renesas-soc.c
index 90d6b7a4340a..9f4ee2567c72 100644
--- a/drivers/soc/renesas/renesas-soc.c
+++ b/drivers/soc/renesas/renesas-soc.c
@@ -144,6 +144,11 @@ static const struct renesas_soc soc_rcar_m3_w __initconst 
__maybe_unused = {
.id = 0x52,
 };
 
+static const struct renesas_soc soc_rcar_v3m __initconst __maybe_unused = {
+   .family = _rcar_gen3,
+   .id = 0x54,
+};
+
 static const struct renesas_soc soc_rcar_d3 __initconst __maybe_unused = {
.family = _rcar_gen3,
.id = 0x58,
@@ -204,6 +209,9 @@ static const struct of_device_id renesas_socs[] __initconst 
= {
 #ifdef CONFIG_ARCH_R8A7796
{ .compatible = "renesas,r8a7796",  .data = _rcar_m3_w },
 #endif
+#ifdef CONFIG_ARCH_R8A77970
+   { .compatible = "renesas,r8a77970", .data = _rcar_v3m },
+#endif
 #ifdef CONFIG_ARCH_R8A77995
{ .compatible = "renesas,r8a77995", .data = _rcar_d3 },
 #endif
-- 
2.1.4



[PATCH 1/3] soc: renesas: rcar-rst: add R8A77970 support

2017-09-25 Thread Simon Horman
From: Sergei Shtylyov 

Add support for R-Car V3M (R8A77970) to the R-Car RST driver -- this driver
is  needed  for the clock driver to work.

Signed-off-by: Sergei Shtylyov 
Reviewed-by: Geert Uytterhoeven 
Signed-off-by: Simon Horman 
---
 Documentation/devicetree/bindings/reset/renesas,rst.txt | 1 +
 drivers/soc/renesas/Kconfig | 3 ++-
 drivers/soc/renesas/rcar-rst.c  | 1 +
 3 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/reset/renesas,rst.txt 
b/Documentation/devicetree/bindings/reset/renesas,rst.txt
index e5a03ffe04fb..a8014f3ab8ba 100644
--- a/Documentation/devicetree/bindings/reset/renesas,rst.txt
+++ b/Documentation/devicetree/bindings/reset/renesas,rst.txt
@@ -26,6 +26,7 @@ Required properties:
  - "renesas,r8a7794-rst" (R-Car E2)
  - "renesas,r8a7795-rst" (R-Car H3)
  - "renesas,r8a7796-rst" (R-Car M3-W)
+ - "renesas,r8a77970-rst" (R-Car V3M)
  - "renesas,r8a77995-rst" (R-Car D3)
   - reg: Address start and address range for the device.
 
diff --git a/drivers/soc/renesas/Kconfig b/drivers/soc/renesas/Kconfig
index 567414cb42ba..f0d562a7c4d3 100644
--- a/drivers/soc/renesas/Kconfig
+++ b/drivers/soc/renesas/Kconfig
@@ -3,7 +3,8 @@ config SOC_RENESAS
default y if ARCH_RENESAS
select SOC_BUS
select RST_RCAR if ARCH_RCAR_GEN1 || ARCH_RCAR_GEN2 || \
-  ARCH_R8A7795 || ARCH_R8A7796 || ARCH_R8A77995
+  ARCH_R8A7795 || ARCH_R8A7796 || ARCH_R8A77970 || \
+  ARCH_R8A77995
select SYSC_R8A7743 if ARCH_R8A7743
select SYSC_R8A7745 if ARCH_R8A7745
select SYSC_R8A7779 if ARCH_R8A7779
diff --git a/drivers/soc/renesas/rcar-rst.c b/drivers/soc/renesas/rcar-rst.c
index baa47014e96b..3316b028f231 100644
--- a/drivers/soc/renesas/rcar-rst.c
+++ b/drivers/soc/renesas/rcar-rst.c
@@ -41,6 +41,7 @@ static const struct of_device_id rcar_rst_matches[] 
__initconst = {
/* R-Car Gen3 is handled like R-Car Gen2 */
{ .compatible = "renesas,r8a7795-rst", .data = _rst_gen2 },
{ .compatible = "renesas,r8a7796-rst", .data = _rst_gen2 },
+   { .compatible = "renesas,r8a77970-rst", .data = _rst_gen2 },
{ .compatible = "renesas,r8a77995-rst", .data = _rst_gen2 },
{ /* sentinel */ }
 };
-- 
2.1.4



[PATCH 3/3] ARM: shmobile: rcar-gen2: Make sure CNTVOFF is initialized on CA7/15

2017-09-25 Thread Simon Horman
From: Geert Uytterhoeven 

On Cortex-A7, the arch timer CNTVOFF register is uninitialized.
Ideally it should be initialized by the boot loader, but it isn't.

For the boot CPU, CNTVOFF is initialized by Linux since commit
9ce3fa6816c2fb59 ("ARM: shmobile: rcar-gen2: Add CA7 arch_timer
initialization for r8a7794").
For secondary CPU cores, no such initialization is done.

Hence when enabling SMP on r8a7794, the kernel log is spammed with:

WARNING: Underflow in clocksource 'arch_sys_counter' observed, time update 
ignored.
 Please report this, consider using a different clocksource, if 
possible.
 Your kernel is probably still fine.

As Marc Zyngier pointed out that Cortex-A15 and Cortex-A7 are similar with
respect to CNTVOFF, we have been very lucky this just worked on R-Car
Gen2 SoCs with Cortex-A15 cores.

To fix this:
  - Move the existing inline asm code to initialize CNTVOFF to an
assembler source file (adding comments and replacing hardcoded
constants by definitions in the process), so it can be reused,
  - Perform the initialization of CNTVOFF on the boot CPU (Cortex-A15 or
Cortex-A7) on all R-Car Gen2 and RZ/G1 parts,
  - Wrap the standard secondary_startup() routine inside a routine which
initializes CNTVOFF.

Based on patches by Hisashi Nakamura in the BSP.

Signed-off-by: Geert Uytterhoeven 
Tested-by: Fabrizio Castro 
Signed-off-by: Simon Horman 
---
 arch/arm/mach-shmobile/Makefile  |  1 +
 arch/arm/mach-shmobile/common.h  |  2 ++
 arch/arm/mach-shmobile/headsmp-apmu.S| 37 
 arch/arm/mach-shmobile/platsmp-apmu.c|  2 +-
 arch/arm/mach-shmobile/setup-rcar-gen2.c | 20 ++---
 5 files changed, 43 insertions(+), 19 deletions(-)
 create mode 100644 arch/arm/mach-shmobile/headsmp-apmu.S

diff --git a/arch/arm/mach-shmobile/Makefile b/arch/arm/mach-shmobile/Makefile
index 64611a1b4276..32176a00c664 100644
--- a/arch/arm/mach-shmobile/Makefile
+++ b/arch/arm/mach-shmobile/Makefile
@@ -22,6 +22,7 @@ cpu-y := platsmp.o headsmp.o
 # Shared SoC family objects
 obj-$(CONFIG_ARCH_RCAR_GEN2)   += setup-rcar-gen2.o platsmp-apmu.o $(cpu-y)
 CFLAGS_setup-rcar-gen2.o   += -march=armv7-a
+obj-$(CONFIG_ARCH_RCAR_GEN2)   += headsmp-apmu.o
 obj-$(CONFIG_ARCH_R8A7790) += regulator-quirk-rcar-gen2.o
 obj-$(CONFIG_ARCH_R8A7791) += regulator-quirk-rcar-gen2.o
 obj-$(CONFIG_ARCH_R8A7793) += regulator-quirk-rcar-gen2.o
diff --git a/arch/arm/mach-shmobile/common.h b/arch/arm/mach-shmobile/common.h
index 1a8f7b3ab449..ea6e9e2be3f7 100644
--- a/arch/arm/mach-shmobile/common.h
+++ b/arch/arm/mach-shmobile/common.h
@@ -1,6 +1,7 @@
 #ifndef __ARCH_MACH_COMMON_H
 #define __ARCH_MACH_COMMON_H
 
+extern void shmobile_init_cntvoff(void);
 extern void shmobile_init_delay(void);
 extern void shmobile_boot_vector(void);
 extern unsigned long shmobile_boot_fn;
@@ -11,6 +12,7 @@ extern void shmobile_smp_hook(unsigned int cpu, unsigned long 
fn,
  unsigned long arg);
 extern bool shmobile_smp_cpu_can_disable(unsigned int cpu);
 extern bool shmobile_smp_init_fallback_ops(void);
+extern void shmobile_boot_apmu(void);
 extern void shmobile_boot_scu(void);
 extern void shmobile_smp_scu_prepare_cpus(phys_addr_t scu_base_phys,
  unsigned int max_cpus);
diff --git a/arch/arm/mach-shmobile/headsmp-apmu.S 
b/arch/arm/mach-shmobile/headsmp-apmu.S
new file mode 100644
index ..db4743d2bf91
--- /dev/null
+++ b/arch/arm/mach-shmobile/headsmp-apmu.S
@@ -0,0 +1,37 @@
+/*
+ * SMP support for APMU based systems with Cortex A7/A15
+ *
+ * Copyright (C) 2014  Renesas Electronics Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+#include 
+
+ENTRY(shmobile_init_cntvoff)
+   /*
+* CNTVOFF has to be initialized either from non-secure Hypervisor
+* mode or secure Monitor mode with SCR.NS==1. If TrustZone is enabled
+* then it should be handled by the secure code
+*/
+   cps #MON_MODE
+   mrc p15, 0, r1, c1, c1, 0   /* Get Secure Config */
+   orr r0, r1, #1
+   mcr p15, 0, r0, c1, c1, 0   /* Set Non Secure bit */
+   instr_sync
+   mov r0, #0
+   mcrrp15, 4, r0, r0, c14 /* CNTVOFF = 0 */
+   instr_sync
+   mcr p15, 0, r1, c1, c1, 0   /* Set Secure bit */
+   instr_sync
+   cps #SVC_MODE
+   ret lr
+ENDPROC(shmobile_init_cntvoff)
+
+ENTRY(shmobile_boot_apmu)
+   bl  shmobile_init_cntvoff
+   b   secondary_startup
+ENDPROC(shmobile_boot_apmu)
diff --git 

[GIT PULL] Renesas ARM Based SoC Defconfig Updates for v4.15

2017-09-25 Thread Simon Horman
Hi Olof, Hi Kevin, Hi Arnd,

Please consider these Renesas ARM based SoC defconfig updates for v4.15.


The following changes since commit 2bd6bf03f4c1c59381d62c61d03f6cc3fe71f66e:

  Linux 4.14-rc1 (2017-09-16 15:47:51 -0700)

are available in the git repository at:

  https://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas.git 
tags/renesas-defconfig-for-v4.15

for you to fetch changes up to 545dc83ed09b5c04f663b766a92cbc8bb02c5f15:

  ARM: multi_v7_defconfig: Enable BQ32000 RTC driver (2017-09-18 07:57:41 +0200)


Renesas ARM Based SoC Defconfig Updates for v4.15

Enable BQ32000 RTC driver in multi_v7_defconfig.

Biju Das says, "The iWave RZ/G1M Q7 SOM supports RTC (TI BQ32000).
To increase hardware support enable the driver in the
multi_v7_defconfig multiplatform configuration."


Biju Das (1):
  ARM: multi_v7_defconfig: Enable BQ32000 RTC driver

 arch/arm/configs/multi_v7_defconfig | 1 +
 1 file changed, 1 insertion(+)


[GIT PULL] Renesas ARM Based SoC Drivers Updates for v4.15

2017-09-25 Thread Simon Horman
Hi Olof, Hi Kevin, Hi Arnd,

Please consider these Renesas ARM based SoC drivers updates for v4.15.


The following changes since commit 2bd6bf03f4c1c59381d62c61d03f6cc3fe71f66e:

  Linux 4.14-rc1 (2017-09-16 15:47:51 -0700)

are available in the git repository at:

  https://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas.git 
tags/renesas-drivers-for-v4.15

for you to fetch changes up to bab9b2a74fe9da96e895e0919f625679a0a8c964:

  soc: renesas: rcar-sysc: add R8A77970 support (2017-09-18 09:46:50 +0200)


Renesas ARM Based SoC Drivers Updates for v4.15

Add basic support for R-Car V3M (R8A77970) SoC.

Sergei Shtylyov says:

* Add support for R-Car V3M (R8A77970) SoC power areas to the R-Car SYSC
  driver

* Add support for identifying the R-Car V3M (R8A77970) SoC

* Add support for R-Car V3M (R8A77970) to the R-Car RST driver -- this
  driver is  needed  for the clock driver to work


Sergei Shtylyov (3):
  soc: renesas: rcar-rst: add R8A77970 support
  soc: renesas: identify R-Car V3M
  soc: renesas: rcar-sysc: add R8A77970 support

 .../bindings/power/renesas,rcar-sysc.txt   |  1 +
 .../devicetree/bindings/reset/renesas,rst.txt  |  1 +
 drivers/soc/renesas/Kconfig|  8 -
 drivers/soc/renesas/Makefile   |  1 +
 drivers/soc/renesas/r8a77970-sysc.c| 39 ++
 drivers/soc/renesas/rcar-rst.c |  1 +
 drivers/soc/renesas/rcar-sysc.c|  3 ++
 drivers/soc/renesas/rcar-sysc.h|  1 +
 drivers/soc/renesas/renesas-soc.c  |  8 +
 9 files changed, 62 insertions(+), 1 deletion(-)
 create mode 100644 drivers/soc/renesas/r8a77970-sysc.c


[PATCH] arm64: dts: salvator-common: add 12V regulator to backlight

2017-09-25 Thread Simon Horman
From: Ulrich Hecht 

This fixes the warning "pwm-backlight backlight: backlight supply power
not found, using dummy regulator".

Fixes: b33be33670217533 ("arm64: dts: salvator-x: Add panel backlight support")
Reported-by: Geert Uytterhoeven 
Signed-off-by: Ulrich Hecht 
Reviewed-by: Laurent Pinchart 
Reviewed-by: Geert Uytterhoeven 
Signed-off-by: Simon Horman 
---
 arch/arm64/boot/dts/renesas/salvator-common.dtsi | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/arch/arm64/boot/dts/renesas/salvator-common.dtsi 
b/arch/arm64/boot/dts/renesas/salvator-common.dtsi
index 4786c67b5e65..d9d885006a8e 100644
--- a/arch/arm64/boot/dts/renesas/salvator-common.dtsi
+++ b/arch/arm64/boot/dts/renesas/salvator-common.dtsi
@@ -62,6 +62,7 @@
brightness-levels = <256 128 64 16 8 4 0>;
default-brightness-level = <6>;
 
+   power-supply = <_12v>;
enable-gpios = < 7 GPIO_ACTIVE_HIGH>;
};
 
@@ -83,6 +84,15 @@
regulator-always-on;
};
 
+   reg_12v: regulator2 {
+   compatible = "regulator-fixed";
+   regulator-name = "fixed-12V";
+   regulator-min-microvolt = <1200>;
+   regulator-max-microvolt = <1200>;
+   regulator-boot-on;
+   regulator-always-on;
+   };
+
rsnd_ak4613: sound {
compatible = "simple-audio-card";
 
-- 
2.1.4



[GIT PULL] Renesas ARM Based SoC Fixes for v4.14

2017-09-25 Thread Simon Horman
Hi Olof, Hi Kevin, Hi Arnd,

Please consider these Renesas ARM based SoC fixes for v4.14.


The following changes since commit 2bd6bf03f4c1c59381d62c61d03f6cc3fe71f66e:

  Linux 4.14-rc1 (2017-09-16 15:47:51 -0700)

are available in the git repository at:

  https://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas.git 
tags/renesas-fixes-for-v4.14

for you to fetch changes up to 829e4887b8676255778e162efc57e4a0f18f8bb3:

  arm64: dts: salvator-common: add 12V regulator to backlight (2017-09-21 
10:03:51 +0200)


Renesas ARM Based SoC Fixes for v4.14

Add 12V regulator to backlight allowing the power supply
for the backlight to be found.


Ulrich Hecht (1):
  arm64: dts: salvator-common: add 12V regulator to backlight

 arch/arm64/boot/dts/renesas/salvator-common.dtsi | 10 ++
 1 file changed, 10 insertions(+)


[PATCH] ARM: multi_v7_defconfig: Enable BQ32000 RTC driver

2017-09-25 Thread Simon Horman
From: Biju Das 

The iWave RZ/G1M Q7 SOM supports RTC (TI BQ32000).
To increase hardware support enable the driver in the
multi_v7_defconfig multiplatform configuration.

Signed-off-by: Biju Das 
Signed-off-by: Simon Horman 
---
 arch/arm/configs/multi_v7_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/configs/multi_v7_defconfig 
b/arch/arm/configs/multi_v7_defconfig
index 0cacdbf84a71..90f546766f38 100644
--- a/arch/arm/configs/multi_v7_defconfig
+++ b/arch/arm/configs/multi_v7_defconfig
@@ -767,6 +767,7 @@ CONFIG_RTC_DRV_MAX8997=m
 CONFIG_RTC_DRV_MAX77686=y
 CONFIG_RTC_DRV_RK808=m
 CONFIG_RTC_DRV_RS5C372=m
+CONFIG_RTC_DRV_BQ32K=m
 CONFIG_RTC_DRV_PALMAS=y
 CONFIG_RTC_DRV_ST_LPC=y
 CONFIG_RTC_DRV_TWL4030=y
-- 
2.1.4



RE: [PATCH v2] ARM: dts: iwg22d: Enable SDHI0 controller

2017-09-25 Thread Chris Paterson
Hello Simon,

> From: Simon Horman [mailto:ho...@verge.net.au]
> Sent: 25 September 2017 08:18
> 
> On Fri, Sep 22, 2017 at 01:33:39PM +, Fabrizio Castro wrote:
> > Hello Simon,
> >
> > just to clarify the changes between v1 and v2, we can't use SDR50 and
> SDR104 (due to an HW issue) therefore the pinctrl for UHS has been
> removed and we dropped property "sd-uhs-sdr104". High Speed has been
> tested, therefore if you are happy with the patch I guess you can update the
> following page accordingly:
> > http://elinux.org/index.php?title=Renesas-MMC-Enabled-
> Speeds=revi
> > sion=451426=451421
> >
> > Although (due to a bug) sdhi0 may not hold a reference to "vccq_sdhi0",
> the gpio regulator will initialize "SDHI0 VccQ" at 3.3V.
> > I have sent another patch (mmc: tmio: check mmc_regulator_get_supply
> return value) to start a discussion about a possible fix for the bug.
> >
> > Let me know if you need more information.
> 
> Thanks again for following up on this.
> 
> I have applied the patch with Geert's tag.

Thanks

> 
> I have also updated the Wiki at the URL above, feel free to make any further
> updates there as appropriate.

Thanks, looks okay to me.

Kind regards, Chris


Re: [PATCH] arm64: defconfig: enable R8A77970 SoC

2017-09-25 Thread Simon Horman
On Sat, Sep 23, 2017 at 01:05:25PM +0200, Geert Uytterhoeven wrote:
> On Fri, Sep 22, 2017 at 11:36 PM, Sergei Shtylyov
>  wrote:
> > Enable the Renesas R-Car V3M (R8A77970) SoC in the ARM64 defconfig.
> >
> > Suggested-by: Simon Horman 
> > Signed-off-by: Sergei Shtylyov 
> 
> Acked-by: Geert Uytterhoeven 

Thanks, applied.


Re: [PATCH v2] ARM: dts: iwg22d: Enable SDHI0 controller

2017-09-25 Thread Simon Horman
On Fri, Sep 22, 2017 at 01:33:39PM +, Fabrizio Castro wrote:
> Hello Simon,
> 
> just to clarify the changes between v1 and v2, we can't use SDR50 and SDR104 
> (due to an HW issue) therefore the pinctrl for UHS has been removed and we 
> dropped property "sd-uhs-sdr104". High Speed has been tested, therefore if 
> you are happy with the patch I guess you can update the following page 
> accordingly:
> http://elinux.org/index.php?title=Renesas-MMC-Enabled-Speeds=revision=451426=451421
> 
> Although (due to a bug) sdhi0 may not hold a reference to "vccq_sdhi0", the 
> gpio regulator will initialize "SDHI0 VccQ" at 3.3V.
> I have sent another patch (mmc: tmio: check mmc_regulator_get_supply return 
> value) to start a discussion about a possible fix for the bug.
> 
> Let me know if you need more information.

Thanks again for following up on this.

I have applied the patch with Geert's tag.

I have also updated the Wiki at the URL above,
feel free to make any further updates there as appropriate.


Re: [PATCH 1/2] arm64: dts: renesas: r8a7795: add USB3.0 peripheral device node

2017-09-25 Thread Simon Horman
On Thu, Sep 21, 2017 at 02:46:18PM +0200, Geert Uytterhoeven wrote:
> On Thu, Sep 21, 2017 at 7:31 AM, Yoshihiro Shimoda
>  wrote:
> > This patch adds USB3.0 peripheral channel 0 device node for r8a7795.
> >
> > Signed-off-by: Yoshihiro Shimoda 
> 
> Reviewed-by: Geert Uytterhoeven 

Thanks, applied.


Re: [PATCH 2/2] arm64: dts: renesas: r8a7796: add USB3.0 peripheral device node

2017-09-25 Thread Simon Horman
On Thu, Sep 21, 2017 at 02:46:37PM +0200, Geert Uytterhoeven wrote:
> On Thu, Sep 21, 2017 at 7:31 AM, Yoshihiro Shimoda
>  wrote:
> > This patch adds USB3.0 peripheral channel 0 device node for r8a7796.
> >
> > Signed-off-by: Yoshihiro Shimoda 
> 
> Reviewed-by: Geert Uytterhoeven 

Thanks, applied.


Re: [PATCH 2/2] arm64: dts: renesas: r8a77995: draak: enable EthernetAVB

2017-09-25 Thread Simon Horman
On Thu, Sep 21, 2017 at 10:37:15AM +, Yoshihiro Shimoda wrote:
> Hi Simon-san,
> 
> > From: Simon Horman
> > Sent: Friday, September 15, 2017 4:35 PM
> > 
> > On Wed, Sep 13, 2017 at 11:58:47PM +, Yoshihiro Shimoda wrote:
> > > Hi Geert-san,
> > >
> > > > From: Geert Uytterhoeven
> > > > Sent: Wednesday, September 13, 2017 11:55 PM
> > > >
> > > > Hi Shimoda-san,
> > > >
> > > > On Wed, Sep 13, 2017 at 2:18 PM, Yoshihiro Shimoda
> > > >  wrote:
> > > > > This patch enables EthernetAVB for R-Car D3 draak board.
> > > > >
> > > > > Signed-off-by: Yoshihiro Shimoda 
> > > >
> > > > Thanks for your patch!
> > > >
> > > > > --- a/arch/arm64/boot/dts/renesas/r8a77995-draak.dts
> > > > > +++ b/arch/arm64/boot/dts/renesas/r8a77995-draak.dts
> > > >
> > > > > @@ -37,6 +39,14 @@
> > > > >  };
> > > > >
> > > > >   {
> > > > > +   avb0_pins: avb {
> > > > > +   mux {
> > > > > +   groups = "avb0_link", "avb0_phy_int", 
> > > > > "avb0_mdc",
> > > > > +"avb0_mii";
> > > > > +   function = "avb0";
> > > >
> > > > This part depends on (an updated version of) "[PATCH 5/8] pinctrl: 
> > > > sh-pfc:
> > > > r8a77995: Add EthernetAVB pins, groups and functions", so it may change?
> > >
> > > Oops, I fotgot to submit v2 PFC patch yesterday...
> > > Yes, it is changed like other gen3 SoCs. I submitted it now.
> > >
> > > > And we will probably have to add driver-strengths later, to avoid a
> > > > dependency on bootloader setup?
> > >
> > > Yes, I will do so, if needed.
> > >
> > > > Apart from that:
> > > > Reviewed-by: Geert Uytterhoeven 
> > >
> > > Thank you for your review!
> > 
> > Thanks. I have marked this as "Deferred" pending acceptance of the PFC
> > patch. Please repost or ping me, f.e. via a reply-to-all to this email,
> > once that dependency is resolved.
> 
> Since the PFC patch is applied into renesas-drivers.git / sh-pfc-for-v4.15 
> branch,
> I'd like to ping you :)
> https://git.kernel.org/pub/scm/linux/kernel/git/geert/renesas-drivers.git/commit/?h=sh-pfc-for-v4.15=66abd968d0ef3eb10dea45b48a31321eb29258f8
> 
> Or, should I rebase this patch on latest devel tag?
> If so, I will rebase it in next Monday because I'll take a day off tomorrow.

Thanks for pinging me. I have applied this patch.
There was some fuzz when doing so. Please check that the applied
patch is correct once I have pushed an updated devel branch later today.


Re: [PATCH] ARM: shmobile: remove inconsistent ; from documentation

2017-09-25 Thread Simon Horman
On Thu, Sep 21, 2017 at 12:04:27PM +0200, Geert Uytterhoeven wrote:
> On Thu, Sep 21, 2017 at 11:44 AM, Simon Horman
>  wrote:
> > Consistently do not suffix compat string documentation with a ';'
> >
> > Signed-off-by: Simon Horman 
> 
> Acked-by: Geert Uytterhoeven 

Thanks, applied.


Re: [PATCH 4/4] arm64: dts: renesas: r8a77995: draak: enable USB2.0 Host (EHCI/OHCI)

2017-09-25 Thread Simon Horman
On Thu, Sep 21, 2017 at 11:12:12AM +0200, Geert Uytterhoeven wrote:
> On Thu, Sep 21, 2017 at 10:58 AM, Simon Horman  wrote:
> > [CC Geert]
> >
> > On Thu, Sep 14, 2017 at 07:30:43PM +0900, Yoshihiro Shimoda wrote:
> >> This patch enables USB2.0 Host (EHCI/OHCI) for r8a77995.
> >>
> >> Signed-off-by: Yoshihiro Shimoda 
> >
> > Hi Geert,
> >
> > thanks for reviewing patches 1-3 of this series.
> > I think you missed this one.
> 
> Oops, this time with Reply-to-all:
> Reviewed-by: Geert Uytterhoeven 

Thanks, applied.