From nobody Sun Feb 8 06:22:21 2026 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (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 7661234DB48 for ; Tue, 13 Jan 2026 16:52:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768323152; cv=none; b=O9a0j2aLSn3RAcqAhjeHh5MEf7vhBWpHASbGKLfn9YFjf04gEmjk0g5pG6N/gBcApTw1AXUrOZ169d32xcCwi+z988tLrykPnxVXd65nHgVZqCFdKj5pTPK7wzsFOi2dUu7RtLKisF1NxA9i7VimPWiLpXldKvhdjQpsvoZM3NU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768323152; c=relaxed/simple; bh=m0D9V4x0TDiYMScx+B2rDcfNHpt1W4utB08H2EYXkTI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=R4QXpp5e/gPpVLZLDqKDGfWSd5augM1HX000Gjtv0R9CZl+9uKRpvcsG20HYvmSF556bfaukv7r/QvBiAEaYUSj/6DTtOL5CmxC0O/ea9lZUVpVSVkz1LXJt3GvkMwav0lno2PQLzXEkIKaCozkEQoRMFBi7CMpbf7D8Wv402/c= 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=mD2Z9EEl; arc=none smtp.client-ip=209.85.128.47 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="mD2Z9EEl" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-477a2ab455fso71417815e9.3 for ; Tue, 13 Jan 2026 08:52:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1768323148; x=1768927948; 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=mD2Z9EElqKO/hQhsq9tOguQfawJojXnQNFJ4eey+mu+S/YDB57FMwV+D41IhXfKKvc OXqJA21UXgmBZVxarYyOCTYbPD/9HKJ6W7fhj0iSTMT1mRd3DuOUF9i/0SRg7HuNf41j 8g5owQ2OsouP+UJWETa6gn8JzTQlHJ/tpyYL7+5MI9G4DR+XniahuTtsZy80w2KfRqdE w3gpmEMVnqz+w2sq94Tz/iYd0/Hbo1XgUYZI9rW4E8KMtVXSoKtY/ur82nhM1XyRYHP7 GwPrWPlltPJdnJczlViPTIh9vslFbQH79H/ADhi62PcSg5daIjdc2arouTzrTgcgls4d l6kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768323148; x=1768927948; 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=pvbkpyFDx6DLM7hsL8wfhbFIWY0t83a4RtrPRanWNTlqHFi/APXz961vb+QMLs9qBb 7sxX4IffBX5zassQWgl6BwQJOiKC0CJdHo7w+z3n9nHlrdWb0TCj2/qktVBzaHvd+TW/ gu1kv0CAvIQ3cm0W7gNdvWN8KdATXswvmaMFNwSFxN6bBcXs9mppXqQf/RBTWiM7p4ma +uxB9YWRov0KQ7L5+DSkbp0qIJUr2yRzYGBSzA5Umtj1AmyVvSQWrUDW/eQOrA2xl8xq ykRP3mgwsNiAEXmgveL2MkOIykP7x0pMWHn6AyKjhBX8HsJS1A/wI/qWEggUCoGOI+o4 WUvw== X-Forwarded-Encrypted: i=1; AJvYcCWYrvmBj1YDljjPRwYVL+UXPkkAGv1y00vu3bi7GGq0cw/mMPe+ISUNHQhizkUXphqaelXtMR6CAGyHxxI=@vger.kernel.org X-Gm-Message-State: AOJu0YxI1r5UcT3RkVYV+EAfHEBuzPlbB3GuvCVUmRg9TInOCTn1SP+Z pMfE3BKT+PtMJQRG6X6NAvUMhaZ58myMNCd+nSbsJakxF62nIGSxWJe2f9o+42XryKU= X-Gm-Gg: AY/fxX4wu0T16RTp/DUu2R8/al8e3quESXEJ+95xi8PFcLmhXGFL2ouQWLJupXKEPwZ hjMHpYHmrAdLlWVl3n6yuhWhEsDtkd08ClvqgRsckIA1c7hSDwehI0hJyc0p0nnZuiQd0kW4H+h 97S497X6O8ta3DSFqskGS/kvmdovHwFmVLHxiIYbjRJho8uiaNgn/2Es8slzvxdwDZmnDc2HxKv D4Z19Dyf1yUf3Bvd+jPNBEG0yzjGjtDxqh+hNuHnpjSuZ5i3lZRArX81T4X2K29KkKsLtgtCudM fO4vr6Y9DK+uf4smWiH8Dy7AMvvDKWiEEPzRGNmQv0IyNiJcbEF/bqWxuWw3QeYWaUmlqOVMV7i D3LkDvBe4xJeFeZEjxNz2vXjU58lw5yX7auNHu9vUbfWDdaG9VJAGAMsynfEYWW+9swHH97ocoM Y2q0LC3iN33QBjgKwaU9oJaaSKVgPZs8U= X-Google-Smtp-Source: AGHT+IE2mf8KyPtT6cpp9Z+sIL+E+Nhzb//si5kbvx2m3OmBsCtIM58L0qqoJtaQDiBQE8qxSXV8Ag== X-Received: by 2002:a05:600c:500d:b0:477:9d54:58d7 with SMTP id 5b1f17b1804b1-47d84b3b881mr210609265e9.29.1768323147822; Tue, 13 Jan 2026 08:52:27 -0800 (PST) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:3594:70ab:9964:c5ec]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47d7f41eb3bsm431684925e9.7.2026.01.13.08.52.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jan 2026 08:52:26 -0800 (PST) From: Daniel Lezcano To: wbg@kernel.org Cc: Frank.li@nxp.com, 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 v5 1/3] counters: Reorder the Makefile Date: Tue, 13 Jan 2026 17:52:18 +0100 Message-ID: <20260113165220.1599038-2-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260113165220.1599038-1-daniel.lezcano@linaro.org> References: <20260113165220.1599038-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 Sun Feb 8 06:22:21 2026 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (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 4CCD634E74F for ; Tue, 13 Jan 2026 16:52:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768323157; cv=none; b=Z13b58ytkY66EnBbsTS76mjbjrVjhwlvZzfpNrWDob7mjR51mlEs1/07cIGe0y9wBfpajLox2V6NCE5BIaLmLtLQP10QvoZvmtMVTfCz8YxKch2tzi2tNj4VtNULSOTOxX7xGS6Gqrhu4gHlGiVnMlNshsHMRLkhhaFFePeA2ic= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768323157; c=relaxed/simple; bh=oJ9gKow6S8KEzSj2K6q1yw7J3LdgtVU6Q9IVbH+UGBA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dh1Hb5qbP7+vAqzxB19mJau+5yiGeS8wAed8VGibBmn8sgKxL9FCizvl7MDecKE1AO1Qc61LdzWwJdcmvZTahuq10BDwfL05ux72wUjHfGwNQfNEQx34wV8ScGiQ6PMva1C1Z4vZ+0dY7bkbwvc+GKGzygIBDl8TyjQ8SxDYrmo= 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=zwbBaG9E; arc=none smtp.client-ip=209.85.128.45 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="zwbBaG9E" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-47ee0291921so4161015e9.3 for ; Tue, 13 Jan 2026 08:52:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1768323149; x=1768927949; 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=2y3xJj6Lny5hNArf79Fe/OIMoyByArkbsGtk/c71GuI=; b=zwbBaG9E9CT3bHkBVCk/NesvscQ6HCIPhHJJnDHqd0Au4gCM0t22ztbvAaBj2O98hN z5q8yHR++mVuIMMn7p+el8C9vdsL05inlYW57mggWhanJ/MKLWRaW3UZuqYIHl5El69r X4TDVJGd81U1ET7fSvVIU6E289/MN9swdP2wziDvfRnBMtJs+vavyNzEuXNduy1JFwP1 MKwMXTx6KdNlZ5sZ4MJz37hboVLu9LLvRSQ8ICSIBQSjDfDvPRrBDSrjkFoRqVn7AXBB jU9tisF/eHn/S5E7+63COSmbG136NCrr/1JKgsUlZr2Zg61BBmK8W7qAF3v/DUfXXNEP y2sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768323149; x=1768927949; 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=2y3xJj6Lny5hNArf79Fe/OIMoyByArkbsGtk/c71GuI=; b=idmxrZ7/HkI+VEalO/TST46RrCJrlY4eyti0gx3IyKTw9rpfbd9o5+4Z0q9PeONBxM UiO9133mroKHxYmloK+r3K1UqoIqBcNi3y7nOxcGFAQXZau7w7xAIowc9EEHtVflA9VW tWV7aM5GEl7aQk4IIaXvnpKHrrjep/8rlvB/Jdob7YeRehxgqo4ZNoqdCpgfZ5tGpZg3 S/MGlWuDAxQR7TzEHmK+XPcsa7Nt/ycZBT9jx0mNrQxRzRyj9UbYQgKuS2AWPEBX/ebj 7q6NFgWHCLWdOaIxRlxyWnh7IzRfwMmdp3CqJRdqDqOlu/v5216ilrQ4nevI2ydfnyRW jRew== X-Forwarded-Encrypted: i=1; AJvYcCXT6oVbgzq+dtQeyu8+WKoRjC4Y1MglQAAvBdBePVJeuskCxOWzL+AUa3UgZOoLsPv9UaRKxyErowdNpiw=@vger.kernel.org X-Gm-Message-State: AOJu0YzJ4qqDvlRByHoWAByhMdozyE7WRoMijalUxHiyC2IrlBrC1Y+U EUZNDxQRqN7KtcF+2I/tVfoBt0KP9e6xUKcxpSicUMzFungTvHF2icXbE2I21Vifeng= X-Gm-Gg: AY/fxX7EybvizLpdD/2VIhqYi24tZdjvGYGyn1Vj5e3HV2mn5BOFv/XUKUGY7fJSgmb +5krgSuwT0+ZfX+wfiXSmS7LS6jeAxLtyimm8RR3xDLSgBU88YowjT6xmG2ED0PGXrNmxoIS2+l AM5k7e6CobmEFGDIQ4Bcv+9nSgSg9N7v+/fefymWPJAiva0H9IulP62NM2+G8x40xedJyRmsLsE wRCenFKxCfbzB23CDDqGvIGW8J1yuc2ipjvUxbLkw0dB83aHxdWQqinw5mlwIx74D1q3BOKpIFA z5hknelMI9+N837VqQhEVcbreCuLO+dKSmU4kAKEvaUD1wEB8ec1ECNKeMsN7wjWvrDgO4h5+W9 +r87X9MS6SR1Nyr6itqdmuhXuD1uAjxQ37o+Xwwpxxl/rNv/3aWNPWvDpEy9BrOYgdr1VFbcWZX ZmE4H6zgpBojX6NtnVTcy/hFAT/6WwtSU= X-Google-Smtp-Source: AGHT+IEicAP01cQZjkyG01ghspfKpykhlK3qAoBCk+2ayoqlIhLWC13pIjU/Acop8PMmfgPDXUsETw== X-Received: by 2002:a05:600c:444c:b0:477:7b16:5f77 with SMTP id 5b1f17b1804b1-47d84b0b303mr225376805e9.3.1768323148712; Tue, 13 Jan 2026 08:52:28 -0800 (PST) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:3594:70ab:9964:c5ec]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47d7f41eb3bsm431684925e9.7.2026.01.13.08.52.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jan 2026 08:52:28 -0800 (PST) From: Daniel Lezcano To: wbg@kernel.org Cc: Frank.li@nxp.com, 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 v5 2/3] dt-bindings: counter: Add NXP System Timer Module Counter Date: Tue, 13 Jan 2026 17:52:19 +0100 Message-ID: <20260113165220.1599038-3-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260113165220.1599038-1-daniel.lezcano@linaro.org> References: <20260113165220.1599038-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 +++++++++++++++++++ arch/arm64/boot/dts/freescale/s32g2.dtsi | 6 +- .../boot/dts/freescale/s32g274a-rdb2.dts | 10 +-- 3 files changed, 70 insertions(+), 10 deletions(-) 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"; + }; diff --git a/arch/arm64/boot/dts/freescale/s32g2.dtsi b/arch/arm64/boot/dts= /freescale/s32g2.dtsi index 51d00dac12de..6bc0c75b574f 100644 --- a/arch/arm64/boot/dts/freescale/s32g2.dtsi +++ b/arch/arm64/boot/dts/freescale/s32g2.dtsi @@ -579,7 +579,7 @@ swt6: watchdog@40208000 { }; =20 stm4: timer@4021c000 { - compatible =3D "nxp,s32g2-stm"; + compatible =3D "nxp,s32g2-stm-cnt"; reg =3D <0x4021c000 0x3000>; clocks =3D <&clks 0x3b>, <&clks 0x3c>, <&clks 0x3c>; clock-names =3D "counter", "module", "register"; @@ -588,7 +588,7 @@ stm4: timer@4021c000 { }; =20 stm5: timer@40220000 { - compatible =3D "nxp,s32g2-stm"; + compatible =3D "nxp,s32g2-stm-cnt"; reg =3D <0x40220000 0x3000>; clocks =3D <&clks 0x3b>, <&clks 0x3c>, <&clks 0x3c>; clock-names =3D "counter", "module", "register"; @@ -597,7 +597,7 @@ stm5: timer@40220000 { }; =20 stm6: timer@40224000 { - compatible =3D "nxp,s32g2-stm"; + compatible =3D "nxp,s32g2-stm-cnt"; reg =3D <0x40224000 0x3000>; clocks =3D <&clks 0x3b>, <&clks 0x3c>, <&clks 0x3c>; clock-names =3D "counter", "module", "register"; diff --git a/arch/arm64/boot/dts/freescale/s32g274a-rdb2.dts b/arch/arm64/b= oot/dts/freescale/s32g274a-rdb2.dts index ee3121b192e5..bde5d3726825 100644 --- a/arch/arm64/boot/dts/freescale/s32g274a-rdb2.dts +++ b/arch/arm64/boot/dts/freescale/s32g274a-rdb2.dts @@ -41,19 +41,15 @@ &uart1 { status =3D "okay"; }; =20 -&stm0 { +&stm4 { status =3D "okay"; }; =20 -&stm1 { +&stm5 { status =3D "okay"; }; =20 -&stm2 { - status =3D "okay"; -}; - -&stm3 { +&stm6 { status =3D "okay"; }; =20 --=20 2.43.0 From nobody Sun Feb 8 06:22:21 2026 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 71F5D1F461D for ; Tue, 13 Jan 2026 16:52:31 +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=1768323155; cv=none; b=e8JaGfDjVKsfcYbYJUkr8HaW5j5MeolwgVYVc1PqRX1MuHJN4WoWyHrr/QUZbINSwQHi0zUhtzc4xaURWnewzTG9u8CBRAT+g6k/Vosw/fezMU5zzuWz1MvjtvmlgufwUtD0uhkBviC9LhHeHrW1BnSu7TWdp+jwXejt45/8MEY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768323155; c=relaxed/simple; bh=98GkFIzSMPnt3Tx/CMMLed78+ru8HzH6WGssVf+Ny5c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZpbsFmZNeUICWYeOMFN5/XvKs96m5LaEZe820KXkDF3PTxNF7vtNNUedqOznwkJkTDdt64YOHC0KDglt8PgjOMYcJ7cSIEf/2MU9sSSlbGAUl1sIJbKUBtRNgR21T4rc+y06goXO+L/xyaZqXbkgATpzi4aYVk0PcrRHlVoQzBM= 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=ENKqJr9l; 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="ENKqJr9l" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-477ba2c1ca2so85387155e9.2 for ; Tue, 13 Jan 2026 08:52:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1768323150; x=1768927950; 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=YWhKzvLhaue9MXuU+3OoXk5PTgxl6mRUtqqJcyueqfM=; b=ENKqJr9lCMQxsKWrwUuy7UnDAvDa0wJGU+NSArHYDIQ1HZc0GgXYaluQm4v0ef9X+/ 4YhQAqLGFUpXRDr4RJ9kg5OeJDyrOJ1ur8rVSETFnPvjkFOslZC7x/FUjdjfDxNZTCKU YCbix15C8Wo9W6rGpaEa2tI68uHcp85K3hXHyx3Wka4sEqHWcg8T0dyrKfQP/IC0PomD Ioxsq0N1RflCb4FXdZOZ1ogW/TB2QpaT9pT12r6w065nGGbwnfMUgbB6ENKrk9HRY6g+ rktOtrlMxiYhxQp0wIgCRQJNW09OeHnsfrigUH4M9wf8HTCn+a2LrJOZATEVawKzowaS SEOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768323150; x=1768927950; 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=YWhKzvLhaue9MXuU+3OoXk5PTgxl6mRUtqqJcyueqfM=; b=t1YwU3NdZYeohgw1l6BjF8R4rbop4uYv3iZjh7Z79dwxRPvMCgdhPZqEJShql1oUDI inp7CRrcPefmwzoj1Cd733kt5UEavrJiFjF+BgJ7ycFFtDigJsqBmAkgIJr2fQZeTPRQ hJ2KvhFfqMxPRdY8uz9WOdcSvPtyv43q91ll+UAPFtOQDoxkGkP1xRAD7ef2a7idz30n ZLf3JPH9TSAcklr9LJnk+049OvTKdb4q8uEOsrtzUdWkByHVw9nqJDw2a6jJh6dV6TKq EyFZDHzjR9Rvtw9rTj2Jl50h+dcDr3T9c1MuzJ2uhDqJtOnaP82/btUXnhEyJWUoAUU4 iksw== X-Forwarded-Encrypted: i=1; AJvYcCXz59hBq5HEHPU4lx1MLKEHwQWWQ49k27lVSSRG5hzExLc60utu4yFir280rp+zwPsrMiz5qIIOy4qRTmc=@vger.kernel.org X-Gm-Message-State: AOJu0Yx+QKs15XJsn/LCv+erk18wbyTG52LZDG8jbUpfX7zcTe3mNVOo PmWo8Tu4H73d5INPDtYUVgBtCWdCsHsEaGYSpxgrYrFrgyZ/X3ObA73St7o8v6VnHlo= X-Gm-Gg: AY/fxX59uxXy/pEkjh5sJgZNPDgsvSOdIJ0f3QKJMKeKvRyXir7V0/3I1CpR5f2u57P lj0Qp8ZeA6UTKNEm4dziBt4uIKy4br3hmBfKxL9ABU7DUXylKg5fIYNL22n5rkZn/UA0dgU/ZeL MQnW9quCxKwzb/piLsiRr56XyVQ3tMVFhK7vjKWq7s+3g1dHBO/fiW0ocIk8s34o0Yj/gUZqy4n qVZbZOsLASZrxqdfhqGZ/XMg10DuBFQoYtgFauUtTetKT+TtWmJLArnxdc4ZBHS7whr5RoWBh/e 2zIl2bvmlkyIutNFJXnuCdt5XVBVcdreAUUhm3dLnDEHmxKuDnioRV1YYmoB0ZaPcfcHp+MOSsB zqX9Fm2zJ4nqpC01BB1mvq1xrzHsNV9ruUHMJoSCb6EQyU1encDg2ODKZVa2VQoDYMoJdUIGhTp Ms7wcXof6UEm29wzxL/T61Wct7ItvLHNs= X-Google-Smtp-Source: AGHT+IFhvpSrB9NvHEJa2j8ApIkJ15IacGHwYubI274UiK0PMFXECr6SVMX+STZboFT3UsoJB1oumg== X-Received: by 2002:a05:600c:4e86:b0:477:9574:d641 with SMTP id 5b1f17b1804b1-47d84b3281fmr256540365e9.22.1768323149606; Tue, 13 Jan 2026 08:52:29 -0800 (PST) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:3594:70ab:9964:c5ec]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47d7f41eb3bsm431684925e9.7.2026.01.13.08.52.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jan 2026 08:52:29 -0800 (PST) From: Daniel Lezcano To: wbg@kernel.org Cc: Frank.li@nxp.com, 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 v5 3/3] counter: Add STM based counter Date: Tue, 13 Jan 2026 17:52:20 +0100 Message-ID: <20260113165220.1599038-4-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260113165220.1599038-1-daniel.lezcano@linaro.org> References: <20260113165220.1599038-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 | 432 ++++++++++++++++++++++++++++++++++ 3 files changed, 443 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..dc2a666b323a --- /dev/null +++ b/drivers/counter/nxp-stm-cnt.c @@ -0,0 +1,432 @@ +// 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_context { + u32 counter; + u8 prescaler; + bool is_started; +}; + +struct nxp_stm_cnt { + void __iomem *base; + atomic_t nr_wraps; + struct nxp_stm_context context; +}; + +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_cfg_overflow(struct nxp_stm_cnt *stm_cnt) +{ + /* + * The STM does not have a dedicated interrupt when the + * counter wraps. We need to use the comparator to check if it + * wrapped or not. + */ + writel(0, 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 counter_device *counter =3D dev_id; + struct nxp_stm_cnt *stm_cnt =3D counter_priv(counter); + + nxp_stm_cnt_irq_ack(stm_cnt); + + atomic_inc(&stm_cnt->nr_wraps); + + counter_push_event(counter, COUNTER_EVENT_OVERFLOW, 0); + + return IRQ_HANDLED; +} + +static void nxp_stm_cnt_start(struct nxp_stm_cnt *stm_cnt) +{ + nxp_stm_cnt_cfg_overflow(stm_cnt); + nxp_stm_cnt_enable(stm_cnt); + nxp_stm_cnt_ccr_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_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_U8("prescaler", nxp_stm_cnt_prescaler_read, nxp_stm_cn= t_prescaler_write), + COUNTER_COMP_ENABLE(nxp_stm_cnt_count_enable_read, nxp_stm_cnt_count_enab= le_write), +}; + +static int nxp_stm_cnt_action_read(struct counter_device *counter, + struct counter_count *count, + struct counter_synapse *synapse, + enum counter_synapse_action *action) +{ + *action =3D COUNTER_SYNAPSE_ACTION_RISING_EDGE; + + return 0; +} + +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); + u32 w1, w2, cnt; + + do { + w1 =3D atomic_read(&stm_cnt->nr_wraps); + cnt =3D nxp_stm_cnt_get_counter(stm_cnt); + w2 =3D atomic_read(&stm_cnt->nr_wraps); + } while (w1 !=3D w2); + + *val =3D ((u64)w1 << 32) | cnt; + + return 0; +} + +static int nxp_stm_cnt_count_write(struct counter_device *dev, + struct counter_count *count, u64 val) +{ + struct nxp_stm_cnt *stm_cnt =3D counter_priv(dev); + + nxp_stm_cnt_set_counter(stm_cnt, 0); + atomic_set(&stm_cnt->nr_wraps, 0); + + return 0; +} + +static const enum counter_function nxp_stm_cnt_functions[] =3D { + COUNTER_FUNCTION_INCREASE, +}; + +static int nxp_stm_cnt_function_read(struct counter_device *counter, + struct counter_count *count, + enum counter_function *function) +{ + *function =3D COUNTER_FUNCTION_INCREASE; + + return 0; +} + +static int nxp_stm_cnt_watch_validate(struct counter_device *counter, + const struct counter_watch *watch) +{ + switch (watch->event) { + case COUNTER_EVENT_OVERFLOW: + return 0; + default: + return -EINVAL; + } +} + +static const struct counter_ops nxp_stm_cnt_counter_ops =3D { + .action_read =3D nxp_stm_cnt_action_read, + .count_read =3D nxp_stm_cnt_count_read, + .count_write =3D nxp_stm_cnt_count_write, + .function_read =3D nxp_stm_cnt_function_read, + .watch_validate =3D nxp_stm_cnt_watch_validate, +}; + +static struct counter_signal nxp_stm_cnt_signals[] =3D { + { + .id =3D 0, + .name =3D "Counter wrap signal", + }, +}; + +static const enum counter_synapse_action nxp_stm_cnt_synapse_actions[] =3D= { + COUNTER_SYNAPSE_ACTION_RISING_EDGE, +}; + +static struct counter_synapse nxp_stm_cnt_synapses[] =3D { + { + .actions_list =3D nxp_stm_cnt_synapse_actions, + .num_actions =3D ARRAY_SIZE(nxp_stm_cnt_synapse_actions), + .signal =3D nxp_stm_cnt_signals, + }, +}; + +static struct counter_count nxp_stm_cnt_counts[] =3D { + { + .id =3D 0, + .name =3D "System Timer Module Counter", + .functions_list =3D nxp_stm_cnt_functions, + .num_functions =3D ARRAY_SIZE(nxp_stm_cnt_functions), + .synapses =3D nxp_stm_cnt_synapses, + .num_synapses =3D ARRAY_SIZE(nxp_stm_cnt_synapses), + .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->context.is_started =3D nxp_stm_cnt_is_started(stm_cnt); + + if (stm_cnt->context.is_started) { + nxp_stm_cnt_stop(stm_cnt); + stm_cnt->context.prescaler =3D nxp_stm_cnt_get_prescaler(stm_cnt); + stm_cnt->context.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->context.is_started) { + nxp_stm_cnt_set_counter(stm_cnt, stm_cnt->context.counter); + nxp_stm_cnt_set_prescaler(stm_cnt, stm_cnt->context.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; + atomic_set(&stm_cnt->nr_wraps, 0); + + 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), counter); + 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