Re: omap-i2c: runtime pm issue during suspend to ram

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* Thomas Richard <thomas.richard@xxxxxxxxxxx> [231220 10:50]:
> On 12/19/23 18:15, Thomas Richard wrote:
> > Hello,
> 
> I add some people in this thread.
> 
> > 
> > I have a gpio expander (pca953x driver) connected to an i2c controller
> > managed by the omap-i2c driver.
> > And I have some issues with pm_runtime_force_suspend/resume during
> > suspend to ram.
> > For some reasons, related to hardware design, I need to access to this
> > gpio expander during suspend_noirq and resume_noirq. So I had to move
> > the suspend/resume of the pca953x to suspend_noirq/resume_noirq.

Hmm at noirq level you need to do polling on the i2c controller?

> > diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
> > index 42165ef57946..fe79b27b46fd 100644
> > --- a/drivers/i2c/busses/i2c-omap.c
> > +++ b/drivers/i2c/busses/i2c-omap.c
> > @@ -1575,9 +1575,24 @@ static int __maybe_unused
> > omap_i2c_runtime_resume(struct device *dev)
> >         return 0;
> >  }
> > 
> > +static int omap_i2c_suspend(struct device *dev)
> > +{
> > +       pm_runtime_get_sync(dev);
> > +       pm_runtime_disable(dev);
> > +       return 0;
> > +}

If you want the i2c controller enabled during suspend, you can leave it
enabled above, and as we already have SET_NOIRQ_SYSTEM_SLEEP_PM_OPS
doing force_suspend() and force_resume(), you can runtime PM put on
resume. So something like below might do the trick:

static int omap_i2c_suspend(struct device *dev)
{
	return pm_runtime_resume_and_get(dev);
}

static int omap_i2c_resume(struct device *dev)
{
	pm_runtime_mark_last_busy(dev);
	pm_runtime_put_autosuspend(dev);

	return 0;
}

> >  static const struct dev_pm_ops omap_i2c_pm_ops = {
> >         SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
> >                                       pm_runtime_force_resume)
> > +       SET_SYSTEM_SLEEP_PM_OPS(omap_i2c_suspend, omap_i2c_resume)
> >         SET_RUNTIME_PM_OPS(omap_i2c_runtime_suspend,
> >                            omap_i2c_runtime_resume, NULL)
> >  };

And with the changes you did to omap_i2c_pm_ops naturally. This way
the controller should stay active until noirq ops.

Of course it's possible I did not quite understand what you're trying
to do, but if so please let me know :)

Regards,

Tony




[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux