From patchwork Thu Feb 23 16:00:48 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haojian Zhuang X-Patchwork-Id: 142653 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-qw0-f56.google.com (mail-qw0-f56.google.com [209.85.216.56]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 4DA66B6EF1 for ; Fri, 24 Feb 2012 02:47:29 +1100 (EST) Received: by qam2 with SMTP id 2sf1271710qam.11 for ; Thu, 23 Feb 2012 07:47:26 -0800 (PST) Received-SPF: pass (google.com: domain of rtc-linux+bncCObKqo_qFxCNv5n6BBoEd7nTZg@googlegroups.com designates 10.68.141.203 as permitted sender) client-ip=10.68.141.203; Authentication-Results: mr.google.com; spf=pass (google.com: domain of rtc-linux+bncCObKqo_qFxCNv5n6BBoEd7nTZg@googlegroups.com designates 10.68.141.203 as permitted sender) smtp.mail=rtc-linux+bncCObKqo_qFxCNv5n6BBoEd7nTZg@googlegroups.com; dkim=pass header.i=rtc-linux+bncCObKqo_qFxCNv5n6BBoEd7nTZg@googlegroups.com Received: from mr.google.com ([10.68.141.203]) by 10.68.141.203 with SMTP id rq11mr1622917pbb.13.1330012046334 (num_hops = 1); Thu, 23 Feb 2012 07:47:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=mime-version:x-beenthere:received-spf:from:to:cc:subject:date :message-id:x-mailer:in-reply-to:references:x-originalarrivaltime :x-original-sender:x-original-authentication-results:reply-to :precedence:mailing-list:list-id:x-google-group-id:list-post :list-help:list-archive:sender:list-subscribe:list-unsubscribe :content-type; bh=49DCZspHoK5NYARMxTwRSCTllAWusCasC3KKaAdXc58=; b=1nJcvvnpocy4srBJJ9vyPZIcq+6k1y7TdzyUiUH1IkS2G2ZsFdlI7logRW/i4ovQRv 8IQtR3ci7uXB23ywG/E7b3kswf3ZcUC2Rdv9/n/QGYR9MMZMpPrIo6JWXW6Nx7oBWooO BuOuTXPXkb8QJ/wmfpaBFU7Ju/rsviMFvX7nI= Received: by 10.68.141.203 with SMTP id rq11mr451170pbb.13.1330012045266; Thu, 23 Feb 2012 07:47:25 -0800 (PST) MIME-Version: 1.0 X-BeenThere: rtc-linux@googlegroups.com Received: by 10.68.219.2 with SMTP id pk2ls6035119pbc.5.gmail; Thu, 23 Feb 2012 07:47:25 -0800 (PST) Received: by 10.68.231.202 with SMTP id ti10mr1596274pbc.5.1330012044997; Thu, 23 Feb 2012 07:47:24 -0800 (PST) Received: by 10.68.231.202 with SMTP id ti10mr1596272pbc.5.1330012044986; Thu, 23 Feb 2012 07:47:24 -0800 (PST) Received: from na3sys009aog117.obsmtp.com ([74.125.149.242]) by gmr-mx.google.com with SMTP id p7si2442422pbq.0.2012.02.23.07.47.00; Thu, 23 Feb 2012 07:47:24 -0800 (PST) Received-SPF: temperror (google.com: error in processing during lookup of hzhuang1@marvell.com: DNS timeout) client-ip=74.125.149.242; Received: from MSI-MTA.marvell.com ([65.219.4.132]) by na3sys009aob117.postini.com ([74.125.148.12]) with SMTP ID DSNKT0Zfc7YobtXIjGq+gkorjwy+zp+Q7PVi@postini.com; Thu, 23 Feb 2012 07:47:24 PST Received: from maili.marvell.com ([10.68.76.210]) by MSI-MTA.marvell.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 23 Feb 2012 07:43:41 -0800 Received: from localhost (unknown [10.38.164.65]) by maili.marvell.com (Postfix) with ESMTP id 9F3954E4BC; Thu, 23 Feb 2012 07:43:41 -0800 (PST) From: Haojian Zhuang To: a.zummo@towertech.it, arnd@arndb.de, rtc-linux@googlegroups.com, robert.jarzmik@free.fr, plagnioj@jcrosoft.com, linux-arm-kernel@lists.infradead.org, linux@arm.linux.org.uk Cc: "Jett.Zhou" , Haojian Zhuang Subject: [rtc-linux] [PATCH v3 4/7] ARM: sa1100: clean up clock support Date: Fri, 24 Feb 2012 00:00:48 +0800 Message-Id: <1330012851-13693-5-git-send-email-haojian.zhuang@marvell.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1330012851-13693-1-git-send-email-haojian.zhuang@marvell.com> References: <1330012851-13693-1-git-send-email-haojian.zhuang@marvell.com> X-OriginalArrivalTime: 23 Feb 2012 15:43:41.0854 (UTC) FILETIME=[EB2183E0:01CCF241] X-Original-Sender: haojian.zhuang@marvell.com X-Original-Authentication-Results: gmr-mx.google.com; spf=temperror (google.com: error in processing during lookup of hzhuang1@marvell.com: DNS timeout) smtp.mail=hzhuang1@marvell.com Reply-To: rtc-linux@googlegroups.com Precedence: list Mailing-list: list rtc-linux@googlegroups.com; contact rtc-linux+owners@googlegroups.com List-ID: X-Google-Group-Id: 712029733259 List-Post: , List-Help: , List-Archive: Sender: rtc-linux@googlegroups.com List-Subscribe: , List-Unsubscribe: , From: Jett.Zhou Add rtc clock support and clean clock support for gpio. Signed-off-by: Jett.Zhou signed-off-by: Haojian Zhuang --- arch/arm/Kconfig | 2 +- arch/arm/mach-sa1100/clock.c | 63 ++++++++++++++++++++++++------------------ 2 files changed, 37 insertions(+), 28 deletions(-) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index a48aecc..6e40039 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -754,7 +754,7 @@ config ARCH_SA1100 select ARCH_HAS_CPUFREQ select CPU_FREQ select GENERIC_CLOCKEVENTS - select HAVE_CLK + select CLKDEV_LOOKUP select HAVE_SCHED_CLOCK select TICK_ONESHOT select ARCH_REQUIRE_GPIOLIB diff --git a/arch/arm/mach-sa1100/clock.c b/arch/arm/mach-sa1100/clock.c index dab3c63..97e2e06 100644 --- a/arch/arm/mach-sa1100/clock.c +++ b/arch/arm/mach-sa1100/clock.c @@ -11,17 +11,29 @@ #include #include #include +#include +#include #include -/* - * Very simple clock implementation - we only have one clock to deal with. - */ +struct clkops { + void (*enable)(struct clk *); + void (*disable)(struct clk *); +}; + struct clk { + const struct clkops *ops; unsigned int enabled; }; -static void clk_gpio27_enable(void) +#define DEFINE_CLK(_name, _ops) \ +struct clk clk_##_name = { \ + .ops = _ops, \ + } + +static DEFINE_SPINLOCK(clocks_lock); + +static void clk_gpio27_enable(struct clk *clk) { /* * First, set up the 3.6864MHz clock on GPIO 27 for the SA-1111: @@ -32,38 +44,22 @@ static void clk_gpio27_enable(void) TUCR = TUCR_3_6864MHz; } -static void clk_gpio27_disable(void) +static void clk_gpio27_disable(struct clk *clk) { TUCR = 0; GPDR &= ~GPIO_32_768kHz; GAFR &= ~GPIO_32_768kHz; } -static struct clk clk_gpio27; - -static DEFINE_SPINLOCK(clocks_lock); - -struct clk *clk_get(struct device *dev, const char *id) -{ - const char *devname = dev_name(dev); - - return strcmp(devname, "sa1111.0") ? ERR_PTR(-ENOENT) : &clk_gpio27; -} -EXPORT_SYMBOL(clk_get); - -void clk_put(struct clk *clk) -{ -} -EXPORT_SYMBOL(clk_put); - int clk_enable(struct clk *clk) { unsigned long flags; spin_lock_irqsave(&clocks_lock, flags); if (clk->enabled++ == 0) - clk_gpio27_enable(); + clk->ops->enable(clk); spin_unlock_irqrestore(&clocks_lock, flags); + return 0; } EXPORT_SYMBOL(clk_enable); @@ -76,13 +72,26 @@ void clk_disable(struct clk *clk) spin_lock_irqsave(&clocks_lock, flags); if (--clk->enabled == 0) - clk_gpio27_disable(); + clk->ops->disable(clk); spin_unlock_irqrestore(&clocks_lock, flags); } EXPORT_SYMBOL(clk_disable); -unsigned long clk_get_rate(struct clk *clk) +const struct clkops clk_gpio27_ops = { + .enable = clk_gpio27_enable, + .disable = clk_gpio27_disable, +}; + +static DEFINE_CLK(gpio27, &clk_gpio27_ops); + +static struct clk_lookup sa11xx_clkregs[] = { + CLKDEV_INIT("sa1111.0", NULL, &clk_gpio27), + CLKDEV_INIT("sa1100-rtc", NULL, NULL), +}; + +static int __init sa11xx_clk_init(void) { - return 3686400; + clkdev_add_table(sa11xx_clkregs, ARRAY_SIZE(sa11xx_clkregs)); + return 0; } -EXPORT_SYMBOL(clk_get_rate); +core_initcall(sa11xx_clk_init);