Skip to content

Commit

Permalink
Merge tag 'timers-core-2022-08-01' of git://git.kernel.org/pub/scm/li…
Browse files Browse the repository at this point in the history
…nux/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
  ...
  • Loading branch information
Linus Torvalds committed Aug 1, 2022
2 parents 63e6053 + cceeeb6 commit dfea848
Show file tree
Hide file tree
Showing 18 changed files with 898 additions and 195 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ properties:
- allwinner,suniv-f1c100s-timer
- items:
- enum:
- allwinner,sun20i-d1-timer
- allwinner,sun50i-a64-timer
- allwinner,sun50i-h6-timer
- allwinner,sun50i-h616-timer
Expand Down
4 changes: 2 additions & 2 deletions Documentation/devicetree/bindings/timer/ingenic,tcu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ properties:
patternProperties:
"^watchdog@[a-f0-9]+$":
type: object
$ref: ../watchdog/watchdog.yaml#
$ref: /schemas/watchdog/watchdog.yaml#
properties:
compatible:
oneOf:
Expand Down Expand Up @@ -145,7 +145,7 @@ patternProperties:

"^pwm@[a-f0-9]+$":
type: object
$ref: ../pwm/pwm.yaml#
$ref: /schemas/pwm/pwm.yaml#
properties:
compatible:
oneOf:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
MediaTek Timers
---------------

MediaTek SoCs have two different timers on different platforms,
MediaTek SoCs have different timers on different platforms,
- CPUX (ARM/ARM64 System Timer)
- GPT (General Purpose Timer)
- SYST (System Timer)

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

For those SoCs that use CPUX
* "mediatek,mt6795-systimer" for MT6795 compatible timers (CPUX)

- reg: Should contain location and length for timer register.
- clocks: Should contain system clock.

Expand Down
16 changes: 14 additions & 2 deletions Documentation/devicetree/bindings/timer/renesas,cmt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ properties:
- renesas,r8a77980-cmt0 # 32-bit CMT0 on R-Car V3H
- renesas,r8a77990-cmt0 # 32-bit CMT0 on R-Car E3
- renesas,r8a77995-cmt0 # 32-bit CMT0 on R-Car D3
- renesas,r8a779a0-cmt0 # 32-bit CMT0 on R-Car V3U
- const: renesas,rcar-gen3-cmt0 # 32-bit CMT0 on R-Car Gen3 and RZ/G2

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

- items:
- enum:
- renesas,r8a779a0-cmt0 # 32-bit CMT0 on R-Car V3U
- renesas,r8a779f0-cmt0 # 32-bit CMT0 on R-Car S4-8
- const: renesas,rcar-gen4-cmt0 # 32-bit CMT0 on R-Car Gen4

- items:
- enum:
- renesas,r8a779a0-cmt1 # 48-bit CMT on R-Car V3U
- renesas,r8a779f0-cmt1 # 48-bit CMT on R-Car S4-8
- const: renesas,rcar-gen4-cmt1 # 48-bit CMT on R-Car Gen4

reg:
maxItems: 1

Expand Down Expand Up @@ -135,6 +145,7 @@ allOf:
enum:
- renesas,rcar-gen2-cmt0
- renesas,rcar-gen3-cmt0
- renesas,rcar-gen4-cmt0
then:
properties:
interrupts:
Expand All @@ -148,6 +159,7 @@ allOf:
enum:
- renesas,rcar-gen2-cmt1
- renesas,rcar-gen3-cmt1
- renesas,rcar-gen4-cmt1
then:
properties:
interrupts:
Expand Down
58 changes: 58 additions & 0 deletions Documentation/devicetree/bindings/timer/st,nomadik-mtu.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
# Copyright 2022 Linaro Ltd.
%YAML 1.2
---
$id: "http://devicetree.org/schemas/timer/st,nomadik-mtu.yaml#"
$schema: "http://devicetree.org/meta-schemas/core.yaml#"

title: ST Microelectronics Nomadik Multi-Timer Unit MTU Timer

maintainers:
- Linus Walleij <linus.walleij@linaro.org>

description: This timer is found in the ST Microelectronics Nomadik
SoCs STn8800, STn8810 and STn8815 as well as in ST-Ericsson DB8500.

properties:
compatible:
items:
- const: st,nomadik-mtu

reg:
maxItems: 1

interrupts:
maxItems: 1

clocks:
description: The first clock named TIMCLK clocks the actual timers and
the second clock clocks the digital interface to the interconnect.
maxItems: 2

clock-names:
items:
- const: timclk
- const: apb_pclk

required:
- compatible
- reg
- interrupts
- clocks
- clock-names

additionalProperties: false

examples:
- |
#include <dt-bindings/interrupt-controller/irq.h>
#include <dt-bindings/interrupt-controller/arm-gic.h>
#include <dt-bindings/mfd/dbx500-prcmu.h>
timer@a03c6000 {
compatible = "st,nomadik-mtu";
reg = <0xa03c6000 0x1000>;
interrupts = <GIC_SPI 4 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&prcmu_clk PRCMU_TIMCLK>, <&prcc_pclk 6 6>;
clock-names = "timclk", "apb_pclk";
};
2 changes: 2 additions & 0 deletions arch/arm/mach-omap2/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ config ARCH_OMAP2PLUS
select MACH_OMAP_GENERIC
select MEMORY
select MFD_SYSCON
select OMAP_DM_SYSTIMER
select OMAP_DM_TIMER
select OMAP_GPMC
select PINCTRL
Expand Down Expand Up @@ -209,6 +210,7 @@ config SOC_OMAP2420
bool "OMAP2420 support"
depends on ARCH_OMAP2
default y
select OMAP_DM_SYSTIMER
select OMAP_DM_TIMER
select SOC_HAS_OMAP2_SDRC

Expand Down
19 changes: 17 additions & 2 deletions drivers/clocksource/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ config CLKEVT_I8253
config I8253_LOCK
bool

config OMAP_DM_TIMER
config OMAP_DM_SYSTIMER
bool
select TIMER_OF

Expand Down Expand Up @@ -56,6 +56,13 @@ config DIGICOLOR_TIMER
help
Enables the support for the digicolor timer driver.

config OMAP_DM_TIMER
bool "OMAP dual-mode timer driver" if ARCH_K3 || COMPILE_TEST
default y if ARCH_K3
select TIMER_OF
help
Enables the support for the TI dual-mode timer driver.

config DW_APB_TIMER
bool "DW APB timer driver" if COMPILE_TEST
help
Expand Down Expand Up @@ -150,6 +157,14 @@ config TEGRA_TIMER
help
Enables support for the Tegra driver.

config TEGRA186_TIMER
bool "NVIDIA Tegra186 timer driver"
depends on ARCH_TEGRA || COMPILE_TEST
depends on WATCHDOG && WATCHDOG_CORE
help
Enables support for the timers and watchdogs found on NVIDIA
Tegra186 and later SoCs.

config VT8500_TIMER
bool "VT8500 timer driver" if COMPILE_TEST
depends on HAS_IOMEM
Expand Down Expand Up @@ -367,7 +382,7 @@ config ARM_GT_INITIAL_PRESCALER_VAL
depends on ARM_GLOBAL_TIMER
help
When the ARM global timer initializes, its current rate is declared
to the kernel and maintained forever. Should it's parent clock
to the kernel and maintained forever. Should its parent clock
change, the driver tries to fix the timer's internal prescaler.
On some machs (i.e. Zynq) the initial prescaler value thus poses
bounds about how much the parent clock is allowed to decrease or
Expand Down
3 changes: 2 additions & 1 deletion drivers/clocksource/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ obj-$(CONFIG_CLKSRC_MMIO) += mmio.o
obj-$(CONFIG_DAVINCI_TIMER) += timer-davinci.o
obj-$(CONFIG_DIGICOLOR_TIMER) += timer-digicolor.o
obj-$(CONFIG_OMAP_DM_TIMER) += timer-ti-dm.o
obj-$(CONFIG_OMAP_DM_TIMER) += timer-ti-dm-systimer.o
obj-$(CONFIG_OMAP_DM_SYSTIMER) += timer-ti-dm-systimer.o
obj-$(CONFIG_DW_APB_TIMER) += dw_apb_timer.o
obj-$(CONFIG_DW_APB_TIMER_OF) += dw_apb_timer_of.o
obj-$(CONFIG_FTTMR010_TIMER) += timer-fttmr010.o
Expand All @@ -36,6 +36,7 @@ obj-$(CONFIG_SUN4I_TIMER) += timer-sun4i.o
obj-$(CONFIG_SUN5I_HSTIMER) += timer-sun5i.o
obj-$(CONFIG_MESON6_TIMER) += timer-meson6.o
obj-$(CONFIG_TEGRA_TIMER) += timer-tegra.o
obj-$(CONFIG_TEGRA186_TIMER) += timer-tegra186.o
obj-$(CONFIG_VT8500_TIMER) += timer-vt8500.o
obj-$(CONFIG_NSPIRE_TIMER) += timer-zevio.o
obj-$(CONFIG_BCM_KONA_TIMER) += bcm_kona_timer.o
Expand Down
8 changes: 8 additions & 0 deletions drivers/clocksource/sh_cmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,14 @@ static const struct of_device_id sh_cmt_of_table[] __maybe_unused = {
.compatible = "renesas,rcar-gen3-cmt1",
.data = &sh_cmt_info[SH_CMT1_RCAR_GEN2]
},
{
.compatible = "renesas,rcar-gen4-cmt0",
.data = &sh_cmt_info[SH_CMT0_RCAR_GEN2]
},
{
.compatible = "renesas,rcar-gen4-cmt1",
.data = &sh_cmt_info[SH_CMT1_RCAR_GEN2]
},
{ }
};
MODULE_DEVICE_TABLE(of, sh_cmt_of_table);
Expand Down
114 changes: 114 additions & 0 deletions drivers/clocksource/timer-mediatek.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@

#define TIMER_SYNC_TICKS (3)

/* cpux mcusys wrapper */
#define CPUX_CON_REG 0x0
#define CPUX_IDX_REG 0x4

/* cpux */
#define CPUX_IDX_GLOBAL_CTRL 0x0
#define CPUX_ENABLE BIT(0)
#define CPUX_CLK_DIV_MASK GENMASK(10, 8)
#define CPUX_CLK_DIV1 BIT(8)
#define CPUX_CLK_DIV2 BIT(9)
#define CPUX_CLK_DIV4 BIT(10)
#define CPUX_IDX_GLOBAL_IRQ 0x30

/* gpt */
#define GPT_IRQ_EN_REG 0x00
#define GPT_IRQ_ENABLE(val) BIT((val) - 1)
Expand Down Expand Up @@ -72,6 +85,52 @@

static void __iomem *gpt_sched_reg __read_mostly;

static u32 mtk_cpux_readl(u32 reg_idx, struct timer_of *to)
{
writel(reg_idx, timer_of_base(to) + CPUX_IDX_REG);
return readl(timer_of_base(to) + CPUX_CON_REG);
}

static void mtk_cpux_writel(u32 val, u32 reg_idx, struct timer_of *to)
{
writel(reg_idx, timer_of_base(to) + CPUX_IDX_REG);
writel(val, timer_of_base(to) + CPUX_CON_REG);
}

static void mtk_cpux_set_irq(struct timer_of *to, bool enable)
{
const unsigned long *irq_mask = cpumask_bits(cpu_possible_mask);
u32 val;

val = mtk_cpux_readl(CPUX_IDX_GLOBAL_IRQ, to);

if (enable)
val |= *irq_mask;
else
val &= ~(*irq_mask);

mtk_cpux_writel(val, CPUX_IDX_GLOBAL_IRQ, to);
}

static int mtk_cpux_clkevt_shutdown(struct clock_event_device *clkevt)
{
/* Clear any irq */
mtk_cpux_set_irq(to_timer_of(clkevt), false);

/*
* Disabling CPUXGPT timer will crash the platform, especially
* if Trusted Firmware is using it (usually, for sleep states),
* so we only mask the IRQ and call it a day.
*/
return 0;
}

static int mtk_cpux_clkevt_resume(struct clock_event_device *clkevt)
{
mtk_cpux_set_irq(to_timer_of(clkevt), true);
return 0;
}

static void mtk_syst_ack_irq(struct timer_of *to)
{
/* Clear and disable interrupt */
Expand Down Expand Up @@ -281,6 +340,60 @@ static struct timer_of to = {
},
};

static int __init mtk_cpux_init(struct device_node *node)
{
static struct timer_of to_cpux;
u32 freq, val;
int ret;

/*
* There are per-cpu interrupts for the CPUX General Purpose Timer
* but since this timer feeds the AArch64 System Timer we can rely
* on the CPU timer PPIs as well, so we don't declare TIMER_OF_IRQ.
*/
to_cpux.flags = TIMER_OF_BASE | TIMER_OF_CLOCK;
to_cpux.clkevt.name = "mtk-cpuxgpt";
to_cpux.clkevt.rating = 10;
to_cpux.clkevt.cpumask = cpu_possible_mask;
to_cpux.clkevt.set_state_shutdown = mtk_cpux_clkevt_shutdown;
to_cpux.clkevt.tick_resume = mtk_cpux_clkevt_resume;

/* If this fails, bad things are about to happen... */
ret = timer_of_init(node, &to_cpux);
if (ret) {
WARN(1, "Cannot start CPUX timers.\n");
return ret;
}

/*
* Check if we're given a clock with the right frequency for this
* timer, otherwise warn but keep going with the setup anyway, as
* that makes it possible to still boot the kernel, even though
* it may not work correctly (random lockups, etc).
* The reason behind this is that having an early UART may not be
* possible for everyone and this gives a chance to retrieve kmsg
* for eventual debugging even on consumer devices.
*/
freq = timer_of_rate(&to_cpux);
if (freq > 13000000)
WARN(1, "Requested unsupported timer frequency %u\n", freq);

/* Clock input is 26MHz, set DIV2 to achieve 13MHz clock */
val = mtk_cpux_readl(CPUX_IDX_GLOBAL_CTRL, &to_cpux);
val &= ~CPUX_CLK_DIV_MASK;
val |= CPUX_CLK_DIV2;
mtk_cpux_writel(val, CPUX_IDX_GLOBAL_CTRL, &to_cpux);

/* Enable all CPUXGPT timers */
val = mtk_cpux_readl(CPUX_IDX_GLOBAL_CTRL, &to_cpux);
mtk_cpux_writel(val | CPUX_ENABLE, CPUX_IDX_GLOBAL_CTRL, &to_cpux);

clockevents_config_and_register(&to_cpux.clkevt, timer_of_rate(&to_cpux),
TIMER_SYNC_TICKS, 0xffffffff);

return 0;
}

static int __init mtk_syst_init(struct device_node *node)
{
int ret;
Expand Down Expand Up @@ -339,3 +452,4 @@ static int __init mtk_gpt_init(struct device_node *node)
}
TIMER_OF_DECLARE(mtk_mt6577, "mediatek,mt6577-timer", mtk_gpt_init);
TIMER_OF_DECLARE(mtk_mt6765, "mediatek,mt6765-timer", mtk_syst_init);
TIMER_OF_DECLARE(mtk_mt6795, "mediatek,mt6795-systimer", mtk_cpux_init);
Loading

0 comments on commit dfea848

Please sign in to comment.