From nobody Tue Jun 16 14:57:01 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 40DA239A7F8 for ; Mon, 20 Apr 2026 10:43:38 +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=1776681819; cv=none; b=KXn3hkxxlaa5jqIm0kVP4QvlofS1s69c+wERaxbOEMKNejhiyYkCfLx7O/awk8JMTEcTD1eTbcxbmCp67j2dRnsJOYkBdWmRp38kDZ90rqLYwnke0dXs0zvBrmGmly62XCuqO8BwBU277sQAJics0ZAOQGUO+xyTHTRXqdz3AT0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776681819; c=relaxed/simple; bh=VhekGTjk/1zXeGIGbEp+mvkiBuKm0sxCLfNTFeimcHU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=phkMsCeZrphQaYKsjQDLa44NfYzKyxxpVbcB2m03OwPsXKFQdCwUHbsD+Wa2DjSuJfjHdxDxtQ+tVAoQ66hujGonrxEW8o0HgVo7quv/521nIozv6rbiKmJMCS0046ISWvfOh+67dpcL048EmgTiEacSj+Jcz9h7z2DvpD89YX4= 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=VZco2aAJ; 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="VZco2aAJ" Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-43eb05b1875so1674174f8f.3 for ; Mon, 20 Apr 2026 03:43:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776681817; x=1777286617; 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=bhm2GeLeG1UM0/AQDKFsQSbZ5IfXuExVpXyI9JPf4cs=; b=VZco2aAJ9RKZn+y48b6y5KhQxByBjuwm3Kgk7lgj3BvOUSEqQSdfWaLrzFHMuWg9Tr O1rg14RdAxE5MQJKSxSHVLRCP1AjPWJle962XWIHVGTiWOkrX70EvuVASDEEXtvsX3uB NESzrhQ8W/FvJFj6s6VbLqJh1N9t0RKlgDkL0tTVXD4yvclwoehbVClSG4NpQuHKKDp6 3GhhIvAnNuPWRoi04UIJuAz/FdmfGCD7v/LnG2tgFRov2VTZx1KeG1/pmFzOKhbKdi9b 3qaapAP6JgI71odqO43GtbIQ90GR8wepoEIz8RpaPEUtlanO1RrorWUqKubzcM2A9yPX rBcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776681817; x=1777286617; 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=bhm2GeLeG1UM0/AQDKFsQSbZ5IfXuExVpXyI9JPf4cs=; b=hSL+ePy7Z+kKmGjF8aG/HeH5nMkrGluGeBQdZJh2o9x+ofHDQh7b+VKb+6w6WwWZ/Q WgthJE996h1/0xDdaUKjVCXJaYtfwClchpr+eaiF16RZpMqnL6wnw5CeHfhAUp4Z+9NN 8jqeuQTmKC4M3BTREkuAoj/mYe4a0ke2fp8azEnVtW8bEWboM3WseijOhFvjTmpJjRx5 ZwyX1qa52UVHU4T95RG3KsfOItUfBkeJ7Fgiuy4xeFjj3Ndv7Vw/bp+K+fd+CRxpdL+0 pPhQrRo5TI0QQ/GubMft/W3iASm6tHXwZQEhtyVX/NP/wj/H5atzEYaqlzhgd4b5XY0D Wd3g== X-Forwarded-Encrypted: i=1; AFNElJ+/aBaKpZE8ZeBrqztUFs2gxKBlGLPPFiMnivxpEtQplL4ACQsz/u4EqSG3ST0m8xT1czJiB5nWo8IM4DA=@vger.kernel.org X-Gm-Message-State: AOJu0Yxoz9S4KakeU639cVSa0JkL3KPAVVaFKQzs7+sp3mDdWS1KQokj 0yMYFIaNtCKrgY2J1husXynz/YYRxdAfuGn4wAu0hZsLpesJgw/re13e X-Gm-Gg: AeBDieuegy3KbkhJ4o8V8QmLriCNi1cXWQsyu/R05OHujhQeBLgWAVjLbNhj2yKfKz7 yBARKqdfNzeFdN7eqHRx+zrtvHBQJZc5am/HluFPo+axGSIU9aC2Gy/Ee4p/8VZm7iy0lHPvmwK a5olqRWDna9+JvI1XxEzNKjJHPj3w84et9x0lELTDS0S26+f0evmS/24scFSUtbJkCGkQ6dCg6t UxIagyT+bgYezkPHeaSU1UOu0Pga7xUVOCTWa40e+PrNrrYDxpahg6Xgbgg9JuP0SDOTeLoq52V L/I3YZZDUx9u4JqIc6rBBvIqDQktzQIYlRRC86pOgRNqHZSLdHYt7/MatEmE+P9dTvgJaJHbJL9 ejV8+bdE8Ifryn24R9Vw7sm4xGUONfgPMRDJgUuoasdlCTEUDGebf+mBpJl2e9LOLbbsuLNzJVQ Jol0RdWgUkfrAapzMCKAL4kQi7RUfKub4Hlsm8xNqKRH6xYUkUyT7tK2AONhrU4QXD/+jC9A== X-Received: by 2002:a05:6000:22ca:b0:43d:6f0f:32fe with SMTP id ffacd0b85a97d-43fe3dfd65fmr18556724f8f.31.1776681816481; Mon, 20 Apr 2026 03:43:36 -0700 (PDT) Received: from localhost.localdomain ([2a00:23c4:a758:8a01:5f3e:f914:6f8c:72c3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43fe4c221cdsm28038301f8f.0.2026.04.20.03.43.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Apr 2026 03:43:36 -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 v5 1/9] dt-bindings: pwm: rzg2l-gpt: Document renesas,poegs property Date: Mon, 20 Apr 2026 11:43:18 +0100 Message-ID: <20260420104332.153640-2-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260420104332.153640-1-biju.das.jz@bp.renesas.com> References: <20260420104332.153640-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: * 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 Tue Jun 16 14:57:01 2026 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.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 01B6D39B483 for ; Mon, 20 Apr 2026 10:43:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776681820; cv=none; b=De2deFZTG0df0Nac0IZxY9aHZlkA0EK/qv/S/0N9QwYmk7LheVsCz7eQvWQ0ZA6w38lcz7mWQ917kfxgn71iiaykrPVGVXk6pvByY92m1rre21YrOVJfMPpAitFAY2Zjsgux/ShmcLINa9UMJ64bSHgvZU2ws7KgVQJU5g3YiAs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776681820; c=relaxed/simple; bh=nrDwUsLA26hzIjayJTgFjPGid/cYtDJ5PDB04XhXoKM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kOhteoIP3dqzhGGD1PTcEUFQv7LZx/nMbw2Kruaic303loC0nTjZLlzabs0HP0HtgbfVJsr1rd+GkJHctJl2JCsmky2LuOAtZiUlH+F2HDuRPjJ51d2ay3akD3z2AOVmTWoKxAnBrLDNE7P9HV5aRkxIccv8NpQcesWxt98i6eI= 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=VUADfpue; arc=none smtp.client-ip=209.85.221.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="VUADfpue" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-43d03db7f87so1822713f8f.3 for ; Mon, 20 Apr 2026 03:43:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776681817; x=1777286617; 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=z/Csqb4UQrcrof3DTRO1RvzP+CgGq/GLAveFMe3H3iI=; b=VUADfpueIZofBYjacztlf7D+NKSH6JXq72sUEpINI4IZ063QYfDAx5dUkwXFnrRX9s e5iAp1mUqdhlln22ZwPjRDjryX7YnnJJ/XCmei1xWrYoW77z9GbvmapbEX5cXgOnSEoM pEZe4E3nC7QlYfzOO+87tgcpVIdlh+nUDboC4tIHWK8ZJq/nyLiSp+ng5jeuPIGf+d8a WGa3s/eCtzpxEjwINZE0AHQP4R9opj7JB64qUdeATmEnt6ZLCb4QuVP+XaYKZGXPevUx R8qsxwILOwMQkM41a7Pu0YM7XcflnYE3CQGEsJMvlEHJ1XzeoUpWK2+GIRKwFauBsURi o4uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776681817; x=1777286617; 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=z/Csqb4UQrcrof3DTRO1RvzP+CgGq/GLAveFMe3H3iI=; b=sSbTS4eiAOvhuMljgIgv35NV2wEQO9pCT+UAU+cyLW6ieJcPg5b9xPr7zzJWpBs5pi KHmFiKKWwsLFS9JJgROtMnhV0WaKKzpedoCn75NvBRLQnqTqvz0te8dK1Lo8Z1w4KP/r cFan5iGBokHW/wMfIGoEGSm4OmIW8GeZz+vokhm2Mpv8NbL4LrOwVGuJx3/CV6zMWSh4 o3dNZ92aUh8p4AorFye/C3k/fjHOkZux/3yeTESf3hkQzAABuGgn1G9OieOZZmdqZaMW JasTNE22OhJO6IK9+zlyHrWKac1mpTTzN2qYGzfm11viDSzyBgJDU9eAkk8SJJd134gF o7uA== X-Forwarded-Encrypted: i=1; AFNElJ9U4CsPg+gP7iSE3lKXCbsroMTQTypFoRSWpAol15tcUVhoBRC51l6wtJ3+/o1Vj/B7WrnvonRlGnmYbOA=@vger.kernel.org X-Gm-Message-State: AOJu0Yysszsn4WPmUFyXdBB7awrc5P4kYQLBD3jIsBZ2xAPP3+W7Ud2k 93Uq26TdoQzF7F/tIeUv7plrETOfzdaMDxdC73CZCuyO3oCiaSAX/ZlI X-Gm-Gg: AeBDietcaJ9cJSPh0I9wlGyiLqHZqpgadbtKacEwcTDY3oPrPLvppCltJnSbLyRtM4+ qEYItuuhYgqTiyNxiVr41Hnoe937mb32I7LXDblU0rFEQIxUheibSAcLLe2iPES0Tz9E4vN08kd Bv+fOWEbDDtCxmqvxK5xdnrz0roH3uWzxGPcnphaUR9WJaJw8Pxqb9FPm33AMFXS8N5yxgag3Dt bi0Ab9aM58MwwkQHjy7V2TeBzKNpiA4XOKh9G32adUywWy9ujJ89sbKHsdEDiPWtIs+5BSPft5J r9oIadwqvSFbdDv6fOxCH29zNjHwfDCayu97P+tyXAQ3NEw7rm79hTvwL6USE1y5xKKhevVynY5 hkTeQg5d0YrxynmSJkUUEgSCHgEXAGS8depky2yYltuZRcGDG/yIeiNIokN7NWuNxTuMX87rU98 zUZaTXiipCv46RUCWY9UQWEh4eLKbHnLGku+/09psnOUexcaMGoUIEfrp14JU= X-Received: by 2002:a05:6000:144d:b0:43c:fe0e:5bbc with SMTP id ffacd0b85a97d-43fe3dc59a6mr18783496f8f.19.1776681817237; Mon, 20 Apr 2026 03:43:37 -0700 (PDT) Received: from localhost.localdomain ([2a00:23c4:a758:8a01:5f3e:f914:6f8c:72c3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43fe4c221cdsm28038301f8f.0.2026.04.20.03.43.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Apr 2026 03:43:36 -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 v5 2/9] pwm: rzg2l-gpt: Add support for gpt linking with poeg Date: Mon, 20 Apr 2026 11:43:19 +0100 Message-ID: <20260420104332.153640-3-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260420104332.153640-1-biju.das.jz@bp.renesas.com> References: <20260420104332.153640-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: * 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 4856af080e8e..71ae2f891fd2 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 { u32 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 + * configure 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 %d >=3D %d\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 %d > %d\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 Tue Jun 16 14:57:01 2026 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (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 DCB8739B951 for ; Mon, 20 Apr 2026 10:43:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776681821; cv=none; b=Oh8KR73r/C2LQtubmuH7/HuudyTgi7ZnWoQMmeFAVzksd8d6qd4e9I1qL85h9vFhpUXaYkTXPCLwfok7DdHQj06LpZvxQMbWCJLTkgnOPQLKt8ZB0y4AMs0/LeQABFEpynAgtbzMGeiSoEH6XMwsmCRD9V6iYSuaIhrmAmwziNw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776681821; c=relaxed/simple; bh=2aEt/uAkd6FnonntTQK2OKrXN9HmT8hxFDkSCFrA00I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fF+sodjcj/bPnTGPYC1Mh6iioMuzrUQdx6A2Pq1UYawrcqDiA6kFJy3TZfMiBvGuH9J8iS63lGZge7ORP37t1gFQQ0gOyWA4pzQuebm+f5qHDH3TetoGljeUf7VmZf19bSITR0vvN1crxNZ+VU4BUfRnMHtSFdJpFXlhLfIRuoc= 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=PS9gX5C+; arc=none smtp.client-ip=209.85.128.54 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="PS9gX5C+" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-488b0e1b870so44455675e9.2 for ; Mon, 20 Apr 2026 03:43:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776681818; x=1777286618; 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=VE92/ZrBwPqbca7eJ2htSzW/89KuFYZSCYN2VEEIChk=; b=PS9gX5C+3CFCYF4tpLhmPkBbpONxdwqOmSNZWquzr/Fg2vq5AJCYdbL6+t5Plo7Yrf ZfCWDz3cnLppacJZSaCVyumVcU9pwx1zcXJnetWn+AmGRvdcw8yBgdik+0TQk7YWfS77 P3MI7XWJGam+6QletyPnHznkBvvSANowXI/5zwqF1/ZxCXTQIhbZdDqFHlcOd9B9LlIU q9gvi2z5RhIWAdOXY/ZotbmosQ3sataxo+ULkzP5pijqf/+7of/344zUf2YUhTcLqgaS wBLdgjQje6ZyzA2hJrV0Fd3rYycZoO7ZgVIfrEEMXFtAsCnIjXsP9KEPRhzlbf49Yo9J ylJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776681818; x=1777286618; 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=VE92/ZrBwPqbca7eJ2htSzW/89KuFYZSCYN2VEEIChk=; b=a3ng0fbLQEH9TWqjjOcEzrEchJf+6oiG5ePyL41WpPMulhJtM80YkCqAvTudUtwaWu P6zGqgoLiCrPac0Jb6DnANHcEOEccaKM3hcyD7UlhnpV1UAEN0QWQ4Jzq+FiCtIybRNT dH7mMaG+n66ffBhZZ0oJhQqVMTU+BbC2RTrXdYlF1FwlsD4eZ/qIUB2vC16EeJRVXtnf Xy6KV/wxpPN5DrfqDb11V+2vrOQbELl9YnnmBOCwlkXGASeDrhR8n1mDr8Z2YLpoa6wi 6nWcq+Q3XfuV6LaiEOmuPUTBO4n7Yev0szHM8Ks2Cw8aenHp++0pOXoe6s5WzRRMlmo0 YTpg== X-Forwarded-Encrypted: i=1; AFNElJ8b0uI3i95XcGUz05e6yEQOILE6tSNSmg7Um5LHAL0AnwKYYE8F8gdCq9QuSSZiGKyODWAHR6RIf7uirug=@vger.kernel.org X-Gm-Message-State: AOJu0YxK7wmlYHiTQDzutv7NthYjKcDfZwHRPTINpGNKR1fzoowA6ogv bMjRKKKX106DaprxXBjSpUWh1cm0Xv7XIdSyKTy+Q2oj5EcSl31KzTZl X-Gm-Gg: AeBDiesKdzh85ySb/ikysHXXLMqC7zHr0BjY1X5Dx7Fi7Ts9Y8TJnS/vwyIOxz5ek9L QZ9gomK/sxtVSC91p+9CYB9tK09Vgg9UWGtWmsmADoHrkg/jk8uhvoXgicOFscTbg9QsVL18l0K zqKAXgGkaUC4WHNy1nJZWlYbWZuiNGDNcQt1GW/0SwgiuxH8vv8+g0tg8B7QaU3Fdhen0dJzsTL p/vHPFln5pRoOAxsTo/hSjLZJCo1qc0erP9rc8YWXTo2bJoTAS+p3DPmzXGLiQCzx7nMxgt1oDw YlJzOA7FglLBovkQc2D5aHYcgBnucE1HjNPuyvgsh3eKbk2t13dnDUTrb7+9lAvjtADG0+1q5E4 hhdQjEgAq4d6HOzRkPj2auUKIOZSgUxA23hVXUGM2BWS5l36Y1tDE7g66UGi7aMaAw4DaRgOG5z 5zDcXa9dgFtAR1E4k+bVL3Dd7VmEc3Tpav4fBzln9FVdpJEMv8XGbA3XTjvXTPxTRPSi3yYg== X-Received: by 2002:a05:600c:620d:b0:489:1d23:4524 with SMTP id 5b1f17b1804b1-4891d23468bmr39960955e9.5.1776681818169; Mon, 20 Apr 2026 03:43:38 -0700 (PDT) Received: from localhost.localdomain ([2a00:23c4:a758:8a01:5f3e:f914:6f8c:72c3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43fe4c221cdsm28038301f8f.0.2026.04.20.03.43.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Apr 2026 03:43:37 -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 v5 3/9] pwm: rzg2l-gpt: Drop unused rzg2l_gpt_chip parameter from rzg2l_gpt_calculate_prescale() Date: Mon, 20 Apr 2026 11:43:20 +0100 Message-ID: <20260420104332.153640-4-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260420104332.153640-1-biju.das.jz@bp.renesas.com> References: <20260420104332.153640-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: * 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 71ae2f891fd2..659044fa3d2f 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 Tue Jun 16 14:57:01 2026 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.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 267F239BFE6 for ; Mon, 20 Apr 2026 10:43:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776681823; cv=none; b=diCW8s+C5/nwKdy8v1hbsDaFKdqf+CttSj0WGXwbJYEjoMBE7eOHVyByF9AIrFBiBuS4FS7v7MCi+4JE5p6IMrmJT1pL1hdPGTVRA3qhhtcymhDv0Ude8z49p7imWE987NyNqAWfwNRlpuJN1t6LcQV2hhcAAUVt96FS5GdnjE0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776681823; c=relaxed/simple; bh=fSIjz6ol48qoy1K8+rN4N5gny3jPXDW4yYyqJMR3808=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NDXnLNefzWCBmro+fdIO130u3uiAGzIO6uv9M1qKwHuTd+6ejMFtJcITPq8HRNEi9BAyV7jR5qgojmPyp3vZYQcGwHFX0ewNQLXDSctdJZ1nZ+tDvnwAuPEc01X4JSaDcD58GgjQMdi0nJOYUSJbz7bm13qy1ta0a3PqNxVYXWU= 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=A9tQUdts; arc=none smtp.client-ip=209.85.221.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="A9tQUdts" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-43cfce3a195so1767902f8f.2 for ; Mon, 20 Apr 2026 03:43:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776681819; x=1777286619; 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=1AOeVq5B83Oakg9rsXTFqzIN0nru0tnCCYoqDYS4Cck=; b=A9tQUdtsmTVIwwsoxACiOL47efgYHe0S54WARuD7HYt5MXrzVBKkD2fbQuRoRB8cU0 U4SvrUlV/Y5DyJ9znYwTm2DNMbHHdKtc3WD64LMFPkby0lJNf2TGp/jyyIdsIHPDUMPl pz+3rq88qpGAVLVdQBVC4xO/3ElrFP7/LvqpdjzDeuxY9pvYKvmsD35Eld+9vC4ct05G IE1pwoedwOok9hiei6N0+DjosRWmO1XTzGFDJpy28+3QZYnwdp1HfdCuKbUZJWdCSVId tTzHxxadkq4N5Fyaa9MFh0MoXLcEqOAMQ41Tz/74tbLelj3tOwS93lfg1rSduJx9Q/ez XDcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776681819; x=1777286619; 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=1AOeVq5B83Oakg9rsXTFqzIN0nru0tnCCYoqDYS4Cck=; b=JEKPxlXXw6OBLD/+8Z85u4BcmGkTwTHoPTgE7LFhEQXaPdoRTG+4Qk6HTA3O8WCdyC vER4ChQ1rsOYLND6ZZXv52OT2qi6WUvpHOJ1ys15t60KfG8ISR8ntfETXwi99nD9xf8t zoyAC2OVrhSMDNgLT2m9CMGgZOcsV+BtZa+ESFj7n3XpjaiRMSJmdXfIkxzys6h1vVP7 yWeHr5mOW0EP/2UOv15oroSPxhwF7uQPHipaVSKVC/LXoRJ0MJv81K8ozcLqD/igLs9J EpRyriMPo6qOXJMKWEh/U3Nlisgx9tXji7DEL8eUf37xusW7amYVWa6UJxQEoo9yzWzP Q0SA== X-Forwarded-Encrypted: i=1; AFNElJ99J3eRlpE9Kp071Z0Dq4s4BmF+KILFbrmRovpXxaEoaLpGd7BsdHDA7Jzzdj/zLHikgShkVUh90CW61iw=@vger.kernel.org X-Gm-Message-State: AOJu0YxnuZu2eQocobuVm5MjFraKhd7VsyQROcM7lT5k8eUQe3VUECWZ UMwdy2guECB9+VNP0M9oDIPCyVR9jvaqWosHT78sbyaoBqSqHVfEheVI X-Gm-Gg: AeBDiesKbKkleYIHbeUrW9ZqSfXmHgNmxHK70bc4o13IIyjXoGHxu01iWkf+RqTM9wG 5vr2J0MdSYkboQqCpUqWrEmMOxkfsq9JzG60dwoqqoHO0kHLVwKzRULmTSlh2/jwfpGvYGZlwQA Se2I/DFlO8dfxX6NT/nuFeQza8WnREJ0lIAdoFOmRVcepok6Ycnjb9HRAa5Pn17hV3P/Bsrgjun cMYnxqzHQJs4C4of+ZoZBAQEVI1j/h04RN+EMIF+reNm1r8c0MZD5KZOiw1naELJFHe88z45002 fwWpt7HY75NxW3y0WAzW25sgUEdffbXdx5/iwwwkvOaUBKfl9ju/EpTlYAzPF6hx4j7dF+Y+d9u iwNCR15Eyz+Do6uKgakM2O7QrM+IuXNsNhvyjOPniQ7PojDCAnqKxCnKQBLzwqBUjvkrx50qZK/ NhGZKhGYkZsp6ZCyUN5uGhPZ/YeVHgQmVyKxI/5bFh7EVMwayx79a2Tf3e+9g= X-Received: by 2002:a05:6000:2508:b0:43b:8f30:39bb with SMTP id ffacd0b85a97d-43fe3df1f30mr19587394f8f.24.1776681819118; Mon, 20 Apr 2026 03:43:39 -0700 (PDT) Received: from localhost.localdomain ([2a00:23c4:a758:8a01:5f3e:f914:6f8c:72c3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43fe4c221cdsm28038301f8f.0.2026.04.20.03.43.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Apr 2026 03:43:38 -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 v5 4/9] pwm: rzg2l-gpt: Convert to waveform callbacks Date: Mon, 20 Apr 2026 11:43:21 +0100 Message-ID: <20260420104332.153640-5-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260420104332.153640-1-biju.das.jz@bp.renesas.com> References: <20260420104332.153640-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: * 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 | 197 ++++++++++++++++++++++-------------- 1 file changed, 121 insertions(+), 76 deletions(-) diff --git a/drivers/pwm/pwm-rzg2l-gpt.c b/drivers/pwm/pwm-rzg2l-gpt.c index 659044fa3d2f..9e7a897a0b4d 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,54 +244,38 @@ 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; + + guard(mutex)(&rzg2l_gpt->lock); + 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; /* @@ -291,21 +286,26 @@ 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); + pv =3D rzg2l_gpt_calculate_pv_or_dc(period_ticks, wfhw->prescale); + wfhw->gtpr =3D pv; + 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); - if (duty_ticks > period_ticks) - duty_ticks =3D period_ticks; - dc =3D rzg2l_gpt_calculate_pv_or_dc(duty_ticks, prescale); + duty_ticks =3D mul_u64_u64_div_u64(wf->duty_length_ns, rzg2l_gpt->rate_kh= z, USEC_PER_SEC); + if (duty_ticks > RZG2L_MAX_TICKS) + duty_ticks =3D RZG2L_MAX_TICKS; + dc =3D rzg2l_gpt_calculate_pv_or_dc(duty_ticks, wfhw->prescale); + wfhw->gtccr =3D dc; =20 /* * GPT counter is shared by multiple channels, we cache the period ticks @@ -314,6 +314,61 @@ static int rzg2l_gpt_config(struct pwm_chip *chip, str= uct pwm_device *pwm, */ rzg2l_gpt->period_ticks[ch] =3D period_ticks; =20 + 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; +} + +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 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); + u32 gptr; + + 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 +387,20 @@ 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) { + gptr =3D rzg2l_gpt_read(rzg2l_gpt, RZG2L_GTPR(ch)); + if (wfhw->gtpr < gptr) + 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 +409,28 @@ 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); + else if (!wfhw->gtpr && rzg2l_gpt_is_ch_enabled(rzg2l_gpt, pwm->hwpwm, NU= LL)) + 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 Tue Jun 16 14:57:01 2026 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.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 8C5AB39BFFE for ; Mon, 20 Apr 2026 10:43:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776681823; cv=none; b=nT1aJedGaIEJq73Ap8JRkaGqNNW6YUud1DRv+jiHg2qfJPFu14l6XgZl/pRgqintXcLLBGUpub539FCAvIZw6o2ogWVdb5klAjasajUCsWvMo9NFZHG3BXIjaKj0o4igmkyPx1dxcxgmRICvqB/ttSsEKDONoxjdyiRgMkDMXBw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776681823; c=relaxed/simple; bh=iqlknQ2GZm0BFaaUMkLXhS5LaHSl/PjXIMXOoaoJh8I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DmpKCi4Ehy8aa4Crbfl6l2bodBWRUf2NBI9ettJO6VwqEkXDg1bv0VcqYx47duiI9rcj0CMuM3NDdjucLiRE0FmXi/wFszU5czmL/F2MEFD5szDJSwUPH+FMzYq4khlST/hf9f7riYQY8fPdcXjGJ4ZtHSltGZNyj/CBjYNf6SQ= 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=ApMkzdtg; arc=none smtp.client-ip=209.85.221.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="ApMkzdtg" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-43d7a5e77b1so2002829f8f.1 for ; Mon, 20 Apr 2026 03:43:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776681820; x=1777286620; 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=7heXUX6SKDIlQgTOyg6oxJS1gEDoX2bQYyBqPsQEUwE=; b=ApMkzdtgd6jq3/g9h9MaJtpAJGLAyIpMlHAT8/DkBPPyV8Tk8kSJRICwxHjV8R6uph w5RNEqjEUwNjrDsB/iUYVZxFAM3I1XZV/aRaD9P+E6p/KJxxZErzJ1E2xeQhQXQcVbnU Shj6QWsoq2daOAh4aFaxEQMRjV6UQGCPA4umOx7X/dTIRMt7asWa2nlsYFcBQihFVS6g kzdlXUA8yHaZmdqeBeeBstib+oM0VloKyWeD9lD+/38RnfSS21US6mY2ybeUrgnhGz7r JfcZ9oqPk9d79rMg4lKfYRzoH1S2uo+RVMCv5BzPdTnzUdmDf+VDogELWzgNKrMuOMBQ 1Eig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776681820; x=1777286620; 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=7heXUX6SKDIlQgTOyg6oxJS1gEDoX2bQYyBqPsQEUwE=; b=j12Jgc031N4KI5DXZcOqGgF6hYeZDZGV2on4MbOVHB3cVZpaPWf+OgJvA7eAzVjm5N sl+Q6gcEAn+C3NQwQIj6giei2l69QCyoJP/jVrohrYZ6GdZRduAGNr9o2bFwjm3ia07u b+Co57Ht8IHmixvI/8ZUSZ+MZlPtEQD1upl9b6pX8Qyc75DosnQCYenYp341mhJSXd6q Md0MDdUw1uXnCjKfNNVJxUlqxgji5oDo5IXRN88JZEO5jzk8m2UP8UEhastG3WwcdLKE 62D7P8FzumFZODYOw817ny9sTRNg8GRU993qUbSvKpLyBSyK1Z5/ymXNX9xFKKxPRLa9 SdBw== X-Forwarded-Encrypted: i=1; AFNElJ9l+Pb5/2Rq5P8IVpMvtnuiLGTmTVN4r8AZ/+pxVpoKRZe9BVsiykS4mL3dKyE8Fkjv6rC683GgpfJv/kw=@vger.kernel.org X-Gm-Message-State: AOJu0YyRQDF6O7E+nghFBTgnjsyC0O6ql4s601Xdgs82366RZUN1pASO mEYxCRPlau851UVWfN2zKV8uDck1JkyjUAkmTM7CVJGxzSAU0gecSMnB X-Gm-Gg: AeBDievLVimn4VkXT5493G3toJDagfFWVS+5elrojba9RETGs/Ashp3zTVzOHxSsKzS FjuFpYpyFKqPYrXDzgqozeJdu69sHiemLgX9R+svDlQ7vFI5dEbhbtnvLBT4E9MHdoo4Fy4y/Ds 8wfsGIrjQDI9wzMeZ4ovxKwtvB46ebjLbNH7iqJAP/aG3/Ht62a/NJsT8CQFVmKVSNf+tnmMsHd PeXb02g349uAcsexq8OSyidPlY70fMUJDXEYEXEQJ4G7WpsYNPQxk1USWbzuOMObAAPBfw3MDdu Z3Y7i+OvNB/hcoZHBK6ZSjRgvf8V6kP/Q5dwDPOWoGtkBlm18f1JAraL8M0pvgzXZedOtBPJvwg TNypf9sIxkJWlOWym9+tW3SM/r2C7pRrPFuZu22OX56HD4uMcMOq0sQaeNYdKRAV2AjpMzYsLaJ gMYZyem8W4fFPuqibnIMhkqNLeUVU0PwDBNngPGbFolN3E+bMct8Y4hdMWyFo= X-Received: by 2002:a05:6000:1866:b0:43c:f257:c706 with SMTP id ffacd0b85a97d-43fe4088c1cmr19857907f8f.23.1776681819918; Mon, 20 Apr 2026 03:43:39 -0700 (PDT) Received: from localhost.localdomain ([2a00:23c4:a758:8a01:5f3e:f914:6f8c:72c3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43fe4c221cdsm28038301f8f.0.2026.04.20.03.43.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Apr 2026 03:43:39 -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 v5 5/9] pwm: rzg2l-gpt: Add info variable to struct rzg2l_gpt_chip Date: Mon, 20 Apr 2026 11:43:22 +0100 Message-ID: <20260420104332.153640-6-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260420104332.153640-1-biju.das.jz@bp.renesas.com> References: <20260420104332.153640-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 --- 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 9e7a897a0b4d..af594c1ce536 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; u32 period_ticks[RZG2L_MAX_HW_CHANNELS]; u32 channel_request_count[RZG2L_MAX_HW_CHANNELS]; @@ -346,7 +351,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) @@ -386,8 +391,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); @@ -527,6 +532,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"); @@ -573,8 +580,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 Tue Jun 16 14:57:01 2026 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 819F839C013 for ; Mon, 20 Apr 2026 10:43:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776681824; cv=none; b=p3F+gL01AShvhdqRO3lDIL6B/73MKwCtJ3NEGhRIicLdPhky4HprYbFdznsg1nxKz3PEK4XcFkfSHB+s06lHQAcPBhtSna9XKOFF/PZferifJyZseUfPxf+/Ux4mLLgtzN7ADAyzI69XnnWDDOHujx6zOKFXZP0wDtIzGAQ1wMw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776681824; c=relaxed/simple; bh=V6vPZIO14rznHl4RSRcL1gjxUChfhoafHLXw4fi8css=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OVSl/Q4dRerW8MuEl2VNlw0wHljJ/tyXl+5Xi6QEY2P70eV7Up7AeJsaEpgMmmjwI+Qjrk2wZ/qJuWuNDKMCkrny8KIHq59RAyTKPvv7xgMf0EtzaOvN4ehWlEE3wLl6ecOrJdHV/G3ms4S9gSaLsmKUdduz6Pw2gWpWwA8fCyw= 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=qrELNSXo; arc=none smtp.client-ip=209.85.128.41 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="qrELNSXo" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-488a8ca4aadso39578145e9.3 for ; Mon, 20 Apr 2026 03:43:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776681821; x=1777286621; 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=bdTM6lxXBPg35ylfZyqHqOCqKgb9cxeDIMetQfd6nAs=; b=qrELNSXogwaUF9nnsxcGOC8ZbOIwdjSg6KGzByj3eWxQOx5CxwaXBgiKRS4TpaeyOv DxUv7ECn10X5DvKQotVCGAabW0rtPUTP+eRVuCJ/yJGaaS7p/vVfLqsOf4GTchEdgINb DcynT8Y2Ghb/1L3DfgoIHYbNM+3Pxnm926XF1cLxbkfMd0YXF7u2xbxeuFS8VHH7bFAI I+Bqie6zUOFHM1KZpFn09ITEzPK87ebMz+AlURnzwahQuLw1bBX2xqlyaIBw6rwrA3o6 jZGNJX0Fnf5XJwm7We2hGvcAJ4cMsmxERG6KRbRkkIa/Zz1y/YXlQOQgH+VVnaHZcXT2 nBNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776681821; x=1777286621; 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=bdTM6lxXBPg35ylfZyqHqOCqKgb9cxeDIMetQfd6nAs=; b=bm5Sanx+sxaU33rWwav7l9gkamrBuAOK0BSIB8qMyXUSJrqfQ3kJW2qlqHmQgWcmOF b9TuezbMQBq1X58+wkqtwvpEnKYqBXDlMYN2e+cTCqNwqox9rYZYUSEdzUKxHCctldDG u9d2+ih8/LYtyPaNlFsk7WMNyZ3vgquSDSTHnVxtptJSbxo/mNg1sa+YYA3qfYFyacGs 62w6JgobUd5UoIvAaKjM41h0HIrdn7xtwKpa8VTCYrB5xLoa93iSS73x/vmEaeU+JcqW 4jUQKIRqLymuzdQux3gu8LPtuCFjG8kHjudzoQQ4vUXQB36uRboDX+VKDXyOIeP7a3/a tYBA== X-Forwarded-Encrypted: i=1; AFNElJ9t/ULAMWzsBT1rx3lW4y4D20LIVGHydG3RnaxjHcAMVBN28/IrOgApEoRnRa/j+p0oVAQ1Ec9DXWE+kkU=@vger.kernel.org X-Gm-Message-State: AOJu0Yw4CSJXTco7VJLyxtYyk14uYTK22GuWP+jiKlPoKq1msOp/4uVB Fy+kFfYaoI5jdZsUAQm45FPFRpFv4AqnEgG5swqE+JqEDcre01WonVcR X-Gm-Gg: AeBDiesbyzqqjG9WyUCpc/DLFOVn8evBI26+C+ppxIEbq+eHE3+3RcY5QH408tLkVxF MSXrBTyTcbxwEVBUHQZNW+oEJDbOHiisOonhI8gwDZvseNmx1665DeteLaoY/b0UEkOn1quqsT5 DPDi9jOnrHKFFUxkmbtTTnZcSeiPmeivGaphryuZ3Wn/7M4NeBW5IPtXIEpGg+q+vMhARq+yfO1 GV9rw5QwdrrHtFJOb1YPpp+Sj0OVAhXTnqjrtu6CJsOVBJRuS0f0kYxIesyTZ9aGWPtsHDvM7vM LegV44fHq2zec1lYPx+pSPPqzUIYCmjPyhWyg9NxEYlv7JVkODtIth8GD0cHdCBAwDnkgbSnqS1 vLMnMb6sJil06lPDaAKvO6Uab7wrzkg305pMPJAmuF20uHqAj5S9qJaHkH/C4S6x25a5dh+AUmO hze/CX7RynyI9A2kO1ekZ1LJOlKGglWtUIanGD281t2sZTSKhfKTI/ilO35nxsARc85YW3Rg== X-Received: by 2002:a05:6000:26cf:b0:43d:6787:992f with SMTP id ffacd0b85a97d-43fe3db2d27mr20233365f8f.10.1776681820855; Mon, 20 Apr 2026 03:43:40 -0700 (PDT) Received: from localhost.localdomain ([2a00:23c4:a758:8a01:5f3e:f914:6f8c:72c3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43fe4c221cdsm28038301f8f.0.2026.04.20.03.43.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Apr 2026 03:43:40 -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 v5 6/9] pwm: rzg2l-gpt: Add prescale_mult variable to struct rzg2l_gpt_info Date: Mon, 20 Apr 2026 11:43:23 +0100 Message-ID: <20260420104332.153640-7-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260420104332.153640-1-biju.das.jz@bp.renesas.com> References: <20260420104332.153640-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/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 --- 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 | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/pwm/pwm-rzg2l-gpt.c b/drivers/pwm/pwm-rzg2l-gpt.c index af594c1ce536..4324ffc8629d 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,6 +235,7 @@ static void rzg2l_gpt_disable(struct rzg2l_gpt_chip *rz= g2l_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 /* @@ -243,15 +245,18 @@ static u64 rzg2l_gpt_calculate_period_or_duty(struct = rzg2l_gpt_chip *rzg2l_gpt, * < 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 @@ -262,6 +267,7 @@ static int rzg2l_gpt_round_waveform_tohw(struct pwm_chi= p *chip, =20 { 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,8 +305,8 @@ static int rzg2l_gpt_round_waveform_tohw(struct pwm_chi= p *chip, } } =20 - wfhw->prescale =3D rzg2l_gpt_calculate_prescale(period_ticks); - pv =3D rzg2l_gpt_calculate_pv_or_dc(period_ticks, wfhw->prescale); + wfhw->prescale =3D rzg2l_gpt_calculate_prescale(rzg2l_gpt, period_ticks); + pv =3D rzg2l_gpt_calculate_pv_or_dc(info, period_ticks, wfhw->prescale); wfhw->gtpr =3D pv; wfhw->gtccr =3D 0; if (is_small_second_period) @@ -309,7 +315,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 > RZG2L_MAX_TICKS) duty_ticks =3D RZG2L_MAX_TICKS; - dc =3D rzg2l_gpt_calculate_pv_or_dc(duty_ticks, wfhw->prescale); + dc =3D rzg2l_gpt_calculate_pv_or_dc(info, duty_ticks, wfhw->prescale); wfhw->gtccr =3D dc; =20 /* @@ -582,6 +588,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 Tue Jun 16 14:57:01 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 677CD39D6C8 for ; Mon, 20 Apr 2026 10:43:43 +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=1776681825; cv=none; b=icW4rQ0mm1di/C4kLUlkFgJQbU6r/UK3VAI79RkuO07hoRHHn0t8oBenNd1XED2JncJ/qoWzL+3xMB5Z6TxCWxDoXRm/2OQ6P6DWZo+VWIiLqZkILjrlW+ACmJRCeE0KS7fzj+HBR0gjkD3K1BDN5YD2JpdQxqR9OmTB/Pt41zg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776681825; c=relaxed/simple; bh=CzNdLIlMDStTIZ7BBa1Bsq0Y9eD8RZUhGL/aLMqsKLs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=E+71ipQu6r0jtLRllHLurt8iQJCfDxEsbZCD8D9fuGJ5Mex3OyrhfHoeWxKk/HliqijETBxwVfmM6Hyw2zT5H88/c8byNj5DeRsGtdEkI6+LfnsQ2pbVOdZ3qSpgJ5iJ5bw4/VrJKryX/2fN0GLh/rrTsZuRBspAgP7arlQTBxQ= 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=TR6d7U1v; 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="TR6d7U1v" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-4890d945eb4so7587765e9.0 for ; Mon, 20 Apr 2026 03:43:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776681822; x=1777286622; 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=Nd03d915YFFbDDS7Gpno90+cH614IrY41lAzLURzwnU=; b=TR6d7U1vsOaB8FPOnHu12YAz4JmZFyaa0vVhlSR16IzkLgtp/qE4ivCZ3w7lWdoy0b eVqmgfLL3hinsDpBE2NTmPdMcYxuSVRvjJo+mxzbieIxTCiIW3Bws9+mePkptoXHnMQ9 5r2IFZvFpmOtp9GSph6ztttP9et1O2QGhjZKb4KgOws3BLHsqyWbdmvEwhAHFDMXsJIP KEFJNKMgaNUpO6NFKWdN43GcgupiTvxjvz7yUhzObTcM/R3xIa+Z6uYBsGgBRF9RoJQg iswSX9qUNw6EIMXsKGHy4WCaXsEkEwR+J8OgOy4uCBw4lviuEcwdxm+8nwxvA+QWlh2n 0NbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776681822; x=1777286622; 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=Nd03d915YFFbDDS7Gpno90+cH614IrY41lAzLURzwnU=; b=UNPAm4RIdqpzwPOlEVsEtf7rHrMqUD113Pxr7PUBN8vgMR9otAp0qbFZ0fWT7KKgzG Mv6g75mprnXKXQ6zpJfvqGbEoCG9OcmXh87zp0QvYe3AbQbp+exLMSQPzDRavrNzG5KZ YmrHwE176OjyPHVcshv55HyVnB0HEu6MmlfVbKL4PYN6x0CQxK9VSWFdDfYql9LJ67Bv d18KU0qNV6L5ZYPVhsygKlhu+2gyBMzNh1wYabddmJOw3hDBocGoyHhZkydr5lNgzvGz eY2AjQnVSPLz67WduiKWdxUiBl28Njm/T1paIwmSNDk0y4MnQTyQjEn7eo7R4S71mnKY I00Q== X-Forwarded-Encrypted: i=1; AFNElJ/tSml6C1Trmy7pRQIUEAQOXazoqAPbz/OGc35DIWd5yC+6vjZV6AkHWwKDpL32Q4F/HYX7XiUiRflGOFQ=@vger.kernel.org X-Gm-Message-State: AOJu0YxUjejoFBpuguHSzivGoOvTM9N9IS0nRC/0nyTXfZoQuDAfXUMn KhLvzs/0SRJ5YzJtTecBwY7gFK6W9NyodoqAZljZ2NE9SCu9VsHR+FEd X-Gm-Gg: AeBDietqy5TeYFaTvPV4gwbNhCVO7U1ld1bt2epcXmekfi37+5t/UBgCw9v5HuE+xyU 3dZWqp5FBq/2y8zZCUFWqLG80ecLKjENqVjtrp1072/GDzN48cYEPV6dVQJ7q87QThfnI5ZUriO 2cSxhYY1hlrjsTDInbRDTOO9vN8vlnJnRLBL8bf9Tyz23PAzZ38JJV+avu2EzmrAHTwPPVb/Q3A S6z0VwmONwQAPHS7AGQF61PEOjpCpz6H+VNVt/eGjv6FPdjBuJJjruz5BO5wGxQQwnzfjJNPHya C2j34fNTDT15d1Zba+vLpuZQ7zgrQXnWHMddYBUMUjO99MUNPnsh3kcFEb3FgjyPw7I+EqSxkLB 7iH97DZVAxFGvoHd1bTEOMMBavdHIz4GLp9aKph6Y7hfkKs7Ot5Qa230NIChKPsaFp2H6HyueRl lmUPKeeannbv4JvLZ8iD7KGh0VBxgJLojXPLoQHz8leWvVTD3ZU/qdcD/KW8AEh4+cw6LFFw== X-Received: by 2002:a05:600c:8a1a:20b0:485:3038:72c2 with SMTP id 5b1f17b1804b1-488fb8bcdf6mr130455095e9.17.1776681821758; Mon, 20 Apr 2026 03:43:41 -0700 (PDT) Received: from localhost.localdomain ([2a00:23c4:a758:8a01:5f3e:f914:6f8c:72c3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43fe4c221cdsm28038301f8f.0.2026.04.20.03.43.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Apr 2026 03:43:41 -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 v5 7/9] pwm: rzg2l-gpt: Add calculate_prescale() callback to struct rzg2l_gpt_info Date: Mon, 20 Apr 2026 11:43:24 +0100 Message-ID: <20260420104332.153640-8-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260420104332.153640-1-biju.das.jz@bp.renesas.com> References: <20260420104332.153640-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 --- 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 4324ffc8629d..de68c02b2d50 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(rzg2l_gpt, period_ticks); + wfhw->prescale =3D info->calculate_prescale(period_ticks); pv =3D rzg2l_gpt_calculate_pv_or_dc(info, period_ticks, wfhw->prescale); wfhw->gtpr =3D pv; wfhw->gtccr =3D 0; @@ -587,6 +588,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 Tue Jun 16 14:57:01 2026 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7DE9D39D6F9 for ; Mon, 20 Apr 2026 10:43:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776681827; cv=none; b=udONJRGpC90OFVfV9rVOUdm3WdDIJ0qKN4pi+s0B5hGAJI2AAUNr2qURMo0w/zkYupBzrMrpoCx6KvNrV+KjnnOr/VZTIQghw/dWaX9veU0TbfOjYpp5cyAsjrMHIESJ+EXwuHwpeTJydSyb1q0VqUo1gtyByBOLhsaVFZJ3mCs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776681827; c=relaxed/simple; bh=aSc61WI2GCRv4io4Xwk6XQ589ru7d382pkZgvtVmxZo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=I4SBeojNdCg2KL1dIE5bEV5oXCOnPVzHDBYe046MbzFcXcCEJYNy0d8JIhbnP4InHFknSyX3e7092fKnJ9fOswiiAzBJ6gfful7waaobSpt/4vFyQtNZ5/+rZoKG3ygczJsgW5l8JG+1HH5Gd9BZsO2txzzg1r6yfBYifelmh8o= 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=NT5IKr4s; arc=none smtp.client-ip=209.85.128.50 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="NT5IKr4s" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-488a14c31eeso21811185e9.0 for ; Mon, 20 Apr 2026 03:43:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776681823; x=1777286623; 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=6qejXMPJoK1szlmp+NPBWtIuGPTckrdO8Ea5i79s798=; b=NT5IKr4sPA7pjuzOgjbl02KUzdzozZalJpPmS5I7FsMjLuUrjuODcEiCeGrw/ryu2J y3mg3cxPMYkKJ67JeG5AvMMrobOVjXUrnky6eQWXQJficckerkTrkoeKux+qmG7mvr+h yvWQTUFhG5alFj5VKFrwLfpQLrAPnfP+HhXQENsXCRvbw0cY8x0pLzndByLX2LLk1BmP gZzGRyU+BJp5+7gtA57AFaa46ttkUgRISbqpbUcTkmcfBzrcg/1PF2e/auAUVCE1vp/0 CSDfxt+5mkvnvTMURU/RdRK35rJQy8WUOTvbg/UaeKpYdp83p9BqBM8H16iA8wFKCqeq OhdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776681823; x=1777286623; 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=6qejXMPJoK1szlmp+NPBWtIuGPTckrdO8Ea5i79s798=; b=O1CsHY9lvCytxDa/e8kKGE1kCbabL4d/m0lbXxXmtwB3eYKUrL+cDyA6nG3NN+6QnX IQbzTb91MYSoAKqhovNgZW8oKYWTckId/nV+VwQNtKqSceVaX2GVQFA/62Di7iQN7BR6 N5dr+S4w+IAh9/XeSX3dCiZN7sCD7XlMHzge3HUL9F3QqGrDbTdYtekJph2Bxci/kuq2 Hv3i0HF5a4W8pDvktbRdNIRCJlj889MQLlA3qyZ1Ewp2HFZNu76t+Gaa4SfPtNHs8bVi r+Qao8tWW3S3BMfgTCeG9aVTXIcXx7/djTHrj2C3mpE2IoNmrnoCWXUkTrckNypE/fAi P3yg== X-Forwarded-Encrypted: i=1; AFNElJ84Gw4paV8nMz34XZFNredWBnskJg2nzRtJ3MPlNBMXswVUr29bc2kwyWNlSNOMrSClAdVjOV7FHxnw+Fs=@vger.kernel.org X-Gm-Message-State: AOJu0YwatkIm2LGbtADinp33QkhpSVCpgdbgLxj+NfO7430+0EQFbQ08 ijxPL1w4zSDX08tN4RTkGpS1whkmahX2me0565dLQkNbZF27f07JZT0J X-Gm-Gg: AeBDieuSHAaxmL54DgnNVfwRlHeInCzdjFLWPY7SX6mvr9rrL/zEveV5z38xPDUth26 TwGeZf/0tFDeVRV/uIjTujL4W7LVbIekC/3u6yQjQlXDLrd9MM78Jcad507pGFjP874T+aKaeZ0 EaBec7cHaXvM/JNjWWl2rhPDxODshLuQRQAJSJsCV/SW0peOsQVOv3xdx6oNLQT/W8rYXKueqOG 1whUvEMyqOpsx8YUShLQRLA8X0spv/16LrAqHE9MfB2hO7lO5QFML9sG9bekGUoDivMx60xRcMo uCOExDx8wO/fjEzhG3NVq25a4Iu36MrPD+9mk6lCikTH6NjIkE/5YXvwBHd6EO5zc8i0YMylKbG qWE9maxu/kCD0dpqmqx7Gs2VborkqY20xKhyt73GviTUzGPiRN5c59lMKzRJp0lrTH9D7GxhTYK rduIhSL9nCjOFlQhlYSVamXmJ7bolofgeajjY9iVfKbcwDBK/jclBeV2FewMo= X-Received: by 2002:a05:600c:34c3:b0:485:41c4:e2e4 with SMTP id 5b1f17b1804b1-488fb792dd0mr184333935e9.23.1776681822758; Mon, 20 Apr 2026 03:43:42 -0700 (PDT) Received: from localhost.localdomain ([2a00:23c4:a758:8a01:5f3e:f914:6f8c:72c3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43fe4c221cdsm28038301f8f.0.2026.04.20.03.43.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Apr 2026 03:43:42 -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 v5 8/9] dt-bindings: pwm: Document RZ/G3E GPT support Date: Mon, 20 Apr 2026 11:43:25 +0100 Message-ID: <20260420104332.153640-9-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260420104332.153640-1-biju.das.jz@bp.renesas.com> References: <20260420104332.153640-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 --- 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 Tue Jun 16 14:57:01 2026 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CDFE239DBE5 for ; Mon, 20 Apr 2026 10:43:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776681827; cv=none; b=SeLpD49qwt8hfc6hmPI4prOMPYi+aMXN8eLrZraCwJGoCtI3DQWScAjfSjTMwyLIw2a8GYB5egV1nYc981lSOnLF22aPsnJEYNI/z7V6yiBilMvuD9ghbYHX0XYOh8bA+NO5epLXCPqXyctdNhnRuQ6zV0mxLgj+6giDsevvV64= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776681827; c=relaxed/simple; bh=2izCtwVg2FbMrCF9D0GFBTIEFINhlDmb1BO3OtT2pMM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jfbHBRjuvo8UDVU46clftih8xsVQKg7UPX3sQ6V2wUCkbCqICm99/Av7pfH/AbFWCB3g/34E+iQUPA5TwZ/d4BEpkhJY1uohUwkKpB+gaQypz5YA+WSN3JWVk1s6d+oiCMh72eX6ucVU4TM9tNY1y1iuVwH3VnihSZqLaHfoDEo= 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=Qe6bMvOB; arc=none smtp.client-ip=209.85.221.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="Qe6bMvOB" Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-43fe62837baso1683346f8f.3 for ; Mon, 20 Apr 2026 03:43:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776681824; x=1777286624; 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=aaXdFUrPKp/aeXuJhYhtKOEu72sa7QrupczRt752uE0=; b=Qe6bMvOBdtpLbY53loJ+cQkepeWM4SIg/K10YTyJEagIWcPJcJsH9GsLdQbeKR0ACi yXY0f5CrS8kDdif2gTIXcET3mXWEOPcecK3Hns+4dJhBuu/TkPtEOHTfJqjdlTfBGWx4 M4Q8INcvzeTVkJ1zZIrehYoTs/eyF4npqj8m5UnCU+4c0odrm13WBWxQI++V6cUoyOso c9AwYF4daauEUQpP7FwpliSYhrgUS44Blvs9O3Ed0OuwkpKOe0BCdgmHwFEJmQsj05Hc 2iN4LNDgjlke/PD3/A8GXqmseb7Avty0z6MO8hX4boWJJHQPJF8w+GWFbmmwyEKGkYbe GECA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776681824; x=1777286624; 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=aaXdFUrPKp/aeXuJhYhtKOEu72sa7QrupczRt752uE0=; b=p1ct8qFgNNrKqx13Un4iNnix43Bn5dH7x4FxrI5MZUBioWpUbhwTKQjfxOaV9Np/5T Oq6P5mFYAhTjLqEDlHF/yhsiX7gcnMfkFIsxRaUbnjOnWkuKxjiQePfOZHF1sbm5PrF3 mkw/lvEdVTL4y+QAUw/suh3MJCaa6cdOM+tcEamDbGpEZFiGcqpRT4J82McHmf1Os3h+ zpu3xTol3vkfohbdDu8YYmUlmaikfVVHaVJ1C5+vgFKGKhbuBfEGgQDBaZ/dbJND0Tas U162U5cPGleFP7/vzy0RqjZEtiDqjyJIHAhuvxJvSTaKLZjIk88aJbqJ+7JmlXL5DyGq 8LdQ== X-Forwarded-Encrypted: i=1; AFNElJ+kvCqy3Ky9myHziVW8xRlgfitCAUAlDMe0ffyHZpprhtvxZr8i4uzf9u9h1AhpM+g6W8J/Yto26NSEieA=@vger.kernel.org X-Gm-Message-State: AOJu0YygBB+XGYxRM7CuoJZZWwOi7ycNxCIDn6L/SNucJzXeeKcgXscB rBP7FTIoNXHTMLigGuSWxGOD4++RBK68EtKJEGOUBI6URE6MSv9T1wMd X-Gm-Gg: AeBDieupqZh6F5ZEyp7Xaymv8EomEHOVigLTLgqw0b+8gkCtpREsnZppVJejygxWdw3 MsII8yieNI+VgAi4h49DSMvl7XcCmKnzl90UxRotoupPMwjPwttWV2sS8OlRPDhXQLtvvgoN+Y/ f2SBINWBf2uJy4RFssyylbAWoozRb/5otpD3hkMeedQF1kUWoX+rrAYEzrAvkBXJrFGfO6kGxl1 RtLX+HOwc0dR8N4cgZMxI8P3q8GxexFFTXhTCTE6Fep1Ge/Eh/gzIsEjhyPSZVEn5+bd+k47zQf nEVx0VvfFF6p95wKarWTflVP22hh+Pvrayv0/m6v+X+AoyWoMvXoVKF3C81FmUSg0TXKqLR41u8 qWFAKLCzCpY02MNbaqD2SXxpQzQNJ/LgQXgvTbH7Se7/8Oj3YxFnS59SQwI/7LhkbTlpWumkzNx 0kj93L3GCTZSiO2HSW0GTL1IHnB/ygRlESMA++VqJpWUtk6TsLEGYy/DHvY6g= X-Received: by 2002:a05:6000:288c:b0:43e:a69b:d804 with SMTP id ffacd0b85a97d-43fe3df26b1mr20158317f8f.29.1776681824064; Mon, 20 Apr 2026 03:43:44 -0700 (PDT) Received: from localhost.localdomain ([2a00:23c4:a758:8a01:5f3e:f914:6f8c:72c3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43fe4c221cdsm28038301f8f.0.2026.04.20.03.43.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Apr 2026 03:43:43 -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 v5 9/9] pwm: rzg2l-gpt: Add RZ/G3E support Date: Mon, 20 Apr 2026 11:43:26 +0100 Message-ID: <20260420104332.153640-10-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260420104332.153640-1-biju.das.jz@bp.renesas.com> References: <20260420104332.153640-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 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 --- 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 | 47 +++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/drivers/pwm/pwm-rzg2l-gpt.c b/drivers/pwm/pwm-rzg2l-gpt.c index de68c02b2d50..8cb3e67f4fdb 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,27 @@ 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 >=3D 64 && prescaled_period_ticks < 256) { + prescale =3D 6; + } else if (prescaled_period_ticks >=3D 256 && prescaled_period_ticks < 10= 24) { + prescale =3D 8; + } else if (prescaled_period_ticks >=3D 1024) { + prescale =3D 10; + } else { + prescale =3D fls(prescaled_period_ticks); + if (prescale > 1) + prescale -=3D 1; + } + + 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); @@ -545,6 +573,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"); @@ -587,6 +623,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, @@ -594,6 +636,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