From patchwork Tue Mar 26 17:29:48 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: 2341791 Return-Path: X-Original-To: patchwork-linux-samsung-soc@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 54C003FD40 for ; Tue, 26 Mar 2013 17:30:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753332Ab3CZRad (ORCPT ); Tue, 26 Mar 2013 13:30:33 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:62500 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753209Ab3CZRaa (ORCPT ); Tue, 26 Mar 2013 13:30:30 -0400 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MKA00D1V3ACS190@mailout4.samsung.com>; Wed, 27 Mar 2013 02:30:29 +0900 (KST) X-AuditID: cbfee61a-b7fa86d0000045ae-4e-5151db35c958 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id F0.EA.17838.53BD1515; Wed, 27 Mar 2013 02:30:29 +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 <0MKA004BH39YZW90@mmp1.samsung.com>; Wed, 27 Mar 2013 02:30:28 +0900 (KST) From: Sylwester Nawrocki To: linux-media@vger.kernel.org Cc: kyungmin.park@samsung.com, myungjoo.ham@samsung.com, dh09.lee@samsung.com, shaik.samsung@gmail.com, arun.kk@samsung.com, a.hajda@samsung.com, linux-samsung-soc@vger.kernel.org, Sylwester Nawrocki Subject: [PATCH v2 06/10] s5p-fimc: Ensure CAMCLK clock can be enabled by FIMC-LITE devices Date: Tue, 26 Mar 2013 18:29:48 +0100 Message-id: <1364318992-20562-7-git-send-email-s.nawrocki@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1364318992-20562-1-git-send-email-s.nawrocki@samsung.com> References: <1364318992-20562-1-git-send-email-s.nawrocki@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprELMWRmVeSWpSXmKPExsVy+t9jAV3T24GBBivusFvcWneO1eLjqdus FtfP21mcbXrDbtGzYSurxYzz+5gsbjeuYLM4/Kad1WLdzknsDpweO2fdZffo27KK0ePzJrkA 5igum5TUnMyy1CJ9uwSujFONtQWTFCvOTbjD2MC4SLqLkZNDQsBEYlPLDkYIW0ziwr31bF2M XBxCAosYJQ42vWaBcDqYJP5/2ssOUsUmYCjRe7QPrENEQF7iSe8NsA5mgSeMEn9OHGACSQgL xEqcnLSVDcRmEVCVuDb7M1icV8BN4uSu30BxDqB1ChJzJtmAhDkF3CWW3zjCAmILAZU8b9jC NoGRdwEjwypG0dSC5ILipPRcQ73ixNzi0rx0veT83E2M4JB6JrWDcWWDxSFGAQ5GJR7eDcEB gUKsiWXFlbmHGCU4mJVEeAU3BgYK8aYkVlalFuXHF5XmpBYfYpTmYFES5z3Qah0oJJCeWJKa nZpakFoEk2Xi4JRqYIzf8a3h0Lz37xZMunNFRDrV1E1Mp1Pa8/iEown5Ph+i8ztF3U+GLjqk NWvTfP1vd6U37GoqSI7bJaS82DDCfs/DlyISOUc+bfBdGbg+rTLq4qJ5Zks/HesuM/8byGzL dqjivMx77yDxmCUzL91N6t33i5/j7Onw78Xij8vkWpK+KrT9WMIhVq/EUpyRaKjFXFScCADv o988JQIAAA== Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org In configurations where FIMC-LITE is used to capture image signal from an external sensor only we need to ensure one of FIMC devices is in active power state and the "fimc" gate clock is enabled. Otherwise the CAMCLK clock output signal will be masked off preventing an external sensor's operation. This affect processing pipelines like: - sensor -> FIMC-LITE -> memory - sensor -> MIPI-CSIS -> FIMC-LITE -> memory Signed-off-by: Sylwester Nawrocki Signed-off-by: Kyungmin Park --- drivers/media/platform/s5p-fimc/fimc-mdevice.c | 18 ++++++++++-------- drivers/media/platform/s5p-fimc/fimc-mdevice.h | 2 ++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/media/platform/s5p-fimc/fimc-mdevice.c b/drivers/media/platform/s5p-fimc/fimc-mdevice.c index 5b11e39..d519ee7 100644 --- a/drivers/media/platform/s5p-fimc/fimc-mdevice.c +++ b/drivers/media/platform/s5p-fimc/fimc-mdevice.c @@ -507,7 +507,6 @@ static int fimc_md_register_sensor_entities(struct fimc_md *fmd) { struct s5p_platform_fimc *pdata = fmd->pdev->dev.platform_data; struct device_node *of_node = fmd->pdev->dev.of_node; - struct fimc_dev *fd = NULL; int num_clients = 0; int ret, i; @@ -515,13 +514,10 @@ static int fimc_md_register_sensor_entities(struct fimc_md *fmd) * Runtime resume one of the FIMC entities to make sure * the sclk_cam clocks are not globally disabled. */ - for (i = 0; !fd && i < ARRAY_SIZE(fmd->fimc); i++) - if (fmd->fimc[i]) - fd = fmd->fimc[i]; - if (!fd) + if (!fmd->pmf) return -ENXIO; - ret = pm_runtime_get_sync(&fd->pdev->dev); + ret = pm_runtime_get_sync(fmd->pmf); if (ret < 0) return ret; @@ -555,7 +551,7 @@ static int fimc_md_register_sensor_entities(struct fimc_md *fmd) } } - pm_runtime_put(&fd->pdev->dev); + pm_runtime_put(fmd->pmf); return ret; } @@ -600,6 +596,8 @@ static int register_fimc_entity(struct fimc_md *fmd, struct fimc_dev *fimc) ret = v4l2_device_register_subdev(&fmd->v4l2_dev, sd); if (!ret) { + if (!fmd->pmf && fimc->pdev) + fmd->pmf = &fimc->pdev->dev; fmd->fimc[fimc->id] = fimc; fimc->vid_cap.user_subdev_api = fmd->user_subdev_api; } else { @@ -1083,7 +1081,7 @@ static int __fimc_md_set_camclk(struct fimc_md *fmd, struct fimc_camclk_info *camclk; int ret = 0; - if (WARN_ON(pdata->clk_id >= FIMC_MAX_CAMCLKS) || fmd == NULL) + if (WARN_ON(pdata->clk_id >= FIMC_MAX_CAMCLKS) || !fmd || !fmd->pmf) return -EINVAL; camclk = &fmd->camclk[pdata->clk_id]; @@ -1099,6 +1097,9 @@ static int __fimc_md_set_camclk(struct fimc_md *fmd, if (camclk->use_count++ == 0) { clk_set_rate(camclk->clock, pdata->clk_frequency); camclk->frequency = pdata->clk_frequency; + ret = pm_runtime_get_sync(fmd->pmf); + if (ret < 0) + return ret; ret = clk_enable(camclk->clock); dbg("Enabled camclk %d: f: %lu", pdata->clk_id, clk_get_rate(camclk->clock)); @@ -1111,6 +1112,7 @@ static int __fimc_md_set_camclk(struct fimc_md *fmd, if (--camclk->use_count == 0) { clk_disable(camclk->clock); + pm_runtime_put(fmd->pmf); dbg("Disabled camclk %d", pdata->clk_id); } return ret; diff --git a/drivers/media/platform/s5p-fimc/fimc-mdevice.h b/drivers/media/platform/s5p-fimc/fimc-mdevice.h index 46f3b82..1d5cea5 100644 --- a/drivers/media/platform/s5p-fimc/fimc-mdevice.h +++ b/drivers/media/platform/s5p-fimc/fimc-mdevice.h @@ -81,6 +81,7 @@ struct fimc_sensor_info { * @camclk: external sensor clock information * @fimc: array of registered fimc devices * @use_isp: set to true when FIMC-IS subsystem is used + * @pmf: handle to the CAMCLK clock control FIMC helper device * @media_dev: top level media device * @v4l2_dev: top level v4l2_device holding up the subdevs * @pdev: platform device this media device is hooked up into @@ -99,6 +100,7 @@ struct fimc_md { struct fimc_lite *fimc_lite[FIMC_LITE_MAX_DEVS]; struct fimc_dev *fimc[FIMC_MAX_DEVS]; bool use_isp; + struct device *pmf; struct media_device media_dev; struct v4l2_device v4l2_dev; struct platform_device *pdev;