Skip to content

Add the System Timer Module counter

Daniel Lezcano linux-devicetree linux-iio lkml 5 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest3 patches 4 repliesIn review
  2. v43 patches 3 repliesSuperseded
  3. v33 patches 4 repliesSuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v23 patches0 repliesSuperseded
v13 patches1 replySuperseded

Changelog from the cover letter · 17 lines

* v5
- Use a lockless version to implement accumulated time (Frank Li)

* v4
- Split context structure to suspend/resume
- Converted counter to a u64 to accumulate the time
- Replaced 'reset' to a count write to reset (William Breathitt Gray)
- Added events for userspace (William Breathitt Gray)
- Added action COUNTER_SYNAPSE_ACTION_RISING_EDGE for signal (William Breathitt Gray)
- Renamed counter name to "System Timer Module Counter" (William Breathitt Gray)

* v3
- Fixed compatible typo "nxp,s32g2-stm" to "nxp,s32g2-stm-cnt"

* v2
- Added Rob's tag
** kbuild
- Reordered alphabetically the headers
- Added bitfield.h header
- Use DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr()

Patches in v5 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3counters: Reorder the Makefiledrivers/counter/Makefile+11 -91 reply
2/3dt-bindings: counter: Add NXP System Timer Module CounterDocumentation/devicetree/bindings/counter/nxp,s32g2-stm-cnt.yaml arch/arm64/boot/dts/freescale/s32g2.dtsi arch/arm64/boot/dts/freescale/s32g274a-rdb2.dts+70 -100 replies
3/3counter: Add STM based counterdrivers/counter/Kconfig drivers/counter/Makefile drivers/counter/nxp-stm-cnt.c+443 -03 replies

Reviews trailers per patch

1 of 3 patches has a Reviewed-by or Acked-by.

PatchRob Herring (Arm)
1/3
2/3R-b
3/3

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v5 thread

Cover letter [PATCH v5 0/3] Add the System Timer Module counter

The NXP S32 family provides a System Timer Module (STM), a 32-bit free-running counter clocked from a peripheral clock. The STM includes a prescaler and one or more compare channels generating optional interrupts. When used as a generic hardware counter, only the main free-running counter is required, while the compare channels are typically unused.

On S32G2 devices, the STM is exposed as a simple counter block that can operate continuously and be shared across subsystems such as the Linux kernel, firmware components running on Cortex-M7 cores, or other co-processors. The counter can be read atomically and provides a stable timestamp source to correlate events occurring in different execution contexts.

The Linux kernel controls the STM through a memory-mapped interface, configuring the prescaler, enabling or disabling the counter, and accounting for wrap-arounds. Other subsystems access the counter in read-only mode, making it a shared timestamp reference across the platform.

This driver adds support for the STM when used as a counter on S32G2 platforms. The device is described in the device tree using the following compatible:

compatible = "nxp,s32g2-stm-cnt";

The driver exposes basic counter functionality: start, stop, reset, prescaler configuration, and overflow handling.

Changelog:
* v5
- Use a lockless version to implement accumulated time (Frank Li)

* v4
- Split context structure to suspend/resume
- Converted counter to a u64 to accumulate the time
- Replaced 'reset' to a count write to reset (William Breathitt Gray)
- Added events for userspace (William Breathitt Gray)
- Added action COUNTER_SYNAPSE_ACTION_RISING_EDGE for signal (William Breathitt Gray)
- Renamed counter name to "System Timer Module Counter" (William Breathitt Gray)

* v3
- Fixed compatible typo "nxp,s32g2-stm" to "nxp,s32g2-stm-cnt"

* v2
- Added Rob's tag
** kbuild
- Reordered alphabetically the headers
- Added bitfield.h header
- Use DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr()

Daniel Lezcano (3):
counters: Reorder the Makefile
dt-bindings: counter: Add NXP System Timer Module Counter
counter: Add STM based counter

 .../bindings/counter/nxp,s32g2-stm-cnt.yaml   |  64 +++
 arch/arm64/boot/dts/freescale/s32g2.dtsi      |   6 +-
 .../boot/dts/freescale/s32g274a-rdb2.dts      |  10 +-
 drivers/counter/Kconfig                       |  10 +
 drivers/counter/Makefile                      |  21 +-
 drivers/counter/nxp-stm-cnt.c                 | 432 ++++++++++++++++++
 6 files changed, 524 insertions(+), 19 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/counter/nxp,s32g2-stm-cnt.yaml
 create mode 100644 drivers/counter/nxp-stm-cnt.c
Signature · 1 line
2.43.0