From patchwork Sun Jul 21 00:23:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Domenico Andreoli X-Patchwork-Id: 2830868 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3D8E2C0319 for ; Sun, 21 Jul 2013 00:54:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1D3BF20158 for ; Sun, 21 Jul 2013 00:54:16 +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 30F1520154 for ; Sun, 21 Jul 2013 00:54:14 +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 1V0htj-0003Re-AE; Sun, 21 Jul 2013 00:53:15 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V0htf-00045S-4U; Sun, 21 Jul 2013 00:53:11 +0000 Received: from mail-ee0-x234.google.com ([2a00:1450:4013:c00::234]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V0htQ-00042v-JU for linux-arm-kernel@lists.infradead.org; Sun, 21 Jul 2013 00:52:58 +0000 Received: by mail-ee0-f52.google.com with SMTP id c50so3091977eek.39 for ; Sat, 20 Jul 2013 17:52:34 -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=NMT68A8Cb/JZ4G+UZ5eP63tKpNbtDeJ2imr06NciIJs=; b=XPlJhyAXKyvZGd81EcFbzw+9/PdSkdUFTum8CddCoZ7YzgdkbNc6C08sMEJ1veyNHQ ioNMnxoAQ9qc/KbuyT8La0vYAYYGtDiK4FQsOlh1qBHw1VPDRzY9AWxXNfAh33aCB2Fc RLo888/1UdcZ4pTC2NEVxaFl5EZrQVUMkZ4zK9TmoGqBuRxbkpPNw5Lkk7/gZS6foOdQ ZogjTFfxXHmr72EBwqp8fk5Z98wvn/XdFxG0f4Y0U+IzC8AswBkMQAnmHGjDq7etGLDc zvlHep0kDJwXSd8PKgI+GrHx+yX+kUdtPd+VEmJB8FKYv7tCjBjNBHXWboNCExDWBbVb 6UXw== X-Received: by 10.15.102.68 with SMTP id bq44mr21728890eeb.89.1374367953989; Sat, 20 Jul 2013 17:52:33 -0700 (PDT) Received: from shock.dandreoli.com (j115181.upc-j.chello.nl. [24.132.115.181]) by mx.google.com with ESMTPSA id m1sm39090189eex.17.2013.07.20.17.52.31 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 20 Jul 2013 17:52:32 -0700 (PDT) Received: by shock.dandreoli.com (Postfix, from userid 1000) id 693ED340215; Sun, 21 Jul 2013 02:27:14 +0200 (CEST) Message-Id: <20130721002714.188757389@gmail.com> User-Agent: quilt/0.60-1 Date: Sun, 21 Jul 2013 02:23:23 +0200 From: Domenico Andreoli To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 3/5] ARM: bcm4760: Add ripple counter References: <20130721002320.730568671@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-20130720_205256_789176_5B006AC5 X-CRM114-Status: GOOD ( 16.21 ) X-Spam-Score: -1.9 (-) Cc: Russell King , Arnd Bergmann , Domenico Andreoli , John Stultz , Olof Johansson , Thomas Gleixner 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=-4.5 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. Cc: John Stultz Cc: Thomas Gleixner 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 void __iomem *to_load(struct bcm4760_timer *timer) { return timer->base + TIMER_LOAD_OFFSET; @@ -123,6 +139,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; @@ -164,6 +207,7 @@ static void __init bcm4760_init_time(str if (setup_irq(irq, &timer->act)) panic("Can't set up timer IRQ\n"); + bcm4760_ripple_counter_init(); clockevents_config_and_register(&timer->evt, freq, 0xf, 0xffffffff); } Index: b/arch/arm/boot/dts/bcm4760.dtsi =================================================================== --- a/arch/arm/boot/dts/bcm4760.dtsi +++ b/arch/arm/boot/dts/bcm4760.dtsi @@ -18,6 +18,11 @@ clock-frequency = <24000000>; }; + 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>;