Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Joel Stanley and committed by
Daniel Lezcano
ba36d53d 82fdd070

+35 -1
+3 -1
Documentation/devicetree/bindings/timer/moxa,moxart-timer.txt
··· 2 2 3 3 Required properties: 4 4 5 - - compatible : Must be "moxa,moxart-timer" 5 + - compatible : Must be one of: 6 + - "moxa,moxart-timer" 7 + - "aspeed,ast2400-timer" 6 8 - reg : Should contain registers location and length 7 9 - interrupts : Should contain the timer interrupt number 8 10 - clocks : Should contain phandle for the clock that drives the counter
+32
drivers/clocksource/moxart_timer.c
··· 56 56 #define MOXART_TIMER1_ENABLE (MOXART_CR_2_ENABLE | MOXART_CR_1_ENABLE) 57 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 76 struct moxart_timer { 60 77 void __iomem *base; 61 78 unsigned int t1_disable_val; ··· 182 165 if (of_device_is_compatible(node, "moxa,moxart-timer")) { 183 166 timer->t1_enable_val = MOXART_TIMER1_ENABLE; 184 167 timer->t1_disable_val = MOXART_TIMER1_DISABLE; 168 + } else if (of_device_is_compatible(node, "aspeed,ast2400-timer")) { 169 + timer->t1_enable_val = ASPEED_TIMER1_ENABLE; 170 + timer->t1_disable_val = ASPEED_TIMER1_DISABLE; 185 171 } else 186 172 panic("%s: unknown platform\n", node->full_name); 187 173 ··· 220 200 return ret; 221 201 } 222 202 203 + /* Clear match registers */ 204 + writel(0, timer->base + TIMER1_BASE + REG_MATCH1); 205 + writel(0, timer->base + TIMER1_BASE + REG_MATCH2); 206 + writel(0, timer->base + TIMER2_BASE + REG_MATCH1); 207 + writel(0, timer->base + TIMER2_BASE + REG_MATCH2); 208 + 209 + /* 210 + * Start timer 2 rolling as our main wall clock source, keep timer 1 211 + * disabled 212 + */ 213 + writel(0, timer->base + TIMER_CR); 223 214 writel(~0, timer->base + TIMER2_BASE + REG_LOAD); 224 215 writel(timer->t1_disable_val, timer->base + TIMER_CR); 225 216 ··· 245 214 return 0; 246 215 } 247 216 CLOCKSOURCE_OF_DECLARE(moxart, "moxa,moxart-timer", moxart_timer_init); 217 + CLOCKSOURCE_OF_DECLARE(aspeed, "aspeed,ast2400-timer", moxart_timer_init);