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

Merge branch 'clockevents/4.13' of https://git.linaro.org/people/daniel.lezcano/linux into timers/core

Pull clockevent changes from Daniel Lezcano:

- Factored out moxart, aspeed, cortina drivers into a generic timer fttrm010.
Take the opportunity to add the delay timer (Linus Walleij)

- Saved / restored tcb atmel context at suspend/resume (Alexandre Belloni)

- Added ast2500 compatible string and fixed aspeed2500 initialization (Daniel
Lezcano)

- Added clock names property for aspeed (Andrew Jeffery)

- Renamed clocksource_of to timer_of (Daniel Lezcano)

- Added a common timer init routine (Daniel Lezcano)

+802 -754
+5 -1
Documentation/devicetree/bindings/timer/faraday,fttmr010.txt
··· 7 7 8 8 - compatible : Must be one of 9 9 "faraday,fttmr010" 10 - "cortina,gemini-timer" 10 + "cortina,gemini-timer", "faraday,fttmr010" 11 + "moxa,moxart-timer", "faraday,fttmr010" 12 + "aspeed,ast2400-timer" 13 + "aspeed,ast2500-timer" 14 + 11 15 - reg : Should contain registers location and length 12 16 - interrupts : Should contain the three timer interrupts usually with 13 17 flags for falling edge
-19
Documentation/devicetree/bindings/timer/moxa,moxart-timer.txt
··· 1 - MOXA ART timer 2 - 3 - Required properties: 4 - 5 - - compatible : Must be one of: 6 - - "moxa,moxart-timer" 7 - - "aspeed,ast2400-timer" 8 - - reg : Should contain registers location and length 9 - - interrupts : Should contain the timer interrupt number 10 - - clocks : Should contain phandle for the clock that drives the counter 11 - 12 - Example: 13 - 14 - timer: timer@98400000 { 15 - compatible = "moxa,moxart-timer"; 16 - reg = <0x98400000 0x42>; 17 - interrupts = <19 1>; 18 - clocks = <&coreclk>; 19 - };
+1 -1
arch/arc/kernel/setup.c
··· 470 470 void __init time_init(void) 471 471 { 472 472 of_clk_init(NULL); 473 - clocksource_probe(); 473 + timer_probe(); 474 474 } 475 475 476 476 static int __init customize_machine(void)
+5 -5
arch/arm/Kconfig
··· 337 337 select ARM_HAS_SG_CHAIN 338 338 select ARM_PATCH_PHYS_VIRT 339 339 select AUTO_ZRELADDR 340 - select CLKSRC_OF 340 + select TIMER_OF 341 341 select COMMON_CLK 342 342 select GENERIC_CLOCKEVENTS 343 343 select MIGHT_HAVE_PCI ··· 351 351 depends on !MMU 352 352 select ARM_NVIC 353 353 select AUTO_ZRELADDR 354 - select CLKSRC_OF 354 + select TIMER_OF 355 355 select COMMON_CLK 356 356 select CPU_V7M 357 357 select GENERIC_CLOCKEVENTS ··· 532 532 select CLKDEV_LOOKUP 533 533 select CLKSRC_PXA 534 534 select CLKSRC_MMIO 535 - select CLKSRC_OF 535 + select TIMER_OF 536 536 select CPU_XSCALE if !CPU_XSC3 537 537 select GENERIC_CLOCKEVENTS 538 538 select GPIO_PXA ··· 571 571 select CLKDEV_LOOKUP 572 572 select CLKSRC_MMIO 573 573 select CLKSRC_PXA 574 - select CLKSRC_OF if OF 574 + select TIMER_OF if OF 575 575 select CPU_FREQ 576 576 select CPU_SA1100 577 577 select GENERIC_CLOCKEVENTS ··· 1357 1357 1358 1358 config HAVE_ARM_TWD 1359 1359 bool 1360 - select CLKSRC_OF if OF 1360 + select TIMER_OF if OF 1361 1361 help 1362 1362 This options enables support for the ARM timer and watchdog unit 1363 1363
+1
arch/arm/boot/dts/aspeed-g4.dtsi
··· 893 893 //interrupts = <16 17 18 35 36 37 38 39>; 894 894 interrupts = <16>; 895 895 clocks = <&clk_apb>; 896 + clock-names = "PCLK"; 896 897 }; 897 898 898 899 wdt1: wdt@1e785000 {
+1
arch/arm/boot/dts/aspeed-g5.dtsi
··· 1000 1000 //interrupts = <16 17 18 35 36 37 38 39>; 1001 1001 interrupts = <16>; 1002 1002 clocks = <&clk_apb>; 1003 + clock-names = "PCLK"; 1003 1004 }; 1004 1005 1005 1006
+3 -3
arch/arm/kernel/smp_twd.c
··· 403 403 WARN(err, "twd_local_timer_of_register failed (%d)\n", err); 404 404 return err; 405 405 } 406 - CLOCKSOURCE_OF_DECLARE(arm_twd_a9, "arm,cortex-a9-twd-timer", twd_local_timer_of_register); 407 - CLOCKSOURCE_OF_DECLARE(arm_twd_a5, "arm,cortex-a5-twd-timer", twd_local_timer_of_register); 408 - CLOCKSOURCE_OF_DECLARE(arm_twd_11mp, "arm,arm11mp-twd-timer", twd_local_timer_of_register); 406 + TIMER_OF_DECLARE(arm_twd_a9, "arm,cortex-a9-twd-timer", twd_local_timer_of_register); 407 + TIMER_OF_DECLARE(arm_twd_a5, "arm,cortex-a5-twd-timer", twd_local_timer_of_register); 408 + TIMER_OF_DECLARE(arm_twd_11mp, "arm,arm11mp-twd-timer", twd_local_timer_of_register); 409 409 #endif
+1 -1
arch/arm/kernel/time.c
··· 120 120 #ifdef CONFIG_COMMON_CLK 121 121 of_clk_init(NULL); 122 122 #endif 123 - clocksource_probe(); 123 + timer_probe(); 124 124 } 125 125 }
+1 -1
arch/arm/mach-aspeed/Kconfig
··· 4 4 select SRAM 5 5 select WATCHDOG 6 6 select ASPEED_WATCHDOG 7 - select MOXART_TIMER 7 + select FTTMR010_TIMER 8 8 select MFD_SYSCON 9 9 select PINCTRL 10 10 help
+1 -1
arch/arm/mach-bcm/Kconfig
··· 150 150 select ARM_ERRATA_411920 if ARCH_MULTI_V6 151 151 select ARM_TIMER_SP804 152 152 select HAVE_ARM_ARCH_TIMER if ARCH_MULTI_V7 153 - select CLKSRC_OF 153 + select TIMER_OF 154 154 select BCM2835_TIMER 155 155 select PINCTRL 156 156 select PINCTRL_BCM2835
+1 -1
arch/arm/mach-clps711x/Kconfig
··· 2 2 bool "Cirrus Logic EP721x/EP731x-based" 3 3 depends on ARCH_MULTI_V4T 4 4 select AUTO_ZRELADDR 5 - select CLKSRC_OF 5 + select TIMER_OF 6 6 select CLPS711X_TIMER 7 7 select COMMON_CLK 8 8 select CPU_ARM720T
+1 -1
arch/arm/mach-mediatek/mediatek.c
··· 41 41 } 42 42 43 43 of_clk_init(NULL); 44 - clocksource_probe(); 44 + timer_probe(); 45 45 }; 46 46 47 47 static const char * const mediatek_board_dt_compat[] = {
+1 -1
arch/arm/mach-moxart/Kconfig
··· 4 4 select CPU_FA526 5 5 select ARM_DMA_MEM_BUFFERABLE 6 6 select FARADAY_FTINTC010 7 - select MOXART_TIMER 7 + select FTTMR010_TIMER 8 8 select GPIOLIB 9 9 select PHYLIB if NETDEVICES 10 10 help
+5 -5
arch/arm/mach-omap2/timer.c
··· 497 497 __omap_sync32k_timer_init(1, "timer_32k_ck", "ti,timer-alwon", 498 498 2, "timer_sys_ck", NULL, false); 499 499 500 - clocksource_probe(); 500 + timer_probe(); 501 501 } 502 502 503 503 #if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_SOC_AM43XX) ··· 506 506 __omap_sync32k_timer_init(12, "secure_32k_fck", "ti,timer-secure", 507 507 2, "timer_sys_ck", NULL, false); 508 508 509 - clocksource_probe(); 509 + timer_probe(); 510 510 } 511 511 #endif /* CONFIG_ARCH_OMAP3 */ 512 512 ··· 517 517 __omap_sync32k_timer_init(2, "timer_sys_ck", NULL, 518 518 1, "timer_sys_ck", "ti,timer-alwon", true); 519 519 if (of_have_populated_dt()) 520 - clocksource_probe(); 520 + timer_probe(); 521 521 } 522 522 #endif 523 523 ··· 532 532 void __init omap4_local_timer_init(void) 533 533 { 534 534 omap4_sync32k_timer_init(); 535 - clocksource_probe(); 535 + timer_probe(); 536 536 } 537 537 #endif 538 538 ··· 656 656 omap4_sync32k_timer_init(); 657 657 realtime_counter_init(); 658 658 659 - clocksource_probe(); 659 + timer_probe(); 660 660 } 661 661 #endif /* CONFIG_SOC_OMAP5 || CONFIG_SOC_DRA7XX */ 662 662
+1 -1
arch/arm/mach-rockchip/rockchip.c
··· 55 55 } 56 56 57 57 of_clk_init(NULL); 58 - clocksource_probe(); 58 + timer_probe(); 59 59 } 60 60 61 61 static void __init rockchip_dt_init(void)
+1 -1
arch/arm/mach-s3c24xx/Kconfig
··· 394 394 395 395 config MACH_S3C2416_DT 396 396 bool "Samsung S3C2416 machine using devicetree" 397 - select CLKSRC_OF 397 + select TIMER_OF 398 398 select USE_OF 399 399 select PINCTRL 400 400 select PINCTRL_S3C24XX
+1 -1
arch/arm/mach-s3c64xx/Kconfig
··· 336 336 337 337 config MACH_S3C64XX_DT 338 338 bool "Samsung S3C6400/S3C6410 machine using Device Tree" 339 - select CLKSRC_OF 339 + select TIMER_OF 340 340 select CPU_S3C6400 341 341 select CPU_S3C6410 342 342 select PINCTRL
+1 -1
arch/arm/mach-shmobile/setup-rcar-gen2.c
··· 113 113 #endif /* CONFIG_ARM_ARCH_TIMER */ 114 114 115 115 of_clk_init(NULL); 116 - clocksource_probe(); 116 + timer_probe(); 117 117 } 118 118 119 119 struct memory_reserve_config {
+1 -1
arch/arm/mach-spear/spear13xx.c
··· 124 124 clk_put(pclk); 125 125 126 126 spear_setup_of_timer(); 127 - clocksource_probe(); 127 + timer_probe(); 128 128 }
+1 -1
arch/arm/mach-sunxi/sunxi.c
··· 42 42 of_clk_init(NULL); 43 43 if (IS_ENABLED(CONFIG_RESET_CONTROLLER)) 44 44 sun6i_reset_init(); 45 - clocksource_probe(); 45 + timer_probe(); 46 46 } 47 47 48 48 DT_MACHINE_START(SUN6I_DT, "Allwinner sun6i (A31) Family")
+1 -1
arch/arm/mach-u300/core.c
··· 407 407 DT_MACHINE_START(U300_DT, "U300 S335/B335 (Device Tree)") 408 408 .map_io = u300_map_io, 409 409 .init_irq = u300_init_irq_dt, 410 - .init_time = clocksource_probe, 410 + .init_time = timer_probe, 411 411 .init_machine = u300_init_machine_dt, 412 412 .restart = u300_restart, 413 413 .dt_compat = u300_board_compat,
+1 -1
arch/arm/mach-zynq/common.c
··· 150 150 { 151 151 zynq_clock_init(); 152 152 of_clk_init(NULL); 153 - clocksource_probe(); 153 + timer_probe(); 154 154 } 155 155 156 156 static struct map_desc zynq_cortex_a9_scu_map __initdata = {
+2 -2
arch/arm64/Kconfig.platforms
··· 18 18 19 19 config ARCH_BCM2835 20 20 bool "Broadcom BCM2835 family" 21 - select CLKSRC_OF 21 + select TIMER_OF 22 22 select GPIOLIB 23 23 select PINCTRL 24 24 select PINCTRL_BCM2835 ··· 178 178 select ARCH_HAS_RESET_CONTROLLER 179 179 select CLKDEV_LOOKUP 180 180 select CLKSRC_MMIO 181 - select CLKSRC_OF 181 + select TIMER_OF 182 182 select GENERIC_CLOCKEVENTS 183 183 select GPIOLIB 184 184 select PINCTRL
+1 -1
arch/arm64/kernel/time.c
··· 70 70 u32 arch_timer_rate; 71 71 72 72 of_clk_init(NULL); 73 - clocksource_probe(); 73 + timer_probe(); 74 74 75 75 tick_setup_hrtimer_broadcast(); 76 76
+1 -1
arch/h8300/Kconfig
··· 15 15 select OF_IRQ 16 16 select OF_EARLY_FLATTREE 17 17 select HAVE_MEMBLOCK 18 - select CLKSRC_OF 18 + select TIMER_OF 19 19 select H8300_TMR8 20 20 select HAVE_KERNEL_GZIP 21 21 select HAVE_KERNEL_LZO
+1 -1
arch/h8300/kernel/setup.c
··· 246 246 void __init time_init(void) 247 247 { 248 248 of_clk_init(NULL); 249 - clocksource_probe(); 249 + timer_probe(); 250 250 }
+1 -1
arch/microblaze/Kconfig
··· 4 4 select ARCH_MIGHT_HAVE_PC_PARPORT 5 5 select ARCH_WANT_IPC_PARSE_VERSION 6 6 select BUILDTIME_EXTABLE_SORT 7 - select CLKSRC_OF 7 + select TIMER_OF 8 8 select CLONE_BACKWARDS3 9 9 select COMMON_CLK 10 10 select GENERIC_ATOMIC64
+1 -1
arch/microblaze/kernel/setup.c
··· 192 192 { 193 193 of_clk_init(NULL); 194 194 setup_cpuinfo_clk(); 195 - clocksource_probe(); 195 + timer_probe(); 196 196 } 197 197 198 198 #ifdef CONFIG_DEBUG_FS
+1 -1
arch/microblaze/kernel/timer.c
··· 333 333 return 0; 334 334 } 335 335 336 - CLOCKSOURCE_OF_DECLARE(xilinx_timer, "xlnx,xps-timer-1.00.a", 336 + TIMER_OF_DECLARE(xilinx_timer, "xlnx,xps-timer-1.00.a", 337 337 xilinx_timer_init);
+1 -1
arch/mips/generic/init.c
··· 161 161 } 162 162 } 163 163 164 - clocksource_probe(); 164 + timer_probe(); 165 165 } 166 166 167 167 void __init arch_init_irq(void)
+1 -1
arch/mips/mti-malta/malta-time.c
··· 265 265 (freq%1000000)*100/1000000); 266 266 #ifdef CONFIG_CLKSRC_MIPS_GIC 267 267 update_gic_frequency_dt(); 268 - clocksource_probe(); 268 + timer_probe(); 269 269 #endif 270 270 } 271 271 #endif
+1 -1
arch/mips/pic32/pic32mzda/time.c
··· 64 64 pr_info("CPU Clock: %ldMHz\n", rate / 1000000); 65 65 mips_hpt_frequency = rate / 2; 66 66 67 - clocksource_probe(); 67 + timer_probe(); 68 68 }
+1 -1
arch/mips/pistachio/time.c
··· 39 39 struct clk *clk; 40 40 41 41 of_clk_init(NULL); 42 - clocksource_probe(); 42 + timer_probe(); 43 43 44 44 np = of_get_cpu_node(0, NULL); 45 45 if (!np) {
+1 -1
arch/mips/ralink/Kconfig
··· 4 4 bool 5 5 depends on SOC_RT305X || SOC_MT7620 6 6 default y 7 - select CLKSRC_OF 7 + select TIMER_OF 8 8 select CLKSRC_MMIO 9 9 10 10 config RALINK_ILL_ACC
+1 -1
arch/mips/ralink/cevt-rt3352.c
··· 152 152 return 0; 153 153 } 154 154 155 - CLOCKSOURCE_OF_DECLARE(systick, "ralink,cevt-systick", ralink_systick_init); 155 + TIMER_OF_DECLARE(systick, "ralink,cevt-systick", ralink_systick_init);
+1 -1
arch/mips/ralink/clk.c
··· 82 82 pr_info("CPU Clock: %ldMHz\n", clk_get_rate(clk) / 1000000); 83 83 mips_hpt_frequency = clk_get_rate(clk) / 2; 84 84 clk_put(clk); 85 - clocksource_probe(); 85 + timer_probe(); 86 86 }
+1 -1
arch/mips/ralink/timer-gic.c
··· 20 20 ralink_of_remap(); 21 21 22 22 of_clk_init(NULL); 23 - clocksource_probe(); 23 + timer_probe(); 24 24 }
+1 -1
arch/mips/xilfpga/time.c
··· 22 22 struct clk *clk; 23 23 24 24 of_clk_init(NULL); 25 - clocksource_probe(); 25 + timer_probe(); 26 26 27 27 np = of_get_cpu_node(0, NULL); 28 28 if (!np) {
+1 -1
arch/nios2/Kconfig
··· 1 1 config NIOS2 2 2 def_bool y 3 - select CLKSRC_OF 3 + select TIMER_OF 4 4 select GENERIC_ATOMIC64 5 5 select GENERIC_CLOCKEVENTS 6 6 select GENERIC_CPU_DEVICES
+2 -2
arch/nios2/kernel/time.c
··· 350 350 if (count < 2) 351 351 panic("%d timer is found, it needs 2 timers in system\n", count); 352 352 353 - clocksource_probe(); 353 + timer_probe(); 354 354 } 355 355 356 - CLOCKSOURCE_OF_DECLARE(nios2_timer, ALTR_TIMER_COMPATIBLE, nios2_time_init); 356 + TIMER_OF_DECLARE(nios2_timer, ALTR_TIMER_COMPATIBLE, nios2_time_init);
+1 -1
arch/sh/boards/Kconfig
··· 10 10 bool "Board Described by Device Tree" 11 11 select OF 12 12 select OF_EARLY_FLATTREE 13 - select CLKSRC_OF 13 + select TIMER_OF 14 14 select COMMON_CLK 15 15 select GENERIC_CALIBRATE_DELAY 16 16 help
+1 -1
arch/sh/boards/of-generic.c
··· 119 119 static void __init sh_of_time_init(void) 120 120 { 121 121 pr_info("SH generic board support: scanning for clocksource devices\n"); 122 - clocksource_probe(); 122 + timer_probe(); 123 123 } 124 124 125 125 static void __init sh_of_setup(char **cmdline_p)
+1 -1
arch/xtensa/kernel/time.c
··· 187 187 local_timer_setup(0); 188 188 setup_irq(this_cpu_ptr(&ccount_timer)->evt.irq, &timer_irqaction); 189 189 sched_clock_register(ccount_sched_clock_read, 32, ccount_freq); 190 - clocksource_probe(); 190 + timer_probe(); 191 191 } 192 192 193 193 /*
+33 -46
drivers/clocksource/Kconfig
··· 1 1 menu "Clock Source drivers" 2 2 depends on !ARCH_USES_GETTIMEOFFSET 3 3 4 - config CLKSRC_OF 4 + config TIMER_OF 5 5 bool 6 - select CLKSRC_PROBE 6 + depends on GENERIC_CLOCKEVENTS 7 + select TIMER_PROBE 7 8 8 - config CLKEVT_OF 9 + config TIMER_ACPI 9 10 bool 10 - select CLKEVT_PROBE 11 + select TIMER_PROBE 11 12 12 - config CLKSRC_ACPI 13 - bool 14 - select CLKSRC_PROBE 15 - 16 - config CLKSRC_PROBE 17 - bool 18 - 19 - config CLKEVT_PROBE 13 + config TIMER_PROBE 20 14 bool 21 15 22 16 config CLKSRC_I8253 ··· 59 65 config DW_APB_TIMER_OF 60 66 bool 61 67 select DW_APB_TIMER 62 - select CLKSRC_OF 68 + select TIMER_OF 63 69 64 70 config FTTMR010_TIMER 65 71 bool "Faraday Technology timer driver" if COMPILE_TEST 66 72 depends on GENERIC_CLOCKEVENTS 67 73 depends on HAS_IOMEM 68 74 select CLKSRC_MMIO 69 - select CLKSRC_OF 75 + select TIMER_OF 70 76 select MFD_SYSCON 71 77 help 72 78 Enables support for the Faraday Technology timer block ··· 75 81 config ROCKCHIP_TIMER 76 82 bool "Rockchip timer driver" if COMPILE_TEST 77 83 depends on ARM || ARM64 78 - select CLKSRC_OF 84 + select TIMER_OF 79 85 select CLKSRC_MMIO 80 86 help 81 87 Enables the support for the rockchip timer driver. ··· 83 89 config ARMADA_370_XP_TIMER 84 90 bool "Armada 370 and XP timer driver" if COMPILE_TEST 85 91 depends on ARM 86 - select CLKSRC_OF 92 + select TIMER_OF 87 93 select CLKSRC_MMIO 88 94 help 89 95 Enables the support for the Armada 370 and XP timer driver. ··· 98 104 config ORION_TIMER 99 105 bool "Orion timer driver" if COMPILE_TEST 100 106 depends on ARM 101 - select CLKSRC_OF 107 + select TIMER_OF 102 108 select CLKSRC_MMIO 103 109 help 104 110 Enables the support for the Orion timer driver ··· 142 148 bool "ASM9260 timer driver" if COMPILE_TEST 143 149 depends on GENERIC_CLOCKEVENTS 144 150 select CLKSRC_MMIO 145 - select CLKSRC_OF 151 + select TIMER_OF 146 152 help 147 153 Enables support for the ASM9260 timer. 148 154 ··· 181 187 select CLKSRC_MMIO 182 188 help 183 189 Enables support for the Atlas7 timer. 184 - 185 - config MOXART_TIMER 186 - bool "Moxart timer driver" if COMPILE_TEST 187 - depends on GENERIC_CLOCKEVENTS 188 - select CLKSRC_MMIO 189 - help 190 - Enables support for the Moxart timer. 191 190 192 191 config MXS_TIMER 193 192 bool "Mxs timer driver" if COMPILE_TEST ··· 248 261 depends on GENERIC_CLOCKEVENTS && HAS_IOMEM 249 262 depends on ARM 250 263 select CLKSRC_MMIO 251 - select CLKSRC_OF 264 + select TIMER_OF 252 265 help 253 266 Support for the LPC32XX clocksource. 254 267 255 268 config CLKSRC_PISTACHIO 256 269 bool "Clocksource for Pistachio SoC" if COMPILE_TEST 257 270 depends on HAS_IOMEM 258 - select CLKSRC_OF 271 + select TIMER_OF 259 272 help 260 273 Enables the clocksource for the Pistachio SoC. 261 274 262 275 config CLKSRC_TI_32K 263 276 bool "Texas Instruments 32.768 Hz Clocksource" if COMPILE_TEST 264 277 depends on GENERIC_SCHED_CLOCK 265 - select CLKSRC_OF if OF 278 + select TIMER_OF if OF 266 279 help 267 280 This option enables support for Texas Instruments 32.768 Hz clocksource 268 281 available on many OMAP-like platforms. ··· 271 284 bool "NPS400 clocksource driver" if COMPILE_TEST 272 285 depends on !PHYS_ADDR_T_64BIT 273 286 select CLKSRC_MMIO 274 - select CLKSRC_OF if OF 287 + select TIMER_OF if OF 275 288 help 276 289 NPS400 clocksource support. 277 290 Got 64 bit counter with update rate up to 1000MHz. ··· 286 299 bool "Clocksource for MPS2 SoCs" if COMPILE_TEST 287 300 depends on GENERIC_SCHED_CLOCK 288 301 select CLKSRC_MMIO 289 - select CLKSRC_OF 302 + select TIMER_OF 290 303 291 304 config ARC_TIMERS 292 305 bool "Support for 32-bit TIMERn counters in ARC Cores" if COMPILE_TEST 293 306 depends on GENERIC_CLOCKEVENTS 294 - select CLKSRC_OF 307 + select TIMER_OF 295 308 help 296 309 These are legacy 32-bit TIMER0 and TIMER1 counters found on all ARC cores 297 310 (ARC700 as well as ARC HS38). ··· 301 314 bool "Support for 64-bit counters in ARC HS38 cores" if COMPILE_TEST 302 315 depends on GENERIC_CLOCKEVENTS 303 316 depends on ARC_TIMERS 304 - select CLKSRC_OF 317 + select TIMER_OF 305 318 help 306 319 This enables 2 different 64-bit timers: RTC (for UP) and GFRC (for SMP) 307 320 RTC is implemented inside the core, while GFRC sits outside the core in ··· 310 323 311 324 config ARM_ARCH_TIMER 312 325 bool 313 - select CLKSRC_OF if OF 314 - select CLKSRC_ACPI if ACPI 326 + select TIMER_OF if OF 327 + select TIMER_ACPI if ACPI 315 328 316 329 config ARM_ARCH_TIMER_EVTSTREAM 317 330 bool "Enable ARM architected timer event stream generation by default" ··· 368 381 369 382 config ARM_GLOBAL_TIMER 370 383 bool "Support for the ARM global timer" if COMPILE_TEST 371 - select CLKSRC_OF if OF 384 + select TIMER_OF if OF 372 385 depends on ARM 373 386 help 374 387 This options enables support for the ARM global timer unit ··· 377 390 bool "Support for Dual Timer SP804 module" 378 391 depends on GENERIC_SCHED_CLOCK && CLKDEV_LOOKUP 379 392 select CLKSRC_MMIO 380 - select CLKSRC_OF if OF 393 + select TIMER_OF if OF 381 394 382 395 config CLKSRC_ARM_GLOBAL_TIMER_SCHED_CLOCK 383 396 bool ··· 388 401 389 402 config ARMV7M_SYSTICK 390 403 bool "Support for the ARMv7M system time" if COMPILE_TEST 391 - select CLKSRC_OF if OF 404 + select TIMER_OF if OF 392 405 select CLKSRC_MMIO 393 406 help 394 407 This options enables support for the ARMv7M system timer unit 395 408 396 409 config ATMEL_PIT 397 - select CLKSRC_OF if OF 410 + select TIMER_OF if OF 398 411 def_bool SOC_AT91SAM9 || SOC_SAMA5 399 412 400 413 config ATMEL_ST 401 414 bool "Atmel ST timer support" if COMPILE_TEST 402 415 depends on GENERIC_CLOCKEVENTS 403 - select CLKSRC_OF 416 + select TIMER_OF 404 417 select MFD_SYSCON 405 418 help 406 419 Support for the Atmel ST timer. ··· 443 456 config OXNAS_RPS_TIMER 444 457 bool "Oxford Semiconductor OXNAS RPS Timers driver" if COMPILE_TEST 445 458 depends on GENERIC_CLOCKEVENTS 446 - select CLKSRC_OF 459 + select TIMER_OF 447 460 select CLKSRC_MMIO 448 461 help 449 462 This enables support for the Oxford Semiconductor OXNAS RPS timers. ··· 454 467 config MTK_TIMER 455 468 bool "Mediatek timer driver" if COMPILE_TEST 456 469 depends on GENERIC_CLOCKEVENTS && HAS_IOMEM 457 - select CLKSRC_OF 470 + select TIMER_OF 458 471 select CLKSRC_MMIO 459 472 help 460 473 Support for Mediatek timer driver. ··· 527 540 config CLKSRC_QCOM 528 541 bool "Qualcomm MSM timer" if COMPILE_TEST 529 542 depends on ARM 530 - select CLKSRC_OF 543 + select TIMER_OF 531 544 help 532 545 This enables the clocksource and the per CPU clockevent driver for the 533 546 Qualcomm SoCs. ··· 535 548 config CLKSRC_VERSATILE 536 549 bool "ARM Versatile (Express) reference platforms clock source" if COMPILE_TEST 537 550 depends on GENERIC_SCHED_CLOCK && !ARCH_USES_GETTIMEOFFSET 538 - select CLKSRC_OF 551 + select TIMER_OF 539 552 default y if MFD_VEXPRESS_SYSREG 540 553 help 541 554 This option enables clock source based on free running ··· 546 559 config CLKSRC_MIPS_GIC 547 560 bool 548 561 depends on MIPS_GIC 549 - select CLKSRC_OF 562 + select TIMER_OF 550 563 551 564 config CLKSRC_TANGO_XTAL 552 565 bool "Clocksource for Tango SoC" if COMPILE_TEST 553 566 depends on ARM 554 - select CLKSRC_OF 567 + select TIMER_OF 555 568 select CLKSRC_MMIO 556 569 help 557 570 This enables the clocksource for Tango SoC ··· 592 605 593 606 config CLKSRC_ST_LPC 594 607 bool "Low power clocksource found in the LPC" if COMPILE_TEST 595 - select CLKSRC_OF if OF 608 + select TIMER_OF if OF 596 609 depends on HAS_IOMEM 597 610 select CLKSRC_MMIO 598 611 help
+2 -3
drivers/clocksource/Makefile
··· 1 - obj-$(CONFIG_CLKSRC_PROBE) += clksrc-probe.o 2 - obj-$(CONFIG_CLKEVT_PROBE) += clkevt-probe.o 1 + obj-$(CONFIG_TIMER_OF) += timer-of.o 2 + obj-$(CONFIG_TIMER_PROBE) += timer-probe.o 3 3 obj-$(CONFIG_ATMEL_PIT) += timer-atmel-pit.o 4 4 obj-$(CONFIG_ATMEL_ST) += timer-atmel-st.o 5 5 obj-$(CONFIG_ATMEL_TCB_CLKSRC) += tcb_clksrc.o ··· 26 26 obj-$(CONFIG_BCM2835_TIMER) += bcm2835_timer.o 27 27 obj-$(CONFIG_CLPS711X_TIMER) += clps711x-timer.o 28 28 obj-$(CONFIG_ATLAS7_TIMER) += timer-atlas7.o 29 - obj-$(CONFIG_MOXART_TIMER) += moxart_timer.o 30 29 obj-$(CONFIG_MXS_TIMER) += mxs_timer.o 31 30 obj-$(CONFIG_CLKSRC_PXA) += pxa_timer.o 32 31 obj-$(CONFIG_PRIMA2_TIMER) += timer-prima2.o
+3 -3
drivers/clocksource/arc_timer.c
··· 99 99 100 100 return clocksource_register_hz(&arc_counter_gfrc, arc_timer_freq); 101 101 } 102 - CLOCKSOURCE_OF_DECLARE(arc_gfrc, "snps,archs-timer-gfrc", arc_cs_setup_gfrc); 102 + TIMER_OF_DECLARE(arc_gfrc, "snps,archs-timer-gfrc", arc_cs_setup_gfrc); 103 103 104 104 #define AUX_RTC_CTRL 0x103 105 105 #define AUX_RTC_LOW 0x104 ··· 158 158 159 159 return clocksource_register_hz(&arc_counter_rtc, arc_timer_freq); 160 160 } 161 - CLOCKSOURCE_OF_DECLARE(arc_rtc, "snps,archs-timer-rtc", arc_cs_setup_rtc); 161 + TIMER_OF_DECLARE(arc_rtc, "snps,archs-timer-rtc", arc_cs_setup_rtc); 162 162 163 163 #endif 164 164 ··· 333 333 334 334 return ret; 335 335 } 336 - CLOCKSOURCE_OF_DECLARE(arc_clkevt, "snps,arc-timer", arc_of_timer_init); 336 + TIMER_OF_DECLARE(arc_clkevt, "snps,arc-timer", arc_of_timer_init);
+4 -4
drivers/clocksource/arm_arch_timer.c
··· 1194 1194 1195 1195 return arch_timer_common_init(); 1196 1196 } 1197 - CLOCKSOURCE_OF_DECLARE(armv7_arch_timer, "arm,armv7-timer", arch_timer_of_init); 1198 - CLOCKSOURCE_OF_DECLARE(armv8_arch_timer, "arm,armv8-timer", arch_timer_of_init); 1197 + TIMER_OF_DECLARE(armv7_arch_timer, "arm,armv7-timer", arch_timer_of_init); 1198 + TIMER_OF_DECLARE(armv8_arch_timer, "arm,armv8-timer", arch_timer_of_init); 1199 1199 1200 1200 static u32 __init 1201 1201 arch_timer_mem_frame_get_cntfrq(struct arch_timer_mem_frame *frame) ··· 1382 1382 kfree(timer_mem); 1383 1383 return ret; 1384 1384 } 1385 - CLOCKSOURCE_OF_DECLARE(armv7_arch_timer_mem, "arm,armv7-timer-mem", 1385 + TIMER_OF_DECLARE(armv7_arch_timer_mem, "arm,armv7-timer-mem", 1386 1386 arch_timer_mem_of_init); 1387 1387 1388 1388 #ifdef CONFIG_ACPI_GTDT ··· 1516 1516 1517 1517 return arch_timer_common_init(); 1518 1518 } 1519 - CLOCKSOURCE_ACPI_DECLARE(arch_timer, ACPI_SIG_GTDT, arch_timer_acpi_init); 1519 + TIMER_ACPI_DECLARE(arch_timer, ACPI_SIG_GTDT, arch_timer_acpi_init); 1520 1520 #endif
+1 -1
drivers/clocksource/arm_global_timer.c
··· 339 339 } 340 340 341 341 /* Only tested on r2p2 and r3p0 */ 342 - CLOCKSOURCE_OF_DECLARE(arm_gt, "arm,cortex-a9-global-timer", 342 + TIMER_OF_DECLARE(arm_gt, "arm,cortex-a9-global-timer", 343 343 global_timer_of_register);
+1 -1
drivers/clocksource/armv7m_systick.c
··· 82 82 return ret; 83 83 } 84 84 85 - CLOCKSOURCE_OF_DECLARE(arm_systick, "arm,armv7m-systick", 85 + TIMER_OF_DECLARE(arm_systick, "arm,armv7m-systick", 86 86 system_timer_of_register);
+1 -1
drivers/clocksource/asm9260_timer.c
··· 238 238 239 239 return 0; 240 240 } 241 - CLOCKSOURCE_OF_DECLARE(asm9260_timer, "alphascale,asm9260-timer", 241 + TIMER_OF_DECLARE(asm9260_timer, "alphascale,asm9260-timer", 242 242 asm9260_timer_init);
+1 -1
drivers/clocksource/bcm2835_timer.c
··· 148 148 iounmap(base); 149 149 return ret; 150 150 } 151 - CLOCKSOURCE_OF_DECLARE(bcm2835, "brcm,bcm2835-system-timer", 151 + TIMER_OF_DECLARE(bcm2835, "brcm,bcm2835-system-timer", 152 152 bcm2835_timer_init);
+2 -2
drivers/clocksource/bcm_kona_timer.c
··· 198 198 return 0; 199 199 } 200 200 201 - CLOCKSOURCE_OF_DECLARE(brcm_kona, "brcm,kona-timer", kona_timer_init); 201 + TIMER_OF_DECLARE(brcm_kona, "brcm,kona-timer", kona_timer_init); 202 202 /* 203 203 * bcm,kona-timer is deprecated by brcm,kona-timer 204 204 * being kept here for driver compatibility 205 205 */ 206 - CLOCKSOURCE_OF_DECLARE(bcm_kona, "bcm,kona-timer", kona_timer_init); 206 + TIMER_OF_DECLARE(bcm_kona, "bcm,kona-timer", kona_timer_init);
+1 -1
drivers/clocksource/cadence_ttc_timer.c
··· 539 539 return 0; 540 540 } 541 541 542 - CLOCKSOURCE_OF_DECLARE(ttc, "cdns,ttc", ttc_timer_init); 542 + TIMER_OF_DECLARE(ttc, "cdns,ttc", ttc_timer_init);
-56
drivers/clocksource/clkevt-probe.c
··· 1 - /* 2 - * Copyright (c) 2016, Linaro Ltd. All rights reserved. 3 - * Daniel Lezcano <daniel.lezcano@linaro.org> 4 - * 5 - * This program is free software; you can redistribute it and/or modify it 6 - * under the terms and conditions of the GNU General Public License, 7 - * version 2, as published by the Free Software Foundation. 8 - * 9 - * This program is distributed in the hope it will be useful, but WITHOUT 10 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 - * more details. 13 - * 14 - * You should have received a copy of the GNU General Public License 15 - * along with this program. If not, see <http://www.gnu.org/licenses/>. 16 - */ 17 - 18 - #include <linux/init.h> 19 - #include <linux/of.h> 20 - #include <linux/clockchips.h> 21 - 22 - extern struct of_device_id __clkevt_of_table[]; 23 - 24 - static const struct of_device_id __clkevt_of_table_sentinel 25 - __used __section(__clkevt_of_table_end); 26 - 27 - int __init clockevent_probe(void) 28 - { 29 - struct device_node *np; 30 - const struct of_device_id *match; 31 - of_init_fn_1_ret init_func; 32 - int ret, clockevents = 0; 33 - 34 - for_each_matching_node_and_match(np, __clkevt_of_table, &match) { 35 - if (!of_device_is_available(np)) 36 - continue; 37 - 38 - init_func = match->data; 39 - 40 - ret = init_func(np); 41 - if (ret) { 42 - pr_warn("Failed to initialize '%s' (%d)\n", 43 - np->name, ret); 44 - continue; 45 - } 46 - 47 - clockevents++; 48 - } 49 - 50 - if (!clockevents) { 51 - pr_crit("%s: no matching clockevent found\n", __func__); 52 - return -ENODEV; 53 - } 54 - 55 - return 0; 56 - }
+1 -1
drivers/clocksource/clksrc-dbx500-prcmu.c
··· 86 86 #endif 87 87 return clocksource_register_hz(&clocksource_dbx500_prcmu, RATE_32K); 88 88 } 89 - CLOCKSOURCE_OF_DECLARE(dbx500_prcmu, "stericsson,db8500-prcmu-timer-4", 89 + TIMER_OF_DECLARE(dbx500_prcmu, "stericsson,db8500-prcmu-timer-4", 90 90 clksrc_dbx500_prcmu_init);
+10 -10
drivers/clocksource/clksrc-probe.c drivers/clocksource/timer-probe.c
··· 19 19 #include <linux/of.h> 20 20 #include <linux/clocksource.h> 21 21 22 - extern struct of_device_id __clksrc_of_table[]; 22 + extern struct of_device_id __timer_of_table[]; 23 23 24 - static const struct of_device_id __clksrc_of_table_sentinel 25 - __used __section(__clksrc_of_table_end); 24 + static const struct of_device_id __timer_of_table_sentinel 25 + __used __section(__timer_of_table_end); 26 26 27 - void __init clocksource_probe(void) 27 + void __init timer_probe(void) 28 28 { 29 29 struct device_node *np; 30 30 const struct of_device_id *match; 31 31 of_init_fn_1_ret init_func_ret; 32 - unsigned clocksources = 0; 32 + unsigned timers = 0; 33 33 int ret; 34 34 35 - for_each_matching_node_and_match(np, __clksrc_of_table, &match) { 35 + for_each_matching_node_and_match(np, __timer_of_table, &match) { 36 36 if (!of_device_is_available(np)) 37 37 continue; 38 38 ··· 45 45 continue; 46 46 } 47 47 48 - clocksources++; 48 + timers++; 49 49 } 50 50 51 - clocksources += acpi_probe_device_table(clksrc); 51 + timers += acpi_probe_device_table(timer); 52 52 53 - if (!clocksources) 54 - pr_crit("%s: no matching clocksources found\n", __func__); 53 + if (!timers) 54 + pr_crit("%s: no matching timers found\n", __func__); 55 55 }
+1 -1
drivers/clocksource/clksrc_st_lpc.c
··· 132 132 133 133 return ret; 134 134 } 135 - CLOCKSOURCE_OF_DECLARE(ddata, "st,stih407-lpc", st_clksrc_of_register); 135 + TIMER_OF_DECLARE(ddata, "st,stih407-lpc", st_clksrc_of_register);
+2 -2
drivers/clocksource/clps711x-timer.c
··· 103 103 BUG_ON(_clps711x_clkevt_init(tc2, tc2_base, irq)); 104 104 } 105 105 106 - #ifdef CONFIG_CLKSRC_OF 106 + #ifdef CONFIG_TIMER_OF 107 107 static int __init clps711x_timer_init(struct device_node *np) 108 108 { 109 109 unsigned int irq = irq_of_parse_and_map(np, 0); ··· 119 119 return -EINVAL; 120 120 } 121 121 } 122 - CLOCKSOURCE_OF_DECLARE(clps711x, "cirrus,ep7209-timer", clps711x_timer_init); 122 + TIMER_OF_DECLARE(clps711x, "cirrus,ep7209-timer", clps711x_timer_init); 123 123 #endif
+4 -4
drivers/clocksource/dw_apb_timer_of.c
··· 167 167 168 168 return 0; 169 169 } 170 - CLOCKSOURCE_OF_DECLARE(pc3x2_timer, "picochip,pc3x2-timer", dw_apb_timer_init); 171 - CLOCKSOURCE_OF_DECLARE(apb_timer_osc, "snps,dw-apb-timer-osc", dw_apb_timer_init); 172 - CLOCKSOURCE_OF_DECLARE(apb_timer_sp, "snps,dw-apb-timer-sp", dw_apb_timer_init); 173 - CLOCKSOURCE_OF_DECLARE(apb_timer, "snps,dw-apb-timer", dw_apb_timer_init); 170 + TIMER_OF_DECLARE(pc3x2_timer, "picochip,pc3x2-timer", dw_apb_timer_init); 171 + TIMER_OF_DECLARE(apb_timer_osc, "snps,dw-apb-timer-osc", dw_apb_timer_init); 172 + TIMER_OF_DECLARE(apb_timer_sp, "snps,dw-apb-timer-sp", dw_apb_timer_init); 173 + TIMER_OF_DECLARE(apb_timer, "snps,dw-apb-timer", dw_apb_timer_init);
+2 -2
drivers/clocksource/exynos_mct.c
··· 610 610 { 611 611 return mct_init_dt(np, MCT_INT_PPI); 612 612 } 613 - CLOCKSOURCE_OF_DECLARE(exynos4210, "samsung,exynos4210-mct", mct_init_spi); 614 - CLOCKSOURCE_OF_DECLARE(exynos4412, "samsung,exynos4412-mct", mct_init_ppi); 613 + TIMER_OF_DECLARE(exynos4210, "samsung,exynos4210-mct", mct_init_spi); 614 + TIMER_OF_DECLARE(exynos4412, "samsung,exynos4412-mct", mct_init_ppi);
+1 -1
drivers/clocksource/fsl_ftm_timer.c
··· 369 369 kfree(priv); 370 370 return ret; 371 371 } 372 - CLOCKSOURCE_OF_DECLARE(flextimer, "fsl,ftm-timer", ftm_timer_init); 372 + TIMER_OF_DECLARE(flextimer, "fsl,ftm-timer", ftm_timer_init);
+1 -1
drivers/clocksource/h8300_timer16.c
··· 187 187 return ret; 188 188 } 189 189 190 - CLOCKSOURCE_OF_DECLARE(h8300_16bit, "renesas,16bit-timer", 190 + TIMER_OF_DECLARE(h8300_16bit, "renesas,16bit-timer", 191 191 h8300_16timer_init);
+1 -1
drivers/clocksource/h8300_timer8.c
··· 207 207 return ret; 208 208 } 209 209 210 - CLOCKSOURCE_OF_DECLARE(h8300_8bit, "renesas,8bit-timer", h8300_8timer_init); 210 + TIMER_OF_DECLARE(h8300_8bit, "renesas,8bit-timer", h8300_8timer_init);
+1 -1
drivers/clocksource/h8300_tpu.c
··· 154 154 return ret; 155 155 } 156 156 157 - CLOCKSOURCE_OF_DECLARE(h8300_tpu, "renesas,tpu", h8300_tpu_init); 157 + TIMER_OF_DECLARE(h8300_tpu, "renesas,tpu", h8300_tpu_init);
+1 -1
drivers/clocksource/jcore-pit.c
··· 246 246 return 0; 247 247 } 248 248 249 - CLOCKSOURCE_OF_DECLARE(jcore_pit, "jcore,pit", jcore_pit_init); 249 + TIMER_OF_DECLARE(jcore_pit, "jcore,pit", jcore_pit_init);
+1 -1
drivers/clocksource/meson6_timer.c
··· 174 174 1, 0xfffe); 175 175 return 0; 176 176 } 177 - CLOCKSOURCE_OF_DECLARE(meson6, "amlogic,meson6-timer", 177 + TIMER_OF_DECLARE(meson6, "amlogic,meson6-timer", 178 178 meson6_timer_init);
+1 -1
drivers/clocksource/mips-gic-timer.c
··· 200 200 201 201 return 0; 202 202 } 203 - CLOCKSOURCE_OF_DECLARE(mips_gic_timer, "mti,gic-timer", 203 + TIMER_OF_DECLARE(mips_gic_timer, "mti,gic-timer", 204 204 gic_clocksource_of_init);
-256
drivers/clocksource/moxart_timer.c
··· 1 - /* 2 - * MOXA ART SoCs timer handling. 3 - * 4 - * Copyright (C) 2013 Jonas Jensen 5 - * 6 - * Jonas Jensen <jonas.jensen@gmail.com> 7 - * 8 - * This file is licensed under the terms of the GNU General Public 9 - * License version 2. This program is licensed "as is" without any 10 - * warranty of any kind, whether express or implied. 11 - */ 12 - 13 - #include <linux/clk.h> 14 - #include <linux/clockchips.h> 15 - #include <linux/interrupt.h> 16 - #include <linux/irq.h> 17 - #include <linux/irqreturn.h> 18 - #include <linux/of.h> 19 - #include <linux/of_address.h> 20 - #include <linux/of_irq.h> 21 - #include <linux/io.h> 22 - #include <linux/clocksource.h> 23 - #include <linux/bitops.h> 24 - #include <linux/slab.h> 25 - 26 - #define TIMER1_BASE 0x00 27 - #define TIMER2_BASE 0x10 28 - #define TIMER3_BASE 0x20 29 - 30 - #define REG_COUNT 0x0 /* writable */ 31 - #define REG_LOAD 0x4 32 - #define REG_MATCH1 0x8 33 - #define REG_MATCH2 0xC 34 - 35 - #define TIMER_CR 0x30 36 - #define TIMER_INTR_STATE 0x34 37 - #define TIMER_INTR_MASK 0x38 38 - 39 - /* 40 - * Moxart TIMER_CR flags: 41 - * 42 - * MOXART_CR_*_CLOCK 0: PCLK, 1: EXT1CLK 43 - * MOXART_CR_*_INT overflow interrupt enable bit 44 - */ 45 - #define MOXART_CR_1_ENABLE BIT(0) 46 - #define MOXART_CR_1_CLOCK BIT(1) 47 - #define MOXART_CR_1_INT BIT(2) 48 - #define MOXART_CR_2_ENABLE BIT(3) 49 - #define MOXART_CR_2_CLOCK BIT(4) 50 - #define MOXART_CR_2_INT BIT(5) 51 - #define MOXART_CR_3_ENABLE BIT(6) 52 - #define MOXART_CR_3_CLOCK BIT(7) 53 - #define MOXART_CR_3_INT BIT(8) 54 - #define MOXART_CR_COUNT_UP BIT(9) 55 - 56 - #define MOXART_TIMER1_ENABLE (MOXART_CR_2_ENABLE | MOXART_CR_1_ENABLE) 57 - #define MOXART_TIMER1_DISABLE (MOXART_CR_2_ENABLE) 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 - 76 - struct moxart_timer { 77 - void __iomem *base; 78 - unsigned int t1_disable_val; 79 - unsigned int t1_enable_val; 80 - unsigned int count_per_tick; 81 - struct clock_event_device clkevt; 82 - }; 83 - 84 - static inline struct moxart_timer *to_moxart(struct clock_event_device *evt) 85 - { 86 - return container_of(evt, struct moxart_timer, clkevt); 87 - } 88 - 89 - static inline void moxart_disable(struct clock_event_device *evt) 90 - { 91 - struct moxart_timer *timer = to_moxart(evt); 92 - 93 - writel(timer->t1_disable_val, timer->base + TIMER_CR); 94 - } 95 - 96 - static inline void moxart_enable(struct clock_event_device *evt) 97 - { 98 - struct moxart_timer *timer = to_moxart(evt); 99 - 100 - writel(timer->t1_enable_val, timer->base + TIMER_CR); 101 - } 102 - 103 - static int moxart_shutdown(struct clock_event_device *evt) 104 - { 105 - moxart_disable(evt); 106 - return 0; 107 - } 108 - 109 - static int moxart_set_oneshot(struct clock_event_device *evt) 110 - { 111 - moxart_disable(evt); 112 - writel(~0, to_moxart(evt)->base + TIMER1_BASE + REG_LOAD); 113 - return 0; 114 - } 115 - 116 - static int moxart_set_periodic(struct clock_event_device *evt) 117 - { 118 - struct moxart_timer *timer = to_moxart(evt); 119 - 120 - moxart_disable(evt); 121 - writel(timer->count_per_tick, timer->base + TIMER1_BASE + REG_LOAD); 122 - writel(0, timer->base + TIMER1_BASE + REG_MATCH1); 123 - moxart_enable(evt); 124 - return 0; 125 - } 126 - 127 - static int moxart_clkevt_next_event(unsigned long cycles, 128 - struct clock_event_device *evt) 129 - { 130 - struct moxart_timer *timer = to_moxart(evt); 131 - u32 u; 132 - 133 - moxart_disable(evt); 134 - 135 - u = readl(timer->base + TIMER1_BASE + REG_COUNT) - cycles; 136 - writel(u, timer->base + TIMER1_BASE + REG_MATCH1); 137 - 138 - moxart_enable(evt); 139 - 140 - return 0; 141 - } 142 - 143 - static irqreturn_t moxart_timer_interrupt(int irq, void *dev_id) 144 - { 145 - struct clock_event_device *evt = dev_id; 146 - evt->event_handler(evt); 147 - return IRQ_HANDLED; 148 - } 149 - 150 - static int __init moxart_timer_init(struct device_node *node) 151 - { 152 - int ret, irq; 153 - unsigned long pclk; 154 - struct clk *clk; 155 - struct moxart_timer *timer; 156 - 157 - timer = kzalloc(sizeof(*timer), GFP_KERNEL); 158 - if (!timer) 159 - return -ENOMEM; 160 - 161 - timer->base = of_iomap(node, 0); 162 - if (!timer->base) { 163 - pr_err("%s: of_iomap failed\n", node->full_name); 164 - ret = -ENXIO; 165 - goto out_free; 166 - } 167 - 168 - irq = irq_of_parse_and_map(node, 0); 169 - if (irq <= 0) { 170 - pr_err("%s: irq_of_parse_and_map failed\n", node->full_name); 171 - ret = -EINVAL; 172 - goto out_unmap; 173 - } 174 - 175 - clk = of_clk_get(node, 0); 176 - if (IS_ERR(clk)) { 177 - pr_err("%s: of_clk_get failed\n", node->full_name); 178 - ret = PTR_ERR(clk); 179 - goto out_unmap; 180 - } 181 - 182 - pclk = clk_get_rate(clk); 183 - 184 - if (of_device_is_compatible(node, "moxa,moxart-timer")) { 185 - timer->t1_enable_val = MOXART_TIMER1_ENABLE; 186 - timer->t1_disable_val = MOXART_TIMER1_DISABLE; 187 - } else if (of_device_is_compatible(node, "aspeed,ast2400-timer")) { 188 - timer->t1_enable_val = ASPEED_TIMER1_ENABLE; 189 - timer->t1_disable_val = ASPEED_TIMER1_DISABLE; 190 - } else { 191 - pr_err("%s: unknown platform\n", node->full_name); 192 - ret = -EINVAL; 193 - goto out_unmap; 194 - } 195 - 196 - timer->count_per_tick = DIV_ROUND_CLOSEST(pclk, HZ); 197 - 198 - timer->clkevt.name = node->name; 199 - timer->clkevt.rating = 200; 200 - timer->clkevt.features = CLOCK_EVT_FEAT_PERIODIC | 201 - CLOCK_EVT_FEAT_ONESHOT; 202 - timer->clkevt.set_state_shutdown = moxart_shutdown; 203 - timer->clkevt.set_state_periodic = moxart_set_periodic; 204 - timer->clkevt.set_state_oneshot = moxart_set_oneshot; 205 - timer->clkevt.tick_resume = moxart_set_oneshot; 206 - timer->clkevt.set_next_event = moxart_clkevt_next_event; 207 - timer->clkevt.cpumask = cpumask_of(0); 208 - timer->clkevt.irq = irq; 209 - 210 - ret = clocksource_mmio_init(timer->base + TIMER2_BASE + REG_COUNT, 211 - "moxart_timer", pclk, 200, 32, 212 - clocksource_mmio_readl_down); 213 - if (ret) { 214 - pr_err("%s: clocksource_mmio_init failed\n", node->full_name); 215 - goto out_unmap; 216 - } 217 - 218 - ret = request_irq(irq, moxart_timer_interrupt, IRQF_TIMER, 219 - node->name, &timer->clkevt); 220 - if (ret) { 221 - pr_err("%s: setup_irq failed\n", node->full_name); 222 - goto out_unmap; 223 - } 224 - 225 - /* Clear match registers */ 226 - writel(0, timer->base + TIMER1_BASE + REG_MATCH1); 227 - writel(0, timer->base + TIMER1_BASE + REG_MATCH2); 228 - writel(0, timer->base + TIMER2_BASE + REG_MATCH1); 229 - writel(0, timer->base + TIMER2_BASE + REG_MATCH2); 230 - 231 - /* 232 - * Start timer 2 rolling as our main wall clock source, keep timer 1 233 - * disabled 234 - */ 235 - writel(0, timer->base + TIMER_CR); 236 - writel(~0, timer->base + TIMER2_BASE + REG_LOAD); 237 - writel(timer->t1_disable_val, timer->base + TIMER_CR); 238 - 239 - /* 240 - * documentation is not publicly available: 241 - * min_delta / max_delta obtained by trial-and-error, 242 - * max_delta 0xfffffffe should be ok because count 243 - * register size is u32 244 - */ 245 - clockevents_config_and_register(&timer->clkevt, pclk, 0x4, 0xfffffffe); 246 - 247 - return 0; 248 - 249 - out_unmap: 250 - iounmap(timer->base); 251 - out_free: 252 - kfree(timer); 253 - return ret; 254 - } 255 - CLOCKSOURCE_OF_DECLARE(moxart, "moxa,moxart-timer", moxart_timer_init); 256 - CLOCKSOURCE_OF_DECLARE(aspeed, "aspeed,ast2400-timer", moxart_timer_init);
+1 -1
drivers/clocksource/mps2-timer.c
··· 274 274 return 0; 275 275 } 276 276 277 - CLOCKSOURCE_OF_DECLARE(mps2_timer, "arm,mps2-timer", mps2_timer_init); 277 + TIMER_OF_DECLARE(mps2_timer, "arm,mps2-timer", mps2_timer_init);
+1 -1
drivers/clocksource/mtk_timer.c
··· 265 265 266 266 return -EINVAL; 267 267 } 268 - CLOCKSOURCE_OF_DECLARE(mtk_mt6577, "mediatek,mt6577-timer", mtk_timer_init); 268 + TIMER_OF_DECLARE(mtk_mt6577, "mediatek,mt6577-timer", mtk_timer_init);
+1 -1
drivers/clocksource/mxs_timer.c
··· 293 293 294 294 return setup_irq(irq, &mxs_timer_irq); 295 295 } 296 - CLOCKSOURCE_OF_DECLARE(mxs, "fsl,timrot", mxs_timer_init); 296 + TIMER_OF_DECLARE(mxs, "fsl,timrot", mxs_timer_init);
+1 -1
drivers/clocksource/nomadik-mtu.c
··· 284 284 285 285 return nmdk_timer_init(base, irq, pclk, clk); 286 286 } 287 - CLOCKSOURCE_OF_DECLARE(nomadik_mtu, "st,nomadik-mtu", 287 + TIMER_OF_DECLARE(nomadik_mtu, "st,nomadik-mtu", 288 288 nmdk_timer_of_init);
+1 -1
drivers/clocksource/pxa_timer.c
··· 216 216 217 217 return pxa_timer_common_init(irq, clk_get_rate(clk)); 218 218 } 219 - CLOCKSOURCE_OF_DECLARE(pxa_timer, "marvell,pxa-timer", pxa_timer_dt_init); 219 + TIMER_OF_DECLARE(pxa_timer, "marvell,pxa-timer", pxa_timer_dt_init); 220 220 221 221 /* 222 222 * Legacy timer init for non device-tree boards.
+2 -2
drivers/clocksource/qcom-timer.c
··· 254 254 255 255 return msm_timer_init(freq, 32, irq, !!percpu_offset); 256 256 } 257 - CLOCKSOURCE_OF_DECLARE(kpss_timer, "qcom,kpss-timer", msm_dt_timer_init); 258 - CLOCKSOURCE_OF_DECLARE(scss_timer, "qcom,scss-timer", msm_dt_timer_init); 257 + TIMER_OF_DECLARE(kpss_timer, "qcom,kpss-timer", msm_dt_timer_init); 258 + TIMER_OF_DECLARE(scss_timer, "qcom,scss-timer", msm_dt_timer_init);
+1 -1
drivers/clocksource/renesas-ostm.c
··· 262 262 return 0; 263 263 } 264 264 265 - CLOCKSOURCE_OF_DECLARE(ostm, "renesas,ostm", ostm_init); 265 + TIMER_OF_DECLARE(ostm, "renesas,ostm", ostm_init);
+2 -2
drivers/clocksource/rockchip_timer.c
··· 303 303 return -EINVAL; 304 304 } 305 305 306 - CLOCKSOURCE_OF_DECLARE(rk3288_timer, "rockchip,rk3288-timer", rk_timer_init); 307 - CLOCKSOURCE_OF_DECLARE(rk3399_timer, "rockchip,rk3399-timer", rk_timer_init); 306 + TIMER_OF_DECLARE(rk3288_timer, "rockchip,rk3288-timer", rk_timer_init); 307 + TIMER_OF_DECLARE(rk3399_timer, "rockchip,rk3399-timer", rk_timer_init);
+5 -5
drivers/clocksource/samsung_pwm_timer.c
··· 418 418 _samsung_pwm_clocksource_init(); 419 419 } 420 420 421 - #ifdef CONFIG_CLKSRC_OF 421 + #ifdef CONFIG_TIMER_OF 422 422 static int __init samsung_pwm_alloc(struct device_node *np, 423 423 const struct samsung_pwm_variant *variant) 424 424 { ··· 466 466 { 467 467 return samsung_pwm_alloc(np, &s3c24xx_variant); 468 468 } 469 - CLOCKSOURCE_OF_DECLARE(s3c2410_pwm, "samsung,s3c2410-pwm", s3c2410_pwm_clocksource_init); 469 + TIMER_OF_DECLARE(s3c2410_pwm, "samsung,s3c2410-pwm", s3c2410_pwm_clocksource_init); 470 470 471 471 static const struct samsung_pwm_variant s3c64xx_variant = { 472 472 .bits = 32, ··· 479 479 { 480 480 return samsung_pwm_alloc(np, &s3c64xx_variant); 481 481 } 482 - CLOCKSOURCE_OF_DECLARE(s3c6400_pwm, "samsung,s3c6400-pwm", s3c64xx_pwm_clocksource_init); 482 + TIMER_OF_DECLARE(s3c6400_pwm, "samsung,s3c6400-pwm", s3c64xx_pwm_clocksource_init); 483 483 484 484 static const struct samsung_pwm_variant s5p64x0_variant = { 485 485 .bits = 32, ··· 492 492 { 493 493 return samsung_pwm_alloc(np, &s5p64x0_variant); 494 494 } 495 - CLOCKSOURCE_OF_DECLARE(s5p6440_pwm, "samsung,s5p6440-pwm", s5p64x0_pwm_clocksource_init); 495 + TIMER_OF_DECLARE(s5p6440_pwm, "samsung,s5p6440-pwm", s5p64x0_pwm_clocksource_init); 496 496 497 497 static const struct samsung_pwm_variant s5p_variant = { 498 498 .bits = 32, ··· 505 505 { 506 506 return samsung_pwm_alloc(np, &s5p_variant); 507 507 } 508 - CLOCKSOURCE_OF_DECLARE(s5pc100_pwm, "samsung,s5pc100-pwm", s5p_pwm_clocksource_init); 508 + TIMER_OF_DECLARE(s5pc100_pwm, "samsung,s5pc100-pwm", s5p_pwm_clocksource_init); 509 509 #endif
+1 -1
drivers/clocksource/sun4i_timer.c
··· 233 233 234 234 return ret; 235 235 } 236 - CLOCKSOURCE_OF_DECLARE(sun4i, "allwinner,sun4i-a10-timer", 236 + TIMER_OF_DECLARE(sun4i, "allwinner,sun4i-a10-timer", 237 237 sun4i_timer_init);
+1 -1
drivers/clocksource/tango_xtal.c
··· 53 53 return 0; 54 54 } 55 55 56 - CLOCKSOURCE_OF_DECLARE(tango, "sigma,tick-counter", tango_clocksource_init); 56 + TIMER_OF_DECLARE(tango, "sigma,tick-counter", tango_clocksource_init);
+51
drivers/clocksource/tcb_clksrc.c
··· 9 9 #include <linux/ioport.h> 10 10 #include <linux/io.h> 11 11 #include <linux/platform_device.h> 12 + #include <linux/syscore_ops.h> 12 13 #include <linux/atmel_tc.h> 13 14 14 15 ··· 41 40 */ 42 41 43 42 static void __iomem *tcaddr; 43 + static struct 44 + { 45 + u32 cmr; 46 + u32 imr; 47 + u32 rc; 48 + bool clken; 49 + } tcb_cache[3]; 50 + static u32 bmr_cache; 44 51 45 52 static u64 tc_get_cycles(struct clocksource *cs) 46 53 { ··· 70 61 return __raw_readl(tcaddr + ATMEL_TC_REG(0, CV)); 71 62 } 72 63 64 + void tc_clksrc_suspend(struct clocksource *cs) 65 + { 66 + int i; 67 + 68 + for (i = 0; i < ARRAY_SIZE(tcb_cache); i++) { 69 + tcb_cache[i].cmr = readl(tcaddr + ATMEL_TC_REG(i, CMR)); 70 + tcb_cache[i].imr = readl(tcaddr + ATMEL_TC_REG(i, IMR)); 71 + tcb_cache[i].rc = readl(tcaddr + ATMEL_TC_REG(i, RC)); 72 + tcb_cache[i].clken = !!(readl(tcaddr + ATMEL_TC_REG(i, SR)) & 73 + ATMEL_TC_CLKSTA); 74 + } 75 + 76 + bmr_cache = readl(tcaddr + ATMEL_TC_BMR); 77 + } 78 + 79 + void tc_clksrc_resume(struct clocksource *cs) 80 + { 81 + int i; 82 + 83 + for (i = 0; i < ARRAY_SIZE(tcb_cache); i++) { 84 + /* Restore registers for the channel, RA and RB are not used */ 85 + writel(tcb_cache[i].cmr, tcaddr + ATMEL_TC_REG(i, CMR)); 86 + writel(tcb_cache[i].rc, tcaddr + ATMEL_TC_REG(i, RC)); 87 + writel(0, tcaddr + ATMEL_TC_REG(i, RA)); 88 + writel(0, tcaddr + ATMEL_TC_REG(i, RB)); 89 + /* Disable all the interrupts */ 90 + writel(0xff, tcaddr + ATMEL_TC_REG(i, IDR)); 91 + /* Reenable interrupts that were enabled before suspending */ 92 + writel(tcb_cache[i].imr, tcaddr + ATMEL_TC_REG(i, IER)); 93 + /* Start the clock if it was used */ 94 + if (tcb_cache[i].clken) 95 + writel(ATMEL_TC_CLKEN, tcaddr + ATMEL_TC_REG(i, CCR)); 96 + } 97 + 98 + /* Dual channel, chain channels */ 99 + writel(bmr_cache, tcaddr + ATMEL_TC_BMR); 100 + /* Finally, trigger all the channels*/ 101 + writel(ATMEL_TC_SYNC, tcaddr + ATMEL_TC_BCR); 102 + } 103 + 73 104 static struct clocksource clksrc = { 74 105 .name = "tcb_clksrc", 75 106 .rating = 200, 76 107 .read = tc_get_cycles, 77 108 .mask = CLOCKSOURCE_MASK(32), 78 109 .flags = CLOCK_SOURCE_IS_CONTINUOUS, 110 + .suspend = tc_clksrc_suspend, 111 + .resume = tc_clksrc_resume, 79 112 }; 80 113 81 114 #ifdef CONFIG_GENERIC_CLOCKEVENTS
+2 -2
drivers/clocksource/tegra20_timer.c
··· 237 237 238 238 return 0; 239 239 } 240 - CLOCKSOURCE_OF_DECLARE(tegra20_timer, "nvidia,tegra20-timer", tegra20_init_timer); 240 + TIMER_OF_DECLARE(tegra20_timer, "nvidia,tegra20-timer", tegra20_init_timer); 241 241 242 242 static int __init tegra20_init_rtc(struct device_node *np) 243 243 { ··· 261 261 262 262 return register_persistent_clock(NULL, tegra_read_persistent_clock64); 263 263 } 264 - CLOCKSOURCE_OF_DECLARE(tegra20_rtc, "nvidia,tegra20-rtc", tegra20_init_rtc); 264 + TIMER_OF_DECLARE(tegra20_rtc, "nvidia,tegra20-rtc", tegra20_init_rtc);
+3 -3
drivers/clocksource/time-armada-370-xp.c
··· 351 351 352 352 return armada_370_xp_timer_common_init(np); 353 353 } 354 - CLOCKSOURCE_OF_DECLARE(armada_xp, "marvell,armada-xp-timer", 354 + TIMER_OF_DECLARE(armada_xp, "marvell,armada-xp-timer", 355 355 armada_xp_timer_init); 356 356 357 357 static int __init armada_375_timer_init(struct device_node *np) ··· 389 389 390 390 return armada_370_xp_timer_common_init(np); 391 391 } 392 - CLOCKSOURCE_OF_DECLARE(armada_375, "marvell,armada-375-timer", 392 + TIMER_OF_DECLARE(armada_375, "marvell,armada-375-timer", 393 393 armada_375_timer_init); 394 394 395 395 static int __init armada_370_timer_init(struct device_node *np) ··· 412 412 413 413 return armada_370_xp_timer_common_init(np); 414 414 } 415 - CLOCKSOURCE_OF_DECLARE(armada_370, "marvell,armada-370-timer", 415 + TIMER_OF_DECLARE(armada_370, "marvell,armada-370-timer", 416 416 armada_370_timer_init);
+2 -2
drivers/clocksource/time-efm32.c
··· 283 283 284 284 return ret; 285 285 } 286 - CLOCKSOURCE_OF_DECLARE(efm32compat, "efm32,timer", efm32_timer_init); 287 - CLOCKSOURCE_OF_DECLARE(efm32, "energymicro,efm32-timer", efm32_timer_init); 286 + TIMER_OF_DECLARE(efm32compat, "efm32,timer", efm32_timer_init); 287 + TIMER_OF_DECLARE(efm32, "energymicro,efm32-timer", efm32_timer_init);
+1 -1
drivers/clocksource/time-lpc32xx.c
··· 311 311 312 312 return ret; 313 313 } 314 - CLOCKSOURCE_OF_DECLARE(lpc32xx_timer, "nxp,lpc3220-timer", lpc32xx_timer_init); 314 + TIMER_OF_DECLARE(lpc32xx_timer, "nxp,lpc3220-timer", lpc32xx_timer_init);
+1 -1
drivers/clocksource/time-orion.c
··· 189 189 190 190 return 0; 191 191 } 192 - CLOCKSOURCE_OF_DECLARE(orion_timer, "marvell,orion-timer", orion_timer_init); 192 + TIMER_OF_DECLARE(orion_timer, "marvell,orion-timer", orion_timer_init);
+1 -1
drivers/clocksource/time-pistachio.c
··· 214 214 sched_clock_register(pistachio_read_sched_clock, 32, rate); 215 215 return clocksource_register_hz(&pcs_gpt.cs, rate); 216 216 } 217 - CLOCKSOURCE_OF_DECLARE(pistachio_gptimer, "img,pistachio-gptimer", 217 + TIMER_OF_DECLARE(pistachio_gptimer, "img,pistachio-gptimer", 218 218 pistachio_clksrc_of_init);
+1 -1
drivers/clocksource/timer-atlas7.c
··· 283 283 284 284 return sirfsoc_atlas7_timer_init(np); 285 285 } 286 - CLOCKSOURCE_OF_DECLARE(sirfsoc_atlas7_timer, "sirf,atlas7-tick", sirfsoc_of_timer_init); 286 + TIMER_OF_DECLARE(sirfsoc_atlas7_timer, "sirf,atlas7-tick", sirfsoc_of_timer_init);
+1 -1
drivers/clocksource/timer-atmel-pit.c
··· 255 255 256 256 return 0; 257 257 } 258 - CLOCKSOURCE_OF_DECLARE(at91sam926x_pit, "atmel,at91sam9260-pit", 258 + TIMER_OF_DECLARE(at91sam926x_pit, "atmel,at91sam9260-pit", 259 259 at91sam926x_pit_dt_init);
+1 -1
drivers/clocksource/timer-atmel-st.c
··· 260 260 /* register clocksource */ 261 261 return clocksource_register_hz(&clk32k, sclk_rate); 262 262 } 263 - CLOCKSOURCE_OF_DECLARE(atmel_st_timer, "atmel,at91rm9200-st", 263 + TIMER_OF_DECLARE(atmel_st_timer, "atmel,at91rm9200-st", 264 264 atmel_st_timer_init);
+1 -1
drivers/clocksource/timer-digicolor.c
··· 203 203 204 204 return 0; 205 205 } 206 - CLOCKSOURCE_OF_DECLARE(conexant_digicolor, "cnxt,cx92755-timer", 206 + TIMER_OF_DECLARE(conexant_digicolor, "cnxt,cx92755-timer", 207 207 digicolor_timer_init);
+299 -197
drivers/clocksource/timer-fttmr010.c
··· 11 11 #include <linux/of.h> 12 12 #include <linux/of_address.h> 13 13 #include <linux/of_irq.h> 14 - #include <linux/mfd/syscon.h> 15 - #include <linux/regmap.h> 16 14 #include <linux/clockchips.h> 17 15 #include <linux/clocksource.h> 18 16 #include <linux/sched_clock.h> 19 17 #include <linux/clk.h> 18 + #include <linux/slab.h> 19 + #include <linux/bitops.h> 20 + #include <linux/delay.h> 20 21 21 22 /* 22 23 * Register definitions for the timers ··· 38 37 #define TIMER_INTR_STATE (0x34) 39 38 #define TIMER_INTR_MASK (0x38) 40 39 41 - #define TIMER_1_CR_ENABLE (1 << 0) 42 - #define TIMER_1_CR_CLOCK (1 << 1) 43 - #define TIMER_1_CR_INT (1 << 2) 44 - #define TIMER_2_CR_ENABLE (1 << 3) 45 - #define TIMER_2_CR_CLOCK (1 << 4) 46 - #define TIMER_2_CR_INT (1 << 5) 47 - #define TIMER_3_CR_ENABLE (1 << 6) 48 - #define TIMER_3_CR_CLOCK (1 << 7) 49 - #define TIMER_3_CR_INT (1 << 8) 50 - #define TIMER_1_CR_UPDOWN (1 << 9) 51 - #define TIMER_2_CR_UPDOWN (1 << 10) 52 - #define TIMER_3_CR_UPDOWN (1 << 11) 53 - #define TIMER_DEFAULT_FLAGS (TIMER_1_CR_UPDOWN | \ 54 - TIMER_3_CR_ENABLE | \ 55 - TIMER_3_CR_UPDOWN) 40 + #define TIMER_1_CR_ENABLE BIT(0) 41 + #define TIMER_1_CR_CLOCK BIT(1) 42 + #define TIMER_1_CR_INT BIT(2) 43 + #define TIMER_2_CR_ENABLE BIT(3) 44 + #define TIMER_2_CR_CLOCK BIT(4) 45 + #define TIMER_2_CR_INT BIT(5) 46 + #define TIMER_3_CR_ENABLE BIT(6) 47 + #define TIMER_3_CR_CLOCK BIT(7) 48 + #define TIMER_3_CR_INT BIT(8) 49 + #define TIMER_1_CR_UPDOWN BIT(9) 50 + #define TIMER_2_CR_UPDOWN BIT(10) 51 + #define TIMER_3_CR_UPDOWN BIT(11) 56 52 57 - #define TIMER_1_INT_MATCH1 (1 << 0) 58 - #define TIMER_1_INT_MATCH2 (1 << 1) 59 - #define TIMER_1_INT_OVERFLOW (1 << 2) 60 - #define TIMER_2_INT_MATCH1 (1 << 3) 61 - #define TIMER_2_INT_MATCH2 (1 << 4) 62 - #define TIMER_2_INT_OVERFLOW (1 << 5) 63 - #define TIMER_3_INT_MATCH1 (1 << 6) 64 - #define TIMER_3_INT_MATCH2 (1 << 7) 65 - #define TIMER_3_INT_OVERFLOW (1 << 8) 53 + /* 54 + * The Aspeed AST2400 moves bits around in the control register 55 + * and lacks bits for setting the timer to count upwards. 56 + */ 57 + #define TIMER_1_CR_ASPEED_ENABLE BIT(0) 58 + #define TIMER_1_CR_ASPEED_CLOCK BIT(1) 59 + #define TIMER_1_CR_ASPEED_INT BIT(2) 60 + #define TIMER_2_CR_ASPEED_ENABLE BIT(4) 61 + #define TIMER_2_CR_ASPEED_CLOCK BIT(5) 62 + #define TIMER_2_CR_ASPEED_INT BIT(6) 63 + #define TIMER_3_CR_ASPEED_ENABLE BIT(8) 64 + #define TIMER_3_CR_ASPEED_CLOCK BIT(9) 65 + #define TIMER_3_CR_ASPEED_INT BIT(10) 66 + 67 + #define TIMER_1_INT_MATCH1 BIT(0) 68 + #define TIMER_1_INT_MATCH2 BIT(1) 69 + #define TIMER_1_INT_OVERFLOW BIT(2) 70 + #define TIMER_2_INT_MATCH1 BIT(3) 71 + #define TIMER_2_INT_MATCH2 BIT(4) 72 + #define TIMER_2_INT_OVERFLOW BIT(5) 73 + #define TIMER_3_INT_MATCH1 BIT(6) 74 + #define TIMER_3_INT_MATCH2 BIT(7) 75 + #define TIMER_3_INT_OVERFLOW BIT(8) 66 76 #define TIMER_INT_ALL_MASK 0x1ff 67 77 68 - static unsigned int tick_rate; 69 - static void __iomem *base; 78 + struct fttmr010 { 79 + void __iomem *base; 80 + unsigned int tick_rate; 81 + bool count_down; 82 + u32 t1_enable_val; 83 + struct clock_event_device clkevt; 84 + #ifdef CONFIG_ARM 85 + struct delay_timer delay_timer; 86 + #endif 87 + }; 70 88 71 - static u64 notrace fttmr010_read_sched_clock(void) 89 + /* 90 + * A local singleton used by sched_clock and delay timer reads, which are 91 + * fast and stateless 92 + */ 93 + static struct fttmr010 *local_fttmr; 94 + 95 + static inline struct fttmr010 *to_fttmr010(struct clock_event_device *evt) 72 96 { 73 - return readl(base + TIMER3_COUNT); 97 + return container_of(evt, struct fttmr010, clkevt); 98 + } 99 + 100 + static unsigned long fttmr010_read_current_timer_up(void) 101 + { 102 + return readl(local_fttmr->base + TIMER2_COUNT); 103 + } 104 + 105 + static unsigned long fttmr010_read_current_timer_down(void) 106 + { 107 + return ~readl(local_fttmr->base + TIMER2_COUNT); 108 + } 109 + 110 + static u64 notrace fttmr010_read_sched_clock_up(void) 111 + { 112 + return fttmr010_read_current_timer_up(); 113 + } 114 + 115 + static u64 notrace fttmr010_read_sched_clock_down(void) 116 + { 117 + return fttmr010_read_current_timer_down(); 74 118 } 75 119 76 120 static int fttmr010_timer_set_next_event(unsigned long cycles, 77 121 struct clock_event_device *evt) 78 122 { 123 + struct fttmr010 *fttmr010 = to_fttmr010(evt); 79 124 u32 cr; 80 125 81 - /* Setup the match register */ 82 - cr = readl(base + TIMER1_COUNT); 83 - writel(cr + cycles, base + TIMER1_MATCH1); 84 - if (readl(base + TIMER1_COUNT) - cr > cycles) 85 - return -ETIME; 126 + /* Stop */ 127 + cr = readl(fttmr010->base + TIMER_CR); 128 + cr &= ~fttmr010->t1_enable_val; 129 + writel(cr, fttmr010->base + TIMER_CR); 130 + 131 + /* Setup the match register forward/backward in time */ 132 + cr = readl(fttmr010->base + TIMER1_COUNT); 133 + if (fttmr010->count_down) 134 + cr -= cycles; 135 + else 136 + cr += cycles; 137 + writel(cr, fttmr010->base + TIMER1_MATCH1); 138 + 139 + /* Start */ 140 + cr = readl(fttmr010->base + TIMER_CR); 141 + cr |= fttmr010->t1_enable_val; 142 + writel(cr, fttmr010->base + TIMER_CR); 86 143 87 144 return 0; 88 145 } 89 146 90 147 static int fttmr010_timer_shutdown(struct clock_event_device *evt) 91 148 { 149 + struct fttmr010 *fttmr010 = to_fttmr010(evt); 92 150 u32 cr; 93 151 94 - /* 95 - * Disable also for oneshot: the set_next() call will arm the timer 96 - * instead. 97 - */ 98 - /* Stop timer and interrupt. */ 99 - cr = readl(base + TIMER_CR); 100 - cr &= ~(TIMER_1_CR_ENABLE | TIMER_1_CR_INT); 101 - writel(cr, base + TIMER_CR); 152 + /* Stop */ 153 + cr = readl(fttmr010->base + TIMER_CR); 154 + cr &= ~fttmr010->t1_enable_val; 155 + writel(cr, fttmr010->base + TIMER_CR); 102 156 103 - /* Setup counter start from 0 */ 104 - writel(0, base + TIMER1_COUNT); 105 - writel(0, base + TIMER1_LOAD); 157 + return 0; 158 + } 106 159 107 - /* enable interrupt */ 108 - cr = readl(base + TIMER_INTR_MASK); 160 + static int fttmr010_timer_set_oneshot(struct clock_event_device *evt) 161 + { 162 + struct fttmr010 *fttmr010 = to_fttmr010(evt); 163 + u32 cr; 164 + 165 + /* Stop */ 166 + cr = readl(fttmr010->base + TIMER_CR); 167 + cr &= ~fttmr010->t1_enable_val; 168 + writel(cr, fttmr010->base + TIMER_CR); 169 + 170 + /* Setup counter start from 0 or ~0 */ 171 + writel(0, fttmr010->base + TIMER1_COUNT); 172 + if (fttmr010->count_down) 173 + writel(~0, fttmr010->base + TIMER1_LOAD); 174 + else 175 + writel(0, fttmr010->base + TIMER1_LOAD); 176 + 177 + /* Enable interrupt */ 178 + cr = readl(fttmr010->base + TIMER_INTR_MASK); 109 179 cr &= ~(TIMER_1_INT_OVERFLOW | TIMER_1_INT_MATCH2); 110 180 cr |= TIMER_1_INT_MATCH1; 111 - writel(cr, base + TIMER_INTR_MASK); 112 - 113 - /* start the timer */ 114 - cr = readl(base + TIMER_CR); 115 - cr |= TIMER_1_CR_ENABLE; 116 - writel(cr, base + TIMER_CR); 181 + writel(cr, fttmr010->base + TIMER_INTR_MASK); 117 182 118 183 return 0; 119 184 } 120 185 121 186 static int fttmr010_timer_set_periodic(struct clock_event_device *evt) 122 187 { 123 - u32 period = DIV_ROUND_CLOSEST(tick_rate, HZ); 188 + struct fttmr010 *fttmr010 = to_fttmr010(evt); 189 + u32 period = DIV_ROUND_CLOSEST(fttmr010->tick_rate, HZ); 124 190 u32 cr; 125 191 126 - /* Stop timer and interrupt */ 127 - cr = readl(base + TIMER_CR); 128 - cr &= ~(TIMER_1_CR_ENABLE | TIMER_1_CR_INT); 129 - writel(cr, base + TIMER_CR); 192 + /* Stop */ 193 + cr = readl(fttmr010->base + TIMER_CR); 194 + cr &= ~fttmr010->t1_enable_val; 195 + writel(cr, fttmr010->base + TIMER_CR); 130 196 131 - /* Setup timer to fire at 1/HT intervals. */ 132 - cr = 0xffffffff - (period - 1); 133 - writel(cr, base + TIMER1_COUNT); 134 - writel(cr, base + TIMER1_LOAD); 197 + /* Setup timer to fire at 1/HZ intervals. */ 198 + if (fttmr010->count_down) { 199 + writel(period, fttmr010->base + TIMER1_LOAD); 200 + writel(0, fttmr010->base + TIMER1_MATCH1); 201 + } else { 202 + cr = 0xffffffff - (period - 1); 203 + writel(cr, fttmr010->base + TIMER1_COUNT); 204 + writel(cr, fttmr010->base + TIMER1_LOAD); 135 205 136 - /* enable interrupt on overflow */ 137 - cr = readl(base + TIMER_INTR_MASK); 138 - cr &= ~(TIMER_1_INT_MATCH1 | TIMER_1_INT_MATCH2); 139 - cr |= TIMER_1_INT_OVERFLOW; 140 - writel(cr, base + TIMER_INTR_MASK); 206 + /* Enable interrupt on overflow */ 207 + cr = readl(fttmr010->base + TIMER_INTR_MASK); 208 + cr &= ~(TIMER_1_INT_MATCH1 | TIMER_1_INT_MATCH2); 209 + cr |= TIMER_1_INT_OVERFLOW; 210 + writel(cr, fttmr010->base + TIMER_INTR_MASK); 211 + } 141 212 142 213 /* Start the timer */ 143 - cr = readl(base + TIMER_CR); 144 - cr |= TIMER_1_CR_ENABLE; 145 - cr |= TIMER_1_CR_INT; 146 - writel(cr, base + TIMER_CR); 214 + cr = readl(fttmr010->base + TIMER_CR); 215 + cr |= fttmr010->t1_enable_val; 216 + writel(cr, fttmr010->base + TIMER_CR); 147 217 148 218 return 0; 149 219 } 150 - 151 - /* Use TIMER1 as clock event */ 152 - static struct clock_event_device fttmr010_clockevent = { 153 - .name = "TIMER1", 154 - /* Reasonably fast and accurate clock event */ 155 - .rating = 300, 156 - .shift = 32, 157 - .features = CLOCK_EVT_FEAT_PERIODIC | 158 - CLOCK_EVT_FEAT_ONESHOT, 159 - .set_next_event = fttmr010_timer_set_next_event, 160 - .set_state_shutdown = fttmr010_timer_shutdown, 161 - .set_state_periodic = fttmr010_timer_set_periodic, 162 - .set_state_oneshot = fttmr010_timer_shutdown, 163 - .tick_resume = fttmr010_timer_shutdown, 164 - }; 165 220 166 221 /* 167 222 * IRQ handler for the timer 168 223 */ 169 224 static irqreturn_t fttmr010_timer_interrupt(int irq, void *dev_id) 170 225 { 171 - struct clock_event_device *evt = &fttmr010_clockevent; 226 + struct clock_event_device *evt = dev_id; 172 227 173 228 evt->event_handler(evt); 174 229 return IRQ_HANDLED; 175 230 } 176 231 177 - static struct irqaction fttmr010_timer_irq = { 178 - .name = "Faraday FTTMR010 Timer Tick", 179 - .flags = IRQF_TIMER, 180 - .handler = fttmr010_timer_interrupt, 181 - }; 182 - 183 - static int __init fttmr010_timer_common_init(struct device_node *np) 232 + static int __init fttmr010_common_init(struct device_node *np, bool is_aspeed) 184 233 { 234 + struct fttmr010 *fttmr010; 185 235 int irq; 236 + struct clk *clk; 237 + int ret; 238 + u32 val; 186 239 187 - base = of_iomap(np, 0); 188 - if (!base) { 189 - pr_err("Can't remap registers"); 190 - return -ENXIO; 191 - } 192 - /* IRQ for timer 1 */ 193 - irq = irq_of_parse_and_map(np, 0); 194 - if (irq <= 0) { 195 - pr_err("Can't parse IRQ"); 196 - return -EINVAL; 197 - } 198 - 199 - /* 200 - * Reset the interrupt mask and status 201 - */ 202 - writel(TIMER_INT_ALL_MASK, base + TIMER_INTR_MASK); 203 - writel(0, base + TIMER_INTR_STATE); 204 - writel(TIMER_DEFAULT_FLAGS, base + TIMER_CR); 205 - 206 - /* 207 - * Setup free-running clocksource timer (interrupts 208 - * disabled.) 209 - */ 210 - writel(0, base + TIMER3_COUNT); 211 - writel(0, base + TIMER3_LOAD); 212 - writel(0, base + TIMER3_MATCH1); 213 - writel(0, base + TIMER3_MATCH2); 214 - clocksource_mmio_init(base + TIMER3_COUNT, 215 - "fttmr010_clocksource", tick_rate, 216 - 300, 32, clocksource_mmio_readl_up); 217 - sched_clock_register(fttmr010_read_sched_clock, 32, tick_rate); 218 - 219 - /* 220 - * Setup clockevent timer (interrupt-driven.) 221 - */ 222 - writel(0, base + TIMER1_COUNT); 223 - writel(0, base + TIMER1_LOAD); 224 - writel(0, base + TIMER1_MATCH1); 225 - writel(0, base + TIMER1_MATCH2); 226 - setup_irq(irq, &fttmr010_timer_irq); 227 - fttmr010_clockevent.cpumask = cpumask_of(0); 228 - clockevents_config_and_register(&fttmr010_clockevent, tick_rate, 229 - 1, 0xffffffff); 230 - 231 - return 0; 232 - } 233 - 234 - static int __init fttmr010_timer_of_init(struct device_node *np) 235 - { 236 240 /* 237 241 * These implementations require a clock reference. 238 242 * FIXME: we currently only support clocking using PCLK 239 243 * and using EXTCLK is not supported in the driver. 240 244 */ 241 - struct clk *clk; 242 - 243 245 clk = of_clk_get_by_name(np, "PCLK"); 244 246 if (IS_ERR(clk)) { 245 - pr_err("could not get PCLK"); 247 + pr_err("could not get PCLK\n"); 246 248 return PTR_ERR(clk); 247 249 } 248 - tick_rate = clk_get_rate(clk); 249 - 250 - return fttmr010_timer_common_init(np); 251 - } 252 - CLOCKSOURCE_OF_DECLARE(fttmr010, "faraday,fttmr010", fttmr010_timer_of_init); 253 - 254 - /* 255 - * Gemini-specific: relevant registers in the global syscon 256 - */ 257 - #define GLOBAL_STATUS 0x04 258 - #define CPU_AHB_RATIO_MASK (0x3 << 18) 259 - #define CPU_AHB_1_1 (0x0 << 18) 260 - #define CPU_AHB_3_2 (0x1 << 18) 261 - #define CPU_AHB_24_13 (0x2 << 18) 262 - #define CPU_AHB_2_1 (0x3 << 18) 263 - #define REG_TO_AHB_SPEED(reg) ((((reg) >> 15) & 0x7) * 10 + 130) 264 - 265 - static int __init gemini_timer_of_init(struct device_node *np) 266 - { 267 - static struct regmap *map; 268 - int ret; 269 - u32 val; 270 - 271 - map = syscon_regmap_lookup_by_phandle(np, "syscon"); 272 - if (IS_ERR(map)) { 273 - pr_err("Can't get regmap for syscon handle\n"); 274 - return -ENODEV; 275 - } 276 - ret = regmap_read(map, GLOBAL_STATUS, &val); 250 + ret = clk_prepare_enable(clk); 277 251 if (ret) { 278 - pr_err("Can't read syscon status register\n"); 279 - return -ENXIO; 252 + pr_err("failed to enable PCLK\n"); 253 + return ret; 280 254 } 281 255 282 - tick_rate = REG_TO_AHB_SPEED(val) * 1000000; 283 - pr_info("Bus: %dMHz ", tick_rate / 1000000); 256 + fttmr010 = kzalloc(sizeof(*fttmr010), GFP_KERNEL); 257 + if (!fttmr010) { 258 + ret = -ENOMEM; 259 + goto out_disable_clock; 260 + } 261 + fttmr010->tick_rate = clk_get_rate(clk); 284 262 285 - tick_rate /= 6; /* APB bus run AHB*(1/6) */ 286 - 287 - switch (val & CPU_AHB_RATIO_MASK) { 288 - case CPU_AHB_1_1: 289 - pr_cont("(1/1)\n"); 290 - break; 291 - case CPU_AHB_3_2: 292 - pr_cont("(3/2)\n"); 293 - break; 294 - case CPU_AHB_24_13: 295 - pr_cont("(24/13)\n"); 296 - break; 297 - case CPU_AHB_2_1: 298 - pr_cont("(2/1)\n"); 299 - break; 263 + fttmr010->base = of_iomap(np, 0); 264 + if (!fttmr010->base) { 265 + pr_err("Can't remap registers"); 266 + ret = -ENXIO; 267 + goto out_free; 268 + } 269 + /* IRQ for timer 1 */ 270 + irq = irq_of_parse_and_map(np, 0); 271 + if (irq <= 0) { 272 + pr_err("Can't parse IRQ"); 273 + ret = -EINVAL; 274 + goto out_unmap; 300 275 } 301 276 302 - return fttmr010_timer_common_init(np); 277 + /* 278 + * The Aspeed AST2400 moves bits around in the control register, 279 + * otherwise it works the same. 280 + */ 281 + if (is_aspeed) { 282 + fttmr010->t1_enable_val = TIMER_1_CR_ASPEED_ENABLE | 283 + TIMER_1_CR_ASPEED_INT; 284 + /* Downward not available */ 285 + fttmr010->count_down = true; 286 + } else { 287 + fttmr010->t1_enable_val = TIMER_1_CR_ENABLE | TIMER_1_CR_INT; 288 + } 289 + 290 + /* 291 + * Reset the interrupt mask and status 292 + */ 293 + writel(TIMER_INT_ALL_MASK, fttmr010->base + TIMER_INTR_MASK); 294 + writel(0, fttmr010->base + TIMER_INTR_STATE); 295 + 296 + /* 297 + * Enable timer 1 count up, timer 2 count up, except on Aspeed, 298 + * where everything just counts down. 299 + */ 300 + if (is_aspeed) 301 + val = TIMER_2_CR_ASPEED_ENABLE; 302 + else { 303 + val = TIMER_2_CR_ENABLE; 304 + if (!fttmr010->count_down) 305 + val |= TIMER_1_CR_UPDOWN | TIMER_2_CR_UPDOWN; 306 + } 307 + writel(val, fttmr010->base + TIMER_CR); 308 + 309 + /* 310 + * Setup free-running clocksource timer (interrupts 311 + * disabled.) 312 + */ 313 + local_fttmr = fttmr010; 314 + writel(0, fttmr010->base + TIMER2_COUNT); 315 + writel(0, fttmr010->base + TIMER2_MATCH1); 316 + writel(0, fttmr010->base + TIMER2_MATCH2); 317 + 318 + if (fttmr010->count_down) { 319 + writel(~0, fttmr010->base + TIMER2_LOAD); 320 + clocksource_mmio_init(fttmr010->base + TIMER2_COUNT, 321 + "FTTMR010-TIMER2", 322 + fttmr010->tick_rate, 323 + 300, 32, clocksource_mmio_readl_down); 324 + sched_clock_register(fttmr010_read_sched_clock_down, 32, 325 + fttmr010->tick_rate); 326 + } else { 327 + writel(0, fttmr010->base + TIMER2_LOAD); 328 + clocksource_mmio_init(fttmr010->base + TIMER2_COUNT, 329 + "FTTMR010-TIMER2", 330 + fttmr010->tick_rate, 331 + 300, 32, clocksource_mmio_readl_up); 332 + sched_clock_register(fttmr010_read_sched_clock_up, 32, 333 + fttmr010->tick_rate); 334 + } 335 + 336 + /* 337 + * Setup clockevent timer (interrupt-driven) on timer 1. 338 + */ 339 + writel(0, fttmr010->base + TIMER1_COUNT); 340 + writel(0, fttmr010->base + TIMER1_LOAD); 341 + writel(0, fttmr010->base + TIMER1_MATCH1); 342 + writel(0, fttmr010->base + TIMER1_MATCH2); 343 + ret = request_irq(irq, fttmr010_timer_interrupt, IRQF_TIMER, 344 + "FTTMR010-TIMER1", &fttmr010->clkevt); 345 + if (ret) { 346 + pr_err("FTTMR010-TIMER1 no IRQ\n"); 347 + goto out_unmap; 348 + } 349 + 350 + fttmr010->clkevt.name = "FTTMR010-TIMER1"; 351 + /* Reasonably fast and accurate clock event */ 352 + fttmr010->clkevt.rating = 300; 353 + fttmr010->clkevt.features = CLOCK_EVT_FEAT_PERIODIC | 354 + CLOCK_EVT_FEAT_ONESHOT; 355 + fttmr010->clkevt.set_next_event = fttmr010_timer_set_next_event; 356 + fttmr010->clkevt.set_state_shutdown = fttmr010_timer_shutdown; 357 + fttmr010->clkevt.set_state_periodic = fttmr010_timer_set_periodic; 358 + fttmr010->clkevt.set_state_oneshot = fttmr010_timer_set_oneshot; 359 + fttmr010->clkevt.tick_resume = fttmr010_timer_shutdown; 360 + fttmr010->clkevt.cpumask = cpumask_of(0); 361 + fttmr010->clkevt.irq = irq; 362 + clockevents_config_and_register(&fttmr010->clkevt, 363 + fttmr010->tick_rate, 364 + 1, 0xffffffff); 365 + 366 + #ifdef CONFIG_ARM 367 + /* Also use this timer for delays */ 368 + if (fttmr010->count_down) 369 + fttmr010->delay_timer.read_current_timer = 370 + fttmr010_read_current_timer_down; 371 + else 372 + fttmr010->delay_timer.read_current_timer = 373 + fttmr010_read_current_timer_up; 374 + fttmr010->delay_timer.freq = fttmr010->tick_rate; 375 + register_current_timer_delay(&fttmr010->delay_timer); 376 + #endif 377 + 378 + return 0; 379 + 380 + out_unmap: 381 + iounmap(fttmr010->base); 382 + out_free: 383 + kfree(fttmr010); 384 + out_disable_clock: 385 + clk_disable_unprepare(clk); 386 + 387 + return ret; 303 388 } 304 - CLOCKSOURCE_OF_DECLARE(gemini, "cortina,gemini-timer", gemini_timer_of_init); 389 + 390 + static __init int aspeed_timer_init(struct device_node *np) 391 + { 392 + return fttmr010_common_init(np, true); 393 + } 394 + 395 + static __init int fttmr010_timer_init(struct device_node *np) 396 + { 397 + return fttmr010_common_init(np, false); 398 + } 399 + 400 + TIMER_OF_DECLARE(fttmr010, "faraday,fttmr010", fttmr010_timer_init); 401 + TIMER_OF_DECLARE(gemini, "cortina,gemini-timer", fttmr010_timer_init); 402 + TIMER_OF_DECLARE(moxart, "moxa,moxart-timer", fttmr010_timer_init); 403 + TIMER_OF_DECLARE(ast2400, "aspeed,ast2400-timer", aspeed_timer_init); 404 + TIMER_OF_DECLARE(ast2500, "aspeed,ast2500-timer", aspeed_timer_init);
+12 -12
drivers/clocksource/timer-imx-gpt.c
··· 545 545 return mxc_timer_init_dt(np, GPT_TYPE_IMX6DL); 546 546 } 547 547 548 - CLOCKSOURCE_OF_DECLARE(imx1_timer, "fsl,imx1-gpt", imx1_timer_init_dt); 549 - CLOCKSOURCE_OF_DECLARE(imx21_timer, "fsl,imx21-gpt", imx21_timer_init_dt); 550 - CLOCKSOURCE_OF_DECLARE(imx27_timer, "fsl,imx27-gpt", imx21_timer_init_dt); 551 - CLOCKSOURCE_OF_DECLARE(imx31_timer, "fsl,imx31-gpt", imx31_timer_init_dt); 552 - CLOCKSOURCE_OF_DECLARE(imx25_timer, "fsl,imx25-gpt", imx31_timer_init_dt); 553 - CLOCKSOURCE_OF_DECLARE(imx50_timer, "fsl,imx50-gpt", imx31_timer_init_dt); 554 - CLOCKSOURCE_OF_DECLARE(imx51_timer, "fsl,imx51-gpt", imx31_timer_init_dt); 555 - CLOCKSOURCE_OF_DECLARE(imx53_timer, "fsl,imx53-gpt", imx31_timer_init_dt); 556 - CLOCKSOURCE_OF_DECLARE(imx6q_timer, "fsl,imx6q-gpt", imx31_timer_init_dt); 557 - CLOCKSOURCE_OF_DECLARE(imx6dl_timer, "fsl,imx6dl-gpt", imx6dl_timer_init_dt); 558 - CLOCKSOURCE_OF_DECLARE(imx6sl_timer, "fsl,imx6sl-gpt", imx6dl_timer_init_dt); 559 - CLOCKSOURCE_OF_DECLARE(imx6sx_timer, "fsl,imx6sx-gpt", imx6dl_timer_init_dt); 548 + TIMER_OF_DECLARE(imx1_timer, "fsl,imx1-gpt", imx1_timer_init_dt); 549 + TIMER_OF_DECLARE(imx21_timer, "fsl,imx21-gpt", imx21_timer_init_dt); 550 + TIMER_OF_DECLARE(imx27_timer, "fsl,imx27-gpt", imx21_timer_init_dt); 551 + TIMER_OF_DECLARE(imx31_timer, "fsl,imx31-gpt", imx31_timer_init_dt); 552 + TIMER_OF_DECLARE(imx25_timer, "fsl,imx25-gpt", imx31_timer_init_dt); 553 + TIMER_OF_DECLARE(imx50_timer, "fsl,imx50-gpt", imx31_timer_init_dt); 554 + TIMER_OF_DECLARE(imx51_timer, "fsl,imx51-gpt", imx31_timer_init_dt); 555 + TIMER_OF_DECLARE(imx53_timer, "fsl,imx53-gpt", imx31_timer_init_dt); 556 + TIMER_OF_DECLARE(imx6q_timer, "fsl,imx6q-gpt", imx31_timer_init_dt); 557 + TIMER_OF_DECLARE(imx6dl_timer, "fsl,imx6dl-gpt", imx6dl_timer_init_dt); 558 + TIMER_OF_DECLARE(imx6sl_timer, "fsl,imx6sl-gpt", imx6dl_timer_init_dt); 559 + TIMER_OF_DECLARE(imx6sx_timer, "fsl,imx6sx-gpt", imx6dl_timer_init_dt);
+1 -1
drivers/clocksource/timer-integrator-ap.c
··· 232 232 return 0; 233 233 } 234 234 235 - CLOCKSOURCE_OF_DECLARE(integrator_ap_timer, "arm,integrator-timer", 235 + TIMER_OF_DECLARE(integrator_ap_timer, "arm,integrator-timer", 236 236 integrator_ap_timer_init_of);
+1 -1
drivers/clocksource/timer-keystone.c
··· 226 226 return error; 227 227 } 228 228 229 - CLOCKSOURCE_OF_DECLARE(keystone_timer, "ti,keystone-timer", 229 + TIMER_OF_DECLARE(keystone_timer, "ti,keystone-timer", 230 230 keystone_timer_init);
+3 -3
drivers/clocksource/timer-nps.c
··· 110 110 return ret; 111 111 } 112 112 113 - CLOCKSOURCE_OF_DECLARE(ezchip_nps400_clksrc, "ezchip,nps400-timer", 113 + TIMER_OF_DECLARE(ezchip_nps400_clksrc, "ezchip,nps400-timer", 114 114 nps_setup_clocksource); 115 - CLOCKSOURCE_OF_DECLARE(ezchip_nps400_clk_src, "ezchip,nps400-timer1", 115 + TIMER_OF_DECLARE(ezchip_nps400_clk_src, "ezchip,nps400-timer1", 116 116 nps_setup_clocksource); 117 117 118 118 #ifdef CONFIG_EZNPS_MTM_EXT ··· 279 279 return 0; 280 280 } 281 281 282 - CLOCKSOURCE_OF_DECLARE(ezchip_nps400_clk_evt, "ezchip,nps400-timer0", 282 + TIMER_OF_DECLARE(ezchip_nps400_clk_evt, "ezchip,nps400-timer0", 283 283 nps_setup_clockevent); 284 284 #endif /* CONFIG_EZNPS_MTM_EXT */
+172
drivers/clocksource/timer-of.c
··· 1 + /* 2 + * Copyright (c) 2017, Linaro Ltd. All rights reserved. 3 + * 4 + * Author: Daniel Lezcano <daniel.lezcano@linaro.org> 5 + * 6 + * This program is free software; you can redistribute it and/or modify it 7 + * under the terms and conditions of the GNU General Public License, 8 + * version 2, as published by the Free Software Foundation. 9 + * 10 + * This program is distributed in the hope it will be useful, but WITHOUT 11 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 + * more details. 14 + * 15 + * You should have received a copy of the GNU General Public License 16 + * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 + */ 18 + #include <linux/clk.h> 19 + #include <linux/interrupt.h> 20 + #include <linux/of.h> 21 + #include <linux/of_address.h> 22 + #include <linux/of_irq.h> 23 + #include <linux/slab.h> 24 + 25 + #include "timer-of.h" 26 + 27 + static __init void timer_irq_exit(struct of_timer_irq *of_irq) 28 + { 29 + struct timer_of *to = container_of(of_irq, struct timer_of, of_irq); 30 + 31 + struct clock_event_device *clkevt = &to->clkevt; 32 + 33 + of_irq->percpu ? free_percpu_irq(of_irq->irq, clkevt) : 34 + free_irq(of_irq->irq, clkevt); 35 + } 36 + 37 + static __init int timer_irq_init(struct device_node *np, 38 + struct of_timer_irq *of_irq) 39 + { 40 + int ret; 41 + struct timer_of *to = container_of(of_irq, struct timer_of, of_irq); 42 + struct clock_event_device *clkevt = &to->clkevt; 43 + 44 + of_irq->irq = of_irq->name ? of_irq_get_byname(np, of_irq->name): 45 + irq_of_parse_and_map(np, of_irq->index); 46 + if (!of_irq->irq) { 47 + pr_err("Failed to map interrupt for %s\n", np->full_name); 48 + return -EINVAL; 49 + } 50 + 51 + ret = of_irq->percpu ? 52 + request_percpu_irq(of_irq->irq, of_irq->handler, 53 + np->full_name, clkevt) : 54 + request_irq(of_irq->irq, of_irq->handler, 55 + of_irq->flags ? of_irq->flags : IRQF_TIMER, 56 + np->full_name, clkevt); 57 + if (ret) { 58 + pr_err("Failed to request irq %d for %s\n", of_irq->irq, 59 + np->full_name); 60 + return ret; 61 + } 62 + 63 + clkevt->irq = of_irq->irq; 64 + 65 + return 0; 66 + } 67 + 68 + static __init void timer_clk_exit(struct of_timer_clk *of_clk) 69 + { 70 + of_clk->rate = 0; 71 + clk_disable_unprepare(of_clk->clk); 72 + clk_put(of_clk->clk); 73 + } 74 + 75 + static __init int timer_clk_init(struct device_node *np, 76 + struct of_timer_clk *of_clk) 77 + { 78 + int ret; 79 + 80 + of_clk->clk = of_clk->name ? of_clk_get_by_name(np, of_clk->name) : 81 + of_clk_get(np, of_clk->index); 82 + if (IS_ERR(of_clk->clk)) { 83 + pr_err("Failed to get clock for %s\n", np->full_name); 84 + return PTR_ERR(of_clk->clk); 85 + } 86 + 87 + ret = clk_prepare_enable(of_clk->clk); 88 + if (ret) { 89 + pr_err("Failed for enable clock for %s\n", np->full_name); 90 + goto out_clk_put; 91 + } 92 + 93 + of_clk->rate = clk_get_rate(of_clk->clk); 94 + if (!of_clk->rate) { 95 + ret = -EINVAL; 96 + pr_err("Failed to get clock rate for %s\n", np->full_name); 97 + goto out_clk_disable; 98 + } 99 + 100 + of_clk->period = DIV_ROUND_UP(of_clk->rate, HZ); 101 + out: 102 + return ret; 103 + 104 + out_clk_disable: 105 + clk_disable_unprepare(of_clk->clk); 106 + out_clk_put: 107 + clk_put(of_clk->clk); 108 + 109 + goto out; 110 + } 111 + 112 + static __init void timer_base_exit(struct of_timer_base *of_base) 113 + { 114 + iounmap(of_base->base); 115 + } 116 + 117 + static __init int timer_base_init(struct device_node *np, 118 + struct of_timer_base *of_base) 119 + { 120 + const char *name = of_base->name ? of_base->name : np->full_name; 121 + 122 + of_base->base = of_io_request_and_map(np, of_base->index, name); 123 + if (of_base->base) { 124 + pr_err("Failed to iomap (%s)\n", name); 125 + return -ENXIO; 126 + } 127 + 128 + return 0; 129 + } 130 + 131 + int __init timer_of_init(struct device_node *np, struct timer_of *to) 132 + { 133 + int ret; 134 + int flags = 0; 135 + 136 + if (to->flags & TIMER_OF_BASE) { 137 + ret = timer_base_init(np, &to->of_base); 138 + if (ret) 139 + goto out_fail; 140 + flags |= TIMER_OF_BASE; 141 + } 142 + 143 + if (to->flags & TIMER_OF_CLOCK) { 144 + ret = timer_clk_init(np, &to->of_clk); 145 + if (ret) 146 + goto out_fail; 147 + flags |= TIMER_OF_CLOCK; 148 + } 149 + 150 + if (to->flags & TIMER_OF_IRQ) { 151 + ret = timer_irq_init(np, &to->of_irq); 152 + if (ret) 153 + goto out_fail; 154 + flags |= TIMER_OF_IRQ; 155 + } 156 + 157 + if (!to->clkevt.name) 158 + to->clkevt.name = np->name; 159 + out: 160 + return ret; 161 + 162 + out_fail: 163 + if (flags & TIMER_OF_IRQ) 164 + timer_irq_exit(&to->of_irq); 165 + 166 + if (flags & TIMER_OF_CLOCK) 167 + timer_clk_exit(&to->of_clk); 168 + 169 + if (flags & TIMER_OF_BASE) 170 + timer_base_exit(&to->of_base); 171 + goto out; 172 + }
+69
drivers/clocksource/timer-of.h
··· 1 + #ifndef __TIMER_OF_H__ 2 + #define __TIMER_OF_H__ 3 + 4 + #include <linux/clockchips.h> 5 + 6 + #define TIMER_OF_BASE 0x1 7 + #define TIMER_OF_CLOCK 0x2 8 + #define TIMER_OF_IRQ 0x4 9 + 10 + struct of_timer_irq { 11 + int irq; 12 + int index; 13 + int percpu; 14 + const char *name; 15 + unsigned long flags; 16 + irq_handler_t handler; 17 + }; 18 + 19 + struct of_timer_base { 20 + void __iomem *base; 21 + const char *name; 22 + int index; 23 + }; 24 + 25 + struct of_timer_clk { 26 + struct clk *clk; 27 + const char *name; 28 + int index; 29 + unsigned long rate; 30 + unsigned long period; 31 + }; 32 + 33 + struct timer_of { 34 + unsigned int flags; 35 + struct clock_event_device clkevt; 36 + struct of_timer_base of_base; 37 + struct of_timer_irq of_irq; 38 + struct of_timer_clk of_clk; 39 + void *private_data; 40 + }; 41 + 42 + static inline struct timer_of *to_timer_of(struct clock_event_device *clkevt) 43 + { 44 + return container_of(clkevt, struct timer_of, clkevt); 45 + } 46 + 47 + static inline void __iomem *timer_of_base(struct timer_of *to) 48 + { 49 + return to->of_base.base; 50 + } 51 + 52 + static inline int timer_of_irq(struct timer_of *to) 53 + { 54 + return to->of_irq.irq; 55 + } 56 + 57 + static inline unsigned long timer_of_rate(struct timer_of *to) 58 + { 59 + return to->of_clk.rate; 60 + } 61 + 62 + static inline unsigned long timer_of_period(struct timer_of *to) 63 + { 64 + return to->of_clk.period; 65 + } 66 + 67 + extern int __init timer_of_init(struct device_node *np, 68 + struct timer_of *to); 69 + #endif
+2 -2
drivers/clocksource/timer-oxnas-rps.c
··· 293 293 return ret; 294 294 } 295 295 296 - CLOCKSOURCE_OF_DECLARE(ox810se_rps, 296 + TIMER_OF_DECLARE(ox810se_rps, 297 297 "oxsemi,ox810se-rps-timer", oxnas_rps_timer_init); 298 - CLOCKSOURCE_OF_DECLARE(ox820_rps, 298 + TIMER_OF_DECLARE(ox820_rps, 299 299 "oxsemi,ox820se-rps-timer", oxnas_rps_timer_init);
+1 -1
drivers/clocksource/timer-prima2.c
··· 245 245 246 246 return 0; 247 247 } 248 - CLOCKSOURCE_OF_DECLARE(sirfsoc_prima2_timer, 248 + TIMER_OF_DECLARE(sirfsoc_prima2_timer, 249 249 "sirf,prima2-tick", sirfsoc_prima2_timer_init);
+2 -2
drivers/clocksource/timer-sp804.c
··· 287 287 iounmap(base); 288 288 return ret; 289 289 } 290 - CLOCKSOURCE_OF_DECLARE(sp804, "arm,sp804", sp804_of_init); 290 + TIMER_OF_DECLARE(sp804, "arm,sp804", sp804_of_init); 291 291 292 292 static int __init integrator_cp_of_init(struct device_node *np) 293 293 { ··· 335 335 iounmap(base); 336 336 return ret; 337 337 } 338 - CLOCKSOURCE_OF_DECLARE(intcp, "arm,integrator-cp-timer", integrator_cp_of_init); 338 + TIMER_OF_DECLARE(intcp, "arm,integrator-cp-timer", integrator_cp_of_init);
+1 -1
drivers/clocksource/timer-stm32.c
··· 187 187 return ret; 188 188 } 189 189 190 - CLOCKSOURCE_OF_DECLARE(stm32, "st,stm32-timer", stm32_clockevent_init); 190 + TIMER_OF_DECLARE(stm32, "st,stm32-timer", stm32_clockevent_init);
+2 -2
drivers/clocksource/timer-sun5i.c
··· 358 358 359 359 return sun5i_setup_clockevent(node, timer_base, clk, irq); 360 360 } 361 - CLOCKSOURCE_OF_DECLARE(sun5i_a13, "allwinner,sun5i-a13-hstimer", 361 + TIMER_OF_DECLARE(sun5i_a13, "allwinner,sun5i-a13-hstimer", 362 362 sun5i_timer_init); 363 - CLOCKSOURCE_OF_DECLARE(sun7i_a20, "allwinner,sun7i-a20-hstimer", 363 + TIMER_OF_DECLARE(sun7i_a20, "allwinner,sun7i-a20-hstimer", 364 364 sun5i_timer_init);
+1 -1
drivers/clocksource/timer-ti-32k.c
··· 124 124 125 125 return 0; 126 126 } 127 - CLOCKSOURCE_OF_DECLARE(ti_32k_timer, "ti,omap-counter32k", 127 + TIMER_OF_DECLARE(ti_32k_timer, "ti,omap-counter32k", 128 128 ti_32k_timer_init);
+1 -1
drivers/clocksource/timer-u300.c
··· 458 458 return 0; 459 459 } 460 460 461 - CLOCKSOURCE_OF_DECLARE(u300_timer, "stericsson,u300-apptimer", 461 + TIMER_OF_DECLARE(u300_timer, "stericsson,u300-apptimer", 462 462 u300_timer_init_of);
+2 -2
drivers/clocksource/versatile.c
··· 38 38 39 39 return 0; 40 40 } 41 - CLOCKSOURCE_OF_DECLARE(vexpress, "arm,vexpress-sysreg", 41 + TIMER_OF_DECLARE(vexpress, "arm,vexpress-sysreg", 42 42 versatile_sched_clock_init); 43 - CLOCKSOURCE_OF_DECLARE(versatile, "arm,versatile-sysreg", 43 + TIMER_OF_DECLARE(versatile, "arm,versatile-sysreg", 44 44 versatile_sched_clock_init);
+1 -1
drivers/clocksource/vf_pit_timer.c
··· 201 201 202 202 return pit_clockevent_init(clk_rate, irq); 203 203 } 204 - CLOCKSOURCE_OF_DECLARE(vf610, "fsl,vf610-pit", pit_timer_init); 204 + TIMER_OF_DECLARE(vf610, "fsl,vf610-pit", pit_timer_init);
+1 -1
drivers/clocksource/vt8500_timer.c
··· 165 165 return 0; 166 166 } 167 167 168 - CLOCKSOURCE_OF_DECLARE(vt8500, "via,vt8500-timer", vt8500_timer_init); 168 + TIMER_OF_DECLARE(vt8500, "via,vt8500-timer", vt8500_timer_init);
+1 -1
drivers/clocksource/zevio-timer.c
··· 215 215 return zevio_timer_add(node); 216 216 } 217 217 218 - CLOCKSOURCE_OF_DECLARE(zevio_timer, "lsi,zevio-timer", zevio_timer_init); 218 + TIMER_OF_DECLARE(zevio_timer, "lsi,zevio-timer", zevio_timer_init);
+4 -5
include/asm-generic/vmlinux.lds.h
··· 172 172 KEEP(*(__##name##_of_table)) \ 173 173 KEEP(*(__##name##_of_table_end)) 174 174 175 - #define CLKSRC_OF_TABLES() OF_TABLE(CONFIG_CLKSRC_OF, clksrc) 176 - #define CLKEVT_OF_TABLES() OF_TABLE(CONFIG_CLKEVT_OF, clkevt) 175 + #define TIMER_OF_TABLES() OF_TABLE(CONFIG_TIMER_OF, timer) 177 176 #define IRQCHIP_OF_MATCH_TABLE() OF_TABLE(CONFIG_IRQCHIP, irqchip) 178 177 #define CLK_OF_TABLES() OF_TABLE(CONFIG_COMMON_CLK, clk) 179 178 #define IOMMU_OF_TABLES() OF_TABLE(CONFIG_OF_IOMMU, iommu) ··· 556 557 MEM_DISCARD(init.rodata) \ 557 558 CLK_OF_TABLES() \ 558 559 RESERVEDMEM_OF_TABLES() \ 559 - CLKSRC_OF_TABLES() \ 560 - CLKEVT_OF_TABLES() \ 560 + TIMER_OF_TABLES() \ 561 561 IOMMU_OF_TABLES() \ 562 562 CPU_METHOD_OF_TABLES() \ 563 563 CPUIDLE_METHOD_OF_TABLES() \ 564 564 KERNEL_DTB() \ 565 565 IRQCHIP_OF_MATCH_TABLE() \ 566 566 ACPI_PROBE_TABLE(irqchip) \ 567 - ACPI_PROBE_TABLE(clksrc) \ 567 + ACPI_PROBE_TABLE(timer) \ 568 + ACPI_PROBE_TABLE(iort) \ 568 569 EARLYCON_TABLE() 569 570 570 571 #define INIT_TEXT \
-9
include/linux/clockchips.h
··· 223 223 224 224 #endif /* !CONFIG_GENERIC_CLOCKEVENTS */ 225 225 226 - #define CLOCKEVENT_OF_DECLARE(name, compat, fn) \ 227 - OF_DECLARE_1_RET(clkevt, name, compat, fn) 228 - 229 - #ifdef CONFIG_CLKEVT_PROBE 230 - extern int clockevent_probe(void); 231 - #else 232 - static inline int clockevent_probe(void) { return 0; } 233 - #endif 234 - 235 226 #endif /* _LINUX_CLOCKCHIPS_H */
+10 -7
include/linux/clocksource.h
··· 249 249 250 250 extern int clocksource_i8253_init(void); 251 251 252 - #define CLOCKSOURCE_OF_DECLARE(name, compat, fn) \ 253 - OF_DECLARE_1_RET(clksrc, name, compat, fn) 252 + #define TIMER_OF_DECLARE(name, compat, fn) \ 253 + OF_DECLARE_1_RET(timer, name, compat, fn) 254 254 255 - #ifdef CONFIG_CLKSRC_PROBE 256 - extern void clocksource_probe(void); 255 + #define CLOCKSOURCE_OF_DECLARE(name, compat, fn) \ 256 + TIMER_OF_DECLARE(name, compat, fn) 257 + 258 + #ifdef CONFIG_TIMER_PROBE 259 + extern void timer_probe(void); 257 260 #else 258 - static inline void clocksource_probe(void) {} 261 + static inline void timer_probe(void) {} 259 262 #endif 260 263 261 - #define CLOCKSOURCE_ACPI_DECLARE(name, table_id, fn) \ 262 - ACPI_DECLARE_PROBE_ENTRY(clksrc, name, table_id, 0, NULL, 0, fn) 264 + #define TIMER_ACPI_DECLARE(name, table_id, fn) \ 265 + ACPI_DECLARE_PROBE_ENTRY(timer, name, table_id, 0, NULL, 0, fn) 263 266 264 267 #endif /* _LINUX_CLOCKSOURCE_H */