public inbox for linux-i3c@lists.infradead.org
 help / color / mirror / Atom feed
From: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
To: Frank Li <Frank.li@nxp.com>
Cc: tomm.merciai@gmail.com, linux-renesas-soc@vger.kernel.org,
	biju.das.jz@bp.renesas.com,
	Wolfram Sang <wsa+renesas@sang-engineering.com>,
	Alexandre Belloni <alexandre.belloni@bootlin.com>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/4] i3c: renesas: Switch to clk_bulk API and store clocks in private data
Date: Tue, 30 Dec 2025 19:39:40 +0100	[thread overview]
Message-ID: <aVQcbIzfqjhxFvj_@tom-desktop> (raw)
In-Reply-To: <aVP81n7yRgeHz3FX@tom-desktop>

Hi Frank,

On Tue, Dec 30, 2025 at 05:24:54PM +0100, Tommaso Merciai wrote:
> Hi Frank,
> Thanks for your review!
> 
> 
> On Tue, Dec 30, 2025 at 10:44:02AM -0500, Frank Li wrote:
> > On Tue, Dec 30, 2025 at 11:39:36AM +0100, Tommaso Merciai wrote:
> > > Replace individual devm_clk_get_enabled() calls with the clk_bulk API
> > > and store the clock handles in the driver's private data structure.
> > >
> > > This simplifies the code, and prepares the driver for upcoming
> > > suspend/resume support.
> > >
> > > No functional change intended.
> > >
> > > Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
> > > ---
> > > v1->v2:
> > >  - New patch.
> > >
> > >  drivers/i3c/master/renesas-i3c.c | 42 +++++++++++++++++++++-----------
> > >  1 file changed, 28 insertions(+), 14 deletions(-)
> > >
> > > diff --git a/drivers/i3c/master/renesas-i3c.c b/drivers/i3c/master/renesas-i3c.c
> > > index 426a418f29b6..8ef6ff06df90 100644
> > > --- a/drivers/i3c/master/renesas-i3c.c
> > > +++ b/drivers/i3c/master/renesas-i3c.c
> > > @@ -259,7 +259,8 @@ struct renesas_i3c {
> > >  	u8 addrs[RENESAS_I3C_MAX_DEVS];
> > >  	struct renesas_i3c_xferqueue xferqueue;
> > >  	void __iomem *regs;
> > > -	struct clk *tclk;
> > > +	struct clk_bulk_data clks[3];
> > > +	u8 num_clks;
> > >  };
> > >
> > >  struct renesas_i3c_i2c_dev_data {
> > > @@ -276,6 +277,10 @@ struct renesas_i3c_config {
> > >  	unsigned int has_pclkrw:1;
> > >  };
> > >
> > > +static const char * const renesas_i3c_clks[] = {
> > > +	"pclk", "tclk", "pclkrw"
> > > +};
> > > +
> > >  static inline void renesas_i3c_reg_update(void __iomem *reg, u32 mask, u32 val)
> > >  {
> > >  	u32 data = readl(reg);
> > > @@ -489,7 +494,7 @@ static int renesas_i3c_bus_init(struct i3c_master_controller *m)
> > >  	int od_high_ticks, od_low_ticks, i2c_total_ticks;
> > >  	int ret;
> > >
> > > -	rate = clk_get_rate(i3c->tclk);
> > > +	rate = clk_get_rate(i3c->clks[1].clk);
> > 
> > Can you use macro of variable replace hardcode "1"
> 
> Ack! I'd go for:
> 
> 	i3c->rate = clk_get_rate(i3c->clks[RENESAS_I3C_TCLK_IDX].clk);
> 
> in v3, thanks.
> 
> > 
> > >  	if (!rate)
> > >  		return -EINVAL;
> > >
> > > @@ -1298,11 +1303,17 @@ static const struct renesas_i3c_irq_desc renesas_i3c_irqs[] = {
> > >  	{ .name = "nack", .isr = renesas_i3c_tend_isr, .desc = "i3c-nack" },
> > >  };
> > >
> > > +static void renesas_i3c_clk_bulk_disable_unprepare(void *data)
> > > +{
> > > +	struct renesas_i3c *i3c = data;
> > > +
> > > +	clk_bulk_disable_unprepare(i3c->num_clks, i3c->clks);
> > > +}
> > > +
> > >  static int renesas_i3c_probe(struct platform_device *pdev)
> > >  {
> > >  	struct renesas_i3c *i3c;
> > >  	struct reset_control *reset;
> > > -	struct clk *clk;
> > >  	const struct renesas_i3c_config *config = of_device_get_match_data(&pdev->dev);
> > >  	int ret, i;
> > >
> > > @@ -1317,19 +1328,22 @@ static int renesas_i3c_probe(struct platform_device *pdev)
> > >  	if (IS_ERR(i3c->regs))
> > >  		return PTR_ERR(i3c->regs);
> > >
> > > -	clk = devm_clk_get_enabled(&pdev->dev, "pclk");
> > > -	if (IS_ERR(clk))
> > > -		return PTR_ERR(clk);
> > > +	i3c->num_clks = config->has_pclkrw ? 3 : 2;
> > >
> > > -	if (config->has_pclkrw) {
> > > -		clk = devm_clk_get_enabled(&pdev->dev, "pclkrw");
> > > -		if (IS_ERR(clk))
> > > -			return PTR_ERR(clk);
> > > -	}
> > > +	for (i = 0; i < i3c->num_clks; i++)
> > > +		i3c->clks[i].id = renesas_i3c_clks[i];
> > >
> > > -	i3c->tclk = devm_clk_get_enabled(&pdev->dev, "tclk");
> > > -	if (IS_ERR(i3c->tclk))
> > > -		return PTR_ERR(i3c->tclk);
> > > +	ret = devm_clk_bulk_get(&pdev->dev, i3c->num_clks, i3c->clks);
> > > +	if (ret)
> > > +		return ret;
> > > +
> > > +	ret = clk_bulk_prepare_enable(i3c->num_clks, i3c->clks);
> > > +	if (ret)
> > > +		return ret;
> > > +
> > > +	ret = devm_add_action_or_reset(&pdev->dev, renesas_i3c_clk_bulk_disable_unprepare, i3c);
> > > +	if (ret)
> > > +		return ret;
> > 
> > Can you use devm_clk_bulk_get_all_enabled()? all dts already verified
> > by dt-schema.
> 
> Ack! I'd got for:
> 
> 	i3c->num_clks = config->has_pclkrw ? 3 : 2;
> 
> 	for (i = 0; i < i3c->num_clks; i++)
> 		i3c->clks[i].id = renesas_i3c_clks[i];
> 
> 	ret = devm_clk_bulk_get_all_enabled(&pdev->dev, &i3c->clks);
> 	if (ret < 0)
> 		return ret;

Checking better I think we can directly use:

	ret = devm_clk_bulk_get_all_enabled(&pdev->dev, &i3c->clks);
	if (ret < 0)
		return ret;

	i3c->num_clks = ret;

In this way we can drop also empty_i3c_config and r9a09g047_i3c_config
that are no more required.

Thanks & Regards,
Tommaso

> 
> In v3, Thanks.
> 
> > 
> > Frank
> > 
> > >
> > >  	reset = devm_reset_control_get_optional_exclusive_deasserted(&pdev->dev, "tresetn");
> > >  	if (IS_ERR(reset))
> > > --
> > > 2.43.0
> > >
> 
> Kind Regards,
> Tommaso
> 
> 

-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

  reply	other threads:[~2025-12-30 18:40 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-30 10:39 [PATCH v2 0/4] i3c: renesas: Add suspend/resume support Tommaso Merciai
2025-12-30 10:39 ` [PATCH v2 1/4] i3c: renesas: Switch to clk_bulk API and store clocks in private data Tommaso Merciai
2025-12-30 15:44   ` Frank Li
2025-12-30 16:24     ` Tommaso Merciai
2025-12-30 18:39       ` Tommaso Merciai [this message]
2025-12-30 10:39 ` [PATCH v2 2/4] i3c: renesas: Store clock rate and reset controls in struct renesas_i3c Tommaso Merciai
2025-12-30 15:45   ` Frank Li
2025-12-30 10:39 ` [PATCH v2 3/4] i3c: renesas: Factor out hardware initialization to separate function Tommaso Merciai
2025-12-30 15:47   ` Frank Li
2025-12-30 16:27     ` Tommaso Merciai
2025-12-30 10:39 ` [PATCH v2 4/4] i3c: renesas: Add suspend/resume support Tommaso Merciai
2025-12-30 15:52   ` Frank Li
2025-12-30 16:31     ` Tommaso Merciai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aVQcbIzfqjhxFvj_@tom-desktop \
    --to=tommaso.merciai.xr@bp.renesas.com \
    --cc=Frank.li@nxp.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=biju.das.jz@bp.renesas.com \
    --cc=linux-i3c@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=tomm.merciai@gmail.com \
    --cc=wsa+renesas@sang-engineering.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox