Skip to content

Commit dfea848

Browse files
committed
Merge tag 'timers-core-2022-08-01' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull timer updates from Thomas Gleixner: "Timers, timekeeping and related drivers update: Core: - Make wait_event_hrtimeout() aware of RT/DL tasks New drivers: - R-Car Gen4 timer - Tegra186 timer - Mediatek MT6795 CPUXGPT timer Updates: - Rework suspend/resume handling in timer drivers so it takes inactive clocks into account. - The usual device tree compatible add ons - Small fixed and cleanups all over the place" * tag 'timers-core-2022-08-01' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (24 commits) wait: Fix __wait_event_hrtimeout for RT/DL tasks clocksource/drivers/sun5i: Remove unnecessary (void*) conversions dt-bindings: timer: allwinner,sun4i-a10-timer: Add D1 compatible dt-bindings: timer: ingenic,tcu: use absolute path to other schema clocksource/drivers/sun4i: Remove unnecessary (void*) conversions dt-bindings: timer: renesas,cmt: Fix R-Car Gen4 fall-out clocksource/drivers/tegra186: Put Kconfig option 'tristate' to 'bool' clocksource/drivers/timer-ti-dm: Make driver selection bool for TI K3 clocksource/drivers/timer-ti-dm: Add compatible for am6 SoCs clocksource/drivers/timer-ti-dm: Make timer selectable for ARCH_K3 clocksource/drivers/timer-ti-dm: Move inline functions to driver for am6 clocksource/drivers/sh_cmt: Add R-Car Gen4 support dt-bindings: timer: renesas,cmt: R-Car V3U is R-Car Gen4 dt-bindings: timer: renesas,cmt: Add r8a779f0 and generic Gen4 CMT support clocksource/drivers/timer-microchip-pit64b: Fix compilation warnings clocksource/drivers/timer-microchip-pit64b: Use mchp_pit64b_{suspend, resume} clocksource/drivers/timer-microchip-pit64b: Remove suspend/resume ops for ce thermal/drivers/rcar_gen3_thermal: Add r8a779f0 support clocksource/drivers/timer-mediatek: Implement CPUXGPT timers dt-bindings: timer: mediatek: Add CPUX System Timer and MT6795 compatible ...
2 parents 63e6053 + cceeeb6 commit dfea848

File tree

18 files changed

+898
-195
lines changed

18 files changed

+898
-195
lines changed

Documentation/devicetree/bindings/timer/allwinner,sun4i-a10-timer.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ properties:
2020
- allwinner,suniv-f1c100s-timer
2121
- items:
2222
- enum:
23+
- allwinner,sun20i-d1-timer
2324
- allwinner,sun50i-a64-timer
2425
- allwinner,sun50i-h6-timer
2526
- allwinner,sun50i-h616-timer

Documentation/devicetree/bindings/timer/ingenic,tcu.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ properties:
113113
patternProperties:
114114
"^watchdog@[a-f0-9]+$":
115115
type: object
116-
$ref: ../watchdog/watchdog.yaml#
116+
$ref: /schemas/watchdog/watchdog.yaml#
117117
properties:
118118
compatible:
119119
oneOf:
@@ -145,7 +145,7 @@ patternProperties:
145145

146146
"^pwm@[a-f0-9]+$":
147147
type: object
148-
$ref: ../pwm/pwm.yaml#
148+
$ref: /schemas/pwm/pwm.yaml#
149149
properties:
150150
compatible:
151151
oneOf:

Documentation/devicetree/bindings/timer/mediatek,mtk-timer.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
MediaTek Timers
22
---------------
33

4-
MediaTek SoCs have two different timers on different platforms,
4+
MediaTek SoCs have different timers on different platforms,
5+
- CPUX (ARM/ARM64 System Timer)
56
- GPT (General Purpose Timer)
67
- SYST (System Timer)
78

@@ -29,6 +30,9 @@ Required properties:
2930
* "mediatek,mt7629-timer" for MT7629 compatible timers (SYST)
3031
* "mediatek,mt6765-timer" for MT6765 and all above compatible timers (SYST)
3132

33+
For those SoCs that use CPUX
34+
* "mediatek,mt6795-systimer" for MT6795 compatible timers (CPUX)
35+
3236
- reg: Should contain location and length for timer register.
3337
- clocks: Should contain system clock.
3438

Documentation/devicetree/bindings/timer/renesas,cmt.yaml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ properties:
8080
- renesas,r8a77980-cmt0 # 32-bit CMT0 on R-Car V3H
8181
- renesas,r8a77990-cmt0 # 32-bit CMT0 on R-Car E3
8282
- renesas,r8a77995-cmt0 # 32-bit CMT0 on R-Car D3
83-
- renesas,r8a779a0-cmt0 # 32-bit CMT0 on R-Car V3U
8483
- const: renesas,rcar-gen3-cmt0 # 32-bit CMT0 on R-Car Gen3 and RZ/G2
8584

8685
- items:
@@ -97,9 +96,20 @@ properties:
9796
- renesas,r8a77980-cmt1 # 48-bit CMT on R-Car V3H
9897
- renesas,r8a77990-cmt1 # 48-bit CMT on R-Car E3
9998
- renesas,r8a77995-cmt1 # 48-bit CMT on R-Car D3
100-
- renesas,r8a779a0-cmt1 # 48-bit CMT on R-Car V3U
10199
- const: renesas,rcar-gen3-cmt1 # 48-bit CMT on R-Car Gen3 and RZ/G2
102100

101+
- items:
102+
- enum:
103+
- renesas,r8a779a0-cmt0 # 32-bit CMT0 on R-Car V3U
104+
- renesas,r8a779f0-cmt0 # 32-bit CMT0 on R-Car S4-8
105+
- const: renesas,rcar-gen4-cmt0 # 32-bit CMT0 on R-Car Gen4
106+
107+
- items:
108+
- enum:
109+
- renesas,r8a779a0-cmt1 # 48-bit CMT on R-Car V3U
110+
- renesas,r8a779f0-cmt1 # 48-bit CMT on R-Car S4-8
111+
- const: renesas,rcar-gen4-cmt1 # 48-bit CMT on R-Car Gen4
112+
103113
reg:
104114
maxItems: 1
105115

@@ -135,6 +145,7 @@ allOf:
135145
enum:
136146
- renesas,rcar-gen2-cmt0
137147
- renesas,rcar-gen3-cmt0
148+
- renesas,rcar-gen4-cmt0
138149
then:
139150
properties:
140151
interrupts:
@@ -148,6 +159,7 @@ allOf:
148159
enum:
149160
- renesas,rcar-gen2-cmt1
150161
- renesas,rcar-gen3-cmt1
162+
- renesas,rcar-gen4-cmt1
151163
then:
152164
properties:
153165
interrupts:
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
2+
# Copyright 2022 Linaro Ltd.
3+
%YAML 1.2
4+
---
5+
$id: "http://devicetree.org/schemas/timer/st,nomadik-mtu.yaml#"
6+
$schema: "http://devicetree.org/meta-schemas/core.yaml#"
7+
8+
title: ST Microelectronics Nomadik Multi-Timer Unit MTU Timer
9+
10+
maintainers:
11+
- Linus Walleij <[email protected]>
12+
13+
description: This timer is found in the ST Microelectronics Nomadik
14+
SoCs STn8800, STn8810 and STn8815 as well as in ST-Ericsson DB8500.
15+
16+
properties:
17+
compatible:
18+
items:
19+
- const: st,nomadik-mtu
20+
21+
reg:
22+
maxItems: 1
23+
24+
interrupts:
25+
maxItems: 1
26+
27+
clocks:
28+
description: The first clock named TIMCLK clocks the actual timers and
29+
the second clock clocks the digital interface to the interconnect.
30+
maxItems: 2
31+
32+
clock-names:
33+
items:
34+
- const: timclk
35+
- const: apb_pclk
36+
37+
required:
38+
- compatible
39+
- reg
40+
- interrupts
41+
- clocks
42+
- clock-names
43+
44+
additionalProperties: false
45+
46+
examples:
47+
- |
48+
#include <dt-bindings/interrupt-controller/irq.h>
49+
#include <dt-bindings/interrupt-controller/arm-gic.h>
50+
#include <dt-bindings/mfd/dbx500-prcmu.h>
51+
timer@a03c6000 {
52+
compatible = "st,nomadik-mtu";
53+
reg = <0xa03c6000 0x1000>;
54+
interrupts = <GIC_SPI 4 IRQ_TYPE_LEVEL_HIGH>;
55+
56+
clocks = <&prcmu_clk PRCMU_TIMCLK>, <&prcc_pclk 6 6>;
57+
clock-names = "timclk", "apb_pclk";
58+
};

arch/arm/mach-omap2/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ config ARCH_OMAP2PLUS
105105
select MACH_OMAP_GENERIC
106106
select MEMORY
107107
select MFD_SYSCON
108+
select OMAP_DM_SYSTIMER
108109
select OMAP_DM_TIMER
109110
select OMAP_GPMC
110111
select PINCTRL
@@ -209,6 +210,7 @@ config SOC_OMAP2420
209210
bool "OMAP2420 support"
210211
depends on ARCH_OMAP2
211212
default y
213+
select OMAP_DM_SYSTIMER
212214
select OMAP_DM_TIMER
213215
select SOC_HAS_OMAP2_SDRC
214216

drivers/clocksource/Kconfig

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ config CLKEVT_I8253
2222
config I8253_LOCK
2323
bool
2424

25-
config OMAP_DM_TIMER
25+
config OMAP_DM_SYSTIMER
2626
bool
2727
select TIMER_OF
2828

@@ -56,6 +56,13 @@ config DIGICOLOR_TIMER
5656
help
5757
Enables the support for the digicolor timer driver.
5858

59+
config OMAP_DM_TIMER
60+
bool "OMAP dual-mode timer driver" if ARCH_K3 || COMPILE_TEST
61+
default y if ARCH_K3
62+
select TIMER_OF
63+
help
64+
Enables the support for the TI dual-mode timer driver.
65+
5966
config DW_APB_TIMER
6067
bool "DW APB timer driver" if COMPILE_TEST
6168
help
@@ -150,6 +157,14 @@ config TEGRA_TIMER
150157
help
151158
Enables support for the Tegra driver.
152159

160+
config TEGRA186_TIMER
161+
bool "NVIDIA Tegra186 timer driver"
162+
depends on ARCH_TEGRA || COMPILE_TEST
163+
depends on WATCHDOG && WATCHDOG_CORE
164+
help
165+
Enables support for the timers and watchdogs found on NVIDIA
166+
Tegra186 and later SoCs.
167+
153168
config VT8500_TIMER
154169
bool "VT8500 timer driver" if COMPILE_TEST
155170
depends on HAS_IOMEM
@@ -367,7 +382,7 @@ config ARM_GT_INITIAL_PRESCALER_VAL
367382
depends on ARM_GLOBAL_TIMER
368383
help
369384
When the ARM global timer initializes, its current rate is declared
370-
to the kernel and maintained forever. Should it's parent clock
385+
to the kernel and maintained forever. Should its parent clock
371386
change, the driver tries to fix the timer's internal prescaler.
372387
On some machs (i.e. Zynq) the initial prescaler value thus poses
373388
bounds about how much the parent clock is allowed to decrease or

drivers/clocksource/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ obj-$(CONFIG_CLKSRC_MMIO) += mmio.o
1818
obj-$(CONFIG_DAVINCI_TIMER) += timer-davinci.o
1919
obj-$(CONFIG_DIGICOLOR_TIMER) += timer-digicolor.o
2020
obj-$(CONFIG_OMAP_DM_TIMER) += timer-ti-dm.o
21-
obj-$(CONFIG_OMAP_DM_TIMER) += timer-ti-dm-systimer.o
21+
obj-$(CONFIG_OMAP_DM_SYSTIMER) += timer-ti-dm-systimer.o
2222
obj-$(CONFIG_DW_APB_TIMER) += dw_apb_timer.o
2323
obj-$(CONFIG_DW_APB_TIMER_OF) += dw_apb_timer_of.o
2424
obj-$(CONFIG_FTTMR010_TIMER) += timer-fttmr010.o
@@ -36,6 +36,7 @@ obj-$(CONFIG_SUN4I_TIMER) += timer-sun4i.o
3636
obj-$(CONFIG_SUN5I_HSTIMER) += timer-sun5i.o
3737
obj-$(CONFIG_MESON6_TIMER) += timer-meson6.o
3838
obj-$(CONFIG_TEGRA_TIMER) += timer-tegra.o
39+
obj-$(CONFIG_TEGRA186_TIMER) += timer-tegra186.o
3940
obj-$(CONFIG_VT8500_TIMER) += timer-vt8500.o
4041
obj-$(CONFIG_NSPIRE_TIMER) += timer-zevio.o
4142
obj-$(CONFIG_BCM_KONA_TIMER) += bcm_kona_timer.o

drivers/clocksource/sh_cmt.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,14 @@ static const struct of_device_id sh_cmt_of_table[] __maybe_unused = {
981981
.compatible = "renesas,rcar-gen3-cmt1",
982982
.data = &sh_cmt_info[SH_CMT1_RCAR_GEN2]
983983
},
984+
{
985+
.compatible = "renesas,rcar-gen4-cmt0",
986+
.data = &sh_cmt_info[SH_CMT0_RCAR_GEN2]
987+
},
988+
{
989+
.compatible = "renesas,rcar-gen4-cmt1",
990+
.data = &sh_cmt_info[SH_CMT1_RCAR_GEN2]
991+
},
984992
{ }
985993
};
986994
MODULE_DEVICE_TABLE(of, sh_cmt_of_table);

drivers/clocksource/timer-mediatek.c

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,19 @@
2222

2323
#define TIMER_SYNC_TICKS (3)
2424

25+
/* cpux mcusys wrapper */
26+
#define CPUX_CON_REG 0x0
27+
#define CPUX_IDX_REG 0x4
28+
29+
/* cpux */
30+
#define CPUX_IDX_GLOBAL_CTRL 0x0
31+
#define CPUX_ENABLE BIT(0)
32+
#define CPUX_CLK_DIV_MASK GENMASK(10, 8)
33+
#define CPUX_CLK_DIV1 BIT(8)
34+
#define CPUX_CLK_DIV2 BIT(9)
35+
#define CPUX_CLK_DIV4 BIT(10)
36+
#define CPUX_IDX_GLOBAL_IRQ 0x30
37+
2538
/* gpt */
2639
#define GPT_IRQ_EN_REG 0x00
2740
#define GPT_IRQ_ENABLE(val) BIT((val) - 1)
@@ -72,6 +85,52 @@
7285

7386
static void __iomem *gpt_sched_reg __read_mostly;
7487

88+
static u32 mtk_cpux_readl(u32 reg_idx, struct timer_of *to)
89+
{
90+
writel(reg_idx, timer_of_base(to) + CPUX_IDX_REG);
91+
return readl(timer_of_base(to) + CPUX_CON_REG);
92+
}
93+
94+
static void mtk_cpux_writel(u32 val, u32 reg_idx, struct timer_of *to)
95+
{
96+
writel(reg_idx, timer_of_base(to) + CPUX_IDX_REG);
97+
writel(val, timer_of_base(to) + CPUX_CON_REG);
98+
}
99+
100+
static void mtk_cpux_set_irq(struct timer_of *to, bool enable)
101+
{
102+
const unsigned long *irq_mask = cpumask_bits(cpu_possible_mask);
103+
u32 val;
104+
105+
val = mtk_cpux_readl(CPUX_IDX_GLOBAL_IRQ, to);
106+
107+
if (enable)
108+
val |= *irq_mask;
109+
else
110+
val &= ~(*irq_mask);
111+
112+
mtk_cpux_writel(val, CPUX_IDX_GLOBAL_IRQ, to);
113+
}
114+
115+
static int mtk_cpux_clkevt_shutdown(struct clock_event_device *clkevt)
116+
{
117+
/* Clear any irq */
118+
mtk_cpux_set_irq(to_timer_of(clkevt), false);
119+
120+
/*
121+
* Disabling CPUXGPT timer will crash the platform, especially
122+
* if Trusted Firmware is using it (usually, for sleep states),
123+
* so we only mask the IRQ and call it a day.
124+
*/
125+
return 0;
126+
}
127+
128+
static int mtk_cpux_clkevt_resume(struct clock_event_device *clkevt)
129+
{
130+
mtk_cpux_set_irq(to_timer_of(clkevt), true);
131+
return 0;
132+
}
133+
75134
static void mtk_syst_ack_irq(struct timer_of *to)
76135
{
77136
/* Clear and disable interrupt */
@@ -281,6 +340,60 @@ static struct timer_of to = {
281340
},
282341
};
283342

343+
static int __init mtk_cpux_init(struct device_node *node)
344+
{
345+
static struct timer_of to_cpux;
346+
u32 freq, val;
347+
int ret;
348+
349+
/*
350+
* There are per-cpu interrupts for the CPUX General Purpose Timer
351+
* but since this timer feeds the AArch64 System Timer we can rely
352+
* on the CPU timer PPIs as well, so we don't declare TIMER_OF_IRQ.
353+
*/
354+
to_cpux.flags = TIMER_OF_BASE | TIMER_OF_CLOCK;
355+
to_cpux.clkevt.name = "mtk-cpuxgpt";
356+
to_cpux.clkevt.rating = 10;
357+
to_cpux.clkevt.cpumask = cpu_possible_mask;
358+
to_cpux.clkevt.set_state_shutdown = mtk_cpux_clkevt_shutdown;
359+
to_cpux.clkevt.tick_resume = mtk_cpux_clkevt_resume;
360+
361+
/* If this fails, bad things are about to happen... */
362+
ret = timer_of_init(node, &to_cpux);
363+
if (ret) {
364+
WARN(1, "Cannot start CPUX timers.\n");
365+
return ret;
366+
}
367+
368+
/*
369+
* Check if we're given a clock with the right frequency for this
370+
* timer, otherwise warn but keep going with the setup anyway, as
371+
* that makes it possible to still boot the kernel, even though
372+
* it may not work correctly (random lockups, etc).
373+
* The reason behind this is that having an early UART may not be
374+
* possible for everyone and this gives a chance to retrieve kmsg
375+
* for eventual debugging even on consumer devices.
376+
*/
377+
freq = timer_of_rate(&to_cpux);
378+
if (freq > 13000000)
379+
WARN(1, "Requested unsupported timer frequency %u\n", freq);
380+
381+
/* Clock input is 26MHz, set DIV2 to achieve 13MHz clock */
382+
val = mtk_cpux_readl(CPUX_IDX_GLOBAL_CTRL, &to_cpux);
383+
val &= ~CPUX_CLK_DIV_MASK;
384+
val |= CPUX_CLK_DIV2;
385+
mtk_cpux_writel(val, CPUX_IDX_GLOBAL_CTRL, &to_cpux);
386+
387+
/* Enable all CPUXGPT timers */
388+
val = mtk_cpux_readl(CPUX_IDX_GLOBAL_CTRL, &to_cpux);
389+
mtk_cpux_writel(val | CPUX_ENABLE, CPUX_IDX_GLOBAL_CTRL, &to_cpux);
390+
391+
clockevents_config_and_register(&to_cpux.clkevt, timer_of_rate(&to_cpux),
392+
TIMER_SYNC_TICKS, 0xffffffff);
393+
394+
return 0;
395+
}
396+
284397
static int __init mtk_syst_init(struct device_node *node)
285398
{
286399
int ret;
@@ -339,3 +452,4 @@ static int __init mtk_gpt_init(struct device_node *node)
339452
}
340453
TIMER_OF_DECLARE(mtk_mt6577, "mediatek,mt6577-timer", mtk_gpt_init);
341454
TIMER_OF_DECLARE(mtk_mt6765, "mediatek,mt6765-timer", mtk_syst_init);
455+
TIMER_OF_DECLARE(mtk_mt6795, "mediatek,mt6795-systimer", mtk_cpux_init);

0 commit comments

Comments
 (0)