From patchwork Wed Mar 11 07:40:54 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Francesco VIRLINZI X-Patchwork-Id: 11073 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 n2B7f348004312 for ; Wed, 11 Mar 2009 07:41:04 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751248AbZCKHlE (ORCPT ); Wed, 11 Mar 2009 03:41:04 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751393AbZCKHlD (ORCPT ); Wed, 11 Mar 2009 03:41:03 -0400 Received: from eu1sys200aog113.obsmtp.com ([207.126.144.135]:52621 "EHLO eu1sys200aog113.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751248AbZCKHlB (ORCPT ); Wed, 11 Mar 2009 03:41:01 -0400 Received: from source ([164.129.1.35]) (using TLSv1) by eu1sys200aob113.postini.com ([207.126.147.11]) with SMTP ID DSNKSbdrCuIRDdgvVeM3/qHd5fogKMPjegcz@postini.com; Wed, 11 Mar 2009 07:41:00 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 4B8EEDA7B for ; Wed, 11 Mar 2009 07:40:02 +0000 (GMT) Received: from mail1.ctn.st.com (mail1.ctn.st.com [164.130.116.128]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id C04C74BE85 for ; Wed, 11 Mar 2009 07:40:57 +0000 (GMT) Received: from [10.52.139.41] (mdt-dhcp41.ctn.st.com [10.52.139.41]) by mail1.ctn.st.com (MOS 3.8.7a) with ESMTP id CZV34844 (AUTH virlinzi); Wed, 11 Mar 2009 08:40:57 +0100 (CET) Message-ID: <49B76B06.50602@st.com> Date: Wed, 11 Mar 2009 08:40:54 +0100 From: Francesco VIRLINZI User-Agent: Thunderbird 2.0.0.19 (X11/20090105) MIME-Version: 1.0 To: linux-sh@vger.kernel.org Subject: [PATCH] sh_clk: added clk_set_parent/clk_get_parent v2 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org From 96d7aa00af83ecb4a3660ace507221b959aa12f1 Mon Sep 17 00:00:00 2001 From: Francesco Virlinzi Date: Wed, 11 Mar 2009 08:09:16 +0100 Subject: [PATCH] sh_clk: Add clk_set_parent/clk_get_parent support This patch adds the clk_set_parent/clk_get_parent in the sh clock framework Signed-off-by: Francesco Virlinzi --- arch/sh/include/asm/clock.h | 1 + arch/sh/kernel/cpu/clock.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 0 deletions(-) diff --git a/arch/sh/include/asm/clock.h b/arch/sh/include/asm/clock.h index f9c8858..2f6c962 100644 --- a/arch/sh/include/asm/clock.h +++ b/arch/sh/include/asm/clock.h @@ -15,6 +15,7 @@ struct clk_ops { void (*disable)(struct clk *clk); void (*recalc)(struct clk *clk); int (*set_rate)(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 7b17137..332a179 100644 --- a/arch/sh/kernel/cpu/clock.c +++ b/arch/sh/kernel/cpu/clock.c @@ -239,6 +239,35 @@ void clk_recalc_rate(struct clk *clk) } EXPORT_SYMBOL_GPL(clk_recalc_rate); +int clk_set_parent(struct clk *clk, struct clk *parent) +{ + int ret = -EINVAL; + struct clk *old; + + if (!parent || !clk) + return ret; + + old = clk->parent; + if (likely(clk->ops && clk->ops->set_parent)) { + unsigned long flags; + spin_lock_irqsave(&clock_lock, flags); + ret = clk->ops->set_parent(clk, parent); + spin_unlock_irqrestore(&clock_lock, flags); + clk->parent = (ret ? old : parent); + } + + if (unlikely(clk->flags & CLK_RATE_PROPAGATES)) + propagate_rate(clk); + return ret; +} +EXPORT_SYMBOL_GPL(clk_set_parent); + +struct clk *clk_get_parent(struct clk *clk) +{ + return clk->parent; +} +EXPORT_SYMBOL_GPL(clk_get_parent); + long clk_round_rate(struct clk *clk, unsigned long rate) { if (likely(clk->ops && clk->ops->round_rate)) { -- 1.5.6.6