summaryrefslogtreecommitdiffstats
path: root/arch/nios2
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2016-07-07 09:41:13 -0400
committerThomas Gleixner <tglx@linutronix.de>2016-07-07 09:41:13 -0400
commit3d93f42d449ace8e2dd8e2ec9790fdce31a14c9c (patch)
tree16abfc89c51a2cf0116eb692a591faf897e04297 /arch/nios2
parent4b4b20852d1009c5e8bc357b22353b62e3a241c7 (diff)
parent34c720a915857f168b98ab03f97b33784286e4ad (diff)
Merge branch 'clockevents/4.8' of http://git.linaro.org/people/daniel.lezcano/linux into timers/core
Pull the clockevents/clocksource tree from Daniel Lezcano: - Convert the clocksource-probe init functions to return a value in order to prepare the consolidation of the drivers using the DT. It is a big patchset but went through 01.org (kbuild bot), linux next and kernel-ci (continuous integration) (Daniel Lezcano) - Fix a bad error handling by returning the right value for cadence_ttc (Christophe Jaillet) - Fix typo in the Kconfig for the Samsung pwm (Alexandre Belloni) - Change functions to static for armada-370-xp and digicolor (Ben Dooks) - Add support for the rk3399 SoC timer by adding bindings and a slight change in the base address. Take the opportunity to add the DYNIRQ flag (Huang Tao) - Fix endian accessors for the Samsung pwm timer (Matthew Leach) - Add Oxford Semiconductor RPS Dual Timer driver (Neil Armstrong) - Add a kernel parameter to swich on/off the event stream feature of the arch arm timer (Will Deacon)
Diffstat (limited to 'arch/nios2')
-rw-r--r--arch/nios2/kernel/time.c63
1 files changed, 44 insertions, 19 deletions
diff --git a/arch/nios2/kernel/time.c b/arch/nios2/kernel/time.c
index e835dda2bfe2..d9563ddb337e 100644
--- a/arch/nios2/kernel/time.c
+++ b/arch/nios2/kernel/time.c
@@ -206,15 +206,21 @@ irqreturn_t timer_interrupt(int irq, void *dev_id)
206 return IRQ_HANDLED; 206 return IRQ_HANDLED;
207} 207}
208 208
209static void __init nios2_timer_get_base_and_freq(struct device_node *np, 209static int __init nios2_timer_get_base_and_freq(struct device_node *np,
210 void __iomem **base, u32 *freq) 210 void __iomem **base, u32 *freq)
211{ 211{
212 *base = of_iomap(np, 0); 212 *base = of_iomap(np, 0);
213 if (!*base) 213 if (!*base) {
214 panic("Unable to map reg for %s\n", np->name); 214 pr_crit("Unable to map reg for %s\n", np->name);
215 return -ENXIO;
216 }
217
218 if (of_property_read_u32(np, "clock-frequency", freq)) {
219 pr_crit("Unable to get %s clock frequency\n", np->name);
220 return -EINVAL;
221 }
215 222
216 if (of_property_read_u32(np, "clock-frequency", freq)) 223 return 0;
217 panic("Unable to get %s clock frequency\n", np->name);
218} 224}
219 225
220static struct nios2_clockevent_dev nios2_ce = { 226static struct nios2_clockevent_dev nios2_ce = {
@@ -231,17 +237,21 @@ static struct nios2_clockevent_dev nios2_ce = {
231 }, 237 },
232}; 238};
233 239
234static __init void nios2_clockevent_init(struct device_node *timer) 240static __init int nios2_clockevent_init(struct device_node *timer)
235{ 241{
236 void __iomem *iobase; 242 void __iomem *iobase;
237 u32 freq; 243 u32 freq;
238 int irq; 244 int irq, ret;
239 245
240 nios2_timer_get_base_and_freq(timer, &iobase, &freq); 246 ret = nios2_timer_get_base_and_freq(timer, &iobase, &freq);
247 if (ret)
248 return ret;
241 249
242 irq = irq_of_parse_and_map(timer, 0); 250 irq = irq_of_parse_and_map(timer, 0);
243 if (!irq) 251 if (!irq) {
244 panic("Unable to parse timer irq\n"); 252 pr_crit("Unable to parse timer irq\n");
253 return -EINVAL;
254 }
245 255
246 nios2_ce.timer.base = iobase; 256 nios2_ce.timer.base = iobase;
247 nios2_ce.timer.freq = freq; 257 nios2_ce.timer.freq = freq;
@@ -253,25 +263,35 @@ static __init void nios2_clockevent_init(struct device_node *timer)
253 /* clear pending interrupt */ 263 /* clear pending interrupt */
254 timer_writew(&nios2_ce.timer, 0, ALTERA_TIMER_STATUS_REG); 264 timer_writew(&nios2_ce.timer, 0, ALTERA_TIMER_STATUS_REG);
255 265
256 if (request_irq(irq, timer_interrupt, IRQF_TIMER, timer->name, 266 ret = request_irq(irq, timer_interrupt, IRQF_TIMER, timer->name,
257 &nios2_ce.ced)) 267 &nios2_ce.ced);
258 panic("Unable to setup timer irq\n"); 268 if (ret) {
269 pr_crit("Unable to setup timer irq\n");
270 return ret;
271 }
259 272
260 clockevents_config_and_register(&nios2_ce.ced, freq, 1, ULONG_MAX); 273 clockevents_config_and_register(&nios2_ce.ced, freq, 1, ULONG_MAX);
274
275 return 0;
261} 276}
262 277
263static __init void nios2_clocksource_init(struct device_node *timer) 278static __init int nios2_clocksource_init(struct device_node *timer)
264{ 279{
265 unsigned int ctrl; 280 unsigned int ctrl;
266 void __iomem *iobase; 281 void __iomem *iobase;
267 u32 freq; 282 u32 freq;
283 int ret;
268 284
269 nios2_timer_get_base_and_freq(timer, &iobase, &freq); 285 ret = nios2_timer_get_base_and_freq(timer, &iobase, &freq);
286 if (ret)
287 return ret;
270 288
271 nios2_cs.timer.base = iobase; 289 nios2_cs.timer.base = iobase;
272 nios2_cs.timer.freq = freq; 290 nios2_cs.timer.freq = freq;
273 291
274 clocksource_register_hz(&nios2_cs.cs, freq); 292 ret = clocksource_register_hz(&nios2_cs.cs, freq);
293 if (ret)
294 return ret;
275 295
276 timer_writew(&nios2_cs.timer, USHRT_MAX, ALTERA_TIMER_PERIODL_REG); 296 timer_writew(&nios2_cs.timer, USHRT_MAX, ALTERA_TIMER_PERIODL_REG);
277 timer_writew(&nios2_cs.timer, USHRT_MAX, ALTERA_TIMER_PERIODH_REG); 297 timer_writew(&nios2_cs.timer, USHRT_MAX, ALTERA_TIMER_PERIODH_REG);
@@ -282,6 +302,8 @@ static __init void nios2_clocksource_init(struct device_node *timer)
282 302
283 /* Calibrate the delay loop directly */ 303 /* Calibrate the delay loop directly */
284 lpj_fine = freq / HZ; 304 lpj_fine = freq / HZ;
305
306 return 0;
285} 307}
286 308
287/* 309/*
@@ -289,22 +311,25 @@ static __init void nios2_clocksource_init(struct device_node *timer)
289 * more instances, the second one gets used as clocksource and all 311 * more instances, the second one gets used as clocksource and all
290 * others are unused. 312 * others are unused.
291*/ 313*/
292static void __init nios2_time_init(struct device_node *timer) 314static int __init nios2_time_init(struct device_node *timer)
293{ 315{
294 static int num_called; 316 static int num_called;
317 int ret;
295 318
296 switch (num_called) { 319 switch (num_called) {
297 case 0: 320 case 0:
298 nios2_clockevent_init(timer); 321 ret = nios2_clockevent_init(timer);
299 break; 322 break;
300 case 1: 323 case 1:
301 nios2_clocksource_init(timer); 324 ret = nios2_clocksource_init(timer);
302 break; 325 break;
303 default: 326 default:
304 break; 327 break;
305 } 328 }
306 329
307 num_called++; 330 num_called++;
331
332 return ret;
308} 333}
309 334
310void read_persistent_clock(struct timespec *ts) 335void read_persistent_clock(struct timespec *ts)