From patchwork Sat Sep 14 15:20:35 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Domenico Andreoli X-Patchwork-Id: 2893471 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 293109F1C0 for ; Sat, 14 Sep 2013 15:22:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3C8E820263 for ; Sat, 14 Sep 2013 15:22:33 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C4FE120258 for ; Sat, 14 Sep 2013 15:22:31 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VKrfm-0007Yc-5g; Sat, 14 Sep 2013 15:22:10 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VKrfh-0004t5-Lk; Sat, 14 Sep 2013 15:22:05 +0000 Received: from mail-ee0-x22e.google.com ([2a00:1450:4013:c00::22e]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VKrfS-0004qx-1R for linux-arm-kernel@lists.infradead.org; Sat, 14 Sep 2013 15:21:53 +0000 Received: by mail-ee0-f46.google.com with SMTP id c13so1150435eek.5 for ; Sat, 14 Sep 2013 08:21:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:user-agent:date:from:to:cc:subject:references :content-disposition; bh=RjF7m0HuPnWqrxA4lX9UlKfXhaNa7w+pr0baSYFvQhg=; b=r6QEep0S/vYh9HS24dIWHJk6fzG+CaGF2JmYnAGrBU1+kFSS+2oJ4ePKt+K88a4gEE c4EE6f+Nnct8zU3UarH3DP7GD4x5xciA0vEf4s270R+QhVmjvf9Fzk7wfOdZp0FifM5p afOom64N/hdmAJv8s8yApuWUeJoxXy+J+G4ZmiPGSSfMsJf/LiTo6qFknKR6M6/etCoP R/7TpD2lEh/o6prQaPlrBameedzKw6uO3yj7OePL6vbV9UtrJg0q0Zh65GF7Kio+Ek+q 3YlHhhHLfQxqbSRc2wy117jJlVDslLuI7+V/7PSagEwaPh6Bsvs8qsxEwUgqTqa2Hbd4 PQ8w== X-Received: by 10.14.210.8 with SMTP id t8mr26855938eeo.39.1379172088108; Sat, 14 Sep 2013 08:21:28 -0700 (PDT) Received: from shock.dandreoli.com (j115181.upc-j.chello.nl. [24.132.115.181]) by mx.google.com with ESMTPSA id a6sm24882270eei.10.1969.12.31.16.00.00 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 14 Sep 2013 08:21:27 -0700 (PDT) Received: by shock.dandreoli.com (Postfix, from userid 1000) id 487F93401ED; Sat, 14 Sep 2013 17:21:24 +0200 (CEST) Message-Id: <20130914152124.062337974@gmail.com> User-Agent: quilt/0.60-1 Date: Sat, 14 Sep 2013 17:20:35 +0200 From: Domenico Andreoli To: Russell King - ARM Linux , Olof Johansson , Arnd Bergmann Subject: [PATCH v4 3/4] ARM: bcm4760: Add ripple counter References: <20130914152032.401907974@gmail.com> Content-Disposition: inline; filename=arm-bcm476x-add-ripple-counter.patch X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130914_112150_282593_707B1191 X-CRM114-Status: GOOD ( 16.92 ) X-Spam-Score: -1.9 (-) Cc: Domenico Andreoli , Thomas Gleixner , John Stultz , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Domenico Andreoli The BCM4760's free runner counter is used as sched clock source. v2,v3,v4: * unchanged v1: * initial release Cc: John Stultz Cc: Thomas Gleixner Cc: devicetree@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Signed-off-by: Domenico Andreoli --- Documentation/devicetree/bindings/timer/brcm,bcm4760-ripple-counter.txt | 17 ++++ arch/arm/boot/dts/bcm4760.dtsi | 5 + drivers/clocksource/bcm4760_timer.c | 44 ++++++++++ 3 files changed, 66 insertions(+) Index: b/Documentation/devicetree/bindings/timer/brcm,bcm4760-ripple-counter.txt =================================================================== --- /dev/null +++ b/Documentation/devicetree/bindings/timer/brcm,bcm4760-ripple-counter.txt @@ -0,0 +1,17 @@ +Broadcom BCM4760 Ripple Counter device tree bindings +---------------------------------------------------- + +The BCM4760 provides a 63-bit free running counter driven by a separate +32kHz clock line. + +Required properties: + +- compatible : should be "brcm,bcm4760-ripple-counter" +- reg : Specifies base physical address and size of the registers. + +Example: + +ripple-counter { + compatible = "brcm,bcm4760-ripple-counter"; + reg = <0xbc000 0x1000>; +}; Index: b/drivers/clocksource/bcm4760_timer.c =================================================================== --- a/drivers/clocksource/bcm4760_timer.c +++ b/drivers/clocksource/bcm4760_timer.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -46,6 +47,21 @@ struct bcm4760_timer { struct irqaction act; }; +static void __iomem *ripple_counter __read_mostly; + +static u32 notrace bcm4760_sched_read(void) +{ + u32 lo, hi; + + /* access to the counter must happen in the lo-hi order even if + * only the lower 32-bit part is of interest + */ + lo = readl(ripple_counter); + hi = readl(ripple_counter + 4); + + return lo; +} + static inline u32 bcm4760_readl(struct bcm4760_timer *timer, unsigned long reg) { return readl(timer->base + reg); @@ -105,6 +121,33 @@ static irqreturn_t bcm4760_timer_interru return IRQ_HANDLED; } +static const struct of_device_id bcm4760_ripple_counter_match[] __initconst = { + { .compatible = "brcm,bcm4760-ripple-counter" }, + {}, +}; + +static void __init bcm4760_ripple_counter_init(void) +{ + struct device_node *node; + void __iomem *base; + int rate = 32000; + + node = of_find_matching_node(NULL, bcm4760_ripple_counter_match); + if (!node) { + pr_info("No bcm4760 ripple counter node"); + return; + } + + base = of_iomap(node, 0); + if (!base) { + pr_err("Can't remap ripple counter registers"); + return; + } + + ripple_counter = base; + setup_sched_clock(bcm4760_sched_read, 32, rate); +} + static void __init bcm4760_init_time(struct device_node *node) { void __iomem *base; @@ -133,6 +176,7 @@ static void __init bcm4760_init_time(str timer->evt.set_next_event = bcm4760_timer_set_next_event; timer->evt.cpumask = cpumask_of(0); + bcm4760_ripple_counter_init(); clockevents_config_and_register(&timer->evt, freq, 0xf, 0xffffffff); timer->act.name = node->name; Index: b/arch/arm/boot/dts/bcm4760.dtsi =================================================================== --- a/arch/arm/boot/dts/bcm4760.dtsi +++ b/arch/arm/boot/dts/bcm4760.dtsi @@ -34,6 +34,11 @@ interrupts = <4>, <11>; }; + ripple-counter { + compatible = "brcm,bcm4760-ripple-counter"; + reg = <0xbc000 0x1000>; + }; + vic0: interrupt-controller@80000 { compatible = "brcm,bcm4760-pl192", "arm,pl192-vic", "arm,primecell"; reg = <0x80000 0x1000>;