diff mbox series

[net-next,12/15] net: phy: realtek: use generic c45 suspend/resume for rtl822x

Message ID 20231220155518.15692-13-kabel@kernel.org (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series Realtek RTL822x PHY rework to c45 and SerDes interface switching | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1115 this patch: 1115
netdev/cc_maintainers warning 1 maintainers not CCed: edumazet@google.com
netdev/build_clang fail Errors and warnings before: 12 this patch: 12
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1142 this patch: 1142
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 78 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Marek Behún Dec. 20, 2023, 3:55 p.m. UTC
Now that rtl822x PHYs .read_mmd() and .write_mmd() methods support
accessing all MMD registers, use the generic clause 45 functions
genphy_c45_pma_suspend() and genphy_c45_pma_resume() for the rtl822x
series of Realtek transceivers.

Add a 20ms delay after resume, as done in the current resume
implementation.

Signed-off-by: Marek Behún <kabel@kernel.org>
---
 drivers/net/phy/realtek.c | 36 ++++++++++++++++++++++++------------
 1 file changed, 24 insertions(+), 12 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
index f36b2bfabe57..cf608d390aa5 100644
--- a/drivers/net/phy/realtek.c
+++ b/drivers/net/phy/realtek.c
@@ -651,6 +651,18 @@  static int rtl822x_probe(struct phy_device *phydev)
 	return 0;
 }
 
+static int rtl822x_resume(struct phy_device *phydev)
+{
+	int ret = genphy_c45_pma_resume(phydev);
+
+	if (ret < 0)
+		return ret;
+
+	msleep(20);
+
+	return 0;
+}
+
 static int rtl822x_config_aneg(struct phy_device *phydev)
 {
 	bool changed = false;
@@ -949,8 +961,8 @@  static struct phy_driver realtek_drvs[] = {
 		.probe		= rtl822x_probe,
 		.config_aneg	= rtl822x_config_aneg,
 		.read_status	= rtl822x_read_status,
-		.suspend	= genphy_suspend,
-		.resume		= rtlgen_resume,
+		.suspend	= genphy_c45_pma_suspend,
+		.resume		= rtl822x_resume,
 		.read_page	= rtl821x_read_page,
 		.write_page	= rtl821x_write_page,
 		.read_mmd	= rtlgen_read_mmd,
@@ -961,8 +973,8 @@  static struct phy_driver realtek_drvs[] = {
 		.probe		= rtl822x_probe,
 		.config_aneg	= rtl822x_config_aneg,
 		.read_status	= rtl822x_read_status,
-		.suspend	= genphy_suspend,
-		.resume		= rtlgen_resume,
+		.suspend	= genphy_c45_pma_suspend,
+		.resume		= rtl822x_resume,
 		.read_page	= rtl821x_read_page,
 		.write_page	= rtl821x_write_page,
 		.read_mmd	= rtlgen_read_mmd,
@@ -973,8 +985,8 @@  static struct phy_driver realtek_drvs[] = {
 		.probe		= rtl822x_probe,
 		.config_aneg    = rtl822x_config_aneg,
 		.read_status    = rtl822x_read_status,
-		.suspend        = genphy_suspend,
-		.resume         = rtlgen_resume,
+		.suspend	= genphy_c45_pma_suspend,
+		.resume		= rtl822x_resume,
 		.read_page      = rtl821x_read_page,
 		.write_page     = rtl821x_write_page,
 		.read_mmd	= rtlgen_read_mmd,
@@ -985,8 +997,8 @@  static struct phy_driver realtek_drvs[] = {
 		.probe		= rtl822x_probe,
 		.config_aneg    = rtl822x_config_aneg,
 		.read_status    = rtl822x_read_status,
-		.suspend        = genphy_suspend,
-		.resume         = rtlgen_resume,
+		.suspend	= genphy_c45_pma_suspend,
+		.resume		= rtl822x_resume,
 		.read_page      = rtl821x_read_page,
 		.write_page     = rtl821x_write_page,
 		.read_mmd	= rtlgen_read_mmd,
@@ -997,8 +1009,8 @@  static struct phy_driver realtek_drvs[] = {
 		.probe		= rtl822x_probe,
 		.config_aneg    = rtl822x_config_aneg,
 		.read_status    = rtl822x_read_status,
-		.suspend        = genphy_suspend,
-		.resume         = rtlgen_resume,
+		.suspend	= genphy_c45_pma_suspend,
+		.resume		= rtl822x_resume,
 		.read_page      = rtl821x_read_page,
 		.write_page     = rtl821x_write_page,
 		.read_mmd	= rtlgen_read_mmd,
@@ -1009,8 +1021,8 @@  static struct phy_driver realtek_drvs[] = {
 		.probe		= rtl822x_probe,
 		.config_aneg    = rtl822x_config_aneg,
 		.read_status    = rtl822x_read_status,
-		.suspend        = genphy_suspend,
-		.resume         = rtlgen_resume,
+		.suspend	= genphy_c45_pma_suspend,
+		.resume		= rtl822x_resume,
 		.read_page      = rtl821x_read_page,
 		.write_page     = rtl821x_write_page,
 		.read_mmd	= rtlgen_read_mmd,