Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4671150iob; Sun, 8 May 2022 21:23:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzTJTjAwpCVVNeA/Hdza0hPDVp2EuY+iN6Xt55yhLJkCqDsS22DlF0Ai1fGrPUZJxGTU9jF X-Received: by 2002:aa7:93b3:0:b0:50d:56d2:e752 with SMTP id x19-20020aa793b3000000b0050d56d2e752mr14355764pff.82.1652070208868; Sun, 08 May 2022 21:23:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652070208; cv=none; d=google.com; s=arc-20160816; b=c6A05KiSiVE7J/7UhFQFhuU003W0ZHtYChoNROrTbY3czlVrDhYsUCGx73rC6mx83i vKfKJbuvj7kN0rhiBKR98TuXtvmNFvr7ARzv2qxc948ZZ8xOpjHXhcnNazCPHNnRm6eI QsXe5dwW/TgMi8dIEbvaK7HNYqREUg0hlrq9sBBZGAxdUvNBsS/Sei8Pak8DDi33rZMX DKtkou3CISi0Yh9s3drdp2eSgbyM0pjPWXK1lfzumGYcCrXOj9FpyHyryIEEZfJD4508 zKdn+KT3mB22/vmPW8Y8wZ7T7T5wdN0tZlrCUJ2Hn85Kqlrbhx2k/9UvXeX/lV3b70Wd vw8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=qYDx03vE3jj2oGtCbP5NamIhARgu7n1pdw/vsL9R664=; b=p2bEwFYeY7KlUK2QhQsIw1ta56RmWRpzoWj6/rK4BA+2ZdYLW+oADqaVRM6yA2xgU6 Lqp6bo6ovZVh741ZwY4Bh9E1SVbCsQQC7Q7QxjEbHS0f7Rfw3bRV9Yfa3xpPPkOu/8eD ChvheZMlNCbMWw21c5aflR69EO6Rxnq9b14crhInEkCJIVPbtuRd/8FM8+e+vNOkO8VK oMUh6I+Sh8A8Kp9Kfp6BS060OWyL0iJ9AnX8nqkpEFrNcbaKC6QKHh+Vun5WADxClk9q +zSPoDw6bWXaBn4XNZoUlSjz7XL4KlG11Y5nTsjkFQtC2whfhIlDOLm6JD4ZsvEC+1zv Tkxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=hKBAMIJo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id u34-20020a056a0009a200b0050567a6fe15si14779518pfg.365.2022.05.08.21.23.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 21:23:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=hKBAMIJo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EBE8C116667; Sun, 8 May 2022 21:21:58 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1391538AbiEFL5b (ORCPT + 99 others); Fri, 6 May 2022 07:57:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231791AbiEFL53 (ORCPT ); Fri, 6 May 2022 07:57:29 -0400 Received: from mail-yb1-xb36.google.com (mail-yb1-xb36.google.com [IPv6:2607:f8b0:4864:20::b36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC60B644D8; Fri, 6 May 2022 04:53:46 -0700 (PDT) Received: by mail-yb1-xb36.google.com with SMTP id m128so12400168ybm.5; Fri, 06 May 2022 04:53:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=qYDx03vE3jj2oGtCbP5NamIhARgu7n1pdw/vsL9R664=; b=hKBAMIJoWWyEdg3efE7Byll1TwG/WXi2Lhlq2hZqVg2yQpxMPMnJWt6c6nBIKeYCds Z8csE03z77cxg4ecxxgWAjaNIe124wXGAQ3z9a2mYwAzMZPu00TW0xCLfCKPNSGabwJj kS8VYK209oLBKUJTdx/k9jvQH7QpeicvykZzyIBfvXe6Ha5hFIlyvf0SpqXApyFakmsM i/ssq8sQBt4Q/IfchBXRKpGdjPL78J4/Z7UtIBfinsRujZUH2HOMrAswtHDjdxoPraBx RQxLHlsMi79SBMMf69CjnXp8JLSVC/oG8kTA4KjTnhlpz6C3Kc+kxA+qelD71NoE/7FD D9vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=qYDx03vE3jj2oGtCbP5NamIhARgu7n1pdw/vsL9R664=; b=oj1U8+HkJbXDJY9UsL4sRuVzGSLuAfKev3RkeBPz3ttMcQvcihRK2YIpzMWcPgnSee A0+GZhQC05lJDMTWyCbQb9CqqWaZczSGLmLS6u4d73e6aq6VMb394LG8u38nJlTuJf/p YdZDcNpxZRprPaGm0CSUNBwxndwStwZEzQFQe0tvHwyFejLyewZB3VysVYh38J7zVrg8 9bHyZYV38lOTLsSgHDHitdXk3tYVrQDc0p34OTtZ1qm6NQZYnhbKGAxv9PHaxJcL0AQ4 xMuXYZZ/+evojnRdfuffFRIPOWiMuKVyv16wX03ju0tcHTFiAGft1QWvUu+2gNts6Rej Ob2Q== X-Gm-Message-State: AOAM530pz3s41hYswKyUIstNK6h3Zfygf9Zasa+Y7e/CklMt986AMg3c AF51PEH751NBEcqou5ruuqnDJIvXP9MiMnmuRno= X-Received: by 2002:a25:83d1:0:b0:648:725c:6a05 with SMTP id v17-20020a2583d1000000b00648725c6a05mr1924802ybm.218.1651838025986; Fri, 06 May 2022 04:53:45 -0700 (PDT) MIME-Version: 1.0 References: <20220505193143.31826-1-prabhakar.mahadev-lad.rj@bp.renesas.com> <20220505193143.31826-3-prabhakar.mahadev-lad.rj@bp.renesas.com> In-Reply-To: From: "Lad, Prabhakar" Date: Fri, 6 May 2022 12:53:19 +0100 Message-ID: Subject: Re: [RFC PATCH 2/4] clk: renesas: rzg2l-cpg: Add support to stack the resets instead of indexing To: Biju Das Cc: Prabhakar Mahadev Lad , Geert Uytterhoeven , Michael Turquette , Stephen Boyd , Rob Herring , Krzysztof Kozlowski , "linux-clk@vger.kernel.org" , "devicetree@vger.kernel.org" , "linux-renesas-soc@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Phil Edworthy Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 6, 2022 at 7:17 AM Biju Das wrote: > > > Subject: RE: [RFC PATCH 2/4] clk: renesas: rzg2l-cpg: Add support to stack > > the resets instead of indexing > > > > Hi Lad Prabhakar, > > > > Thanks for the patch. > > > > > Subject: [RFC PATCH 2/4] clk: renesas: rzg2l-cpg: Add support to stack > > > the resets instead of indexing > > > > > > Instead of indexing the resets, stack them and instead create an id > > > member in struct rzg2l_reset to store the index. With this approach > > > for every id we will have to loop through the resets array to match the > > id. > > > > > > This in preparation to add support for Renesas RZ/Five CPG in > > > r9a07g043- cpg.c file where the resets array will be split up into > > > three i.e. common and two SoC specific. > > > > > > Signed-off-by: Lad Prabhakar > > > --- > > > drivers/clk/renesas/rzg2l-cpg.c | 76 > > > ++++++++++++++++++++++++++------- drivers/clk/renesas/rzg2l-cpg.h | 4 > > > +- > > > 2 files changed, 63 insertions(+), 17 deletions(-) > > > > > > diff --git a/drivers/clk/renesas/rzg2l-cpg.c > > > b/drivers/clk/renesas/rzg2l- cpg.c index 1ce35f65682b..94fe307ec4c5 > > > 100644 > > > --- a/drivers/clk/renesas/rzg2l-cpg.c > > > +++ b/drivers/clk/renesas/rzg2l-cpg.c > > > @@ -681,14 +681,37 @@ rzg2l_cpg_register_mod_clk(const struct > > > rzg2l_mod_clk *mod, > > > > > > #define rcdev_to_priv(x) container_of(x, struct rzg2l_cpg_priv, > > > rcdev) > > > > > > +static const struct rzg2l_reset > > > +*rzg2l_get_reset_ptr(struct rzg2l_cpg_priv *priv, > > > + unsigned long id) > > > + > > > +{ > > > + const struct rzg2l_cpg_info *info = priv->info; > > > + unsigned int i; > > > + > > > + for (i = 0; i < priv->num_resets; i++) { > > > + if (info->resets[i].id == id) > > > + return &info->resets[i]; > > > + } > > > > Is it not possible to use shared reset like RZ/G2L and RZ/V2L?, which has > > optimal memory and performance wise we can avoid bigger loop. > > > > Like adding Last index of RZ/Five as last reset index and Handle RZ/G2UL > > specific as invalid reset index in xlate?? > > Or add a invalidate_resets() callback to info structure and in probe, call this > Callback,if present to invalidate the resets which are not specific to this SoC. > Could you please elaborate on this. Cheers, Prabhakar > > > > > > > > + > > > + return NULL; > > > +} > > > + > > > static int rzg2l_cpg_reset(struct reset_controller_dev *rcdev, > > > unsigned long id) > > > { > > > struct rzg2l_cpg_priv *priv = rcdev_to_priv(rcdev); > > > - const struct rzg2l_cpg_info *info = priv->info; > > > - unsigned int reg = info->resets[id].off; > > > - u32 dis = BIT(info->resets[id].bit); > > > - u32 we = dis << 16; > > > + const struct rzg2l_reset *reset; > > > + unsigned int reg; > > > + u32 dis, we; > > > + > > > + reset = rzg2l_get_reset_ptr(priv, id); > > > + if (!reset) > > > + return -EINVAL; > > > + > > > + reg = reset->off; > > > + dis = BIT(reset->bit); > > > + we = dis << 16; > > > > > > dev_dbg(rcdev->dev, "reset id:%ld offset:0x%x\n", id, > > > CLK_RST_R(reg)); > > > > > > @@ -708,9 +731,16 @@ static int rzg2l_cpg_assert(struct > > > reset_controller_dev *rcdev, > > > unsigned long id) > > > { > > > struct rzg2l_cpg_priv *priv = rcdev_to_priv(rcdev); > > > - const struct rzg2l_cpg_info *info = priv->info; > > > - unsigned int reg = info->resets[id].off; > > > - u32 value = BIT(info->resets[id].bit) << 16; > > > + const struct rzg2l_reset *reset; > > > + unsigned int reg; > > > + u32 value; > > > + > > > + reset = rzg2l_get_reset_ptr(priv, id); > > > + if (!reset) > > > + return -EINVAL; > > > + > > > + reg = reset->off; > > > + value = BIT(reset->bit) << 16; > > > > > > dev_dbg(rcdev->dev, "assert id:%ld offset:0x%x\n", id, > > > CLK_RST_R(reg)); > > > > > > @@ -722,11 +752,17 @@ static int rzg2l_cpg_deassert(struct > > > reset_controller_dev *rcdev, > > > unsigned long id) > > > { > > > struct rzg2l_cpg_priv *priv = rcdev_to_priv(rcdev); > > > - const struct rzg2l_cpg_info *info = priv->info; > > > - unsigned int reg = info->resets[id].off; > > > - u32 dis = BIT(info->resets[id].bit); > > > - u32 value = (dis << 16) | dis; > > > + const struct rzg2l_reset *reset; > > > + unsigned int reg; > > > + u32 dis, value; > > > + > > > + reset = rzg2l_get_reset_ptr(priv, id); > > > + if (!reset) > > > + return -EINVAL; > > > > > > + reg = reset->off; > > > + dis = BIT(reset->bit); > > > + value = (dis << 16) | dis; > > > dev_dbg(rcdev->dev, "deassert id:%ld offset:0x%x\n", id, > > > CLK_RST_R(reg)); > > > > > > @@ -738,9 +774,16 @@ static int rzg2l_cpg_status(struct > > > reset_controller_dev *rcdev, > > > unsigned long id) > > > { > > > struct rzg2l_cpg_priv *priv = rcdev_to_priv(rcdev); > > > - const struct rzg2l_cpg_info *info = priv->info; > > > - unsigned int reg = info->resets[id].off; > > > - u32 bitmask = BIT(info->resets[id].bit); > > > + const struct rzg2l_reset *reset; > > > + unsigned int reg; > > > + u32 bitmask; > > > + > > > + reset = rzg2l_get_reset_ptr(priv, id); > > > + if (!reset) > > > + return -EINVAL; > > > + > > > + reg = reset->off; > > > + bitmask = BIT(reset->bit); > > > > > > return !(readl(priv->base + CLK_MRST_R(reg)) & bitmask); } @@ - > > > 756,10 +799,11 @@ static int rzg2l_cpg_reset_xlate(struct > > > reset_controller_dev *rcdev, > > > const struct of_phandle_args *reset_spec) { > > > struct rzg2l_cpg_priv *priv = rcdev_to_priv(rcdev); > > > - const struct rzg2l_cpg_info *info = priv->info; > > > unsigned int id = reset_spec->args[0]; > > > + const struct rzg2l_reset *reset; > > > > > > - if (id >= rcdev->nr_resets || !info->resets[id].off) { > > > + reset = rzg2l_get_reset_ptr(priv, id); > > > + if (!reset) { > > > dev_err(rcdev->dev, "Invalid reset index %u\n", id); > > > return -EINVAL; > > > } > > > diff --git a/drivers/clk/renesas/rzg2l-cpg.h > > > b/drivers/clk/renesas/rzg2l- cpg.h index 92c88f42ca7f..a99f2ba7868f > > > 100644 > > > --- a/drivers/clk/renesas/rzg2l-cpg.h > > > +++ b/drivers/clk/renesas/rzg2l-cpg.h > > > @@ -152,12 +152,14 @@ struct rzg2l_mod_clk { > > > * @bit: reset bit > > > */ > > > struct rzg2l_reset { > > > + unsigned int id; > > > > Now you are adding 4 bytes to each reset entry in the LUT. > > > > Cheers, > > Biju > > > > > u16 off; > > > u8 bit; > > > }; > > > > > > > > #define DEF_RST(_id, _off, _bit) \ > > > - [_id] = { \ > > > + { \ > > > + .id = (_id), \ > > > .off = (_off), \ > > > .bit = (_bit) \ > > > } > > > -- > > > 2.25.1 >