.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (C) 2008 STMicroelectronics |
---|
3 | 4 | * Copyright (C) 2010 Alessandro Rubini |
---|
4 | 5 | * Copyright (C) 2010 Linus Walleij for ST-Ericsson |
---|
5 | | - * |
---|
6 | | - * This program is free software; you can redistribute it and/or modify |
---|
7 | | - * it under the terms of the GNU General Public License version 2, as |
---|
8 | | - * published by the Free Software Foundation. |
---|
9 | 6 | */ |
---|
10 | 7 | #include <linux/init.h> |
---|
11 | 8 | #include <linux/interrupt.h> |
---|
.. | .. |
---|
69 | 66 | static u32 nmdk_cycle; /* write-once */ |
---|
70 | 67 | static struct delay_timer mtu_delay_timer; |
---|
71 | 68 | |
---|
72 | | -#ifdef CONFIG_CLKSRC_NOMADIK_MTU_SCHED_CLOCK |
---|
73 | 69 | /* |
---|
74 | 70 | * Override the global weak sched_clock symbol with this |
---|
75 | 71 | * local implementation which uses the clocksource to get some |
---|
.. | .. |
---|
82 | 78 | |
---|
83 | 79 | return -readl(mtu_base + MTU_VAL(0)); |
---|
84 | 80 | } |
---|
85 | | -#endif |
---|
86 | 81 | |
---|
87 | 82 | static unsigned long nmdk_timer_read_current_timer(void) |
---|
88 | 83 | { |
---|
.. | .. |
---|
186 | 181 | return IRQ_HANDLED; |
---|
187 | 182 | } |
---|
188 | 183 | |
---|
189 | | -static struct irqaction nmdk_timer_irq = { |
---|
190 | | - .name = "Nomadik Timer Tick", |
---|
191 | | - .flags = IRQF_TIMER, |
---|
192 | | - .handler = nmdk_timer_interrupt, |
---|
193 | | - .dev_id = &nmdk_clkevt, |
---|
194 | | -}; |
---|
195 | | - |
---|
196 | 184 | static int __init nmdk_timer_init(void __iomem *base, int irq, |
---|
197 | 185 | struct clk *pclk, struct clk *clk) |
---|
198 | 186 | { |
---|
199 | 187 | unsigned long rate; |
---|
200 | 188 | int ret; |
---|
| 189 | + int min_ticks; |
---|
201 | 190 | |
---|
202 | 191 | mtu_base = base; |
---|
203 | 192 | |
---|
.. | .. |
---|
206 | 195 | |
---|
207 | 196 | /* |
---|
208 | 197 | * Tick rate is 2.4MHz for Nomadik and 2.4Mhz, 100MHz or 133 MHz |
---|
209 | | - * for ux500. |
---|
| 198 | + * for ux500, and in one specific Ux500 case 32768 Hz. |
---|
| 199 | + * |
---|
210 | 200 | * Use a divide-by-16 counter if the tick rate is more than 32MHz. |
---|
211 | 201 | * At 32 MHz, the timer (with 32 bit counter) can be programmed |
---|
212 | 202 | * to wake-up at a max 127s a head in time. Dividing a 2.4 MHz timer |
---|
.. | .. |
---|
234 | 224 | return ret; |
---|
235 | 225 | } |
---|
236 | 226 | |
---|
237 | | -#ifdef CONFIG_CLKSRC_NOMADIK_MTU_SCHED_CLOCK |
---|
238 | 227 | sched_clock_register(nomadik_read_sched_clock, 32, rate); |
---|
239 | | -#endif |
---|
240 | 228 | |
---|
241 | 229 | /* Timer 1 is used for events, register irq and clockevents */ |
---|
242 | | - setup_irq(irq, &nmdk_timer_irq); |
---|
| 230 | + if (request_irq(irq, nmdk_timer_interrupt, IRQF_TIMER, |
---|
| 231 | + "Nomadik Timer Tick", &nmdk_clkevt)) |
---|
| 232 | + pr_err("%s: request_irq() failed\n", "Nomadik Timer Tick"); |
---|
243 | 233 | nmdk_clkevt.cpumask = cpumask_of(0); |
---|
244 | 234 | nmdk_clkevt.irq = irq; |
---|
245 | | - clockevents_config_and_register(&nmdk_clkevt, rate, 2, 0xffffffffU); |
---|
| 235 | + if (rate < 100000) |
---|
| 236 | + min_ticks = 5; |
---|
| 237 | + else |
---|
| 238 | + min_ticks = 2; |
---|
| 239 | + clockevents_config_and_register(&nmdk_clkevt, rate, min_ticks, |
---|
| 240 | + 0xffffffffU); |
---|
246 | 241 | |
---|
247 | 242 | mtu_delay_timer.read_current_timer = &nmdk_timer_read_current_timer; |
---|
248 | 243 | mtu_delay_timer.freq = rate; |
---|