From nobody Tue Feb 10 15:44:37 2026 Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.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 E0B7F36C0BB for ; Fri, 30 Jan 2026 11:58:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769774336; cv=none; b=FLBVrmFP1YKw3r5m3BnFdlmayMBQhuXupZiBpzKma+gRWcLjiD6d9sCXVI0yJlOWUs864NlHk8OPpQ0k/4cB+FbC4arw0mnYKK22AoVgXAuyI6vs2A5z32qx9/GaTBIY4koSJK+hTT3Y13yaXUi7FbAed1gqlYmihctL+lHEr5o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769774336; c=relaxed/simple; bh=RFS3L+HoKH/ZpUq4IYPiZn2EYx+MJ9MMW1dc0w7GCLw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ll9RhevTLPu6cZkl76l6cNp8mh7/tYOFtlZ1RdBByOiFCvlSez74FiRcEmn8A2/L+U5chPijB4L1Ja9sh4ijsnDysYKbPXVxqyxUhx20++wVPjrgYi2INH72n7Bgg0AX2YOZyTMTbG12e8mN0Ox37jmGxjGCBrDASa3G+bu3slg= 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=aXTiwbgZ; arc=none smtp.client-ip=209.85.218.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="aXTiwbgZ" Received: by mail-ej1-f44.google.com with SMTP id a640c23a62f3a-b8876d1a39bso291593366b.1 for ; Fri, 30 Jan 2026 03:58:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769774333; x=1770379133; 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=HGMFI6tCot74p730gmYxB0ganfKY4B4oFGS/FHtw0j4=; b=aXTiwbgZVk5XMABOxFNKhCMNg6zjF0PYYeZi6KQJziMeRfgDl8RiWo1L0ipNXunSuj mX3g6bBv+e4vT5b39bbYoSwq1oGZLiHw6K3VSWZXVzUwpRLw+8taX4Ek+kHVTZmXeQxm ajBzdzOgZJkVKtQFZPlLlzg9M7Nnzcc76Vls21a88Q28x0bOOPWMTLJmg5emQHaE1g48 Qv/oRFdLpqYEwrwWG8HSK6zFN86OB1dbWWDGapzR76nwzKwRI+HtIl65xSpSFq7IASN3 AeoqiAdqJ5EI+DcqqBBgf3CTsF2EACNev3yjVpWVkoz3eK7r1q0LnT0wmcQOgbFjIP0X C+ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769774333; x=1770379133; 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=HGMFI6tCot74p730gmYxB0ganfKY4B4oFGS/FHtw0j4=; b=fgPMiujQhDnK8vstv8wVQenvV/mA5ZF5tKMmumoip25xBCBjLqjlHyDpGx8CfrAxFV mPxnvO8B5ao61I4TEyaddahrhu768J+ADHapdLeALZr0xuFGOmSzbqPWze6pCWUrpwwb CjxRfrhKoOWaGaTosas9z6yJYldjjgUNd111rklfgD6QCmLVQNsddpcJcBCuWir+dNn9 Gk99/nbQbh8+QLVScDp7ajumiV5jtYrderm5CFJekR9DxEPCnzZhMln1bCZUCgdP2Vnh R6+IwaZZdMNZbjy6/vvKCs4+uHVP+TLV/ldQ6DKGEbDUuzr/RjaR18A0rRGShBURKzTc 7tlg== X-Forwarded-Encrypted: i=1; AJvYcCVTRnP8rX5cd1kYUQP/q3w8K4leo5cUY57FSRluy2rld9TNUP2dAZaSX5aXhpDYxIdP8fWy4YNe8OXqzbs=@vger.kernel.org X-Gm-Message-State: AOJu0Yz64cpwHby6e6YvVZ1nGOmrp4OKqmmVOi4q/YYTBFp5/hgZlvAl 2L64STpnAypOG3xdl0XJae7VV+rnDWmDIwtIbIXQW7wpCz+AWcSM0aRZ X-Gm-Gg: AZuq6aJutXWeRSybbK9aCInhsOwhKPkPncR3wzwiFKQRdEraLYkGZPSQjrJTSrIBAgy zzZeuItl/DuNNSeYohFUrHjF5R1hG7jdnlJyi0SunB8uJnITHQ7UhRXnbv45DWTMm5hhJJvWhFw bFIQwiBwoyCMVm3e9E5leYVXyWHgN2mdNDHLe1vjC/u93si0exkeBIUjHddES9UL/VhrzF7pkUV oOqLok5WsdkY5QevDYiqi8bJsI2xprUcMaCVihFEz3ibQ8A2DMJ2WPpV6AA248AJzmQ+9KJKIHZ rGn25f6xU8M86lnAvutOsj/Jleyi7CJoNyFw8LpO6ZSVb1qTnTh5rw9MJfJGvC7pqATZ8XlyVAx iXCkdPq7PDotEiWx9vdOOYw0idPhI1tRAjjSEXQKd49uEFNYxNWpzgFIKwEm97QFwNNNWpDp5iQ ne5exAi9ouwQP8r+desb/oiiVYu7WJW4bIc4kHrvMzPUFzag== X-Received: by 2002:a17:906:d554:b0:b88:5722:700 with SMTP id a640c23a62f3a-b8dff52ba80mr155016866b.5.1769774333210; Fri, 30 Jan 2026 03:58:53 -0800 (PST) Received: from localhost.localdomain ([2a00:23c4:a758:8a01:bd64:2984:fe71:7633]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b8dbeffed15sm404671566b.31.2026.01.30.03.58.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Jan 2026 03:58:53 -0800 (PST) From: Biju X-Google-Original-From: Biju To: Geert Uytterhoeven , Michael Turquette , Stephen Boyd Cc: Biju Das , linux-renesas-soc@vger.kernel.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Prabhakar Mahadev Lad , Biju Das Subject: [PATCH v2 2/4] clk: renesas: rzg2l: Add support for enabling PLLs Date: Fri, 30 Jan 2026 11:58:43 +0000 Message-ID: <20260130115850.253555-3-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260130115850.253555-1-biju.das.jz@bp.renesas.com> References: <20260130115850.253555-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 support for enabling PLL clocks in the RZ/G3L CPG driver to turn off some PLLs, if they are not in use(eg: PLL6, PLL7) Introduce `is_enabled` and `enable` callbacks to handle PLL state transitions. With the `enable` callback, PLL will be turned ON only when the PLL consumer device is enabled; otherwise, it will remain off. Define new macros for PLL standby and monitor registers to facilitate this process. Signed-off-by: Biju Das --- v1->v2: * No change --- drivers/clk/renesas/rzg2l-cpg.c | 67 +++++++++++++++++++++++++++++++++ drivers/clk/renesas/rzg2l-cpg.h | 4 ++ 2 files changed, 71 insertions(+) diff --git a/drivers/clk/renesas/rzg2l-cpg.c b/drivers/clk/renesas/rzg2l-cp= g.c index ee92d07c6ff7..dfb36e6e6a7b 100644 --- a/drivers/clk/renesas/rzg2l-cpg.c +++ b/drivers/clk/renesas/rzg2l-cpg.c @@ -58,6 +58,13 @@ #define RZG3S_DIV_NF GENMASK(12, 1) #define RZG3S_SEL_PLL BIT(0) =20 +#define RZG3L_PLL_STBY_OFFSET(x) (GET_REG_SAMPLL_CLK1(x) - 0x4) +#define RZG3L_PLL_STBY_RESETB BIT(0) +#define RZG3L_PLL_STBY_RESETB_WEN BIT(16) +#define RZG3L_PLL_MON_OFFSET(x) (GET_REG_SAMPLL_CLK1(x) + 0x8) +#define RZG3L_PLL_MON_RESETB BIT(0) +#define RZG3L_PLL_MON_LOCK BIT(4) + #define CLK_ON_R(reg) (reg) #define CLK_MON_R(reg) (0x180 + (reg)) #define CLK_RST_R(reg) (reg) @@ -1181,6 +1188,63 @@ rzg2l_cpg_pll_clk_register(const struct cpg_core_clk= *core, return pll_clk->hw.clk; } =20 +static int rzg3l_cpg_pll_clk_is_enabled(struct clk_hw *hw) +{ + struct pll_clk *pll_clk =3D to_pll(hw); + struct rzg2l_cpg_priv *priv =3D pll_clk->priv; + u32 val =3D readl(priv->base + RZG3L_PLL_MON_OFFSET(pll_clk->conf)); + u32 mon_val =3D RZG3L_PLL_MON_RESETB | RZG3L_PLL_MON_LOCK; + + /* Ensure both RESETB and LOCK bits are set */ + return (mon_val =3D=3D (val & mon_val)); +} + +static int rzg3l_cpg_pll_clk_endisable(struct clk_hw *hw, bool enable) +{ + struct pll_clk *pll_clk =3D to_pll(hw); + struct rzg2l_cpg_priv *priv =3D pll_clk->priv; + u32 stby_offset, mon_offset; + u32 val, mon_val; + int ret; + + stby_offset =3D RZG3L_PLL_STBY_OFFSET(pll_clk->conf); + mon_offset =3D RZG3L_PLL_MON_OFFSET(pll_clk->conf); + + if (enable) { + val =3D RZG3L_PLL_STBY_RESETB_WEN | RZG3L_PLL_STBY_RESETB; + mon_val =3D RZG3L_PLL_MON_RESETB | RZG3L_PLL_MON_LOCK; + } else { + val =3D RZG3L_PLL_STBY_RESETB_WEN; + mon_val =3D 0; + } + + writel(val, priv->base + stby_offset); + + /* ensure PLL is in normal/stanby mode */ + ret =3D readl_poll_timeout_atomic(priv->base + mon_offset, val, mon_val = =3D=3D + (val & (RZG3L_PLL_MON_RESETB | RZG3L_PLL_MON_LOCK)), + 10, 100); + if (ret) + dev_err(priv->dev, "Failed to %s PLL 0x%x/%pC\n", enable ? + "enable" : "disable", stby_offset, hw->clk); + + return ret; +} + +static int rzg3l_cpg_pll_clk_enable(struct clk_hw *hw) +{ + if (rzg3l_cpg_pll_clk_is_enabled(hw)) + return 0; + + return rzg3l_cpg_pll_clk_endisable(hw, true); +} + +static const struct clk_ops rzg3l_cpg_pll_ops =3D { + .is_enabled =3D rzg3l_cpg_pll_clk_is_enabled, + .enable =3D rzg3l_cpg_pll_clk_enable, + .recalc_rate =3D rzg3s_cpg_pll_clk_recalc_rate, +}; + static struct clk *rzg2l_cpg_clk_src_twocell_get(struct of_phandle_args *clkspec, void *data) @@ -1264,6 +1328,9 @@ rzg2l_cpg_register_core_clk(const struct cpg_core_clk= *core, case CLK_TYPE_SAM_PLL: clk =3D rzg2l_cpg_pll_clk_register(core, priv, &rzg2l_cpg_pll_ops); break; + case CLK_TYPE_G3L_PLL: + clk =3D rzg2l_cpg_pll_clk_register(core, priv, &rzg3l_cpg_pll_ops); + break; case CLK_TYPE_G3S_PLL: clk =3D rzg2l_cpg_pll_clk_register(core, priv, &rzg3s_cpg_pll_ops); break; diff --git a/drivers/clk/renesas/rzg2l-cpg.h b/drivers/clk/renesas/rzg2l-cp= g.h index 1db413bb433d..7de4cb7af1cc 100644 --- a/drivers/clk/renesas/rzg2l-cpg.h +++ b/drivers/clk/renesas/rzg2l-cpg.h @@ -123,6 +123,7 @@ enum clk_types { CLK_TYPE_IN, /* External Clock Input */ CLK_TYPE_FF, /* Fixed Factor Clock */ CLK_TYPE_SAM_PLL, + CLK_TYPE_G3L_PLL, CLK_TYPE_G3S_PLL, =20 /* Clock with divider */ @@ -152,6 +153,9 @@ enum clk_types { DEF_TYPE(_name, _id, _type, .parent =3D _parent) #define DEF_SAMPLL(_name, _id, _parent, _conf) \ DEF_TYPE(_name, _id, CLK_TYPE_SAM_PLL, .parent =3D _parent, .conf =3D _co= nf) +#define DEF_G3L_PLL(_name, _id, _parent, _conf, _default_rate) \ + DEF_TYPE(_name, _id, CLK_TYPE_G3L_PLL, .parent =3D _parent, .conf =3D _co= nf, \ + .default_rate =3D _default_rate) #define DEF_G3S_PLL(_name, _id, _parent, _conf, _default_rate) \ DEF_TYPE(_name, _id, CLK_TYPE_G3S_PLL, .parent =3D _parent, .conf =3D _co= nf, \ .default_rate =3D _default_rate) --=20 2.43.0