linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: mchehab@s-opensource.com (Mauro Carvalho Chehab)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 4/4] [media] davinci: vpif: adaptions for DT support
Date: Wed, 7 Jun 2017 12:28:34 -0300	[thread overview]
Message-ID: <20170607122834.4fcb92f4@vento.lan> (raw)
In-Reply-To: <20170606233741.26718-5-khilman@baylibre.com>

Em Tue,  6 Jun 2017 16:37:41 -0700
Kevin Hilman <khilman@baylibre.com> escreveu:

> The davinci VPIF is a single hardware block, but the existing driver
> is broken up into a common library (vpif.c), output (vpif_display.c) and
> intput (vpif_capture.c).
> 
> When migrating to DT, to better model the hardware, and because
> registers, interrupts, etc. are all common,it was decided to
> have a single VPIF hardware node[1].
> 
> Because davinci uses legacy, non-DT boot on several SoCs still, the
> platform_drivers need to remain.  But they are also needed in DT boot.
> Since there are no DT nodes for the display/capture parts in DT
> boot (there is a single node for the parent/common device) we need to
> create platform_devices somewhere to instansiate the platform_drivers.
> 
> When VPIF display/capture are needed for a DT boot, the VPIF node
> will have endpoints defined for its subdevs.  Therefore, vpif_probe()
> checks for the presence of endpoints, and if detected manually creates
> the platform_devices for the display and capture platform_drivers.
> 
> [1] Documentation/devicetree/bindings/media/ti,da850-vpif.txt
> 
> Signed-off-by: Kevin Hilman <khilman@baylibre.com>
> ---
>  drivers/media/platform/davinci/vpif.c | 49 ++++++++++++++++++++++++++++++++++-
>  1 file changed, 48 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/davinci/vpif.c b/drivers/media/platform/davinci/vpif.c
> index 1b02a6363f77..502917abcb13 100644
> --- a/drivers/media/platform/davinci/vpif.c
> +++ b/drivers/media/platform/davinci/vpif.c
> @@ -26,6 +26,7 @@
>  #include <linux/pm_runtime.h>
>  #include <linux/spinlock.h>
>  #include <linux/v4l2-dv-timings.h>
> +#include <linux/of_graph.h>
>  
>  #include "vpif.h"
>  
> @@ -423,7 +424,9 @@ EXPORT_SYMBOL(vpif_channel_getfid);
>  
>  static int vpif_probe(struct platform_device *pdev)
>  {
> -	static struct resource	*res;
> +	static struct resource	*res, *res_irq;
> +	struct platform_device *pdev_capture, *pdev_display;
> +	struct device_node *endpoint = NULL;
>  
>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  	vpif_base = devm_ioremap_resource(&pdev->dev, res);
> @@ -435,6 +438,50 @@ static int vpif_probe(struct platform_device *pdev)
>  
>  	spin_lock_init(&vpif_lock);
>  	dev_info(&pdev->dev, "vpif probe success\n");
> +
> +	/*
> +	 * If VPIF Node has endpoints, assume "new" DT support,
> +	 * where capture and display drivers don't have DT nodes
> +	 * so their devices need to be registered manually here
> +	 * for their legacy platform_drivers to work.
> +	 */
> +	endpoint = of_graph_get_next_endpoint(pdev->dev.of_node,
> +					      endpoint);
> +	if (!endpoint) 
> +		return 0;
> +
> +	/*
> +	 * For DT platforms, manually create platform_devices for
> +	 * capture/display drivers.
> +	 */
> +	res_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
> +	if (!res_irq) {
> +		dev_warn(&pdev->dev, "Missing IRQ resource.\n");
> +		return -EINVAL;
> +	}
> +
> +	pdev_capture = devm_kzalloc(&pdev->dev, sizeof(*pdev_capture),
> +				    GFP_KERNEL);

You need to check if it won't return NULL here...

> +	pdev_capture->name = "vpif_capture";
> +	pdev_capture->id = -1;
> +	pdev_capture->resource = res_irq;
> +	pdev_capture->num_resources = 1;
> +	pdev_capture->dev.dma_mask = pdev->dev.dma_mask;
> +	pdev_capture->dev.coherent_dma_mask = pdev->dev.coherent_dma_mask;
> +	pdev_capture->dev.parent = &pdev->dev;
> +	platform_device_register(pdev_capture);
> +
> +	pdev_display = devm_kzalloc(&pdev->dev, sizeof(*pdev_display),
> +				    GFP_KERNEL);

and here.

Ok, in thesis, if size is lower than page size, it shouldn't fail,
but we still want to have an explicit check[1].

[1] https://lwn.net/Articles/723317/

Thanks,
Mauro

      reply	other threads:[~2017-06-07 15:28 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-06 23:37 [PATCH v2 0/4] [media] davinci: vpif_capture: raw camera support Kevin Hilman
2017-06-06 23:37 ` [PATCH v2 1/4] [media] davinci: vpif_capture: drop compliance hack Kevin Hilman
2017-06-06 23:37 ` [PATCH v2 2/4] [media] davinci: vpif_capture: get subdevs from DT when available Kevin Hilman
2017-06-08  6:29   ` Hans Verkuil
2017-06-09  1:01     ` Kevin Hilman
2017-06-09  7:12       ` Lad, Prabhakar
2017-06-09 10:27       ` Sakari Ailus
2017-06-06 23:37 ` [PATCH v2 3/4] [media] davinci: vpif_capture: cleanup raw camera support Kevin Hilman
2017-06-06 23:37 ` [PATCH v2 4/4] [media] davinci: vpif: adaptions for DT support Kevin Hilman
2017-06-07 15:28   ` Mauro Carvalho Chehab [this message]

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=20170607122834.4fcb92f4@vento.lan \
    --to=mchehab@s-opensource.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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).