From patchwork Fri Jun 2 21:34:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 9763549 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D4B166038E for ; Fri, 2 Jun 2017 21:36:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C6C08285D8 for ; Fri, 2 Jun 2017 21:36:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BB802285DC; Fri, 2 Jun 2017 21:36:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 32FC5285D8 for ; Fri, 2 Jun 2017 21:36:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=CNsQ52xEzP0BV47TQO3oQ+w98fndoC2Rb7WolGZkKhM=; b=ZGnf3hs+wvSOgh qW9KlMkT8v/WrAMHGdZcqqRAo/rm2JbRRuHfC7HjeInP/e01HR+TQY1QrJspjJc7IwFWNH3CsRsIp fqpqDtq5/LFSHaJU+09fOgGHOnFHzTAWSDXk2xASuUuQQ6tp32QL5B4UhF2g1Sfy4dQzWnjtfiVxa sa+avd31WaEJMRUzH88VfEjvX4COfdn57XnWY1mRR1Xl/nO+xYSywwlYduPBcd1g95AxlMKv6g1Ev O4ui7eGgoCwnG4Rp5nGPqu/0yE/bxgoDidNOftAPqVD5ZqqnG01upTNIHqeqcf1qKM5oQRRGVHLYc NoqST1Pax/xvOu2bA6ag==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dGuEg-0000ad-IX; Fri, 02 Jun 2017 21:35:58 +0000 Received: from mail-pg0-x233.google.com ([2607:f8b0:400e:c05::233]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dGuE8-0006vu-3G for linux-arm-kernel@lists.infradead.org; Fri, 02 Jun 2017 21:35:28 +0000 Received: by mail-pg0-x233.google.com with SMTP id x64so12324620pgd.3 for ; Fri, 02 Jun 2017 14:35:03 -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=Gjm4r0qpM1s/adF3agX1z7pZXlUKourDzaoz/tftv04r7L/+Vp+oexUBTs9JcUCEzD Sjm216FSnUKxUEG9oG10w1zufisQmC2tfhRs8lQ8J+yGqiVqB9iMriPx1P7+bqD5AoVQ h852PrwXMKWqFMc7/22c1IFgecSFUP0fJLoHkBlYTXxJr2OP2kIwOP9HioBfBIrutd/n moN2GHD24XIiBqT5ZeDptwopuVbEAQHqHlMYBVbSQ4UZh9iz2D4+BWjkbFACmqDnP8cZ Nn2nOg/rsz9wInD+zAyIKHUtfvjo0OB/x2sN+q0Ig+rhn3Guy1XgnVRbl1hTQVSFY0Eg 4Wxw== 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=cHXLH5RIXNsWJrIruzl4pWkKxmZorfe5RNV6EPLmJyccF3Qf3Tn6TIqLlbF1wUEkh1 SB4Df2LTNOkRQ2UKPQ8u6O6+2/tl9OReFdr9NgDxdCDFjDMs73wThBh9vA8SIYcJsyye qKlgW4pPaDu4q7vTTv8f7WVj35Dg6EYOvtjDI9i+IE8h5DuTl8Jsl8spK1VXx6zB4LdK v4WvWeawJZn1Y7PihCKzVspOCkIZKihc3QBvaq0IrsWTFe63AK7lZMrjU50RdDW42V5r gHH8UFyFuIRpxcyZ5kdojBbbGfwZktWAjqtezBTP1xYAze7CuimWet7ZNBeEyiyFgH1N a0DQ== X-Gm-Message-State: AODbwcAT5g7I/gjC00XRzP0cjk9C8K161hfxyMw/xdxpkm/nf4AujCfj 2GO0iICSmWZ3/+bW X-Received: by 10.99.143.90 with SMTP id r26mr9122326pgn.102.1496439303142; Fri, 02 Jun 2017 14:35:03 -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 l63sm43864639pfb.68.2017.06.02.14.35.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Jun 2017 14:35:02 -0700 (PDT) From: Kevin Hilman To: Hans Verkuil , Laurent Pinchart , linux-media@vger.kernel.org Subject: [PATCH 4/4] [media] davinci: vpif: adaptions for DT support Date: Fri, 2 Jun 2017 14:34:31 -0700 Message-Id: <20170602213431.10777-5-khilman@baylibre.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170602213431.10777-1-khilman@baylibre.com> References: <20170602213431.10777-1-khilman@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170602_143524_902199_C4255A79 X-CRM114-Status: GOOD ( 14.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sekhar Nori , linux-arm-kernel@lists.infradead.org, Patrick Titiano Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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; }