From patchwork Wed Aug 14 22:10:47 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Domenico Andreoli X-Patchwork-Id: 2844823 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 85ABCBF546 for ; Wed, 14 Aug 2013 22:14:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8BB1520638 for ; Wed, 14 Aug 2013 22:14:11 +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 75D542061A for ; Wed, 14 Aug 2013 22:14:10 +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 1V9jJy-00017E-F3; Wed, 14 Aug 2013 22:13:39 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V9jJo-00084i-Er; Wed, 14 Aug 2013 22:13:28 +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 1V9jJQ-000818-Bo for linux-arm-kernel@lists.infradead.org; Wed, 14 Aug 2013 22:13:10 +0000 Received: by mail-ee0-f52.google.com with SMTP id c41so14179eek.39 for ; Wed, 14 Aug 2013 15:12:42 -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=JHpEeimjs2zF1yfHkXYBRoeZ/tDqXAdNsNtpx6B11m8=; b=eo8KEEQjPTteN2mPpgMNkO4JXB3rZFCv7KvIvJT/KhHhAhojUHuVOA2G2F/Ri1/0HC IatyBow7oJG+Ieg3z422KDEuotQ1B3lg8ee1jNkOFHOzxKJOGAhqGc2Nxthg92/xjvg5 KCLKLxZwWtv8O56rpGpBxmsodcusFxt2i+WRjg6P5D0uuvnpKp8l5ft5Ywwv/SmHW3OR lF9Rb89riLPWsDntLw+s0T8TlWbwvVWqX6ib1bxwehx3kJ9l8ltYC8PBX/3ciMAKw3pE 8reRTD3KdgF3KCK8qFXuYuDb837Z/uB3vShQE/crsb+1r3kZNCb58pHhaO7zl2Iq7udf xU8g== X-Received: by 10.14.176.8 with SMTP id a8mr17575750eem.12.1376518362045; Wed, 14 Aug 2013 15:12:42 -0700 (PDT) Received: from shock.dandreoli.com (j115181.upc-j.chello.nl. [24.132.115.181]) by mx.google.com with ESMTPSA id l47sm34391938eex.15.2013.08.14.15.12.39 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 14 Aug 2013 15:12:40 -0700 (PDT) Received: by shock.dandreoli.com (Postfix, from userid 1000) id 3FBC93402AF; Thu, 15 Aug 2013 00:12:38 +0200 (CEST) Message-Id: <20130814221237.976234473@gmail.com> User-Agent: quilt/0.60-1 Date: Thu, 15 Aug 2013 00:10:47 +0200 From: Domenico Andreoli To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 4/5] ARM: bcm4760: Add ripple counter References: <20130814221043.528864175@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-20130814_181304_609376_DE1665C9 X-CRM114-Status: GOOD ( 16.64 ) X-Spam-Score: -1.9 (-) Cc: Russell King - ARM Linux , 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=-6.9 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: * 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 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; @@ -157,6 +200,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 @@ -35,6 +35,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>;