From patchwork Fri Feb 1 19:09:25 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: 2082441 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 14E6DDFE75 for ; Fri, 1 Feb 2013 19:13:19 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1U1M0T-0000v9-9v; Fri, 01 Feb 2013 19:10:37 +0000 Received: from mailout3.samsung.com ([203.254.224.33]) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1U1Lzv-0000lq-1a for linux-arm-kernel@lists.infradead.org; Fri, 01 Feb 2013 19:10:05 +0000 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> for linux-arm-kernel@lists.infradead.org; Sat, 02 Feb 2013 04:10:02 +0900 (KST) X-AuditID: cbfee61b-b7fb06d000000f28-e1-510c13096612 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 04.45.03880.9031C015; Sat, 02 Feb 2013 04:10:02 +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> for linux-arm-kernel@lists.infradead.org; Sat, 02 Feb 2013 04:10:01 +0900 (KST) From: Sylwester Nawrocki To: linux-media@vger.kernel.org Subject: [PATCH v4 04/10] s5p-fimc: Add device tree support for the main media device driver Date: Fri, 01 Feb 2013 20:09:25 +0100 Message-id: <1359745771-23684-5-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+NgFnrAJMWRmVeSWpSXmKPExsVy+t9jAV0uYZ5AgzN72Sw2Pb7G6sDosXlJ fQBjFJdNSmpOZllqkb5dAlfGru7sgql6Ffsb57I2ME5T62Lk5JAQMJFY8vUZO4QtJnHh3nq2 LkYuDiGBRYwS2+78YYJwNjJJ3J91hBWkik3AUKL3aB8jiC0iIC/xpPcGWAezwFwmiVdHOpi7 GDk4hAXiJK6cCwepYRFQlZj7rYsFxOYVcJNoeLqAHaREQkBBYs4kG5Awp4C7xI/uSWwgthBQ ydnGt2wTGHkXMDKsYhRNLUguKE5KzzXSK07MLS7NS9dLzs/dxAj29zPpHYyrGiwOMQpwMCrx 8Dr85A4UYk0sK67MPcQowcGsJMJrWwsU4k1JrKxKLcqPLyrNSS0+xCjNwaIkzst46kmAkEB6 YklqdmpqQWoRTJaJg1OqgVH7cFpeePPevwHVex6+eszw+Hh38/XIgOrGjmIF1jkTi5dPVXLk Pvz14/HFwufz28sfCWorbAjfMZ/f9pjB04dymd/Fr308ZDBxy401K1pkf/D/SX5YeyZMdpIh 1+zFW7d+P5+zfNYM3ikBNssq8+x7ZN+d/8V8IWhL7qqeiKb72w3tPFfPbFuvxFKckWioxVxU nAgAb+u9GPMBAAA= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130201_141003_630645_609A0080 X-CRM114-Status: GOOD ( 21.38 ) X-Spam-Score: -7.6 (-------) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-7.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [203.254.224.33 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: kgene.kim@samsung.com, swarren@wwwdotorg.org, devicetree-discuss@lists.ozlabs.org, rob.herring@calxeda.com, prabhakar.lad@ti.com, kyungmin.park@samsung.com, linux-samsung-soc@vger.kernel.org, Sylwester Nawrocki , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This patch adds changes required for the main camera media device driver to be initialized on systems instantiated from the device tree. The platform devices corresponding to child nodes of the 'camera' node are looked up and and registered as sub-devices to the common media device. The main driver's probing is deferred if any of the sub-device drivers is not yet initialized and ready. An OF matching table is added for the main driver associated with the 'camera' node. Signed-off-by: Sylwester Nawrocki Signed-off-by: Kyungmin Park --- drivers/media/platform/s5p-fimc/fimc-core.c | 1 - drivers/media/platform/s5p-fimc/fimc-mdevice.c | 77 +++++++++++++++++++++--- drivers/media/platform/s5p-fimc/fimc-mdevice.h | 4 ++ include/media/s5p_fimc.h | 1 + 4 files changed, 75 insertions(+), 8 deletions(-) diff --git a/drivers/media/platform/s5p-fimc/fimc-core.c b/drivers/media/platform/s5p-fimc/fimc-core.c index 07ca0e0..ba743a5 100644 --- a/drivers/media/platform/s5p-fimc/fimc-core.c +++ b/drivers/media/platform/s5p-fimc/fimc-core.c @@ -1276,7 +1276,6 @@ static const struct platform_device_id fimc_driver_ids[] = { }, { }, }; -MODULE_DEVICE_TABLE(platform, fimc_driver_ids); static const struct of_device_id fimc_of_match[] = { { diff --git a/drivers/media/platform/s5p-fimc/fimc-mdevice.c b/drivers/media/platform/s5p-fimc/fimc-mdevice.c index f49f6f1..c113734 100644 --- a/drivers/media/platform/s5p-fimc/fimc-mdevice.c +++ b/drivers/media/platform/s5p-fimc/fimc-mdevice.c @@ -17,6 +17,8 @@ #include #include #include +#include +#include #include #include #include @@ -457,6 +459,51 @@ static int fimc_md_pdev_match(struct device *dev, void *data) return 0; } +/* Register FIMC, FIMC-LITE and CSIS media entities */ +#ifdef CONFIG_OF +static int fimc_md_register_of_platform_entities(struct fimc_md *fmd, + struct device_node *parent) +{ + struct device_node *node; + int ret = 0; + + for_each_available_child_of_node(parent, node) { + struct platform_device *pdev; + int plat_entity = -1; + + pdev = of_find_device_by_node(node); + if (!pdev) + continue; + + /* If driver of any entity isn't ready try all again later. */ + if (!strcmp(node->name, CSIS_OF_NODE_NAME)) + plat_entity = IDX_CSIS; + else if (!strcmp(node->name, FIMC_LITE_OF_NODE_NAME)) + plat_entity = IDX_FLITE; + else if (!strcmp(node->name, FIMC_OF_NODE_NAME)) + plat_entity = IDX_FIMC; + + if (plat_entity >= 0) + ret = fimc_md_register_platform_entity(fmd, pdev, + plat_entity); + put_device(&pdev->dev); + if (ret < 0) + break; + + /* FIMC-IS child devices */ + if (plat_entity == IDX_IS_ISP) { + ret = fimc_md_register_of_platform_entities(fmd, node); + if (ret < 0) + break; + } + } + + return ret; +} +#else +#define fimc_md_register_platform_entities(fmd) (-ENOSYS) +#endif + static void fimc_md_unregister_entities(struct fimc_md *fmd) { int i; @@ -948,8 +995,8 @@ static int fimc_md_probe(struct platform_device *pdev) v4l2_dev = &fmd->v4l2_dev; v4l2_dev->mdev = &fmd->media_dev; v4l2_dev->notify = fimc_sensor_notify; - snprintf(v4l2_dev->name, sizeof(v4l2_dev->name), "%s", - dev_name(&pdev->dev)); + strlcpy(v4l2_dev->name, "s5p-fimc-md", sizeof(v4l2_dev->name)); + ret = v4l2_device_register(&pdev->dev, &fmd->v4l2_dev); if (ret < 0) { @@ -965,13 +1012,16 @@ static int fimc_md_probe(struct platform_device *pdev) if (ret) goto err_clk; - fmd->user_subdev_api = false; + fmd->user_subdev_api = (dev->of_node != NULL); /* Protect the media graph while we're registering entities */ mutex_lock(&fmd->media_dev.graph_mutex); - ret = bus_for_each_dev(&platform_bus_type, NULL, fmd, - fimc_md_pdev_match); + if (fmd->pdev->dev.of_node) + ret = fimc_md_register_of_platform_entities(fmd, dev->of_node); + else + ret = bus_for_each_dev(&platform_bus_type, NULL, fmd, + fimc_md_pdev_match); if (ret) goto err_unlock; @@ -1019,12 +1069,25 @@ static int fimc_md_remove(struct platform_device *pdev) return 0; } +static struct platform_device_id fimc_driver_ids[] __always_unused = { + { .name = "s5p-fimc-md" }, + { }, +}; +MODULE_DEVICE_TABLE(platform, fimc_driver_ids); + +static const struct of_device_id fimc_md_of_match[] __initconst = { + { .compatible = "samsung,fimc" }, + { }, +}; +MODULE_DEVICE_TABLE(of, fimc_md_of_match); + static struct platform_driver fimc_md_driver = { .probe = fimc_md_probe, .remove = fimc_md_remove, .driver = { - .name = "s5p-fimc-md", - .owner = THIS_MODULE, + .of_match_table = fimc_md_of_match, + .name = "s5p-fimc-md", + .owner = THIS_MODULE, } }; diff --git a/drivers/media/platform/s5p-fimc/fimc-mdevice.h b/drivers/media/platform/s5p-fimc/fimc-mdevice.h index 06b0d82..f3e0251 100644 --- a/drivers/media/platform/s5p-fimc/fimc-mdevice.h +++ b/drivers/media/platform/s5p-fimc/fimc-mdevice.h @@ -21,6 +21,10 @@ #include "fimc-lite.h" #include "mipi-csis.h" +#define FIMC_OF_NODE_NAME "fimc" +#define FIMC_LITE_OF_NODE_NAME "fimc-lite" +#define CSIS_OF_NODE_NAME "csis" + /* Group IDs of sensor, MIPI-CSIS, FIMC-LITE and the writeback subdevs. */ #define GRP_ID_SENSOR (1 << 8) #define GRP_ID_FIMC_IS_SENSOR (1 << 9) diff --git a/include/media/s5p_fimc.h b/include/media/s5p_fimc.h index 28f3590..17fd2fa 100644 --- a/include/media/s5p_fimc.h +++ b/include/media/s5p_fimc.h @@ -81,6 +81,7 @@ enum fimc_subdev_index { IDX_SENSOR, IDX_CSIS, IDX_FLITE, + IDX_IS_ISP, IDX_FIMC, IDX_MAX, };