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: 9453243 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 22FA26071C for ; Tue, 29 Nov 2016 23:57:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1360E2835B for ; Tue, 29 Nov 2016 23:57:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 07BA52846F; Tue, 29 Nov 2016 23:57:25 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 73A7F2835B for ; Tue, 29 Nov 2016 23:57:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754964AbcK2X5U (ORCPT ); Tue, 29 Nov 2016 18:57:20 -0500 Received: from mail-pg0-f41.google.com ([74.125.83.41]:34801 "EHLO mail-pg0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754772AbcK2X5R (ORCPT ); Tue, 29 Nov 2016 18:57:17 -0500 Received: by mail-pg0-f41.google.com with SMTP id x23so74806806pgx.1 for ; Tue, 29 Nov 2016 15:57:17 -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=e+7e+EtyIu3WroswyMqb0ccDNHq0paZJ7yaPswUaFhlOmYMHDC8zi430aUQaZzRKoE pTrJbGeJxVQRRxJ0nWlHb20Q40aGqIyKuievAIygCEyRA+gr1W9A6+hCMhZTZBZQSfA8 E9w23GkZVmpcu7ZNikqJZPHdW9vyiAxVhBhPQqTveBmS3kgZYJAwHdUF+l2jwwnXerlM bPWgl92Ku7G0AFhInt8lSZshulHQWKbze07UGbnWXbWfwvHzOTur7fWLZirDnJuTEvCj U0dvotphyI8Mh7Q+4Jx/ZpzWAc1M389+QxAmlSnwQwJb3m87lsChuDbZCfRy5xwCMOlB gh/w== X-Gm-Message-State: AKaTC00OEfvfV7SUOK4tz0dcsUYEnYccTPMsx54uoO5Qd0beGDPokKR/mjHpe5rIp5YTYC1K 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 Cc: Hans Verkuil , Laurent Pinchart , Sakari Ailus , linux-arm-kernel@lists.infradead.org, Sekhar Nori , Rob Herring , devicetree@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 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.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();