From patchwork Mon Nov 22 19:53:54 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Aguirre Rodriguez, Sergio Alberto" X-Patchwork-Id: 348291 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oAMKwFYd003614 for ; Mon, 22 Nov 2010 20:58:24 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757435Ab0KVTyR (ORCPT ); Mon, 22 Nov 2010 14:54:17 -0500 Received: from bear.ext.ti.com ([192.94.94.41]:52488 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757379Ab0KVTyP (ORCPT ); Mon, 22 Nov 2010 14:54:15 -0500 Received: from dlep36.itg.ti.com ([157.170.170.91]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id oAMJs8j9015951 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 22 Nov 2010 13:54:08 -0600 Received: from legion.dal.design.ti.com (localhost [127.0.0.1]) by dlep36.itg.ti.com (8.13.8/8.13.8) with ESMTP id oAMJs8pT008681; Mon, 22 Nov 2010 13:54:08 -0600 (CST) Received: from localhost (dtx0091359-ubuntu-1.am.dhcp.ti.com [128.247.79.64]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id oAMJs8f03955; Mon, 22 Nov 2010 13:54:08 -0600 (CST) From: Sergio Aguirre To: Laurent Pinchart Cc: linux-media@vger.kernel.org, David Cohen , Sergio Aguirre Subject: [omap3isp RFC][RESEND PATCH v2 1/4] omap3isp: Abstract isp subdevs clock control Date: Mon, 22 Nov 2010 13:53:54 -0600 Message-Id: <1290455637-22813-2-git-send-email-saaguirre@ti.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1290455637-22813-1-git-send-email-saaguirre@ti.com> References: <1290455637-22813-1-git-send-email-saaguirre@ti.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Mon, 22 Nov 2010 20:58:24 +0000 (UTC) diff --git a/drivers/media/video/isp/isp.c b/drivers/media/video/isp/isp.c index 30bdc48..1ff7193 100644 --- a/drivers/media/video/isp/isp.c +++ b/drivers/media/video/isp/isp.c @@ -991,6 +991,52 @@ void isp_sbl_disable(struct isp_device *isp, enum isp_sbl_resource res) * Clock management */ +#define ISPCTRL_CLKS_MASK (ISPCTRL_H3A_CLK_EN | \ + ISPCTRL_HIST_CLK_EN | \ + ISPCTRL_RSZ_CLK_EN | \ + (ISPCTRL_CCDC_CLK_EN | ISPCTRL_CCDC_RAM_EN) | \ + (ISPCTRL_PREV_CLK_EN | ISPCTRL_PREV_RAM_EN)) + +static void __isp_subclk_update(struct isp_device *isp) +{ + u32 clk = 0; + + if (isp->subclk_resources & OMAP3_ISP_SUBCLK_H3A) + clk |= ISPCTRL_H3A_CLK_EN; + + if (isp->subclk_resources & OMAP3_ISP_SUBCLK_HIST) + clk |= ISPCTRL_HIST_CLK_EN; + + if (isp->subclk_resources & OMAP3_ISP_SUBCLK_RESIZER) + clk |= ISPCTRL_RSZ_CLK_EN; + + /* NOTE: For CCDC & Preview submodules, we need to affect internal + * RAM aswell. + */ + if (isp->subclk_resources & OMAP3_ISP_SUBCLK_CCDC) + clk |= ISPCTRL_CCDC_CLK_EN | ISPCTRL_CCDC_RAM_EN; + + if (isp->subclk_resources & OMAP3_ISP_SUBCLK_PREVIEW) + clk |= ISPCTRL_PREV_CLK_EN | ISPCTRL_PREV_RAM_EN; + + isp_reg_clr_set(isp, OMAP3_ISP_IOMEM_MAIN, ISP_CTRL, + ISPCTRL_CLKS_MASK, clk); +} + +void isp_subclk_enable(struct isp_device *isp, enum isp_subclk_resource res) +{ + isp->subclk_resources |= res; + + __isp_subclk_update(isp); +} + +void isp_subclk_disable(struct isp_device *isp, enum isp_subclk_resource res) +{ + isp->subclk_resources &= ~res; + + __isp_subclk_update(isp); +} + /* * isp_enable_clocks - Enable ISP clocks * @isp: OMAP3 ISP device diff --git a/drivers/media/video/isp/isp.h b/drivers/media/video/isp/isp.h index b8f63e2..5edbc86 100644 --- a/drivers/media/video/isp/isp.h +++ b/drivers/media/video/isp/isp.h @@ -85,6 +85,14 @@ enum isp_sbl_resource { OMAP3_ISP_SBL_RESIZER_WRITE = 0x200, }; +enum isp_subclk_resource { + OMAP3_ISP_SUBCLK_CCDC = (1 << 0), + OMAP3_ISP_SUBCLK_H3A = (1 << 1), + OMAP3_ISP_SUBCLK_HIST = (1 << 2), + OMAP3_ISP_SUBCLK_PREVIEW = (1 << 3), + OMAP3_ISP_SUBCLK_RESIZER = (1 << 4), +}; + enum isp_interface_type { ISP_INTERFACE_PARALLEL, ISP_INTERFACE_CSI2A_PHY2, @@ -262,6 +270,7 @@ struct isp_device { struct isp_csiphy isp_csiphy2; unsigned int sbl_resources; + unsigned int subclk_resources; struct iommu *iommu; }; @@ -294,6 +303,9 @@ void isp_print_status(struct isp_device *isp); void isp_sbl_enable(struct isp_device *isp, enum isp_sbl_resource res); void isp_sbl_disable(struct isp_device *isp, enum isp_sbl_resource res); +void isp_subclk_enable(struct isp_device *isp, enum isp_subclk_resource res); +void isp_subclk_disable(struct isp_device *isp, enum isp_subclk_resource res); + int omap3isp_register_entities(struct platform_device *pdev, struct v4l2_device *v4l2_dev); void omap3isp_unregister_entities(struct platform_device *pdev); diff --git a/drivers/media/video/isp/ispccdc.c b/drivers/media/video/isp/ispccdc.c index c3d1d7a..4244edf 100644 --- a/drivers/media/video/isp/ispccdc.c +++ b/drivers/media/video/isp/ispccdc.c @@ -1687,8 +1687,7 @@ static int ccdc_set_stream(struct v4l2_subdev *sd, int enable) if (enable == ISP_PIPELINE_STREAM_STOPPED) return 0; - isp_reg_set(isp, OMAP3_ISP_IOMEM_MAIN, ISP_CTRL, - ISPCTRL_CCDC_RAM_EN | ISPCTRL_CCDC_CLK_EN); + isp_subclk_enable(isp, OMAP3_ISP_SUBCLK_CCDC); isp_reg_set(isp, OMAP3_ISP_IOMEM_CCDC, ISPCCDC_CFG, ISPCCDC_CFG_VDLC); @@ -1725,8 +1724,7 @@ static int ccdc_set_stream(struct v4l2_subdev *sd, int enable) ret = ispccdc_disable(ccdc); if (ccdc->output & CCDC_OUTPUT_MEMORY) isp_sbl_disable(isp, OMAP3_ISP_SBL_CCDC_WRITE); - isp_reg_clr(isp, OMAP3_ISP_IOMEM_MAIN, ISP_CTRL, - ISPCTRL_CCDC_CLK_EN | ISPCTRL_CCDC_RAM_EN); + isp_subclk_disable(isp, OMAP3_ISP_SUBCLK_CCDC); ccdc->underrun = 0; break; } diff --git a/drivers/media/video/isp/isppreview.c b/drivers/media/video/isp/isppreview.c index 74e4f6a..3e55123 100644 --- a/drivers/media/video/isp/isppreview.c +++ b/drivers/media/video/isp/isppreview.c @@ -1648,8 +1648,7 @@ static int preview_set_stream(struct v4l2_subdev *sd, int enable) if (enable == ISP_PIPELINE_STREAM_STOPPED) return 0; - isp_reg_set(isp, OMAP3_ISP_IOMEM_MAIN, ISP_CTRL, - ISPCTRL_PREV_RAM_EN | ISPCTRL_PREV_CLK_EN); + isp_subclk_enable(isp, OMAP3_ISP_SUBCLK_PREVIEW); preview_configure(prev); isppreview_print_status(prev); } @@ -1677,8 +1676,7 @@ static int preview_set_stream(struct v4l2_subdev *sd, int enable) case ISP_PIPELINE_STREAM_STOPPED: isp_sbl_disable(isp, OMAP3_ISP_SBL_PREVIEW_READ); isp_sbl_disable(isp, OMAP3_ISP_SBL_PREVIEW_WRITE); - isp_reg_clr(isp, OMAP3_ISP_IOMEM_MAIN, ISP_CTRL, - ISPCTRL_PREV_CLK_EN | ISPCTRL_PREV_RAM_EN); + isp_subclk_disable(isp, OMAP3_ISP_SUBCLK_PREVIEW); prev->underrun = 0; break; } diff --git a/drivers/media/video/isp/ispresizer.c b/drivers/media/video/isp/ispresizer.c index 95c5895..bd33f21 100644 --- a/drivers/media/video/isp/ispresizer.c +++ b/drivers/media/video/isp/ispresizer.c @@ -1120,8 +1120,7 @@ static int resizer_set_stream(struct v4l2_subdev *sd, int enable) if (enable != ISP_PIPELINE_STREAM_STOPPED && res->state == ISP_PIPELINE_STREAM_STOPPED) { - isp_reg_set(isp, OMAP3_ISP_IOMEM_MAIN, ISP_CTRL, - ISPCTRL_RSZ_CLK_EN); + isp_subclk_enable(isp, OMAP3_ISP_SUBCLK_RESIZER); resizer_configure(res); ispresizer_print_status(res); } @@ -1146,8 +1145,7 @@ static int resizer_set_stream(struct v4l2_subdev *sd, int enable) case ISP_PIPELINE_STREAM_STOPPED: isp_sbl_disable(isp, OMAP3_ISP_SBL_RESIZER_READ | OMAP3_ISP_SBL_RESIZER_WRITE); - isp_reg_clr(isp, OMAP3_ISP_IOMEM_MAIN, ISP_CTRL, - ISPCTRL_RSZ_CLK_EN); + isp_subclk_disable(isp, OMAP3_ISP_SUBCLK_RESIZER); res->underrun = 0; break; }