Marc Zyngier | 022c03a | 2012-01-11 17:25:17 +0000 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/kernel/arch_timer.c |
| 3 | * |
| 4 | * Copyright (C) 2011 ARM Ltd. |
| 5 | * All Rights Reserved |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License version 2 as |
| 9 | * published by the Free Software Foundation. |
| 10 | */ |
| 11 | #include <linux/init.h> |
Mark Rutland | 8a4da6e | 2012-11-12 14:33:44 +0000 | [diff] [blame] | 12 | #include <linux/types.h> |
Arnd Bergmann | fe7dc72 | 2013-02-14 17:45:25 +0100 | [diff] [blame] | 13 | #include <linux/errno.h> |
Marc Zyngier | 022c03a | 2012-01-11 17:25:17 +0000 | [diff] [blame] | 14 | |
Jonathan Austin | 56942fe | 2012-09-21 18:51:44 +0100 | [diff] [blame] | 15 | #include <asm/delay.h> |
Marc Zyngier | 022c03a | 2012-01-11 17:25:17 +0000 | [diff] [blame] | 16 | |
Mark Rutland | 8a4da6e | 2012-11-12 14:33:44 +0000 | [diff] [blame] | 17 | #include <clocksource/arm_arch_timer.h> |
Marc Zyngier | f48b5f1 | 2012-09-07 18:09:57 +0100 | [diff] [blame] | 18 | |
Mark Rutland | 8a4da6e | 2012-11-12 14:33:44 +0000 | [diff] [blame] | 19 | static unsigned long arch_timer_read_counter_long(void) |
| 20 | { |
| 21 | return arch_timer_read_counter(); |
| 22 | } |
Marc Zyngier | f48b5f1 | 2012-09-07 18:09:57 +0100 | [diff] [blame] | 23 | |
Jonathan Austin | 56942fe | 2012-09-21 18:51:44 +0100 | [diff] [blame] | 24 | static struct delay_timer arch_delay_timer; |
Will Deacon | d0a533b | 2012-07-06 15:47:17 +0100 | [diff] [blame] | 25 | |
Mark Rutland | 8a4da6e | 2012-11-12 14:33:44 +0000 | [diff] [blame] | 26 | static void __init arch_timer_delay_timer_register(void) |
Marc Zyngier | f48b5f1 | 2012-09-07 18:09:57 +0100 | [diff] [blame] | 27 | { |
Jonathan Austin | 56942fe | 2012-09-21 18:51:44 +0100 | [diff] [blame] | 28 | /* Use the architected timer for the delay loop. */ |
Mark Rutland | 8a4da6e | 2012-11-12 14:33:44 +0000 | [diff] [blame] | 29 | arch_delay_timer.read_current_timer = arch_timer_read_counter_long; |
| 30 | arch_delay_timer.freq = arch_timer_get_rate(); |
Jonathan Austin | 56942fe | 2012-09-21 18:51:44 +0100 | [diff] [blame] | 31 | register_current_timer_delay(&arch_delay_timer); |
Marc Zyngier | 022c03a | 2012-01-11 17:25:17 +0000 | [diff] [blame] | 32 | } |
Marc Zyngier | 3f61c80 | 2011-01-14 15:32:36 +0000 | [diff] [blame] | 33 | |
Rob Herring | 0583fe4 | 2013-04-10 18:27:51 -0500 | [diff] [blame] | 34 | int __init arch_timer_arch_init(void) |
Marc Zyngier | 3f61c80 | 2011-01-14 15:32:36 +0000 | [diff] [blame] | 35 | { |
Rob Herring | 023796b | 2013-03-11 16:23:46 -0500 | [diff] [blame] | 36 | u32 arch_timer_rate = arch_timer_get_rate(); |
| 37 | |
| 38 | if (arch_timer_rate == 0) |
Mark Rutland | 8a4da6e | 2012-11-12 14:33:44 +0000 | [diff] [blame] | 39 | return -ENXIO; |
Marc Zyngier | 3f61c80 | 2011-01-14 15:32:36 +0000 | [diff] [blame] | 40 | |
Rob Herring | 0583fe4 | 2013-04-10 18:27:51 -0500 | [diff] [blame] | 41 | arch_timer_delay_timer_register(); |
| 42 | |
Marc Zyngier | 3f61c80 | 2011-01-14 15:32:36 +0000 | [diff] [blame] | 43 | return 0; |
| 44 | } |