Skip to content

Commit cec32ac

Browse files
committed
clocksource/drivers/nxp-timer: Add the System Timer Module for the s32gx platforms
STM supports commonly required system and application software timing functions. STM includes a 32-bit count-up timer and four 32-bit compare channels with a separate interrupt source for each channel. The timer is driven by the STM module clock divided by an 8-bit prescale value (1 to 256). STM has the following features: • One 32-bit count-up timer with an 8-bit prescaler • Four 32-bit compare channels • An independent interrupt source for each channel • Ability to stop the timer in Debug mode The s32g platform is declined into two versions, the s32g2 and the s32g3. The former has a STM block with 8 timers and the latter has 12 timers. The platform is designed to have one usable STM instance per core on the system which is composed of 3 x Cortex-M3 + 4 Cortex-A53 for the s32g2 and 3 x Cortex-M3 + 8 Cortex-A53 for the s32g3. There is a special STM instance called STM_TS which is dedicated to the timestamp. The 7th STM instance STM_07 is directly tied to the STM_TS which means it is not usable as a clockevent. The driver instantiate each STM described in the device tree as a clocksource and a clockevent conforming to the reference manual even if the Linux system does not use all of the clocksource. Each clockevent will have a cpumask set for a specific CPU. Given the counter is shared between the clocksource and the clockevent, the STM module can not be disabled by one or another so the refcounting mechanism is used to stop the counter when it reaches zero and to start it when it is one. The suspend and resume relies on the refcount to stop the module. As the device tree will have multiple STM entries, the driver can be probed in parallel with the async option but it is not enabled yet. However, the driver code takes care of preventing a race by putting a lock to protect the number of STM instances global variable which means it is ready to support the option when enough testing will be done with the underlying time framework. Cc: Ghennadi Procopciuc <[email protected]> Cc: Krzysztof Kozlowski <[email protected]> Cc: Thomas Fossati <[email protected]> Suggested-by: Ghennadi Procopciuc <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Daniel Lezcano <[email protected]>
1 parent eec34eb commit cec32ac

File tree

3 files changed

+504
-0
lines changed

3 files changed

+504
-0
lines changed

drivers/clocksource/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,4 +763,12 @@ config RALINK_TIMER
763763
Enables support for system tick counter present on
764764
Ralink SoCs RT3352 and MT7620.
765765

766+
config NXP_STM_TIMER
767+
bool "NXP System Timer Module driver"
768+
depends on ARCH_S32 || COMPILE_TEST
769+
select CLKSRC_MMIO
770+
help
771+
Enables the support for NXP System Timer Module found in the
772+
s32g NXP platform series.
773+
766774
endmenu

drivers/clocksource/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,4 @@ obj-$(CONFIG_GXP_TIMER) += timer-gxp.o
9292
obj-$(CONFIG_CLKSRC_LOONGSON1_PWM) += timer-loongson1-pwm.o
9393
obj-$(CONFIG_EP93XX_TIMER) += timer-ep93xx.o
9494
obj-$(CONFIG_RALINK_TIMER) += timer-ralink.o
95+
obj-$(CONFIG_NXP_STM_TIMER) += timer-nxp-stm.o

0 commit comments

Comments
 (0)