From patchwork Mon Mar 11 19:00:22 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: 2249991 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id B88E9DF5B1 for ; Mon, 11 Mar 2013 19:01:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754472Ab3CKTBO (ORCPT ); Mon, 11 Mar 2013 15:01:14 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:58391 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754451Ab3CKTBM (ORCPT ); Mon, 11 Mar 2013 15:01:12 -0400 Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MJI00M7TFHW9VK0@mailout1.samsung.com>; Tue, 12 Mar 2013 04:01:11 +0900 (KST) X-AuditID: cbfee61b-b7f076d0000034b6-48-513e29f7258a Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 8A.8B.13494.7F92E315; Tue, 12 Mar 2013 04:01:11 +0900 (KST) Received: from amdc1344.digital.local ([106.116.147.32]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MJI00F2XFGXUP00@mmp2.samsung.com>; Tue, 12 Mar 2013 04:01:11 +0900 (KST) From: Sylwester Nawrocki To: linux-media@vger.kernel.org Cc: kyungmin.park@samsung.com, myungjoo.ham@samsung.com, shaik.samsung@gmail.com, arun.kk@samsung.com, a.hajda@samsung.com, linux-samsung-soc@vger.kernel.org, Sylwester Nawrocki Subject: [PATCH RFC 07/11] s5p-fimc: Ensure CAMCLK clock can be enabled by FIMC-LITE devices Date: Mon, 11 Mar 2013 20:00:22 +0100 Message-id: <1363028426-2771-8-git-send-email-s.nawrocki@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1363028426-2771-1-git-send-email-s.nawrocki@samsung.com> References: <1363028426-2771-1-git-send-email-s.nawrocki@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupjluLIzCtJLcpLzFFi42I5/e+xoO53TbtAg23TFCxurTvHavHx1G1W i7NNb9gtejZsZbWYcX4fk8XtxhVsFofftLNarNs5id2Bw2PnrLvsHn1bVjF6fN4kF8AcxWWT kpqTWZZapG+XwJVxoPM7a8ESxYoLrXYNjNukuxg5OSQETCRWLl3FCGGLSVy4t56ti5GLQ0hg OqPExYb3zBBOB5NEz4dDYFVsAoYSvUf7wGwRAXmJJ703wDqYBc4xSry58ZoVJCEsECdx+nAj O4jNIqAqcefBI2YQm1fAVWL9pIVANRxA6xQk5kyyAQlzCrhJrHmygA3EFgIq+fHzDPsERt4F jAyrGEVTC5ILipPSc430ihNzi0vz0vWS83M3MYJD6Zn0DsZVDRaHGAU4GJV4eBW+2QYKsSaW FVfmHmKU4GBWEuFduckmUIg3JbGyKrUoP76oNCe1+BCjNAeLkjjvwVbrQCGB9MSS1OzU1ILU IpgsEwenVAOj0PKZXrpNSiFlz75rnjqd+zM6/p+eobSdLbfj34cfyirvNsa+3R5vUX381adf HC9UDXt2da9axW+9b4KLKp/i1ocyVXEKvWziLMLKybs1mnZMNj059WXdmokbJiTvOpwwR0DR 1fPmieCFhrdyzKcv7tpTWJKZl3U180HrWVvDfWdEM46lZsYrsRRnJBpqMRcVJwIAxb5SJSEC AAA= Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@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 d26b7bf..c336ed1 100644 --- a/drivers/media/platform/s5p-fimc/fimc-mdevice.c +++ b/drivers/media/platform/s5p-fimc/fimc-mdevice.c @@ -464,7 +464,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; @@ -472,13 +471,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; @@ -512,7 +508,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; } @@ -557,6 +553,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 { @@ -1048,7 +1046,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]; @@ -1064,6 +1062,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)); @@ -1076,6 +1077,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 91be5db..a827bf9 100644 --- a/drivers/media/platform/s5p-fimc/fimc-mdevice.h +++ b/drivers/media/platform/s5p-fimc/fimc-mdevice.h @@ -80,6 +80,7 @@ struct fimc_sensor_info { * @num_sensors: actual number of registered sensors * @camclk: external sensor clock information * @fimc: array of registered fimc devices + * @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 @@ -97,6 +98,7 @@ struct fimc_md { struct clk *wbclk[FIMC_MAX_WBCLKS]; struct fimc_lite *fimc_lite[FIMC_LITE_MAX_DEVS]; struct fimc_dev *fimc[FIMC_MAX_DEVS]; + struct device *pmf; struct media_device media_dev; struct v4l2_device v4l2_dev; struct platform_device *pdev;