[PATCH v3 2/3] drivers: bus: simple-pm-bus: Use clocks

Liu Ying victor.liu at nxp.com
Fri Aug 12 05:25:20 PDT 2022


Hi Geert,

On Fri, 2022-08-12 at 11:49 +0200, Geert Uytterhoeven wrote:
> On Thu, Aug 4, 2022 at 8:10 AM Liu Ying <victor.liu at nxp.com> wrote:
> > Simple Power-Managed bus controller may need functional clock(s)
> > to be enabled before child devices connected to the bus can be
> > accessed.  Get the clock(s) as a bulk and enable/disable the
> > clock(s) when the bus is being power managed.
> > 
> > One example is that Freescale i.MX8qxp pixel link MSI bus
> > controller
> > needs MSI clock and AHB clock to be enabled before accessing child
> > devices.
> > 
> > Signed-off-by: Liu Ying <victor.liu at nxp.com>
> > ---
> > v1->v3:
> > * No change.
> 
> Thanks for your patch!
> 
> > --- a/drivers/bus/simple-pm-bus.c
> > +++ b/drivers/bus/simple-pm-bus.c
> > @@ -72,6 +89,42 @@ static int simple_pm_bus_remove(struct
> > platform_device *pdev)
> >         return 0;
> >  }
> > 
> > +static int simple_pm_bus_runtime_suspend(struct device *dev)
> > +{
> > +       struct simple_pm_bus *bus = dev_get_drvdata(dev);
> > +
> > +       if (!bus)
> > +               return 0;
> 
> Can this really happen?

Good question. Should not happen in any cases. pm_runtime_init() sets 
runtime_status to RPM_SUSPENDED and needs_force_resume to 0, so
simple_pm_bus_runtime_{suspend,resume} are only called for
simple-pm-bus, not the others. Unless I miss something, I would remove
the check here and ...

> 
> > +
> > +       clk_bulk_disable_unprepare(bus->num_clks, bus->clks);
> > +
> > +       return 0;
> > +}
> > +
> > +static int simple_pm_bus_runtime_resume(struct device *dev)
> > +{
> > +       struct simple_pm_bus *bus = dev_get_drvdata(dev);
> > +       int ret;
> > +
> > +       if (!bus)
> > +               return 0;
> 
> Likewise.

... here.

> 
> > +
> > +       ret = clk_bulk_prepare_enable(bus->num_clks, bus->clks);
> > +       if (ret) {
> > +               dev_err(dev, "failed to enable clocks: %d\n", ret);
> > +               return ret;
> > +       }
> > +
> > +       return 0;
> > +}
> 
> The rest LGTM, so
> Reviewed-by: Geert Uytterhoeven <geert+renesas at glider.be>

Thanks,
Liu Ying




More information about the linux-arm-kernel mailing list