diff options
author | Maxime Ripard <maxime.ripard@free-electrons.com> | 2013-07-16 10:45:37 -0400 |
---|---|---|
committer | Daniel Lezcano <daniel.lezcano@linaro.org> | 2013-07-18 09:27:15 -0400 |
commit | 137c6b3c7c63944a9cb51de0870b72f62d240f62 (patch) | |
tree | 35f7bc2835c2be7cb5e6dd0aa190b1537b527146 /drivers/clocksource | |
parent | 9eded23215e99338155c18f6d860859106568bb0 (diff) |
clocksource: sun4i: Add clocksource and sched clock drivers
Use the second timer found on the Allwinner SoCs as a clock source and
sched clock, that were both not used yet on these platforms.
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Diffstat (limited to 'drivers/clocksource')
-rw-r--r-- | drivers/clocksource/sun4i_timer.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/clocksource/sun4i_timer.c b/drivers/clocksource/sun4i_timer.c index f5e227b06ad5..b581c93f20b3 100644 --- a/drivers/clocksource/sun4i_timer.c +++ b/drivers/clocksource/sun4i_timer.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/interrupt.h> | 19 | #include <linux/interrupt.h> |
20 | #include <linux/irq.h> | 20 | #include <linux/irq.h> |
21 | #include <linux/irqreturn.h> | 21 | #include <linux/irqreturn.h> |
22 | #include <linux/sched_clock.h> | ||
22 | #include <linux/of.h> | 23 | #include <linux/of.h> |
23 | #include <linux/of_address.h> | 24 | #include <linux/of_address.h> |
24 | #include <linux/of_irq.h> | 25 | #include <linux/of_irq.h> |
@@ -96,6 +97,11 @@ static struct irqaction sun4i_timer_irq = { | |||
96 | .dev_id = &sun4i_clockevent, | 97 | .dev_id = &sun4i_clockevent, |
97 | }; | 98 | }; |
98 | 99 | ||
100 | static u32 sun4i_timer_sched_read(void) | ||
101 | { | ||
102 | return ~readl(timer_base + TIMER_CNTVAL_REG(1)); | ||
103 | } | ||
104 | |||
99 | static void __init sun4i_timer_init(struct device_node *node) | 105 | static void __init sun4i_timer_init(struct device_node *node) |
100 | { | 106 | { |
101 | unsigned long rate = 0; | 107 | unsigned long rate = 0; |
@@ -117,6 +123,15 @@ static void __init sun4i_timer_init(struct device_node *node) | |||
117 | 123 | ||
118 | rate = clk_get_rate(clk); | 124 | rate = clk_get_rate(clk); |
119 | 125 | ||
126 | writel(~0, timer_base + TIMER_INTVAL_REG(1)); | ||
127 | writel(TIMER_CTL_ENABLE | TIMER_CTL_RELOAD | | ||
128 | TIMER_CTL_CLK_SRC(TIMER_CTL_CLK_SRC_OSC24M), | ||
129 | timer_base + TIMER_CTL_REG(1)); | ||
130 | |||
131 | setup_sched_clock(sun4i_timer_sched_read, 32, rate); | ||
132 | clocksource_mmio_init(timer_base + TIMER_CNTVAL_REG(1), node->name, | ||
133 | rate, 300, 32, clocksource_mmio_readl_down); | ||
134 | |||
120 | writel(rate / (TIMER_SCAL * HZ), | 135 | writel(rate / (TIMER_SCAL * HZ), |
121 | timer_base + TIMER_INTVAL_REG(0)); | 136 | timer_base + TIMER_INTVAL_REG(0)); |
122 | 137 | ||