All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Marek Behún" <kabel@kernel.org>
To: netdev@vger.kernel.org, Andrew Lunn <andrew@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: "Russell King" <rmk+kernel@armlinux.org.uk>,
	"Alexander Couzens" <lynxis@fe80.eu>,
	"Daniel Golle" <daniel@makrotopia.org>,
	"Heiner Kallweit" <hkallweit1@gmail.com>,
	"Willy Liu" <willy.liu@realtek.com>,
	"Ioana Ciornei" <ioana.ciornei@nxp.com>,
	"Marek Mojík" <marek.mojik@nic.cz>,
	"Maximilián Maliar" <maximilian.maliar@nic.cz>,
	"Marek Behún" <kabel@kernel.org>
Subject: [PATCH net-next 06/15] net: phy: realtek: use generic MDIO constants
Date: Wed, 20 Dec 2023 16:55:09 +0100	[thread overview]
Message-ID: <20231220155518.15692-7-kabel@kernel.org> (raw)
In-Reply-To: <20231220155518.15692-1-kabel@kernel.org>

Drop the ad-hoc MDIO constants used in the driver and use generic
constants instead.

Signed-off-by: Marek Behún <kabel@kernel.org>
---
 drivers/net/phy/realtek.c | 30 +++++++++++++-----------------
 1 file changed, 13 insertions(+), 17 deletions(-)

diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
index 8f11320b38a8..52a7022d6a64 100644
--- a/drivers/net/phy/realtek.c
+++ b/drivers/net/phy/realtek.c
@@ -57,14 +57,6 @@
 #define RTL8366RB_POWER_SAVE			0x15
 #define RTL8366RB_POWER_SAVE_ON			BIT(12)
 
-#define RTL_SUPPORTS_5000FULL			BIT(14)
-#define RTL_SUPPORTS_2500FULL			BIT(13)
-#define RTL_SUPPORTS_10000FULL			BIT(0)
-#define RTL_ADV_2500FULL			BIT(7)
-#define RTL_LPADV_10000FULL			BIT(11)
-#define RTL_LPADV_5000FULL			BIT(6)
-#define RTL_LPADV_2500FULL			BIT(5)
-
 #define RTL9000A_GINMR				0x14
 #define RTL9000A_GINMR_LINK_STATUS		BIT(4)
 
@@ -653,11 +645,11 @@ static int rtl822x_get_features(struct phy_device *phydev)
 		return val;
 
 	linkmode_mod_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT,
-			 phydev->supported, val & RTL_SUPPORTS_2500FULL);
+			 phydev->supported, val & MDIO_PMA_SPEED_2_5G);
 	linkmode_mod_bit(ETHTOOL_LINK_MODE_5000baseT_Full_BIT,
-			 phydev->supported, val & RTL_SUPPORTS_5000FULL);
+			 phydev->supported, val & MDIO_PMA_SPEED_5G);
 	linkmode_mod_bit(ETHTOOL_LINK_MODE_10000baseT_Full_BIT,
-			 phydev->supported, val & RTL_SUPPORTS_10000FULL);
+			 phydev->supported, val & MDIO_SPEED_10G);
 
 	return genphy_read_abilities(phydev);
 }
@@ -671,10 +663,11 @@ static int rtl822x_config_aneg(struct phy_device *phydev)
 
 		if (linkmode_test_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT,
 				      phydev->advertising))
-			adv2500 = RTL_ADV_2500FULL;
+			adv2500 = MDIO_AN_10GBT_CTRL_ADV2_5G;
 
 		ret = phy_modify_paged_changed(phydev, 0xa5d, 0x12,
-					       RTL_ADV_2500FULL, adv2500);
+					       MDIO_AN_10GBT_CTRL_ADV2_5G,
+					       adv2500);
 		if (ret < 0)
 			return ret;
 	}
@@ -693,11 +686,14 @@ static int rtl822x_read_status(struct phy_device *phydev)
 			return lpadv;
 
 		linkmode_mod_bit(ETHTOOL_LINK_MODE_10000baseT_Full_BIT,
-			phydev->lp_advertising, lpadv & RTL_LPADV_10000FULL);
+				 phydev->lp_advertising,
+				 lpadv & MDIO_AN_10GBT_STAT_LP10G);
 		linkmode_mod_bit(ETHTOOL_LINK_MODE_5000baseT_Full_BIT,
-			phydev->lp_advertising, lpadv & RTL_LPADV_5000FULL);
+				 phydev->lp_advertising,
+				 lpadv & MDIO_AN_10GBT_STAT_LP5G);
 		linkmode_mod_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT,
-			phydev->lp_advertising, lpadv & RTL_LPADV_2500FULL);
+				 phydev->lp_advertising,
+				 lpadv & MDIO_AN_10GBT_STAT_LP2_5G);
 	}
 
 	ret = genphy_read_status(phydev);
@@ -715,7 +711,7 @@ static bool rtlgen_supports_2_5gbps(struct phy_device *phydev)
 	val = phy_read(phydev, 0x13);
 	phy_write(phydev, RTL821x_PAGE_SELECT, 0);
 
-	return val >= 0 && val & RTL_SUPPORTS_2500FULL;
+	return val >= 0 && val & MDIO_PMA_SPEED_2_5G;
 }
 
 static int rtlgen_match_phy_device(struct phy_device *phydev)
-- 
2.41.0


  parent reply	other threads:[~2023-12-20 15:55 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-20 15:55 [PATCH net-next 00/15] Realtek RTL822x PHY rework to c45 and SerDes interface switching Marek Behún
2023-12-20 15:55 ` [PATCH net-next 01/15] net: phy: fail early with error code if indirect MMD access fails Marek Behún
2024-01-02 11:09   ` Russell King (Oracle)
2023-12-20 15:55 ` [PATCH net-next 02/15] net: phy: export indirect MMD register accessors Marek Behún
2024-01-02 11:15   ` Russell King (Oracle)
2023-12-20 15:55 ` [PATCH net-next 03/15] net: phy: realtek: rework MMD register access methods Marek Behún
2024-01-02 11:16   ` Russell King (Oracle)
2024-01-02 13:18     ` Heiner Kallweit
2023-12-20 15:55 ` [PATCH net-next 04/15] net: phy: realtek: fill .read_mmd and .write_mmd methods for all rtl822x PHYs Marek Behún
2024-01-02 11:16   ` Russell King (Oracle)
2023-12-20 15:55 ` [PATCH net-next 05/15] net: mdio: add 2.5g and 5g related PMA speed constants Marek Behún
2024-01-02 11:05   ` Russell King (Oracle)
2023-12-20 15:55 ` Marek Behún [this message]
2024-01-02 11:06   ` [PATCH net-next 06/15] net: phy: realtek: use generic MDIO constants Russell King (Oracle)
2023-12-20 15:55 ` [PATCH net-next 07/15] net: phy: realtek: set is_c45 and fill in c45 IDs in PHY probe for rtl822x PHYs Marek Behún
2023-12-20 15:55 ` [PATCH net-next 08/15] net: phy: realtek: use generic clause 45 feature reading " Marek Behún
2023-12-20 15:55 ` [PATCH net-next 09/15] net: phy: realtek: read standard MMD register for rtlgen speed capability Marek Behún
2023-12-20 15:55 ` [PATCH net-next 10/15] net: phy: realtek: use generic c45 AN config with 1000baseT vendor extension for rtl822x Marek Behún
2023-12-20 15:55 ` [PATCH net-next 11/15] net: phy: realtek: use generic c45 status reading " Marek Behún
2023-12-20 15:55 ` [PATCH net-next 12/15] net: phy: realtek: use generic c45 suspend/resume " Marek Behún
2023-12-20 15:55 ` [PATCH net-next 13/15] net: phy: realtek: drop .read_page and .write_page for rtl822x series Marek Behún
2023-12-20 17:23   ` Heiner Kallweit
2023-12-21 10:21     ` Marek Behún
2023-12-20 15:55 ` [PATCH net-next 14/15] net: phy: realtek: configure SerDes mode for rtl822x PHYs Marek Behún
2023-12-20 15:55 ` [PATCH net-next 15/15] net: sfp: add quirk for another multigig RollBall transceiver Marek Behún
2023-12-20 16:20 ` [PATCH net-next 00/15] Realtek RTL822x PHY rework to c45 and SerDes interface switching Heiner Kallweit
2023-12-20 16:25   ` Marek Behún
2023-12-20 17:07     ` Heiner Kallweit
2023-12-23 19:09     ` Heiner Kallweit
2023-12-25 10:28       ` Marek Behún
2023-12-26 12:46         ` Heiner Kallweit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231220155518.15692-7-kabel@kernel.org \
    --to=kabel@kernel.org \
    --cc=andrew@lunn.ch \
    --cc=daniel@makrotopia.org \
    --cc=davem@davemloft.net \
    --cc=hkallweit1@gmail.com \
    --cc=ioana.ciornei@nxp.com \
    --cc=kuba@kernel.org \
    --cc=lynxis@fe80.eu \
    --cc=marek.mojik@nic.cz \
    --cc=maximilian.maliar@nic.cz \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rmk+kernel@armlinux.org.uk \
    --cc=willy.liu@realtek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.