From nobody Mon Jun 8 09:49:58 2026 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (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 8CD5F376479 for ; Thu, 4 Jun 2026 09:56:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780567014; cv=none; b=NiYnxvD7lYDMUBt97d/uPpv3bRQrQgFlLQTHnHwuhkr6x48uT46wVb1nRLOBpg7ooSOK4VKYlySAO9kC+nGXX325Xl8tN/85O4/6Eozt7mZvug4U2RqWG5FQfIctutAJXOjB0T1+53RUQe5gz6bG7QcLrPOmiMtlc9nmAodkybI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780567014; c=relaxed/simple; bh=EB7Ettr8Ri2NzRDhCKydd64Ve4kaYLDjIWunWqzwUuM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LpOOdfx3VocI9yMgj1UaRA+f1MoVE0IKx4xdRgUuX2Bn1pASlcqcVOd0v7OBkn1oj/BQhalEeZB+n1vwZg8SXBvUvZqUqAOgFto4yIp8zProNvMWx4qQi0+/DXC0PLI5dgJN4FisozfMBnpyoIkDxNsqQyVfpuNGP8hK77lkzS4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=I32NKOWI; arc=none smtp.client-ip=209.85.128.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="I32NKOWI" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-490b8ac62baso11122285e9.0 for ; Thu, 04 Jun 2026 02:56:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780567012; x=1781171812; 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=ie8fAa3TVGPNRGFIullgvrpG6cDSByumclgvyRIodhE=; b=I32NKOWIj11L0AOOAE9PTPByFiRc79MhMQvqtAD1jko9drrGiTCRoszYqmAT09JNWI 4gmj+pAaALp9An7ZWcCANlxtpWu37yCLb/PGnzgUBWdIPX56+XEKVe+Z45WT66OnDuNC VADZyProxCHs7DzP0e7KL4rCkeRuecst/SUQMCqhPB3aQcIxgkBHO+O9v9qYd0xbZBu1 XrPOvHdSTzxiRtrq9yiFOPllU6yORfbAW5Si1+PzSJR6dOxaY8pqVy6HlNx3YvR9YMpf jx8eyk1dSXSSy5UU91mGLRGs0wmtngE/LfrDN8k/A19elVI7MDVHdyCJXXwa7Cpoqh1S twfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780567012; x=1781171812; 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=ie8fAa3TVGPNRGFIullgvrpG6cDSByumclgvyRIodhE=; b=nwGV39bRJwHgtPUxG24xjfkw06yQMNLFGFAI+hWm0FM4KXCD8AXif3zya+3+aCF8lL rg33VzYkZn2epiYtHTCCGI12kfoxG8M0KWssS0Z27n9uU5/QXyv7FpDC3x6v+3w7BvCs ft41igG1lkAtHtkPkx6szTgjVy0knqx0ybPdyFkuRxhgObxxepkvNQFAdt5c8YXt0wd/ 4kfU5dPgdOBESI6+mnellEhs5MfB1ctul2QAgEpfVhaO4VfATdaKM57eoCoSGAjD93l9 eT/UQA92d9Mlj9qUEiu2SCAT4LWmkDQzGBQotEPMqjaxeVvaqDFVS3EBwRvbGzE56v18 o3RA== X-Forwarded-Encrypted: i=1; AFNElJ87zfa6SbvvsZjYFEEASQwyXPWIvlvParrXTQ/fw0oj3a/h5kbXdKawJ6w6nilLfADb+nBcbUnirLuQNRs=@vger.kernel.org X-Gm-Message-State: AOJu0Yznb0B7StbjMHmfaQXrTilKK1vVr/lVWG2twCT+UefiJwWJnPXp YYw+HNAprcE8e1LCGSmYlX+Ga/DJ662tZR/66qY8F4oR5iiGtHaRx2I3 X-Gm-Gg: Acq92OFXPPwppl5CmzN6eADS0jAoIIRdnAFdZPjYjLvF1j9/e2ERnVNK+ZSu5aoX0jb Z08KJ+obZgdbfOFioqUxSz7h2pP/VvxMxVmrIMR6HUaKBp0i7kF+mzeskodt1HlierCiX702brz 3wUHqqDwvhvW8Q/guBD+KZxcnSYabmIC+W3WFAXKwrNDJCTsTNRzpxFh2nHn3l4dZ5q4uDe0mi4 B5KBcy1tq/eBsIJ4gEfLwKZ3m2rulVtXkqnOHcGK6/If5Y0QWox6WYyPfpueSCO/O7sM+mVx5eB LokSzPgXMEqZB9bqkFN5CTtxXOyEVDzF86nFvlBMKUH6kMpfhtDia1qrzfLrrEVJ0gyrqAR4Gsr TNI/gtYeT1dxP5TIl+8ebnImX6RINwKwBoEUxnGjUVXwog8zhV6KGoVvGKSV6XTnd8RMWO7mU74 nrYXwjKisE1plzLvnl7wh3SuVcHkHCdN6Cs8JRJrp4qI6dRnIO4ESf5Va7WSyUkQpEJiFgbQ== X-Received: by 2002:a05:600c:1988:b0:490:af63:2cb1 with SMTP id 5b1f17b1804b1-490bc4d7071mr45062895e9.7.1780567011787; Thu, 04 Jun 2026 02:56:51 -0700 (PDT) Received: from localhost.localdomain ([2a00:23c4:a700:7301:1615:3574:e0c0:837d]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490be1f69bcsm38037335e9.8.2026.06.04.02.56.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2026 02:56:51 -0700 (PDT) From: Biju X-Google-Original-From: Biju To: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Philipp Zabel , Geert Uytterhoeven , Magnus Damm Cc: Biju Das , linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Prabhakar Mahadev Lad , Biju Das , stable@kernel.org Subject: [PATCH v6 01/11] pwm: rzg2l-gpt: Fix period_ticks type from u32 to u64 Date: Thu, 4 Jun 2026 10:56:31 +0100 Message-ID: <20260604095647.108654-2-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260604095647.108654-1-biju.das.jz@bp.renesas.com> References: <20260604095647.108654-1-biju.das.jz@bp.renesas.com> 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" From: Biju Das period_ticks is used to store PWM period values that can exceed the 32-bit range, so change its type from u32 to u64 to prevent overflow. Cc: stable@kernel.org Fixes: 061f087f5d0b ("pwm: Add support for RZ/G2L GPT") Signed-off-by: Biju Das --- v6: * New patch. --- drivers/pwm/pwm-rzg2l-gpt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pwm/pwm-rzg2l-gpt.c b/drivers/pwm/pwm-rzg2l-gpt.c index 4856af080e8e..c9dfa59bc1ea 100644 --- a/drivers/pwm/pwm-rzg2l-gpt.c +++ b/drivers/pwm/pwm-rzg2l-gpt.c @@ -81,7 +81,7 @@ struct rzg2l_gpt_chip { void __iomem *mmio; struct mutex lock; /* lock to protect shared channel resources */ unsigned long rate_khz; - u32 period_ticks[RZG2L_MAX_HW_CHANNELS]; + u64 period_ticks[RZG2L_MAX_HW_CHANNELS]; u32 channel_request_count[RZG2L_MAX_HW_CHANNELS]; u32 channel_enable_count[RZG2L_MAX_HW_CHANNELS]; }; --=20 2.43.0 From nobody Mon Jun 8 09:49:58 2026 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (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 3FF643905F0 for ; Thu, 4 Jun 2026 09:56:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780567015; cv=none; b=C4PJrTF1nvjjqy2Ie3tmSVCSeAJstf84DEh7ntXdWzY1nhi1F5iba1+/A9YIvduE/nPgnUAPZ15Ync0HeHq4KPUCvFmGEY2rDWJt9Oh8McYtoyjk5jAZQCmX551u9qgZ7ByK+KxoiDdjroR9JGCWOzxS+hjCibD0z7bAHJHk4O4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780567015; c=relaxed/simple; bh=GlK9ixHx54Su6flP5suqw3t57abQqWUB6DRE7SgXo5Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DL1tb6n1KnvEcKYNSABX/MrHjdOpjkpyzbJ+AK81mXyOBd1P56qaxQi0KsLN1bPSKwrCQ7qlPmLgMT1l+xX1DgIOH6veKnGhGi90uu+6hKvj8afuOjKh13kijRZJ7/+p6VQ/7oFaduhyjcvpZ46sKSRWa7NNJRsSR6BWqa9FLq8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=USqgekZk; arc=none smtp.client-ip=209.85.128.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="USqgekZk" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-490b8ac62baso11122335e9.0 for ; Thu, 04 Jun 2026 02:56:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780567013; x=1781171813; 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=bpnqT/H77UIaNdz4UGNV31fQveT8Q7DBDQnTYavMONs=; b=USqgekZkAxbpGQV2ymPvT1uNwjPrBfku36ElBt/jclzS/CHcGL/dTM/2EzLQwllb1b LK5klRIooUYTdjT1AXH3n98y1y0NgyVP2yM/9dsrra2nmwfKV2/BGyLo+RH4R5dgh2JT a3vbklzKhfS6rAUbSkxDoijh3FUcHIFBuoP1b7IiDu+hJOEISUfrqmFEwZUSo6dKOG8e +IF/13eVJI6NzLNn9qfp/xbXlnHGyezVzfhtv6IkJE3sUW8drNexJr4Ul/q0HXVb+A3n JXCtPyT3LvOlQp4aq2ub+LD35Ud/crSqew7XiLwhVxpIFSo436RyrcAIFJeFBvaac36f oTSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780567013; x=1781171813; 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=bpnqT/H77UIaNdz4UGNV31fQveT8Q7DBDQnTYavMONs=; b=Q6KAla0zRBliJsv/offD2BgiBlRty4BfKMmFHPQSS7WivdlzOJMMLlIsHFWL1O0fm+ kB4VyljylH5TSv1F1YYMgcpmmkJhKF5mh1LXATYKEizyeINpVQD3FHVT8ypmxhnBr7rv NUpZ/BZUCn0LmfycZ0MU9hmQ3PGPv3blpG/qnnRLOFLWRvhsShpzW9W3JiMUeQeMWTVa PHCnoHm7Tb0aSYo5lJjUxbXi4a96zodGM3/zQRaIUlswJuLoLND74XG5eb4LIuDkfCDg //eRQ2IZf5hWGb33oj7WT1lZi7Af+T6ImIPr+pVZMIq4acCmnQFOcGN99rgvBtTDvjjN tLsA== X-Forwarded-Encrypted: i=1; AFNElJ8enkiGRkPjNWcgcqq/HOLb51NrqZT4BeYoEAAWnrVoLBmDa0zN0/+sdbP/o2ZrbC95r1DgLcB+RV+jZ8s=@vger.kernel.org X-Gm-Message-State: AOJu0YyQu1k2jgXuQpVMtgpzQRXf5yMizk/2Ocr4BwD57FJ4kBpAOE3z 6b1p9V3e3G+MlZL8uxfvWMmB7dDRUZEn+s97f4KIiU5a34xHtTXhhVZY X-Gm-Gg: Acq92OFs/GzHH281moi0elSxVjNvjGecgwBDchpMSArhCQRp3jG+0lLNaNus2EilRwN YOrREdkRoAIEWgqcbCBmcXlkee/MvsLms+TE6cjXShFs4NRr+4sISFRlWf808to2rdxB/E+eh2u XUKGme1t1Jr88IU1dr0dhVcaYMqehvbO/BRPN0+JY/6j1PfqODeVghJFEjgjAnlYj8+BdKU7vko OCXJ2oeBEEp1GOfur0cysAcMQkstcETQsGccc1dCXKImQ/BGBBIQILmR5kRztxVYYNGQBHrihqp ImU7MZGkjRsDd2qYEQP6CfE+gV98PcrT/XmWSIGTk6YHVHAtG3ZoL/dEB2+rP/Chrz0HO2q17sK h8krYKmJoxF5c1+kYXgB8m8FHJDPMbSECjBNSTcWg/x09EVixjiBnH6sv8NZDeDtZFICdqMQkKY ZTbBMsg5FVhEQfC1aK/ZtmzkL/ZGNAYeTnEAbqRkKvgCmsZxPF9WJigadhY4Y= X-Received: by 2002:a05:600c:4453:b0:48f:e230:29f5 with SMTP id 5b1f17b1804b1-490bc50dcecmr42162245e9.16.1780567012510; Thu, 04 Jun 2026 02:56:52 -0700 (PDT) Received: from localhost.localdomain ([2a00:23c4:a700:7301:1615:3574:e0c0:837d]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490be1f69bcsm38037335e9.8.2026.06.04.02.56.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2026 02:56:52 -0700 (PDT) From: Biju X-Google-Original-From: Biju To: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Geert Uytterhoeven , Magnus Damm Cc: Biju Das , linux-pwm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Prabhakar Mahadev Lad , Biju Das Subject: [PATCH v6 02/11] dt-bindings: pwm: rzg2l-gpt: Document renesas,poegs property Date: Thu, 4 Jun 2026 10:56:32 +0100 Message-ID: <20260604095647.108654-3-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260604095647.108654-1-biju.das.jz@bp.renesas.com> References: <20260604095647.108654-1-biju.das.jz@bp.renesas.com> 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" From: Biju Das RZ/G2L GPT IP supports output pin disable function by dead time error and detecting short-circuits between output pins. Add documentation for the optional property renesas,poegs to link a pair of GPT IOs with POEG. Reviewed-by: Rob Herring Signed-off-by: Biju Das --- v5->v6: * No change v5: * No change v24 from [1]: [1] https://lore.kernel.org/all/20250226144531.176819-1-biju.das.jz@bp.rene= sas.com/ --- .../bindings/pwm/renesas,rzg2l-gpt.yaml | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Documentation/devicetree/bindings/pwm/renesas,rzg2l-gpt.yaml b= /Documentation/devicetree/bindings/pwm/renesas,rzg2l-gpt.yaml index 13b807765a30..98bcde755fb9 100644 --- a/Documentation/devicetree/bindings/pwm/renesas,rzg2l-gpt.yaml +++ b/Documentation/devicetree/bindings/pwm/renesas,rzg2l-gpt.yaml @@ -245,6 +245,28 @@ properties: resets: maxItems: 1 =20 + renesas,poegs: + minItems: 1 + maxItems: 8 + $ref: /schemas/types.yaml#/definitions/phandle-array + items: + items: + - description: phandle to POEG instance that serves the output dis= able + - enum: [ 0, 1, 2, 3, 4, 5, 6, 7 ] + description: | + An index identifying pair of GPT channels. + <0> : GPT channels 0 and 1 + <1> : GPT channels 2 and 3 + <2> : GPT channels 4 and 5 + <3> : GPT channels 6 and 7 + <4> : GPT channels 8 and 9 + <5> : GPT channels 10 and 11 + <6> : GPT channels 12 and 13 + <7> : GPT channels 14 and 15 + description: + A list of phandle and channel index pair tuples to the POEGs that ha= ndle the + output disable for the GPT channels. + required: - compatible - reg @@ -375,4 +397,5 @@ examples: power-domains =3D <&cpg>; resets =3D <&cpg R9A07G044_GPT_RST_C>; #pwm-cells =3D <3>; + renesas,poegs =3D <&poeggd 4>; }; --=20 2.43.0 From nobody Mon Jun 8 09:49:58 2026 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1E0EF3D3016 for ; Thu, 4 Jun 2026 09:56:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780567018; cv=none; b=TBWkUBBCMkoPWGQ/re90tZW4NYC0qM9V//N53fX6VYvd6JRHOZU1Wz0Ux3DbvPMpbNysNqsTMZ/wEHL56GYMsN4oV/kEcvvnvK1MhVELo0BIu+pN8emxn5PJCqjvGSx6kd2FBTj2JWRQIgM68JaAOUHLAjiHgK+t+qMR30gTBEI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780567018; c=relaxed/simple; bh=ISLs2X2Qp4rtIO+skqURDL7+5OsBohOiLqyNgEXhHas=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cKXcc6MAOkxxOFG+8FWDBVl/A/wtruRM1ABwo4nu5kBxkQiBuoPm0IKo/cAFh7AjzpB0gyj8L9g7UFihNW/wx/6uBuEkB+Nf/XBNE5TnOCPV/oWra8sywZhwVuq8CKCIQ28x3GaBwxjfa9gne64pSQp0Wi8DtFjj3Z6vlwTPIDM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=eenFJcBY; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eenFJcBY" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4903997fcb5so4291895e9.2 for ; Thu, 04 Jun 2026 02:56:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780567013; x=1781171813; 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=YhrCwZDLA8Hyn5RMh/SaXAXNT2PWN8NDvUTyEoAbtw8=; b=eenFJcBY4GqBNfd27s/okNywO7oa35jVsCjwGdeV+SZYKEYLxElC9os7Tz5RXkxqtb Phhvw7neQBlMZFomT4fG2nQjUvzF4LeCHL+1TJCVN4xPvR/UhGZq4keoGTtMIQlQbCnM UMOlc+rmyXTUYlBBBRNjy8skQpaw4VrW4xv30XMADVgCGngACvQQjzNWu1QqEHuRlgdW qE1+HD3nkR8Dq79/cMUjrZ7mT9KN9pqhcZa8K/xc7PEcJOTWwfwXtf7IGoTsLDnJ80AZ 5h1d7dtrWFnciZdXaP3Sn0CAWPtZD1tkPs+ivrBBZUlv8PI1bqfUDIApTz9OuWlKxKi0 TFnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780567013; x=1781171813; 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=YhrCwZDLA8Hyn5RMh/SaXAXNT2PWN8NDvUTyEoAbtw8=; b=Waxax2tFU3Zjq24sTQN8yDLZCOOLfftgDVoWGjjT/FmvvEb8t9AQuvE6pgTZiCpnA+ aFvOZhn+fRVlJZSGmKXwwzOSioJUWA1YqLawT+3x7wR/58PaxS5QNRpXxYCsdj18CKOy giXPbKUvUF2jmsG9WkucavfrfuCVDk2gQvWF//TTHhCAFvUHUnX/KTRbgUSJ/oC4LUIH js2diQC44NcobapePVLVNH2TapZ7a7uAaBM+14Po8/zljTtivIlaql7HDbZVZfGbsCbe 3O/Hg5ZiBSlGaydqbkeALT+7E65cj/ClYHq8Ow98eRGN77n+pKzFNDNrkw5Su/pDqngy ycmQ== X-Forwarded-Encrypted: i=1; AFNElJ9Gpxrcowh2PjOCitgBWRnYm5cZ0eOpyCy/PEobZdp17nMpH34RosfrnEAiKnYdQBKHD+YgU+gu6sYF8l0=@vger.kernel.org X-Gm-Message-State: AOJu0YzRMs8XcFKPPnVlt8gyhPtzh8k+uLkWGdV1N/lK/jO6zE21EG4h UlWjOjvxLVzbg0B6rxeVwQHdJa9XmbnKPVo5OiAWjkJ5tj3L753W6xBq X-Gm-Gg: Acq92OERe+C4NWJgR9OsJd/T1lI+jyP2ypoxBSG3Ka8YLQp5Nn1lN7vo+ntK7z9n1Uu n22OkV5Z7nG19yZh8p1hpQqqv9zu6A6QVNE/wGb7e/K+PUW5ohhtCZicfuiksUPnTfWxoV94WfB 9Na697gn+8qddw3Jf4rIC8bFPyL5Hyk4YHnIuhZzMAmfdpbVt3a7pUeNQtP1wajYo9mJKA5Ov/a GM/Qi2pIQSwNhPcTFofAv1TgeVNKZa0viZGqLeOeIiElN6aFVPUfe8hWa4fPh9LCnWudRF9dnxH NmoBDsQ4kEhPVEnUYYhr6jNl1IYW2rvP9S8+CdNHh0c/kyr+0EYW5jbwBeqbACjCzoST1KTnx0B QKKjMaYFD4HlmYWtMvUlcOOrLH8Rexl68s9USp7yDOKUXYqH1ID6z2pXBGhAb/Nwj22gpgsavFZ Vh5P0ri7gcfoSV3e/RaDqj7eeRiNAbO7vARJoBooS0OUdJmg2cmETEAWj6+EmiJhVykmIDpQ== X-Received: by 2002:a05:600c:828d:b0:490:bf1a:ed04 with SMTP id 5b1f17b1804b1-490bf1aedcdmr19572105e9.1.1780567013393; Thu, 04 Jun 2026 02:56:53 -0700 (PDT) Received: from localhost.localdomain ([2a00:23c4:a700:7301:1615:3574:e0c0:837d]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490be1f69bcsm38037335e9.8.2026.06.04.02.56.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2026 02:56:53 -0700 (PDT) From: Biju X-Google-Original-From: Biju To: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Geert Uytterhoeven , Magnus Damm Cc: Biju Das , linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Prabhakar Mahadev Lad , Biju Das Subject: [PATCH v6 03/11] pwm: rzg2l-gpt: Add support for gpt linking with poeg Date: Thu, 4 Jun 2026 10:56:33 +0100 Message-ID: <20260604095647.108654-4-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260604095647.108654-1-biju.das.jz@bp.renesas.com> References: <20260604095647.108654-1-biju.das.jz@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: Biju Das The General PWM Timer (GPT) is capable of detecting "dead time error and short-circuits between output pins" and send Output disable request to poeg(Port Output Enable for GPT). Add support for linking poeg group with gpt, so that gpt can control the output disable function by adding rzg2l_gpt_poeg_init() to parse the renesas,poegs device tree property and establish links between POEG groups (A=E2=80=93D) and GPT hardware channels (0=E2=80=937). For each vali= d, enabled POEG phandle entry, the driver: - Reads the renesas,poeg-id from the POEG node and validates it against the supported range - Records the GPT=E2=80=93POEG association in a per-chip bitmap (poeg_gpt_= link) - Configures GTINTAD to route the output disable request to the correct POEG group - Configures GTIOR (OADF/OBDF fields) to set both output pins to high-impedance on an output disable event Non-enabled POEG nodes are silently skipped. Signed-off-by: Biju Das --- v5->v6: * Dropped extra space in poegs variable assignment in rzg2l_gpt_poeg_init(). * Updated the comment sections of rzg2l_gpt_poeg_init() with POEG and GPT in upper-case and replaced configure->configures. * Format specifiers in dev_err() changed from %d to %u in rzg2l_gpt_poeg_init(). v5: * Updated commit description. * Replaced return type of rzg2l_gpt_poeg_init() from void->int and probe() checks this return value. * Added more error checks in rzg2l_gpt_poeg_init()=20 V24 from [1]: [1] https://lore.kernel.org/all/20250226144531.176819-1-biju.das.jz@bp.rene= sas.com/ --- drivers/pwm/pwm-rzg2l-gpt.c | 93 +++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) diff --git a/drivers/pwm/pwm-rzg2l-gpt.c b/drivers/pwm/pwm-rzg2l-gpt.c index c9dfa59bc1ea..233e5ff2d04d 100644 --- a/drivers/pwm/pwm-rzg2l-gpt.c +++ b/drivers/pwm/pwm-rzg2l-gpt.c @@ -39,6 +39,7 @@ #define RZG2L_GTCR(ch) (0x2c + RZG2L_GET_CH_OFFS(ch)) #define RZG2L_GTUDDTYC(ch) (0x30 + RZG2L_GET_CH_OFFS(ch)) #define RZG2L_GTIOR(ch) (0x34 + RZG2L_GET_CH_OFFS(ch)) +#define RZG2L_GTINTAD(ch) (0x38 + RZG2L_GET_CH_OFFS(ch)) #define RZG2L_GTBER(ch) (0x40 + RZG2L_GET_CH_OFFS(ch)) #define RZG2L_GTCNT(ch) (0x48 + RZG2L_GET_CH_OFFS(ch)) #define RZG2L_GTCCR(ch, sub_ch) (0x4c + RZG2L_GET_CH_OFFS(ch) + 4 * (sub_c= h)) @@ -55,12 +56,19 @@ #define RZG2L_GTUDDTYC_UP_COUNTING (RZG2L_GTUDDTYC_UP | RZG2L_GTUDDTYC_UDF) =20 #define RZG2L_GTIOR_GTIOA GENMASK(4, 0) +#define RZG2L_GTIOR_OADF GENMASK(10, 9) #define RZG2L_GTIOR_GTIOB GENMASK(20, 16) +#define RZG2L_GTIOR_OBDF GENMASK(26, 25) #define RZG2L_GTIOR_GTIOx(sub_ch) ((sub_ch) ? RZG2L_GTIOR_GTIOB : RZG2L_GT= IOR_GTIOA) #define RZG2L_GTIOR_OAE BIT(8) #define RZG2L_GTIOR_OBE BIT(24) #define RZG2L_GTIOR_OxE(sub_ch) ((sub_ch) ? RZG2L_GTIOR_OBE : RZG2L_GTIOR= _OAE) =20 +#define RZG2L_GTIOR_OADF_HIGH_IMP_ON_OUT_DISABLE BIT(9) +#define RZG2L_GTIOR_OBDF_HIGH_IMP_ON_OUT_DISABLE BIT(25) +#define RZG2L_GTIOR_PIN_DISABLE_SETTING \ + (RZG2L_GTIOR_OADF_HIGH_IMP_ON_OUT_DISABLE | RZG2L_GTIOR_OBDF_HIGH_IMP_ON_= OUT_DISABLE) + #define RZG2L_INIT_OUT_HI_OUT_HI_END_TOGGLE 0x1b #define RZG2L_GTIOR_GTIOA_OUT_HI_END_TOGGLE_CMP_MATCH \ (RZG2L_INIT_OUT_HI_OUT_HI_END_TOGGLE | RZG2L_GTIOR_OAE) @@ -71,12 +79,17 @@ ((sub_ch) ? RZG2L_GTIOR_GTIOB_OUT_HI_END_TOGGLE_CMP_MATCH : \ RZG2L_GTIOR_GTIOA_OUT_HI_END_TOGGLE_CMP_MATCH) =20 +#define RZG2L_GTINTAD_GRP_MASK GENMASK(25, 24) + #define RZG2L_MAX_HW_CHANNELS 8 #define RZG2L_CHANNELS_PER_IO 2 #define RZG2L_MAX_PWM_CHANNELS (RZG2L_MAX_HW_CHANNELS * RZG2L_CHANNELS_PER= _IO) #define RZG2L_MAX_SCALE_FACTOR 1024 #define RZG2L_MAX_TICKS ((u64)U32_MAX * RZG2L_MAX_SCALE_FACTOR) =20 +#define RZG2L_MAX_POEG_GROUPS 4 +#define RZG2L_LAST_POEG_GROUP 3 + struct rzg2l_gpt_chip { void __iomem *mmio; struct mutex lock; /* lock to protect shared channel resources */ @@ -84,6 +97,7 @@ struct rzg2l_gpt_chip { u64 period_ticks[RZG2L_MAX_HW_CHANNELS]; u32 channel_request_count[RZG2L_MAX_HW_CHANNELS]; u32 channel_enable_count[RZG2L_MAX_HW_CHANNELS]; + DECLARE_BITMAP(poeg_gpt_link, RZG2L_MAX_POEG_GROUPS * RZG2L_MAX_HW_CHANNE= LS); }; =20 static inline struct rzg2l_gpt_chip *to_rzg2l_gpt_chip(struct pwm_chip *ch= ip) @@ -375,6 +389,81 @@ static const struct pwm_ops rzg2l_gpt_ops =3D { .apply =3D rzg2l_gpt_apply, }; =20 +/* + * This function links a POEG group{A,B,C,D} with a GPT channel{0..7} and + * configures the pin for output disable. + */ +static int rzg2l_gpt_poeg_init(struct platform_device *pdev, + struct rzg2l_gpt_chip *rzg2l_gpt) +{ + const char *poeg_name =3D "renesas,poegs"; + struct of_phandle_args of_args; + struct property *poegs; + unsigned int i; + u32 poeg_grp; + u32 bitpos; + int cells; + int ret; + + poegs =3D of_find_property(pdev->dev.of_node, poeg_name, NULL); + if (!poegs) + return 0; + + cells =3D of_property_count_u32_elems(pdev->dev.of_node, poeg_name); + if (cells < 0) + return cells; + + if (cells & 1) + return -EINVAL; + + cells >>=3D 1; + for (i =3D 0; i < cells; i++) { + ret =3D of_parse_phandle_with_fixed_args(pdev->dev.of_node, + poeg_name, 1, i, + &of_args); + if (ret) + return ret; + + if (of_args.args[0] >=3D RZG2L_MAX_HW_CHANNELS) { + dev_err(&pdev->dev, "Invalid channel %u >=3D %u\n", + of_args.args[0], RZG2L_MAX_HW_CHANNELS); + goto err_of_node; + } + + if (!of_device_is_available(of_args.np)) { + /* It's fine to have a phandle to a non-enabled poeg. */ + of_node_put(of_args.np); + continue; + } + + if (!of_property_read_u32(of_args.np, "renesas,poeg-id", &poeg_grp)) { + if (poeg_grp > RZG2L_LAST_POEG_GROUP) { + dev_err(&pdev->dev, "Invalid poeg group %u > %u\n", + poeg_grp, RZG2L_LAST_POEG_GROUP); + goto err_of_node; + } + + bitpos =3D of_args.args[0] + poeg_grp * RZG2L_MAX_HW_CHANNELS; + set_bit(bitpos, rzg2l_gpt->poeg_gpt_link); + + rzg2l_gpt_modify(rzg2l_gpt, RZG2L_GTINTAD(of_args.args[0]), + RZG2L_GTINTAD_GRP_MASK, poeg_grp << 24); + + rzg2l_gpt_modify(rzg2l_gpt, RZG2L_GTIOR(of_args.args[0]), + RZG2L_GTIOR_OBDF | RZG2L_GTIOR_OADF, + RZG2L_GTIOR_PIN_DISABLE_SETTING); + } + + of_node_put(of_args.np); + } + + return 0; + +err_of_node: + of_node_put(of_args.np); + return -EINVAL; +} + static int rzg2l_gpt_probe(struct platform_device *pdev) { struct rzg2l_gpt_chip *rzg2l_gpt; @@ -426,6 +515,10 @@ static int rzg2l_gpt_probe(struct platform_device *pde= v) if (rzg2l_gpt->rate_khz * KILO !=3D rate) return dev_err_probe(dev, -EINVAL, "Rate is not multiple of 1000"); =20 + ret =3D rzg2l_gpt_poeg_init(pdev, rzg2l_gpt); + if (ret) + return dev_err_probe(dev, ret, "Failed to link gpt with poeg\n"); + mutex_init(&rzg2l_gpt->lock); =20 chip->ops =3D &rzg2l_gpt_ops; --=20 2.43.0 From nobody Mon Jun 8 09:49:58 2026 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (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 BF46F3E024A for ; Thu, 4 Jun 2026 09:56:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780567017; cv=none; b=n9L2qaHwo30/U6mmcHZxvCzl62Jd739ndKc61ELqlI+5wFC4MkI1neIoaNyw/IB3tMPkWpF8EWuUga9YDebGT+wcRjUQAma1E/OG85Y/roNCISW7j79ndizM/kBGtkFjmiONE5HCiBpzfhqitEZkP5tzzpuEg7zO2j3YZuNIoFw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780567017; c=relaxed/simple; bh=ormcBKXgtMUbxhPH8flZunLMCWwtspwzC/31OfGnHNA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Wt+w3c6zk0W0oUUn7jnDpm9w9V7wXN1nST6eptW1HXjyOU3QYXxmItNga5Zc6muzXuM4mlC4FnHURDplzS0zE5huofgiTk9gU03N/bB7TWzCNrafVsWydgR8UGWIBafiU9LeXi5xiaF29BSkZG0MjkZdeDbvTukA35TaARDcqcY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=VQe6f7bo; arc=none smtp.client-ip=209.85.128.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VQe6f7bo" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-490bc6a7958so6444535e9.1 for ; Thu, 04 Jun 2026 02:56:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780567014; x=1781171814; 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=WRHuLwRJMvtvIKprdTuRI74u8tyjnb0ERZ60XzwxUP4=; b=VQe6f7bon18+7QGKbdzoaphzaYbDRWjE82U1lnsUKukrj6AhWfqavsECmqK5mwt6Jp zzilVHMarGcY60iHp66zx+z4BYmy/iUlq1t1S5od6LgdyDlwQY51Vy5sVvjFfSYBUXH1 NaONf7TYElPn3goeaa/OEY2TwYdogf56wAM0R7qzoDpsTs/j87lIj4JJzM8yxnAXN/zz Xzx04jA1wnFSNHBt3pjLMzlquuF8PJWBhUwPwS2MogPxg8cKt+jy3QHJZcI2BwuVJ1NR i0KD9uyu3+kYNS7jNz/1nc2HfpiE6YexFdmWm0IWaBFbdWGWoSd2N4sxGyTqu6VSOGhn aEug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780567014; x=1781171814; 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=WRHuLwRJMvtvIKprdTuRI74u8tyjnb0ERZ60XzwxUP4=; b=GIvcPgIpMvc5juNogptkx/OtTxxfDOExnHCa6+0ggvm0QnbSR0OrEAc7Ch52vosumT Mua4bWWeb+63GcwIq5piH6VZcWPAd23vkT7TaA1AkEZMKNaboukkz5Ad4b6xwYelDtH/ yTBL0Pet9HFEkFAnLMlkY/JUbNJ9gJQJEzu9T+MIqdZ2IeBCp4AJp1zbAGD1x4qU5OiP Aua9V9lb3SM4Oh5qVdL2jhsTzhLwOpbpFB+Twi9BscHbUh7lZM63okiLQGAGsjWclaNM YuDXzZI0+4V+lgyAbcV5uhVNN9sDhSKhjvzpoo9IjvcV5qdva7kHrgLSeTGMobhcAZuk Q9rw== X-Forwarded-Encrypted: i=1; AFNElJ/T6vBgHe9PZBsEoZwgstGOix0BtoQ6iHjpnpA/x7NwX1dxhLFR/T0FIly+zK/LXtO2gjHtkNfGThXmps4=@vger.kernel.org X-Gm-Message-State: AOJu0YxPxxzIhKaBQCCNoB0eG6iYrFVEekbmf51BsSr2P3O9GfXS/Cj/ 87KrKMy3yFoHmKDungsOGQQatqRfwJp+lEHCvm1oc0EPnAQ2uM8+kJp1 X-Gm-Gg: Acq92OFseUI1f+HmajDUtFQtyB+plCK16hIvQuQnPNc2wKK1GrIsTXTvy9t6bS62l9H EHga3bhbdd17nufuiUPVXc1QHHn3WAY4VxiVwEo3ZN1Yq1HLOnv3FVzhz6AGH+2tp1jrYWo0H6M WWYQM32UHq5/BXxZXD6O0uW1k8u/3Txg+9mEVCGUqiL315ErQzpRYp0lq85JYAqILxsF6kc/aWH wQUABhmK8sdLMifxVKAFtG3YtgxaUefm9+SuzUkirYZ/rC7UgJ/QGi+Av99dz2grI7vP19440Lg zwN3zyswhEVbFXXL2Mvs7yFAu8mvlPZSvUcYwEEmV+nK58vHwO3A9YItS3t/IMR/3NNFMu2tdDg PZaOYsad/cw06bv++uU9+P143vhcs6MCsi65Am00iYf+Rtd4c18M8AY1+eZL4tJm9GfPztVMJej FXjxaBjFHAISvoceoglFmJGJ5mZaMB2+ZTxwKAPGM6W0BxQO2tPrY704YU9xU= X-Received: by 2002:a05:600c:83c6:b0:48a:53cb:8604 with SMTP id 5b1f17b1804b1-490bc5001e0mr48514435e9.14.1780567014180; Thu, 04 Jun 2026 02:56:54 -0700 (PDT) Received: from localhost.localdomain ([2a00:23c4:a700:7301:1615:3574:e0c0:837d]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490be1f69bcsm38037335e9.8.2026.06.04.02.56.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2026 02:56:53 -0700 (PDT) From: Biju X-Google-Original-From: Biju To: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Philipp Zabel , Geert Uytterhoeven , Magnus Damm Cc: Biju Das , linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Prabhakar Mahadev Lad , Biju Das Subject: [PATCH v6 04/11] pwm: rzg2l-gpt: Add missing newlines to dev_err_probe() messages Date: Thu, 4 Jun 2026 10:56:34 +0100 Message-ID: <20260604095647.108654-5-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260604095647.108654-1-biju.das.jz@bp.renesas.com> References: <20260604095647.108654-1-biju.das.jz@bp.renesas.com> 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" From: Biju Das dev_err_probe() internally calls dev_err() which uses pr_fmt() and printk(). Kernel log messages should end with a newline character to ensure proper log formatting. Add missing '\n' at the end of the error strings in rzg2l_gpt_probe(). Signed-off-by: Biju Das --- v6: * New patch. --- drivers/pwm/pwm-rzg2l-gpt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/pwm/pwm-rzg2l-gpt.c b/drivers/pwm/pwm-rzg2l-gpt.c index 233e5ff2d04d..47c6c2eb3067 100644 --- a/drivers/pwm/pwm-rzg2l-gpt.c +++ b/drivers/pwm/pwm-rzg2l-gpt.c @@ -497,14 +497,14 @@ static int rzg2l_gpt_probe(struct platform_device *pd= ev) =20 rate =3D clk_get_rate(clk); if (!rate) - return dev_err_probe(dev, -EINVAL, "The gpt clk rate is 0"); + return dev_err_probe(dev, -EINVAL, "The gpt clk rate is 0\n"); =20 /* * Refuse clk rates > 1 GHz to prevent overflow later for computing * period and duty cycle. */ if (rate > NSEC_PER_SEC) - return dev_err_probe(dev, -EINVAL, "The gpt clk rate is > 1GHz"); + return dev_err_probe(dev, -EINVAL, "The gpt clk rate is > 1GHz\n"); =20 /* * Rate is in MHz and is always integer for peripheral clk @@ -513,7 +513,7 @@ static int rzg2l_gpt_probe(struct platform_device *pdev) */ rzg2l_gpt->rate_khz =3D rate / KILO; if (rzg2l_gpt->rate_khz * KILO !=3D rate) - return dev_err_probe(dev, -EINVAL, "Rate is not multiple of 1000"); + return dev_err_probe(dev, -EINVAL, "Rate is not multiple of 1000\n"); =20 ret =3D rzg2l_gpt_poeg_init(pdev, rzg2l_gpt); if (ret) --=20 2.43.0 From nobody Mon Jun 8 09:49:58 2026 Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (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 88EAB3F1664 for ; Thu, 4 Jun 2026 09:56:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780567018; cv=none; b=pvXuDehPqZ0rF3ydDHcX7n/rwAP9FM6x7Nw85XySGBJWRRfeJpBNMRGOjVO6dlilp79nOZb1uzQeLatHT9ea6LG9Pdlg+2Lj8mgptrqFCDvbdjSMNVFO77eNEOn6IoDoeQdMkbo+cRVe1AQMF8AGs5thc/9f2RiYK1zU+3H/OsU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780567018; c=relaxed/simple; bh=NlDkVlMm1JuUzeAtDRZB+Iz/R/2FhoZf5pp2LkeDlno=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rFl/iJ9y9Q4toHSTuD15746muQlZTMmogSggBBcIEQDvpY6HgbPWeGcLjWlWubJPf9wKuOmlLxj1NO44Ywy2EL8p1gJqo344N9CZBlkTT95w7qGu4L6WVXxvtVLmKj15XDMfcMwFaYl0MF1j1ZNaWh5ZYbDY7ZNM+hQnRDRZEO4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=HGoR38PT; arc=none smtp.client-ip=209.85.221.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HGoR38PT" Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-45eec22fab7so251362f8f.3 for ; Thu, 04 Jun 2026 02:56:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780567015; x=1781171815; 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=DgXQ8Wjt8CwTPh1rq91BMMsmDAAHzwhsHaimZBrxe6g=; b=HGoR38PT4SbCSDnTWDUJ+y+snwDBzNTyuUIL8FK+/zdIlga+C6kBvrXlMGfNk5UE9E C6BG8vjw/a7PuzGSAUbbba0u/8kTTDd/uBYkvbgzp/Ceh27JUX/Bzr5njo9uSnNaFNZw FYaTmn6S4IUiQKCJvAbmWhpeigXKAfPqxP42coNOmtmOJrlmmEoJUu4jZVKgGahpNt7C S0C6e/3pP/SIOf6PgnYVml5fXyFIySzNgboi5Nn2ZJve1FPAaB29nfrBggt/c5NdHrFQ vGH9D/PKa/KrQu+w4Bcww1wZKioOaSbSMb3p0Uz7+jRxEypgkX74wM3VWLcYD500ocv+ YdIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780567015; x=1781171815; 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=DgXQ8Wjt8CwTPh1rq91BMMsmDAAHzwhsHaimZBrxe6g=; b=YQF2b3yHVOyt65o9MEdoAlPPgjWpr3MikHL3hZF1MOZkShyTJ/jU3ZMmX3wUUQXXCT umNgxZYsmMeQeojqmgIOhRbWGGr2oAnwj0O4rfUdc42GQW5o68QQ/eqtD742ph/s5omq Vl8s+x5+kI9wa15Dno3s8eTi5kt102PPId26D18J+pHHpjhEY4Q8ONo3SGk0Z2CaYb7e nPyoEUYi1hqSHHJNTR4UMRDSpt5eBmtZdajTjhkIGqoIS8mHwiNI5Joogp+M9U49WM/r pHNvjzt8MHql9Ln9qZIBYRptCXHr+hrZZtwoz4yJh12+dU4s/yC9qVau7Dd0XeKVk1qs rEyA== X-Forwarded-Encrypted: i=1; AFNElJ/uvGXY6F6U0BVeRfOoYuY8mC+3JPUwOabc+x2YFQay5e65UJVUj8tGrEGqW++J9zhtMHtHhZB0GA6gytg=@vger.kernel.org X-Gm-Message-State: AOJu0YzQvEv/f4tLihEhZh04pgezM2o9dlJzkO4nHIf2EbQM+mt/zDfB oT1AUx8vCp58076vp7QdF5HEH7xDRtU8oVihc8+lhzwnQYOWfUAjB0h4 X-Gm-Gg: Acq92OH30+hJQ+gnNUcnNRWHx2uEKA3NWJGfYutUC4JP0uQtMbHBR7CN0D2Y8PqfBDt YoLTYT7YlagsC8Dhcq58TzYZWiw4WRzw49J9gbyniw0SvCw/Fd628CyOlFt3lcccnRCnlborm+K z5mdqbpyNGCvcbC7RSZgNaIkyDyHU5FajNV5qK2oi9ud44eYWI31fJ5DmhmZRlbzsVmzsoizVYb b7mGM2tii9NOS3GBvER7V5t304KPHPF3JeVe+U+rt/Va6xJowqx34edWkZ5RYjwFvgh2L0qvJPG vEax2MRf5/0kdcCmZlzMv14QLCUvWTzXr9jp/ooeMn2d/pdv9y6gxWW2I/WSDy+ZtTxWXwwydDY 9Q90kko8iAWzeBsuvjUbFZfMyD09JKs2VjPaEtkfaVckEFpfWyZSexnYq6HwK3V8jIxdrmi+mlQ ek05jskHPtZUxbf2K1L4/O40/jS9smkqv3mEtY2DC7kyVi9vcxnva+7VtygNk= X-Received: by 2002:a05:600c:8b01:b0:490:6237:5200 with SMTP id 5b1f17b1804b1-490b5d36863mr117178755e9.10.1780567014917; Thu, 04 Jun 2026 02:56:54 -0700 (PDT) Received: from localhost.localdomain ([2a00:23c4:a700:7301:1615:3574:e0c0:837d]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490be1f69bcsm38037335e9.8.2026.06.04.02.56.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2026 02:56:54 -0700 (PDT) From: Biju X-Google-Original-From: Biju To: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Cc: Biju Das , linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven , Prabhakar Mahadev Lad , Biju Das , linux-renesas-soc@vger.kernel.org Subject: [PATCH v6 05/11] pwm: rzg2l-gpt: Drop unused rzg2l_gpt_chip parameter from rzg2l_gpt_calculate_prescale() Date: Thu, 4 Jun 2026 10:56:35 +0100 Message-ID: <20260604095647.108654-6-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260604095647.108654-1-biju.das.jz@bp.renesas.com> References: <20260604095647.108654-1-biju.das.jz@bp.renesas.com> 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" From: Biju Das The rzg2l_gpt parameter was passed to rzg2l_gpt_calculate_prescale() but never used inside the function. Remove it and update the sole call site accordingly. Signed-off-by: Biju Das --- v5->v6: * No change. v5: * New patch. --- drivers/pwm/pwm-rzg2l-gpt.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/pwm/pwm-rzg2l-gpt.c b/drivers/pwm/pwm-rzg2l-gpt.c index 47c6c2eb3067..49b95e53ad83 100644 --- a/drivers/pwm/pwm-rzg2l-gpt.c +++ b/drivers/pwm/pwm-rzg2l-gpt.c @@ -132,8 +132,7 @@ static void rzg2l_gpt_modify(struct rzg2l_gpt_chip *rzg= 2l_gpt, u32 reg, u32 clr, (rzg2l_gpt_read(rzg2l_gpt, reg) & ~clr) | set); } =20 -static u8 rzg2l_gpt_calculate_prescale(struct rzg2l_gpt_chip *rzg2l_gpt, - u64 period_ticks) +static u8 rzg2l_gpt_calculate_prescale(u64 period_ticks) { u32 prescaled_period_ticks; u8 prescale; @@ -300,7 +299,7 @@ static int rzg2l_gpt_config(struct pwm_chip *chip, stru= ct pwm_device *pwm, } } =20 - prescale =3D rzg2l_gpt_calculate_prescale(rzg2l_gpt, period_ticks); + prescale =3D rzg2l_gpt_calculate_prescale(period_ticks); pv =3D rzg2l_gpt_calculate_pv_or_dc(period_ticks, prescale); =20 duty_ticks =3D mul_u64_u64_div_u64(state->duty_cycle, rzg2l_gpt->rate_khz= , USEC_PER_SEC); --=20 2.43.0 From nobody Mon Jun 8 09:49:58 2026 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 9A3193FC5AC for ; Thu, 4 Jun 2026 09:56:57 +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=1780567020; cv=none; b=okinnyI+0Grx3qKQhv6eTqDoNxolypbagSwH3tHU0w1u9tPv3IWdSVM/vQLKDJUYOWpnKhuXtXwV2evp+4Ly/gxY9ZWkCOQ/zgZC5ZUIj+JymIYSm4nn5x7bl4zsRZAw6ZC7jfMzJ3zRZtfXUanQNeF41QxBrwHSE3PzlFneZ/o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780567020; c=relaxed/simple; bh=8I83KcHuzZ8jlwx7AcuWFKq2DcGYr8Ypu5tkOjSq+MI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=klBZPmeStRyVICv43t0SXvkygH1zMUgu01RzPqZ7VeVXM5saVNBp74ptvnpxdNLSxjz51Dwt1m9ljXb6qS69L+NRgz3gyfffpseiXwAOb/9TPEV/sr96fxEcF4rn5BKW5ph1xbnJKuvjGZ8T7UHj/R7ABZbmDIQrc9+VK4IcMEs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=XzjVjzzk; arc=none smtp.client-ip=209.85.128.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XzjVjzzk" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-490afc47455so2347985e9.2 for ; Thu, 04 Jun 2026 02:56:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780567016; x=1781171816; 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=wYE54b9tWfq3+sWiO/DUacgmOh4UF8vkWeVCdf21x40=; b=XzjVjzzkGZGB5d6528t2z4ml79IOjEQlId85mWnLVZBN58YlTkA87F0NszfHe3QF/s U6hA2i1qfoZz8Opar2W6N1N2OepE7Mg4JFsBNTjIVKVXZuv/C/ouzK0nz7gDxcpLhrO4 WlJwMiV20ieMWp5Q+KOkRtTsrpa1bje6IgH3V5IlQ+ZbgvGRg4MKJNbdXJjYRUtcOpBl cw5FWyICVagejY40BpcVj0yug2kxhqOsXE9jhK8n21K/26Tg8nPbhj3XKen7aBO7cZ+3 Dn5sp2KjpZpMQl/hsBj+UbeLetTiaxj+r4sTpDvcWN/AzwbxoMshxL4ZAZpAtWdCEoB+ 2jhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780567016; x=1781171816; 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=wYE54b9tWfq3+sWiO/DUacgmOh4UF8vkWeVCdf21x40=; b=rtDTAM/mZq4Fasos6XK82X+AeabFv65zZSukfa+BsKifzQcOQLMReRLIssJNcDVF0f KDEzesC0wcZBLqUZAxRg0ohpUoxrDdw/FFQZnEJ7Oy2ji5kgSjquN5tqo3jqNKZMFdf1 OaUVhr8AMvbRW7cqKn9gMGw0piJB+kF7D9zdvjDT5FnBptRPNe9TNFcK1WhPOmvPx751 Gp4QACImr/W6TvZpQUePf3eaJssIi7gUxufGSTm1X00OKAOHPnGb6vNhA6Ajtx+myyL2 Ih7nsZ06sLTlSC8GV7DVvZ3m+67jHnkXTQl1OIGD5hRtBnB5Bc+GOEMbaxisgfwpbvHI jn/A== X-Forwarded-Encrypted: i=1; AFNElJ+9GVkoQxgnRNXN876KfMeliVBztpO7ItLPOvJQiDd1Bekc0c0EklslTQFX0GdQ6ta6N14npe7tcDj3NXE=@vger.kernel.org X-Gm-Message-State: AOJu0YzHpJM7X0EFex5eWXRitFZzFvzv9OYFBlDUBCyypeo6DcDuUWtE JonhMiZ5QeSJGfTT5vQAM24Nn+2Jsdu5gyY0x1Q3gbFJ5CjreTwOk3wY X-Gm-Gg: Acq92OEkKs6G5oof+zd4l9aXv6n7t3TfCeYGiMZY17fzcX6cW1hNzM798Jz8fh5M6LG 40EOSwKeLu+s3GKGwohga+nF4JpvtmjuWDQ7aZGCNEmcfAMv2Ed+XXWdsETLDjhIA2ue0qN0vOM 5nmf9Sndc/lhGWnUqpVnOWIffZO5J5X6b+r894e1R1314PPB7DaLb+WxvSC04BsDlpHdgap1qUm edxHM12A4+KT2tD66HEprnggXEoXP8LudMgBpru0dXpvw9jw9ajp/68QWSD58fuqGWYkHP8FBVL xiky3vjLOg11rmeQoMOc0sIaPqTOmo/88zCFYvMzjXoDBRl6Wt9sKwiChYK0+kXcDNLkAuBtIqc NfFQnBtW0TzMRyhYF9Emkh7c4u7mRn1UznKfG7WIbpzXk/1EqQtxsMtgxD431RTzV/P2pdmhHUN WFKMs38aM9UyKPd3N2bsO7ZkUbZ5HU9qoVKnfSwUxybH/iVvXEWDwky1Qvr+c= X-Received: by 2002:a05:600c:3490:b0:490:b7a2:8864 with SMTP id 5b1f17b1804b1-490b7a28a0amr102093135e9.0.1780567015850; Thu, 04 Jun 2026 02:56:55 -0700 (PDT) Received: from localhost.localdomain ([2a00:23c4:a700:7301:1615:3574:e0c0:837d]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490be1f69bcsm38037335e9.8.2026.06.04.02.56.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2026 02:56:55 -0700 (PDT) From: Biju X-Google-Original-From: Biju To: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Cc: Biju Das , linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven , Prabhakar Mahadev Lad , Biju Das , linux-renesas-soc@vger.kernel.org Subject: [PATCH v6 06/11] pwm: rzg2l-gpt: Convert to waveform callbacks Date: Thu, 4 Jun 2026 10:56:36 +0100 Message-ID: <20260604095647.108654-7-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260604095647.108654-1-biju.das.jz@bp.renesas.com> References: <20260604095647.108654-1-biju.das.jz@bp.renesas.com> 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" From: Biju Das Migrate the rzg2l-gpt driver from the legacy .get_state/.apply ops to the new waveform callback interface. Introduce struct rzg2l_gpt_waveform to represent a hardware waveform configuration holding the period register value (gtpr), compare/capture register value (gtccr), and prescaler (prescale). Signed-off-by: Biju Das --- v5->v6: * Dropped local variables pv and dc from rzg2l_gpt_round_waveform_tohw(). * Dropped blank line in rzg2l_gpt_round_waveform_tohw(). * Moved assignment of rzg2l_gpt->period_ticks[ch] to *_write_waveform(). * Restored clamping of duty_ticks with period_ticks in rzg2l_gpt_round_waveform_tohw(). * Simplified rzg2l_gpt_write_waveform() using else if statement. * Dropped local variable gptr in rzg2l_gpt_write_waveform(). * Moved mutex after early return in rzg2l_gpt_round_waveform_tohw(). v5: * Updated commit description. * Updated rzg2l_gpt_round_waveform_tohw() to initialize gtccr when the period of the second channel is smaller. * Replaced period_ticks with RZG2L_MAX_TICKS for the duty_ticks maximum value check in rzg2l_gpt_round_waveform_tohw(). v4 from [1] [1] https://lore.kernel.org/all/20251208152133.269316-3-biju.das.jz@bp.rene= sas.com/ --- drivers/pwm/pwm-rzg2l-gpt.c | 205 ++++++++++++++++++++++-------------- 1 file changed, 124 insertions(+), 81 deletions(-) diff --git a/drivers/pwm/pwm-rzg2l-gpt.c b/drivers/pwm/pwm-rzg2l-gpt.c index 49b95e53ad83..18e6c0f28e29 100644 --- a/drivers/pwm/pwm-rzg2l-gpt.c +++ b/drivers/pwm/pwm-rzg2l-gpt.c @@ -100,6 +100,13 @@ struct rzg2l_gpt_chip { DECLARE_BITMAP(poeg_gpt_link, RZG2L_MAX_POEG_GROUPS * RZG2L_MAX_HW_CHANNE= LS); }; =20 +/* This represents a hardware configuration for one channel */ +struct rzg2l_gpt_waveform { + u32 gtpr; + u32 gtccr; + u8 prescale; +}; + static inline struct rzg2l_gpt_chip *to_rzg2l_gpt_chip(struct pwm_chip *ch= ip) { return pwmchip_get_drvdata(chip); @@ -166,7 +173,8 @@ static void rzg2l_gpt_free(struct pwm_chip *chip, struc= t pwm_device *pwm) rzg2l_gpt->channel_request_count[ch]--; } =20 -static bool rzg2l_gpt_is_ch_enabled(struct rzg2l_gpt_chip *rzg2l_gpt, u8 h= wpwm) +static bool rzg2l_gpt_is_ch_enabled(struct rzg2l_gpt_chip *rzg2l_gpt, u8 h= wpwm, + u32 *gtcr) { u8 ch =3D RZG2L_GET_CH(hwpwm); u32 val; @@ -175,6 +183,9 @@ static bool rzg2l_gpt_is_ch_enabled(struct rzg2l_gpt_ch= ip *rzg2l_gpt, u8 hwpwm) if (!(val & RZG2L_GTCR_CST)) return false; =20 + if (gtcr) + *gtcr =3D val; + val =3D rzg2l_gpt_read(rzg2l_gpt, RZG2L_GTIOR(ch)); =20 return val & RZG2L_GTIOR_OxE(rzg2l_gpt_subchannel(hwpwm)); @@ -233,56 +244,39 @@ static u64 rzg2l_gpt_calculate_period_or_duty(struct = rzg2l_gpt_chip *rzg2l_gpt, return DIV64_U64_ROUND_UP(tmp, rzg2l_gpt->rate_khz); } =20 -static int rzg2l_gpt_get_state(struct pwm_chip *chip, struct pwm_device *p= wm, - struct pwm_state *state) -{ - struct rzg2l_gpt_chip *rzg2l_gpt =3D to_rzg2l_gpt_chip(chip); - - state->enabled =3D rzg2l_gpt_is_ch_enabled(rzg2l_gpt, pwm->hwpwm); - if (state->enabled) { - u32 sub_ch =3D rzg2l_gpt_subchannel(pwm->hwpwm); - u32 ch =3D RZG2L_GET_CH(pwm->hwpwm); - u8 prescale; - u32 val; - - val =3D rzg2l_gpt_read(rzg2l_gpt, RZG2L_GTCR(ch)); - prescale =3D FIELD_GET(RZG2L_GTCR_TPCS, val); - - val =3D rzg2l_gpt_read(rzg2l_gpt, RZG2L_GTPR(ch)); - state->period =3D rzg2l_gpt_calculate_period_or_duty(rzg2l_gpt, val, pre= scale); - - val =3D rzg2l_gpt_read(rzg2l_gpt, RZG2L_GTCCR(ch, sub_ch)); - state->duty_cycle =3D rzg2l_gpt_calculate_period_or_duty(rzg2l_gpt, val,= prescale); - if (state->duty_cycle > state->period) - state->duty_cycle =3D state->period; - } - - state->polarity =3D PWM_POLARITY_NORMAL; - - return 0; -} - static u32 rzg2l_gpt_calculate_pv_or_dc(u64 period_or_duty_cycle, u8 presc= ale) { return min_t(u64, DIV_ROUND_DOWN_ULL(period_or_duty_cycle, 1 << (2 * pres= cale)), U32_MAX); } =20 -/* Caller holds the lock while calling rzg2l_gpt_config() */ -static int rzg2l_gpt_config(struct pwm_chip *chip, struct pwm_device *pwm, - const struct pwm_state *state) +static int rzg2l_gpt_round_waveform_tohw(struct pwm_chip *chip, + struct pwm_device *pwm, + const struct pwm_waveform *wf, + void *_wfhw) { struct rzg2l_gpt_chip *rzg2l_gpt =3D to_rzg2l_gpt_chip(chip); - u8 sub_ch =3D rzg2l_gpt_subchannel(pwm->hwpwm); + struct rzg2l_gpt_waveform *wfhw =3D _wfhw; + bool is_small_second_period =3D false; u8 ch =3D RZG2L_GET_CH(pwm->hwpwm); u64 period_ticks, duty_ticks; - unsigned long pv, dc; - u8 prescale; + + if (wf->period_length_ns =3D=3D 0) { + *wfhw =3D (struct rzg2l_gpt_waveform){ + .gtpr =3D 0, + .gtccr =3D 0, + .prescale =3D 0, + }; + + return 0; + } =20 /* Limit period/duty cycle to max value supported by the HW */ - period_ticks =3D mul_u64_u64_div_u64(state->period, rzg2l_gpt->rate_khz, = USEC_PER_SEC); + period_ticks =3D mul_u64_u64_div_u64(wf->period_length_ns, rzg2l_gpt->rat= e_khz, USEC_PER_SEC); if (period_ticks > RZG2L_MAX_TICKS) period_ticks =3D RZG2L_MAX_TICKS; + + guard(mutex)(&rzg2l_gpt->lock); /* * GPT counter is shared by the two IOs of a single channel, so * prescale and period can NOT be modified when there are multiple IOs @@ -291,29 +285,84 @@ static int rzg2l_gpt_config(struct pwm_chip *chip, st= ruct pwm_device *pwm, if (rzg2l_gpt->channel_request_count[ch] > 1) { u8 sibling_ch =3D rzg2l_gpt_sibling(pwm->hwpwm); =20 - if (rzg2l_gpt_is_ch_enabled(rzg2l_gpt, sibling_ch)) { + if (rzg2l_gpt_is_ch_enabled(rzg2l_gpt, sibling_ch, NULL)) { if (period_ticks < rzg2l_gpt->period_ticks[ch]) - return -EBUSY; + is_small_second_period =3D true; =20 period_ticks =3D rzg2l_gpt->period_ticks[ch]; } } =20 - prescale =3D rzg2l_gpt_calculate_prescale(period_ticks); - pv =3D rzg2l_gpt_calculate_pv_or_dc(period_ticks, prescale); + wfhw->prescale =3D rzg2l_gpt_calculate_prescale(period_ticks); + wfhw->gtpr =3D rzg2l_gpt_calculate_pv_or_dc(period_ticks, wfhw->prescale); + wfhw->gtccr =3D 0; + if (is_small_second_period) + return 1; =20 - duty_ticks =3D mul_u64_u64_div_u64(state->duty_cycle, rzg2l_gpt->rate_khz= , USEC_PER_SEC); + duty_ticks =3D mul_u64_u64_div_u64(wf->duty_length_ns, rzg2l_gpt->rate_kh= z, USEC_PER_SEC); if (duty_ticks > period_ticks) duty_ticks =3D period_ticks; - dc =3D rzg2l_gpt_calculate_pv_or_dc(duty_ticks, prescale); + wfhw->gtccr =3D rzg2l_gpt_calculate_pv_or_dc(duty_ticks, wfhw->prescale); =20 - /* - * GPT counter is shared by multiple channels, we cache the period ticks - * from the first enabled channel and use the same value for both - * channels. - */ - rzg2l_gpt->period_ticks[ch] =3D period_ticks; + return 0; +} + +static int rzg2l_gpt_round_waveform_fromhw(struct pwm_chip *chip, + struct pwm_device *pwm, + const void *_wfhw, + struct pwm_waveform *wf) +{ + struct rzg2l_gpt_chip *rzg2l_gpt =3D to_rzg2l_gpt_chip(chip); + const struct rzg2l_gpt_waveform *wfhw =3D _wfhw; + + wf->period_length_ns =3D rzg2l_gpt_calculate_period_or_duty(rzg2l_gpt, wf= hw->gtpr, + wfhw->prescale); + wf->duty_length_ns =3D rzg2l_gpt_calculate_period_or_duty(rzg2l_gpt, wfhw= ->gtccr, + wfhw->prescale); + wf->duty_offset_ns =3D 0; + + return 0; +} =20 +static int rzg2l_gpt_read_waveform(struct pwm_chip *chip, + struct pwm_device *pwm, + void *_wfhw) +{ + struct rzg2l_gpt_chip *rzg2l_gpt =3D to_rzg2l_gpt_chip(chip); + struct rzg2l_gpt_waveform *wfhw =3D _wfhw; + u32 sub_ch =3D rzg2l_gpt_subchannel(pwm->hwpwm); + u32 ch =3D RZG2L_GET_CH(pwm->hwpwm); + u32 gtcr; + + guard(mutex)(&rzg2l_gpt->lock); + if (rzg2l_gpt_is_ch_enabled(rzg2l_gpt, pwm->hwpwm, >cr)) { + wfhw->prescale =3D FIELD_GET(RZG2L_GTCR_TPCS, gtcr); + wfhw->gtpr =3D rzg2l_gpt_read(rzg2l_gpt, RZG2L_GTPR(ch)); + wfhw->gtccr =3D rzg2l_gpt_read(rzg2l_gpt, RZG2L_GTCCR(ch, sub_ch)); + if (wfhw->gtccr > wfhw->gtpr) + wfhw->gtccr =3D wfhw->gtpr; + } else { + *wfhw =3D (struct rzg2l_gpt_waveform) { }; + } + + return 0; +} + +static u64 rzg2l_gpt_calculate_cycles(u32 value, u8 prescale) +{ + return (u64)value << (2 * prescale); +} + +static int rzg2l_gpt_write_waveform(struct pwm_chip *chip, + struct pwm_device *pwm, + const void *_wfhw) +{ + struct rzg2l_gpt_chip *rzg2l_gpt =3D to_rzg2l_gpt_chip(chip); + const struct rzg2l_gpt_waveform *wfhw =3D _wfhw; + u8 sub_ch =3D rzg2l_gpt_subchannel(pwm->hwpwm); + u8 ch =3D RZG2L_GET_CH(pwm->hwpwm); + + guard(mutex)(&rzg2l_gpt->lock); /* * Counter must be stopped before modifying mode, prescaler, timer * counter and buffer enable registers. These registers are shared @@ -332,14 +381,16 @@ static int rzg2l_gpt_config(struct pwm_chip *chip, st= ruct pwm_device *pwm, =20 /* Select count clock */ rzg2l_gpt_modify(rzg2l_gpt, RZG2L_GTCR(ch), RZG2L_GTCR_TPCS, - FIELD_PREP(RZG2L_GTCR_TPCS, prescale)); + FIELD_PREP(RZG2L_GTCR_TPCS, wfhw->prescale)); =20 /* Set period */ - rzg2l_gpt_write(rzg2l_gpt, RZG2L_GTPR(ch), pv); + rzg2l_gpt_write(rzg2l_gpt, RZG2L_GTPR(ch), wfhw->gtpr); + } else if (wfhw->gtpr && (wfhw->gtpr < rzg2l_gpt_read(rzg2l_gpt, RZG2L_GT= PR(ch)))) { + return -EBUSY; } =20 /* Set duty cycle */ - rzg2l_gpt_write(rzg2l_gpt, RZG2L_GTCCR(ch, sub_ch), dc); + rzg2l_gpt_write(rzg2l_gpt, RZG2L_GTCCR(ch, sub_ch), wfhw->gtccr); =20 if (rzg2l_gpt->channel_enable_count[ch] <=3D 1) { /* Set initial value for counter */ @@ -348,44 +399,36 @@ static int rzg2l_gpt_config(struct pwm_chip *chip, st= ruct pwm_device *pwm, /* Set no buffer operation */ rzg2l_gpt_write(rzg2l_gpt, RZG2L_GTBER(ch), 0); =20 - /* Restart the counter after updating the registers */ - rzg2l_gpt_modify(rzg2l_gpt, RZG2L_GTCR(ch), - RZG2L_GTCR_CST, RZG2L_GTCR_CST); + if (wfhw->gtpr) + /* Restart the counter after updating the registers */ + rzg2l_gpt_modify(rzg2l_gpt, RZG2L_GTCR(ch), + RZG2L_GTCR_CST, RZG2L_GTCR_CST); } =20 - return 0; -} - -static int rzg2l_gpt_apply(struct pwm_chip *chip, struct pwm_device *pwm, - const struct pwm_state *state) -{ - struct rzg2l_gpt_chip *rzg2l_gpt =3D to_rzg2l_gpt_chip(chip); - bool enabled =3D pwm->state.enabled; - int ret; - - if (state->polarity !=3D PWM_POLARITY_NORMAL) - return -EINVAL; - - guard(mutex)(&rzg2l_gpt->lock); - if (!state->enabled) { - if (enabled) - rzg2l_gpt_disable(rzg2l_gpt, pwm); - - return 0; - } - - ret =3D rzg2l_gpt_config(chip, pwm, state); - if (!ret && !enabled) + if (wfhw->gtpr && !rzg2l_gpt_is_ch_enabled(rzg2l_gpt, pwm->hwpwm, NULL)) { rzg2l_gpt_enable(rzg2l_gpt, pwm); + /* + * GPT counter is shared by multiple channels, we cache the + * period ticks from the first enabled channel and use the same + * value for both channels. + */ + rzg2l_gpt->period_ticks[ch] =3D rzg2l_gpt_calculate_cycles(wfhw->gtpr, + wfhw->prescale); + } else if (!wfhw->gtpr && rzg2l_gpt_is_ch_enabled(rzg2l_gpt, pwm->hwpwm, = NULL)) { + rzg2l_gpt_disable(rzg2l_gpt, pwm); + } =20 - return ret; + return 0; } =20 static const struct pwm_ops rzg2l_gpt_ops =3D { .request =3D rzg2l_gpt_request, .free =3D rzg2l_gpt_free, - .get_state =3D rzg2l_gpt_get_state, - .apply =3D rzg2l_gpt_apply, + .sizeof_wfhw =3D sizeof(struct rzg2l_gpt_waveform), + .round_waveform_tohw =3D rzg2l_gpt_round_waveform_tohw, + .round_waveform_fromhw =3D rzg2l_gpt_round_waveform_fromhw, + .read_waveform =3D rzg2l_gpt_read_waveform, + .write_waveform =3D rzg2l_gpt_write_waveform, }; =20 /* --=20 2.43.0 From nobody Mon Jun 8 09:49:58 2026 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 6EF933DB632 for ; Thu, 4 Jun 2026 09:56:58 +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=1780567020; cv=none; b=bgHHxXH94Jnp+kivaXG/f0numotzuXeWE1V5/sQmNEjXWpZgYZ2deEwv8n9GMI6GhdevOSFXmQg/GWCjfuw5crlm2FkfaYs8ddNL8GpkOMLctr5bVtKS1k731NauR5Ywwk9EeNnJIeCD0ROLGJCMD5uu3/O06p2Ev4YX8BoO+GA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780567020; c=relaxed/simple; bh=7k9zOJLQmwMA/uzYIEjXOvz20d0UsGHSnWUHZU6C/nA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dOKeP8riXcyYf94A5Zkz6VMi69RChhrCMtJcHq07V10iaPWeKAikwFTt7t24JzAjDDR6Z+Y84kf2NPmOJzSiWImoVOi88m7nu+mG8OjYvbYNCTfWpwso7TQcxZ+4IpAYGjYU/vW3fLSi+i2im1IGa9kI//9U2r434WOZjpc3tuo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Opfn+kfT; arc=none smtp.client-ip=209.85.128.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Opfn+kfT" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-490ae94a89eso4810855e9.1 for ; Thu, 04 Jun 2026 02:56:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780567017; x=1781171817; 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=a5m4IybCJvRhAGS6FWlVTrHuns1jqnPal3+xcRsaPBs=; b=Opfn+kfTunl5vKIxlP7ahtKla8gu65LCou0ae0mOdksuCKYIYZimfx3ElTAv/FERrU rsujUIBbOZES1EupyVVxLWnfhlSbM/rYu0Mh0OVBfQ2tkX8OwkbDkZ8KsotkpViYZ3td 8+h6LEl6XzSev2d5Az4HUpiOTUXnBLHN/RVxHGSIjpfhT4RPxYRZnGM6GEIe0oew0MGC BPHfvEsfR5VhUJZdzT/Z2oaJORJlfAALPMaKACgHtgEwVGB5+e9RNRQAMLA16TVLQtU6 BrXN4ut/TB8xJB3sg/Osqr1ONjqkKEtzlr/LNdNXThmUndqmG5nMSxVsYrgO76DPhelM RRsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780567017; x=1781171817; 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=a5m4IybCJvRhAGS6FWlVTrHuns1jqnPal3+xcRsaPBs=; b=UUh96glN2O/AFuskJsuZqUhJcqQpjv8YR4XP9OJyO1I2/m/NsWlUFXPKG1duZuhZrO Gkw+LdCHgbgGszjEod/bLIsIeeMBhU+nDqvn3RW5bKhns2hZ8PB+Pljnz3RLUKZHCtJO vgEfcuBvdpRuMGrDpjh54gKHBaDErcKfeDqlWLR2AKIJsWhdCxm+FO9R4JvS1rJLs87q G+MBFcKgTbad3+PQhGzMFOUCOJ5nJ0ldF4/9DbURJtgjEyohoudLPuZ/kqUa+EnH5k8s Xg15kq2fpA78fWJszRj7S7MBHkfyEZsuVmaDvlSK+dFIFsHZG25o3fx3tqRo6OHCR1YQ iDfw== X-Forwarded-Encrypted: i=1; AFNElJ+d0ImtkWsAnlz6cGs5F5PIphpiJqY+dmI0sklq5uXOftO3mpTYX2UxGg8ynDRUYrspZUbk0MgoAoULp8Q=@vger.kernel.org X-Gm-Message-State: AOJu0YxOj2+98fZFobfZdaxhLR6jr96t+JXZn6xtdEp11hbocBy1WWQU 5Lb1YGBZRXYVxVCkmot6r2iEWf/1G4QfjUHgU63hy7F6y2nTTk7cAvv8 X-Gm-Gg: Acq92OEaHHb0UijsbhKPIp/MeR5D9z8YVjcAHcgW7D8YBH+Kc9/G8N/k5+4KY/u1y+S PnPwaea39etzIRRmquIubVq+fNt8gwp5tlsWUS4kn9fGgHEhro7viEc4r5DZJ1DONVqxORV5k8O v0sP/jZgg4K5uEaUXpsF7a9oYWkfb3Pp9YAQu1dOnMpGYLwIbw/qFrgWNwKK3I2AS+MA/THNkeF 1zAllNqDT2rgXImJcT25DAAKRd5Pwws3Yql+7p6iERrfh/nuX5vqLqZzRzNeKERAW2BKXi1FBlr 4MJ7rYuUee9b/JIH3T0DCnTm+gwvPExpfT4XTvxVJRn1vG8gDSxwYAKXbJJqAnsTmy1ge6UoRxH ZzN/8E/g22J0f4LOChddUMa39ZmK9kdAPOVMlBss+T5QTr8Lj7P6c7Eg67OGkUtjuSTJtAuzXxa WkmxaGTbCXc/htIfalnoVTYOjcXoOVihGyPwwPsDd+wuzpncBy4h6EizwGjlw= X-Received: by 2002:a05:600c:4fcc:b0:490:59cc:999f with SMTP id 5b1f17b1804b1-490b5ea1016mr120694265e9.4.1780567016697; Thu, 04 Jun 2026 02:56:56 -0700 (PDT) Received: from localhost.localdomain ([2a00:23c4:a700:7301:1615:3574:e0c0:837d]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490be1f69bcsm38037335e9.8.2026.06.04.02.56.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2026 02:56:56 -0700 (PDT) From: Biju X-Google-Original-From: Biju To: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Geert Uytterhoeven , Magnus Damm Cc: Biju Das , linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Prabhakar Mahadev Lad , Biju Das , Tommaso Merciai Subject: [PATCH v6 07/11] pwm: rzg2l-gpt: Add info variable to struct rzg2l_gpt_chip Date: Thu, 4 Jun 2026 10:56:37 +0100 Message-ID: <20260604095647.108654-8-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260604095647.108654-1-biju.das.jz@bp.renesas.com> References: <20260604095647.108654-1-biju.das.jz@bp.renesas.com> 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" From: Biju Das Introduce struct rzg2l_gpt_info to capture SoC-specific hardware differences, starting with the gtcr_tpcs field mask for the prescaler bitfield in GTCR. This is needed because the RZ/G3E GPT has a 4-bit prescaler field versus the 3-bit field on RZ/G2L. Reviewed-by: Tommaso Merciai Signed-off-by: Biju Das --- v5->v6: * No change. v4->v5: * Updated commit description. v3->v4: * Dropped field_{get,prep} as mainline now support it. * Updated commit description. * Retained RZG2L_GTCR_TPCS bit definitons * Replaced gtcr_tpcs_mask->gtcr_tpcs v2->v3: * No change. v1->v2: * Collected tag. --- drivers/pwm/pwm-rzg2l-gpt.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/pwm/pwm-rzg2l-gpt.c b/drivers/pwm/pwm-rzg2l-gpt.c index 18e6c0f28e29..3ee5a70ca265 100644 --- a/drivers/pwm/pwm-rzg2l-gpt.c +++ b/drivers/pwm/pwm-rzg2l-gpt.c @@ -90,9 +90,14 @@ #define RZG2L_MAX_POEG_GROUPS 4 #define RZG2L_LAST_POEG_GROUP 3 =20 +struct rzg2l_gpt_info { + u32 gtcr_tpcs; +}; + struct rzg2l_gpt_chip { void __iomem *mmio; struct mutex lock; /* lock to protect shared channel resources */ + const struct rzg2l_gpt_info *info; unsigned long rate_khz; u64 period_ticks[RZG2L_MAX_HW_CHANNELS]; u32 channel_request_count[RZG2L_MAX_HW_CHANNELS]; @@ -336,7 +341,7 @@ static int rzg2l_gpt_read_waveform(struct pwm_chip *chi= p, =20 guard(mutex)(&rzg2l_gpt->lock); if (rzg2l_gpt_is_ch_enabled(rzg2l_gpt, pwm->hwpwm, >cr)) { - wfhw->prescale =3D FIELD_GET(RZG2L_GTCR_TPCS, gtcr); + wfhw->prescale =3D field_get(rzg2l_gpt->info->gtcr_tpcs, gtcr); wfhw->gtpr =3D rzg2l_gpt_read(rzg2l_gpt, RZG2L_GTPR(ch)); wfhw->gtccr =3D rzg2l_gpt_read(rzg2l_gpt, RZG2L_GTCCR(ch, sub_ch)); if (wfhw->gtccr > wfhw->gtpr) @@ -380,8 +385,8 @@ static int rzg2l_gpt_write_waveform(struct pwm_chip *ch= ip, rzg2l_gpt_write(rzg2l_gpt, RZG2L_GTUDDTYC(ch), RZG2L_GTUDDTYC_UP_COUNTIN= G); =20 /* Select count clock */ - rzg2l_gpt_modify(rzg2l_gpt, RZG2L_GTCR(ch), RZG2L_GTCR_TPCS, - FIELD_PREP(RZG2L_GTCR_TPCS, wfhw->prescale)); + rzg2l_gpt_modify(rzg2l_gpt, RZG2L_GTCR(ch), rzg2l_gpt->info->gtcr_tpcs, + field_prep(rzg2l_gpt->info->gtcr_tpcs, wfhw->prescale)); =20 /* Set period */ rzg2l_gpt_write(rzg2l_gpt, RZG2L_GTPR(ch), wfhw->gtpr); @@ -525,6 +530,8 @@ static int rzg2l_gpt_probe(struct platform_device *pdev) if (IS_ERR(rzg2l_gpt->mmio)) return PTR_ERR(rzg2l_gpt->mmio); =20 + rzg2l_gpt->info =3D of_device_get_match_data(dev); + rstc =3D devm_reset_control_get_exclusive_deasserted(dev, NULL); if (IS_ERR(rstc)) return dev_err_probe(dev, PTR_ERR(rstc), "Cannot deassert reset control\= n"); @@ -571,8 +578,12 @@ static int rzg2l_gpt_probe(struct platform_device *pde= v) return 0; } =20 +static const struct rzg2l_gpt_info rzg2l_data =3D { + .gtcr_tpcs =3D RZG2L_GTCR_TPCS, +}; + static const struct of_device_id rzg2l_gpt_of_table[] =3D { - { .compatible =3D "renesas,rzg2l-gpt", }, + { .compatible =3D "renesas,rzg2l-gpt", .data =3D &rzg2l_data }, { /* Sentinel */ } }; MODULE_DEVICE_TABLE(of, rzg2l_gpt_of_table); --=20 2.43.0 From nobody Mon Jun 8 09:49:58 2026 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 678083CAA5E for ; Thu, 4 Jun 2026 09:56:59 +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=1780567021; cv=none; b=MEljIRjevsoOaWuR9ntGgc3x0rZ+tR1E/OShsy/UBN1KRkPRrnFVT0boCOVHmwNLPskPIzmVDwDVZ7iqZKW4E5UpElDgsXS87GLk0lVPDEBuJPjBfDF56OFR4owmfyPxtUX4OLzSDQYdS1UYm7yAutw3Nno38ucRysT1azfFlfM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780567021; c=relaxed/simple; bh=uEIhjPWjaq8rpVHKXdCy1CAe3eGcNxikkPVyLTDFfXE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Y1TfRfepRZH5csrSdPTBwJxSOHUtO6nORoNxLAu18C+7MDTBNU917dVVjy2R2wxgKzmt6SrTv5poUWenhkwSmad34rBrZ/i545SbK3Wu7Lr4JipKbGGH/GrCzaBqkZjhf7CQF9K4W4XIbw2pL4wmg7/dLc1egGX75gtW5/HLpH8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=cmnueLEj; arc=none smtp.client-ip=209.85.128.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cmnueLEj" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-4905529b933so5442725e9.0 for ; Thu, 04 Jun 2026 02:56:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780567018; x=1781171818; 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=2eeFO3Vk65Lc6zMxBzrYaIBsCoZCZ8S4g/NBNLR0pfQ=; b=cmnueLEj3QSK0Ka0ch/KgtaMcKA3aBaMGI1dz1YJs29ik2aRadf+fNMaQh//BFvSyU h7ruSorqZ8n+Nsphl6hsOEOKYrJ3HJO+UMEKRt9ytPSL3OevkannfFLAb99L5Jec1w4b SKobBwSfUj7ZN1Zx+ergJbxRSnhzm6dHWcHz0KZrkCexAEZ4eTgQ6RqfKVdl6PJJ1YcI qzsFydBAlPpkpT6+kPvozldWos8raxtKJnzybKQWV4/cLpKpW+eYV3LOZOmd/tFdw6nP s2RMPegRev55nuu5sl1wUabxR3A7K19a7aWWtF8jBfJIOwYWJju5RBytVYcAZgQhxViL 3BSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780567018; x=1781171818; 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=2eeFO3Vk65Lc6zMxBzrYaIBsCoZCZ8S4g/NBNLR0pfQ=; b=NSre7qXNCkvuGzwIZwPJFAaqKQdddqb9O/1WbDU7yMRRDsgQ1SMg2YkUyZWNamZVxx VyMcrEjC4cyXAbdsTKxKl7hSbIDL0QXCE3LcaeYu0d89/rvnpDyzkNuXTdToX29aEN0f GIa2ybJIMGP9b5d3p90VsMrrE3igG57QIp9VCeAa5mYhPa9TcF5r6zHRbiTx8qtjFEQv PMBgtT9C0IkDAryc2ycMY5JW3eWilLb0dgFWguzh0WprWdKAottBhok1feYRRTnzYQD+ fUlW+ihJa9Z2HR4ijhEaBeQsQMHLLt7eO3/vWZSMu/pHC5ln3jk7MgYsFa2jx+g8mNLW DyiQ== X-Forwarded-Encrypted: i=1; AFNElJ+JRgMj2fB533h4YdaWEA5kXdaEdnxcdsSaLYmVYCEChZWTsRPvBAOh64pd7/opNHy/yO13Bh/4TA5tnxI=@vger.kernel.org X-Gm-Message-State: AOJu0Yzx3CdyO+/N7oRHvqnHhiTE3LQMjQ2t7DOWEvkSFfOG/v9MdGeI 3VGwZbVpLKIt2dvlq58gGCghqG6l0R4QYBUsHTxPKU2goXaAVqgKjBwr X-Gm-Gg: Acq92OFKe+OPRbJVQv0SvOjgyKQM9MBhiPExFPEME1tKDiW6NUJGaGrMiN51xPj7owE m/CDUkUkX77DLl8aB54tRACetMcUnCQ5+GJ1MO9TvMrJG3Vpuli6295+jj31KVuxCQZvSR98K1w s8Hm91iL+QhQC6QbMfskhGyRMr6bP3z3tX2cfvh9wSOMKE7HFb0OQVuIEeFHlN5MEfcv4eCZjQt VCb30xsMYn6XMR8+LZNHJT+ZDv1GO33Xi/lcxis6Gh3CmGN1Dt0yP4mERIQuOgFkrqUOjUXLbpM oQxC58XAEmHZ641SI97KisJIVExEgaxlZ5VKVy3k4uhSPaAw8m8rA51fJQRuSyh3sfwuChTQNrI SoF2LAYG1bPReT+otUN+pMQ4QpQIzf5EN4SgQD5a7C7hz8JPc6bGNOvDEYmsrMNouNPEDysyLzB bYH74Coef+earnqQWastX04/PGMlCL+jNXae7Z49YYyqR9Q+ycFc84jokcXtM= X-Received: by 2002:a05:600c:1381:b0:490:a1be:6b01 with SMTP id 5b1f17b1804b1-490b5e64659mr120340375e9.4.1780567017574; Thu, 04 Jun 2026 02:56:57 -0700 (PDT) Received: from localhost.localdomain ([2a00:23c4:a700:7301:1615:3574:e0c0:837d]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490be1f69bcsm38037335e9.8.2026.06.04.02.56.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2026 02:56:57 -0700 (PDT) From: Biju X-Google-Original-From: Biju To: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Cc: Biju Das , linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven , Prabhakar Mahadev Lad , Biju Das , linux-renesas-soc@vger.kernel.org, Tommaso Merciai Subject: [PATCH v6 08/11] pwm: rzg2l-gpt: Add prescale_mult variable to struct rzg2l_gpt_info Date: Thu, 4 Jun 2026 10:56:38 +0100 Message-ID: <20260604095647.108654-9-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260604095647.108654-1-biju.das.jz@bp.renesas.com> References: <20260604095647.108654-1-biju.das.jz@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: Biju Das RZ/G3E GPT IP has prescale factor power of 2 where as that of RZ/G2L is 4. Add prescale_mult variable to struct rzg2l_gpt_info for handling this difference. Reviewed-by: Tommaso Merciai Signed-off-by: Biju Das --- v5->v6: * Dropped extra parameter rzg2l_gpt from rzg2l_gpt_calculate_prescale() in rzg2l_gpt_round_waveform_tohw(). * Updated comment in rzg2l_gpt_calculate_period_or_duty(). v4->v5: * No change. v3->v4: * Updated commit header and description * Renamed prescale_pow_of_two_mult_factor->prescale_mult v2->v3: * No change. v1->v2: * Collected tag. --- drivers/pwm/pwm-rzg2l-gpt.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/drivers/pwm/pwm-rzg2l-gpt.c b/drivers/pwm/pwm-rzg2l-gpt.c index 3ee5a70ca265..4f3b4dd959e6 100644 --- a/drivers/pwm/pwm-rzg2l-gpt.c +++ b/drivers/pwm/pwm-rzg2l-gpt.c @@ -92,6 +92,7 @@ =20 struct rzg2l_gpt_info { u32 gtcr_tpcs; + u8 prescale_mult; }; =20 struct rzg2l_gpt_chip { @@ -234,24 +235,29 @@ static void rzg2l_gpt_disable(struct rzg2l_gpt_chip *= rzg2l_gpt, static u64 rzg2l_gpt_calculate_period_or_duty(struct rzg2l_gpt_chip *rzg2l= _gpt, u32 val, u8 prescale) { + const struct rzg2l_gpt_info *info =3D rzg2l_gpt->info; u64 tmp; =20 /* - * The calculation doesn't overflow an u64 because prescale =E2=89=A4 5 a= nd so - * tmp =3D val << (2 * prescale) * USEC_PER_SEC + * The calculation doesn't overflow a u64 because, + * prescale =E2=89=A4 5 for info->prescale_mult =3D 2 and so + * tmp =3D val << (info->prescale_mult * prescale) * USEC_PER_SEC * < 2^32 * 2^10 * 10^6 * < 2^32 * 2^10 * 2^20 * =3D 2^62 */ - tmp =3D (u64)val << (2 * prescale); + tmp =3D (u64)val << (info->prescale_mult * prescale); tmp *=3D USEC_PER_SEC; =20 return DIV64_U64_ROUND_UP(tmp, rzg2l_gpt->rate_khz); } =20 -static u32 rzg2l_gpt_calculate_pv_or_dc(u64 period_or_duty_cycle, u8 presc= ale) +static u32 rzg2l_gpt_calculate_pv_or_dc(const struct rzg2l_gpt_info *info, + u64 period_or_duty_cycle, u8 prescale) { - return min_t(u64, DIV_ROUND_DOWN_ULL(period_or_duty_cycle, 1 << (2 * pres= cale)), + return min_t(u64, + DIV_ROUND_DOWN_ULL(period_or_duty_cycle, + 1 << (info->prescale_mult * prescale)), U32_MAX); } =20 @@ -261,6 +267,7 @@ static int rzg2l_gpt_round_waveform_tohw(struct pwm_chi= p *chip, void *_wfhw) { struct rzg2l_gpt_chip *rzg2l_gpt =3D to_rzg2l_gpt_chip(chip); + const struct rzg2l_gpt_info *info =3D rzg2l_gpt->info; struct rzg2l_gpt_waveform *wfhw =3D _wfhw; bool is_small_second_period =3D false; u8 ch =3D RZG2L_GET_CH(pwm->hwpwm); @@ -299,7 +306,7 @@ static int rzg2l_gpt_round_waveform_tohw(struct pwm_chi= p *chip, } =20 wfhw->prescale =3D rzg2l_gpt_calculate_prescale(period_ticks); - wfhw->gtpr =3D rzg2l_gpt_calculate_pv_or_dc(period_ticks, wfhw->prescale); + wfhw->gtpr =3D rzg2l_gpt_calculate_pv_or_dc(info, period_ticks, wfhw->pre= scale); wfhw->gtccr =3D 0; if (is_small_second_period) return 1; @@ -307,7 +314,7 @@ static int rzg2l_gpt_round_waveform_tohw(struct pwm_chi= p *chip, duty_ticks =3D mul_u64_u64_div_u64(wf->duty_length_ns, rzg2l_gpt->rate_kh= z, USEC_PER_SEC); if (duty_ticks > period_ticks) duty_ticks =3D period_ticks; - wfhw->gtccr =3D rzg2l_gpt_calculate_pv_or_dc(duty_ticks, wfhw->prescale); + wfhw->gtccr =3D rzg2l_gpt_calculate_pv_or_dc(info, duty_ticks, wfhw->pres= cale); =20 return 0; } @@ -353,9 +360,9 @@ static int rzg2l_gpt_read_waveform(struct pwm_chip *chi= p, return 0; } =20 -static u64 rzg2l_gpt_calculate_cycles(u32 value, u8 prescale) +static u64 rzg2l_gpt_calculate_cycles(u32 value, u8 mult, u8 prescale) { - return (u64)value << (2 * prescale); + return (u64)value << (mult * prescale); } =20 static int rzg2l_gpt_write_waveform(struct pwm_chip *chip, @@ -363,6 +370,7 @@ static int rzg2l_gpt_write_waveform(struct pwm_chip *ch= ip, const void *_wfhw) { struct rzg2l_gpt_chip *rzg2l_gpt =3D to_rzg2l_gpt_chip(chip); + const struct rzg2l_gpt_info *info =3D rzg2l_gpt->info; const struct rzg2l_gpt_waveform *wfhw =3D _wfhw; u8 sub_ch =3D rzg2l_gpt_subchannel(pwm->hwpwm); u8 ch =3D RZG2L_GET_CH(pwm->hwpwm); @@ -418,6 +426,7 @@ static int rzg2l_gpt_write_waveform(struct pwm_chip *ch= ip, * value for both channels. */ rzg2l_gpt->period_ticks[ch] =3D rzg2l_gpt_calculate_cycles(wfhw->gtpr, + info->prescale_mult, wfhw->prescale); } else if (!wfhw->gtpr && rzg2l_gpt_is_ch_enabled(rzg2l_gpt, pwm->hwpwm, = NULL)) { rzg2l_gpt_disable(rzg2l_gpt, pwm); @@ -580,6 +589,7 @@ static int rzg2l_gpt_probe(struct platform_device *pdev) =20 static const struct rzg2l_gpt_info rzg2l_data =3D { .gtcr_tpcs =3D RZG2L_GTCR_TPCS, + .prescale_mult =3D 2, }; =20 static const struct of_device_id rzg2l_gpt_of_table[] =3D { --=20 2.43.0 From nobody Mon Jun 8 09:49:58 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 0D3BF3FE659 for ; Thu, 4 Jun 2026 09:56:59 +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=1780567021; cv=none; b=re2Kv02WPI+T7iWkqaknxIFNOZBf+5Lj+KWkoQfHqBHoFrOsxmPtQYfj6FlDugqaWP/ByKyZZQXgcO5yyodRlwhVMKG9ByG2gS0I0YmWKLB4odUW8ki0knxMd90XUfAE3EGNroxl6MiUQ2l/89VXZh4ntXleOm/wLkDJDPToFv8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780567021; c=relaxed/simple; bh=DSOrnh+y1FR5hznD6d87goguRPCs/nf79LO/QwtZvLs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=efLMvCnn2a8zTp5Y1mddEGxMlv7kIkDnWyvt0Tj9gBtxiJQdzFRq0bcRPA1Oy3iP+fTW+B6K+79GJRJUa7AMZeiqEJEk0w/Z7IjEXWOd9Ifb/64ZF58qBZzbLrlhoP0mOEda44TfogGaLcfV80C2gItzOQiyFpCvFDMZ8MFqEto= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=EO/2fHqq; arc=none smtp.client-ip=209.85.128.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EO/2fHqq" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-490ae94a89eso4811215e9.1 for ; Thu, 04 Jun 2026 02:56:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780567018; x=1781171818; 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=0+OfL2gz90L3t0N5J/m3NQlBjpG1dV2rmeosaocF/dE=; b=EO/2fHqqptII7S5/MbSpi4XZB7E0hoqgA2NM3CtTdNMP9oca9lAdJcieDRZAMjL0o4 oDjuw4HLpWRoOJu7iaxJvSAvtTVefmhT0EaL5b/Eogbm0qnWvzexlXZz4xBv9A7TO3wv OpJ7iDlxXPtqOIGxuZoZHrhzTt+iOe5Wp0pkopQL2MgtxZgg9t4kq2crWR7hXJFM2z8+ U9QnEgJPBc5jV9zBZvQQk9gHCwap3apcPZCGAhVyzQVncbLZSlyPP209TwFyoM6xliMM 5BCL9vQTCWI2mtWhYNJOxM6VnlXNvA2kVZzv1T+T6uErxPjS5zIJNuNGh1u6i5FkhKTV nTgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780567018; x=1781171818; 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=0+OfL2gz90L3t0N5J/m3NQlBjpG1dV2rmeosaocF/dE=; b=KzMi6QonSrcuD4kEXCKweB806G/6f/ujJgXM+4giVR3apjhKc4NrVSC0zjLfSgViGR 5pQlZZu2ssweqMYjZbGJdydylnD4n10/4ErpzHRX2j/55Aig++8Q0OPGjQb5lHJ6PK/i QT3ja2M4EJ1wiNTBEky0gh+VP7cdGjbw+p7+voRteHdL0xYjugzYc0srgtazEiBdpVKx L9WXWsfzg4DFdboH5C+rkNdWPxsFmHWvVgd8A424bz2KA3IZVVK6Xusu8YInQbgDcmwD Yk/gWx/Hl8btJefPwnJLm8Z6XnfBJeJYznqAa38Sbn6clOiZk3+f+EDXztb1voPQmSc1 2I1g== X-Forwarded-Encrypted: i=1; AFNElJ8PsnqARSrgfLauL/f8KufI9PeDcuZWCRqP2xeweDmnad6xz1t+G6Ot4gAStjf9vqRXTV5UlHvwwJECKO0=@vger.kernel.org X-Gm-Message-State: AOJu0Yy74JncfaNmKLwjgwjjIWgku9twaj4Iu1XrMUihHBqVTLCFyk5q 4DcmckkUU1yY7hmX4UNtJz7u9/+B3eJ/hDfLbJ1a3e4XEO/b9pzRY2X7 X-Gm-Gg: Acq92OFeFu48/XsfELtbPXOPSVg1EQ5vpBkNALReRDOP4ScfpJJuvxFFK0RHFk822uK AAcMuWMHKru7Q8VuJNy6fsjLxWHn0Oy6G8XNhXebwsKTLISctVOCk7rAAlqkTiBl4DwUNYNcm3F Oxoajfqq+23ShUai5NgyvmoyOqfIMbIoDBYEd6i2r8tvnoNyqr0C4jeyipWX5/l88LKVnZdD0IQ U85qT51x5BwA0y8zZOiJfcBWM5mOrNY7CCQWv5auprQ3L5393yMALAGKch4OxLvFf90rSI0zbZv jBL2kIa31z1e28kJz6WXqimi8VHWdRk3/lVkF1+diKMC9IsC8IzAc06E/4KepyBWIx3ERuoPdHV Qo+RBAK+k6U5i0Nx/5TzzpuUVVtR+CvkKoMvkWTzTC4lDd8ttN3zQZQasF9wHaSX0vMXw4tQ1ET w8tmcS7XPgWdtnx3kxpvEISL4BrP2sSct7HL/v7ylU2xwnkATk/7MJV72Her4vhECBbnNU7A== X-Received: by 2002:a05:600c:354e:b0:48a:75b9:b0bc with SMTP id 5b1f17b1804b1-490b60edb8bmr112259485e9.29.1780567018421; Thu, 04 Jun 2026 02:56:58 -0700 (PDT) Received: from localhost.localdomain ([2a00:23c4:a700:7301:1615:3574:e0c0:837d]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490be1f69bcsm38037335e9.8.2026.06.04.02.56.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2026 02:56:58 -0700 (PDT) From: Biju X-Google-Original-From: Biju To: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Cc: Biju Das , linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven , Prabhakar Mahadev Lad , Biju Das , linux-renesas-soc@vger.kernel.org, Tommaso Merciai Subject: [PATCH v6 09/11] pwm: rzg2l-gpt: Add calculate_prescale() callback to struct rzg2l_gpt_info Date: Thu, 4 Jun 2026 10:56:39 +0100 Message-ID: <20260604095647.108654-10-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260604095647.108654-1-biju.das.jz@bp.renesas.com> References: <20260604095647.108654-1-biju.das.jz@bp.renesas.com> 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" From: Biju Das The RZ/G2L GPT prescaler steps are continuous powers of 4, while RZ/G3E uses powers of 2 but with a discontinuous sequence. Add a calculate_prescale function pointer to struct rzg2l_gpt_info to allow per-SoC prescaler selection logic. Replace the direct call to rzg2l_gpt_calculate_prescale() in rzg2l_gpt_round_waveform_tohw() with an indirect call through info->calculate_prescale(). Wire the existing rzg2l_gpt_calculate_prescale() into rzg2l_data to preserve current RZ/G2L behaviour. Reviewed-by: Tommaso Merciai Signed-off-by: Biju Das --- v5->v6: * No change. v4->v5: * Updated commit description. v3->v4: * No change. v2->v3: * No change. v1->v2: * Collected tag. --- drivers/pwm/pwm-rzg2l-gpt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/pwm/pwm-rzg2l-gpt.c b/drivers/pwm/pwm-rzg2l-gpt.c index 4f3b4dd959e6..7e669406dcdd 100644 --- a/drivers/pwm/pwm-rzg2l-gpt.c +++ b/drivers/pwm/pwm-rzg2l-gpt.c @@ -91,6 +91,7 @@ #define RZG2L_LAST_POEG_GROUP 3 =20 struct rzg2l_gpt_info { + u8 (*calculate_prescale)(u64 period); u32 gtcr_tpcs; u8 prescale_mult; }; @@ -305,7 +306,7 @@ static int rzg2l_gpt_round_waveform_tohw(struct pwm_chi= p *chip, } } =20 - wfhw->prescale =3D rzg2l_gpt_calculate_prescale(period_ticks); + wfhw->prescale =3D info->calculate_prescale(period_ticks); wfhw->gtpr =3D rzg2l_gpt_calculate_pv_or_dc(info, period_ticks, wfhw->pre= scale); wfhw->gtccr =3D 0; if (is_small_second_period) @@ -588,6 +589,7 @@ static int rzg2l_gpt_probe(struct platform_device *pdev) } =20 static const struct rzg2l_gpt_info rzg2l_data =3D { + .calculate_prescale =3D rzg2l_gpt_calculate_prescale, .gtcr_tpcs =3D RZG2L_GTCR_TPCS, .prescale_mult =3D 2, }; --=20 2.43.0 From nobody Mon Jun 8 09:49:58 2026 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 1D7903FF885 for ; Thu, 4 Jun 2026 09:57:00 +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=1780567023; cv=none; b=Ih/F5GQH43RWuGZR8oQTKVFjbNZOzStle7T3cAoWXJFBsZoividSGC1KD3G1vkttuQ7SxJUZs2Cv9ZtVm73LRjT/QKNluMrg29OHFvYoEN749h7Wf132Sg/ZFquPrg44lWTDiYvk+v7xQNEA1GBkuQ9Kclbo3Ep1ISmBJGY6zDM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780567023; c=relaxed/simple; bh=evaDaa31llaNDA1fKuLNIMrcVIoSuwe6xA6Yyspx69Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aEYt0TaxqJVYL20vj+MtK6AyzbrRlpbCUEvBVS/UIHNIoDdeyEdTKt40HZs/ACgkymH7pW6tHWRF72C/4SquVBnwnUnCIOBZHBUjJGHNIcPqrSeZKBXQN4WnyGuluLXK7ZngHucL+oy52uTsRYtqjtOEDqSjRMAoascQ3cVjxdE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=nK/cY5WR; arc=none smtp.client-ip=209.85.128.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nK/cY5WR" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-4903f7a90d1so5158995e9.2 for ; Thu, 04 Jun 2026 02:57:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780567019; x=1781171819; 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=sKLaORJorgMTbBd/sx2zZmtjtloHrdymYnVNk+b0fwk=; b=nK/cY5WRPlTr/WPviRVz8Plji3lOsJqD1gv44UxxCOkOJwsx/3NaK2aHx1MhdEY7iA YNgvzNDLu5B5BhXpgRgrZuzlzQHbBKzWFTaeg3taIMIsZS5joqETcy9u4W5PQJkpWB9f 0Yrpv5NwbtdZDlBQ8Sdd4aaLQ05ysL7yIHE4yLzTS43L42Vi0ayWUP4KoRWZEBHDdEEq 2l1V2asQIyA1y/BYEq3ZxGyadl9MHoDDjSnqqrF6jT6sHIklHX/zzgoL6SurtAK8J/63 TbuvspgKGzQYicPZn/QXUAcxXYNI7dM454s6702NNp8Sl6WhlGxDWQ7Ro5g38kgIhBmD OqNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780567019; x=1781171819; 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=sKLaORJorgMTbBd/sx2zZmtjtloHrdymYnVNk+b0fwk=; b=W6q6CC3fWywl1aqcLbzSnhWcCime+wRUZDuJZn3X5yWxV6g15xPSOOwsqc9j+9PpFc N1pLBwqCfcF+KKsy/DsFuv9fY0DVqdJ/ybIWgBU+nRlpAjCxrWHizv+Wgwi3CngdhCwD 8WMW6uyk2WWPqDhgsdjjb4l4SEq7lH4NcIe+mhA85twsQkkapN0a9JyUbzTKt7vygo1u VzUKnfshWmAnVEpfw+fBRIfZA71o65trPWK1r5oxOUcWT2z9sDlwLTB5lkwodBCSL2cj EA8P07a9XZ+4t86hs2kZg39x5pVgldlGuhC3MyB0zrlWPrb4/yuV9m+fIOhGdsYmWiKs 3K0g== X-Forwarded-Encrypted: i=1; AFNElJ8FW6sKvjcE2/g4THQhehbJf1N89kKReVFo7mFdCiVIsvjb3Y2+/vpVpeZXxrE2hwveijkAb1nais9yEFQ=@vger.kernel.org X-Gm-Message-State: AOJu0YxWxB5Z1u85tE9eZEapgvuCBBtP5hEc1BeVixcNhDbIWncitHiY 27DIcrbOWTtNZYiiVuV2dSDICjsZdDMUJbAlcrvMy2K2/GX48yXbGvgp X-Gm-Gg: Acq92OGoWsRLhDfaUCHrkzjSU9iD04W0x4XCVrPTEV5RTbbMGa7WxUcIjFhOBzkaQqC HWm6G/vnSeVizivUhp7YobsalTV0HHaBL2HR9iBWirBr3+ltctBWGDbP2UUFWM8NzhZFkO9vxaX DGCd6uQSjUDlqVuOYLiBFIv+zPEOnuL38HmuMTmnG243T3wcXhJq+DNEVd1uTqZfUX9+Rmqm7at woc4MhqhYvNDpyWvYip1xWjmvgxcBaHCu1nGA10nuumGVttl6YrPfGJC3fqvWk6LFwCDjpIpfsc m9O8kiKnlpnmRJ7Tmn0Ts0ADgR7+/dqyirKfxV2uxbJ5loNUMenQIJYPkXyJuBcvxIlQUZicfRi QUHSsyCDsIXBeSbKXNyAyATLeEi4dIeT3zo8idkYL9DBbLlyRJssW+aUKP+KaElMjjfC/sX0EWw jluFxtsBgGpHy1YcWGcl3CklWcaUc9SuaLwb6rvOvrC+FtUDPiTFBMhPNq9+U= X-Received: by 2002:a05:600c:a4b:b0:490:3d62:eb0 with SMTP id 5b1f17b1804b1-490b60ed881mr111383535e9.24.1780567019397; Thu, 04 Jun 2026 02:56:59 -0700 (PDT) Received: from localhost.localdomain ([2a00:23c4:a700:7301:1615:3574:e0c0:837d]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490be1f69bcsm38037335e9.8.2026.06.04.02.56.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2026 02:56:59 -0700 (PDT) From: Biju X-Google-Original-From: Biju To: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Geert Uytterhoeven , Magnus Damm Cc: Biju Das , linux-pwm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Prabhakar Mahadev Lad , Biju Das Subject: [PATCH v6 10/11] dt-bindings: pwm: Document RZ/G3E GPT support Date: Thu, 4 Jun 2026 10:56:40 +0100 Message-ID: <20260604095647.108654-11-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260604095647.108654-1-biju.das.jz@bp.renesas.com> References: <20260604095647.108654-1-biju.das.jz@bp.renesas.com> 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" From: Biju Das Document support for the GPT found on the Renesas RZ/G3E (R9A09G047) SoC. The GPT is a 32-bit timer with 16 hardware channels (GPT0: 8 channel and GPT1: 8channels). The hardware supports simultaneous control of all channels. PWM waveforms can be generated by controlling the up-counter, downcounter, or up- and down-counter. Reviewed-by: Rob Herring (Arm) Signed-off-by: Biju Das --- v5->v6: * No change. v4->v5: * No change. v3->v4: * No change. v2->v3: * Added Rb tag from Rob. v1->v2: * Created separate document for RZ/G3E GPT. * Updated commit header and description. --- .../bindings/pwm/renesas,rzg3e-gpt.yaml | 323 ++++++++++++++++++ 1 file changed, 323 insertions(+) create mode 100644 Documentation/devicetree/bindings/pwm/renesas,rzg3e-gpt= .yaml diff --git a/Documentation/devicetree/bindings/pwm/renesas,rzg3e-gpt.yaml b= /Documentation/devicetree/bindings/pwm/renesas,rzg3e-gpt.yaml new file mode 100644 index 000000000000..cb4ffab5f47f --- /dev/null +++ b/Documentation/devicetree/bindings/pwm/renesas,rzg3e-gpt.yaml @@ -0,0 +1,323 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/pwm/renesas,rzg3e-gpt.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Renesas RZ/G3E General PWM Timer (GPT) + +maintainers: + - Biju Das + +description: | + RZ/G3E General PWM Timer (GPT) composed of 16 channels with 32-bit + timer. It supports the following functions + * 32 bits x 16 channels. + * Up-counting or down-counting (saw waves) or up/down-counting + (triangle waves) for each counter. + * Clock sources independently selectable for each channel. + * Four I/O pins per channel. + * Two output compare/input capture registers per channel. + * For the two output compare/input capture registers of each channel, + four registers are provided as buffer registers and are capable of + operating as comparison registers when buffering is not in use. + * In output compare operation, buffer switching can be at crests or + troughs, enabling the generation of laterally asymmetric PWM waveforms. + * Registers for setting up frame cycles in each channel (with capability + for generating interrupts at overflow or underflow) + * Generation of dead times in PWM operation. + * Synchronous starting, stopping and clearing counters for arbitrary + channels. + * Count start, count stop, count clear, up-count, down-count, or input + capture operation in response to a maximum of 8 ELC events. + * Count start, count stop, count clear, up-count, down-count, or input + capture operation in response to the status of two input pins. + * Starting, clearing, stopping and up/down counters in response to a + maximum of four external triggers. + * Output pin disable function by detected short-circuits between output + pins. + * A/D converter start triggers can be generated. + * Compare match A to F event and overflow/underflow event can be output + to the ELC. + * Enables the noise filter for input capture. + * Logical operation between the channel output. + +properties: + compatible: + items: + - const: renesas,r9a09g047-gpt # RZ/G3E + + reg: + maxItems: 1 + + '#pwm-cells': + const: 3 + + interrupts: + items: + - description: Input capture/compare match of the GTCCRA for channel= GPT{0,1}.0 + - description: Input capture/compare match of the GTCCRB for channel= GPT{0,1}.0 + - description: Compare match with the GTCCRC for channel GPT{0,1}.0 + - description: Compare match with the GTCCRD for channel GPT{0,1}.0 + - description: Compare match with the GTCCRE for channel GPT{0,1}.0 + - description: Compare match with the GTCCRF for channel GPT{0,1}.0 + - description: A and B both high interrupt for channel GPT{0,1}.0 + - description: A and B both low interrupt for channel GPT{0,1}.0 + - description: Input capture/compare match of the GTCCRA for channel= GPT{0,1}.1 + - description: Input capture/compare match of the GTCCRB for channel= GPT{0,1}.1 + - description: Compare match with the GTCCRC for channel GPT{0,1}.1 + - description: Compare match with the GTCCRD for channel GPT{0,1}.1 + - description: Compare match with the GTCCRE for channel GPT{0,1}.1 + - description: Compare match with the GTCCRF for channel GPT{0,1}.1 + - description: A and B both high interrupt for channel GPT{0,1}.1 + - description: A and B both low interrupt for channel GPT{0,1}.1 + - description: Input capture/compare match of the GTCCRA for channel= GPT{0,1}.2 + - description: Input capture/compare match of the GTCCRB for channel= GPT{0,1}.2 + - description: Compare match with the GTCCRC for channel GPT{0,1}.2 + - description: Compare match with the GTCCRD for channel GPT{0,1}.2 + - description: Compare match with the GTCCRE for channel GPT{0,1}.2 + - description: Compare match with the GTCCRF for channel GPT{0,1}.2 + - description: A and B both high interrupt for channel GPT{0,1}.2 + - description: A and B both low interrupt for channel GPT{0,1}.2 + - description: Input capture/compare match of the GTCCRA for channel= GPT{0,1}.3 + - description: Input capture/compare match of the GTCCRB for channel= GPT{0,1}.3 + - description: Compare match with the GTCCRC for channel GPT{0,1}.3 + - description: Compare match with the GTCCRD for channel GPT{0,1}.3 + - description: Compare match with the GTCCRE for channel GPT{0,1}.3 + - description: Compare match with the GTCCRF for channel GPT{0,1}.3 + - description: A and B both high interrupt for channel GPT{0,1}.3 + - description: A and B both low interrupt for channel GPT{0,1}.3 + - description: Input capture/compare match of the GTCCRA for channel= GPT{0,1}.4 + - description: Input capture/compare match of the GTCCRB for channel= GPT{0,1}.4 + - description: Compare match with the GTCCRC for channel GPT{0,1}.4 + - description: Compare match with the GTCCRD for channel GPT{0,1}.4 + - description: Compare match with the GTCCRE for channel GPT{0,1}.4 + - description: Compare match with the GTCCRF for channel GPT{0,1}.4 + - description: A and B both high interrupt for channel GPT{0,1}.4 + - description: A and B both low interrupt for channel GPT{0,1}.4 + - description: Input capture/compare match of the GTCCRA for channel= GPT{0,1}.5 + - description: Input capture/compare match of the GTCCRB for channel= GPT{0,1}.5 + - description: Compare match with the GTCCRC for channel GPT{0,1}.5 + - description: Compare match with the GTCCRD for channel GPT{0,1}.5 + - description: Compare match with the GTCCRE for channel GPT{0,1}.5 + - description: Compare match with the GTCCRF for channel GPT{0,1}.5 + - description: A and B both high interrupt for channel GPT{0,1}.5 + - description: A and B both low interrupt for channel GPT{0,1}.5 + - description: Input capture/compare match of the GTCCRA for channel= GPT{0,1}.6 + - description: Input capture/compare match of the GTCCRB for channel= GPT{0,1}.6 + - description: Compare match with the GTCCRC for channel GPT{0,1}.6 + - description: Compare match with the GTCCRD for channel GPT{0,1}.6 + - description: Compare match with the GTCCRE for channel GPT{0,1}.6 + - description: Compare match with the GTCCRF for channel GPT{0,1}.6 + - description: A and B both high interrupt for channel GPT{0,1}.6 + - description: A and B both low interrupt for channel GPT{0,1}.6 + - description: Input capture/compare match of the GTCCRA for channel= GPT{0,1}.7 + - description: Input capture/compare match of the GTCCRB for channel= GPT{0,1}.7 + - description: Compare match with the GTCCRC for channel GPT{0,1}.7 + - description: Compare match with the GTCCRD for channel GPT{0,1}.7 + - description: Compare match with the GTCCRE for channel GPT{0,1}.7 + - description: Compare match with the GTCCRF for channel GPT{0,1}.7 + - description: A and B both high interrupt for channel GPT{0,1}.7 + - description: A and B both low interrupt for channel GPT{0,1}.7 + + interrupt-names: + items: + - const: gtcia0 + - const: gtcib0 + - const: gtcic0 + - const: gtcid0 + - const: gtcie0 + - const: gtcif0 + - const: gtcih0 + - const: gtcil0 + - const: gtcia1 + - const: gtcib1 + - const: gtcic1 + - const: gtcid1 + - const: gtcie1 + - const: gtcif1 + - const: gtcih1 + - const: gtcil1 + - const: gtcia2 + - const: gtcib2 + - const: gtcic2 + - const: gtcid2 + - const: gtcie2 + - const: gtcif2 + - const: gtcih2 + - const: gtcil2 + - const: gtcia3 + - const: gtcib3 + - const: gtcic3 + - const: gtcid3 + - const: gtcie3 + - const: gtcif3 + - const: gtcih3 + - const: gtcil3 + - const: gtcia4 + - const: gtcib4 + - const: gtcic4 + - const: gtcid4 + - const: gtcie4 + - const: gtcif4 + - const: gtcih4 + - const: gtcil4 + - const: gtcia5 + - const: gtcib5 + - const: gtcic5 + - const: gtcid5 + - const: gtcie5 + - const: gtcif5 + - const: gtcih5 + - const: gtcil5 + - const: gtcia6 + - const: gtcib6 + - const: gtcic6 + - const: gtcid6 + - const: gtcie6 + - const: gtcif6 + - const: gtcih6 + - const: gtcil6 + - const: gtcia7 + - const: gtcib7 + - const: gtcic7 + - const: gtcid7 + - const: gtcie7 + - const: gtcif7 + - const: gtcih7 + - const: gtcil7 + + clocks: + items: + - description: Core clock (PCLKD) + - description: Bus clock (PCLKA) + + clock-names: + items: + - const: core + - const: bus + + power-domains: + maxItems: 1 + + resets: + items: + - description: Reset for bus clock (PCLKA/PCLKD) + - description: Reset for core clock (PCLKD) + + reset-names: + items: + - const: rst_p + - const: rst_s + +required: + - compatible + - reg + - interrupts + - interrupt-names + - clocks + - clock-names + - power-domains + - resets + - reset-names + +allOf: + - $ref: pwm.yaml# + +additionalProperties: false + +examples: + - | + #include + #include + + pwm@13010000 { + compatible =3D "renesas,r9a09g047-gpt"; + reg =3D <0x13010000 0x10000>; + interrupts =3D , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + ; + interrupt-names =3D "gtcia0", "gtcib0", "gtcic0", "gtcid0", + "gtcie0", "gtcif0", "gtcih0", "gtcil0", + "gtcia1", "gtcib1", "gtcic1", "gtcid1", + "gtcie1", "gtcif1", "gtcih1", "gtcil1", + "gtcia2", "gtcib2", "gtcic2", "gtcid2", + "gtcie2", "gtcif2", "gtcih2", "gtcil2", + "gtcia3", "gtcib3", "gtcic3", "gtcid3", + "gtcie3", "gtcif3", "gtcih3", "gtcil3", + "gtcia4", "gtcib4", "gtcic4", "gtcid4", + "gtcie4", "gtcif4", "gtcih4", "gtcil4", + "gtcia5", "gtcib5", "gtcic5", "gtcid5", + "gtcie5", "gtcif5", "gtcih5", "gtcil5", + "gtcia6", "gtcib6", "gtcic6", "gtcid6", + "gtcie6", "gtcif6", "gtcih6", "gtcil6", + "gtcia7", "gtcib7", "gtcic7", "gtcid7", + "gtcie7", "gtcif7", "gtcih7", "gtcil7"; + clocks =3D <&cpg CPG_MOD 0x31>, <&cpg CPG_MOD 0x31>; + clock-names =3D "core", "bus"; + power-domains =3D <&cpg>; + resets =3D <&cpg 0x59>, <&cpg 0x5a>; + reset-names =3D "rst_p", "rst_s"; + #pwm-cells =3D <3>; + }; --=20 2.43.0 From nobody Mon Jun 8 09:49:58 2026 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (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 B51533FF8B0 for ; Thu, 4 Jun 2026 09:57:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780567024; cv=none; b=eERasl2lUYijJM1NapW2VfTdB4+8SNlbF2OxxQfRe1Iqpbl8x1/dRTEJpD6ZlsQ2jWlt83zlcz1yNCyU30mVM+R3l78BgII088+0hDBWgOIUlYZ+0UkxL1ooTPO6v/vjJG7konIG0b1A7HvZfpZTD6AiU4uAiyxMO7ymj6vaTSA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780567024; c=relaxed/simple; bh=2g9nbNkTUzWdHdIPzC+Vgp2uzTMblT+4A1ma6K2JYGw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=saBDS9be/Jkr9znJaU8xoXkBhOdPweV8ayx9vJmFlo3vDoqbLnIGXo87ZhSMdsuMox3nEMGpMdvyj5RBvtVEHVqEdwGZTt1CGOjymzrf/xGx5nukLmUWcaudOsN8LeBm1lhXr/ZYgFB2124N0d3gHRpHpzDcks5P45ZjIYGj2gU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=a+AzEdAv; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="a+AzEdAv" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-49068493267so4114845e9.1 for ; Thu, 04 Jun 2026 02:57:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780567020; x=1781171820; 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=wTNA9VHVpA1LS/HbVfTfBi8FzZd1SoiTkIbiSRSf3Fc=; b=a+AzEdAvFWSs2fCSeNOsY/WY8dW3yMa9AO0jcZsfy5TOoGITQbph7WYKONYSLQXhto RQjlgb69BxgVd6y+IdqBmwQAeqaOYPx9enXLlM24ccK7ylI4cPVJd4eZsElk9pFEpQ1n gtN4uf2CN3CGoLP00WG8ydAh8ZkdKL3ECOFp+FYRHm15e97thqriMyiFZ3EZkHMTfEMM R6o610ssVwTHFcCkrCk+rrLGUe5U8N3lrXCourVjZfY7mRwaO9njctg9bwAVZHFETAsT 1tutIJNeors7ouF5YTlte6XvMrMD01Z9HVTSwGYgXPe30Ns3IBNfOZT7BegbscyXuju5 usSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780567020; x=1781171820; 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=wTNA9VHVpA1LS/HbVfTfBi8FzZd1SoiTkIbiSRSf3Fc=; b=hdr+pivDD8RaiiSlGX5cGVW2ank/FlyzLo96Jn//F3Y9cbX50+e3BUDDkVPFErc1jT wqnDGYhPHIodibsBwuAWVwq/WqCoQsIMyAImZZ98Hcwk90fjSoPv4omm86ACYtXXde6c nEgc6Ux2P6AFgNTes0IFmLAqPnAtkKr9eV6NcBkqSq97cgiuoIwrEQ7vBHZXee/TsANX X2tzLsUtN+rHM4kbjTEQ2BVzl1eTbz45DgCfw1V84WOmwlo6HIRevbMTmcaUdSnpHI/m 03V6UgpCH6cubNg4/Vtb/CUrmReY1V8+0GExw0Ho6H85Rx9Qp2GkXIff+JYpiOkI8xDu MnIA== X-Forwarded-Encrypted: i=1; AFNElJ/34LlrIRnhgQ1rfjuDqiPqYZG6LNnRyYNrk7F74sZoPUUu0SWrUGnDrVlSt+2IqF416i29Nnow/eaPDOA=@vger.kernel.org X-Gm-Message-State: AOJu0Yxchu5EFKmDtwd2t1ScwzqppyEnGqw7rNjkeJi1w0QLofKd1sXZ k7a5TQENtddSS8GoecFStYxurO8RXN4D8LOQ6r5h0sd9gVo1YVC9vGNl X-Gm-Gg: Acq92OEyP9sWu/ZCe1FLScPH6DPY8+404nqz778X1I4nQ26lvtg1ROC1UfEEALOKzq2 Pd+4hxWDXJlorPnRfbEi7kgI+tOYJTIZvA8KyPR4UkFnoIHxkiwYKqfsgYkJcN2RUvxRp8fZQ3C JgGRnON9F4crgaiPc+mXfyLXbMKNKsFaJbII7rDtsQLoTgtFHVBuAaib5nJrTvwgFIN+Wc5naH6 3wbBkoofts5SZtZtRNCs9o1Bo7a8zXE1LV7Z/WZPWLET3Z1nwWs99hLCBC87/EsIxLmsuz0SG3S ua/kvYySIxT8QRz9IVxA/xm1+UClEyPqvHfJfYZTnbUgMsPqaqGW9x8HlZFvud7I7T/mexHhw9Y 8BONT8rgozJA28d0wfyHeS/mzu3yuiCOZMFxFCpHkbgJwNW0al8bWs86A7y3nU9c1Hp5BQ4r15D p72zYdQ9AXX77f12qTpT3RQBEiicXZ5/iZ1wWgKD2Hihm2BwsD1ea90wckcKc= X-Received: by 2002:a05:600c:1910:b0:490:bb3e:30c2 with SMTP id 5b1f17b1804b1-490bb3e32f9mr76102615e9.18.1780567020226; Thu, 04 Jun 2026 02:57:00 -0700 (PDT) Received: from localhost.localdomain ([2a00:23c4:a700:7301:1615:3574:e0c0:837d]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490be1f69bcsm38037335e9.8.2026.06.04.02.56.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2026 02:56:59 -0700 (PDT) From: Biju X-Google-Original-From: Biju To: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Philipp Zabel , Geert Uytterhoeven , Magnus Damm Cc: Biju Das , linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Prabhakar Mahadev Lad , Biju Das , Tommaso Merciai Subject: [PATCH v6 11/11] pwm: rzg2l-gpt: Add RZ/G3E support Date: Thu, 4 Jun 2026 10:56:41 +0100 Message-ID: <20260604095647.108654-12-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260604095647.108654-1-biju.das.jz@bp.renesas.com> References: <20260604095647.108654-1-biju.das.jz@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: Biju Das Add RZ/G3E GPT support. It has multiple clocks and resets compared to RZ/G2L. Also prescale field width and factor for calculating prescale are different. Reviewed-by: Tommaso Merciai Signed-off-by: Biju Das --- v5->v6: * Updated rzg3e_gpt_calculate_prescale(). * Updated comment in rzg2l_gpt_calculate_period_or_duty(). v4->v5: * No change. v3->v4: * Added RZG3E_GTCR_TPCS bit definition for RZ/G3E and added to rzg3e_data. v2->v3: * No change. v1->v2: * Added link to hardware manual * Updated limitation section * Collected tag=20 --- drivers/pwm/pwm-rzg2l-gpt.c | 45 ++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/drivers/pwm/pwm-rzg2l-gpt.c b/drivers/pwm/pwm-rzg2l-gpt.c index 7e669406dcdd..f84de41e1360 100644 --- a/drivers/pwm/pwm-rzg2l-gpt.c +++ b/drivers/pwm/pwm-rzg2l-gpt.c @@ -6,15 +6,21 @@ * * Hardware manual for this IP can be found here * https://www.renesas.com/eu/en/document/mah/rzg2l-group-rzg2lc-group-use= rs-manual-hardware-0?language=3Den + * https://www.renesas.com/en/document/mah/rzg3e-group-users-manual-hardwa= re * * Limitations: * - Counter must be stopped before modifying Mode and Prescaler. * - When PWM is disabled, the output is driven to inactive. * - While the hardware supports both polarities, the driver (for now) * only handles normal polarity. - * - General PWM Timer (GPT) has 8 HW channels for PWM operations and - * each HW channel have 2 IOs. + * - For RZ/G2L, the General PWM Timer (GPT) has 8 HW channels for PWM + operations and each HW channel have 2 IOs (GTIOCn{A, B}). * - Each IO is modelled as an independent PWM channel. + * - For RZ/G3E, the General PWM Timer (GPT) has 16 HW channels for PWM + operations (GPT0: 8 channels, GPT1: 8 Channels) and each HW channel + have 4 IOs (GTIOCn{A,AN,B,BN}). The 2 extra IOs GTIOCnAN and GTIOCnBN + in RZ/G3E are anti-phase signals of GTIOCnA and GTIOCnB. The + anti-phase signals of RZ/G3E are not modelled as PWM channel. * - When both channels are used, disabling the channel on one stops the * other. * - When both channels are used, the period of both IOs in the HW channel @@ -48,6 +54,7 @@ #define RZG2L_GTCR_CST BIT(0) #define RZG2L_GTCR_MD GENMASK(18, 16) #define RZG2L_GTCR_TPCS GENMASK(26, 24) +#define RZG3E_GTCR_TPCS GENMASK(26, 23) =20 #define RZG2L_GTCR_MD_SAW_WAVE_PWM_MODE FIELD_PREP(RZG2L_GTCR_MD, 0) =20 @@ -160,6 +167,22 @@ static u8 rzg2l_gpt_calculate_prescale(u64 period_tick= s) return prescale; } =20 +static u8 rzg3e_gpt_calculate_prescale(u64 period_ticks) +{ + u32 prescaled_period_ticks; + u8 prescale; + + prescaled_period_ticks =3D period_ticks >> 32; + if (prescaled_period_ticks > 64 && prescaled_period_ticks < 256) + prescale =3D 8; + else if (prescaled_period_ticks >=3D 256) + prescale =3D 10; + else + prescale =3D fls(prescaled_period_ticks); + + return prescale; +} + static int rzg2l_gpt_request(struct pwm_chip *chip, struct pwm_device *pwm) { struct rzg2l_gpt_chip *rzg2l_gpt =3D to_rzg2l_gpt_chip(chip); @@ -241,7 +264,8 @@ static u64 rzg2l_gpt_calculate_period_or_duty(struct rz= g2l_gpt_chip *rzg2l_gpt, =20 /* * The calculation doesn't overflow a u64 because, - * prescale =E2=89=A4 5 for info->prescale_mult =3D 2 and so + * prescale =E2=89=A4 5 for info->prescale_mult =3D 2, + * prescale =E2=89=A4 10 for info->prescale_mult =3D 1, and so * tmp =3D val << (info->prescale_mult * prescale) * USEC_PER_SEC * < 2^32 * 2^10 * 10^6 * < 2^32 * 2^10 * 2^20 @@ -546,6 +570,14 @@ static int rzg2l_gpt_probe(struct platform_device *pde= v) if (IS_ERR(rstc)) return dev_err_probe(dev, PTR_ERR(rstc), "Cannot deassert reset control\= n"); =20 + rstc =3D devm_reset_control_get_optional_exclusive_deasserted(dev, "rst_s= "); + if (IS_ERR(rstc)) + return dev_err_probe(dev, PTR_ERR(rstc), "Cannot deassert rst_s reset\n"= ); + + clk =3D devm_clk_get_optional_enabled(dev, "bus"); + if (IS_ERR(clk)) + return dev_err_probe(dev, PTR_ERR(clk), "Cannot get bus clock\n"); + clk =3D devm_clk_get_enabled(dev, NULL); if (IS_ERR(clk)) return dev_err_probe(dev, PTR_ERR(clk), "Cannot get clock\n"); @@ -588,6 +620,12 @@ static int rzg2l_gpt_probe(struct platform_device *pde= v) return 0; } =20 +static const struct rzg2l_gpt_info rzg3e_data =3D { + .calculate_prescale =3D rzg3e_gpt_calculate_prescale, + .gtcr_tpcs =3D RZG3E_GTCR_TPCS, + .prescale_mult =3D 1, +}; + static const struct rzg2l_gpt_info rzg2l_data =3D { .calculate_prescale =3D rzg2l_gpt_calculate_prescale, .gtcr_tpcs =3D RZG2L_GTCR_TPCS, @@ -595,6 +633,7 @@ static const struct rzg2l_gpt_info rzg2l_data =3D { }; =20 static const struct of_device_id rzg2l_gpt_of_table[] =3D { + { .compatible =3D "renesas,r9a09g047-gpt", .data =3D &rzg3e_data }, { .compatible =3D "renesas,rzg2l-gpt", .data =3D &rzg2l_data }, { /* Sentinel */ } }; --=20 2.43.0