From patchwork Thu Aug 25 13:17:36 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jamie Iles X-Patchwork-Id: 1096352 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p7PDHv0Y025309 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 25 Aug 2011 13:18:18 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QwZoa-00037B-Kz; Thu, 25 Aug 2011 13:17:48 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QwZoa-0002mF-6L; Thu, 25 Aug 2011 13:17:48 +0000 Received: from mail-wy0-f177.google.com ([74.125.82.177]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QwZoV-0002lu-Io for linux-arm-kernel@lists.infradead.org; Thu, 25 Aug 2011 13:17:45 +0000 Received: by wyh11 with SMTP id 11so2028897wyh.36 for ; Thu, 25 Aug 2011 06:17:40 -0700 (PDT) Received: by 10.216.221.102 with SMTP id q80mr5801647wep.37.1314278260348; Thu, 25 Aug 2011 06:17:40 -0700 (PDT) Received: from localhost (cpc1-chap8-2-0-cust192.aztw.cable.virginmedia.com [94.169.120.193]) by mx.google.com with ESMTPS id u55sm360349wec.38.2011.08.25.06.17.38 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 25 Aug 2011 06:17:39 -0700 (PDT) Date: Thu, 25 Aug 2011 14:17:36 +0100 From: Jamie Iles To: Mark Brown Subject: Re: [PATCH 04/11] clk: Add simple gated clock Message-ID: <20110825131736.GE2838@pulham.picochip.com> References: <20110824131324.GB16520@opensource.wolfsonmicro.com> <1314191759-16941-1-git-send-email-broonie@opensource.wolfsonmicro.com> <1314191759-16941-4-git-send-email-broonie@opensource.wolfsonmicro.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1314191759-16941-4-git-send-email-broonie@opensource.wolfsonmicro.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110825_091743_887399_18ABE26C X-CRM114-Status: GOOD ( 24.43 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [74.125.82.177 listed in list.dnswl.org] Cc: Jeremy Kerr , Linus Walleij , linux-arm-kernel@lists.infradead.org, Mike Turquette X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 25 Aug 2011 13:18:18 +0000 (UTC) Hi Mark, Jeremy, On Wed, Aug 24, 2011 at 02:15:52PM +0100, Mark Brown wrote: > From: Jeremy Kerr > > Signed-off-by: Jeremy Kerr > Signed-off-by: Mark Brown I've just ported my (currently out-of-tree) platform to use the common struct clk and it all works nicely (if I add a naive implementation of clk_set_parent()). Our platform has gateable clocks where bits in the control register are set to disable the clocks rather than enable them. I've used the patch below to add support for that. Jamie 8<---- Subject: [PATCH] clk: allow gateable clocks to work with both polarities Some devices (picoxcell in particular) have gateable clocks where the control register is a set-to-disable register. Create a new set of clock ops that can use struct clk_gate with this register configuration. Signed-off-by: Jamie Iles --- drivers/clk/clk-gate.c | 45 +++++++++++++++++++++++++++++++++++++-------- include/linux/clk.h | 3 ++- 2 files changed, 39 insertions(+), 9 deletions(-) diff --git a/drivers/clk/clk-gate.c b/drivers/clk/clk-gate.c index 833e0da..30926e9 100644 --- a/drivers/clk/clk-gate.c +++ b/drivers/clk/clk-gate.c @@ -10,7 +10,7 @@ static unsigned long clk_gate_get_rate(struct clk_hw *clk) return clk_get_rate(clk_get_parent(clk->clk)); } -static int clk_gate_enable(struct clk_hw *clk) +static void clk_gate_set_bit(struct clk_hw *clk) { struct clk_gate *gate = to_clk_gate(clk); u32 reg; @@ -18,11 +18,9 @@ static int clk_gate_enable(struct clk_hw *clk) reg = __raw_readl(gate->reg); reg |= 1 << gate->bit_idx; __raw_writel(reg, gate->reg); - - return 0; } -static void clk_gate_disable(struct clk_hw *clk) +static void clk_gate_clear_bit(struct clk_hw *clk) { struct clk_gate *gate = to_clk_gate(clk); u32 reg; @@ -32,10 +30,41 @@ static void clk_gate_disable(struct clk_hw *clk) __raw_writel(reg, gate->reg); } -struct clk_hw_ops clk_gate_ops = { +static int clk_gate_enable_set(struct clk_hw *clk) +{ + clk_gate_set_bit(clk); + + return 0; +} + +static void clk_gate_disable_clear(struct clk_hw *clk) +{ + clk_gate_clear_bit(clk); +} + +struct clk_hw_ops clk_gate_set_enable_ops = { + .recalc_rate = clk_gate_get_rate, + .enable = clk_gate_enable_set, + .disable = clk_gate_disable_clear, +}; +EXPORT_SYMBOL_GPL(clk_gate_set_enable_ops); + +static int clk_gate_enable_clear(struct clk_hw *clk) +{ + clk_gate_clear_bit(clk); + + return 0; +} + +static void clk_gate_disable_set(struct clk_hw *clk) +{ + clk_gate_set_bit(clk); +} + +struct clk_hw_ops clk_gate_set_disable_ops = { .recalc_rate = clk_gate_get_rate, - .enable = clk_gate_enable, - .disable = clk_gate_disable, + .enable = clk_gate_enable_clear, + .disable = clk_gate_disable_set, }; -EXPORT_SYMBOL_GPL(clk_gate_ops); +EXPORT_SYMBOL_GPL(clk_gate_set_disable_ops); diff --git a/include/linux/clk.h b/include/linux/clk.h index cb1879b..d30314a 100644 --- a/include/linux/clk.h +++ b/include/linux/clk.h @@ -132,7 +132,8 @@ struct clk_gate { u8 bit_idx; }; -extern struct clk_hw_ops clk_gate_ops; +extern struct clk_hw_ops clk_gate_set_enable_ops; +extern struct clk_hw_ops clk_gate_set_disable_ops; #endif /* CONFIG_GENERIC_CLK_GATE */