From patchwork Mon May 11 16:34:13 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Francesco VIRLINZI X-Patchwork-Id: 23016 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n4BGYRRA018288 for ; Mon, 11 May 2009 16:34:28 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752052AbZEKQeZ (ORCPT ); Mon, 11 May 2009 12:34:25 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752917AbZEKQeZ (ORCPT ); Mon, 11 May 2009 12:34:25 -0400 Received: from eu1sys200aog103.obsmtp.com ([207.126.144.115]:51890 "EHLO eu1sys200aog103.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752052AbZEKQeZ (ORCPT ); Mon, 11 May 2009 12:34:25 -0400 Received: from source ([164.129.1.35]) (using TLSv1) by eu1sys200aob103.postini.com ([207.126.147.11]) with SMTP ID DSNKSghTkGgreJtgrDz8s8eNEmJ2SVMMbEjW@postini.com; Mon, 11 May 2009 16:34:26 UTC Received: from zeta.dmz-eu.st.com (ns2.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 02BC8DA70 for ; Mon, 11 May 2009 16:33:02 +0000 (GMT) Received: from mail3.ctn.st.com (mail3.ctn.st.com [164.130.116.150]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 9B6284C664 for ; Mon, 11 May 2009 16:34:23 +0000 (GMT) Received: from localhost (mdt-dhcp41.ctn.st.com [10.52.139.41]) by mail3.ctn.st.com (MOS 3.8.7a) with ESMTP id CRY09969 (AUTH virlinzi); Mon, 11 May 2009 18:34:23 +0200 (CEST) From: Francesco VIRLINZI To: linux-sh@vger.kernel.org Cc: Francesco Virlinzi Subject: [PATCH] sh: clkfw: Added the .set_rate_ex callback in the clock operation [v2] Date: Mon, 11 May 2009 18:34:13 +0200 Message-Id: <1242059653-21681-1-git-send-email-francesco.virlinzi@st.com> X-Mailer: git-send-email 1.6.0.6 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org This patch adds the .set_rate_ex callback to manage clearly the clk_set_rate() operation and the operation under clk_set_rate_ex(). Signed-off-by: Francesco Virlinzi --- arch/sh/include/asm/clock.h | 3 ++- arch/sh/kernel/cpu/clock.c | 22 +++++++++++++++++----- arch/sh/kernel/cpu/sh4/clock-sh4-202.c | 5 ++--- arch/sh/kernel/cpu/sh4a/clock-sh7722.c | 9 ++++----- 4 files changed, 25 insertions(+), 14 deletions(-) diff --git a/arch/sh/include/asm/clock.h b/arch/sh/include/asm/clock.h index b1f2919..ba9114b 100644 --- a/arch/sh/include/asm/clock.h +++ b/arch/sh/include/asm/clock.h @@ -13,7 +13,8 @@ struct clk_ops { void (*enable)(struct clk *clk); void (*disable)(struct clk *clk); void (*recalc)(struct clk *clk); - int (*set_rate)(struct clk *clk, unsigned long rate, int algo_id); + int (*set_rate)(struct clk *clk, unsigned long rate); + int (*set_rate_ex)(struct clk *clk, unsigned long rate, int algo_id); int (*set_parent)(struct clk *clk, struct clk *parent); long (*round_rate)(struct clk *clk, unsigned long rate); }; diff --git a/arch/sh/kernel/cpu/clock.c b/arch/sh/kernel/cpu/clock.c index 133dbe4..b2791ee 100644 --- a/arch/sh/kernel/cpu/clock.c +++ b/arch/sh/kernel/cpu/clock.c @@ -211,7 +211,20 @@ EXPORT_SYMBOL_GPL(clk_get_rate); int clk_set_rate(struct clk *clk, unsigned long rate) { - return clk_set_rate_ex(clk, rate, 0); + int ret = -EOPNOTSUPP; + + if (likely(clk->ops && clk->ops->set_rate)) { + unsigned long flags; + + spin_lock_irqsave(&clock_lock, flags); + ret = clk->ops->set_rate(clk, rate); + spin_unlock_irqrestore(&clock_lock, flags); + } + + if (unlikely(clk->flags & CLK_RATE_PROPAGATES)) + propagate_rate(clk); + + return ret; } EXPORT_SYMBOL_GPL(clk_set_rate); @@ -219,11 +232,11 @@ int clk_set_rate_ex(struct clk *clk, unsigned long rate, int algo_id) { int ret = -EOPNOTSUPP; - if (likely(clk->ops && clk->ops->set_rate)) { + if (likely(clk->ops && clk->ops->set_rate_ex)) { unsigned long flags; spin_lock_irqsave(&clock_lock, flags); - ret = clk->ops->set_rate(clk, rate, algo_id); + ret = clk->ops->set_rate_ex(clk, rate, algo_id); spin_unlock_irqrestore(&clock_lock, flags); } @@ -386,8 +399,7 @@ static int clks_sysdev_suspend(struct sys_device *dev, pm_message_t state) clkp->ops->set_parent(clkp, clkp->parent); if (likely(clkp->ops->set_rate)) - clkp->ops->set_rate(clkp, - rate, NO_CHANGE); + clkp->ops->set_rate(clkp, rate); else if (likely(clkp->ops->recalc)) clkp->ops->recalc(clkp); } diff --git a/arch/sh/kernel/cpu/sh4/clock-sh4-202.c b/arch/sh/kernel/cpu/sh4/clock-sh4-202.c index a334294..eb22dcc 100644 --- a/arch/sh/kernel/cpu/sh4/clock-sh4-202.c +++ b/arch/sh/kernel/cpu/sh4/clock-sh4-202.c @@ -82,8 +82,7 @@ static void shoc_clk_init(struct clk *clk) for (i = 0; i < ARRAY_SIZE(frqcr3_divisors); i++) { int divisor = frqcr3_divisors[i]; - if (clk->ops->set_rate(clk, clk->parent->rate / - divisor, 0) == 0) + if (clk->ops->set_rate(clk, clk->parent->rate / divisor) == 0) break; } @@ -111,7 +110,7 @@ static int shoc_clk_verify_rate(struct clk *clk, unsigned long rate) return 0; } -static int shoc_clk_set_rate(struct clk *clk, unsigned long rate, int algo_id) +static int shoc_clk_set_rate(struct clk *clk, unsigned long rate) { unsigned long frqcr3; unsigned int tmp; diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7722.c b/arch/sh/kernel/cpu/sh4a/clock-sh7722.c index 1ccdfc5..9546904 100644 --- a/arch/sh/kernel/cpu/sh4a/clock-sh7722.c +++ b/arch/sh/kernel/cpu/sh4a/clock-sh7722.c @@ -191,7 +191,7 @@ static void module_clk_recalc(struct clk *clk) #define FRQCRKICK 0x00000000 #endif -static int master_clk_setrate(struct clk *clk, unsigned long rate, int id) +static int master_clk_setrate(struct clk *clk, unsigned long rate) { int div = rate / clk->rate; int master_divs[] = MASTERDIVS; @@ -433,7 +433,7 @@ static long sh7722_frqcr_round_rate(struct clk *clk, unsigned long rate) static struct clk_ops sh7722_frqcr_clk_ops = { .recalc = sh7722_frqcr_recalc, - .set_rate = sh7722_frqcr_set_rate, + .set_rate_ex = sh7722_frqcr_set_rate, .round_rate = sh7722_frqcr_round_rate, }; @@ -444,7 +444,7 @@ static struct clk_ops sh7722_frqcr_clk_ops = { #ifndef CONFIG_CPU_SUBTYPE_SH7343 -static int sh7722_siu_set_rate(struct clk *clk, unsigned long rate, int algo_id) +static int sh7722_siu_set_rate(struct clk *clk, unsigned long rate) { unsigned long r; int div; @@ -513,8 +513,7 @@ static void sh7722_video_disable(struct clk *clk) ctrl_outl( r | (1<<8), VCLKCR); } -static int sh7722_video_set_rate(struct clk *clk, unsigned long rate, - int algo_id) +static int sh7722_video_set_rate(struct clk *clk, unsigned long rate) { unsigned long r;