From nobody Fri Dec 19 11:45:26 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 A48FC21858D for ; Mon, 8 Dec 2025 03:05:40 +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=1765163142; cv=none; b=STLpTU9uJDMBBtmF6ETd4fVUXBX0OLmZBOyuwhJe5G6in/PchLf/VP2/ZyJ+Us8UBFTn/GGIOwXF/M8rkTkoWZ+FYeuIkN2WkHGx8AEpzNUpnfaHuPs0tAmP7Qce4EX1viCd3kIyRdsFJDxkj2mr79C19D2LN/BXqMDq4+Rb8LU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765163142; c=relaxed/simple; bh=m0D9V4x0TDiYMScx+B2rDcfNHpt1W4utB08H2EYXkTI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=km1RtohJCnO/q9+pmFUDcDt9yBi0BnvS6TtNJTo37NSg/pWrvhZ7AisRgqLnO19aEGB+0mtW+H1RZuTqQeml9FzZDPw0LpJtQvh0MYp9Okr00cJSh1VvZYdfHU0/RXuMxS8Cff29ndRZuBGbsYmTo1nqclAhaljnTzS1X/ZJgIE= 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=R8wa295u; 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="R8wa295u" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-477619f8ae5so31067155e9.3 for ; Sun, 07 Dec 2025 19:05:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765163138; x=1765767938; 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=R8wa295uhw5LPI5x8KhwsVKi+4n0nWN8AnA9AXPBx8yC8MvAieTb73BjI/jqvDTWEp t8nu3/Qtye8F1DP9Tb0pj3F2JdSiYEvV59zs7UIZon+FzjBDkuninZDIIHUruOnE5IYl JLUtuoVN8N2KED801sOLqBDT9dzGzE00eqiM2NZYWAM+uKqIfKQfdzbozD9nMDecUdwi Z7UmVG7/UgWZ+G9Mtg7uE/8CFL74hAJkhpr7Vzr6E1f/m5pccjChkRkpzS0H843jhxPQ hMlaUX1xKYI64YCaxXGrpobvRxd2rii/1aJBBZxvnhv0ULVlqboZ2zwGDsTB/dAc4Qxg /Jqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765163138; x=1765767938; 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=jAd6bFdopOPSOXu4eng0axSlA5XM36skEhz6mhv8aivQMp7XG8aGzw8mik45owG5ki EdGgbFVeU9kcq6LFN0F7/KR4QMqeVqcCYrkvOP+eqbX89XIU0PSTNauWKa608xCUCxB2 bDozEaB5GnN/gIy9XdBGfl/YeeNzPBkvTU+Su+Y9MozpjUfy5C49fFY15VX8k9Q6NX/B bef5H3Q8fCbJKugccVm2TRVRo1NnxICj0P5U4cO7MeZnukO5bvILvI1BXGV8/t/85WQN BgC73ePN/df74WXefqEZcoio3RpNCXXCwquRJfVEJ5vUgVSybAwSXPBXB5xrdBe7bSae jhRQ== X-Forwarded-Encrypted: i=1; AJvYcCUKyhIg039Hx2CjYEHcQDAfqtyMT4U4t1YlXA2UgyqDZ5jlPpRdnedAKPCWLnb3TnSvyC4b1fZHYLOh6KU=@vger.kernel.org X-Gm-Message-State: AOJu0YwJ4NRwkcej6pPrOG+/k3VSgse4JLnvJzIczn9mo7GByCcUILPR ZNefUENmM4zruZ/A8wqDFr/UCuQn/IOAibfgt9zuLBK/ZKBTHMu9B2Nq0N/zAbQBIoE= X-Gm-Gg: ASbGnctSAHnp3FSg2xofqldhOfUTcn1wtr3VabOfqzovRg2D3bq5ifm9Ov6KgctDx+6 EcSLLGrgoSmbHh+8pEIvfrrn9wVDFnEezMjkMs7oHVTtZNkwkcW3TLnnhbg1wdvk2gtqEaMWw7s rKW1JIpk8TqqSqI/FxXyHq/f8rHQOfDb78CV5ldjmIbvIugH3anEtQK2YT7nKqqryxj171XYs8R XswkOpQL+cSbZGevD0xjMW8NYroXZcWczl064AEF3N5/Lbh6zywlyJw9c6CQNZAnu3hqltu1osu zUFXuhuwdk8rk+r21VomiXyi4Vd8/oi+V2PB9g7FwLhtJUxdqCz9IZJgjWPDmYVCj0AEOYp7s6N qfmCUrU+dvPy/zrYZqQA3ia69ZW+OO/heL4SQJMjrnla2Uj6VuV/0Ig9JCxkVzw4p779oiYzaJd pPZoe0MW5zU1Jt/WMCd+dCA5Ban2IprCfEPy4whwCKTA== X-Google-Smtp-Source: AGHT+IE5NLuFXDyXwZeEfScNoLU+uyHbkMSa7QkD1GDahbK5J8VDnVXB/PQgU5tmn4TB0uE2IXuIpg== X-Received: by 2002:a05:600c:4e55:b0:477:df7:b020 with SMTP id 5b1f17b1804b1-47939e1cac1mr60317925e9.18.1765163138213; Sun, 07 Dec 2025 19:05:38 -0800 (PST) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:37e6:ed62:3c8b:2621]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-479310b8e70sm220564885e9.5.2025.12.07.19.05.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Dec 2025 19:05:37 -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 v1 1/3] counters: Reorder the Makefile Date: Mon, 8 Dec 2025 04:04:11 +0100 Message-ID: <20251208030413.3117660-2-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251208030413.3117660-1-daniel.lezcano@linaro.org> References: <20251208030413.3117660-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 11:45:26 2025 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (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 F31B6168BD for ; Mon, 8 Dec 2025 03:05:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765163149; cv=none; b=kUoB9HXa29mzPsRrF4mhi8b9Ns6MN83WHGh+EluHKUBkKSVhERotQxl1KukQWRWNmmHoJgq4OPA4xSwAF5L+15IIJJpOjz6kCLwLtT3vt4b1xfU9ffmolBJbmfa3/3aQnv2gykH3oseymHYY1bwLNLoBSEv3xfFs9lPfnKAVQ0w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765163149; c=relaxed/simple; bh=sCRqVl7K3M0fY0HQHMfz4uoNLVMybTWLicOnAms2XpQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BfP6kF98e2Hy2Zsaq4+OFkT1U+Ci5J5L7usF6uK/oryFL6TXtzN2EfVhN2U5o7lbxo5paSm7SY0Dep0iWvcdPe5iUyY9sXkk+tnLqp1APYprMKFPohperfQvJMt5FwtIgj0DPqZPr43nyrjqqepO1y+s5dU9+Wli2T+2lqCW0pQ= 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=vuXAV9Oy; arc=none smtp.client-ip=209.85.128.49 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="vuXAV9Oy" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-477770019e4so42203195e9.3 for ; Sun, 07 Dec 2025 19:05:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765163139; x=1765767939; 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=31YJF8mMxnr+LqmRtwQssQbvEbeKZ9gZ0EQ+P+M9XPs=; b=vuXAV9Oyg8aU3Ig0w8zSJNedgIXqnt9PoT5FP69SGntaKDHFPWVHP4j2UvO28SLLCq NDxpdxqkf8zC/jiKgfBYn/VeXvNZ+X6PuE3qgiMs1NbvZVTci8Sz7j5moHshKoNZjCp9 vlG3pKSjGvjXbgbEeJDk6FWAwizctgK0wdVU8WZFTYe2fhmTR4866Fhb24FrjdnnMoNW 1Av2RaQeMtDYX1LM9+DAstQ+Q1S0WNUyyUU/8hQQ3yt0f3C7oOcTIg+bVRAdfKrfF17m Ecarge3yUfqgr8Ew/g1y4iqvFgCEgRLYzAwWGqbYutZcutXj1Ir+zogcEYvWsEebN9V2 glbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765163139; x=1765767939; 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=31YJF8mMxnr+LqmRtwQssQbvEbeKZ9gZ0EQ+P+M9XPs=; b=kcuzqUmKu/lnETvYa6KPmh01zfWbRcKVp29eKOVJGQG8gtQjvHPO8Dt710662+Ohga d2kQyF+nCN4qPsoN6kS9D5LvfzveG7b6b088dbujNKWUldo2gakL0Mw6W9nkxfv0DvCC VXveqyZe+CqyVH/tyGIf3GmUk9nPzfmf6Xt5akPM0yPBoVvdhpkINkdBqnfAHracpwI7 sk7DFNyqtUaL3m1cshQDUITOKujdIAAlNI9M/uUKZXV/OBOmxvQhXJuPTj55jET9QVA4 H/FlVvTzfbjP1x5v2+HaPtCqMflW1FIM+rfILnrYlf231dLFZHh21ZEFrwwdWWKe0KrB m7vA== X-Forwarded-Encrypted: i=1; AJvYcCW0toBVUPaT8ZB801Q4rG73ghQ51zY39hbXDwKL6pD3EIrPa7YtP+lfMNL/qro7WKP/MFid5kRGkRI5qLs=@vger.kernel.org X-Gm-Message-State: AOJu0YyrSdlbnhShLjqYr0dKfwdLGfijEVLZcs9ZDL1pnMzGFOTUThHv GU6OrWVtPmjWKTYEDDqIbCYB2JQG3TFCqCas7+nFzb/N6+9HkLWBuEIS80kZBJCzChQ= X-Gm-Gg: ASbGnctM/7KIcwUxTdNxlzBfBfp9ByhdNJGnWXEOHOfWEFG52MgxDTUHhrAY0sI02c+ /b2hi6O260g8/a4PjfRRF6XEJgeQGJtK1fn0mtTKm9g0sWShXA5Tr/h6RAWRK9X1/GUDaChNG6M xWOTpKPPhGPMYGAC3dmT6pHFpZc3i7wh7F0r3DtXNZZ0j3qa0WQ8wP6tvdr1Gu+e4AdoFSp3MN+ EI1M/e6u9PHA87Mc3RkQyf2mXSMvq5iQorwaQvy6XZmlBsTsN5O7kgUyvQ9nRQSSYdN6N1zYJbD Itx7C+521H11kWwZuXfyUd94bW8cpdz9vk2Iuw/exIxE1iqd/3ksaw8IcDrSeDDrWXg3APXoKL8 q9ly4dGAhfEA1jfzPSPR5BKtwlgdag/evpQr5u4Fj8k0UJg0WSOPhKyzxRHyMx0UBj3izuCkHVn YWMQowNxtWXyEzGvzRZ3ssqrf7QIONSrY= X-Google-Smtp-Source: AGHT+IH1x7f63RvjHVJG0byImMjDmXlGrr71B/o+nkO+iw0TVwtKQXc5NIk9o91oiM8Lr9SJh4idng== X-Received: by 2002:a05:600c:1c07:b0:477:9cc3:7971 with SMTP id 5b1f17b1804b1-47939e2464fmr68196895e9.20.1765163139118; Sun, 07 Dec 2025 19:05:39 -0800 (PST) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:37e6:ed62:3c8b:2621]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-479310b8e70sm220564885e9.5.2025.12.07.19.05.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Dec 2025 19:05:38 -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 v1 2/3] dt-bindings: counter: Add NXP System Timer Module Counter Date: Mon, 8 Dec 2025 04:04:12 +0100 Message-ID: <20251208030413.3117660-3-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251208030413.3117660-1-daniel.lezcano@linaro.org> References: <20251208030413.3117660-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. Signed-off-by: Daniel Lezcano Reviewed-by: Rob Herring (Arm) --- .../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 11:45:26 2025 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (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 9327D2E88BB for ; Mon, 8 Dec 2025 03:05:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765163148; cv=none; b=tdb/gRQPMM7iPKio9es9BGvIDOR80mD9ZzNzJnWP4L+zCMKMABRDP0TNqXyChMxJCYE0eEYsJql+hqriduTbNPyGUBiCH90ldT7AumP5s71+at7FsvRJK6XER/329dCaewp9ScJrBHS1fIbCSzlG+3yb4Q9bTdM4MLuVMz44oIY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765163148; c=relaxed/simple; bh=o3uFZj8uwjErxHYmJWATmCtv0noJuvIaMeGBEzIYSyU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qTDAZ7u4z9ALc2POJgCysbXCx0Yf+jnrekwgJy0TE95rzAMiUAQRGaMEiTkAE6dng1nPJB641Ghbsps6eNx4N9yhmBCFXzdnMGMvV1aswVzuSvI3iAftv8ljNYABV9GZzkxfi8E0QZhuH/WG/wY6P+2xPp3kmvMdmDcnPgScLII= 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=Bwz/Xdq2; arc=none smtp.client-ip=209.85.128.50 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="Bwz/Xdq2" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-477b91680f8so43820275e9.0 for ; Sun, 07 Dec 2025 19:05:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765163140; x=1765767940; 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=C2AFPBdB+zIHc08SUXdUENK7CVx17JwYuHGmDp1Nvo4=; b=Bwz/Xdq2bKa9zah8N8WzqLASazk8UycUJsNjIdB+MXrfQgPaPJGBSO7o6FMZki402O fIVxgrRH0srotRMF5s+y5MpsOF0tkxc8NbA3fpNezJ6B2TJGTfIsCjJw+b4DhgdXZzGy ggUjt6Qw+cdVNXqlYwuSt4x+NFjNdY22/TIc1K8GXstQ1WyIOLk3Q+5l09DGUI7kcicb KGwB4MJ9TaF3DbM3Ce2zk+Jw1hAg41B27ENq8dWXDn9X5k8qxfyxam+BURUquHo5pFcw xxD6QwCt8Iqf/O4tvjcaHTp+2N+iToNF5wxgLU9V57j0dBaNTTbMoPnIr5qTsiDElyAa 6fwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765163140; x=1765767940; 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=C2AFPBdB+zIHc08SUXdUENK7CVx17JwYuHGmDp1Nvo4=; b=vwqoyc623JmXDTWsmzs+DyNIUlpP2RKqV48oIduNDwXoyOxYybUAdl6PK4N5KR/QLt dj/fLK2aKauY1wreDllyRiJp18GREGJ/nr7VByDIr/IrnzgjaaVXwbXhzKhISRFU91+e nVaswyhHfsm15otG7o/t248ENJyk1OSQzKQT+09amjetelb2RFj+8Vid3KtTWDHu2prQ RyEdsxhITWCj/UbQcWLOet6NiyjRN+tDjcMkRZlDZFozJWkQXIjHHZK4yo4wIIz/+ome LHe0PRc7bX03UcvvD4hH12mjTPtsByZwMWtIizuB3M3bMoLp8cCPasxVxDaleg7avztL pgNA== X-Forwarded-Encrypted: i=1; AJvYcCWB2m4dBW72rO/lLrLjIBEUwYJr990pZDwzWkAF++pFdBJ0+p2W5nxkaxAzcwsLrtkwZkOYITbwAx1r4n4=@vger.kernel.org X-Gm-Message-State: AOJu0YzlE18C2Ia+DDjdXBI5KJG2lqcQ5GS+WCoSNtQ1vK+J1HQd9iuC 85CaowY6w8ZF3tUfLrOzCzvebwQjy9K1bXsaftugOqHdu0zWwxAGgdmPgexVWr38+Ac= X-Gm-Gg: ASbGncvBH9endpXdxP57D0kmfX7kbjIp801REfzfs1n2qPlHnnowRc78zG+t0V/QLze 9LkziDzatA+9ZlZe1AyeD9MkrXWCALTog/FEg/1O2hh5WFErHcZaO5enBeZR0y1XTCfTXzKZW6G XQM1a/1g4jXr88aTMcgQcWIVPxZALxGC5zLF6GfVPR5ShfX5Hg9IicrN2yVBOG1vYG1Ew/jXKCQ 5H3dvyY7BYv4IIkFm1IU7xAqWN1wFE6FEP0w3welsNMD185lMK581m38CYUkp66VYSOllwh67W4 kgJBC/E1AccxWlsjmjTgoJa3vONSP4Ey3n7MDPRuLvQD9PUnfKo2WNL0GhhUQbh2yKF1HBQLUCS 0vijHU8UjQDmxW7s10WNPbiaT83nVuVWXlDTL0jXO6LLXaqIttb/gJ7A/noJugRchgxo48xOcuA vIAFjQoTxVMYN/wQ0CgLt++Y+GK6znIQ4= X-Google-Smtp-Source: AGHT+IGKLOklsf1nDrQut6uW4Yzz55UBXj5Llc2oBlZGsMPLq6LC9TWgCrTRW+nJfU3U0GEBAcsBew== X-Received: by 2002:a05:600c:190d:b0:477:ae31:1311 with SMTP id 5b1f17b1804b1-47939dfa526mr61080905e9.13.1765163140067; Sun, 07 Dec 2025 19:05:40 -0800 (PST) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:37e6:ed62:3c8b:2621]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-479310b8e70sm220564885e9.5.2025.12.07.19.05.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Dec 2025 19:05:39 -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 v1 3/3] counter: Add STM based counter Date: Mon, 8 Dec 2025 04:04:13 +0100 Message-ID: <20251208030413.3117660-4-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251208030413.3117660-1-daniel.lezcano@linaro.org> References: <20251208030413.3117660-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 | 387 ++++++++++++++++++++++++++++++++++ 3 files changed, 398 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..ff6db07962f4 --- /dev/null +++ b/drivers/counter/nxp-stm-cnt.c @@ -0,0 +1,387 @@ +// 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 const struct dev_pm_ops nxp_stm_cnt_pm_ops =3D { + .suspend =3D nxp_stm_cnt_suspend, + .resume =3D 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", }, + { } +}; +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", + .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