From patchwork Fri Feb 1 19:09:24 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sylwester Nawrocki/Kernel \\(PLT\\) /SRPOL/Staff Engineer/Samsung Electronics" X-Patchwork-Id: 2082251 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 53B6340E3D for ; Fri, 1 Feb 2013 19:10:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757046Ab3BATKA (ORCPT ); Fri, 1 Feb 2013 14:10:00 -0500 Received: from mailout3.samsung.com ([203.254.224.33]:55374 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755464Ab3BATJ7 (ORCPT ); Fri, 1 Feb 2013 14:09:59 -0500 Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MHK00ICG2K9TH20@mailout3.samsung.com>; Sat, 02 Feb 2013 04:09:58 +0900 (KST) X-AuditID: cbfee61b-b7fb06d000000f28-dc-510c130663c1 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 43.45.03880.6031C015; Sat, 02 Feb 2013 04:09:58 +0900 (KST) Received: from amdc1344.digital.local ([106.116.147.32]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MHK00AVD2JZ3YB0@mmp1.samsung.com>; Sat, 02 Feb 2013 04:09:57 +0900 (KST) From: Sylwester Nawrocki To: linux-media@vger.kernel.org Cc: kyungmin.park@samsung.com, kgene.kim@samsung.com, swarren@wwwdotorg.org, rob.herring@calxeda.com, prabhakar.lad@ti.com, devicetree-discuss@lists.ozlabs.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Sylwester Nawrocki Subject: [PATCH v4 03/10] s5p-fimc: Add device tree support for FIMC-LITE devices Date: Fri, 01 Feb 2013 20:09:24 +0100 Message-id: <1359745771-23684-4-git-send-email-s.nawrocki@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1359745771-23684-1-git-send-email-s.nawrocki@samsung.com> References: <1359745771-23684-1-git-send-email-s.nawrocki@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrOJMWRmVeSWpSXmKPExsVy+t9jAV02YZ5Ag7nLOCx6NmxltZhxfh+T A5PH501yAYxRXDYpqTmZZalF+nYJXBmnDy1mK1hgWLH6yhWWBsbXGl2MnBwSAiYSD14cZYOw xSQu3FsPZHNxCAksYpQ4PGcTO4TTwSRxa8ICZpAqNgFDid6jfYwgtoiAvMST3htgHcwCc5kk Xh3pACsSFgiW2DbpMiuIzSKgKnHlQwsTiM0r4CbxbtI0IJsDaJ2CxJxJNiBhTgF3iR/dk8Cu EAIqOdv4lm0CI+8CRoZVjKKpBckFxUnpuUZ6xYm5xaV56XrJ+bmbGMHefya9g3FVg8UhRgEO RiUeXoef3IFCrIllxZW5hxglOJiVRHhta4FCvCmJlVWpRfnxRaU5qcWHGKU5WJTEeRlPPQkQ EkhPLEnNTk0tSC2CyTJxcEo1MDL/NJCdyr8l7ddnofvTLvXuWFq32FUjQWDixYxjOQL3vOte NPTEyPY3Hd91v8GgeLF0YpLEmaAI56rO64Wfp9iozY5OnbrVqJwpzTWwxbv6vh/nzBPT/zN8 jJnY+G7JiY7MXfyVF1i+b/Hne6270ZR3MuvhQul4NTEh1lq+Gxvs5c2Vd+8PUGIpzkg01GIu Kk4EAM7GAUj6AQAA Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org This patch add support for binding the driver to FIMC-LITE devices instantiated from the device tree. Signed-off-by: Sylwester Nawrocki Signed-off-by: Kyungmin Park --- .../devicetree/bindings/media/soc/samsung-fimc.txt | 15 +++++ drivers/media/platform/s5p-fimc/fimc-lite.c | 65 ++++++++++++++------ 2 files changed, 61 insertions(+), 19 deletions(-) diff --git a/Documentation/devicetree/bindings/media/soc/samsung-fimc.txt b/Documentation/devicetree/bindings/media/soc/samsung-fimc.txt index 916b2c3..2b932f2 100644 --- a/Documentation/devicetree/bindings/media/soc/samsung-fimc.txt +++ b/Documentation/devicetree/bindings/media/soc/samsung-fimc.txt @@ -41,6 +41,21 @@ Optional properties - clock-frequency - maximum FIMC local clock (LCLK) frequency +'fimc-lite' device nodes +----------------------- + +Required properties: + +- compatible : should be "samsung,exynos4212-fimc" for Exynos4212 and + Exynos4412 SoCs; +- reg : physical base address and size of the device memory mapped + registers; +- interrupts : should contain FIMC-LITE interrupt; + +For every fimc-lite node a numbered alias should be present in the aliases +node. Aliases are in form of fimc-lite, where is an integer (0...N) +specifying the IP's instance index. + Example: aliases { diff --git a/drivers/media/platform/s5p-fimc/fimc-lite.c b/drivers/media/platform/s5p-fimc/fimc-lite.c index e18babf..a0a70bc 100644 --- a/drivers/media/platform/s5p-fimc/fimc-lite.c +++ b/drivers/media/platform/s5p-fimc/fimc-lite.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -1480,18 +1481,34 @@ static int fimc_lite_clk_get(struct fimc_lite *fimc) return ret; } +static const struct of_device_id flite_of_match[]; + static int fimc_lite_probe(struct platform_device *pdev) { - struct flite_drvdata *drv_data = fimc_lite_get_drvdata(pdev); + struct flite_drvdata *drv_data = NULL; + struct device *dev = &pdev->dev; + const struct of_device_id *of_id; struct fimc_lite *fimc; struct resource *res; int ret; - fimc = devm_kzalloc(&pdev->dev, sizeof(*fimc), GFP_KERNEL); + fimc = devm_kzalloc(dev, sizeof(*fimc), GFP_KERNEL); if (!fimc) return -ENOMEM; - fimc->index = pdev->id; + if (dev->of_node) { + of_id = of_match_node(flite_of_match, dev->of_node); + if (of_id) + drv_data = (struct flite_drvdata *)of_id->data; + fimc->index = of_alias_get_id(dev->of_node, "fimc-lite"); + } else { + drv_data = fimc_lite_get_drvdata(pdev); + fimc->index = pdev->id; + } + + if (!drv_data || fimc->index < 0 || fimc->index >= FIMC_LITE_MAX_DEVS) + return -EINVAL; + fimc->variant = drv_data->variant[fimc->index]; fimc->pdev = pdev; @@ -1500,15 +1517,15 @@ static int fimc_lite_probe(struct platform_device *pdev) mutex_init(&fimc->lock); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - fimc->regs = devm_request_and_ioremap(&pdev->dev, res); + fimc->regs = devm_request_and_ioremap(dev, res); if (fimc->regs == NULL) { - dev_err(&pdev->dev, "Failed to obtain io memory\n"); + dev_err(dev, "Failed to obtain io memory\n"); return -ENOENT; } res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); if (res == NULL) { - dev_err(&pdev->dev, "Failed to get IRQ resource\n"); + dev_err(dev, "Failed to get IRQ resource\n"); return -ENXIO; } @@ -1516,10 +1533,10 @@ static int fimc_lite_probe(struct platform_device *pdev) if (ret) return ret; - ret = devm_request_irq(&pdev->dev, res->start, flite_irq_handler, - 0, dev_name(&pdev->dev), fimc); + ret = devm_request_irq(dev, res->start, flite_irq_handler, + 0, dev_name(dev), fimc); if (ret) { - dev_err(&pdev->dev, "Failed to install irq (%d)\n", ret); + dev_err(dev, "Failed to install irq (%d)\n", ret); goto err_clk; } @@ -1529,23 +1546,23 @@ static int fimc_lite_probe(struct platform_device *pdev) goto err_clk; platform_set_drvdata(pdev, fimc); - pm_runtime_enable(&pdev->dev); - ret = pm_runtime_get_sync(&pdev->dev); + pm_runtime_enable(dev); + ret = pm_runtime_get_sync(dev); if (ret < 0) goto err_sd; - fimc->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev); + fimc->alloc_ctx = vb2_dma_contig_init_ctx(dev); if (IS_ERR(fimc->alloc_ctx)) { ret = PTR_ERR(fimc->alloc_ctx); goto err_pm; } - pm_runtime_put(&pdev->dev); + pm_runtime_put(dev); - dev_dbg(&pdev->dev, "FIMC-LITE.%d registered successfully\n", + dev_dbg(dev, "FIMC-LITE.%d registered successfully\n", fimc->index); return 0; err_pm: - pm_runtime_put(&pdev->dev); + pm_runtime_put(dev); err_sd: fimc_lite_unregister_capture_subdev(fimc); err_clk: @@ -1636,6 +1653,12 @@ static int fimc_lite_remove(struct platform_device *pdev) return 0; } +static const struct dev_pm_ops fimc_lite_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(fimc_lite_suspend, fimc_lite_resume) + SET_RUNTIME_PM_OPS(fimc_lite_runtime_suspend, fimc_lite_runtime_resume, + NULL) +}; + static struct flite_variant fimc_lite0_variant_exynos4 = { .max_width = 8192, .max_height = 8192, @@ -1661,17 +1684,21 @@ static struct platform_device_id fimc_lite_driver_ids[] = { }; MODULE_DEVICE_TABLE(platform, fimc_lite_driver_ids); -static const struct dev_pm_ops fimc_lite_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(fimc_lite_suspend, fimc_lite_resume) - SET_RUNTIME_PM_OPS(fimc_lite_runtime_suspend, fimc_lite_runtime_resume, - NULL) +static const struct of_device_id flite_of_match[] = { + { + .compatible = "samsung,exynos4212-fimc-lite", + .data = &fimc_lite_drvdata_exynos4, + }, + { /* sentinel */ }, }; +MODULE_DEVICE_TABLE(of, flite_of_match); static struct platform_driver fimc_lite_driver = { .probe = fimc_lite_probe, .remove = fimc_lite_remove, .id_table = fimc_lite_driver_ids, .driver = { + .of_match_table = flite_of_match, .name = FIMC_LITE_DRV_NAME, .owner = THIS_MODULE, .pm = &fimc_lite_pm_ops,