From nobody Fri Dec 19 03:42:46 2025 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (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 454CE3358A2 for ; Wed, 17 Dec 2025 07:50:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765957821; cv=none; b=lHrZyjtSQodkkIvIfxrgHgxDxMILWpBFs5iUxBTrBgJj1/Sx2fLusp6szM9lYCNjeHfH7NcRI5rfYNeylFgSlnCIK74rhiNzQD6x68Y74bIsQ5iNERmsLQFtyva5017r0GYo/oqegHTBRMSnXT6HTISvqfMTwrXQEOqSrI8ee14= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765957821; c=relaxed/simple; bh=m0D9V4x0TDiYMScx+B2rDcfNHpt1W4utB08H2EYXkTI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=krdRfSOJ7RaYs37YvmZuORD0qYfIhsX1I0RfXNUrrfIjMMYRXLBEZTRzhN6mfvfYvTUTYAW2CDkL4Js049n7v8AF/Y7VgbYxtQ9MM9izPVNKyCz5mkhQ5RUHIzIZ9t1HRbuBTY/34Sx4lIZ+YlxtGmLin5zW9si1j00ZLCqc1cQ= 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=StbrB3d9; arc=none smtp.client-ip=209.85.128.41 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="StbrB3d9" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-47789cd2083so28984115e9.2 for ; Tue, 16 Dec 2025 23:50:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765957816; x=1766562616; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=reHYsRVhVlhU9/XLdVBvX/hBxL5PqvrIU5ifd6VhtQI=; b=StbrB3d9bH6MzWe9qh9ziSuYrL7Tdlw6H917XsSknkV9Iyd4mIi1B6nFgD4YFIrsLW waK686duKqoxiInG7ab0HV/kHRY1KWA3EJ/kPf/4uQDEtIS7JlHsS8kQIyv0BbPs5OJ9 b8ASMv7oK/vHqI7n7UNN9RMP4mo2fS6BkqPoUjaS70mQ2gb36uhCKfxYHi+mskXBo8jF RxrXXVn1km+J0yW2DUuhKSHdoFpDA1LfnmbTg1aLFG+tXVlqC4BBT8qQ5HDCZvB7qqlo FdsYdRHHH5PCX2FcIjKFdHxKrZ7whEhK+ce7DKK4f6QlmmR14gKU5yfGiVKEjfHvnFc3 gzPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765957816; x=1766562616; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=reHYsRVhVlhU9/XLdVBvX/hBxL5PqvrIU5ifd6VhtQI=; b=dj3ggjGtEYm62Jbqv75w3G0C8TQWKETiG9X6TqozHL26UQs1J0M1kwzvLV3E7BJQlK +drR4TD9zBDSgMK5Tz4+uYHUtMp7Rm6nHnLZhqCtwgJwzDoOxuHnXvnfVnG3vFQKP5xc keFo1tfBp0kNH0xa0dvETu6sjKulucMQHqAiFWDJNdCc705gWfWcVpnb9otYyUfqahip QSvMTsn/hcysxgiaPLLwz3gmk3rQw4yIN1/6l3MVLaUEnNv+I2GDWw08ryALjK+Z+d++ szhp8AX7gZ2Z7mAqaP0ZWBmxvA+MYdJcpnJd4hPr97OofXTwIqj7ej2r/yQfkqrxq/Hg iRhA== X-Forwarded-Encrypted: i=1; AJvYcCWdOXJE8lSo/YU3ODbIE+SQOpeZZXZPIItuzTmZCThRdycbSY3ZwuT98jHwM3YhVSd3S9ZJUJQpahNwhHI=@vger.kernel.org X-Gm-Message-State: AOJu0YxLBO3e2tRGLdpm39sl34e9J37ES4D3H6DQ3Tk6Mk3qOpdizwxz ocAR4rDX0sSk7x748jbZOqrH/ZKfAMGqJNwYHcWiYsOPwQV7MWlCp/KlpXWJ0Mm+A2U= X-Gm-Gg: AY/fxX4TIhu0sQyr6xVMQu1ybqKjd8NQSa8kiIV/4wsdU8XHFb8uvSO6TSfEw37LCfY L9WFypzyLM+GIAf0gQI1JieJmNpDMY+evKnb/qqVmhbpi6aCVtdMPeGrpIBukZ/MGN3SXyeakJc CaIIvgRMKdrxw9fRxKgDA95IC8D0g6JJQVOAK5wYaPh1nd3fbmxcFTJH73KFmghJaf1aYOmdkJo jqsIvFKif5xP5df71+6z/MNQinudTk18sSE/asYZp6qa4rleM5Z7Jdzla3bAHhdOW3zjgvUHe/j woAOt1vYe+O8NLoVcAT22QaWkYhd+06xMZoUmCWvGSM9SbJc0bDBnRqeKraQgAJj5uQn3pBjciO gdoZ+ESXOBbwxkg0/KcRRRLEcIDy1xbhglhApDm2mXxMRjhjvQIMw9vblCifgCuTcoPVx052aCP AzJnUiXcka0rn//Frzw6JRtt5B+VK+ya8= X-Google-Smtp-Source: AGHT+IFnx406KO2q93NhOrqRhNQ711mt1VR1CvL6ul0btReeHMDv6zRYevqWvEWqN/pLnAUfw+qqmA== X-Received: by 2002:a05:600c:45c8:b0:477:b0b9:312a with SMTP id 5b1f17b1804b1-47a8f8a7136mr148399285e9.7.1765957816540; Tue, 16 Dec 2025 23:50:16 -0800 (PST) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:37e6:ed62:3c8b:2621]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47bdc1edff5sm26094315e9.14.2025.12.16.23.50.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Dec 2025 23:50:15 -0800 (PST) From: Daniel Lezcano To: wbg@kernel.org, robh@kernel.org, conor+dt@kernel.org, krzk+dt@kernel.org Cc: s32@nxp.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org Subject: [PATCH v3 1/3] counters: Reorder the Makefile Date: Wed, 17 Dec 2025 08:49:55 +0100 Message-ID: <20251217075000.2592966-2-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251217075000.2592966-1-daniel.lezcano@linaro.org> References: <20251217075000.2592966-1-daniel.lezcano@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The next changes provide a new driver. For the sake of clarity, reorder the Makefile alphabetically. No functional changes intended. Signed-off-by: Daniel Lezcano --- drivers/counter/Makefile | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/counter/Makefile b/drivers/counter/Makefile index fa3c1d08f706..40e644948e7a 100644 --- a/drivers/counter/Makefile +++ b/drivers/counter/Makefile @@ -6,14 +6,16 @@ obj-$(CONFIG_COUNTER) +=3D counter.o counter-y :=3D counter-core.o counter-sysfs.o counter-chrdev.o =20 -obj-$(CONFIG_I8254) +=3D i8254.o -obj-$(CONFIG_104_QUAD_8) +=3D 104-quad-8.o +obj-$(CONFIG_104_QUAD_8) +=3D 104-quad-8.o +obj-$(CONFIG_FTM_QUADDEC) +=3D ftm-quaddec.o +obj-$(CONFIG_I8254) +=3D i8254.o +obj-$(CONFIG_INTEL_QEP) +=3D intel-qep.o obj-$(CONFIG_INTERRUPT_CNT) +=3D interrupt-cnt.o -obj-$(CONFIG_RZ_MTU3_CNT) +=3D rz-mtu3-cnt.o -obj-$(CONFIG_STM32_TIMER_CNT) +=3D stm32-timer-cnt.o -obj-$(CONFIG_STM32_LPTIMER_CNT) +=3D stm32-lptimer-cnt.o -obj-$(CONFIG_TI_EQEP) +=3D ti-eqep.o -obj-$(CONFIG_FTM_QUADDEC) +=3D ftm-quaddec.o obj-$(CONFIG_MICROCHIP_TCB_CAPTURE) +=3D microchip-tcb-capture.o -obj-$(CONFIG_INTEL_QEP) +=3D intel-qep.o -obj-$(CONFIG_TI_ECAP_CAPTURE) +=3D ti-ecap-capture.o +obj-$(CONFIG_RZ_MTU3_CNT) +=3D rz-mtu3-cnt.o +obj-$(CONFIG_STM32_TIMER_CNT) +=3D stm32-timer-cnt.o +obj-$(CONFIG_STM32_LPTIMER_CNT) +=3D stm32-lptimer-cnt.o +obj-$(CONFIG_TI_ECAP_CAPTURE) +=3D ti-ecap-capture.o +obj-$(CONFIG_TI_EQEP) +=3D ti-eqep.o + + --=20 2.43.0 From nobody Fri Dec 19 03:42:46 2025 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (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 79A0D33BBCD for ; Wed, 17 Dec 2025 07:50:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765957823; cv=none; b=pPI+jLbd40f37fQVeCS1uyGhTiHsB1e532D0MzqCQoMRy2A063WlrU00itSx6BSnklA/RaVt8y5yYwPdAGkQGoskTXpylSR2FYs8QHpxRXWttEh58bbkixifiVIZtITU9WQlO+AOMMe0z08xrxSZelkh1mtF9PXrYrhJSfrModA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765957823; c=relaxed/simple; bh=rRE+Pn6uRjeIMKhh5F8RB2UlR4gSdwImg4JvNVWYId0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=c60Uuk+SPyleShqOY8comIxR7hIuijWzNd16NzmjubeiPcp11JdEtk1oL+WSLzLEPGdTVuCDN9yNCOUlr/0fi/FweZ0BCh7fMvuLDQy6fsflua5V80iZz7Qe7231pk13qEcK0eQsWlE7TAeCBaztKJsXjHSYRBG07/33wJXfohw= 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=VXTNWBt7; arc=none smtp.client-ip=209.85.128.43 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="VXTNWBt7" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-477ba2c1ca2so59864845e9.2 for ; Tue, 16 Dec 2025 23:50:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765957820; x=1766562620; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4cI6o8go+UXL/S5TqQXusywCs+KEzzJC/G+A907W08g=; b=VXTNWBt7ds+4RtgsA2e/Xe9hkG2AUuB7OFXtmQ3k+Go8hKRJ3XJtoely6IKdVbd7Cd ME3Y8AEfSi20WvdfC5XqlwfQI9/m0pPvZX32Oaa7muGUZyZ4w1MzZnxXLeNbjVhf4snx BOE0YwXLEEraevD6d/TYDfpuQ/cft6SQ3owokz5QKt/ilm8bNFxiSHcAnmOZm0pfPIPs ifr9dk8geHJp2aNVI39VWXVj+tZths2MwBnt/c6f2Y5W0rqjJnJn7TplBb3eHpu/0r+/ inOEal8INVNEBnumvrwddvEknOSuati6x3QvyflYf3qn0wjRHwpeQgHCQGidN4ACeZDT d1Ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765957820; x=1766562620; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=4cI6o8go+UXL/S5TqQXusywCs+KEzzJC/G+A907W08g=; b=eKXKKfOEPeu4HfpdJ5Um0mQw97WxI15dfs5HoJkxGWWpIgQWgeW4yzcJbSOHXTxajU opxa8WOC0FRiU7HFitlRwkyEeJjx2TrBr5fK72hRtEC9ItMmCj6eaJBvPinyzjVP0WKC 2EMAAUz2YO7Ra3IRuB3PkjVPqDddGNlcVLHRdpoLpzUIG2rBljZ4s65T9YEt/q2JGH7s kQulPXKT02Zmt+WHu3Zd3pIP+zDKQ0ZdLsHnwodSfG8gr9DKObSRhZkeJB4qvwJjKtv9 4clAp5iybJCpc71BIyFIMd8aIGR5/0kDVtexCR30tS7pfUoxzo1I0NY7A61Ot15z3Doi w0sQ== X-Forwarded-Encrypted: i=1; AJvYcCUecIaO8w5x+dCYq+8dHO+rroQOfLqyrQ/QTaaeV5rGTXKE7JrtBIwNJvB5slOzLmRBuCg77pCVyWYFuLg=@vger.kernel.org X-Gm-Message-State: AOJu0Yz5BTdysme0jcOeHhzor88gaMtPi0LP6Q43yIkIrensQFZE0dpV BndlxU6lmaZZTOuwc+bTm7VfSci9fg0jXIYXFxMtuls/wLzB/BDB8Qp+ZpjHMffHEFU= X-Gm-Gg: AY/fxX60ei3VWDe/1Rg7R2RrxpobHoslZm+TRZ+5oXf4Tof7Ktdu4BpNXzHPwKI5JY+ 6K34fCDiY1vRECrgqFsI7nohn699XwytyoH1QBqqsrLS0lsSPKP8vM5B+QYC6klf/Q31N99sQ0+ ehxO03B6tqE2Xcq4zyidL5SjJj7C9m40itIrtHusy3yzNLdiCJl6UGFXwSkLdkrJn+BpFZyF1+c 4VB0UuNwq7VEr28wECb64SnuHyhy/00tuC/A1PbL9Odxc7FjJcVIDeFolhH7AFKmYBSVt1D/c+v mZEIxtWik37hDtXyOduO+bwFZEgRurqKRfvW4JOmsei6as1tv6/vUduYXah1JGN89Brb3SLzGCH 4vT1MCsD1BWpMCP0N72yatofeVkkLSeuz1vuQPgYIZtOuVI/e4Na6mbcER3XNL9dUMJuuZwWdWA c43l4CS13JIFaHdEOr/6a8dWD3T2EaBps= X-Google-Smtp-Source: AGHT+IHUt4H0d4IVMI4vL/GyjK6b+P3BJ1v53Cknxck8AjlUtvfUSe1tsqrmrYziamrC2AoPcIxuOA== X-Received: by 2002:a05:600c:4595:b0:479:3a87:2092 with SMTP id 5b1f17b1804b1-47a8f9145edmr164663625e9.36.1765957819748; Tue, 16 Dec 2025 23:50:19 -0800 (PST) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:37e6:ed62:3c8b:2621]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47bdc1edff5sm26094315e9.14.2025.12.16.23.50.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Dec 2025 23:50:19 -0800 (PST) From: Daniel Lezcano To: wbg@kernel.org, robh@kernel.org, conor+dt@kernel.org, krzk+dt@kernel.org Cc: s32@nxp.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, Maxime Coquelin , Alexandre Torgue , linux-stm32@st-md-mailman.stormreply.com (moderated list:ARM/STM32 ARCHITECTURE), linux-arm-kernel@lists.infradead.org (moderated list:ARM/STM32 ARCHITECTURE) Subject: [PATCH v3 2/3] dt-bindings: counter: Add NXP System Timer Module Counter Date: Wed, 17 Dec 2025 08:49:56 +0100 Message-ID: <20251217075000.2592966-3-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251217075000.2592966-1-daniel.lezcano@linaro.org> References: <20251217075000.2592966-1-daniel.lezcano@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add the System Timer Module description found on the NXP s32 platform when it is used as a counter and the compatible for the s32g2 variant. Reviewed-by: Rob Herring (Arm) Signed-off-by: Daniel Lezcano --- .../bindings/counter/nxp,s32g2-stm-cnt.yaml | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 Documentation/devicetree/bindings/counter/nxp,s32g2-stm= -cnt.yaml diff --git a/Documentation/devicetree/bindings/counter/nxp,s32g2-stm-cnt.ya= ml b/Documentation/devicetree/bindings/counter/nxp,s32g2-stm-cnt.yaml new file mode 100644 index 000000000000..4d42996f5ad3 --- /dev/null +++ b/Documentation/devicetree/bindings/counter/nxp,s32g2-stm-cnt.yaml @@ -0,0 +1,64 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/counter/nxp,s32g2-stm-cnt.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: NXP System Timer Module (STM) + +maintainers: + - Daniel Lezcano + +description: + The System Timer Module 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 channe= l. + The counter is driven by the STM module clock divided by an 8-bit presca= le + value. + +properties: + compatible: + oneOf: + - const: nxp,s32g2-stm-cnt + - items: + - const: nxp,s32g3-stm-cnt + - const: nxp,s32g2-stm-cnt + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + clocks: + items: + - description: Counter clock + - description: Module clock + - description: Register clock + + clock-names: + items: + - const: counter + - const: module + - const: register + +required: + - compatible + - reg + - interrupts + - clocks + - clock-names + +additionalProperties: false + +examples: + - | + #include + + timer@4011c000 { + compatible =3D "nxp,s32g2-stm-cnt"; + reg =3D <0x4011c000 0x3000>; + interrupts =3D ; + clocks =3D <&clks 0x3b>, <&clks 0x3c>, <&clks 0x3c>; + clock-names =3D "counter", "module", "register"; + }; --=20 2.43.0 From nobody Fri Dec 19 03:42:46 2025 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (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 09B7B33ADBE for ; Wed, 17 Dec 2025 07:50:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765957826; cv=none; b=U4HZRqPqyOH/UYTqRpkAL3Ey84ILW8Qe7gIsCUG8SBUscyZ3P6aqA6Pkpxmp7bWdjVbK9sgykGXeLVAGFsKFUPjwLlDYiktIHZHcE3cmz5ZxwsZCJuAU2dJ6Aj2hSpboAj0NrKFdBesOTHuuRBwZmKjBQqrPTV84A9EAj2aQZ2E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765957826; c=relaxed/simple; bh=Fqv9y7a9HPIIUX574t6eHC7roCbUyY72GmQtdqF+kd0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NzaiVV8Yiu2Bt95IWjHcjjoq6VMy/udpdAl+6CxroOVpRlHGJiMM7MR8m5GU2yEwbN2f3r7WuJ/PQETiaJ6UQn2qHWIF2weOuruePaO4jGheJOYsXkdN8cUIcAmhFeVBS0vUzXV89+MK+FGQed/bdomSLceMtC/zIpPPLUHvT9s= 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=nbHxNbPt; arc=none smtp.client-ip=209.85.128.42 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="nbHxNbPt" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-477ba2c1ca2so59865165e9.2 for ; Tue, 16 Dec 2025 23:50:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765957821; x=1766562621; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3mEDspWRxu8ev/Lf8BHmK/EnPiZCfkr2HvPb/NoKe5Q=; b=nbHxNbPtHc6WfYDXuz+gvj46AdVEV8XlNX8yDBOSmIatwLQT1GQyRRMs5KcfLCXiGx /BrCOutYPIG3dly7QB2s9dnyNSSQEPg1/XrYuu89iEn2r43You7xQ82D4HhBsfFSQalm SoX7rZt2GjEG5kXx9yKr1cs3uct8oS8ZyITg9akyunKTBkpQd3iIAbhM1YiCj9/y4DSF VEWVvHlg5ENl10i27S+AhnacUOopk6CFZx5J3iARioiSwloS4/dDNg4SjZ1j9+MbnoTC j1TpgKPZyUV2VWBC+AJrvikbLpGgdMWfKC8qnT7nLBSWLZ6ZOQLypeQWfBJ32gv2w/sT U2bQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765957821; x=1766562621; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=3mEDspWRxu8ev/Lf8BHmK/EnPiZCfkr2HvPb/NoKe5Q=; b=k8TiN+xOy3hO4MFWlsy5CPZISAodjBoNwqX96kdvnrhwk8Pj9DQG1dtQqxKmV9Bb07 Tqw7+NFozIfTxaKpOQiXbr0EqpDrB9cQAyrBVACTTWnG4+WJLYWEni0kozJ2gxMfMytq 9wOccroPihCzXLEVJiKT7Q+5ig5VFWO0HY2hf1iCqxAgxqib4lPPNztTbyb5aa6Dvl0w KxLLCjThdrWAUfls3rhqYtR1oWPlsC/cpJLTI/Z0XIGdKwh970LhQJdSb0nhRzMwuJ/v ityHIliQj/hP1m6sXN4vvPH8KMxYeULdnEFvf78Y1WyAW7EAg5YldHfE9zFBPvCyoYYS jkxQ== X-Forwarded-Encrypted: i=1; AJvYcCW3ZdVSZKttJQmtcQd2HCdo8Gp0LXGkii/MlYSDuKb7tcKO462eQNqkcpsX/Jgu9mXFwcOtFCSZECVNgeE=@vger.kernel.org X-Gm-Message-State: AOJu0Yxks/IvER5/cjG3QtrJ0wWCE13NSJzJOYN7VsyswFdM7V03viIc y/6WY4jvES/LHxx6pKwEX/7gwbw6CTxIGPHESZ34lbbfrRu8/jqYrZsgEPARTsFIk14= X-Gm-Gg: AY/fxX4LAFR7kJTYnC82UHvCN2yq9hJpTf9dNF/tsVAArH+0j1NJ4y0hsZ9VzQTm7QK Pcn7Mk6kaxxs0Ze+xOiIAXerSQPErP+Wwkkm0UQhGvDXxGJ55Txybqk5+GF7y194/9QkiDRZzGA 6Z0ArWktoS68i2qtzMhfnDr2HxuJuFSc1On46Q0A/MZk8WjQElui3wvlvpOdNZ6SL3JP5qfgbWz ENmRMH3Wh0r00dhhG3h79HlZDwo/Shu7aoJahrJkn9py7FQtay3UUWp3eBLqVDz3RqQp/JBaHjK pBd4MFpcZJfPdhN2xR6W+46UXOcVuDwTH+PmkH4bOhUvTp2eO+9fYY1QsnlpzjrUNE47rSldxNz dtSfP062XtZ8eJ/o7cT3FzMndRaYh8n6E4pOYJcQL7D5rSGqSPwvCu2KggzND2flSROVcuPwVsv 0D2tiz8UxgI8Lzd6VuL+KCIk/TgUMDsKo= X-Google-Smtp-Source: AGHT+IE5wiDfaK/vzIGieNFAGeN1n7bTb5hWPHvlVtjJbKESFVmmsC3/l1Mw+mozuxMdTSpQ8GYC6A== X-Received: by 2002:a05:600c:4e54:b0:477:9eb8:97d2 with SMTP id 5b1f17b1804b1-47a8f8a7092mr197954635e9.8.1765957821327; Tue, 16 Dec 2025 23:50:21 -0800 (PST) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:37e6:ed62:3c8b:2621]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47bdc1edff5sm26094315e9.14.2025.12.16.23.50.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Dec 2025 23:50:20 -0800 (PST) From: Daniel Lezcano To: wbg@kernel.org, robh@kernel.org, conor+dt@kernel.org, krzk+dt@kernel.org Cc: s32@nxp.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, Maxime Coquelin , Alexandre Torgue , linux-stm32@st-md-mailman.stormreply.com (moderated list:ARM/STM32 ARCHITECTURE), linux-arm-kernel@lists.infradead.org (moderated list:ARM/STM32 ARCHITECTURE) Subject: [PATCH v3 3/3] counter: Add STM based counter Date: Wed, 17 Dec 2025 08:49:57 +0100 Message-ID: <20251217075000.2592966-4-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251217075000.2592966-1-daniel.lezcano@linaro.org> References: <20251217075000.2592966-1-daniel.lezcano@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The NXP S32G2 automotive platform integrates four Cortex-A53 cores and three Cortex-M7 cores, along with a large number of timers and counters. These hardware blocks can be used as clocksources or clockevents, or as timestamp counters shared across the various subsystems running alongside the Linux kernel, such as firmware components. Their actual usage depends on the overall platform software design. In a Linux-based system, the kernel controls the counter, which is a read-only shared resource for the other subsystems. One of its primary purposes is to act as a common timestamp source for messages or traces, allowing correlation of events occurring in different operating system contexts. These changes introduce a basic counter driver that can start, stop, and reset the counter. It also handles overflow accounting and configures the prescaler value. Signed-off-by: Daniel Lezcano --- drivers/counter/Kconfig | 10 + drivers/counter/Makefile | 1 + drivers/counter/nxp-stm-cnt.c | 386 ++++++++++++++++++++++++++++++++++ 3 files changed, 397 insertions(+) create mode 100644 drivers/counter/nxp-stm-cnt.c diff --git a/drivers/counter/Kconfig b/drivers/counter/Kconfig index d30d22dfe577..bf5b281f194c 100644 --- a/drivers/counter/Kconfig +++ b/drivers/counter/Kconfig @@ -90,6 +90,16 @@ config MICROCHIP_TCB_CAPTURE To compile this driver as a module, choose M here: the module will be called microchip-tcb-capture. =20 +config NXP_STM_CNT + tristate "NXP System Timer Module Counter driver" + depends on ARCH_S32 || COMPILE_TEST + help + Select this option to enable the NXP System Timer Module + Counter driver. + + To compile this driver as a module, choose M here: the + module will be called nxp_stm_cnt. + config RZ_MTU3_CNT tristate "Renesas RZ/G2L MTU3a counter driver" depends on RZ_MTU3 diff --git a/drivers/counter/Makefile b/drivers/counter/Makefile index 40e644948e7a..196b3c216875 100644 --- a/drivers/counter/Makefile +++ b/drivers/counter/Makefile @@ -12,6 +12,7 @@ obj-$(CONFIG_I8254) +=3D i8254.o obj-$(CONFIG_INTEL_QEP) +=3D intel-qep.o obj-$(CONFIG_INTERRUPT_CNT) +=3D interrupt-cnt.o obj-$(CONFIG_MICROCHIP_TCB_CAPTURE) +=3D microchip-tcb-capture.o +obj-$(CONFIG_NXP_STM_CNT) +=3D nxp-stm-cnt.o obj-$(CONFIG_RZ_MTU3_CNT) +=3D rz-mtu3-cnt.o obj-$(CONFIG_STM32_TIMER_CNT) +=3D stm32-timer-cnt.o obj-$(CONFIG_STM32_LPTIMER_CNT) +=3D stm32-lptimer-cnt.o diff --git a/drivers/counter/nxp-stm-cnt.c b/drivers/counter/nxp-stm-cnt.c new file mode 100644 index 000000000000..36463fcbc9df --- /dev/null +++ b/drivers/counter/nxp-stm-cnt.c @@ -0,0 +1,386 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright 2018,2021-2025 NXP + * Copyright 2025 Linaro Limited + * + * Author: Daniel Lezcano + * + * NXP S32G System Timer Module counters: + * + * 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). It has ability to stop the timer + * in Debug mode + * + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define STM_CR(__base) (__base) +#define STM_CR_TEN BIT(0) +#define STM_CR_FRZ BIT(1) +#define STM_CR_CPS_MASK GENMASK(15, 8) + +#define STM_CCR0(__base) ((__base) + 0x10) +#define STM_CCR_CEN BIT(0) + +#define STM_CIR0(__base) ((__base) + 0x14) +#define STM_CIR_CIF BIT(0) + +#define STM_CMP0(__base) ((__base) + 0x18) + +#define STM_CNT(__base) ((__base) + 0x04) + +#define STM_ENABLE_MASK (STM_CR_FRZ | STM_CR_TEN) + +struct nxp_stm_cnt { + spinlock_t lock; + void __iomem *base; + u64 overflow; + u32 counter; + u8 prescaler; + bool is_started; +}; + +static void nxp_stm_cnt_enable(struct nxp_stm_cnt *stm_cnt) +{ + u32 reg; + + reg =3D readl(STM_CR(stm_cnt->base)); + + reg |=3D STM_ENABLE_MASK; + + writel(reg, STM_CR(stm_cnt->base)); +} + +static void nxp_stm_cnt_disable(struct nxp_stm_cnt *stm_cnt) +{ + u32 reg; + + reg =3D readl(STM_CR(stm_cnt->base)); + + reg &=3D ~STM_ENABLE_MASK; + + writel(reg, STM_CR(stm_cnt->base)); +} + +static void nxp_stm_cnt_ccr_disable(struct nxp_stm_cnt *stm_cnt) +{ + writel(0, STM_CCR0(stm_cnt->base)); +} + +static void nxp_stm_cnt_ccr_enable(struct nxp_stm_cnt *stm_cnt) +{ + writel(STM_CCR_CEN, STM_CCR0(stm_cnt->base)); +} + +static void nxp_stm_cnt_set_overflow(struct nxp_stm_cnt *stm_cnt) +{ + writel(UINT_MAX, STM_CMP0(stm_cnt->base)); +} + +static u32 nxp_stm_cnt_get_counter(struct nxp_stm_cnt *stm_cnt) +{ + return readl(STM_CNT(stm_cnt->base)); +} + +static void nxp_stm_cnt_set_counter(struct nxp_stm_cnt *stm_cnt, u32 count= er) +{ + writel(counter, STM_CNT(stm_cnt->base)); +} + +static void nxp_stm_cnt_set_prescaler(struct nxp_stm_cnt *stm_cnt, u8 pres= caler) +{ + u32 reg; + + reg =3D readl(STM_CR(stm_cnt->base)); + + FIELD_MODIFY(STM_CR_CPS_MASK, ®, prescaler); + + writel(reg, STM_CR(stm_cnt->base)); +} + +static u8 nxp_stm_cnt_get_prescaler(struct nxp_stm_cnt *stm_cnt) +{ + u32 reg =3D readl(STM_CR(stm_cnt->base)); + + return FIELD_GET(STM_CR_CPS_MASK, reg); +} + +static bool nxp_stm_cnt_is_started(struct nxp_stm_cnt *stm_cnt) +{ + u32 reg; + + reg =3D readl(STM_CR(stm_cnt->base)); + + return !!FIELD_GET(STM_CR_TEN, reg); +} + +static void nxp_stm_cnt_irq_ack(struct nxp_stm_cnt *stm_cnt) +{ + writel(STM_CIR_CIF, STM_CIR0(stm_cnt->base)); +} + +static irqreturn_t nxp_stm_cnt_irq(int irq, void *dev_id) +{ + struct nxp_stm_cnt *stm_cnt =3D dev_id; + + nxp_stm_cnt_irq_ack(stm_cnt); + + spin_lock(&stm_cnt->lock); + stm_cnt->overflow++; + spin_unlock(&stm_cnt->lock); + + return IRQ_HANDLED; +} + +static void nxp_stm_cnt_start(struct nxp_stm_cnt *stm_cnt) +{ + nxp_stm_cnt_ccr_enable(stm_cnt); + nxp_stm_cnt_set_overflow(stm_cnt); + nxp_stm_cnt_enable(stm_cnt); +} + +static void nxp_stm_cnt_stop(struct nxp_stm_cnt *stm_cnt) +{ + nxp_stm_cnt_disable(stm_cnt); + nxp_stm_cnt_irq_ack(stm_cnt); + nxp_stm_cnt_ccr_disable(stm_cnt); +} + +static int nxp_stm_cnt_overflow_read(struct counter_device *counter, + struct counter_count *count, u64 *val) +{ + struct nxp_stm_cnt *stm_cnt =3D counter_priv(counter); + unsigned long irqflags; + + spin_lock_irqsave(&stm_cnt->lock, irqflags); + *val =3D stm_cnt->overflow; + spin_unlock_irqrestore(&stm_cnt->lock, irqflags); + + return 0; +} + +static int nxp_stm_cnt_overflow_write(struct counter_device *counter, + struct counter_count *count, u64 val) +{ + struct nxp_stm_cnt *stm_cnt =3D counter_priv(counter); + unsigned long irqflags; + + spin_lock_irqsave(&stm_cnt->lock, irqflags); + stm_cnt->overflow =3D val; + spin_unlock_irqrestore(&stm_cnt->lock, irqflags); + + return 0; +} + +static int nxp_stm_cnt_reset_write(struct counter_device *counter, + struct counter_count *count, u8 val) +{ + struct nxp_stm_cnt *stm_cnt =3D counter_priv(counter); + + nxp_stm_cnt_set_counter(stm_cnt, 0); + spin_lock(&stm_cnt->lock); + stm_cnt->overflow =3D 0; + spin_unlock(&stm_cnt->lock); + + return 0; +} + +static int nxp_stm_cnt_prescaler_read(struct counter_device *counter, + struct counter_count *count, u8 *val) +{ + struct nxp_stm_cnt *stm_cnt =3D counter_priv(counter); + + *val =3D nxp_stm_cnt_get_prescaler(stm_cnt); + + return 0; +} + +static int nxp_stm_cnt_prescaler_write(struct counter_device *counter, + struct counter_count *count, u8 val) +{ + struct nxp_stm_cnt *stm_cnt =3D counter_priv(counter); + + nxp_stm_cnt_set_prescaler(stm_cnt, val); + + return 0; +} + +static int nxp_stm_cnt_count_enable_write(struct counter_device *counter, + struct counter_count *count, u8 enable) +{ + struct nxp_stm_cnt *stm_cnt =3D counter_priv(counter); + + if (enable) + nxp_stm_cnt_start(stm_cnt); + else + nxp_stm_cnt_stop(stm_cnt); + + return 0; +} + +static int nxp_stm_cnt_count_enable_read(struct counter_device *counter, + struct counter_count *count, u8 *enable) +{ + struct nxp_stm_cnt *stm_cnt =3D counter_priv(counter); + + *enable =3D nxp_stm_cnt_is_started(stm_cnt); + + return 0; +} + +static struct counter_comp stm_cnt_count_ext[] =3D { + COUNTER_COMP_COUNT_BOOL("reset", NULL, nxp_stm_cnt_reset_write), + COUNTER_COMP_COUNT_U8("prescaler", nxp_stm_cnt_prescaler_read, nxp_stm_cn= t_prescaler_write), + COUNTER_COMP_COUNT_U64("overflows", nxp_stm_cnt_overflow_read, nxp_stm_cn= t_overflow_write), + COUNTER_COMP_ENABLE(nxp_stm_cnt_count_enable_read, nxp_stm_cnt_count_enab= le_write), +}; + +static int nxp_stm_cnt_count_read(struct counter_device *dev, + struct counter_count *count, u64 *val) +{ + struct nxp_stm_cnt *stm_cnt =3D counter_priv(dev); + + *val =3D nxp_stm_cnt_get_counter(stm_cnt); + + return 0; +} + +static const struct counter_ops nxp_stm_cnt_counter_ops =3D { + .count_read =3D nxp_stm_cnt_count_read, +}; + +static struct counter_count nxp_stm_cnt_counts[] =3D { + { + .id =3D 0, + .name =3D "stm_cnt", + .ext =3D stm_cnt_count_ext, + .num_ext =3D ARRAY_SIZE(stm_cnt_count_ext), + }, +}; + +static int nxp_stm_cnt_suspend(struct device *dev) +{ + struct nxp_stm_cnt *stm_cnt =3D dev_get_drvdata(dev); + + stm_cnt->is_started =3D nxp_stm_cnt_is_started(stm_cnt); + + if (stm_cnt->is_started) { + nxp_stm_cnt_stop(stm_cnt); + stm_cnt->prescaler =3D nxp_stm_cnt_get_prescaler(stm_cnt); + stm_cnt->counter =3D nxp_stm_cnt_get_counter(stm_cnt); + } + + return 0; +} + +static int nxp_stm_cnt_resume(struct device *dev) +{ + struct nxp_stm_cnt *stm_cnt =3D dev_get_drvdata(dev); + + if (stm_cnt->is_started) { + nxp_stm_cnt_set_counter(stm_cnt, stm_cnt->counter); + nxp_stm_cnt_set_prescaler(stm_cnt, stm_cnt->prescaler); + nxp_stm_cnt_start(stm_cnt); + } + + return 0; +} + +static DEFINE_SIMPLE_DEV_PM_OPS(nxp_stm_cnt_pm_ops, nxp_stm_cnt_suspend, + nxp_stm_cnt_resume); + +static int nxp_stm_cnt_probe(struct platform_device *pdev) +{ + struct device *dev =3D &pdev->dev; + struct device_node *np =3D dev->of_node; + struct counter_device *counter; + struct nxp_stm_cnt *stm_cnt; + struct clk *clk; + void __iomem *base; + int irq, ret; + + base =3D devm_of_iomap(dev, np, 0, NULL); + if (IS_ERR(base)) + return dev_err_probe(dev, PTR_ERR(base), "Failed to iomap %pOFn\n", np); + + irq =3D platform_get_irq(pdev, 0); + if (irq < 0) + return dev_err_probe(dev, irq, "Failed to get IRQ\n"); + + clk =3D devm_clk_get_enabled(dev, NULL); + if (IS_ERR(clk)) + return dev_err_probe(dev, PTR_ERR(clk), "Clock not found\n"); + + counter =3D devm_counter_alloc(dev, sizeof(*stm_cnt)); + if (!counter) + return -ENOMEM; + + stm_cnt =3D counter_priv(counter); + + stm_cnt->base =3D base; + stm_cnt->overflow =3D 0; + spin_lock_init(&stm_cnt->lock); + + counter->name =3D "stm_counter"; + counter->parent =3D &pdev->dev; + counter->ops =3D &nxp_stm_cnt_counter_ops; + counter->counts =3D nxp_stm_cnt_counts; + counter->num_counts =3D ARRAY_SIZE(nxp_stm_cnt_counts); + + ret =3D devm_request_irq(dev, irq, nxp_stm_cnt_irq, IRQF_TIMER | IRQF_NOB= ALANCING, + dev_name(&counter->dev), stm_cnt); + if (ret) + return dev_err_probe(dev, ret, "Unable to allocate interrupt line\n"); + + ret =3D devm_counter_add(dev, counter); + if (ret) + return dev_err_probe(dev, ret, "Failed to register counter\n"); + + platform_set_drvdata(pdev, stm_cnt); + + return 0; +} + +static void nxp_stm_cnt_remove(struct platform_device *pdev) +{ + struct nxp_stm_cnt *stm_cnt =3D platform_get_drvdata(pdev); + + if (nxp_stm_cnt_is_started(stm_cnt)) + nxp_stm_cnt_stop(stm_cnt); +} + +static const struct of_device_id nxp_stm_cnt_of_match[] =3D { + { .compatible =3D "nxp,s32g2-stm-cnt", }, + { } +}; +MODULE_DEVICE_TABLE(of, nxp_stm_cnt_of_match); + +static struct platform_driver nxp_stm_cnt_driver =3D { + .probe =3D nxp_stm_cnt_probe, + .remove =3D nxp_stm_cnt_remove, + .driver =3D { + .name =3D "nxp-stm-cnt", + .pm =3D pm_sleep_ptr(&nxp_stm_cnt_pm_ops), + .of_match_table =3D nxp_stm_cnt_of_match, + }, +}; +module_platform_driver(nxp_stm_cnt_driver); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Daniel Lezcano"); +MODULE_DESCRIPTION("NXP System Timer Module counter driver"); +MODULE_IMPORT_NS("COUNTER"); --=20 2.43.0