devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@collabora.com>
To: Philipp Zabel <p.zabel@pengutronix.de>
Cc: linux-media@vger.kernel.org,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Hans Verkuil <hverkuil@xs4all.nl>,
	Ezequiel Garcia <ezequiel@collabora.com>,
	Nicolas Dufresne <nicolas@ndufresne.ca>,
	Jonas Karlman <jonas@kwiboo.se>,
	devicetree@vger.kernel.org, kernel@pengutronix.de
Subject: Re: [PATCH v3 05/10] media: hantro: add support for named register ranges
Date: Sat, 1 Jun 2019 11:14:01 +0200	[thread overview]
Message-ID: <20190601111401.540166d0@collabora.com> (raw)
In-Reply-To: <20190531085523.10892-6-p.zabel@pengutronix.de>

On Fri, 31 May 2019 10:55:18 +0200
Philipp Zabel <p.zabel@pengutronix.de> wrote:

> Add support for multiple register ranges with SoC specific names.
> 
> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
> ---
> Changes since v2 [1]:
>  - Move array of reg_names out of struct hantro_variant
>  - Use ARRAY_SIZE to set num_regs
>  - Dynamically allocate base address array in struct hantro_dev and
>    rename it to bases
>  - More concise IORESOURCE_MEM setup in hantro_probe
> 
> [1] https://patchwork.linuxtv.org/patch/56424/
> ---
>  drivers/staging/media/hantro/hantro.h     |  8 ++++++--
>  drivers/staging/media/hantro/hantro_drv.c | 24 +++++++++++++++++------
>  2 files changed, 24 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/staging/media/hantro/hantro.h b/drivers/staging/media/hantro/hantro.h
> index d041d36a0805..feaa439a17b3 100644
> --- a/drivers/staging/media/hantro/hantro.h
> +++ b/drivers/staging/media/hantro/hantro.h
> @@ -72,6 +72,8 @@ struct hantro_irq {
>   * @num_irqs:			number of irqs in the array
>   * @clk_names:			array of clock names
>   * @num_clocks:			number of clocks in the array
> + * @reg_names:			array of register range names
> + * @num_regs:			number of register range names in the array
>   */
>  struct hantro_variant {
>  	unsigned int enc_offset;
> @@ -88,6 +90,8 @@ struct hantro_variant {
>  	int num_irqs;
>  	const char *clk_names[HANTRO_MAX_CLOCKS];
>  	int num_clocks;
> +	const char * const *reg_names;
> +	int num_regs;
>  };
>  
>  /**
> @@ -160,7 +164,7 @@ hantro_vdev_to_func(struct video_device *vdev)
>   * @dev:		Pointer to device for convenient logging using
>   *			dev_ macros.
>   * @clocks:		Array of clock handles.
> - * @base:		Mapped address of VPU registers.
> + * @bases:		Mapped addresses of VPU registers.

I find the name 'bases' a bit too generic, maybe 'reg_bases'.
The rest of the patch LGTM

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>

>   * @enc_base:		Mapped address of VPU encoder register for convenience.
>   * @dec_base:		Mapped address of VPU decoder register for convenience.
>   * @vpu_mutex:		Mutex to synchronize V4L2 calls.
> @@ -178,7 +182,7 @@ struct hantro_dev {
>  	struct platform_device *pdev;
>  	struct device *dev;
>  	struct clk_bulk_data clocks[HANTRO_MAX_CLOCKS];
> -	void __iomem *base;
> +	void __iomem **bases;
>  	void __iomem *enc_base;
>  	void __iomem *dec_base;
>  
> diff --git a/drivers/staging/media/hantro/hantro_drv.c b/drivers/staging/media/hantro/hantro_drv.c
> index e49bb03a988e..1f756e06dfc6 100644
> --- a/drivers/staging/media/hantro/hantro_drv.c
> +++ b/drivers/staging/media/hantro/hantro_drv.c
> @@ -669,6 +669,7 @@ static int hantro_probe(struct platform_device *pdev)
>  	const struct of_device_id *match;
>  	struct hantro_dev *vpu;
>  	struct resource *res;
> +	int num_bases;
>  	int i, ret;
>  
>  	vpu = devm_kzalloc(&pdev->dev, sizeof(*vpu), GFP_KERNEL);
> @@ -692,12 +693,23 @@ static int hantro_probe(struct platform_device *pdev)
>  	if (ret)
>  		return ret;
>  
> -	res = platform_get_resource(vpu->pdev, IORESOURCE_MEM, 0);
> -	vpu->base = devm_ioremap_resource(vpu->dev, res);
> -	if (IS_ERR(vpu->base))
> -		return PTR_ERR(vpu->base);
> -	vpu->enc_base = vpu->base + vpu->variant->enc_offset;
> -	vpu->dec_base = vpu->base + vpu->variant->dec_offset;
> +	num_bases = vpu->variant->num_regs ?: 1;
> +	vpu->bases = devm_kcalloc(&pdev->dev, num_bases, sizeof(*vpu->bases),
> +				  GFP_KERNEL);
> +	if (!vpu->bases)
> +		return -ENOMEM;
> +
> +	for (i = 0; i < num_bases; i++) {
> +		res = vpu->variant->reg_names ?
> +		      platform_get_resource_byname(vpu->pdev, IORESOURCE_MEM,
> +						   vpu->variant->reg_names[i]) :
> +		      platform_get_resource(vpu->pdev, IORESOURCE_MEM, 0);
> +		vpu->bases[i] = devm_ioremap_resource(vpu->dev, res);
> +		if (IS_ERR(vpu->bases[i]))
> +			return PTR_ERR(vpu->bases[i]);
> +	}
> +	vpu->enc_base = vpu->bases[0] + vpu->variant->enc_offset;
> +	vpu->dec_base = vpu->bases[0] + vpu->variant->dec_offset;
>  
>  	ret = dma_set_coherent_mask(vpu->dev, DMA_BIT_MASK(32));
>  	if (ret) {

  reply	other threads:[~2019-06-01  9:14 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-31  8:55 [PATCH v3 00/10] Rename Rockchip VPU driver to Hantro, add initial i.MX8M support Philipp Zabel
2019-05-31  8:55 ` [PATCH v3 01/10] rockchip/vpu: rename from rockchip to hantro Philipp Zabel
2019-06-05 11:22   ` Boris Brezillon
2019-06-06 15:06     ` Boris Brezillon
2019-06-11 11:51       ` Philipp Zabel
2019-05-31  8:55 ` [PATCH v3 02/10] media: hantro: print video device name in addition to device node Philipp Zabel
2019-05-31  8:55 ` [PATCH v3 03/10] media: hantro: add PM runtime resume callback Philipp Zabel
2019-05-31  8:55 ` [PATCH v3 04/10] media: hantro: make irq names configurable Philipp Zabel
2019-06-01  9:07   ` Boris Brezillon
2019-05-31  8:55 ` [PATCH v3 05/10] media: hantro: add support for named register ranges Philipp Zabel
2019-06-01  9:14   ` Boris Brezillon [this message]
2019-05-31  8:55 ` [PATCH v3 06/10] media: hantro: add support for separate control block Philipp Zabel
2019-06-01  9:16   ` Boris Brezillon
2019-05-31  8:55 ` [PATCH v3 07/10] media: dt-bindings: Document i.MX8MQ and i.MX8MM VPU bindings Philipp Zabel
2019-06-01  9:18   ` Boris Brezillon
2019-06-11 12:44     ` Philipp Zabel
2019-05-31  8:55 ` [PATCH v3 08/10] media: hantro: add initial i.MX8MQ support Philipp Zabel
2019-06-03 12:45   ` Hans Verkuil
2019-06-03 20:02     ` Boris Brezillon
2019-06-04 10:42       ` Hans Verkuil
2019-06-11 11:55         ` Philipp Zabel
2019-12-01  2:16           ` Adam Ford
2019-05-31  8:55 ` [PATCH v3 09/10] media: hantro: add initial i.MX8MM support (untested) Philipp Zabel
2019-06-03 12:54   ` Hans Verkuil
2019-06-03 18:59     ` Nicolas Dufresne
2019-06-03 18:59       ` Nicolas Dufresne
2019-06-11 11:52     ` Philipp Zabel
2019-05-31  8:55 ` [PATCH v3 10/10] media: hantro: allow arbitrary number of clocks Philipp Zabel
2019-06-01  9:23   ` Boris Brezillon
2019-06-03 12:40   ` Hans Verkuil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190601111401.540166d0@collabora.com \
    --to=boris.brezillon@collabora.com \
    --cc=devicetree@vger.kernel.org \
    --cc=ezequiel@collabora.com \
    --cc=hverkuil@xs4all.nl \
    --cc=jonas@kwiboo.se \
    --cc=kernel@pengutronix.de \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=nicolas@ndufresne.ca \
    --cc=p.zabel@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).