From patchwork Fri Jun 9 16:10:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 9778899 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 3ABE260393 for ; Fri, 9 Jun 2017 16:10:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 275102863C for ; Fri, 9 Jun 2017 16:10:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1C4532863F; Fri, 9 Jun 2017 16:10:59 +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 8C1EF2863C for ; Fri, 9 Jun 2017 16:10:58 +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: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:In-Reply-To:References: List-Owner; bh=9zaLq9qzWIlEelU5srlaZ29E8KUk71CFUOVnJixnvhM=; b=jHrQXkFQq674AI u324+JR4VTcrud4H70hLcyUF+PEctBNQYtG7GuRHF+vaUIlBEs7Qo5DQWKyiKZ+LglWscJfZoHlTm YTwtYbXigmSQs/E1ypBzgZjmMDlFy7GdRMbHZPj42WKS2VkCLFv+hXs4jSII33XDFL8ajBmMlwysW xvzsavPQXBWdZvxc4f5j8zGefnvqU1q3XkmzGi2kGk/IoQtZjGYjLhpUqEk4zfdSlEd3TGsVJNOrD RlUiWd0mB9Rg95ZzoWmXiKECyt2D9TdUYjcLb0ED63jN3xD2QvbMbu3PFgukfVqOCWlMwCDMz8C5Z 1rT116yw/zSR9B4T8Gtg==; 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 1dJMUz-0006Sk-Gv; Fri, 09 Jun 2017 16:10:57 +0000 Received: from mail-pg0-x22a.google.com ([2607:f8b0:400e:c05::22a]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dJMUv-0006D5-El for linux-arm-kernel@lists.infradead.org; Fri, 09 Jun 2017 16:10:55 +0000 Received: by mail-pg0-x22a.google.com with SMTP id v18so27977413pgb.1 for ; Fri, 09 Jun 2017 09:10:33 -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:mime-version :content-transfer-encoding; bh=IY6AT+WRY7UkQyJf1tVZvx2hLc7uzzrcCpRW7QP/EzA=; b=1gj/EJgGB9yRYqHEA0L/N8EShTAodjWY+dzgFIQxsWzqHcjzfD9AsPsqYLpPbKLYEy QghrxOGCk+pj8gk5JglowFp68niksfedXgCZRdd1a6R1MDahK98UHe9zEzv84/I7Ussl qnm8hBVaCsp4UxoP1JH4R8xeaoo9pdcfir9Hq0Op+cA7Zoi39GoDRcrPhWUGiKS6OkJR vt3tcS8DAtakVU3k/TFTiQDWUt7I9Bu+23LvLj1osFSSsojsaMl5aF75uLuhbZub0WEY hus1EOED64taF5CqWq9coOvhM4Iesup/gay7VrP2LsAd3a4s+BPPGMtFS2TFV2M8xlRW tudA== 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:mime-version :content-transfer-encoding; bh=IY6AT+WRY7UkQyJf1tVZvx2hLc7uzzrcCpRW7QP/EzA=; b=tUExj8+/30ED29gq+t2vL82RUByW0jTmFemZXl1CviUIDvRsUMJdnEQ3YdEJIPZegO U80t14UrXUxfkZCWEKpIOGdr95xXa89S1qr38JYzjJD+80gouwYNPKcORsqKIiE8WZ5n qV5opPo0mn8U1mQNUr4hOAzBSpgHjWJ/xz1yJX3isXh9lff4IM68+QTZw1yssxESZwNj VhqyqcOgedYFqa3LqWmaKj5MtmFWNTC9OQ24lXtBhXrq/9S7MY3eN0eyyXQ4WR+6xQ+s YT1I7SbniERjx69yAOskZNtQY2lzDBW0hMhIfp4gfjeihkhXN6uWVOzBW++sHTMRH6zI lvHw== X-Gm-Message-State: AODbwcCBFpgr8fkgAsaRe90ZVdQS0OXsMZOSaaaGrezRnNRQQPbUKO1T ovS9y0AdS9HvaY0h X-Received: by 10.99.99.134 with SMTP id x128mr4898996pgb.81.1497024632535; Fri, 09 Jun 2017 09:10:32 -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 u85sm4239622pfg.73.2017.06.09.09.10.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Jun 2017 09:10:32 -0700 (PDT) From: Kevin Hilman To: Mauro Carvalho Chehab , Hans Verkuil , linux-media@vger.kernel.org Subject: [PATCH v2] [media] davinci: vpif: adaptions for DT support Date: Fri, 9 Jun 2017 09:10:26 -0700 Message-Id: <20170609161026.7582-1-khilman@baylibre.com> X-Mailer: git-send-email 2.9.3 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170609_091053_570006_F14FA75E X-CRM114-Status: GOOD ( 15.80 ) 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: David Lechner , Sekhar Nori , Benoit Parrot , Prabhakar Lad , Patrick Titiano , linux-arm-kernel@lists.infradead.org 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 Reviewed-by: Sylwester Nawrocki Acked-by: Lad, Prabhakar --- Changes since v1: - added proper error checking to kzalloc calls - rebased onto media/master drivers/media/platform/davinci/vpif.c | 57 ++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/davinci/vpif.c b/drivers/media/platform/davinci/vpif.c index 1b02a6363f77..c2d214dfaa3e 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,58 @@ 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); + if (pdev_capture) { + 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); + } else { + dev_warn(&pdev->dev, "Unable to allocate memory for pdev_capture.\n"); + } + + pdev_display = devm_kzalloc(&pdev->dev, sizeof(*pdev_display), + GFP_KERNEL); + if (pdev_display) { + 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); + } else { + dev_warn(&pdev->dev, "Unable to allocate memory for pdev_display.\n"); + } + return 0; }