diff options
| author | Rob Herring <rob.herring@calxeda.com> | 2013-04-10 19:27:51 -0400 |
|---|---|---|
| committer | Rob Herring <rob.herring@calxeda.com> | 2013-04-11 16:11:15 -0400 |
| commit | 0583fe478a7d93be2c814b7e50d6e81c287edfe8 (patch) | |
| tree | 1fedae32e915a0caf60fa20be32824a67262cf99 | |
| parent | f414f13f2fd0d8bb12a87268a55827cda771d42b (diff) | |
ARM: convert arm/arm64 arch timer to use CLKSRC_OF init
This converts arm and arm64 to use CLKSRC_OF DT based initialization for
the arch timer. A new function arch_timer_arch_init is added to allow for
arch specific setup.
This has a side effect of enabling sched_clock on omap5 and exynos5. There
should not be any reason not to use the arch timers for sched_clock.
Signed-off-by: Rob Herring <rob.herring@calxeda.com>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Kukjin Kim <kgene.kim@samsung.com>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Simon Horman <horms@verge.net.au>
Cc: Magnus Damm <magnus.damm@gmail.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-samsung-soc@vger.kernel.org
Cc: linux-omap@vger.kernel.org
Cc: linux-sh@vger.kernel.org
Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
| -rw-r--r-- | arch/arm/include/asm/arch_timer.h | 13 | ||||
| -rw-r--r-- | arch/arm/kernel/arch_timer.c | 17 | ||||
| -rw-r--r-- | arch/arm/mach-exynos/mach-exynos5-dt.c | 1 | ||||
| -rw-r--r-- | arch/arm/mach-exynos/mct.c | 6 | ||||
| -rw-r--r-- | arch/arm/mach-highbank/highbank.c | 5 | ||||
| -rw-r--r-- | arch/arm/mach-omap2/timer.c | 5 | ||||
| -rw-r--r-- | arch/arm/mach-shmobile/board-kzm9d.c | 1 | ||||
| -rw-r--r-- | arch/arm/mach-shmobile/setup-emev2.c | 1 | ||||
| -rw-r--r-- | arch/arm/mach-shmobile/setup-r8a7740.c | 1 | ||||
| -rw-r--r-- | arch/arm/mach-shmobile/setup-sh7372.c | 1 | ||||
| -rw-r--r-- | arch/arm/mach-shmobile/setup-sh73a0.c | 1 | ||||
| -rw-r--r-- | arch/arm/mach-shmobile/timer.c | 7 | ||||
| -rw-r--r-- | arch/arm/mach-vexpress/v2m.c | 7 | ||||
| -rw-r--r-- | arch/arm/mach-virt/virt.c | 9 | ||||
| -rw-r--r-- | arch/arm64/include/asm/arch_timer.h | 5 | ||||
| -rw-r--r-- | arch/arm64/kernel/time.c | 6 | ||||
| -rw-r--r-- | drivers/clocksource/Kconfig | 1 | ||||
| -rw-r--r-- | drivers/clocksource/arm_arch_timer.c | 23 | ||||
| -rw-r--r-- | include/clocksource/arm_arch_timer.h | 6 |
19 files changed, 29 insertions, 87 deletions
diff --git a/arch/arm/include/asm/arch_timer.h b/arch/arm/include/asm/arch_timer.h index 7ade91d8cc6f..7c1bfc0aea0c 100644 --- a/arch/arm/include/asm/arch_timer.h +++ b/arch/arm/include/asm/arch_timer.h | |||
| @@ -10,8 +10,7 @@ | |||
| 10 | #include <clocksource/arm_arch_timer.h> | 10 | #include <clocksource/arm_arch_timer.h> |
| 11 | 11 | ||
| 12 | #ifdef CONFIG_ARM_ARCH_TIMER | 12 | #ifdef CONFIG_ARM_ARCH_TIMER |
| 13 | int arch_timer_of_register(void); | 13 | int arch_timer_arch_init(void); |
| 14 | int arch_timer_sched_clock_init(void); | ||
| 15 | 14 | ||
| 16 | /* | 15 | /* |
| 17 | * These register accessors are marked inline so the compiler can | 16 | * These register accessors are marked inline so the compiler can |
| @@ -110,16 +109,6 @@ static inline void __cpuinit arch_counter_set_user_access(void) | |||
| 110 | 109 | ||
| 111 | asm volatile("mcr p15, 0, %0, c14, c1, 0" : : "r" (cntkctl)); | 110 | asm volatile("mcr p15, 0, %0, c14, c1, 0" : : "r" (cntkctl)); |
| 112 | } | 111 | } |
| 113 | #else | ||
| 114 | static inline int arch_timer_of_register(void) | ||
| 115 | { | ||
| 116 | return -ENXIO; | ||
| 117 | } | ||
| 118 | |||
| 119 | static inline int arch_timer_sched_clock_init(void) | ||
| 120 | { | ||
| 121 | return -ENXIO; | ||
| 122 | } | ||
| 123 | #endif | 112 | #endif |
| 124 | 113 | ||
| 125 | #endif | 114 | #endif |
diff --git a/arch/arm/kernel/arch_timer.c b/arch/arm/kernel/arch_timer.c index 80c458fc4a30..59dcdced6e30 100644 --- a/arch/arm/kernel/arch_timer.c +++ b/arch/arm/kernel/arch_timer.c | |||
| @@ -39,26 +39,15 @@ static void __init arch_timer_delay_timer_register(void) | |||
| 39 | register_current_timer_delay(&arch_delay_timer); | 39 | register_current_timer_delay(&arch_delay_timer); |
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | int __init arch_timer_of_register(void) | 42 | int __init arch_timer_arch_init(void) |
| 43 | { | ||
| 44 | int ret; | ||
| 45 | |||
| 46 | ret = arch_timer_init(); | ||
| 47 | if (ret) | ||
| 48 | return ret; | ||
| 49 | |||
| 50 | arch_timer_delay_timer_register(); | ||
| 51 | |||
| 52 | return 0; | ||
| 53 | } | ||
| 54 | |||
| 55 | int __init arch_timer_sched_clock_init(void) | ||
| 56 | { | 43 | { |
| 57 | u32 arch_timer_rate = arch_timer_get_rate(); | 44 | u32 arch_timer_rate = arch_timer_get_rate(); |
| 58 | 45 | ||
| 59 | if (arch_timer_rate == 0) | 46 | if (arch_timer_rate == 0) |
| 60 | return -ENXIO; | 47 | return -ENXIO; |
| 61 | 48 | ||
| 49 | arch_timer_delay_timer_register(); | ||
| 50 | |||
| 62 | /* Cache the sched_clock multiplier to save a divide in the hot path. */ | 51 | /* Cache the sched_clock multiplier to save a divide in the hot path. */ |
| 63 | sched_clock_mult = NSEC_PER_SEC / arch_timer_rate; | 52 | sched_clock_mult = NSEC_PER_SEC / arch_timer_rate; |
| 64 | sched_clock_func = arch_timer_sched_clock; | 53 | sched_clock_func = arch_timer_sched_clock; |
diff --git a/arch/arm/mach-exynos/mach-exynos5-dt.c b/arch/arm/mach-exynos/mach-exynos5-dt.c index acaeb14db54b..4d97b4311084 100644 --- a/arch/arm/mach-exynos/mach-exynos5-dt.c +++ b/arch/arm/mach-exynos/mach-exynos5-dt.c | |||
| @@ -216,7 +216,6 @@ DT_MACHINE_START(EXYNOS5_DT, "SAMSUNG EXYNOS5 (Flattened Device Tree)") | |||
| 216 | .map_io = exynos5_dt_map_io, | 216 | .map_io = exynos5_dt_map_io, |
| 217 | .init_machine = exynos5_dt_machine_init, | 217 | .init_machine = exynos5_dt_machine_init, |
| 218 | .init_late = exynos_init_late, | 218 | .init_late = exynos_init_late, |
| 219 | .init_time = exynos4_timer_init, | ||
| 220 | .dt_compat = exynos5_dt_compat, | 219 | .dt_compat = exynos5_dt_compat, |
| 221 | .restart = exynos5_restart, | 220 | .restart = exynos5_restart, |
| 222 | .reserve = exynos5_reserve, | 221 | .reserve = exynos5_reserve, |
diff --git a/arch/arm/mach-exynos/mct.c b/arch/arm/mach-exynos/mct.c index c9d6650f9b5d..04aff6a61e8d 100644 --- a/arch/arm/mach-exynos/mct.c +++ b/arch/arm/mach-exynos/mct.c | |||
| @@ -21,7 +21,6 @@ | |||
| 21 | #include <linux/percpu.h> | 21 | #include <linux/percpu.h> |
| 22 | #include <linux/of.h> | 22 | #include <linux/of.h> |
| 23 | 23 | ||
| 24 | #include <asm/arch_timer.h> | ||
| 25 | #include <asm/localtimer.h> | 24 | #include <asm/localtimer.h> |
| 26 | 25 | ||
| 27 | #include <plat/cpu.h> | 26 | #include <plat/cpu.h> |
| @@ -469,11 +468,6 @@ static void __init exynos4_timer_resources(void) | |||
| 469 | 468 | ||
| 470 | void __init exynos4_timer_init(void) | 469 | void __init exynos4_timer_init(void) |
| 471 | { | 470 | { |
| 472 | if (soc_is_exynos5440()) { | ||
| 473 | arch_timer_of_register(); | ||
| 474 | return; | ||
| 475 | } | ||
| 476 | |||
| 477 | if ((soc_is_exynos4210()) || (soc_is_exynos5250())) | 471 | if ((soc_is_exynos4210()) || (soc_is_exynos5250())) |
| 478 | mct_int_type = MCT_INT_SPI; | 472 | mct_int_type = MCT_INT_SPI; |
| 479 | else | 473 | else |
diff --git a/arch/arm/mach-highbank/highbank.c b/arch/arm/mach-highbank/highbank.c index 76c1170b3528..758150eb9975 100644 --- a/arch/arm/mach-highbank/highbank.c +++ b/arch/arm/mach-highbank/highbank.c | |||
| @@ -15,6 +15,7 @@ | |||
| 15 | */ | 15 | */ |
| 16 | #include <linux/clk.h> | 16 | #include <linux/clk.h> |
| 17 | #include <linux/clkdev.h> | 17 | #include <linux/clkdev.h> |
| 18 | #include <linux/clocksource.h> | ||
| 18 | #include <linux/dma-mapping.h> | 19 | #include <linux/dma-mapping.h> |
| 19 | #include <linux/io.h> | 20 | #include <linux/io.h> |
| 20 | #include <linux/irq.h> | 21 | #include <linux/irq.h> |
| @@ -28,7 +29,6 @@ | |||
| 28 | #include <linux/amba/bus.h> | 29 | #include <linux/amba/bus.h> |
| 29 | #include <linux/clk-provider.h> | 30 | #include <linux/clk-provider.h> |
| 30 | 31 | ||
| 31 | #include <asm/arch_timer.h> | ||
| 32 | #include <asm/cacheflush.h> | 32 | #include <asm/cacheflush.h> |
| 33 | #include <asm/cputype.h> | 33 | #include <asm/cputype.h> |
| 34 | #include <asm/smp_plat.h> | 34 | #include <asm/smp_plat.h> |
| @@ -118,9 +118,6 @@ static void __init highbank_timer_init(void) | |||
| 118 | sp804_clocksource_and_sched_clock_init(timer_base + 0x20, "timer1"); | 118 | sp804_clocksource_and_sched_clock_init(timer_base + 0x20, "timer1"); |
| 119 | sp804_clockevents_init(timer_base, irq, "timer0"); | 119 | sp804_clockevents_init(timer_base, irq, "timer0"); |
| 120 | 120 | ||
| 121 | arch_timer_of_register(); | ||
| 122 | arch_timer_sched_clock_init(); | ||
| 123 | |||
| 124 | clocksource_of_init(); | 121 | clocksource_of_init(); |
| 125 | } | 122 | } |
| 126 | 123 | ||
diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c index 4fd80257c73e..7dd6453a213e 100644 --- a/arch/arm/mach-omap2/timer.c +++ b/arch/arm/mach-omap2/timer.c | |||
| @@ -46,7 +46,6 @@ | |||
| 46 | #include <asm/smp_twd.h> | 46 | #include <asm/smp_twd.h> |
| 47 | #include <asm/sched_clock.h> | 47 | #include <asm/sched_clock.h> |
| 48 | 48 | ||
| 49 | #include <asm/arch_timer.h> | ||
| 50 | #include "omap_hwmod.h" | 49 | #include "omap_hwmod.h" |
| 51 | #include "omap_device.h" | 50 | #include "omap_device.h" |
| 52 | #include <plat/counter-32k.h> | 51 | #include <plat/counter-32k.h> |
| @@ -624,9 +623,7 @@ void __init omap5_realtime_timer_init(void) | |||
| 624 | omap5_sync32k_timer_init(); | 623 | omap5_sync32k_timer_init(); |
| 625 | realtime_counter_init(); | 624 | realtime_counter_init(); |
| 626 | 625 | ||
| 627 | err = arch_timer_of_register(); | 626 | clocksource_of_init(); |
| 628 | if (err) | ||
| 629 | pr_err("%s: arch_timer_register failed %d\n", __func__, err); | ||
| 630 | } | 627 | } |
| 631 | #endif /* CONFIG_SOC_OMAP5 */ | 628 | #endif /* CONFIG_SOC_OMAP5 */ |
| 632 | 629 | ||
diff --git a/arch/arm/mach-shmobile/board-kzm9d.c b/arch/arm/mach-shmobile/board-kzm9d.c index c254782aa727..c016ccd92433 100644 --- a/arch/arm/mach-shmobile/board-kzm9d.c +++ b/arch/arm/mach-shmobile/board-kzm9d.c | |||
| @@ -90,6 +90,5 @@ DT_MACHINE_START(KZM9D_DT, "kzm9d") | |||
| 90 | .init_irq = emev2_init_irq, | 90 | .init_irq = emev2_init_irq, |
| 91 | .init_machine = kzm9d_add_standard_devices, | 91 | .init_machine = kzm9d_add_standard_devices, |
| 92 | .init_late = shmobile_init_late, | 92 | .init_late = shmobile_init_late, |
| 93 | .init_time = shmobile_timer_init, | ||
| 94 | .dt_compat = kzm9d_boards_compat_dt, | 93 | .dt_compat = kzm9d_boards_compat_dt, |
| 95 | MACHINE_END | 94 | MACHINE_END |
diff --git a/arch/arm/mach-shmobile/setup-emev2.c b/arch/arm/mach-shmobile/setup-emev2.c index 47662a581c0a..4e38a66508a4 100644 --- a/arch/arm/mach-shmobile/setup-emev2.c +++ b/arch/arm/mach-shmobile/setup-emev2.c | |||
| @@ -456,7 +456,6 @@ DT_MACHINE_START(EMEV2_DT, "Generic Emma Mobile EV2 (Flattened Device Tree)") | |||
| 456 | .nr_irqs = NR_IRQS_LEGACY, | 456 | .nr_irqs = NR_IRQS_LEGACY, |
| 457 | .init_irq = irqchip_init, | 457 | .init_irq = irqchip_init, |
| 458 | .init_machine = emev2_add_standard_devices_dt, | 458 | .init_machine = emev2_add_standard_devices_dt, |
| 459 | .init_time = shmobile_timer_init, | ||
| 460 | .dt_compat = emev2_boards_compat_dt, | 459 | .dt_compat = emev2_boards_compat_dt, |
| 461 | MACHINE_END | 460 | MACHINE_END |
| 462 | 461 | ||
diff --git a/arch/arm/mach-shmobile/setup-r8a7740.c b/arch/arm/mach-shmobile/setup-r8a7740.c index 8b85d4d8fab6..104b474a2ccf 100644 --- a/arch/arm/mach-shmobile/setup-r8a7740.c +++ b/arch/arm/mach-shmobile/setup-r8a7740.c | |||
| @@ -906,7 +906,6 @@ DT_MACHINE_START(R8A7740_DT, "Generic R8A7740 (Flattened Device Tree)") | |||
| 906 | .init_irq = r8a7740_init_irq, | 906 | .init_irq = r8a7740_init_irq, |
| 907 | .handle_irq = shmobile_handle_irq_intc, | 907 | .handle_irq = shmobile_handle_irq_intc, |
| 908 | .init_machine = r8a7740_add_standard_devices_dt, | 908 | .init_machine = r8a7740_add_standard_devices_dt, |
| 909 | .init_time = shmobile_timer_init, | ||
| 910 | .dt_compat = r8a7740_boards_compat_dt, | 909 | .dt_compat = r8a7740_boards_compat_dt, |
| 911 | MACHINE_END | 910 | MACHINE_END |
| 912 | 911 | ||
diff --git a/arch/arm/mach-shmobile/setup-sh7372.c b/arch/arm/mach-shmobile/setup-sh7372.c index 59c7146bf66f..5502d624aca6 100644 --- a/arch/arm/mach-shmobile/setup-sh7372.c +++ b/arch/arm/mach-shmobile/setup-sh7372.c | |||
| @@ -1175,7 +1175,6 @@ DT_MACHINE_START(SH7372_DT, "Generic SH7372 (Flattened Device Tree)") | |||
| 1175 | .init_irq = sh7372_init_irq, | 1175 | .init_irq = sh7372_init_irq, |
| 1176 | .handle_irq = shmobile_handle_irq_intc, | 1176 | .handle_irq = shmobile_handle_irq_intc, |
| 1177 | .init_machine = sh7372_add_standard_devices_dt, | 1177 | .init_machine = sh7372_add_standard_devices_dt, |
| 1178 | .init_time = shmobile_timer_init, | ||
| 1179 | .dt_compat = sh7372_boards_compat_dt, | 1178 | .dt_compat = sh7372_boards_compat_dt, |
| 1180 | MACHINE_END | 1179 | MACHINE_END |
| 1181 | 1180 | ||
diff --git a/arch/arm/mach-shmobile/setup-sh73a0.c b/arch/arm/mach-shmobile/setup-sh73a0.c index bdab575f88bc..ea66316f0ac9 100644 --- a/arch/arm/mach-shmobile/setup-sh73a0.c +++ b/arch/arm/mach-shmobile/setup-sh73a0.c | |||
| @@ -923,7 +923,6 @@ DT_MACHINE_START(SH73A0_DT, "Generic SH73A0 (Flattened Device Tree)") | |||
| 923 | .nr_irqs = NR_IRQS_LEGACY, | 923 | .nr_irqs = NR_IRQS_LEGACY, |
| 924 | .init_irq = sh73a0_init_irq_dt, | 924 | .init_irq = sh73a0_init_irq_dt, |
| 925 | .init_machine = sh73a0_add_standard_devices_dt, | 925 | .init_machine = sh73a0_add_standard_devices_dt, |
| 926 | .init_time = shmobile_timer_init, | ||
| 927 | .dt_compat = sh73a0_boards_compat_dt, | 926 | .dt_compat = sh73a0_boards_compat_dt, |
| 928 | MACHINE_END | 927 | MACHINE_END |
| 929 | #endif /* CONFIG_USE_OF */ | 928 | #endif /* CONFIG_USE_OF */ |
diff --git a/arch/arm/mach-shmobile/timer.c b/arch/arm/mach-shmobile/timer.c index 3d16d4dff01b..f321dbeb2379 100644 --- a/arch/arm/mach-shmobile/timer.c +++ b/arch/arm/mach-shmobile/timer.c | |||
| @@ -19,10 +19,8 @@ | |||
| 19 | * | 19 | * |
| 20 | */ | 20 | */ |
| 21 | #include <linux/platform_device.h> | 21 | #include <linux/platform_device.h> |
| 22 | #include <linux/clocksource.h> | ||
| 22 | #include <linux/delay.h> | 23 | #include <linux/delay.h> |
| 23 | #include <asm/arch_timer.h> | ||
| 24 | #include <asm/mach/time.h> | ||
| 25 | #include <asm/smp_twd.h> | ||
| 26 | 24 | ||
| 27 | void __init shmobile_setup_delay(unsigned int max_cpu_core_mhz, | 25 | void __init shmobile_setup_delay(unsigned int max_cpu_core_mhz, |
| 28 | unsigned int mult, unsigned int div) | 26 | unsigned int mult, unsigned int div) |
| @@ -63,6 +61,5 @@ void __init shmobile_earlytimer_init(void) | |||
| 63 | 61 | ||
| 64 | void __init shmobile_timer_init(void) | 62 | void __init shmobile_timer_init(void) |
| 65 | { | 63 | { |
| 66 | arch_timer_of_register(); | 64 | clocksource_of_init(); |
| 67 | arch_timer_sched_clock_init(); | ||
| 68 | } | 65 | } |
diff --git a/arch/arm/mach-vexpress/v2m.c b/arch/arm/mach-vexpress/v2m.c index d0ad78998cb6..621571781b20 100644 --- a/arch/arm/mach-vexpress/v2m.c +++ b/arch/arm/mach-vexpress/v2m.c | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Versatile Express V2M Motherboard Support | 2 | * Versatile Express V2M Motherboard Support |
| 3 | */ | 3 | */ |
| 4 | #include <linux/clocksource.h> | ||
| 4 | #include <linux/device.h> | 5 | #include <linux/device.h> |
| 5 | #include <linux/amba/bus.h> | 6 | #include <linux/amba/bus.h> |
| 6 | #include <linux/amba/mmci.h> | 7 | #include <linux/amba/mmci.h> |
| @@ -23,7 +24,6 @@ | |||
| 23 | #include <linux/regulator/machine.h> | 24 | #include <linux/regulator/machine.h> |
| 24 | #include <linux/vexpress.h> | 25 | #include <linux/vexpress.h> |
| 25 | 26 | ||
| 26 | #include <asm/arch_timer.h> | ||
| 27 | #include <asm/mach-types.h> | 27 | #include <asm/mach-types.h> |
| 28 | #include <asm/sizes.h> | 28 | #include <asm/sizes.h> |
| 29 | #include <asm/mach/arch.h> | 29 | #include <asm/mach/arch.h> |
| @@ -446,10 +446,7 @@ static void __init v2m_dt_timer_init(void) | |||
| 446 | irq_of_parse_and_map(node, 0)); | 446 | irq_of_parse_and_map(node, 0)); |
| 447 | } | 447 | } |
| 448 | 448 | ||
| 449 | arch_timer_of_register(); | 449 | versatile_sched_clock_init(vexpress_get_24mhz_clock_base(), |
| 450 | |||
| 451 | if (arch_timer_sched_clock_init() != 0) | ||
| 452 | versatile_sched_clock_init(vexpress_get_24mhz_clock_base(), | ||
| 453 | 24000000); | 450 | 24000000); |
| 454 | } | 451 | } |
| 455 | 452 | ||
diff --git a/arch/arm/mach-virt/virt.c b/arch/arm/mach-virt/virt.c index 31666f6b4373..adc0945255ae 100644 --- a/arch/arm/mach-virt/virt.c +++ b/arch/arm/mach-virt/virt.c | |||
| @@ -23,21 +23,13 @@ | |||
| 23 | #include <linux/of_platform.h> | 23 | #include <linux/of_platform.h> |
| 24 | #include <linux/smp.h> | 24 | #include <linux/smp.h> |
| 25 | 25 | ||
| 26 | #include <asm/arch_timer.h> | ||
| 27 | #include <asm/mach/arch.h> | 26 | #include <asm/mach/arch.h> |
| 28 | #include <asm/mach/time.h> | ||
| 29 | 27 | ||
| 30 | static void __init virt_init(void) | 28 | static void __init virt_init(void) |
| 31 | { | 29 | { |
| 32 | of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); | 30 | of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); |
| 33 | } | 31 | } |
| 34 | 32 | ||
| 35 | static void __init virt_timer_init(void) | ||
| 36 | { | ||
| 37 | WARN_ON(arch_timer_of_register() != 0); | ||
| 38 | WARN_ON(arch_timer_sched_clock_init() != 0); | ||
| 39 | } | ||
| 40 | |||
| 41 | static const char *virt_dt_match[] = { | 33 | static const char *virt_dt_match[] = { |
| 42 | "linux,dummy-virt", | 34 | "linux,dummy-virt", |
| 43 | NULL | 35 | NULL |
| @@ -47,7 +39,6 @@ extern struct smp_operations virt_smp_ops; | |||
| 47 | 39 | ||
| 48 | DT_MACHINE_START(VIRT, "Dummy Virtual Machine") | 40 | DT_MACHINE_START(VIRT, "Dummy Virtual Machine") |
| 49 | .init_irq = irqchip_init, | 41 | .init_irq = irqchip_init, |
| 50 | .init_time = virt_timer_init, | ||
| 51 | .init_machine = virt_init, | 42 | .init_machine = virt_init, |
| 52 | .smp = smp_ops(virt_smp_ops), | 43 | .smp = smp_ops(virt_smp_ops), |
| 53 | .dt_compat = virt_dt_match, | 44 | .dt_compat = virt_dt_match, |
diff --git a/arch/arm64/include/asm/arch_timer.h b/arch/arm64/include/asm/arch_timer.h index 91e2a6a6fcd4..bf6ab242f047 100644 --- a/arch/arm64/include/asm/arch_timer.h +++ b/arch/arm64/include/asm/arch_timer.h | |||
| @@ -130,4 +130,9 @@ static inline u64 arch_counter_get_cntvct(void) | |||
| 130 | return cval; | 130 | return cval; |
| 131 | } | 131 | } |
| 132 | 132 | ||
| 133 | static inline int arch_timer_arch_init(void) | ||
| 134 | { | ||
| 135 | return 0; | ||
| 136 | } | ||
| 137 | |||
| 133 | #endif | 138 | #endif |
diff --git a/arch/arm64/kernel/time.c b/arch/arm64/kernel/time.c index b0ef18d14c3b..a551f88ae2c1 100644 --- a/arch/arm64/kernel/time.c +++ b/arch/arm64/kernel/time.c | |||
| @@ -32,6 +32,7 @@ | |||
| 32 | #include <linux/timer.h> | 32 | #include <linux/timer.h> |
| 33 | #include <linux/irq.h> | 33 | #include <linux/irq.h> |
| 34 | #include <linux/delay.h> | 34 | #include <linux/delay.h> |
| 35 | #include <linux/clocksource.h> | ||
| 35 | 36 | ||
| 36 | #include <clocksource/arm_arch_timer.h> | 37 | #include <clocksource/arm_arch_timer.h> |
| 37 | 38 | ||
| @@ -77,10 +78,11 @@ void __init time_init(void) | |||
| 77 | { | 78 | { |
| 78 | u32 arch_timer_rate; | 79 | u32 arch_timer_rate; |
| 79 | 80 | ||
| 80 | if (arch_timer_init()) | 81 | clocksource_of_init(); |
| 81 | panic("Unable to initialise architected timer.\n"); | ||
| 82 | 82 | ||
| 83 | arch_timer_rate = arch_timer_get_rate(); | 83 | arch_timer_rate = arch_timer_get_rate(); |
| 84 | if (!arch_timer_rate) | ||
| 85 | panic("Unable to initialise architected timer.\n"); | ||
| 84 | 86 | ||
| 85 | /* Cache the sched_clock multiplier to save a divide in the hot path. */ | 87 | /* Cache the sched_clock multiplier to save a divide in the hot path. */ |
| 86 | sched_clock_mult = NSEC_PER_SEC / arch_timer_rate; | 88 | sched_clock_mult = NSEC_PER_SEC / arch_timer_rate; |
diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig index e507ab7df60b..d98e7e1ee594 100644 --- a/drivers/clocksource/Kconfig +++ b/drivers/clocksource/Kconfig | |||
| @@ -62,6 +62,7 @@ config CLKSRC_DBX500_PRCMU_SCHED_CLOCK | |||
| 62 | 62 | ||
| 63 | config ARM_ARCH_TIMER | 63 | config ARM_ARCH_TIMER |
| 64 | bool | 64 | bool |
| 65 | select CLKSRC_OF if OF | ||
| 65 | 66 | ||
| 66 | config CLKSRC_METAG_GENERIC | 67 | config CLKSRC_METAG_GENERIC |
| 67 | def_bool y if METAG | 68 | def_bool y if METAG |
diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c index d7ad425ab9b3..122ff05628b5 100644 --- a/drivers/clocksource/arm_arch_timer.c +++ b/drivers/clocksource/arm_arch_timer.c | |||
| @@ -337,22 +337,14 @@ out: | |||
| 337 | return err; | 337 | return err; |
| 338 | } | 338 | } |
| 339 | 339 | ||
| 340 | static const struct of_device_id arch_timer_of_match[] __initconst = { | 340 | static void __init arch_timer_init(struct device_node *np) |
| 341 | { .compatible = "arm,armv7-timer", }, | ||
| 342 | { .compatible = "arm,armv8-timer", }, | ||
| 343 | {}, | ||
| 344 | }; | ||
| 345 | |||
| 346 | int __init arch_timer_init(void) | ||
| 347 | { | 341 | { |
| 348 | struct device_node *np; | ||
| 349 | u32 freq; | 342 | u32 freq; |
| 350 | int i; | 343 | int i; |
| 351 | 344 | ||
| 352 | np = of_find_matching_node(NULL, arch_timer_of_match); | 345 | if (arch_timer_get_rate()) { |
| 353 | if (!np) { | 346 | pr_warn("arch_timer: multiple nodes in dt, skipping\n"); |
| 354 | pr_err("arch_timer: can't find DT node\n"); | 347 | return; |
| 355 | return -ENODEV; | ||
| 356 | } | 348 | } |
| 357 | 349 | ||
| 358 | /* Try to determine the frequency from the device tree or CNTFRQ */ | 350 | /* Try to determine the frequency from the device tree or CNTFRQ */ |
| @@ -378,7 +370,7 @@ int __init arch_timer_init(void) | |||
| 378 | if (!arch_timer_ppi[PHYS_SECURE_PPI] || | 370 | if (!arch_timer_ppi[PHYS_SECURE_PPI] || |
| 379 | !arch_timer_ppi[PHYS_NONSECURE_PPI]) { | 371 | !arch_timer_ppi[PHYS_NONSECURE_PPI]) { |
| 380 | pr_warn("arch_timer: No interrupt available, giving up\n"); | 372 | pr_warn("arch_timer: No interrupt available, giving up\n"); |
| 381 | return -EINVAL; | 373 | return; |
| 382 | } | 374 | } |
| 383 | } | 375 | } |
| 384 | 376 | ||
| @@ -387,5 +379,8 @@ int __init arch_timer_init(void) | |||
| 387 | else | 379 | else |
| 388 | arch_timer_read_counter = arch_counter_get_cntpct; | 380 | arch_timer_read_counter = arch_counter_get_cntpct; |
| 389 | 381 | ||
| 390 | return arch_timer_register(); | 382 | arch_timer_register(); |
| 383 | arch_timer_arch_init(); | ||
| 391 | } | 384 | } |
| 385 | CLOCKSOURCE_OF_DECLARE(armv7_arch_timer, "arm,armv7-timer", arch_timer_init); | ||
| 386 | CLOCKSOURCE_OF_DECLARE(armv8_arch_timer, "arm,armv8-timer", arch_timer_init); | ||
diff --git a/include/clocksource/arm_arch_timer.h b/include/clocksource/arm_arch_timer.h index 2603267b1a29..e6c9c4cc9b23 100644 --- a/include/clocksource/arm_arch_timer.h +++ b/include/clocksource/arm_arch_timer.h | |||
| @@ -31,18 +31,12 @@ | |||
| 31 | 31 | ||
| 32 | #ifdef CONFIG_ARM_ARCH_TIMER | 32 | #ifdef CONFIG_ARM_ARCH_TIMER |
| 33 | 33 | ||
| 34 | extern int arch_timer_init(void); | ||
| 35 | extern u32 arch_timer_get_rate(void); | 34 | extern u32 arch_timer_get_rate(void); |
| 36 | extern u64 (*arch_timer_read_counter)(void); | 35 | extern u64 (*arch_timer_read_counter)(void); |
| 37 | extern struct timecounter *arch_timer_get_timecounter(void); | 36 | extern struct timecounter *arch_timer_get_timecounter(void); |
| 38 | 37 | ||
| 39 | #else | 38 | #else |
| 40 | 39 | ||
| 41 | static inline int arch_timer_init(void) | ||
| 42 | { | ||
| 43 | return -ENXIO; | ||
| 44 | } | ||
| 45 | |||
| 46 | static inline u32 arch_timer_get_rate(void) | 40 | static inline u32 arch_timer_get_rate(void) |
| 47 | { | 41 | { |
| 48 | return 0; | 42 | return 0; |
