On Do, 2024-02-15 at 16:17 +0100, Thomas Richard wrote: > Add suspend and resume support. > > The already_configured flag is cleared during the suspend stage to force > the PHY initialization during the resume stage. > > Based on the work of Théo Lebrun <theo.lebrun@xxxxxxxxxxx> > > Signed-off-by: Thomas Richard <thomas.richard@xxxxxxxxxxx> > --- > drivers/phy/cadence/phy-cadence-torrent.c | 54 +++++++++++++++++++++++++++++++ > 1 file changed, 54 insertions(+) > > diff --git a/drivers/phy/cadence/phy-cadence-torrent.c b/drivers/phy/cadence/phy-cadence-torrent.c > index 52cadca4c07b..f8945a11e7ca 100644 > --- a/drivers/phy/cadence/phy-cadence-torrent.c > +++ b/drivers/phy/cadence/phy-cadence-torrent.c > @@ -3005,6 +3005,59 @@ static void cdns_torrent_phy_remove(struct platform_device *pdev) > cdns_torrent_clk_cleanup(cdns_phy); > } > > +static int cdns_torrent_phy_suspend_noirq(struct device *dev) > +{ > + struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(dev); > + int i; > + > + reset_control_assert(cdns_phy->phy_rst); > + reset_control_assert(cdns_phy->apb_rst); > + for (i = 0; i < cdns_phy->nsubnodes; i++) > + reset_control_assert(cdns_phy->phys[i].lnk_rst); > + > + if (cdns_phy->already_configured) > + cdns_phy->already_configured = 0; > + else > + clk_disable_unprepare(cdns_phy->clk); > + > + return 0; > +} > + > +static int cdns_torrent_phy_resume_noirq(struct device *dev) > +{ > + struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(dev); > + int node = cdns_phy->nsubnodes; > + int ret, i; > + > + ret = cdns_torrent_clk(cdns_phy); > + if (ret) > + goto clk_cleanup; > + > + /* Enable APB */ > + reset_control_deassert(cdns_phy->apb_rst); > + > + if (cdns_phy->nsubnodes > 1) { > + ret = cdns_torrent_phy_configure_multilink(cdns_phy); > + if (ret) > + goto put_lnk_rst; > + } > + > + return 0; > + > +put_lnk_rst: > + for (i = 0; i < node; i++) > + reset_control_assert(cdns_phy->phys[i].lnk_rst); The same cleanup is found in probe. Would it be cleaner to move this into cdns_torrent_phy_configure_multilink() instead of duplicating it here? > + reset_control_assert(cdns_phy->apb_rst); > + clk_disable_unprepare(cdns_phy->clk); > +clk_cleanup: > + cdns_torrent_clk_cleanup(cdns_phy); This calls of_clk_del_provider(), seems misplaced here. regards Philipp