diff options
author | Joel Stanley <joel@jms.id.au> | 2016-07-21 09:43:53 -0400 |
---|---|---|
committer | Daniel Lezcano <daniel.lezcano@linaro.org> | 2016-09-09 08:15:47 -0400 |
commit | ba36d53db536d31c49c139484e82581eeb377278 (patch) | |
tree | ac9206e0f0e095cabb7cc02f255973ba7579734f /drivers/clocksource/moxart_timer.c | |
parent | 82fdd070873f7ac9b3e37b3d4523b4ae27d02e50 (diff) |
clocksource/drivers/moxart: Add Aspeed support
The Aspeed SoC has timer IP with a very similar register layout to the
moxart timer. This patch adds support for the fourth and fifth gen
aspeed SoCs, and has been tested on the ast2400 and ast2500.
Signed-off-by: Joel Stanley <joel@jms.id.au>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Diffstat (limited to 'drivers/clocksource/moxart_timer.c')
-rw-r--r-- | drivers/clocksource/moxart_timer.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/drivers/clocksource/moxart_timer.c b/drivers/clocksource/moxart_timer.c index cb0b34786a8e..ad2bead9ce45 100644 --- a/drivers/clocksource/moxart_timer.c +++ b/drivers/clocksource/moxart_timer.c | |||
@@ -56,6 +56,23 @@ | |||
56 | #define MOXART_TIMER1_ENABLE (MOXART_CR_2_ENABLE | MOXART_CR_1_ENABLE) | 56 | #define MOXART_TIMER1_ENABLE (MOXART_CR_2_ENABLE | MOXART_CR_1_ENABLE) |
57 | #define MOXART_TIMER1_DISABLE (MOXART_CR_2_ENABLE) | 57 | #define MOXART_TIMER1_DISABLE (MOXART_CR_2_ENABLE) |
58 | 58 | ||
59 | /* | ||
60 | * The ASpeed variant of the IP block has a different layout | ||
61 | * for the control register | ||
62 | */ | ||
63 | #define ASPEED_CR_1_ENABLE BIT(0) | ||
64 | #define ASPEED_CR_1_CLOCK BIT(1) | ||
65 | #define ASPEED_CR_1_INT BIT(2) | ||
66 | #define ASPEED_CR_2_ENABLE BIT(4) | ||
67 | #define ASPEED_CR_2_CLOCK BIT(5) | ||
68 | #define ASPEED_CR_2_INT BIT(6) | ||
69 | #define ASPEED_CR_3_ENABLE BIT(8) | ||
70 | #define ASPEED_CR_3_CLOCK BIT(9) | ||
71 | #define ASPEED_CR_3_INT BIT(10) | ||
72 | |||
73 | #define ASPEED_TIMER1_ENABLE (ASPEED_CR_2_ENABLE | ASPEED_CR_1_ENABLE) | ||
74 | #define ASPEED_TIMER1_DISABLE (ASPEED_CR_2_ENABLE) | ||
75 | |||
59 | struct moxart_timer { | 76 | struct moxart_timer { |
60 | void __iomem *base; | 77 | void __iomem *base; |
61 | unsigned int t1_disable_val; | 78 | unsigned int t1_disable_val; |
@@ -165,6 +182,9 @@ static int __init moxart_timer_init(struct device_node *node) | |||
165 | if (of_device_is_compatible(node, "moxa,moxart-timer")) { | 182 | if (of_device_is_compatible(node, "moxa,moxart-timer")) { |
166 | timer->t1_enable_val = MOXART_TIMER1_ENABLE; | 183 | timer->t1_enable_val = MOXART_TIMER1_ENABLE; |
167 | timer->t1_disable_val = MOXART_TIMER1_DISABLE; | 184 | timer->t1_disable_val = MOXART_TIMER1_DISABLE; |
185 | } else if (of_device_is_compatible(node, "aspeed,ast2400-timer")) { | ||
186 | timer->t1_enable_val = ASPEED_TIMER1_ENABLE; | ||
187 | timer->t1_disable_val = ASPEED_TIMER1_DISABLE; | ||
168 | } else | 188 | } else |
169 | panic("%s: unknown platform\n", node->full_name); | 189 | panic("%s: unknown platform\n", node->full_name); |
170 | 190 | ||
@@ -200,6 +220,17 @@ static int __init moxart_timer_init(struct device_node *node) | |||
200 | return ret; | 220 | return ret; |
201 | } | 221 | } |
202 | 222 | ||
223 | /* Clear match registers */ | ||
224 | writel(0, timer->base + TIMER1_BASE + REG_MATCH1); | ||
225 | writel(0, timer->base + TIMER1_BASE + REG_MATCH2); | ||
226 | writel(0, timer->base + TIMER2_BASE + REG_MATCH1); | ||
227 | writel(0, timer->base + TIMER2_BASE + REG_MATCH2); | ||
228 | |||
229 | /* | ||
230 | * Start timer 2 rolling as our main wall clock source, keep timer 1 | ||
231 | * disabled | ||
232 | */ | ||
233 | writel(0, timer->base + TIMER_CR); | ||
203 | writel(~0, timer->base + TIMER2_BASE + REG_LOAD); | 234 | writel(~0, timer->base + TIMER2_BASE + REG_LOAD); |
204 | writel(timer->t1_disable_val, timer->base + TIMER_CR); | 235 | writel(timer->t1_disable_val, timer->base + TIMER_CR); |
205 | 236 | ||
@@ -214,3 +245,4 @@ static int __init moxart_timer_init(struct device_node *node) | |||
214 | return 0; | 245 | return 0; |
215 | } | 246 | } |
216 | CLOCKSOURCE_OF_DECLARE(moxart, "moxa,moxart-timer", moxart_timer_init); | 247 | CLOCKSOURCE_OF_DECLARE(moxart, "moxa,moxart-timer", moxart_timer_init); |
248 | CLOCKSOURCE_OF_DECLARE(aspeed, "aspeed,ast2400-timer", moxart_timer_init); | ||