From nobody Mon Dec 1 21:31:50 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EAE9C287516 for ; Mon, 1 Dec 2025 06:51:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764571903; cv=none; b=FpFA5VQE8o2p+I1EaVkhbubGgZI1vigKmnreaRbG9W7i90CfZYpdgybUOs2EUdqD4wpo0nzPZk4JYHu9l14X9GqAur6aRhZPsUkNnX8jRIsJCS4KLvNWW/ee6jW6G0SvXbtjnebNTeDQvWzFeaSV59Nc5iwBOn+sFKeprbJppvU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764571903; c=relaxed/simple; bh=FGoI+LFlJm+Hla18NHXxk9RalWw1C0SRlmEF86MLPZM=; h=From:To:Cc:Subject:References:Message-ID:Content-Type: MIME-Version:Date; b=Ysx9MWGhFpLGsZTsZCHnw7qlbqfP/iHCdn1qnzsPrwfieWbjYH0lMeMrWynhAQVOVUlJoMHbIBZ5QiOtXnpa45OS32j3bQ4pzNaqu2d5v8Sdc7T+MSSDXii8LKRs746OYDJKbRS+/SCx/NgXyeSSA+1giFPCXJEjSCKxXu1Rs8o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=N8zLBpom; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=c3hI8B2i; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="N8zLBpom"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="c3hI8B2i" From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1764571899; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: references:references; bh=PWmS88z9jd78o7CkYMCiLGWKmavTRj3yNOqIX0YNiHI=; b=N8zLBpomBgNP9I80cd0kiZypuiTxuUMKqae4S/IMMq9iq7mUxuNCtExMxjZILP3p1FJpmh vTzL1zrdvc0xmcKyYR5XUrt/CnlKiLX7X5evxl8Z2OHFQkXH7qY3yWOuuYUSapxc/3g9H5 EwQmJUVZBxSNS3WEkl/Z9zqi/Bpvtda23v643y0Yl/dpF58wPREdt3gDVa8/cKtagielAP NCY3+iLbM/T0T12GK6q56kAKqr0tkXTC7got6knWJWOUmHq2OFKxgpixrBJyhuigJWh9Nx D1D9Cx5UZSsuWIgC+NHg8gd7ZR0uEKxi73iHMBkjaMRrv7s0l7Mj/H/uIrJ2JA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1764571899; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: references:references; bh=PWmS88z9jd78o7CkYMCiLGWKmavTRj3yNOqIX0YNiHI=; b=c3hI8B2i+4ppMC5UQl+VjT819DxSjuFC7LITkYjLogVhmHYnSSyC1Ze9Fv9uBchKKNDtwH tf7CDNn9rfnd8WCg== To: Linus Torvalds Cc: linux-kernel@vger.kernel.org, x86@kernel.org Subject: [GIT pull] timers/clocksource for v6.19-rc1 References: <176457119565.1888260.10012195384143368631.tglx@xen13> Message-ID: <176457121799.1888260.7967196214170790017.tglx@xen13> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Mon, 1 Dec 2025 07:51:33 +0100 (CET) Linus, please pull the latest timers/clocksource branch from: git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git timers-clockso= urce-2025-11-30 up to: 2437f798809d: Merge tag 'timers-v6.19-rc1' of git://git.kernel.org/= pub/scm/linux/kernel/git/daniel.lezcano/linux into timers/clocksource Updates for clocksource and clockevent drivers: - A new driver for the Realtel system timer - Prevent the unbinding of timers when the drivers do not support that. - Expand the timer counter readout for the SPRD driver to 64 bit to allow IOT devices suspend times of more than 36 hours, which is the current limit of the 32-bi readout - The usual small cleanups, fixes and enhancements all over the place. Thanks, tglx ------------------> Enlin Mu (2): clocksource/drivers/sprd: Enable register for timer counter from 32 b= it to 64 bit clocksource/drivers/rda: Add sched_clock_register for RDA8810PL SoC Hao-Wen Ting (2): dt-bindings: timer: Add Realtek SYSTIMER clocksource/drivers: Add Realtek system timer driver Haotian Zhang (1): clocksource/drivers/ralink: Fix resource leaks in init error path Johan Hovold (6): clocksource/drivers/stm: Fix double deregistration on probe failure clocksource/drivers/nxp-stm: Fix section mismatches clocksource/drivers/arm_arch_timer_mmio: Prevent driver unbind clocksource/drivers/nxp-pit: Prevent driver unbind clocksource/drivers/nxp-stm: Prevent driver unbind clocksource/drivers/stm32-lp: Drop unused module alias Niklas S=C3=B6derlund (1): clocksource/drivers/sh_cmt: Always leave device running after probe Stephen Eta Zhou (1): clocksource/drivers/timer-sp804: Fix read_current_timer() issue when = clock source is not registered .../bindings/timer/realtek,rtd1625-systimer.yaml | 47 +++++++ MAINTAINERS | 5 + drivers/clocksource/Kconfig | 11 ++ drivers/clocksource/Makefile | 1 + drivers/clocksource/arm_arch_timer_mmio.c | 2 + drivers/clocksource/sh_cmt.c | 36 +---- drivers/clocksource/timer-nxp-pit.c | 3 +- drivers/clocksource/timer-nxp-stm.c | 23 ++-- drivers/clocksource/timer-ralink.c | 11 +- drivers/clocksource/timer-rda.c | 9 +- drivers/clocksource/timer-realtek.c | 150 +++++++++++++++++= ++++ drivers/clocksource/timer-sp804.c | 24 ++++ drivers/clocksource/timer-sprd.c | 24 +++- drivers/clocksource/timer-stm32-lp.c | 1 - 14 files changed, 291 insertions(+), 56 deletions(-) create mode 100644 Documentation/devicetree/bindings/timer/realtek,rtd1625= -systimer.yaml create mode 100644 drivers/clocksource/timer-realtek.c diff --git a/Documentation/devicetree/bindings/timer/realtek,rtd1625-systim= er.yaml b/Documentation/devicetree/bindings/timer/realtek,rtd1625-systimer.= yaml new file mode 100644 index 000000000000..e08d3d2d306b --- /dev/null +++ b/Documentation/devicetree/bindings/timer/realtek,rtd1625-systimer.yaml @@ -0,0 +1,47 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/timer/realtek,rtd1625-systimer.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Realtek System Timer + +maintainers: + - Hao-Wen Ting + +description: + The Realtek SYSTIMER (System Timer) is a 64-bit global hardware counter = operating + at a fixed 1MHz frequency. Thanks to its compare match interrupt capabil= ity, + the timer natively supports oneshot mode for tick broadcast functionalit= y. + +properties: + compatible: + oneOf: + - const: realtek,rtd1625-systimer + - items: + - const: realtek,rtd1635-systimer + - const: realtek,rtd1625-systimer + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + +required: + - compatible + - reg + - interrupts + +additionalProperties: false + +examples: + - | + #include + + timer@89420 { + compatible =3D "realtek,rtd1635-systimer", + "realtek,rtd1625-systimer"; + reg =3D <0x89420 0x18>; + interrupts =3D ; + }; diff --git a/MAINTAINERS b/MAINTAINERS index 3da2c26a796b..b72b9873b90e 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -21669,6 +21669,11 @@ S: Maintained F: Documentation/devicetree/bindings/spi/realtek,rtl9301-snand.yaml F: drivers/spi/spi-realtek-rtl-snand.c =20 +REALTEK SYSTIMER DRIVER +M: Hao-Wen Ting +S: Maintained +F: drivers/clocksource/timer-realtek.c + REALTEK WIRELESS DRIVER (rtlwifi family) M: Ping-Ke Shih L: linux-wireless@vger.kernel.org diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig index ffcd23668763..aa59e5b13351 100644 --- a/drivers/clocksource/Kconfig +++ b/drivers/clocksource/Kconfig @@ -782,4 +782,15 @@ config NXP_STM_TIMER Enables the support for NXP System Timer Module found in the s32g NXP platform series. =20 +config RTK_SYSTIMER + bool "Realtek SYSTIMER support" + depends on ARM || ARM64 + depends on ARCH_REALTEK || COMPILE_TEST + select TIMER_OF + help + This option enables the driver that registers the global 1 MHz hardware + counter as a clock event device on Realtek SoCs. Make sure to enable + this option only when building for a Realtek platform or for compilation + testing. + endmenu diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile index ec4452ee958f..b46376af6b49 100644 --- a/drivers/clocksource/Makefile +++ b/drivers/clocksource/Makefile @@ -95,3 +95,4 @@ obj-$(CONFIG_CLKSRC_LOONGSON1_PWM) +=3D timer-loongson1-p= wm.o obj-$(CONFIG_EP93XX_TIMER) +=3D timer-ep93xx.o obj-$(CONFIG_RALINK_TIMER) +=3D timer-ralink.o obj-$(CONFIG_NXP_STM_TIMER) +=3D timer-nxp-stm.o +obj-$(CONFIG_RTK_SYSTIMER) +=3D timer-realtek.o diff --git a/drivers/clocksource/arm_arch_timer_mmio.c b/drivers/clocksourc= e/arm_arch_timer_mmio.c index ebe1987d651e..d10362692fdd 100644 --- a/drivers/clocksource/arm_arch_timer_mmio.c +++ b/drivers/clocksource/arm_arch_timer_mmio.c @@ -426,6 +426,7 @@ static struct platform_driver arch_timer_mmio_drv =3D { .driver =3D { .name =3D "arch-timer-mmio", .of_match_table =3D arch_timer_mmio_of_table, + .suppress_bind_attrs =3D true, }, .probe =3D arch_timer_mmio_probe, }; @@ -434,6 +435,7 @@ builtin_platform_driver(arch_timer_mmio_drv); static struct platform_driver arch_timer_mmio_acpi_drv =3D { .driver =3D { .name =3D "gtdt-arm-mmio-timer", + .suppress_bind_attrs =3D true, }, .probe =3D arch_timer_mmio_probe, }; diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c index 385eb94bbe7c..791b298c995b 100644 --- a/drivers/clocksource/sh_cmt.c +++ b/drivers/clocksource/sh_cmt.c @@ -355,14 +355,6 @@ static int sh_cmt_enable(struct sh_cmt_channel *ch) =20 dev_pm_syscore_device(&ch->cmt->pdev->dev, true); =20 - /* enable clock */ - ret =3D clk_enable(ch->cmt->clk); - if (ret) { - dev_err(&ch->cmt->pdev->dev, "ch%u: cannot enable clock\n", - ch->index); - goto err0; - } - /* make sure channel is disabled */ sh_cmt_start_stop_ch(ch, 0); =20 @@ -384,19 +376,12 @@ static int sh_cmt_enable(struct sh_cmt_channel *ch) if (ret || sh_cmt_read_cmcnt(ch)) { dev_err(&ch->cmt->pdev->dev, "ch%u: cannot clear CMCNT\n", ch->index); - ret =3D -ETIMEDOUT; - goto err1; + return -ETIMEDOUT; } =20 /* enable channel */ sh_cmt_start_stop_ch(ch, 1); return 0; - err1: - /* stop clock */ - clk_disable(ch->cmt->clk); - - err0: - return ret; } =20 static void sh_cmt_disable(struct sh_cmt_channel *ch) @@ -407,9 +392,6 @@ static void sh_cmt_disable(struct sh_cmt_channel *ch) /* disable interrupts in CMT block */ sh_cmt_write_cmcsr(ch, 0); =20 - /* stop clock */ - clk_disable(ch->cmt->clk); - dev_pm_syscore_device(&ch->cmt->pdev->dev, false); } =20 @@ -583,8 +565,6 @@ static int sh_cmt_start_clocksource(struct sh_cmt_chann= el *ch) int ret =3D 0; unsigned long flags; =20 - pm_runtime_get_sync(&ch->cmt->pdev->dev); - raw_spin_lock_irqsave(&ch->lock, flags); =20 if (!(ch->flags & (FLAG_CLOCKEVENT | FLAG_CLOCKSOURCE))) @@ -619,8 +599,6 @@ static void sh_cmt_stop_clocksource(struct sh_cmt_chann= el *ch) sh_cmt_disable(ch); =20 raw_spin_unlock_irqrestore(&ch->lock, flags); - - pm_runtime_put(&ch->cmt->pdev->dev); } =20 static int sh_cmt_start_clockevent(struct sh_cmt_channel *ch) @@ -630,10 +608,8 @@ static int sh_cmt_start_clockevent(struct sh_cmt_chann= el *ch) =20 raw_spin_lock_irqsave(&ch->lock, flags); =20 - if (!(ch->flags & (FLAG_CLOCKEVENT | FLAG_CLOCKSOURCE))) { - pm_runtime_get_sync(&ch->cmt->pdev->dev); + if (!(ch->flags & (FLAG_CLOCKEVENT | FLAG_CLOCKSOURCE))) ret =3D sh_cmt_enable(ch); - } =20 if (ret) goto out; @@ -656,10 +632,8 @@ static void sh_cmt_stop_clockevent(struct sh_cmt_chann= el *ch) =20 ch->flags &=3D ~FLAG_CLOCKEVENT; =20 - if (f && !(ch->flags & (FLAG_CLOCKEVENT | FLAG_CLOCKSOURCE))) { + if (f && !(ch->flags & (FLAG_CLOCKEVENT | FLAG_CLOCKSOURCE))) sh_cmt_disable(ch); - pm_runtime_put(&ch->cmt->pdev->dev); - } =20 /* adjust the timeout to maximum if only clocksource left */ if (ch->flags & FLAG_CLOCKSOURCE) @@ -1134,8 +1108,6 @@ static int sh_cmt_setup(struct sh_cmt_device *cmt, st= ruct platform_device *pdev) mask &=3D ~(1 << hwidx); } =20 - clk_disable(cmt->clk); - platform_set_drvdata(pdev, cmt); =20 return 0; @@ -1183,8 +1155,6 @@ static int sh_cmt_probe(struct platform_device *pdev) out: if (cmt->has_clockevent || cmt->has_clocksource) pm_runtime_irq_safe(&pdev->dev); - else - pm_runtime_idle(&pdev->dev); =20 return 0; } diff --git a/drivers/clocksource/timer-nxp-pit.c b/drivers/clocksource/time= r-nxp-pit.c index 2d0a3554b6bf..d1740f18f718 100644 --- a/drivers/clocksource/timer-nxp-pit.c +++ b/drivers/clocksource/timer-nxp-pit.c @@ -374,9 +374,10 @@ static struct platform_driver nxp_pit_driver =3D { .driver =3D { .name =3D "nxp-pit", .of_match_table =3D pit_timer_of_match, + .suppress_bind_attrs =3D true, }, .probe =3D pit_timer_probe, }; -module_platform_driver(nxp_pit_driver); +builtin_platform_driver(nxp_pit_driver); =20 TIMER_OF_DECLARE(vf610, "fsl,vf610-pit", pit_timer_init); diff --git a/drivers/clocksource/timer-nxp-stm.c b/drivers/clocksource/time= r-nxp-stm.c index bbc40623728f..1ab907233f48 100644 --- a/drivers/clocksource/timer-nxp-stm.c +++ b/drivers/clocksource/timer-nxp-stm.c @@ -177,15 +177,15 @@ static void nxp_stm_clocksource_resume(struct clockso= urce *cs) nxp_stm_clocksource_enable(cs); } =20 -static void __init devm_clocksource_unregister(void *data) +static void devm_clocksource_unregister(void *data) { struct stm_timer *stm_timer =3D data; =20 clocksource_unregister(&stm_timer->cs); } =20 -static int __init nxp_stm_clocksource_init(struct device *dev, struct stm_= timer *stm_timer, - const char *name, void __iomem *base, struct clk *clk) +static int nxp_stm_clocksource_init(struct device *dev, struct stm_timer *= stm_timer, + const char *name, void __iomem *base, struct clk *clk) { int ret; =20 @@ -208,10 +208,8 @@ static int __init nxp_stm_clocksource_init(struct devi= ce *dev, struct stm_timer return ret; =20 ret =3D devm_add_action_or_reset(dev, devm_clocksource_unregister, stm_ti= mer); - if (ret) { - clocksource_unregister(&stm_timer->cs); + if (ret) return ret; - } =20 stm_sched_clock =3D stm_timer; =20 @@ -298,9 +296,9 @@ static void nxp_stm_clockevent_resume(struct clock_even= t_device *ced) nxp_stm_module_get(stm_timer); } =20 -static int __init nxp_stm_clockevent_per_cpu_init(struct device *dev, stru= ct stm_timer *stm_timer, - const char *name, void __iomem *base, int irq, - struct clk *clk, int cpu) +static int nxp_stm_clockevent_per_cpu_init(struct device *dev, struct stm_= timer *stm_timer, + const char *name, void __iomem *base, int irq, + struct clk *clk, int cpu) { stm_timer->base =3D base; stm_timer->rate =3D clk_get_rate(clk); @@ -388,7 +386,7 @@ static irqreturn_t nxp_stm_module_interrupt(int irq, vo= id *dev_id) return IRQ_HANDLED; } =20 -static int __init nxp_stm_timer_probe(struct platform_device *pdev) +static int nxp_stm_timer_probe(struct platform_device *pdev) { struct stm_timer *stm_timer; struct device *dev =3D &pdev->dev; @@ -484,14 +482,15 @@ static const struct of_device_id nxp_stm_of_match[] = =3D { }; MODULE_DEVICE_TABLE(of, nxp_stm_of_match); =20 -static struct platform_driver nxp_stm_probe =3D { +static struct platform_driver nxp_stm_driver =3D { .probe =3D nxp_stm_timer_probe, .driver =3D { .name =3D "nxp-stm", .of_match_table =3D nxp_stm_of_match, + .suppress_bind_attrs =3D true, }, }; -module_platform_driver(nxp_stm_probe); +builtin_platform_driver(nxp_stm_driver); =20 MODULE_DESCRIPTION("NXP System Timer Module driver"); MODULE_LICENSE("GPL"); diff --git a/drivers/clocksource/timer-ralink.c b/drivers/clocksource/timer= -ralink.c index 6ecdb4228f76..68434d9ed910 100644 --- a/drivers/clocksource/timer-ralink.c +++ b/drivers/clocksource/timer-ralink.c @@ -130,14 +130,15 @@ static int __init ralink_systick_init(struct device_n= ode *np) systick.dev.irq =3D irq_of_parse_and_map(np, 0); if (!systick.dev.irq) { pr_err("%pOFn: request_irq failed", np); - return -EINVAL; + ret =3D -EINVAL; + goto err_iounmap; } =20 ret =3D clocksource_mmio_init(systick.membase + SYSTICK_COUNT, np->name, SYSTICK_FREQ, 301, 16, clocksource_mmio_readl_up); if (ret) - return ret; + goto err_free_irq; =20 clockevents_register_device(&systick.dev); =20 @@ -145,6 +146,12 @@ static int __init ralink_systick_init(struct device_no= de *np) np, systick.dev.mult, systick.dev.shift); =20 return 0; + +err_free_irq: + irq_dispose_mapping(systick.dev.irq); +err_iounmap: + iounmap(systick.membase); + return ret; } =20 TIMER_OF_DECLARE(systick, "ralink,cevt-systick", ralink_systick_init); diff --git a/drivers/clocksource/timer-rda.c b/drivers/clocksource/timer-rd= a.c index fd1199c189bf..0be8e05970e2 100644 --- a/drivers/clocksource/timer-rda.c +++ b/drivers/clocksource/timer-rda.c @@ -13,6 +13,7 @@ =20 #include #include +#include =20 #include "timer-of.h" =20 @@ -153,7 +154,7 @@ static struct timer_of rda_ostimer_of =3D { }, }; =20 -static u64 rda_hwtimer_read(struct clocksource *cs) +static u64 rda_hwtimer_clocksource_read(void) { void __iomem *base =3D timer_of_base(&rda_ostimer_of); u32 lo, hi; @@ -167,6 +168,11 @@ static u64 rda_hwtimer_read(struct clocksource *cs) return ((u64)hi << 32) | lo; } =20 +static u64 rda_hwtimer_read(struct clocksource *cs) +{ + return rda_hwtimer_clocksource_read(); +} + static struct clocksource rda_hwtimer_clocksource =3D { .name =3D "rda-timer", .rating =3D 400, @@ -185,6 +191,7 @@ static int __init rda_timer_init(struct device_node *np) return ret; =20 clocksource_register_hz(&rda_hwtimer_clocksource, rate); + sched_clock_register(rda_hwtimer_clocksource_read, 64, rate); =20 clockevents_config_and_register(&rda_ostimer_of.clkevt, rate, 0x2, UINT_MAX); diff --git a/drivers/clocksource/timer-realtek.c b/drivers/clocksource/time= r-realtek.c new file mode 100644 index 000000000000..4f0439de9939 --- /dev/null +++ b/drivers/clocksource/timer-realtek.c @@ -0,0 +1,150 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (c) 2025 Realtek Semiconductor Corp. + */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include +#include +#include "timer-of.h" + +#define ENBL 1 +#define DSBL 0 + +#define SYSTIMER_RATE 1000000 +#define SYSTIMER_MIN_DELTA 0x64 +#define SYSTIMER_MAX_DELTA ULONG_MAX + +/* SYSTIMER Register Offset (RTK Internal Use) */ +#define TS_LW_OFST 0x0 +#define TS_HW_OFST 0x4 +#define TS_CMP_VAL_LW_OFST 0x8 +#define TS_CMP_VAL_HW_OFST 0xC +#define TS_CMP_CTRL_OFST 0x10 +#define TS_CMP_STAT_OFST 0x14 + +/* SYSTIMER CMP CTRL REG Mask */ +#define TS_CMP_EN_MASK 0x1 +#define TS_WR_EN0_MASK 0x2 + +static void __iomem *systimer_base; + +static u64 rtk_ts64_read(void) +{ + u32 low, high; + u64 ts; + + /* Caution: Read LSB word (TS_LW_OFST) first then MSB (TS_HW_OFST) */ + low =3D readl(systimer_base + TS_LW_OFST); + high =3D readl(systimer_base + TS_HW_OFST); + ts =3D ((u64)high << 32) | low; + + return ts; +} + +static void rtk_cmp_value_write(u64 value) +{ + u32 high, low; + + low =3D value & 0xFFFFFFFF; + high =3D value >> 32; + + writel(high, systimer_base + TS_CMP_VAL_HW_OFST); + writel(low, systimer_base + TS_CMP_VAL_LW_OFST); +} + +static inline void rtk_cmp_en_write(bool cmp_en) +{ + u32 val; + + val =3D TS_WR_EN0_MASK; + if (cmp_en =3D=3D ENBL) + val |=3D TS_CMP_EN_MASK; + + writel(val, systimer_base + TS_CMP_CTRL_OFST); +} + +static int rtk_syst_clkevt_next_event(unsigned long cycles, struct clock_e= vent_device *clkevt) +{ + u64 cmp_val; + + rtk_cmp_en_write(DSBL); + cmp_val =3D rtk_ts64_read(); + + /* Set CMP value to current timestamp plus delta_us */ + rtk_cmp_value_write(cmp_val + cycles); + rtk_cmp_en_write(ENBL); + return 0; +} + +static irqreturn_t rtk_ts_match_intr_handler(int irq, void *dev_id) +{ + struct clock_event_device *clkevt =3D dev_id; + void __iomem *reg_base; + u32 val; + + /* Disable TS CMP Match */ + rtk_cmp_en_write(DSBL); + + /* Clear TS CMP INTR */ + reg_base =3D systimer_base + TS_CMP_STAT_OFST; + val =3D readl(reg_base) & TS_CMP_EN_MASK; + writel(val | TS_CMP_EN_MASK, reg_base); + clkevt->event_handler(clkevt); + + return IRQ_HANDLED; +} + +static int rtk_syst_shutdown(struct clock_event_device *clkevt) +{ + void __iomem *reg_base; + u64 cmp_val =3D 0; + + /* Disable TS CMP Match */ + rtk_cmp_en_write(DSBL); + /* Set compare value to 0 */ + rtk_cmp_value_write(cmp_val); + + /* Clear TS CMP INTR */ + reg_base =3D systimer_base + TS_CMP_STAT_OFST; + writel(TS_CMP_EN_MASK, reg_base); + return 0; +} + +static struct timer_of rtk_timer_to =3D { + .flags =3D TIMER_OF_IRQ | TIMER_OF_BASE, + + .clkevt =3D { + .name =3D "rtk-clkevt", + .rating =3D 300, + .cpumask =3D cpu_possible_mask, + .features =3D CLOCK_EVT_FEAT_DYNIRQ | + CLOCK_EVT_FEAT_ONESHOT, + .set_next_event =3D rtk_syst_clkevt_next_event, + .set_state_oneshot =3D rtk_syst_shutdown, + .set_state_shutdown =3D rtk_syst_shutdown, + }, + + .of_irq =3D { + .flags =3D IRQF_TIMER | IRQF_IRQPOLL, + .handler =3D rtk_ts_match_intr_handler, + }, +}; + +static int __init rtk_systimer_init(struct device_node *node) +{ + int ret; + + ret =3D timer_of_init(node, &rtk_timer_to); + if (ret) + return ret; + + systimer_base =3D timer_of_base(&rtk_timer_to); + clockevents_config_and_register(&rtk_timer_to.clkevt, SYSTIMER_RATE, + SYSTIMER_MIN_DELTA, SYSTIMER_MAX_DELTA); + + return 0; +} + +TIMER_OF_DECLARE(rtk_systimer, "realtek,rtd1625-systimer", rtk_systimer_in= it); diff --git a/drivers/clocksource/timer-sp804.c b/drivers/clocksource/timer-= sp804.c index cd1916c05325..e82a95ea4724 100644 --- a/drivers/clocksource/timer-sp804.c +++ b/drivers/clocksource/timer-sp804.c @@ -21,6 +21,10 @@ #include #include =20 +#ifdef CONFIG_ARM +#include +#endif + #include "timer-sp.h" =20 /* Hisilicon 64-bit timer(a variant of ARM SP804) */ @@ -102,6 +106,23 @@ static u64 notrace sp804_read(void) return ~readl_relaxed(sched_clkevt->value); } =20 +#ifdef CONFIG_ARM +static struct delay_timer delay; +static unsigned long sp804_read_delay_timer_read(void) +{ + return sp804_read(); +} + +static void sp804_register_delay_timer(int freq) +{ + delay.freq =3D freq; + delay.read_current_timer =3D sp804_read_delay_timer_read; + register_current_timer_delay(&delay); +} +#else +static inline void sp804_register_delay_timer(int freq) {} +#endif + static int __init sp804_clocksource_and_sched_clock_init(void __iomem *bas= e, const char *name, struct clk *clk, @@ -114,6 +135,8 @@ static int __init sp804_clocksource_and_sched_clock_ini= t(void __iomem *base, if (rate < 0) return -EINVAL; =20 + sp804_register_delay_timer(rate); + clkevt =3D sp804_clkevt_get(base); =20 writel(0, clkevt->ctrl); @@ -318,6 +341,7 @@ static int __init sp804_of_init(struct device_node *np,= struct sp804_timer *time if (ret) goto err; } + initialized =3D true; =20 return 0; diff --git a/drivers/clocksource/timer-sprd.c b/drivers/clocksource/timer-s= prd.c index 430cb99d8d79..2c07dd2af760 100644 --- a/drivers/clocksource/timer-sprd.c +++ b/drivers/clocksource/timer-sprd.c @@ -30,6 +30,7 @@ #define TIMER_VALUE_SHDW_HI 0x1c =20 #define TIMER_VALUE_LO_MASK GENMASK(31, 0) +#define TIMER_VALUE_HI_MASK GENMASK(31, 0) =20 static void sprd_timer_enable(void __iomem *base, u32 flag) { @@ -162,15 +163,26 @@ static struct timer_of suspend_to =3D { =20 static u64 sprd_suspend_timer_read(struct clocksource *cs) { - return ~(u64)readl_relaxed(timer_of_base(&suspend_to) + - TIMER_VALUE_SHDW_LO) & cs->mask; + u32 lo, hi; + + do { + hi =3D readl_relaxed(timer_of_base(&suspend_to) + + TIMER_VALUE_SHDW_HI); + lo =3D readl_relaxed(timer_of_base(&suspend_to) + + TIMER_VALUE_SHDW_LO); + } while (hi !=3D readl_relaxed(timer_of_base(&suspend_to) + TIMER_VALUE_S= HDW_HI)); + + return ~(((u64)hi << 32) | lo); } =20 static int sprd_suspend_timer_enable(struct clocksource *cs) { - sprd_timer_update_counter(timer_of_base(&suspend_to), - TIMER_VALUE_LO_MASK); - sprd_timer_enable(timer_of_base(&suspend_to), TIMER_CTL_PERIOD_MODE); + writel_relaxed(TIMER_VALUE_LO_MASK, + timer_of_base(&suspend_to) + TIMER_LOAD_LO); + writel_relaxed(TIMER_VALUE_HI_MASK, + timer_of_base(&suspend_to) + TIMER_LOAD_HI); + sprd_timer_enable(timer_of_base(&suspend_to), + TIMER_CTL_PERIOD_MODE|TIMER_CTL_64BIT_WIDTH); =20 return 0; } @@ -186,7 +198,7 @@ static struct clocksource suspend_clocksource =3D { .read =3D sprd_suspend_timer_read, .enable =3D sprd_suspend_timer_enable, .disable =3D sprd_suspend_timer_disable, - .mask =3D CLOCKSOURCE_MASK(32), + .mask =3D CLOCKSOURCE_MASK(64), .flags =3D CLOCK_SOURCE_IS_CONTINUOUS | CLOCK_SOURCE_SUSPEND_NONSTOP, }; =20 diff --git a/drivers/clocksource/timer-stm32-lp.c b/drivers/clocksource/tim= er-stm32-lp.c index c2a699f5c1dd..3d804128c765 100644 --- a/drivers/clocksource/timer-stm32-lp.c +++ b/drivers/clocksource/timer-stm32-lp.c @@ -289,5 +289,4 @@ static struct platform_driver stm32_clkevent_lp_driver = =3D { }; module_platform_driver(stm32_clkevent_lp_driver); =20 -MODULE_ALIAS("platform:stm32-lptimer-timer"); MODULE_DESCRIPTION("STMicroelectronics STM32 clockevent low power driver");