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

Merge branch 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull timer updates from Thomas Gleixner:
"The timer department delivers the following christmas presents:

Core code:

- Use proper seqcount initializer to make lockdep happy

- SPDX annotations and cleanup of license boilerplates

- Use DEFINE_SHOW_ATTRIBUTE() instead of open coding it

- Minor cleanups

Driver code:

- Add the sched_clock for the arc timer (Alexey Brodkin)

- Change the file timer names for riscv, rockchip, tegra20, sun4i and
meson6 (Daniel Lezcano)

- Add the DT bindings for r8a7796, r8a77470 and r8a774a1 (Biju Das)

- Remove the early platform driver registration for timer-ti-dm
(Bartosz Golaszewski)

- Provide the sched_clock for the riscv timer (Anup Patel)

- Add support for ARM64 for the imx-gpt and convert the imx-tpm to
the timer-of API (Anson Huang)

- Remove useless irq protection for the imx-gpt (Clément Péron)

- Remove a duplicate function name for the vt8500 (Dan Carpenter)

- Remove obsolete inclusion of <asm/smp_twd.h> for the tegra20 (Geert
Uytterhoeven)

- Demote the prcmu and the custom sched_clock for the dbx500 and the
ux500 (Linus Walleij)

- Add a new timer clock for the RDA8810PL (Manivannan Sadhasivam)

- Rename the macro to stick to the register name and add the delay
timer (Martin Blumenstingl)

- Switch the bcm2835 to the SPDX identifier (Stefan Wahren)

- Fix the interrupt register access on the fttmr010 (Tao Ren)

- Add missing of_node_put in the initialization path on the
integrator-ap (Yangtao Li)"

* 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (39 commits)
dt-bindings: timer: Document RDA8810PL SoC timer
clocksource/drivers/rda: Add clock driver for RDA8810PL SoC
clocksource/drivers/meson6: Change name meson6_timer timer-meson6
clocksource/drivers/sun4i: Change name sun4i_timer to timer-sun4i
clocksource/drivers/tegra20: Change name tegra20_timer to timer-tegra20
clocksource/drivers/rockchip: Change name rockchip_timer to timer-rockchip
clocksource/drivers/riscv: Change name riscv_timer to timer-riscv
clocksource/drivers/riscv_timer: Provide the sched_clock
clocksource/drivers/timer-imx-tpm: Specify clock name for timer-of
clocksource/drivers/fttmr010: Fix invalid interrupt register access
clocksource/drivers/integrator-ap: Add missing of_node_put()
clocksource/drivers/bcm2835: Switch to SPDX identifier
dt-bindings: timer: renesas, cmt: Document r8a774a1 CMT support
clocksource/drivers/timer-imx-tpm: Convert the driver to timer-of
clocksource/drivers/arc_timer: Utilize generic sched_clock
dt-bindings: timer: renesas, cmt: Document r8a77470 CMT support
dt-bindings: timer: renesas, cmt: Document r8a7796 CMT support
clocksource/drivers/imx-gpt: Remove unnecessary irq protection
clocksource/drivers/imx-gpt: Add support for ARM64
clocksource/drivers/meson6_timer: Implement the ARM delay timer
...

+673 -602
+20
Documentation/devicetree/bindings/timer/rda,8810pl-timer.txt
··· 1 + RDA Micro RDA8810PL Timer 2 + 3 + Required properties: 4 + - compatible : "rda,8810pl-timer" 5 + - reg : Offset and length of the register set for the device. 6 + - interrupts : Should contain two interrupts. 7 + - interrupt-names : Should be "hwtimer", "ostimer". 8 + 9 + Example: 10 + 11 + apb@20900000 { 12 + compatible = "simple-bus"; 13 + ... 14 + timer@10000 { 15 + compatible = "rda,8810pl-timer"; 16 + reg = <0x10000 0x1000>; 17 + interrupts = <16 IRQ_TYPE_LEVEL_HIGH>, 18 + <17 IRQ_TYPE_LEVEL_HIGH>; 19 + interrupt-names = "hwtimer", "ostimer"; 20 + };
+12 -3
Documentation/devicetree/bindings/timer/renesas,cmt.txt
··· 28 28 - "renesas,r8a7744-cmt1" for the 48-bit CMT1 device included in r8a7744. 29 29 - "renesas,r8a7745-cmt0" for the 32-bit CMT0 device included in r8a7745. 30 30 - "renesas,r8a7745-cmt1" for the 48-bit CMT1 device included in r8a7745. 31 + - "renesas,r8a77470-cmt0" for the 32-bit CMT0 device included in r8a77470. 32 + - "renesas,r8a77470-cmt1" for the 48-bit CMT1 device included in r8a77470. 33 + - "renesas,r8a774a1-cmt0" for the 32-bit CMT0 device included in r8a774a1. 34 + - "renesas,r8a774a1-cmt1" for the 48-bit CMT1 device included in r8a774a1. 31 35 - "renesas,r8a7790-cmt0" for the 32-bit CMT0 device included in r8a7790. 32 36 - "renesas,r8a7790-cmt1" for the 48-bit CMT1 device included in r8a7790. 33 37 - "renesas,r8a7791-cmt0" for the 32-bit CMT0 device included in r8a7791. ··· 40 36 - "renesas,r8a7793-cmt1" for the 48-bit CMT1 device included in r8a7793. 41 37 - "renesas,r8a7794-cmt0" for the 32-bit CMT0 device included in r8a7794. 42 38 - "renesas,r8a7794-cmt1" for the 48-bit CMT1 device included in r8a7794. 39 + - "renesas,r8a7796-cmt0" for the 32-bit CMT0 device included in r8a7796. 40 + - "renesas,r8a7796-cmt1" for the 48-bit CMT1 device included in r8a7796. 43 41 - "renesas,r8a77970-cmt0" for the 32-bit CMT0 device included in r8a77970. 44 42 - "renesas,r8a77970-cmt1" for the 48-bit CMT1 device included in r8a77970. 45 43 - "renesas,r8a77980-cmt0" for the 32-bit CMT0 device included in r8a77980. ··· 53 47 and RZ/G1. 54 48 These are fallbacks for r8a73a4, R-Car Gen2 and RZ/G1 entries 55 49 listed above. 56 - - "renesas,rcar-gen3-cmt0" for 32-bit CMT0 devices included in R-Car Gen3. 57 - - "renesas,rcar-gen3-cmt1" for 48-bit CMT1 devices included in R-Car Gen3. 58 - These are fallbacks for R-Car Gen3 entries listed above. 50 + - "renesas,rcar-gen3-cmt0" for 32-bit CMT0 devices included in R-Car Gen3 51 + and RZ/G2. 52 + - "renesas,rcar-gen3-cmt1" for 48-bit CMT1 devices included in R-Car Gen3 53 + and RZ/G2. 54 + These are fallbacks for R-Car Gen3 and RZ/G2 entries listed 55 + above. 59 56 60 57 - reg: base address and length of the registers block for the timer module. 61 58 - interrupts: interrupt-specifier for the timer, one per channel.
+1
arch/arc/Kconfig
··· 26 26 select GENERIC_IRQ_SHOW 27 27 select GENERIC_PCI_IOMAP 28 28 select GENERIC_PENDING_IRQ if SMP 29 + select GENERIC_SCHED_CLOCK 29 30 select GENERIC_SMP_IDLE_THREAD 30 31 select HAVE_ARCH_KGDB 31 32 select HAVE_ARCH_TRACEHOOK
+11 -15
drivers/clocksource/Kconfig
··· 105 105 help 106 106 Enables the support for the Actions Semi Owl timer driver. 107 107 108 + config RDA_TIMER 109 + bool "RDA timer driver" if COMPILE_TEST 110 + depends on GENERIC_CLOCKEVENTS 111 + select CLKSRC_MMIO 112 + select TIMER_OF 113 + help 114 + Enables the support for the RDA Micro timer driver. 115 + 108 116 config SUN4I_TIMER 109 117 bool "Sun4i timer driver" if COMPILE_TEST 110 118 depends on HAS_IOMEM ··· 171 163 to multiple interrupt generating programmable 172 164 32-bit free running decrementing counters. 173 165 174 - config CLKSRC_NOMADIK_MTU_SCHED_CLOCK 175 - bool 176 - depends on CLKSRC_NOMADIK_MTU 177 - help 178 - Use the Multi Timer Unit as the sched_clock. 179 - 180 166 config CLKSRC_DBX500_PRCMU 181 167 bool "Clocksource PRCMU Timer" if COMPILE_TEST 182 168 depends on HAS_IOMEM ··· 227 225 select CLKSRC_MMIO 228 226 help 229 227 Enables support for the Integrator-ap timer. 230 - 231 - config CLKSRC_DBX500_PRCMU_SCHED_CLOCK 232 - bool "Clocksource PRCMU Timer sched_clock" 233 - depends on (CLKSRC_DBX500_PRCMU && !CLKSRC_NOMADIK_MTU_SCHED_CLOCK) 234 - default y 235 - help 236 - Use the always on PRCMU Timer as sched_clock 237 228 238 229 config CLKSRC_EFM32 239 230 bool "Clocksource for Energy Micro's EFM32 SoCs" if !ARCH_EFM32 ··· 285 290 286 291 config ARC_TIMERS 287 292 bool "Support for 32-bit TIMERn counters in ARC Cores" if COMPILE_TEST 293 + depends on GENERIC_SCHED_CLOCK 288 294 select TIMER_OF 289 295 help 290 296 These are legacy 32-bit TIMER0 and TIMER1 counters found on all ARC cores ··· 576 580 577 581 config CLKSRC_IMX_GPT 578 582 bool "Clocksource using i.MX GPT" if COMPILE_TEST 579 - depends on ARM && CLKDEV_LOOKUP 583 + depends on (ARM || ARM64) && CLKDEV_LOOKUP 580 584 select CLKSRC_MMIO 581 585 582 586 config CLKSRC_IMX_TPM ··· 607 611 608 612 config RISCV_TIMER 609 613 bool "Timer for the RISC-V platform" 610 - depends on RISCV 614 + depends on GENERIC_SCHED_CLOCK && RISCV 611 615 default y 612 616 select TIMER_PROBE 613 617 select TIMER_OF
+6 -5
drivers/clocksource/Makefile
··· 20 20 obj-$(CONFIG_DW_APB_TIMER) += dw_apb_timer.o 21 21 obj-$(CONFIG_DW_APB_TIMER_OF) += dw_apb_timer_of.o 22 22 obj-$(CONFIG_FTTMR010_TIMER) += timer-fttmr010.o 23 - obj-$(CONFIG_ROCKCHIP_TIMER) += rockchip_timer.o 23 + obj-$(CONFIG_ROCKCHIP_TIMER) += timer-rockchip.o 24 24 obj-$(CONFIG_CLKSRC_NOMADIK_MTU) += nomadik-mtu.o 25 25 obj-$(CONFIG_CLKSRC_DBX500_PRCMU) += clksrc-dbx500-prcmu.o 26 26 obj-$(CONFIG_ARMADA_370_XP_TIMER) += timer-armada-370-xp.o ··· 32 32 obj-$(CONFIG_CLKSRC_PXA) += pxa_timer.o 33 33 obj-$(CONFIG_PRIMA2_TIMER) += timer-prima2.o 34 34 obj-$(CONFIG_U300_TIMER) += timer-u300.o 35 - obj-$(CONFIG_SUN4I_TIMER) += sun4i_timer.o 35 + obj-$(CONFIG_SUN4I_TIMER) += timer-sun4i.o 36 36 obj-$(CONFIG_SUN5I_HSTIMER) += timer-sun5i.o 37 - obj-$(CONFIG_MESON6_TIMER) += meson6_timer.o 38 - obj-$(CONFIG_TEGRA_TIMER) += tegra20_timer.o 37 + obj-$(CONFIG_MESON6_TIMER) += timer-meson6.o 38 + obj-$(CONFIG_TEGRA_TIMER) += timer-tegra20.o 39 39 obj-$(CONFIG_VT8500_TIMER) += timer-vt8500.o 40 40 obj-$(CONFIG_NSPIRE_TIMER) += timer-zevio.o 41 41 obj-$(CONFIG_BCM_KONA_TIMER) += bcm_kona_timer.o ··· 57 57 obj-$(CONFIG_OWL_TIMER) += timer-owl.o 58 58 obj-$(CONFIG_SPRD_TIMER) += timer-sprd.o 59 59 obj-$(CONFIG_NPCM7XX_TIMER) += timer-npcm7xx.o 60 + obj-$(CONFIG_RDA_TIMER) += timer-rda.o 60 61 61 62 obj-$(CONFIG_ARC_TIMERS) += arc_timer.o 62 63 obj-$(CONFIG_ARM_ARCH_TIMER) += arm_arch_timer.o ··· 79 78 obj-$(CONFIG_CLKSRC_ST_LPC) += clksrc_st_lpc.o 80 79 obj-$(CONFIG_X86_NUMACHIP) += numachip.o 81 80 obj-$(CONFIG_ATCPIT100_TIMER) += timer-atcpit100.o 82 - obj-$(CONFIG_RISCV_TIMER) += riscv_timer.o 81 + obj-$(CONFIG_RISCV_TIMER) += timer-riscv.o 83 82 obj-$(CONFIG_CSKY_MP_TIMER) += timer-mp-csky.o 84 83 obj-$(CONFIG_GX6605S_TIMER) += timer-gx6605s.o
+22
drivers/clocksource/arc_timer.c
··· 23 23 #include <linux/cpu.h> 24 24 #include <linux/of.h> 25 25 #include <linux/of_irq.h> 26 + #include <linux/sched_clock.h> 26 27 27 28 #include <soc/arc/timers.h> 28 29 #include <soc/arc/mcip.h> ··· 89 88 return (((u64)h) << 32) | l; 90 89 } 91 90 91 + static notrace u64 arc_gfrc_clock_read(void) 92 + { 93 + return arc_read_gfrc(NULL); 94 + } 95 + 92 96 static struct clocksource arc_counter_gfrc = { 93 97 .name = "ARConnect GFRC", 94 98 .rating = 400, ··· 116 110 ret = arc_get_timer_clk(node); 117 111 if (ret) 118 112 return ret; 113 + 114 + sched_clock_register(arc_gfrc_clock_read, 64, arc_timer_freq); 119 115 120 116 return clocksource_register_hz(&arc_counter_gfrc, arc_timer_freq); 121 117 } ··· 145 137 } while (!(status & _BITUL(31))); 146 138 147 139 return (((u64)h) << 32) | l; 140 + } 141 + 142 + static notrace u64 arc_rtc_clock_read(void) 143 + { 144 + return arc_read_rtc(NULL); 148 145 } 149 146 150 147 static struct clocksource arc_counter_rtc = { ··· 183 170 184 171 write_aux_reg(AUX_RTC_CTRL, 1); 185 172 173 + sched_clock_register(arc_rtc_clock_read, 64, arc_timer_freq); 174 + 186 175 return clocksource_register_hz(&arc_counter_rtc, arc_timer_freq); 187 176 } 188 177 TIMER_OF_DECLARE(arc_rtc, "snps,archs-timer-rtc", arc_cs_setup_rtc); ··· 198 183 static u64 arc_read_timer1(struct clocksource *cs) 199 184 { 200 185 return (u64) read_aux_reg(ARC_REG_TIMER1_CNT); 186 + } 187 + 188 + static notrace u64 arc_timer1_clock_read(void) 189 + { 190 + return arc_read_timer1(NULL); 201 191 } 202 192 203 193 static struct clocksource arc_counter_timer1 = { ··· 228 208 write_aux_reg(ARC_REG_TIMER1_LIMIT, ARC_TIMERN_MAX); 229 209 write_aux_reg(ARC_REG_TIMER1_CNT, 0); 230 210 write_aux_reg(ARC_REG_TIMER1_CTRL, TIMER_CTRL_NH); 211 + 212 + sched_clock_register(arc_timer1_clock_read, 32, arc_timer_freq); 231 213 232 214 return clocksource_register_hz(&arc_counter_timer1, arc_timer_freq); 233 215 }
+1 -14
drivers/clocksource/bcm2835_timer.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /* 2 3 * Copyright 2012 Simon Arlott 3 - * 4 - * This program is free software; you can redistribute it and/or modify 5 - * it under the terms of the GNU General Public License as published by 6 - * the Free Software Foundation; either version 2 of the License, or 7 - * (at your option) any later version. 8 - * 9 - * This program is distributed in the hope that it will be useful, 10 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 - * GNU General Public License for more details. 13 - * 14 - * You should have received a copy of the GNU General Public License 15 - * along with this program; if not, write to the Free Software 16 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 4 */ 18 5 19 6 #include <linux/bitops.h>
+2 -20
drivers/clocksource/clksrc-dbx500-prcmu.c
··· 15 15 #include <linux/of.h> 16 16 #include <linux/of_address.h> 17 17 #include <linux/clockchips.h> 18 - #include <linux/sched_clock.h> 19 18 20 19 #define RATE_32K 32768 21 20 ··· 24 25 #define PRCMU_TIMER_REF 0 25 26 #define PRCMU_TIMER_DOWNCOUNT 0x4 26 27 #define PRCMU_TIMER_MODE 0x8 27 - 28 - #define SCHED_CLOCK_MIN_WRAP 131072 /* 2^32 / 32768 */ 29 28 30 29 static void __iomem *clksrc_dbx500_timer_base; 31 30 ··· 43 46 44 47 static struct clocksource clocksource_dbx500_prcmu = { 45 48 .name = "dbx500-prcmu-timer", 46 - .rating = 300, 49 + .rating = 100, 47 50 .read = clksrc_dbx500_prcmu_read, 48 51 .mask = CLOCKSOURCE_MASK(32), 49 - .flags = CLOCK_SOURCE_IS_CONTINUOUS, 52 + .flags = CLOCK_SOURCE_IS_CONTINUOUS | CLOCK_SOURCE_SUSPEND_NONSTOP, 50 53 }; 51 - 52 - #ifdef CONFIG_CLKSRC_DBX500_PRCMU_SCHED_CLOCK 53 - 54 - static u64 notrace dbx500_prcmu_sched_clock_read(void) 55 - { 56 - if (unlikely(!clksrc_dbx500_timer_base)) 57 - return 0; 58 - 59 - return clksrc_dbx500_prcmu_read(&clocksource_dbx500_prcmu); 60 - } 61 - 62 - #endif 63 54 64 55 static int __init clksrc_dbx500_prcmu_init(struct device_node *node) 65 56 { ··· 66 81 writel(TIMER_DOWNCOUNT_VAL, 67 82 clksrc_dbx500_timer_base + PRCMU_TIMER_REF); 68 83 } 69 - #ifdef CONFIG_CLKSRC_DBX500_PRCMU_SCHED_CLOCK 70 - sched_clock_register(dbx500_prcmu_sched_clock_read, 32, RATE_32K); 71 - #endif 72 84 return clocksource_register_hz(&clocksource_dbx500_prcmu, RATE_32K); 73 85 } 74 86 TIMER_OF_DECLARE(dbx500_prcmu, "stericsson,db8500-prcmu-timer-4",
-178
drivers/clocksource/meson6_timer.c
··· 1 - /* 2 - * Amlogic Meson6 SoCs timer handling. 3 - * 4 - * Copyright (C) 2014 Carlo Caione <carlo@caione.org> 5 - * 6 - * Based on code from Amlogic, Inc 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/sched_clock.h> 19 - #include <linux/of.h> 20 - #include <linux/of_address.h> 21 - #include <linux/of_irq.h> 22 - 23 - #define CED_ID 0 24 - #define CSD_ID 4 25 - 26 - #define TIMER_ISA_MUX 0 27 - #define TIMER_ISA_VAL(t) (((t) + 1) << 2) 28 - 29 - #define TIMER_INPUT_BIT(t) (2 * (t)) 30 - #define TIMER_ENABLE_BIT(t) (16 + (t)) 31 - #define TIMER_PERIODIC_BIT(t) (12 + (t)) 32 - 33 - #define TIMER_CED_INPUT_MASK (3UL << TIMER_INPUT_BIT(CED_ID)) 34 - #define TIMER_CSD_INPUT_MASK (7UL << TIMER_INPUT_BIT(CSD_ID)) 35 - 36 - #define TIMER_CED_UNIT_1US 0 37 - #define TIMER_CSD_UNIT_1US 1 38 - 39 - static void __iomem *timer_base; 40 - 41 - static u64 notrace meson6_timer_sched_read(void) 42 - { 43 - return (u64)readl(timer_base + TIMER_ISA_VAL(CSD_ID)); 44 - } 45 - 46 - static void meson6_clkevt_time_stop(unsigned char timer) 47 - { 48 - u32 val = readl(timer_base + TIMER_ISA_MUX); 49 - 50 - writel(val & ~TIMER_ENABLE_BIT(timer), timer_base + TIMER_ISA_MUX); 51 - } 52 - 53 - static void meson6_clkevt_time_setup(unsigned char timer, unsigned long delay) 54 - { 55 - writel(delay, timer_base + TIMER_ISA_VAL(timer)); 56 - } 57 - 58 - static void meson6_clkevt_time_start(unsigned char timer, bool periodic) 59 - { 60 - u32 val = readl(timer_base + TIMER_ISA_MUX); 61 - 62 - if (periodic) 63 - val |= TIMER_PERIODIC_BIT(timer); 64 - else 65 - val &= ~TIMER_PERIODIC_BIT(timer); 66 - 67 - writel(val | TIMER_ENABLE_BIT(timer), timer_base + TIMER_ISA_MUX); 68 - } 69 - 70 - static int meson6_shutdown(struct clock_event_device *evt) 71 - { 72 - meson6_clkevt_time_stop(CED_ID); 73 - return 0; 74 - } 75 - 76 - static int meson6_set_oneshot(struct clock_event_device *evt) 77 - { 78 - meson6_clkevt_time_stop(CED_ID); 79 - meson6_clkevt_time_start(CED_ID, false); 80 - return 0; 81 - } 82 - 83 - static int meson6_set_periodic(struct clock_event_device *evt) 84 - { 85 - meson6_clkevt_time_stop(CED_ID); 86 - meson6_clkevt_time_setup(CED_ID, USEC_PER_SEC / HZ - 1); 87 - meson6_clkevt_time_start(CED_ID, true); 88 - return 0; 89 - } 90 - 91 - static int meson6_clkevt_next_event(unsigned long evt, 92 - struct clock_event_device *unused) 93 - { 94 - meson6_clkevt_time_stop(CED_ID); 95 - meson6_clkevt_time_setup(CED_ID, evt); 96 - meson6_clkevt_time_start(CED_ID, false); 97 - 98 - return 0; 99 - } 100 - 101 - static struct clock_event_device meson6_clockevent = { 102 - .name = "meson6_tick", 103 - .rating = 400, 104 - .features = CLOCK_EVT_FEAT_PERIODIC | 105 - CLOCK_EVT_FEAT_ONESHOT, 106 - .set_state_shutdown = meson6_shutdown, 107 - .set_state_periodic = meson6_set_periodic, 108 - .set_state_oneshot = meson6_set_oneshot, 109 - .tick_resume = meson6_shutdown, 110 - .set_next_event = meson6_clkevt_next_event, 111 - }; 112 - 113 - static irqreturn_t meson6_timer_interrupt(int irq, void *dev_id) 114 - { 115 - struct clock_event_device *evt = (struct clock_event_device *)dev_id; 116 - 117 - evt->event_handler(evt); 118 - 119 - return IRQ_HANDLED; 120 - } 121 - 122 - static struct irqaction meson6_timer_irq = { 123 - .name = "meson6_timer", 124 - .flags = IRQF_TIMER | IRQF_IRQPOLL, 125 - .handler = meson6_timer_interrupt, 126 - .dev_id = &meson6_clockevent, 127 - }; 128 - 129 - static int __init meson6_timer_init(struct device_node *node) 130 - { 131 - u32 val; 132 - int ret, irq; 133 - 134 - timer_base = of_io_request_and_map(node, 0, "meson6-timer"); 135 - if (IS_ERR(timer_base)) { 136 - pr_err("Can't map registers\n"); 137 - return -ENXIO; 138 - } 139 - 140 - irq = irq_of_parse_and_map(node, 0); 141 - if (irq <= 0) { 142 - pr_err("Can't parse IRQ\n"); 143 - return -EINVAL; 144 - } 145 - 146 - /* Set 1us for timer E */ 147 - val = readl(timer_base + TIMER_ISA_MUX); 148 - val &= ~TIMER_CSD_INPUT_MASK; 149 - val |= TIMER_CSD_UNIT_1US << TIMER_INPUT_BIT(CSD_ID); 150 - writel(val, timer_base + TIMER_ISA_MUX); 151 - 152 - sched_clock_register(meson6_timer_sched_read, 32, USEC_PER_SEC); 153 - clocksource_mmio_init(timer_base + TIMER_ISA_VAL(CSD_ID), node->name, 154 - 1000 * 1000, 300, 32, clocksource_mmio_readl_up); 155 - 156 - /* Timer A base 1us */ 157 - val &= ~TIMER_CED_INPUT_MASK; 158 - val |= TIMER_CED_UNIT_1US << TIMER_INPUT_BIT(CED_ID); 159 - writel(val, timer_base + TIMER_ISA_MUX); 160 - 161 - /* Stop the timer A */ 162 - meson6_clkevt_time_stop(CED_ID); 163 - 164 - ret = setup_irq(irq, &meson6_timer_irq); 165 - if (ret) { 166 - pr_warn("failed to setup irq %d\n", irq); 167 - return ret; 168 - } 169 - 170 - meson6_clockevent.cpumask = cpu_possible_mask; 171 - meson6_clockevent.irq = irq; 172 - 173 - clockevents_config_and_register(&meson6_clockevent, USEC_PER_SEC, 174 - 1, 0xfffe); 175 - return 0; 176 - } 177 - TIMER_OF_DECLARE(meson6, "amlogic,meson6-timer", 178 - meson6_timer_init);
-4
drivers/clocksource/nomadik-mtu.c
··· 69 69 static u32 nmdk_cycle; /* write-once */ 70 70 static struct delay_timer mtu_delay_timer; 71 71 72 - #ifdef CONFIG_CLKSRC_NOMADIK_MTU_SCHED_CLOCK 73 72 /* 74 73 * Override the global weak sched_clock symbol with this 75 74 * local implementation which uses the clocksource to get some ··· 81 82 82 83 return -readl(mtu_base + MTU_VAL(0)); 83 84 } 84 - #endif 85 85 86 86 static unsigned long nmdk_timer_read_current_timer(void) 87 87 { ··· 232 234 return ret; 233 235 } 234 236 235 - #ifdef CONFIG_CLKSRC_NOMADIK_MTU_SCHED_CLOCK 236 237 sched_clock_register(nomadik_read_sched_clock, 32, rate); 237 - #endif 238 238 239 239 /* Timer 1 is used for events, register irq and clockevents */ 240 240 setup_irq(irq, &nmdk_timer_irq);
+9
drivers/clocksource/riscv_timer.c drivers/clocksource/timer-riscv.c
··· 8 8 #include <linux/cpu.h> 9 9 #include <linux/delay.h> 10 10 #include <linux/irq.h> 11 + #include <linux/sched_clock.h> 11 12 #include <asm/smp.h> 12 13 #include <asm/sbi.h> 13 14 ··· 46 45 * backwards when hopping between CPUs, practically it won't happen. 47 46 */ 48 47 static unsigned long long riscv_clocksource_rdtime(struct clocksource *cs) 48 + { 49 + return get_cycles64(); 50 + } 51 + 52 + static u64 riscv_sched_clock(void) 49 53 { 50 54 return get_cycles64(); 51 55 } ··· 102 96 103 97 cs = per_cpu_ptr(&riscv_clocksource, cpuid); 104 98 clocksource_register_hz(cs, riscv_timebase); 99 + 100 + sched_clock_register(riscv_sched_clock, 101 + BITS_PER_LONG, riscv_timebase); 105 102 106 103 error = cpuhp_setup_state(CPUHP_AP_RISCV_TIMER_STARTING, 107 104 "clockevents/riscv/timer:starting",
drivers/clocksource/rockchip_timer.c drivers/clocksource/timer-rockchip.c
drivers/clocksource/sun4i_timer.c drivers/clocksource/timer-sun4i.c
-1
drivers/clocksource/tegra20_timer.c drivers/clocksource/timer-tegra20.c
··· 30 30 #include <linux/delay.h> 31 31 32 32 #include <asm/mach/time.h> 33 - #include <asm/smp_twd.h> 34 33 35 34 #define RTC_SECONDS 0x08 36 35 #define RTC_SHADOW_SECONDS 0x0c
+42 -31
drivers/clocksource/timer-fttmr010.c
··· 21 21 #include <linux/delay.h> 22 22 23 23 /* 24 - * Register definitions for the timers 24 + * Register definitions common for all the timer variants. 25 25 */ 26 26 #define TIMER1_COUNT (0x00) 27 27 #define TIMER1_LOAD (0x04) ··· 36 36 #define TIMER3_MATCH1 (0x28) 37 37 #define TIMER3_MATCH2 (0x2c) 38 38 #define TIMER_CR (0x30) 39 - #define TIMER_INTR_STATE (0x34) 40 - #define TIMER_INTR_MASK (0x38) 41 39 40 + /* 41 + * Control register (TMC30) bit fields for fttmr010/gemini/moxart timers. 42 + */ 42 43 #define TIMER_1_CR_ENABLE BIT(0) 43 44 #define TIMER_1_CR_CLOCK BIT(1) 44 45 #define TIMER_1_CR_INT BIT(2) ··· 54 53 #define TIMER_3_CR_UPDOWN BIT(11) 55 54 56 55 /* 57 - * The Aspeed AST2400 moves bits around in the control register 58 - * and lacks bits for setting the timer to count upwards. 56 + * Control register (TMC30) bit fields for aspeed ast2400/ast2500 timers. 57 + * The aspeed timers move bits around in the control register and lacks 58 + * bits for setting the timer to count upwards. 59 59 */ 60 60 #define TIMER_1_CR_ASPEED_ENABLE BIT(0) 61 61 #define TIMER_1_CR_ASPEED_CLOCK BIT(1) ··· 68 66 #define TIMER_3_CR_ASPEED_CLOCK BIT(9) 69 67 #define TIMER_3_CR_ASPEED_INT BIT(10) 70 68 69 + /* 70 + * Interrupt status/mask register definitions for fttmr010/gemini/moxart 71 + * timers. 72 + * The registers don't exist and they are not needed on aspeed timers 73 + * because: 74 + * - aspeed timer overflow interrupt is controlled by bits in Control 75 + * Register (TMC30). 76 + * - aspeed timers always generate interrupt when either one of the 77 + * Match registers equals to Status register. 78 + */ 79 + #define TIMER_INTR_STATE (0x34) 80 + #define TIMER_INTR_MASK (0x38) 71 81 #define TIMER_1_INT_MATCH1 BIT(0) 72 82 #define TIMER_1_INT_MATCH2 BIT(1) 73 83 #define TIMER_1_INT_OVERFLOW BIT(2) ··· 94 80 struct fttmr010 { 95 81 void __iomem *base; 96 82 unsigned int tick_rate; 97 - bool count_down; 83 + bool is_aspeed; 98 84 u32 t1_enable_val; 99 85 struct clock_event_device clkevt; 100 86 #ifdef CONFIG_ARM ··· 144 130 cr &= ~fttmr010->t1_enable_val; 145 131 writel(cr, fttmr010->base + TIMER_CR); 146 132 147 - if (fttmr010->count_down) { 133 + if (fttmr010->is_aspeed) { 148 134 /* 149 135 * ASPEED Timer Controller will load TIMER1_LOAD register 150 136 * into TIMER1_COUNT register when the timer is re-enabled. ··· 189 175 190 176 /* Setup counter start from 0 or ~0 */ 191 177 writel(0, fttmr010->base + TIMER1_COUNT); 192 - if (fttmr010->count_down) 178 + if (fttmr010->is_aspeed) { 193 179 writel(~0, fttmr010->base + TIMER1_LOAD); 194 - else 180 + } else { 195 181 writel(0, fttmr010->base + TIMER1_LOAD); 196 182 197 - /* Enable interrupt */ 198 - cr = readl(fttmr010->base + TIMER_INTR_MASK); 199 - cr &= ~(TIMER_1_INT_OVERFLOW | TIMER_1_INT_MATCH2); 200 - cr |= TIMER_1_INT_MATCH1; 201 - writel(cr, fttmr010->base + TIMER_INTR_MASK); 183 + /* Enable interrupt */ 184 + cr = readl(fttmr010->base + TIMER_INTR_MASK); 185 + cr &= ~(TIMER_1_INT_OVERFLOW | TIMER_1_INT_MATCH2); 186 + cr |= TIMER_1_INT_MATCH1; 187 + writel(cr, fttmr010->base + TIMER_INTR_MASK); 188 + } 202 189 203 190 return 0; 204 191 } ··· 216 201 writel(cr, fttmr010->base + TIMER_CR); 217 202 218 203 /* Setup timer to fire at 1/HZ intervals. */ 219 - if (fttmr010->count_down) { 204 + if (fttmr010->is_aspeed) { 220 205 writel(period, fttmr010->base + TIMER1_LOAD); 221 - writel(0, fttmr010->base + TIMER1_MATCH1); 222 206 } else { 223 207 cr = 0xffffffff - (period - 1); 224 208 writel(cr, fttmr010->base + TIMER1_COUNT); ··· 295 281 } 296 282 297 283 /* 298 - * The Aspeed AST2400 moves bits around in the control register, 299 - * otherwise it works the same. 284 + * The Aspeed timers move bits around in the control register. 300 285 */ 301 286 if (is_aspeed) { 302 287 fttmr010->t1_enable_val = TIMER_1_CR_ASPEED_ENABLE | 303 288 TIMER_1_CR_ASPEED_INT; 304 - /* Downward not available */ 305 - fttmr010->count_down = true; 289 + fttmr010->is_aspeed = true; 306 290 } else { 307 291 fttmr010->t1_enable_val = TIMER_1_CR_ENABLE | TIMER_1_CR_INT; 308 - } 309 292 310 - /* 311 - * Reset the interrupt mask and status 312 - */ 313 - writel(TIMER_INT_ALL_MASK, fttmr010->base + TIMER_INTR_MASK); 314 - writel(0, fttmr010->base + TIMER_INTR_STATE); 293 + /* 294 + * Reset the interrupt mask and status 295 + */ 296 + writel(TIMER_INT_ALL_MASK, fttmr010->base + TIMER_INTR_MASK); 297 + writel(0, fttmr010->base + TIMER_INTR_STATE); 298 + } 315 299 316 300 /* 317 301 * Enable timer 1 count up, timer 2 count up, except on Aspeed, ··· 318 306 if (is_aspeed) 319 307 val = TIMER_2_CR_ASPEED_ENABLE; 320 308 else { 321 - val = TIMER_2_CR_ENABLE; 322 - if (!fttmr010->count_down) 323 - val |= TIMER_1_CR_UPDOWN | TIMER_2_CR_UPDOWN; 309 + val = TIMER_2_CR_ENABLE | TIMER_1_CR_UPDOWN | 310 + TIMER_2_CR_UPDOWN; 324 311 } 325 312 writel(val, fttmr010->base + TIMER_CR); 326 313 ··· 332 321 writel(0, fttmr010->base + TIMER2_MATCH1); 333 322 writel(0, fttmr010->base + TIMER2_MATCH2); 334 323 335 - if (fttmr010->count_down) { 324 + if (fttmr010->is_aspeed) { 336 325 writel(~0, fttmr010->base + TIMER2_LOAD); 337 326 clocksource_mmio_init(fttmr010->base + TIMER2_COUNT, 338 327 "FTTMR010-TIMER2", ··· 382 371 383 372 #ifdef CONFIG_ARM 384 373 /* Also use this timer for delays */ 385 - if (fttmr010->count_down) 374 + if (fttmr010->is_aspeed) 386 375 fttmr010->delay_timer.read_current_timer = 387 376 fttmr010_read_current_timer_down; 388 377 else
+4 -17
drivers/clocksource/timer-imx-gpt.c
··· 141 141 return sched_clock_reg ? readl_relaxed(sched_clock_reg) : 0; 142 142 } 143 143 144 + #if defined(CONFIG_ARM) 144 145 static struct delay_timer imx_delay_timer; 145 146 146 147 static unsigned long imx_read_current_timer(void) 147 148 { 148 149 return readl_relaxed(sched_clock_reg); 149 150 } 151 + #endif 150 152 151 153 static int __init mxc_clocksource_init(struct imx_timer *imxtm) 152 154 { 153 155 unsigned int c = clk_get_rate(imxtm->clk_per); 154 156 void __iomem *reg = imxtm->base + imxtm->gpt->reg_tcn; 155 157 158 + #if defined(CONFIG_ARM) 156 159 imx_delay_timer.read_current_timer = &imx_read_current_timer; 157 160 imx_delay_timer.freq = c; 158 161 register_current_timer_delay(&imx_delay_timer); 162 + #endif 159 163 160 164 sched_clock_reg = reg; 161 165 ··· 202 198 static int mxc_shutdown(struct clock_event_device *ced) 203 199 { 204 200 struct imx_timer *imxtm = to_imx_timer(ced); 205 - unsigned long flags; 206 201 u32 tcn; 207 - 208 - /* 209 - * The timer interrupt generation is disabled at least 210 - * for enough time to call mxc_set_next_event() 211 - */ 212 - local_irq_save(flags); 213 202 214 203 /* Disable interrupt in GPT module */ 215 204 imxtm->gpt->gpt_irq_disable(imxtm); ··· 218 221 printk(KERN_INFO "%s: changing mode\n", __func__); 219 222 #endif /* DEBUG */ 220 223 221 - local_irq_restore(flags); 222 - 223 224 return 0; 224 225 } 225 226 226 227 static int mxc_set_oneshot(struct clock_event_device *ced) 227 228 { 228 229 struct imx_timer *imxtm = to_imx_timer(ced); 229 - unsigned long flags; 230 - 231 - /* 232 - * The timer interrupt generation is disabled at least 233 - * for enough time to call mxc_set_next_event() 234 - */ 235 - local_irq_save(flags); 236 230 237 231 /* Disable interrupt in GPT module */ 238 232 imxtm->gpt->gpt_irq_disable(imxtm); ··· 248 260 * mode switching 249 261 */ 250 262 imxtm->gpt->gpt_irq_enable(imxtm); 251 - local_irq_restore(flags); 252 263 253 264 return 0; 254 265 }
+58 -81
drivers/clocksource/timer-imx-tpm.c
··· 12 12 #include <linux/of_irq.h> 13 13 #include <linux/sched_clock.h> 14 14 15 + #include "timer-of.h" 16 + 15 17 #define TPM_PARAM 0x4 16 18 #define TPM_PARAM_WIDTH_SHIFT 16 17 19 #define TPM_PARAM_WIDTH_MASK (0xff << 16) ··· 35 33 #define TPM_C0V 0x24 36 34 37 35 static int counter_width; 38 - static int rating; 39 36 static void __iomem *timer_base; 40 - static struct clock_event_device clockevent_tpm; 41 37 42 38 static inline void tpm_timer_disable(void) 43 39 { ··· 78 78 static u64 notrace tpm_read_sched_clock(void) 79 79 { 80 80 return tpm_read_counter(); 81 - } 82 - 83 - static int __init tpm_clocksource_init(unsigned long rate) 84 - { 85 - tpm_delay_timer.read_current_timer = &tpm_read_current_timer; 86 - tpm_delay_timer.freq = rate; 87 - register_current_timer_delay(&tpm_delay_timer); 88 - 89 - sched_clock_register(tpm_read_sched_clock, counter_width, rate); 90 - 91 - return clocksource_mmio_init(timer_base + TPM_CNT, "imx-tpm", 92 - rate, rating, counter_width, 93 - clocksource_mmio_readl_up); 94 81 } 95 82 96 83 static int tpm_set_next_event(unsigned long delta, ··· 124 137 return IRQ_HANDLED; 125 138 } 126 139 127 - static struct clock_event_device clockevent_tpm = { 128 - .name = "i.MX7ULP TPM Timer", 129 - .features = CLOCK_EVT_FEAT_ONESHOT, 130 - .set_state_oneshot = tpm_set_state_oneshot, 131 - .set_next_event = tpm_set_next_event, 132 - .set_state_shutdown = tpm_set_state_shutdown, 140 + static struct timer_of to_tpm = { 141 + .flags = TIMER_OF_IRQ | TIMER_OF_BASE | TIMER_OF_CLOCK, 142 + .clkevt = { 143 + .name = "i.MX7ULP TPM Timer", 144 + .rating = 200, 145 + .features = CLOCK_EVT_FEAT_ONESHOT, 146 + .set_state_shutdown = tpm_set_state_shutdown, 147 + .set_state_oneshot = tpm_set_state_oneshot, 148 + .set_next_event = tpm_set_next_event, 149 + .cpumask = cpu_possible_mask, 150 + }, 151 + .of_irq = { 152 + .handler = tpm_timer_interrupt, 153 + .flags = IRQF_TIMER | IRQF_IRQPOLL, 154 + }, 155 + .of_clk = { 156 + .name = "per", 157 + }, 133 158 }; 134 159 135 - static int __init tpm_clockevent_init(unsigned long rate, int irq) 160 + static int __init tpm_clocksource_init(void) 136 161 { 137 - int ret; 162 + tpm_delay_timer.read_current_timer = &tpm_read_current_timer; 163 + tpm_delay_timer.freq = timer_of_rate(&to_tpm) >> 3; 164 + register_current_timer_delay(&tpm_delay_timer); 138 165 139 - ret = request_irq(irq, tpm_timer_interrupt, IRQF_TIMER | IRQF_IRQPOLL, 140 - "i.MX7ULP TPM Timer", &clockevent_tpm); 166 + sched_clock_register(tpm_read_sched_clock, counter_width, 167 + timer_of_rate(&to_tpm) >> 3); 141 168 142 - clockevent_tpm.rating = rating; 143 - clockevent_tpm.cpumask = cpumask_of(0); 144 - clockevent_tpm.irq = irq; 145 - clockevents_config_and_register(&clockevent_tpm, rate, 300, 146 - GENMASK(counter_width - 1, 1)); 169 + return clocksource_mmio_init(timer_base + TPM_CNT, 170 + "imx-tpm", 171 + timer_of_rate(&to_tpm) >> 3, 172 + to_tpm.clkevt.rating, 173 + counter_width, 174 + clocksource_mmio_readl_up); 175 + } 147 176 148 - return ret; 177 + static void __init tpm_clockevent_init(void) 178 + { 179 + clockevents_config_and_register(&to_tpm.clkevt, 180 + timer_of_rate(&to_tpm) >> 3, 181 + 300, 182 + GENMASK(counter_width - 1, 183 + 1)); 149 184 } 150 185 151 186 static int __init tpm_timer_init(struct device_node *np) 152 187 { 153 - struct clk *ipg, *per; 154 - int irq, ret; 155 - u32 rate; 156 - 157 - timer_base = of_iomap(np, 0); 158 - if (!timer_base) { 159 - pr_err("tpm: failed to get base address\n"); 160 - return -ENXIO; 161 - } 162 - 163 - irq = irq_of_parse_and_map(np, 0); 164 - if (!irq) { 165 - pr_err("tpm: failed to get irq\n"); 166 - ret = -ENOENT; 167 - goto err_iomap; 168 - } 188 + struct clk *ipg; 189 + int ret; 169 190 170 191 ipg = of_clk_get_by_name(np, "ipg"); 171 - per = of_clk_get_by_name(np, "per"); 172 - if (IS_ERR(ipg) || IS_ERR(per)) { 173 - pr_err("tpm: failed to get ipg or per clk\n"); 174 - ret = -ENODEV; 175 - goto err_clk_get; 192 + if (IS_ERR(ipg)) { 193 + pr_err("tpm: failed to get ipg clk\n"); 194 + return -ENODEV; 176 195 } 177 - 178 196 /* enable clk before accessing registers */ 179 197 ret = clk_prepare_enable(ipg); 180 198 if (ret) { 181 199 pr_err("tpm: ipg clock enable failed (%d)\n", ret); 182 - goto err_clk_get; 200 + clk_put(ipg); 201 + return ret; 183 202 } 184 203 185 - ret = clk_prepare_enable(per); 186 - if (ret) { 187 - pr_err("tpm: per clock enable failed (%d)\n", ret); 188 - goto err_per_clk_enable; 189 - } 204 + ret = timer_of_init(np, &to_tpm); 205 + if (ret) 206 + return ret; 190 207 191 - counter_width = (readl(timer_base + TPM_PARAM) & TPM_PARAM_WIDTH_MASK) 192 - >> TPM_PARAM_WIDTH_SHIFT; 208 + timer_base = timer_of_base(&to_tpm); 209 + 210 + counter_width = (readl(timer_base + TPM_PARAM) 211 + & TPM_PARAM_WIDTH_MASK) >> TPM_PARAM_WIDTH_SHIFT; 193 212 /* use rating 200 for 32-bit counter and 150 for 16-bit counter */ 194 - rating = counter_width == 0x20 ? 200 : 150; 213 + to_tpm.clkevt.rating = counter_width == 0x20 ? 200 : 150; 195 214 196 215 /* 197 216 * Initialize tpm module to a known state ··· 222 229 writel(TPM_SC_CMOD_INC_PER_CNT | 223 230 (counter_width == 0x20 ? 224 231 TPM_SC_CMOD_DIV_DEFAULT : TPM_SC_CMOD_DIV_MAX), 225 - timer_base + TPM_SC); 232 + timer_base + TPM_SC); 226 233 227 234 /* set MOD register to maximum for free running mode */ 228 235 writel(GENMASK(counter_width - 1, 0), timer_base + TPM_MOD); 229 236 230 - rate = clk_get_rate(per) >> 3; 231 - ret = tpm_clocksource_init(rate); 232 - if (ret) 233 - goto err_per_clk_enable; 237 + tpm_clockevent_init(); 234 238 235 - ret = tpm_clockevent_init(rate, irq); 236 - if (ret) 237 - goto err_per_clk_enable; 238 - 239 - return 0; 240 - 241 - err_per_clk_enable: 242 - clk_disable_unprepare(ipg); 243 - err_clk_get: 244 - clk_put(per); 245 - clk_put(ipg); 246 - err_iomap: 247 - iounmap(timer_base); 248 - return ret; 239 + return tpm_clocksource_init(); 249 240 } 250 241 TIMER_OF_DECLARE(imx7ulp, "fsl,imx7ulp-tpm", tpm_timer_init);
+16 -9
drivers/clocksource/timer-integrator-ap.c
··· 181 181 int irq; 182 182 struct clk *clk; 183 183 unsigned long rate; 184 - struct device_node *pri_node; 185 - struct device_node *sec_node; 184 + struct device_node *alias_node; 186 185 187 186 base = of_io_request_and_map(node, 0, "integrator-timer"); 188 187 if (IS_ERR(base)) ··· 203 204 return err; 204 205 } 205 206 206 - pri_node = of_find_node_by_path(path); 207 + alias_node = of_find_node_by_path(path); 208 + 209 + /* 210 + * The pointer is used as an identifier not as a pointer, we 211 + * can drop the refcount on the of__node immediately after 212 + * getting it. 213 + */ 214 + of_node_put(alias_node); 215 + 216 + if (node == alias_node) 217 + /* The primary timer lacks IRQ, use as clocksource */ 218 + return integrator_clocksource_init(rate, base); 207 219 208 220 err = of_property_read_string(of_aliases, 209 221 "arm,timer-secondary", &path); ··· 223 213 return err; 224 214 } 225 215 216 + alias_node = of_find_node_by_path(path); 226 217 227 - sec_node = of_find_node_by_path(path); 218 + of_node_put(alias_node); 228 219 229 - if (node == pri_node) 230 - /* The primary timer lacks IRQ, use as clocksource */ 231 - return integrator_clocksource_init(rate, base); 232 - 233 - if (node == sec_node) { 220 + if (node == alias_node) { 234 221 /* The secondary timer will drive the clock event */ 235 222 irq = irq_of_parse_and_map(node, 0); 236 223 return integrator_clockevent_init(rate, base, irq);
+220
drivers/clocksource/timer-meson6.c
··· 1 + /* 2 + * Amlogic Meson6 SoCs timer handling. 3 + * 4 + * Copyright (C) 2014 Carlo Caione <carlo@caione.org> 5 + * 6 + * Based on code from Amlogic, Inc 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/bitfield.h> 14 + #include <linux/bitops.h> 15 + #include <linux/clk.h> 16 + #include <linux/clockchips.h> 17 + #include <linux/interrupt.h> 18 + #include <linux/irq.h> 19 + #include <linux/irqreturn.h> 20 + #include <linux/sched_clock.h> 21 + #include <linux/of.h> 22 + #include <linux/of_address.h> 23 + #include <linux/of_irq.h> 24 + 25 + #ifdef CONFIG_ARM 26 + #include <linux/delay.h> 27 + #endif 28 + 29 + #define MESON_ISA_TIMER_MUX 0x00 30 + #define MESON_ISA_TIMER_MUX_TIMERD_EN BIT(19) 31 + #define MESON_ISA_TIMER_MUX_TIMERC_EN BIT(18) 32 + #define MESON_ISA_TIMER_MUX_TIMERB_EN BIT(17) 33 + #define MESON_ISA_TIMER_MUX_TIMERA_EN BIT(16) 34 + #define MESON_ISA_TIMER_MUX_TIMERD_MODE BIT(15) 35 + #define MESON_ISA_TIMER_MUX_TIMERC_MODE BIT(14) 36 + #define MESON_ISA_TIMER_MUX_TIMERB_MODE BIT(13) 37 + #define MESON_ISA_TIMER_MUX_TIMERA_MODE BIT(12) 38 + #define MESON_ISA_TIMER_MUX_TIMERE_INPUT_CLOCK_MASK GENMASK(10, 8) 39 + #define MESON_ISA_TIMER_MUX_TIMERE_INPUT_CLOCK_SYSTEM_CLOCK 0x0 40 + #define MESON_ISA_TIMER_MUX_TIMERE_INPUT_CLOCK_1US 0x1 41 + #define MESON_ISA_TIMER_MUX_TIMERE_INPUT_CLOCK_10US 0x2 42 + #define MESON_ISA_TIMER_MUX_TIMERE_INPUT_CLOCK_100US 0x3 43 + #define MESON_ISA_TIMER_MUX_TIMERE_INPUT_CLOCK_1MS 0x4 44 + #define MESON_ISA_TIMER_MUX_TIMERD_INPUT_CLOCK_MASK GENMASK(7, 6) 45 + #define MESON_ISA_TIMER_MUX_TIMERC_INPUT_CLOCK_MASK GENMASK(5, 4) 46 + #define MESON_ISA_TIMER_MUX_TIMERB_INPUT_CLOCK_MASK GENMASK(3, 2) 47 + #define MESON_ISA_TIMER_MUX_TIMERA_INPUT_CLOCK_MASK GENMASK(1, 0) 48 + #define MESON_ISA_TIMER_MUX_TIMERABCD_INPUT_CLOCK_1US 0x0 49 + #define MESON_ISA_TIMER_MUX_TIMERABCD_INPUT_CLOCK_10US 0x1 50 + #define MESON_ISA_TIMER_MUX_TIMERABCD_INPUT_CLOCK_100US 0x0 51 + #define MESON_ISA_TIMER_MUX_TIMERABCD_INPUT_CLOCK_1MS 0x3 52 + 53 + #define MESON_ISA_TIMERA 0x04 54 + #define MESON_ISA_TIMERB 0x08 55 + #define MESON_ISA_TIMERC 0x0c 56 + #define MESON_ISA_TIMERD 0x10 57 + #define MESON_ISA_TIMERE 0x14 58 + 59 + static void __iomem *timer_base; 60 + 61 + #ifdef CONFIG_ARM 62 + static unsigned long meson6_read_current_timer(void) 63 + { 64 + return readl_relaxed(timer_base + MESON_ISA_TIMERE); 65 + } 66 + 67 + static struct delay_timer meson6_delay_timer = { 68 + .read_current_timer = meson6_read_current_timer, 69 + .freq = 1000 * 1000, 70 + }; 71 + #endif 72 + 73 + static u64 notrace meson6_timer_sched_read(void) 74 + { 75 + return (u64)readl(timer_base + MESON_ISA_TIMERE); 76 + } 77 + 78 + static void meson6_clkevt_time_stop(void) 79 + { 80 + u32 val = readl(timer_base + MESON_ISA_TIMER_MUX); 81 + 82 + writel(val & ~MESON_ISA_TIMER_MUX_TIMERA_EN, 83 + timer_base + MESON_ISA_TIMER_MUX); 84 + } 85 + 86 + static void meson6_clkevt_time_setup(unsigned long delay) 87 + { 88 + writel(delay, timer_base + MESON_ISA_TIMERA); 89 + } 90 + 91 + static void meson6_clkevt_time_start(bool periodic) 92 + { 93 + u32 val = readl(timer_base + MESON_ISA_TIMER_MUX); 94 + 95 + if (periodic) 96 + val |= MESON_ISA_TIMER_MUX_TIMERA_MODE; 97 + else 98 + val &= ~MESON_ISA_TIMER_MUX_TIMERA_MODE; 99 + 100 + writel(val | MESON_ISA_TIMER_MUX_TIMERA_EN, 101 + timer_base + MESON_ISA_TIMER_MUX); 102 + } 103 + 104 + static int meson6_shutdown(struct clock_event_device *evt) 105 + { 106 + meson6_clkevt_time_stop(); 107 + return 0; 108 + } 109 + 110 + static int meson6_set_oneshot(struct clock_event_device *evt) 111 + { 112 + meson6_clkevt_time_stop(); 113 + meson6_clkevt_time_start(false); 114 + return 0; 115 + } 116 + 117 + static int meson6_set_periodic(struct clock_event_device *evt) 118 + { 119 + meson6_clkevt_time_stop(); 120 + meson6_clkevt_time_setup(USEC_PER_SEC / HZ - 1); 121 + meson6_clkevt_time_start(true); 122 + return 0; 123 + } 124 + 125 + static int meson6_clkevt_next_event(unsigned long evt, 126 + struct clock_event_device *unused) 127 + { 128 + meson6_clkevt_time_stop(); 129 + meson6_clkevt_time_setup(evt); 130 + meson6_clkevt_time_start(false); 131 + 132 + return 0; 133 + } 134 + 135 + static struct clock_event_device meson6_clockevent = { 136 + .name = "meson6_tick", 137 + .rating = 400, 138 + .features = CLOCK_EVT_FEAT_PERIODIC | 139 + CLOCK_EVT_FEAT_ONESHOT, 140 + .set_state_shutdown = meson6_shutdown, 141 + .set_state_periodic = meson6_set_periodic, 142 + .set_state_oneshot = meson6_set_oneshot, 143 + .tick_resume = meson6_shutdown, 144 + .set_next_event = meson6_clkevt_next_event, 145 + }; 146 + 147 + static irqreturn_t meson6_timer_interrupt(int irq, void *dev_id) 148 + { 149 + struct clock_event_device *evt = (struct clock_event_device *)dev_id; 150 + 151 + evt->event_handler(evt); 152 + 153 + return IRQ_HANDLED; 154 + } 155 + 156 + static struct irqaction meson6_timer_irq = { 157 + .name = "meson6_timer", 158 + .flags = IRQF_TIMER | IRQF_IRQPOLL, 159 + .handler = meson6_timer_interrupt, 160 + .dev_id = &meson6_clockevent, 161 + }; 162 + 163 + static int __init meson6_timer_init(struct device_node *node) 164 + { 165 + u32 val; 166 + int ret, irq; 167 + 168 + timer_base = of_io_request_and_map(node, 0, "meson6-timer"); 169 + if (IS_ERR(timer_base)) { 170 + pr_err("Can't map registers\n"); 171 + return -ENXIO; 172 + } 173 + 174 + irq = irq_of_parse_and_map(node, 0); 175 + if (irq <= 0) { 176 + pr_err("Can't parse IRQ\n"); 177 + return -EINVAL; 178 + } 179 + 180 + /* Set 1us for timer E */ 181 + val = readl(timer_base + MESON_ISA_TIMER_MUX); 182 + val &= ~MESON_ISA_TIMER_MUX_TIMERE_INPUT_CLOCK_MASK; 183 + val |= FIELD_PREP(MESON_ISA_TIMER_MUX_TIMERE_INPUT_CLOCK_MASK, 184 + MESON_ISA_TIMER_MUX_TIMERE_INPUT_CLOCK_1US); 185 + writel(val, timer_base + MESON_ISA_TIMER_MUX); 186 + 187 + sched_clock_register(meson6_timer_sched_read, 32, USEC_PER_SEC); 188 + clocksource_mmio_init(timer_base + MESON_ISA_TIMERE, node->name, 189 + 1000 * 1000, 300, 32, clocksource_mmio_readl_up); 190 + 191 + /* Timer A base 1us */ 192 + val &= ~MESON_ISA_TIMER_MUX_TIMERA_INPUT_CLOCK_MASK; 193 + val |= FIELD_PREP(MESON_ISA_TIMER_MUX_TIMERA_INPUT_CLOCK_MASK, 194 + MESON_ISA_TIMER_MUX_TIMERABCD_INPUT_CLOCK_1US); 195 + writel(val, timer_base + MESON_ISA_TIMER_MUX); 196 + 197 + /* Stop the timer A */ 198 + meson6_clkevt_time_stop(); 199 + 200 + ret = setup_irq(irq, &meson6_timer_irq); 201 + if (ret) { 202 + pr_warn("failed to setup irq %d\n", irq); 203 + return ret; 204 + } 205 + 206 + meson6_clockevent.cpumask = cpu_possible_mask; 207 + meson6_clockevent.irq = irq; 208 + 209 + clockevents_config_and_register(&meson6_clockevent, USEC_PER_SEC, 210 + 1, 0xfffe); 211 + 212 + #ifdef CONFIG_ARM 213 + /* Also use MESON_ISA_TIMERE for delays */ 214 + register_current_timer_delay(&meson6_delay_timer); 215 + #endif 216 + 217 + return 0; 218 + } 219 + TIMER_OF_DECLARE(meson6, "amlogic,meson6-timer", 220 + meson6_timer_init);
+195
drivers/clocksource/timer-rda.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 2 + /* 3 + * RDA8810PL SoC timer driver 4 + * 5 + * Copyright RDA Microelectronics Company Limited 6 + * Copyright (c) 2017 Andreas Färber 7 + * Copyright (c) 2018 Manivannan Sadhasivam 8 + * 9 + * RDA8810PL has two independent timers: OSTIMER (56 bit) and HWTIMER (64 bit). 10 + * Each timer provides optional interrupt support. In this driver, OSTIMER is 11 + * used for clockevents and HWTIMER is used for clocksource. 12 + */ 13 + 14 + #include <linux/init.h> 15 + #include <linux/interrupt.h> 16 + 17 + #include "timer-of.h" 18 + 19 + #define RDA_OSTIMER_LOADVAL_L 0x000 20 + #define RDA_OSTIMER_CTRL 0x004 21 + #define RDA_HWTIMER_LOCKVAL_L 0x024 22 + #define RDA_HWTIMER_LOCKVAL_H 0x028 23 + #define RDA_TIMER_IRQ_MASK_SET 0x02c 24 + #define RDA_TIMER_IRQ_MASK_CLR 0x030 25 + #define RDA_TIMER_IRQ_CLR 0x034 26 + 27 + #define RDA_OSTIMER_CTRL_ENABLE BIT(24) 28 + #define RDA_OSTIMER_CTRL_REPEAT BIT(28) 29 + #define RDA_OSTIMER_CTRL_LOAD BIT(30) 30 + 31 + #define RDA_TIMER_IRQ_MASK_OSTIMER BIT(0) 32 + 33 + #define RDA_TIMER_IRQ_CLR_OSTIMER BIT(0) 34 + 35 + static int rda_ostimer_start(void __iomem *base, bool periodic, u64 cycles) 36 + { 37 + u32 ctrl, load_l; 38 + 39 + load_l = (u32)cycles; 40 + ctrl = ((cycles >> 32) & 0xffffff); 41 + ctrl |= RDA_OSTIMER_CTRL_LOAD | RDA_OSTIMER_CTRL_ENABLE; 42 + if (periodic) 43 + ctrl |= RDA_OSTIMER_CTRL_REPEAT; 44 + 45 + /* Enable ostimer interrupt first */ 46 + writel_relaxed(RDA_TIMER_IRQ_MASK_OSTIMER, 47 + base + RDA_TIMER_IRQ_MASK_SET); 48 + 49 + /* Write low 32 bits first, high 24 bits are with ctrl */ 50 + writel_relaxed(load_l, base + RDA_OSTIMER_LOADVAL_L); 51 + writel_relaxed(ctrl, base + RDA_OSTIMER_CTRL); 52 + 53 + return 0; 54 + } 55 + 56 + static int rda_ostimer_stop(void __iomem *base) 57 + { 58 + /* Disable ostimer interrupt first */ 59 + writel_relaxed(RDA_TIMER_IRQ_MASK_OSTIMER, 60 + base + RDA_TIMER_IRQ_MASK_CLR); 61 + 62 + writel_relaxed(0, base + RDA_OSTIMER_CTRL); 63 + 64 + return 0; 65 + } 66 + 67 + static int rda_ostimer_set_state_shutdown(struct clock_event_device *evt) 68 + { 69 + struct timer_of *to = to_timer_of(evt); 70 + 71 + rda_ostimer_stop(timer_of_base(to)); 72 + 73 + return 0; 74 + } 75 + 76 + static int rda_ostimer_set_state_oneshot(struct clock_event_device *evt) 77 + { 78 + struct timer_of *to = to_timer_of(evt); 79 + 80 + rda_ostimer_stop(timer_of_base(to)); 81 + 82 + return 0; 83 + } 84 + 85 + static int rda_ostimer_set_state_periodic(struct clock_event_device *evt) 86 + { 87 + struct timer_of *to = to_timer_of(evt); 88 + unsigned long cycles_per_jiffy; 89 + 90 + rda_ostimer_stop(timer_of_base(to)); 91 + 92 + cycles_per_jiffy = ((unsigned long long)NSEC_PER_SEC / HZ * 93 + evt->mult) >> evt->shift; 94 + rda_ostimer_start(timer_of_base(to), true, cycles_per_jiffy); 95 + 96 + return 0; 97 + } 98 + 99 + static int rda_ostimer_tick_resume(struct clock_event_device *evt) 100 + { 101 + return 0; 102 + } 103 + 104 + static int rda_ostimer_set_next_event(unsigned long evt, 105 + struct clock_event_device *ev) 106 + { 107 + struct timer_of *to = to_timer_of(ev); 108 + 109 + rda_ostimer_start(timer_of_base(to), false, evt); 110 + 111 + return 0; 112 + } 113 + 114 + static irqreturn_t rda_ostimer_interrupt(int irq, void *dev_id) 115 + { 116 + struct clock_event_device *evt = dev_id; 117 + struct timer_of *to = to_timer_of(evt); 118 + 119 + /* clear timer int */ 120 + writel_relaxed(RDA_TIMER_IRQ_CLR_OSTIMER, 121 + timer_of_base(to) + RDA_TIMER_IRQ_CLR); 122 + 123 + if (evt->event_handler) 124 + evt->event_handler(evt); 125 + 126 + return IRQ_HANDLED; 127 + } 128 + 129 + static struct timer_of rda_ostimer_of = { 130 + .flags = TIMER_OF_IRQ | TIMER_OF_BASE, 131 + 132 + .clkevt = { 133 + .name = "rda-ostimer", 134 + .rating = 250, 135 + .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT | 136 + CLOCK_EVT_FEAT_DYNIRQ, 137 + .set_state_shutdown = rda_ostimer_set_state_shutdown, 138 + .set_state_oneshot = rda_ostimer_set_state_oneshot, 139 + .set_state_periodic = rda_ostimer_set_state_periodic, 140 + .tick_resume = rda_ostimer_tick_resume, 141 + .set_next_event = rda_ostimer_set_next_event, 142 + }, 143 + 144 + .of_base = { 145 + .name = "rda-timer", 146 + .index = 0, 147 + }, 148 + 149 + .of_irq = { 150 + .name = "ostimer", 151 + .handler = rda_ostimer_interrupt, 152 + .flags = IRQF_TIMER, 153 + }, 154 + }; 155 + 156 + static u64 rda_hwtimer_read(struct clocksource *cs) 157 + { 158 + void __iomem *base = timer_of_base(&rda_ostimer_of); 159 + u32 lo, hi; 160 + 161 + /* Always read low 32 bits first */ 162 + do { 163 + lo = readl_relaxed(base + RDA_HWTIMER_LOCKVAL_L); 164 + hi = readl_relaxed(base + RDA_HWTIMER_LOCKVAL_H); 165 + } while (hi != readl_relaxed(base + RDA_HWTIMER_LOCKVAL_H)); 166 + 167 + return ((u64)hi << 32) | lo; 168 + } 169 + 170 + static struct clocksource rda_hwtimer_clocksource = { 171 + .name = "rda-timer", 172 + .rating = 400, 173 + .read = rda_hwtimer_read, 174 + .mask = CLOCKSOURCE_MASK(64), 175 + .flags = CLOCK_SOURCE_IS_CONTINUOUS, 176 + }; 177 + 178 + static int __init rda_timer_init(struct device_node *np) 179 + { 180 + unsigned long rate = 2000000; 181 + int ret; 182 + 183 + ret = timer_of_init(np, &rda_ostimer_of); 184 + if (ret) 185 + return ret; 186 + 187 + clocksource_register_hz(&rda_hwtimer_clocksource, rate); 188 + 189 + clockevents_config_and_register(&rda_ostimer_of.clkevt, rate, 190 + 0x2, UINT_MAX); 191 + 192 + return 0; 193 + } 194 + 195 + TIMER_OF_DECLARE(rda8810pl, "rda,8810pl-timer", rda_timer_init);
-1
drivers/clocksource/timer-ti-dm.c
··· 991 991 }, 992 992 }; 993 993 994 - early_platform_init("earlytimer", &omap_dm_timer_driver); 995 994 module_platform_driver(omap_dm_timer_driver); 996 995 997 996 MODULE_DESCRIPTION("OMAP Dual-Mode Timer Driver");
+1 -1
drivers/clocksource/timer-vt8500.c
··· 145 145 146 146 ret = clocksource_register_hz(&clocksource, VT8500_TIMER_HZ); 147 147 if (ret) { 148 - pr_err("%s: vt8500_timer_init: clocksource_register failed for %s\n", 148 + pr_err("%s: clocksource_register failed for %s\n", 149 149 __func__, clocksource.name); 150 150 return ret; 151 151 }
+1 -4
include/linux/hrtimer.h
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 - * include/linux/hrtimer.h 3 - * 4 3 * hrtimers - High-resolution kernel timers 5 4 * 6 5 * Copyright(C) 2005, Thomas Gleixner <tglx@linutronix.de> ··· 8 9 * data type definitions, declarations, prototypes 9 10 * 10 11 * Started by: Thomas Gleixner and Ingo Molnar 11 - * 12 - * For licencing details see kernel-base/COPYING 13 12 */ 14 13 #ifndef _LINUX_HRTIMER_H 15 14 #define _LINUX_HRTIMER_H
+1 -4
kernel/time/alarmtimer.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * Alarmtimer interface 3 4 * ··· 11 10 * Copyright (C) 2010 IBM Corperation 12 11 * 13 12 * Author: John Stultz <john.stultz@linaro.org> 14 - * 15 - * This program is free software; you can redistribute it and/or modify 16 - * it under the terms of the GNU General Public License version 2 as 17 - * published by the Free Software Foundation. 18 13 */ 19 14 #include <linux/time.h> 20 15 #include <linux/hrtimer.h>
+4 -14
kernel/time/clockevents.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 - * linux/kernel/time/clockevents.c 3 - * 4 3 * This file contains functions which manage clock event devices. 5 4 * 6 5 * Copyright(C) 2005-2006, Thomas Gleixner <tglx@linutronix.de> 7 6 * Copyright(C) 2005-2007, Red Hat, Inc., Ingo Molnar 8 7 * Copyright(C) 2006-2007, Timesys Corp., Thomas Gleixner 9 - * 10 - * This code is licenced under the GPL version 2. For details see 11 - * kernel-base/COPYING. 12 8 */ 13 9 14 10 #include <linux/clockchips.h> ··· 35 39 u64 clc = (u64) latch << evt->shift; 36 40 u64 rnd; 37 41 38 - if (unlikely(!evt->mult)) { 42 + if (WARN_ON(!evt->mult)) 39 43 evt->mult = 1; 40 - WARN_ON(1); 41 - } 42 44 rnd = (u64) evt->mult - 1; 43 45 44 46 /* ··· 158 164 * on it, so fix it up and emit a warning: 159 165 */ 160 166 if (clockevent_state_oneshot(dev)) { 161 - if (unlikely(!dev->mult)) { 167 + if (WARN_ON(!dev->mult)) 162 168 dev->mult = 1; 163 - WARN_ON(1); 164 - } 165 169 } 166 170 } 167 171 } ··· 307 315 int64_t delta; 308 316 int rc; 309 317 310 - if (unlikely(expires < 0)) { 311 - WARN_ON_ONCE(1); 318 + if (WARN_ON_ONCE(expires < 0)) 312 319 return -ETIME; 313 - } 314 320 315 321 dev->next_event = expires; 316 322
+1 -19
kernel/time/clocksource.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /* 2 - * linux/kernel/time/clocksource.c 3 - * 4 3 * This file contains the functions which manage clocksource drivers. 5 4 * 6 5 * Copyright (C) 2004, 2005 IBM, John Stultz (johnstul@us.ibm.com) 7 - * 8 - * This program is free software; you can redistribute it and/or modify 9 - * it under the terms of the GNU General Public License as published by 10 - * the Free Software Foundation; either version 2 of the License, or 11 - * (at your option) any later version. 12 - * 13 - * This program is distributed in the hope that it will be useful, 14 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 - * GNU General Public License for more details. 17 - * 18 - * You should have received a copy of the GNU General Public License 19 - * along with this program; if not, write to the Free Software 20 - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 21 - * 22 - * TODO WishList: 23 - * o Allow clocksource drivers to be unregistered 24 6 */ 25 7 26 8 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+5 -14
kernel/time/hrtimer.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 - * linux/kernel/hrtimer.c 3 - * 4 3 * Copyright(C) 2005-2006, Thomas Gleixner <tglx@linutronix.de> 5 4 * Copyright(C) 2005-2007, Red Hat, Inc., Ingo Molnar 6 5 * Copyright(C) 2006-2007 Timesys Corp., Thomas Gleixner 7 6 * 8 7 * High-resolution kernel timers 9 8 * 10 - * In contrast to the low-resolution timeout API implemented in 11 - * kernel/timer.c, hrtimers provide finer resolution and accuracy 12 - * depending on system configuration and capabilities. 13 - * 14 - * These timers are currently used for: 15 - * - itimers 16 - * - POSIX timers 17 - * - nanosleep 18 - * - precise in-kernel timing 9 + * In contrast to the low-resolution timeout API, aka timer wheel, 10 + * hrtimers provide finer resolution and accuracy depending on system 11 + * configuration and capabilities. 19 12 * 20 13 * Started by: Thomas Gleixner and Ingo Molnar 21 14 * 22 15 * Credits: 23 - * based on kernel/timer.c 16 + * Based on the original timer wheel code 24 17 * 25 18 * Help, testing, suggestions, bugfixes, improvements were 26 19 * provided by: 27 20 * 28 21 * George Anzinger, Andrew Morton, Steven Rostedt, Roman Zippel 29 22 * et. al. 30 - * 31 - * For licencing details see kernel-base/COPYING 32 23 */ 33 24 34 25 #include <linux/cpu.h>
-2
kernel/time/itimer.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 /* 3 - * linux/kernel/itimer.c 4 - * 5 3 * Copyright (C) 1992 Darren Senn 6 4 */ 7 5
+6 -22
kernel/time/jiffies.c
··· 1 - /*********************************************************************** 2 - * linux/kernel/time/jiffies.c 3 - * 4 - * This file contains the jiffies based clocksource. 5 - * 6 - * Copyright (C) 2004, 2005 IBM, John Stultz (johnstul@us.ibm.com) 7 - * 8 - * This program is free software; you can redistribute it and/or modify 9 - * it under the terms of the GNU General Public License as published by 10 - * the Free Software Foundation; either version 2 of the License, or 11 - * (at your option) any later version. 12 - * 13 - * This program is distributed in the hope that it will be useful, 14 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 - * GNU General Public License for more details. 17 - * 18 - * You should have received a copy of the GNU General Public License 19 - * along with this program; if not, write to the Free Software 20 - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 21 - * 22 - ************************************************************************/ 1 + // SPDX-License-Identifier: GPL-2.0+ 2 + /* 3 + * This file contains the jiffies based clocksource. 4 + * 5 + * Copyright (C) 2004, 2005 IBM, John Stultz (johnstul@us.ibm.com) 6 + */ 23 7 #include <linux/clocksource.h> 24 8 #include <linux/jiffies.h> 25 9 #include <linux/module.h>
-1
kernel/time/ntp.c
··· 17 17 #include <linux/mm.h> 18 18 #include <linux/module.h> 19 19 #include <linux/rtc.h> 20 - #include <linux/math64.h> 21 20 22 21 #include "ntp_internal.h" 23 22 #include "timekeeping_internal.h"
+2 -15
kernel/time/posix-clock.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /* 2 - * posix-clock.c - support for dynamic clock devices 3 + * Support for dynamic clock devices 3 4 * 4 5 * Copyright (C) 2010 OMICRON electronics GmbH 5 - * 6 - * This program is free software; you can redistribute it and/or modify 7 - * it under the terms of the GNU General Public License as published by 8 - * the Free Software Foundation; either version 2 of the License, or 9 - * (at your option) any later version. 10 - * 11 - * This program is distributed in the hope that it will be useful, 12 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 - * GNU General Public License for more details. 15 - * 16 - * You should have received a copy of the GNU General Public License 17 - * along with this program; if not, write to the Free Software 18 - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 6 */ 20 7 #include <linux/device.h> 21 8 #include <linux/export.h>
+1 -4
kernel/time/posix-stubs.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * Dummy stubs used when CONFIG_POSIX_TIMERS=n 3 4 * 4 5 * Created by: Nicolas Pitre, July 2016 5 6 * Copyright: (C) 2016 Linaro Limited 6 - * 7 - * This program is free software; you can redistribute it and/or modify 8 - * it under the terms of the GNU General Public License version 2 as 9 - * published by the Free Software Foundation. 10 7 */ 11 8 12 9 #include <linux/linkage.h>
+2 -23
kernel/time/posix-timers.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /* 2 - * linux/kernel/posix-timers.c 3 - * 4 - * 5 3 * 2002-10-15 Posix Clocks & timers 6 4 * by George Anzinger george@mvista.com 7 - * 8 5 * Copyright (C) 2002 2003 by MontaVista Software. 9 6 * 10 7 * 2004-06-01 Fix CLOCK_REALTIME clock/timer TIMER_ABSTIME bug. 11 8 * Copyright (C) 2004 Boris Hu 12 9 * 13 - * This program is free software; you can redistribute it and/or modify 14 - * it under the terms of the GNU General Public License as published by 15 - * the Free Software Foundation; either version 2 of the License, or (at 16 - * your option) any later version. 17 - * 18 - * This program is distributed in the hope that it will be useful, but 19 - * WITHOUT ANY WARRANTY; without even the implied warranty of 20 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 - * General Public License for more details. 22 - 23 - * You should have received a copy of the GNU General Public License 24 - * along with this program; if not, write to the Free Software 25 - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 26 - * 27 - * MontaVista Software | 1237 East Arques Avenue | Sunnyvale | CA 94085 | USA 28 - */ 29 - 30 - /* These are all the functions necessary to implement 31 - * POSIX clocks & timers 10 + * These are all the functions necessary to implement POSIX clocks & timers 32 11 */ 33 12 #include <linux/mm.h> 34 13 #include <linux/interrupt.h>
+3 -6
kernel/time/sched_clock.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 - * sched_clock.c: Generic sched_clock() support, to extend low level 3 - * hardware time counters to full 64-bit ns values. 4 - * 5 - * This program is free software; you can redistribute it and/or modify 6 - * it under the terms of the GNU General Public License version 2 as 7 - * published by the Free Software Foundation. 3 + * Generic sched_clock() support, to extend low level hardware time 4 + * counters to full 64-bit ns values. 8 5 */ 9 6 #include <linux/clocksource.h> 10 7 #include <linux/init.h>
+1 -9
kernel/time/test_udelay.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * udelay() test kernel module 3 4 * ··· 8 7 * Specifying usecs of 0 or negative values will run multiples tests. 9 8 * 10 9 * Copyright (C) 2014 Google, Inc. 11 - * 12 - * This software is licensed under the terms of the GNU General Public 13 - * License version 2, as published by the Free Software Foundation, and 14 - * may be copied, distributed, and modified under those terms. 15 - * 16 - * This program is distributed in the hope that it will be useful, 17 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 - * GNU General Public License for more details. 20 10 */ 21 11 22 12 #include <linux/debugfs.h>
+1 -3
kernel/time/tick-broadcast-hrtimer.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 /* 3 - * linux/kernel/time/tick-broadcast-hrtimer.c 4 - * This file emulates a local clock event device 5 - * via a pseudo clock device. 3 + * Emulate a local clock event device via a pseudo clock device. 6 4 */ 7 5 #include <linux/cpu.h> 8 6 #include <linux/err.h>
+1 -5
kernel/time/tick-broadcast.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 - * linux/kernel/time/tick-broadcast.c 3 - * 4 3 * This file contains functions which emulate a local clock-event 5 4 * device via a broadcast event source. 6 5 * 7 6 * Copyright(C) 2005-2006, Thomas Gleixner <tglx@linutronix.de> 8 7 * Copyright(C) 2005-2007, Red Hat, Inc., Ingo Molnar 9 8 * Copyright(C) 2006-2007, Timesys Corp., Thomas Gleixner 10 - * 11 - * This code is licenced under the GPL version 2. For details see 12 - * kernel-base/COPYING. 13 9 */ 14 10 #include <linux/cpu.h> 15 11 #include <linux/err.h>
+1 -5
kernel/time/tick-common.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 - * linux/kernel/time/tick-common.c 3 - * 4 3 * This file contains the base functions to manage periodic tick 5 4 * related events. 6 5 * 7 6 * Copyright(C) 2005-2006, Thomas Gleixner <tglx@linutronix.de> 8 7 * Copyright(C) 2005-2007, Red Hat, Inc., Ingo Molnar 9 8 * Copyright(C) 2006-2007, Timesys Corp., Thomas Gleixner 10 - * 11 - * This code is licenced under the GPL version 2. For details see 12 - * kernel-base/COPYING. 13 9 */ 14 10 #include <linux/cpu.h> 15 11 #include <linux/err.h>
+1 -5
kernel/time/tick-oneshot.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 - * linux/kernel/time/tick-oneshot.c 3 - * 4 3 * This file contains functions which manage high resolution tick 5 4 * related events. 6 5 * 7 6 * Copyright(C) 2005-2006, Thomas Gleixner <tglx@linutronix.de> 8 7 * Copyright(C) 2005-2007, Red Hat, Inc., Ingo Molnar 9 8 * Copyright(C) 2006-2007, Timesys Corp., Thomas Gleixner 10 - * 11 - * This code is licenced under the GPL version 2. For details see 12 - * kernel-base/COPYING. 13 9 */ 14 10 #include <linux/cpu.h> 15 11 #include <linux/err.h>
+1 -4
kernel/time/tick-sched.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 - * linux/kernel/time/tick-sched.c 3 - * 4 3 * Copyright(C) 2005-2006, Thomas Gleixner <tglx@linutronix.de> 5 4 * Copyright(C) 2005-2007, Red Hat, Inc., Ingo Molnar 6 5 * Copyright(C) 2006-2007 Timesys Corp., Thomas Gleixner ··· 7 8 * No idle tick implementation for low and high resolution timers 8 9 * 9 10 * Started by: Thomas Gleixner and Ingo Molnar 10 - * 11 - * Distribute under GPLv2. 12 11 */ 13 12 #include <linux/cpu.h> 14 13 #include <linux/err.h>
+5 -8
kernel/time/time.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 - * linux/kernel/time.c 3 - * 4 3 * Copyright (C) 1991, 1992 Linus Torvalds 5 4 * 6 - * This file contains the interface functions for the various 7 - * time related system calls: time, stime, gettimeofday, settimeofday, 8 - * adjtime 9 - */ 10 - /* 11 - * Modification history kernel/time.c 5 + * This file contains the interface functions for the various time related 6 + * system calls: time, stime, gettimeofday, settimeofday, adjtime 7 + * 8 + * Modification history: 12 9 * 13 10 * 1993-09-02 Philip Gladstone 14 11 * Created file with time related functions from sched/core.c and adjtimex()
+2
kernel/time/timeconst.bc
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + 1 3 scale=0 2 4 3 5 define gcd(a,b) {
+1
kernel/time/timeconv.c
··· 1 + // SPDX-License-Identifier: LGPL-2.0+ 1 2 /* 2 3 * Copyright (C) 1993, 1994, 1995, 1996, 1997 Free Software Foundation, Inc. 3 4 * This file is part of the GNU C Library.
+2 -15
kernel/time/timecounter.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /* 2 - * linux/kernel/time/timecounter.c 3 - * 4 - * based on code that migrated away from 5 - * linux/kernel/time/clocksource.c 6 - * 7 - * This program is free software; you can redistribute it and/or modify 8 - * it under the terms of the GNU General Public License as published by 9 - * the Free Software Foundation; either version 2 of the License, or 10 - * (at your option) any later version. 11 - * 12 - * This program is distributed in the hope that it will be useful, 13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 - * GNU General Public License for more details. 3 + * Based on clocksource code. See commit 74d23cc704d1 16 4 */ 17 - 18 5 #include <linux/export.h> 19 6 #include <linux/timecounter.h> 20 7
+6 -9
kernel/time/timekeeping.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 - * linux/kernel/time/timekeeping.c 3 - * 4 - * Kernel timekeeping code and accessor functions 5 - * 6 - * This code was moved from linux/kernel/timer.c. 7 - * Please see that file for copyright and history logs. 8 - * 3 + * Kernel timekeeping code and accessor functions. Based on code from 4 + * timer.c, moved in commit 8524070b7982. 9 5 */ 10 - 11 6 #include <linux/timekeeper_internal.h> 12 7 #include <linux/module.h> 13 8 #include <linux/interrupt.h> ··· 45 50 static struct { 46 51 seqcount_t seq; 47 52 struct timekeeper timekeeper; 48 - } tk_core ____cacheline_aligned; 53 + } tk_core ____cacheline_aligned = { 54 + .seq = SEQCNT_ZERO(tk_core.seq), 55 + }; 49 56 50 57 static DEFINE_RAW_SPINLOCK(timekeeper_lock); 51 58 static struct timekeeper shadow_timekeeper;
+3 -23
kernel/time/timekeeping_debug.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /* 2 3 * debugfs file to track time spent in suspend 3 4 * 4 5 * Copyright (c) 2011, Google, Inc. 5 - * 6 - * This program is free software; you can redistribute it and/or modify 7 - * it under the terms of the GNU General Public License as published by 8 - * the Free Software Foundation; either version 2 of the License, or 9 - * (at your option) any later version. 10 - * 11 - * This program is distributed in the hope that it will be useful, but WITHOUT 12 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 14 - * more details. 15 6 */ 16 7 17 8 #include <linux/debugfs.h> ··· 19 28 20 29 static unsigned int sleep_time_bin[NUM_BINS] = {0}; 21 30 22 - static int tk_debug_show_sleep_time(struct seq_file *s, void *data) 31 + static int tk_debug_sleep_time_show(struct seq_file *s, void *data) 23 32 { 24 33 unsigned int bin; 25 34 seq_puts(s, " time (secs) count\n"); ··· 33 42 } 34 43 return 0; 35 44 } 36 - 37 - static int tk_debug_sleep_time_open(struct inode *inode, struct file *file) 38 - { 39 - return single_open(file, tk_debug_show_sleep_time, NULL); 40 - } 41 - 42 - static const struct file_operations tk_debug_sleep_time_fops = { 43 - .open = tk_debug_sleep_time_open, 44 - .read = seq_read, 45 - .llseek = seq_lseek, 46 - .release = single_release, 47 - }; 45 + DEFINE_SHOW_ATTRIBUTE(tk_debug_sleep_time); 48 46 49 47 static int __init tk_debug_sleep_time_init(void) 50 48 {
+1 -2
kernel/time/timer.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 - * linux/kernel/timer.c 3 - * 4 3 * Kernel internal timers 5 4 * 6 5 * Copyright (C) 1991, 1992 Linus Torvalds
+1 -6
kernel/time/timer_list.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 - * kernel/time/timer_list.c 3 - * 4 3 * List pending timers 5 4 * 6 5 * Copyright(C) 2006, Red Hat, Inc., Ingo Molnar 7 - * 8 - * This program is free software; you can redistribute it and/or modify 9 - * it under the terms of the GNU General Public License version 2 as 10 - * published by the Free Software Foundation. 11 6 */ 12 7 13 8 #include <linux/proc_fs.h>