[PATCH v7 1/1] i2c: lpi2c: use clk notifier for rate changes

Andi Shyti andi.shyti at kernel.org
Wed Nov 8 01:15:13 PST 2023


Hi Alexander,

On Wed, Nov 08, 2023 at 07:46:12AM +0100, Alexander Stein wrote:
> Am Dienstag, 7. November 2023, 22:20:49 CET schrieb Andi Shyti:
> > is it my mail client not working or is is your patch that has
> > gone through something terribly bad?
> 
> I can't see anything obviously wrong. Can you elaborate?

If you see your part in my reply down here you see that some
parts are missing. Perhaps there is a bug in lei that has missed
the top part of your patch because in lore I see that, indeed,
there is nothing wrong with your mail.

Andi

> Thanks
> Alexander
> 
> > Andi
> > 
> > On Tue, Nov 07, 2023 at 03:12:01PM +0100, Alexander Stein wrote:
> > > * CLKLO = I2C_CLK_RATIO * CLKHI, SETHOLD = CLKHI, DATAVD = CLKHI/2 */
> > > 
> > >  static int lpi2c_imx_config(struct lpi2c_imx_struct *lpi2c_imx)
> > >  {
> > > 
> > > @@ -207,7 +224,7 @@ static int lpi2c_imx_config(struct lpi2c_imx_struct
> > > *lpi2c_imx)> 
> > >  	lpi2c_imx_set_mode(lpi2c_imx);
> > > 
> > > -	clk_rate = clk_get_rate(lpi2c_imx->clks[0].clk);
> > > +	clk_rate = atomic_read(&lpi2c_imx->rate_per);
> > > 
> > >  	if (!clk_rate)
> > >  	
> > >  		return -EINVAL;
> > > 
> > > @@ -590,6 +607,27 @@ static int lpi2c_imx_probe(struct platform_device
> > > *pdev)> 
> > >  	if (ret)
> > >  	
> > >  		return ret;
> > > 
> > > +	lpi2c_imx->clk_change_nb.notifier_call = lpi2c_imx_clk_change_cb;
> > > +	ret = devm_clk_notifier_register(&pdev->dev, lpi2c_imx->clks[0].clk,
> > > +					 &lpi2c_imx->clk_change_nb);
> > > +	if (ret)
> > > +		return dev_err_probe(&pdev->dev, ret,
> > > +				     "can't register peripheral clock 
> notifier\n");
> > > +	/*
> > > +	 * Lock the clock rate to avoid rate change between clk_get_rate() 
> and
> > > +	 * atomic_set()
> > > +	 */
> > > +	ret = clk_rate_exclusive_get(lpi2c_imx->clks[0].clk);
> > > +	if (ret)
> > > +		return dev_err_probe(&pdev->dev, ret,
> > > +				     "can't lock I2C peripheral clock 
> rate\n");
> > > +
> > > +	atomic_set(&lpi2c_imx->rate_per, clk_get_rate(lpi2c_imx-
> >clks[0].clk));
> > > +	clk_rate_exclusive_put(lpi2c_imx->clks[0].clk);
> > > +	if (!atomic_read(&lpi2c_imx->rate_per))
> > > +		return dev_err_probe(&pdev->dev, -EINVAL,
> > > +				     "can't get I2C peripheral clock 
> rate\n");
> > > +
> > > 
> > >  	pm_runtime_set_autosuspend_delay(&pdev->dev, I2C_PM_TIMEOUT);
> > >  	pm_runtime_use_autosuspend(&pdev->dev);
> > >  	pm_runtime_get_noresume(&pdev->dev);
> 
> 
> -- 
> TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
> Amtsgericht München, HRB 105018
> Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
> http://www.tq-group.com/
> 
> 



More information about the linux-arm-kernel mailing list