From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6FD062FB0B3 for ; Wed, 7 Jan 2026 13:39:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767793201; cv=none; b=lwS2JqyCpCwx+j4txyu6BoaHfyEq+NO6jxsj+z1bCNJ+qLzYFfDPYXjWtByVWisZ3xpM/U5MXEg30AF3Aq5PJFOrRj4RG38BxEEQ1dVpJFkmNu58cyTZEhGor6zUryMRfeJ2X5AIlWr+ukZNo7zdtcGNBsdRXV/z+PYJDbyRc8E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767793201; c=relaxed/simple; bh=b4JPiwYZZNZVEP0BvLqcWwbe/rsB9saevx47a301FVA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=JbKaaRidNCD7847FixhJpwy80ANd/J44OiI3ZobR9qdasORRxPSc44R0AK0O85yl4rnX0HamJCF1cCoYWtB7YEzjJaLFG5wcH3tunV3RWfk0dX3DOJY7FYLVDF30gkVgDQc1AFORRPSNufGSqyvFB8pnGFi9Y417p8Qyu/7HjlQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=IMXnTQJa; arc=none smtp.client-ip=209.85.221.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="IMXnTQJa" Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-42fb5810d39so1148582f8f.2 for ; Wed, 07 Jan 2026 05:39:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1767793198; x=1768397998; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=essmEBOdYZvlb56f47cnSD8phUDtBzvO/hiGaoERCfE=; b=IMXnTQJaBvrujm3qT28MiKfy9kVPWjq/7nSb8GKZBIR8an2W63BoU2BDsC7WvDTC0z LQJMzHVdn8EyhcfxgZc15KqxOWOvqFTZ4fUrS8f4jWz6LDs2ixi61oDLJ3R3+F9Sry2t dm3rv46URR/1pYuDZLhzwuWdmdBU/ydv4gk2+cYihfqxma9hBGUETeHJr/elH4UT8qnd 4XNlTNo22VxNC6JdDBfMN7TEfYVBpPltYBZCuc4uifZDm6tySvVp5BKfyXsCj3tdhXRG abHWcSRFTjlqTX5QsSTSdHo/83d3mnJ9bgDKBp8mViMfPREu3cIRjoWU5xXh0Zq0D0eW dkeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767793198; x=1768397998; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=essmEBOdYZvlb56f47cnSD8phUDtBzvO/hiGaoERCfE=; b=dlVmKRxhMJ8rBMWuZRW2RBS5tfe9VAanPcDo74X6FONPb7MEsmCijxUhGxuH4hsH0P 0lV4NR7A5gG+GqlW1d52tMzIB1OZ9/b0ZkuH8MHRj3NAM3eoAv96H+1WXHTtpHLoi8Wg 2MlsxBVOEarXf2tYNzxcdWLKE2FaEjcTQqnihH9g9cmYjAz1HnpJ+ZSYb/9fmwGbCvGO t0+fDBDaVYsoh5e0DdlkJQsS/ZrN4GYCWRhkF+tkBRVg62jhKCpZJudsmuKP40s2l/0o Vqpn/ab0hVdcBiPFscpivXIbcVtlRHIVPhQ9iFVFmEkfbtMsc6pp7kKZqET/UGrh/An3 1cWw== X-Forwarded-Encrypted: i=1; AJvYcCU/XQWn2dskZQkNWpYNd30s5d/Mjnj5ooL7Xl6b4zOkD3VZLkgwO9l/pHPDdjS2Bs35LLtCthMXiZC0Q80=@vger.kernel.org X-Gm-Message-State: AOJu0Yz0BabNzv/xeArdzdAfcu6RNTQpXASJT2Cfk9bqaCi+kjAQqv7c up9wDxk0AeuhWbgnEtS8GM1J2q9CSNaCt+UAaK5Slf4zuerjjD9bXo6qurZW7TkORCM= X-Gm-Gg: AY/fxX4ZOzn2T3gttsNUc/m0b1BUf5s+PbYlacVnp+Q6/4yJlhE/kkBSAzgbIzrUjxD izcql7jOop02caiW6aeLmb5Aomq28dE4cTfiTESndGsLLglJe0bl+Ae3uqOPZcGpqrj0J8ObbZk DGjxgr0wUt6C4VYz1NtXj7+VkphPLsNH+dpBsRfAIDhcsuUk6FXLxhG3SmzUcFelv/VKPZh97mv v7cRRcUS2jGR7AVsk6xLWoBRRrx7y3h4sA9Q38hyiGCAmyaQYylT7x0dPs/v94FzCdf6bHeT90W ovX1D3BgJiu8zyDNjXykz6MSbHyF0/SIHrmZRhOYUVG3TQPD3oz7gtFROFIlCSQXD+sMUd26U1U sTOT+t/wa47xbBhsdxyWaiPtPaDN49rXCDtbP20IXUstJa34eNzYDSMvtvNc44HFATz2VHy7Nd/ CIr+hcKyLXDVMWzfAZR6RjhD9uDb2pZo0= X-Google-Smtp-Source: AGHT+IG5yiUMmsBELFqzl5e0cwWDO08ZlCwN7eYh8sJJ//HcdWLe6zUmYURWf7nvq3DOf61gkk+LhA== X-Received: by 2002:a5d:64c6:0:b0:42f:b581:c69d with SMTP id ffacd0b85a97d-432c3628323mr2941135f8f.3.1767793197720; Wed, 07 Jan 2026 05:39:57 -0800 (PST) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:39ee:bc4c:aafe:6bd0]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-432bd0dade5sm10595542f8f.9.2026.01.07.05.39.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jan 2026 05:39:57 -0800 (PST) From: Daniel Lezcano To: wbg@kernel.org Cc: robh@kernel.org, conor+dt@kernel.org, krzk+dt@kernel.org, s32@nxp.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org Subject: [PATCH v4 0/3] Add the System Timer Module counter Date: Wed, 7 Jan 2026 14:39:49 +0100 Message-ID: <20260107133953.2094015-1-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: * 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 | 433 ++++++++++++++++++ 6 files changed, 525 insertions(+), 19 deletions(-) create mode 100644 Documentation/devicetree/bindings/counter/nxp,s32g2-stm-cnt.yaml create mode 100644 drivers/counter/nxp-stm-cnt.c -- 2.43.0