The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] phy: ti: gmii-sel: add resume support
@ 2024-01-25 17:17 Thomas Richard
  2024-02-07 14:01 ` Vinod Koul
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Richard @ 2024-01-25 17:17 UTC (permalink / raw)
  To: vkoul, kishon
  Cc: linux-phy, linux-kernel, gregory.clement, thomas.petazzoni,
	theo.lebrun, u-kumar1, Thomas Richard

The resume callback restores the submode of each PHY.

It uses the submode stored in struct phy_gmii_sel_phy_priv (variable
phy_if_mode). The submode was saved by the set_mode PHY operation.

Signed-off-by: Thomas Richard <thomas.richard@bootlin.com>
---
 drivers/phy/ti/phy-gmii-sel.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/drivers/phy/ti/phy-gmii-sel.c b/drivers/phy/ti/phy-gmii-sel.c
index 555b323f45da..c62790937313 100644
--- a/drivers/phy/ti/phy-gmii-sel.c
+++ b/drivers/phy/ti/phy-gmii-sel.c
@@ -491,11 +491,35 @@ static int phy_gmii_sel_probe(struct platform_device *pdev)
 	return 0;
 }
 
+static int phy_gmii_sel_resume_noirq(struct device *dev)
+{
+	struct phy_gmii_sel_priv *priv = dev_get_drvdata(dev);
+	struct phy_gmii_sel_phy_priv *if_phys = priv->if_phys;
+	int ret, i;
+
+	for (i = 0; i < priv->num_ports; i++) {
+		if (if_phys[i].phy_if_mode) {
+			ret = phy_gmii_sel_mode(if_phys[i].if_phy,
+						PHY_MODE_ETHERNET, if_phys[i].phy_if_mode);
+			if (ret) {
+				dev_err(dev, "port%u: restore mode fail %d\n",
+					if_phys[i].if_phy->id, ret);
+				return ret;
+			}
+		}
+	}
+
+	return 0;
+}
+
+static DEFINE_NOIRQ_DEV_PM_OPS(phy_gmii_sel_pm_ops, NULL, phy_gmii_sel_resume_noirq);
+
 static struct platform_driver phy_gmii_sel_driver = {
 	.probe		= phy_gmii_sel_probe,
 	.driver		= {
 		.name	= "phy-gmii-sel",
 		.of_match_table = phy_gmii_sel_id_table,
+		.pm = pm_sleep_ptr(&phy_gmii_sel_pm_ops),
 	},
 };
 module_platform_driver(phy_gmii_sel_driver);
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] phy: ti: gmii-sel: add resume support
  2024-01-25 17:17 [PATCH] phy: ti: gmii-sel: add resume support Thomas Richard
@ 2024-02-07 14:01 ` Vinod Koul
  0 siblings, 0 replies; 2+ messages in thread
From: Vinod Koul @ 2024-02-07 14:01 UTC (permalink / raw)
  To: kishon, Thomas Richard
  Cc: linux-phy, linux-kernel, gregory.clement, thomas.petazzoni,
	theo.lebrun, u-kumar1


On Thu, 25 Jan 2024 18:17:54 +0100, Thomas Richard wrote:
> The resume callback restores the submode of each PHY.
> 
> It uses the submode stored in struct phy_gmii_sel_phy_priv (variable
> phy_if_mode). The submode was saved by the set_mode PHY operation.
> 
> 

Applied, thanks!

[1/1] phy: ti: gmii-sel: add resume support
      commit: dc7c77bd79ffbd4c2840354a5da4b08781cb1ee8

Best regards,
-- 
~Vinod



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-02-07 14:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-25 17:17 [PATCH] phy: ti: gmii-sel: add resume support Thomas Richard
2024-02-07 14:01 ` Vinod Koul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox