From patchwork Thu Dec 15 01:24:53 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Zhao X-Patchwork-Id: 5738 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 9252B23E04 for ; Thu, 15 Dec 2011 01:25:15 +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 89247A180EC for ; Thu, 15 Dec 2011 01:25:15 +0000 (UTC) Received: by mail-ey0-f180.google.com with SMTP id k10so1519937eaa.11 for ; Wed, 14 Dec 2011 17:25:15 -0800 (PST) Received: by 10.204.131.74 with SMTP id w10mr262889bks.36.1323912315352; Wed, 14 Dec 2011 17:25:15 -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 hg2cs25771bkc; Wed, 14 Dec 2011 17:25:15 -0800 (PST) Received: by 10.52.74.163 with SMTP id u3mr927722vdv.91.1323912313204; Wed, 14 Dec 2011 17:25:13 -0800 (PST) Received: from ch1outboundpool.messaging.microsoft.com (ch1ehsobe001.messaging.microsoft.com. [216.32.181.181]) by mx.google.com with ESMTPS id j2si2205089vdv.11.2011.12.14.17.25.12 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 14 Dec 2011 17:25:13 -0800 (PST) Received-SPF: neutral (google.com: 216.32.181.181 is neither permitted nor denied by best guess record for domain of B20223@freescale.com) client-ip=216.32.181.181; Authentication-Results: mx.google.com; spf=neutral (google.com: 216.32.181.181 is neither permitted nor denied by best guess record for domain of B20223@freescale.com) smtp.mail=B20223@freescale.com Received: from mail168-ch1-R.bigfish.com (10.43.68.244) by CH1EHSOBE003.bigfish.com (10.43.70.53) with Microsoft SMTP Server id 14.1.225.23; Thu, 15 Dec 2011 01:25:13 +0000 Received: from mail168-ch1 (localhost [127.0.0.1]) by mail168-ch1-R.bigfish.com (Postfix) with ESMTP id 69D951600FC; Thu, 15 Dec 2011 01:25:16 +0000 (UTC) X-SpamScore: 0 X-BigFish: VS0(zzzz1202hzz8275dhz2dh2a8h668h839h) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-FB-SS: 13, Received: from mail168-ch1 (localhost.localdomain [127.0.0.1]) by mail168-ch1 (MessageSwitch) id 1323912316300300_18552; Thu, 15 Dec 2011 01:25:16 +0000 (UTC) Received: from CH1EHSMHS017.bigfish.com (snatpool1.int.messaging.microsoft.com [10.43.68.242]) by mail168-ch1.bigfish.com (Postfix) with ESMTP id 3A56E100042; Thu, 15 Dec 2011 01:25:16 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by CH1EHSMHS017.bigfish.com (10.43.70.17) with Microsoft SMTP Server (TLS) id 14.1.225.23; Thu, 15 Dec 2011 01:25:13 +0000 Received: from az33smr01.freescale.net (10.64.34.199) by 039-SN1MMR1-002.039d.mgd.msft.net (10.84.1.15) with Microsoft SMTP Server id 14.1.355.3; Wed, 14 Dec 2011 19:25:10 -0600 Received: from b20223-02.ap.freescale.net (b20223-02.ap.freescale.net [10.192.242.124]) by az33smr01.freescale.net (8.13.1/8.13.0) with ESMTP id pBF1OvgL018541; Wed, 14 Dec 2011 19:25:08 -0600 (CST) From: Richard Zhao To: CC: , Sascha Hauer , Richard Zhao Subject: [RFC V2 6/8] ARM i.MX: prepare common clk support Date: Thu, 15 Dec 2011 09:24:53 +0800 Message-ID: <1323912295-21144-6-git-send-email-richard.zhao@freescale.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1323912295-21144-1-git-send-email-richard.zhao@freescale.com> References: <1323854638-3455-1-git-send-email-richard.zhao@linaro.org> <1323912295-21144-1-git-send-email-richard.zhao@freescale.com> MIME-Version: 1.0 X-OriginatorOrg: freescale.com From: Sascha Hauer Add static clock help macros, clock register spinlock. Signed-off-by: Sascha Hauer Signed-off-by: Richard Zhao --- arch/arm/plat-mxc/clock.c | 8 ++++++ arch/arm/plat-mxc/include/mach/clock.h | 42 +++++++++++++++++++++++++++++-- 2 files changed, 47 insertions(+), 3 deletions(-) diff --git a/arch/arm/plat-mxc/clock.c b/arch/arm/plat-mxc/clock.c index 2ed3ab1..1973b30 100644 --- a/arch/arm/plat-mxc/clock.c +++ b/arch/arm/plat-mxc/clock.c @@ -41,6 +41,8 @@ #include #include +#ifndef CONFIG_GENERIC_CLK + static LIST_HEAD(clocks); static DEFINE_MUTEX(clocks_mutex); @@ -199,6 +201,7 @@ struct clk *clk_get_parent(struct clk *clk) return clk->parent; } EXPORT_SYMBOL(clk_get_parent); +#endif /* * Get the resulting clock rate from a PLL register value and the input @@ -244,3 +247,8 @@ unsigned long mxc_decode_pll(unsigned int reg_val, u32 freq) return ll; } + +#ifdef CONFIG_GENERIC_CLK +DEFINE_SPINLOCK(imx_ccm_lock); +EXPORT_SYMBOL_GPL(imx_ccm_lock); +#endif /* CONFIG_USE_COMMON_STRUCT_CLK */ diff --git a/arch/arm/plat-mxc/include/mach/clock.h b/arch/arm/plat-mxc/include/mach/clock.h index f62256e..500879b 100644 --- a/arch/arm/plat-mxc/include/mach/clock.h +++ b/arch/arm/plat-mxc/include/mach/clock.h @@ -81,9 +81,13 @@ struct clk_pllv2 { extern struct clk_hw_ops clk_pllv2_ops; -#define DEFINE_CLK_PLLV2(name, _parent, _base) \ - struct clk_pllv2 name = { \ - .parent = (_parent), \ +#define DEFINE_CLK_PLLV2(_name, _parent, _base) \ + struct clk_pllv2 _name = { \ + .clk = { \ + .name = #_name, \ + .ops = &clk_pllv2_ops, \ + .parent = _parent, \ + }, \ .base = (_base), \ } @@ -109,6 +113,38 @@ extern struct clk_hw_ops clk_gate2b_ops; int clk_gate2b_set_val(struct clk *clk, int en, int dis); +extern spinlock_t imx_ccm_lock; + +#define DEFINE_CLK_GATE2B(_name, _parent, _reg, _shift) \ + struct clk_gate2b _name = { \ + .clk = { \ + .name = #_name, \ + .ops = &clk_gate2b_ops, \ + .parent = _parent, \ + }, \ + .reg = (_reg), \ + .shift = (_shift) * 2, \ + .val_en = 0x3, \ + .val_dis = 0x0, \ + .lock = &imx_ccm_lock, \ + } + +#define IMX_DEFINE_CLK_DIVIDER(_name, _parent, _flags, _reg, _shift, _width) \ + DEFINE_CLK_DIVIDER(_name, _parent, _flags, _reg, _shift, _width, \ + &imx_ccm_lock) + +#define IMX_DEFINE_CLK_MUX(_name, _reg, _shift, _width, _clks) \ + DEFINE_CLK_MUX(_name, _reg, _shift, _width, _clks, &imx_ccm_lock) + +#define DEFINE_CLK_FIXED(_name, _rate) \ + struct clk_hw_fixed _name = { \ + .clk = { \ + .name = #_name, \ + .ops = &clk_hw_fixed_ops, \ + }, \ + .fixed_rate = (_rate), \ + } + #endif /* CONFIG_GENERIC_CLK */ #endif /* __ASSEMBLY__ */ #endif /* __ASM_ARCH_MXC_CLOCK_H__ */