From patchwork Tue Nov 29 23:57:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 9453255 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 F0ED56071C for ; Tue, 29 Nov 2016 23:59:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E35982835B for ; Tue, 29 Nov 2016 23:59:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D7F302848D; Tue, 29 Nov 2016 23:59:53 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DE1492835B for ; Tue, 29 Nov 2016 23:59:51 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cBsHy-0002fU-88; Tue, 29 Nov 2016 23:58:18 +0000 Received: from mail-pg0-x229.google.com ([2607:f8b0:400e:c05::229]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cBsHM-0002Im-0Q for linux-arm-kernel@lists.infradead.org; Tue, 29 Nov 2016 23:57:42 +0000 Received: by mail-pg0-x229.google.com with SMTP id p66so74806818pga.2 for ; Tue, 29 Nov 2016 15:57:16 -0800 (PST) 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=r+XuXD9Fy4zu2QdahMoTf8mQANqA4rvDqfn3qu6NoAA=; b=K7YfddR2xcsqGgiIbBG3yY0rPf4yJfpBdReI1aTsHD/Ckoha7Al8fII9tDr4r1eiqO s9oulDAJ97XPxhWTLOMV+akK6Kl7ALxHf8jQ7qYBNt/BUMpHQQaI2ED9MetgAglZx7Rg ASCByPcZAxwaAgbNR+wOP7xBsKF52LnB9uEosCb3zT42xqyQHH1/Y3GdA5i7EqyjBNpG xLYnwHlQk53VSUjCz+CWMhIAMoc7xcYbHhzTwGkLxNDHOTq+idwNzLWG69rCDqhRvddZ LrNyjBwFniJoRQU5Lq8IpOQ4PebGwssORioClIEwF6bLo/UCY4WAzU8+fvM06nJiLPBl W69w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=r+XuXD9Fy4zu2QdahMoTf8mQANqA4rvDqfn3qu6NoAA=; b=cGwYgb1Q7olxiNclp+KjzpkI4MmUmnrZfLOqN95bjugD2pZxmQ5/MYe5om112w4D61 4smTZKjLiRJmU9gMEYJ1pgof7ctcluI/4NOxd42Eti10l8uE3Wvmei2rXJw62xgLMXqM PQQkEeZonmEZN8zmoFCJQ98HI5t9qchDaMZm3rtskxrX8uQcsiZ6gsZdgjuKd4Q3YC9y if2pZioOlJKc/0LLjm2AZ07rXFZdpbnt/Sl+PuZ5ArHSjjZaekQMbk9g8ljVktHPbtz5 iAQVvMjlvLhNyowoF1d5y9ooUntfOn7f4VHN9CyJD4xo6k7qJ7paIbp3tZ7Tst9tn9NE X47A== X-Gm-Message-State: AKaTC03xyd2aQ/6FcAVk8jBNNddrXvhGfpaUIekGlwoKt1qHvTIHh/20ftDQbcnsOJ4EBZzh X-Received: by 10.98.192.148 with SMTP id g20mr30293531pfk.36.1480463836477; Tue, 29 Nov 2016 15:57:16 -0800 (PST) Received: from localhost (c-98-203-232-209.hsd1.wa.comcast.net. [98.203.232.209]) by smtp.gmail.com with ESMTPSA id k25sm43031250pfg.84.2016.11.29.15.57.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Nov 2016 15:57:16 -0800 (PST) From: Kevin Hilman To: linux-media@vger.kernel.org Subject: [PATCH v4 2/4] [media] davinci: VPIF: add basic support for DT init Date: Tue, 29 Nov 2016 15:57:10 -0800 Message-Id: <20161129235712.29846-3-khilman@baylibre.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20161129235712.29846-1-khilman@baylibre.com> References: <20161129235712.29846-1-khilman@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161129_155740_161017_90F95B69 X-CRM114-Status: GOOD ( 16.19 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Sekhar Nori , Hans Verkuil , Sakari Ailus , Laurent Pinchart , 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 Add basic support for initialization via DT. Because existing capture and display devices are implemented as separate platform_devices, and in order to preserve that legacy support, during DT boot, manually create capture and display platform devices to initialize capture and display support. Signed-off-by: Kevin Hilman --- drivers/media/platform/davinci/vpif.c | 48 ++++++++++++++++++++++++++- drivers/media/platform/davinci/vpif_capture.c | 6 ++++ drivers/media/platform/davinci/vpif_display.c | 6 ++++ 3 files changed, 59 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/davinci/vpif.c b/drivers/media/platform/davinci/vpif.c index 0380cf2e5775..528b30d52208 100644 --- a/drivers/media/platform/davinci/vpif.c +++ b/drivers/media/platform/davinci/vpif.c @@ -420,7 +420,8 @@ 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; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); vpif_base = devm_ioremap_resource(&pdev->dev, res); @@ -432,6 +433,42 @@ static int vpif_probe(struct platform_device *pdev) spin_lock_init(&vpif_lock); dev_info(&pdev->dev, "vpif probe success\n"); + + if (!pdev->dev.of_node) + 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; } @@ -464,8 +501,17 @@ static const struct dev_pm_ops vpif_pm = { #define vpif_pm_ops NULL #endif +#if IS_ENABLED(CONFIG_OF) +static const struct of_device_id vpif_of_match[] = { + { .compatible = "ti,da850-vpif", }, + { /* sentinel */ }, +}; +MODULE_DEVICE_TABLE(of, vpif_of_match); +#endif + static struct platform_driver vpif_driver = { .driver = { + .of_match_table = of_match_ptr(vpif_of_match), .name = "vpif", .pm = vpif_pm_ops, }, diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c index 9f8f41c0f251..a83df07e4051 100644 --- a/drivers/media/platform/davinci/vpif_capture.c +++ b/drivers/media/platform/davinci/vpif_capture.c @@ -45,6 +45,7 @@ module_param(debug, int, 0644); MODULE_PARM_DESC(debug, "Debug level 0-1"); #define VPIF_DRIVER_NAME "vpif_capture" +MODULE_ALIAS("platform:" VPIF_DRIVER_NAME); /* global variables */ static struct vpif_device vpif_obj = { {NULL} }; @@ -1438,6 +1439,11 @@ static __init int vpif_probe(struct platform_device *pdev) int res_idx = 0; int i, err; + if (!pdev->dev.platform_data) { + dev_warn(&pdev->dev, "Missing platform data. Giving up.\n"); + return -EINVAL; + } + vpif_dev = &pdev->dev; err = initialize_vpif(); diff --git a/drivers/media/platform/davinci/vpif_display.c b/drivers/media/platform/davinci/vpif_display.c index 75b27233ec2f..7f632b757d32 100644 --- a/drivers/media/platform/davinci/vpif_display.c +++ b/drivers/media/platform/davinci/vpif_display.c @@ -42,6 +42,7 @@ module_param(debug, int, 0644); MODULE_PARM_DESC(debug, "Debug level 0-1"); #define VPIF_DRIVER_NAME "vpif_display" +MODULE_ALIAS("platform:" VPIF_DRIVER_NAME); /* Is set to 1 in case of SDTV formats, 2 in case of HDTV formats. */ static int ycmux_mode; @@ -1249,6 +1250,11 @@ static __init int vpif_probe(struct platform_device *pdev) int res_idx = 0; int i, err; + if (!pdev->dev.platform_data) { + dev_warn(&pdev->dev, "Missing platform data. Giving up.\n"); + return -EINVAL; + } + vpif_dev = &pdev->dev; err = initialize_vpif();