===================================================================
@@ -0,0 +1,18 @@
+Broadcom BCM4760 and BCM4761 Ripple Counter device tree bindings
+----------------------------------------------------------------
+
+The BCM476x provides a 63-bit free running counter driven by a separate
+32kHz clock line.
+
+Required properties:
+
+- compatible : should be "brcm,bcm4760-ripple-counter" or
+ "brcm,bcm4761-ripple-counter".
+- reg : Specifies base physical address and size of the registers.
+
+Example:
+
+ripple-counter {
+ compatible = "brcm,bcm4760-ripple-counter";
+ reg = <0xbc000 0x1000>;
+};
===================================================================
@@ -24,6 +24,8 @@
#include <linux/of_platform.h>
#include <linux/bcm476x_timer.h>
+#include <asm/sched_clock.h>
+
#define TIMER_LOAD_OFFSET 0x00 /* load */
#define TIMER_VALUE_OFFSET 0x04 /* value */
#define TIMER_CONTROL_OFFSET 0x08 /* control */
@@ -47,6 +49,21 @@ struct bcm476x_timer {
struct irqaction act;
};
+static void __iomem *ripple_counter __read_mostly;
+
+static u32 notrace bcm476x_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 bcm476x_timer *timer)
{
return timer->base + TIMER_LOAD_OFFSET;
@@ -124,6 +141,34 @@ static irqreturn_t bcm476x_timer_interru
return IRQ_HANDLED;
}
+static const struct of_device_id bcm476x_ripple_counter_match[] __initconst = {
+ { .compatible = "brcm,bcm4760-ripple-counter" },
+ { .compatible = "brcm,bcm4761-ripple-counter" },
+ {}
+};
+
+static void __init bcm476x_ripple_counter_init(void)
+{
+ struct device_node *node;
+ void __iomem *base;
+ int rate = 32000;
+
+ node = of_find_matching_node(NULL, bcm476x_ripple_counter_match);
+ if (!node) {
+ pr_info("No bcm476x 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(bcm476x_sched_read, 32, rate);
+}
+
static const struct of_device_id bcm476x_timer_match[] __initconst = {
{ .compatible = "brcm,bcm4760-system-timer" },
{ .compatible = "brcm,bcm4761-system-timer" },
@@ -175,6 +220,7 @@ static void __init bcm476x_timer_init(vo
if (setup_irq(irq, &timer->act))
panic("Can't set up timer IRQ\n");
+ bcm476x_ripple_counter_init();
clockevents_config_and_register(&timer->evt, freq, 0xf, 0xffffffff);
}
===================================================================
@@ -18,6 +18,12 @@
clock-frequency = <24000000>;
};
+ ripple-counter {
+ compatible = "brcm,bcm4760-ripple-counter";
+ reg = <0xbc000 0x1000>;
+ clock-frequency = <32000>;
+ };
+
vic0: interrupt-controller@80000 {
compatible = "brcm,bcm4760-pl192", "arm,pl192-vic", "arm,primecell";
reg = <0x80000 0x1000>;
===================================================================
@@ -18,6 +18,12 @@
clock-frequency = <24000000>;
};
+ ripple-counter {
+ compatible = "brcm,bcm4761-ripple-counter";
+ reg = <0xbc000 0x1000>;
+ clock-frequency = <32000>;
+ };
+
vic0: interrupt-controller@80000 {
compatible = "brcm,bcm4761-pl192", "arm,pl192-vic", "arm,primecell";
reg = <0x80000 0x1000>;