From patchwork Wed Dec 14 04:11:55 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Turquette X-Patchwork-Id: 5659 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 549A423E18 for ; Wed, 14 Dec 2011 04:16:18 +0000 (UTC) Received: from mail-ey0-f180.google.com (mail-ey0-f180.google.com [209.85.215.180]) by fiordland.canonical.com (Postfix) with ESMTP id 4ABB8A18265 for ; Wed, 14 Dec 2011 04:16:18 +0000 (UTC) Received: by mail-ey0-f180.google.com with SMTP id k10so50195eaa.11 for ; Tue, 13 Dec 2011 20:16:18 -0800 (PST) Received: by 10.204.157.12 with SMTP id z12mr200042bkw.18.1323836177639; Tue, 13 Dec 2011 20:16:17 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.205.129.2 with SMTP id hg2cs100867bkc; Tue, 13 Dec 2011 20:16:17 -0800 (PST) Received: by 10.68.73.162 with SMTP id m2mr1024360pbv.23.1323836174835; Tue, 13 Dec 2011 20:16:14 -0800 (PST) Received: from na3sys009aog105.obsmtp.com ([74.125.149.75]) by mx.google.com with SMTP id k1si5055178pbh.74.2011.12.13.20.16.10 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 13 Dec 2011 20:16:14 -0800 (PST) Received-SPF: pass (google.com: domain of mturquette@ti.com designates 74.125.149.75 as permitted sender) client-ip=74.125.149.75; Authentication-Results: mx.google.com; spf=pass (google.com: domain of mturquette@ti.com designates 74.125.149.75 as permitted sender) smtp.mail=mturquette@ti.com Received: from mail-gy0-f175.google.com ([209.85.160.175]) (using TLSv1) by na3sys009aob105.postini.com ([74.125.148.12]) with SMTP ID DSNKTugjCTEVYAnpYm5WJz+7uMUnSGVUesiq@postini.com; Tue, 13 Dec 2011 20:16:14 PST Received: by ghrr15 with SMTP id r15so338713ghr.6 for ; Tue, 13 Dec 2011 20:16:09 -0800 (PST) Received: by 10.236.181.71 with SMTP id k47mr8707373yhm.28.1323836169426; Tue, 13 Dec 2011 20:16:09 -0800 (PST) Received: from localhost.localdomain (dragon.ti.com. [192.94.94.33]) by mx.google.com with ESMTPS id f47sm2065330yhh.8.2011.12.13.20.16.06 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 13 Dec 2011 20:16:08 -0800 (PST) From: Mike Turquette To: linux@arm.linux.org.uk Cc: linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org, khilman@ti.com, tony@atomide.com, b-cousson@ti.com, rnayak@ti.com, jeremy.kerr@canonical.com, paul@pwsan.com, broonie@opensource.wolfsonmicro.com, tglx@linutronix.de, linus.walleij@stericsson.com, amit.kucheria@linaro.org, dsaxena@linaro.org, patches@linaro.org, linaro-dev@lists.linaro.org, grant.likely@secretlab.ca, sboyd@quicinc.com, shawn.guo@freescale.com, skannan@quicinc.com, magnus.damm@gmail.com, arnd.bergmann@linaro.org, eric.miao@linaro.org, richard.zhao@linaro.org, mturquette@linaro.org, mturquette@ti.com, andrew@lunn.ch Subject: [PATCH 4/7] omap: hwmod: convert to use common struct clk Date: Tue, 13 Dec 2011 20:11:55 -0800 Message-Id: <1323835918-2371-5-git-send-email-mturquette@ti.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1323835918-2371-1-git-send-email-mturquette@ti.com> References: <1323835918-2371-1-git-send-email-mturquette@ti.com> hwmod functions implicitly deal with hardware clks and must be updated to support the new common struct clk and accompanying functions. Changes in this patch include adding clk_prepare/clk_unprepare to hwmod as well as using struct clk_hw_omap instead of the old OMAP-specific struct clk. Signed-off-by: Mike Turquette --- arch/arm/mach-omap2/omap_hwmod.c | 54 ++++++++++++++++++++++++++++--------- 1 files changed, 41 insertions(+), 13 deletions(-) diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c index 207a2ff..3e533c7 100644 --- a/arch/arm/mach-omap2/omap_hwmod.c +++ b/arch/arm/mach-omap2/omap_hwmod.c @@ -465,13 +465,19 @@ static int _disable_wakeup(struct omap_hwmod *oh, u32 *v) */ static int _add_initiator_dep(struct omap_hwmod *oh, struct omap_hwmod *init_oh) { + struct clk_hw_omap *oclk; + struct clk_hw_omap *init_oclk; + if (!oh->_clk) return -EINVAL; - if (oh->_clk->clkdm && oh->_clk->clkdm->flags & CLKDM_NO_AUTODEPS) + oclk = to_clk_hw_omap(oh->_clk); + init_oclk = to_clk_hw_omap(init_oh->_clk); + + if (oclk->clkdm && oclk->clkdm->flags & CLKDM_NO_AUTODEPS) return 0; - return clkdm_add_sleepdep(oh->_clk->clkdm, init_oh->_clk->clkdm); + return clkdm_add_sleepdep(oclk->clkdm, init_oclk->clkdm); } /** @@ -489,13 +495,19 @@ static int _add_initiator_dep(struct omap_hwmod *oh, struct omap_hwmod *init_oh) */ static int _del_initiator_dep(struct omap_hwmod *oh, struct omap_hwmod *init_oh) { + struct clk_hw_omap *oclk; + struct clk_hw_omap *init_oclk; + if (!oh->_clk) return -EINVAL; - if (oh->_clk->clkdm && oh->_clk->clkdm->flags & CLKDM_NO_AUTODEPS) + oclk = to_clk_hw_omap(oh->_clk); + init_oclk = to_clk_hw_omap(init_oh->_clk); + + if (oclk->clkdm && oclk->clkdm->flags & CLKDM_NO_AUTODEPS) return 0; - return clkdm_del_sleepdep(oh->_clk->clkdm, init_oh->_clk->clkdm); + return clkdm_del_sleepdep(oclk->clkdm, init_oclk->clkdm); } /** @@ -509,10 +521,12 @@ static int _del_initiator_dep(struct omap_hwmod *oh, struct omap_hwmod *init_oh) static int _init_main_clk(struct omap_hwmod *oh) { int ret = 0; + struct clk_hw_omap *oclk; if (!oh->main_clk) return 0; + /* FIXME replace with common clk get_clk_by_name() */ oh->_clk = omap_clk_get_by_name(oh->main_clk); if (!oh->_clk) { pr_warning("omap_hwmod: %s: cannot clk_get main_clk %s\n", @@ -520,7 +534,9 @@ static int _init_main_clk(struct omap_hwmod *oh) return -EINVAL; } - if (!oh->_clk->clkdm) + oclk = to_clk_hw_omap(oh->_clk); + + if (!oclk->clkdm) pr_warning("omap_hwmod: %s: missing clockdomain for %s.\n", oh->main_clk, oh->_clk->name); @@ -601,16 +617,20 @@ static int _enable_clocks(struct omap_hwmod *oh) pr_debug("omap_hwmod: %s: enabling clocks\n", oh->name); - if (oh->_clk) + if (oh->_clk) { + clk_prepare(oh->_clk); clk_enable(oh->_clk); + } if (oh->slaves_cnt > 0) { for (i = 0; i < oh->slaves_cnt; i++) { struct omap_hwmod_ocp_if *os = oh->slaves[i]; struct clk *c = os->_clk; - if (c && (os->flags & OCPIF_SWSUP_IDLE)) + if (c && (os->flags & OCPIF_SWSUP_IDLE)) { + clk_prepare(c); clk_enable(c); + } } } @@ -631,16 +651,20 @@ static int _disable_clocks(struct omap_hwmod *oh) pr_debug("omap_hwmod: %s: disabling clocks\n", oh->name); - if (oh->_clk) + if (oh->_clk) { clk_disable(oh->_clk); + clk_unprepare(oh->_clk); + } if (oh->slaves_cnt > 0) { for (i = 0; i < oh->slaves_cnt; i++) { struct omap_hwmod_ocp_if *os = oh->slaves[i]; struct clk *c = os->_clk; - if (c && (os->flags & OCPIF_SWSUP_IDLE)) + if (c && (os->flags & OCPIF_SWSUP_IDLE)) { clk_disable(c); + clk_unprepare(c); + } } } @@ -660,6 +684,7 @@ static void _enable_optional_clocks(struct omap_hwmod *oh) if (oc->_clk) { pr_debug("omap_hwmod: enable %s:%s\n", oc->role, oc->_clk->name); + clk_prepare(oc->_clk); clk_enable(oc->_clk); } } @@ -676,6 +701,7 @@ static void _disable_optional_clocks(struct omap_hwmod *oh) pr_debug("omap_hwmod: disable %s:%s\n", oc->role, oc->_clk->name); clk_disable(oc->_clk); + clk_unprepare(oc->_clk); } } @@ -1697,6 +1723,7 @@ static int _setup(struct omap_hwmod *oh, void *data) /* XXX omap_iclk_deny_idle(c); */ } else { /* XXX omap_iclk_allow_idle(c); */ + clk_prepare(c); clk_enable(c); } } @@ -1995,8 +2022,6 @@ int __init omap_hwmod_setup_one(const char *oh_name) struct omap_hwmod *oh; int r; - pr_debug("omap_hwmod: %s: %s\n", oh_name, __func__); - if (!mpu_oh) { pr_err("omap_hwmod: %s: cannot setup_one: MPU initiator hwmod %s not yet registered\n", oh_name, MPU_INITIATOR_NAME); @@ -2304,6 +2329,7 @@ int omap_hwmod_fill_resources(struct omap_hwmod *oh, struct resource *res) struct powerdomain *omap_hwmod_get_pwrdm(struct omap_hwmod *oh) { struct clk *c; + struct clk_hw_omap *oclk; if (!oh) return NULL; @@ -2316,10 +2342,12 @@ struct powerdomain *omap_hwmod_get_pwrdm(struct omap_hwmod *oh) c = oh->slaves[oh->_mpu_port_index]->_clk; } - if (!c->clkdm) + oclk = to_clk_hw_omap(oh->_clk); + + if (!oclk->clkdm) return NULL; - return c->clkdm->pwrdm.ptr; + return oclk->clkdm->pwrdm.ptr; }