Skip to content

Commit 0da27ed

Browse files
thom24vinodkoul
authored andcommitted
phy: cadence-torrent: add suspend and resume support
Add suspend and resume support. The already_configured flag is cleared during the suspend stage to force the PHY initialization during the resume stage. Co-developed-by: Théo Lebrun <theo.lebrun@bootlin.com> Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com> Signed-off-by: Thomas Richard <thomas.richard@bootlin.com> Link: https://lore.kernel.org/r/20240412-j7200-phy-s2r-v1-8-f15815833974@bootlin.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent 81472a5 commit 0da27ed

1 file changed

Lines changed: 57 additions & 0 deletions

File tree

drivers/phy/cadence/phy-cadence-torrent.c

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3095,6 +3095,62 @@ static struct cdns_torrent_vals sgmii_qsgmii_xcvr_diag_ln_vals = {
30953095
.num_regs = ARRAY_SIZE(sgmii_qsgmii_xcvr_diag_ln_regs),
30963096
};
30973097

3098+
static int cdns_torrent_phy_suspend_noirq(struct device *dev)
3099+
{
3100+
struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(dev);
3101+
int i;
3102+
3103+
reset_control_assert(cdns_phy->phy_rst);
3104+
reset_control_assert(cdns_phy->apb_rst);
3105+
for (i = 0; i < cdns_phy->nsubnodes; i++)
3106+
reset_control_assert(cdns_phy->phys[i].lnk_rst);
3107+
3108+
if (cdns_phy->already_configured)
3109+
cdns_phy->already_configured = 0;
3110+
else {
3111+
clk_disable_unprepare(cdns_phy->clk1);
3112+
clk_disable_unprepare(cdns_phy->clk);
3113+
}
3114+
3115+
return 0;
3116+
}
3117+
3118+
static int cdns_torrent_phy_resume_noirq(struct device *dev)
3119+
{
3120+
struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(dev);
3121+
int node = cdns_phy->nsubnodes;
3122+
int ret, i;
3123+
3124+
ret = cdns_torrent_clk(cdns_phy);
3125+
if (ret)
3126+
return ret;
3127+
3128+
/* Enable APB */
3129+
reset_control_deassert(cdns_phy->apb_rst);
3130+
3131+
if (cdns_phy->nsubnodes > 1) {
3132+
ret = cdns_torrent_phy_configure_multilink(cdns_phy);
3133+
if (ret)
3134+
goto put_lnk_rst;
3135+
}
3136+
3137+
return 0;
3138+
3139+
put_lnk_rst:
3140+
for (i = 0; i < node; i++)
3141+
reset_control_assert(cdns_phy->phys[i].lnk_rst);
3142+
reset_control_assert(cdns_phy->apb_rst);
3143+
3144+
clk_disable_unprepare(cdns_phy->clk1);
3145+
clk_disable_unprepare(cdns_phy->clk);
3146+
3147+
return ret;
3148+
}
3149+
3150+
static DEFINE_NOIRQ_DEV_PM_OPS(cdns_torrent_phy_pm_ops,
3151+
cdns_torrent_phy_suspend_noirq,
3152+
cdns_torrent_phy_resume_noirq);
3153+
30983154
/* USB and DP link configuration */
30993155
static struct cdns_reg_pairs usb_dp_link_cmn_regs[] = {
31003156
{0x0002, PHY_PLL_CFG},
@@ -5332,6 +5388,7 @@ static struct platform_driver cdns_torrent_phy_driver = {
53325388
.driver = {
53335389
.name = "cdns-torrent-phy",
53345390
.of_match_table = cdns_torrent_phy_of_match,
5391+
.pm = pm_sleep_ptr(&cdns_torrent_phy_pm_ops),
53355392
}
53365393
};
53375394
module_platform_driver(cdns_torrent_phy_driver);

0 commit comments

Comments
 (0)