From patchwork Tue Jun 6 23:37:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 41662 X-Patchwork-Delegate: hverkuil@xs4all.nl Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dIO2v-0002fF-TG; Tue, 06 Jun 2017 23:37:57 +0000 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.89/mailfrontend-7) with esmtp id 1dIO2t-0005ME-1O; Wed, 07 Jun 2017 01:37:57 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751485AbdFFXhv (ORCPT + 1 other); Tue, 6 Jun 2017 19:37:51 -0400 Received: from mail-pg0-f52.google.com ([74.125.83.52]:33425 "EHLO mail-pg0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751474AbdFFXhs (ORCPT ); Tue, 6 Jun 2017 19:37:48 -0400 Received: by mail-pg0-f52.google.com with SMTP id f185so39433655pgc.0 for ; Tue, 06 Jun 2017 16:37:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Mllk+o7RqQw4d051/sVdnJ4AWVmjsBq4k1zGeft0c4U=; b=AFiWupf9flAF2Ul/Mj52T6GLqmRAk1P0pO0rDNHS/HvXjSU7ZECItzfhzKLnA2A0j0 OXXCuv3wFivv8SklPDtlZqveHJMEsOtwuAMGOy+HrwaftQxjCKcEehq5Ntmvojy03Bj1 jHRvW3DWZeDikQTXFpD29thJ+uGs+nSOYEywkuurZnmwCMUEyz1mULuf9XjtRRHB4pC8 q6C6J4cKPHVE4I7xibUcjqbWmPHrPVDLOLxNRLJPMIs1zwqCdlg4dMQl+xn0we3vavBz upnok+A++hp7Zg/3oj+OXGKI2dely/nqH9u4BS9HcLM0bqrUxIA67bSE3AJjhwUbtx0f R9Lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Mllk+o7RqQw4d051/sVdnJ4AWVmjsBq4k1zGeft0c4U=; b=Dj5bczz0eX4Xtd03SotLtfsxC7ADoRzd52yGJ6cteLBvO/7X1cx+SdY2b7qtqkjOmk UQfHRyYXNuwY+3xD2nfnN63lqe0bJnSSSBocoQ5MoVXOsuVHyYPoLzRID0k/dZpIANv3 obH+N2/J3H1R5vdpNDMnfR5v5xf1sYi3SM9m5Q0V4McRGhZtXU8qdG0ifvx28UN700b4 /ycOq1LqLmy0RwBIkHqjTj6llccJInBaG+IQwH5bRb5jbkgTBxCm7a3GyOcSKJlvf4An 3PAdUiBgzowBiCG1Uv7hvanCsR2MWLvKYG48hmYvRh6/SnX7+YsLB8DylOMPjXiMJHMq VnrA== X-Gm-Message-State: AODbwcAcUA5tRaupjsuDzEwyZo7E40pAt3ckYSS1z5qmODPXr7m4Qsdq ZbSqXBbDD7CD+Wx3 X-Received: by 10.101.89.66 with SMTP id g2mr14759027pgu.146.1496792267387; Tue, 06 Jun 2017 16:37:47 -0700 (PDT) Received: from localhost (c-98-203-232-209.hsd1.wa.comcast.net. [98.203.232.209]) by smtp.gmail.com with ESMTPSA id 65sm52421855pgf.14.2017.06.06.16.37.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Jun 2017 16:37:46 -0700 (PDT) From: Kevin Hilman To: Hans Verkuil , Laurent Pinchart , linux-media@vger.kernel.org Cc: Sekhar Nori , David Lechner , Patrick Titiano , Benoit Parrot , Prabhakar Lad , linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 4/4] [media] davinci: vpif: adaptions for DT support Date: Tue, 6 Jun 2017 16:37:41 -0700 Message-Id: <20170606233741.26718-5-khilman@baylibre.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170606233741.26718-1-khilman@baylibre.com> References: <20170606233741.26718-1-khilman@baylibre.com> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 6.0.0.2142326, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2017.6.6.233317 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, BODY_SIZE_3000_3999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, DATE_TZ_NA 0, DKIM_SIGNATURE 0, IN_REP_TO 0, LEGITIMATE_SIGNS 0, MSG_THREAD 0, MULTIPLE_REAL_RCPTS 0, NO_URI_HTTPS 0, REFERENCES 0, __ANY_URI 0, __CC_NAME 0, __CC_NAME_DIFF_FROM_ACC 0, __CC_REAL_NAMES 0, __CTE 0, __FROM_DOMAIN_IN_ANY_CC2 0, __FROM_DOMAIN_IN_RCPT 0, __HAS_CC_HDR 0, __HAS_FROM 0, __HAS_LIST_ID 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HAS_X_MAILING_LIST 0, __IN_REP_TO 0, __MIME_TEXT_ONLY 0, __MIME_TEXT_P 0, __MIME_TEXT_P1 0, __MIME_VERSION 0, __MULTIPLE_RCPTS_CC_X2 0, __NO_HTML_TAG_RAW 0, __REFERENCES 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __TO_MALFORMED_2 0, __TO_NAME 0, __TO_NAME_DIFF_FROM_ACC 0, __TO_REAL_NAMES 0, __URI_NO_WWW 0, __URI_NS , __YOUTUBE_RCVD 0' 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 --- 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 #include #include +#include #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); + 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); + pdev_display->name = "vpif_display"; + pdev_display->id = -1; + pdev_display->resource = res_irq; + pdev_display->num_resources = 1; + pdev_display->dev.dma_mask = pdev->dev.dma_mask; + pdev_display->dev.coherent_dma_mask = pdev->dev.coherent_dma_mask; + pdev_display->dev.parent = &pdev->dev; + platform_device_register(pdev_display); + return 0; }