===================================================================
@@ -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>;
+};
===================================================================
@@ -19,6 +19,7 @@
#include <linux/slab.h>
#include <linux/interrupt.h>
#include <linux/clockchips.h>
+#include <linux/sched_clock.h>
#include <linux/of_address.h>
#include <linux/of_irq.h>
#include <linux/of_platform.h>
@@ -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;
===================================================================
@@ -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>;