Netdev Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH net-next 0/2] net: phy: realtek: support NBase-T MMD EEE registers on RTL8125
@ 2019-08-16 19:55 Heiner Kallweit
  2019-08-16 19:56 ` [PATCH net-next 1/2] net: phy: add EEE-related constants Heiner Kallweit
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Heiner Kallweit @ 2019-08-16 19:55 UTC (permalink / raw)
  To: Andrew Lunn, Florian Fainelli, David Miller; +Cc: netdev

Add missing EEE-related constants, including the new MMD EEE registers
for NBase-T / 802.3bz. Based on that emulate the new 802.3bz MMD EEE
registers for 2.5Gbps EEE on RTL8125.

Heiner Kallweit (2):
  net: phy: add EEE-related constants
  net: phy: realtek: support NBase-T MMD EEE registers on RTL8125

 drivers/net/phy/realtek.c | 45 +++++++++++++++++++++++++++++++++++++--
 include/uapi/linux/mdio.h | 10 +++++++++
 2 files changed, 53 insertions(+), 2 deletions(-)

-- 
2.22.1


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

* [PATCH net-next 1/2] net: phy: add EEE-related constants
  2019-08-16 19:55 [PATCH net-next 0/2] net: phy: realtek: support NBase-T MMD EEE registers on RTL8125 Heiner Kallweit
@ 2019-08-16 19:56 ` Heiner Kallweit
  2019-08-16 19:57 ` [PATCH net-next 2/2] net: phy: realtek: support NBase-T MMD EEE registers on RTL8125 Heiner Kallweit
  2019-08-19 20:05 ` [PATCH net-next 0/2] " David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Heiner Kallweit @ 2019-08-16 19:56 UTC (permalink / raw)
  To: Andrew Lunn, Florian Fainelli, David Miller; +Cc: netdev

Add EEE-related constants. This includes the new MMD EEE registers for
NBase-T / 802.3bz.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 include/uapi/linux/mdio.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/include/uapi/linux/mdio.h b/include/uapi/linux/mdio.h
index 0a552061f..4bcb41c71 100644
--- a/include/uapi/linux/mdio.h
+++ b/include/uapi/linux/mdio.h
@@ -45,11 +45,14 @@
 #define MDIO_AN_ADVERTISE	16	/* AN advertising (base page) */
 #define MDIO_AN_LPA		19	/* AN LP abilities (base page) */
 #define MDIO_PCS_EEE_ABLE	20	/* EEE Capability register */
+#define MDIO_PCS_EEE_ABLE2	21	/* EEE Capability register 2 */
 #define MDIO_PMA_NG_EXTABLE	21	/* 2.5G/5G PMA/PMD extended ability */
 #define MDIO_PCS_EEE_WK_ERR	22	/* EEE wake error counter */
 #define MDIO_PHYXS_LNSTAT	24	/* PHY XGXS lane state */
 #define MDIO_AN_EEE_ADV		60	/* EEE advertisement */
 #define MDIO_AN_EEE_LPABLE	61	/* EEE link partner ability */
+#define MDIO_AN_EEE_ADV2	62	/* EEE advertisement 2 */
+#define MDIO_AN_EEE_LPABLE2	63	/* EEE link partner ability 2 */
 
 /* Media-dependent registers. */
 #define MDIO_PMA_10GBT_SWAPPOL	130	/* 10GBASE-T pair swap & polarity */
@@ -276,6 +279,13 @@
 #define MDIO_EEE_1000KX		0x0010	/* 1000KX EEE cap */
 #define MDIO_EEE_10GKX4		0x0020	/* 10G KX4 EEE cap */
 #define MDIO_EEE_10GKR		0x0040	/* 10G KR EEE cap */
+#define MDIO_EEE_40GR_FW	0x0100	/* 40G R fast wake */
+#define MDIO_EEE_40GR_DS	0x0200	/* 40G R deep sleep */
+#define MDIO_EEE_100GR_FW	0x1000	/* 100G R fast wake */
+#define MDIO_EEE_100GR_DS	0x2000	/* 100G R deep sleep */
+
+#define MDIO_EEE_2_5GT		0x0001	/* 2.5GT EEE cap */
+#define MDIO_EEE_5GT		0x0002	/* 5GT EEE cap */
 
 /* 2.5G/5G Extended abilities register. */
 #define MDIO_PMA_NG_EXTABLE_2_5GBT	0x0001	/* 2.5GBASET ability */
-- 
2.22.1



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

* [PATCH net-next 2/2] net: phy: realtek: support NBase-T MMD EEE registers on RTL8125
  2019-08-16 19:55 [PATCH net-next 0/2] net: phy: realtek: support NBase-T MMD EEE registers on RTL8125 Heiner Kallweit
  2019-08-16 19:56 ` [PATCH net-next 1/2] net: phy: add EEE-related constants Heiner Kallweit
@ 2019-08-16 19:57 ` Heiner Kallweit
  2019-08-19 20:05 ` [PATCH net-next 0/2] " David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Heiner Kallweit @ 2019-08-16 19:57 UTC (permalink / raw)
  To: Andrew Lunn, Florian Fainelli, David Miller; +Cc: netdev

Emulate the 802.3bz MMD EEE registers for 2.5Gbps EEE on RTL8125.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/net/phy/realtek.c | 45 +++++++++++++++++++++++++++++++++++++--
 1 file changed, 43 insertions(+), 2 deletions(-)

diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
index fa662099f..677c45985 100644
--- a/drivers/net/phy/realtek.c
+++ b/drivers/net/phy/realtek.c
@@ -305,6 +305,47 @@ static int rtlgen_write_mmd(struct phy_device *phydev, int devnum, u16 regnum,
 	return ret;
 }
 
+static int rtl8125_read_mmd(struct phy_device *phydev, int devnum, u16 regnum)
+{
+	int ret = rtlgen_read_mmd(phydev, devnum, regnum);
+
+	if (ret != -EOPNOTSUPP)
+		return ret;
+
+	if (devnum == MDIO_MMD_PCS && regnum == MDIO_PCS_EEE_ABLE2) {
+		rtl821x_write_page(phydev, 0xa6e);
+		ret = __phy_read(phydev, 0x16);
+		rtl821x_write_page(phydev, 0);
+	} else if (devnum == MDIO_MMD_AN && regnum == MDIO_AN_EEE_ADV2) {
+		rtl821x_write_page(phydev, 0xa6d);
+		ret = __phy_read(phydev, 0x12);
+		rtl821x_write_page(phydev, 0);
+	} else if (devnum == MDIO_MMD_AN && regnum == MDIO_AN_EEE_LPABLE2) {
+		rtl821x_write_page(phydev, 0xa6d);
+		ret = __phy_read(phydev, 0x10);
+		rtl821x_write_page(phydev, 0);
+	}
+
+	return ret;
+}
+
+static int rtl8125_write_mmd(struct phy_device *phydev, int devnum, u16 regnum,
+			     u16 val)
+{
+	int ret = rtlgen_write_mmd(phydev, devnum, regnum, val);
+
+	if (ret != -EOPNOTSUPP)
+		return ret;
+
+	if (devnum == MDIO_MMD_AN && regnum == MDIO_AN_EEE_ADV2) {
+		rtl821x_write_page(phydev, 0xa6d);
+		ret = __phy_write(phydev, 0x12, val);
+		rtl821x_write_page(phydev, 0);
+	}
+
+	return ret;
+}
+
 static int rtl8125_get_features(struct phy_device *phydev)
 {
 	int val;
@@ -473,8 +514,8 @@ static struct phy_driver realtek_drvs[] = {
 		.resume		= genphy_resume,
 		.read_page	= rtl821x_read_page,
 		.write_page	= rtl821x_write_page,
-		.read_mmd	= rtlgen_read_mmd,
-		.write_mmd	= rtlgen_write_mmd,
+		.read_mmd	= rtl8125_read_mmd,
+		.write_mmd	= rtl8125_write_mmd,
 	}, {
 		PHY_ID_MATCH_EXACT(0x001cc961),
 		.name		= "RTL8366RB Gigabit Ethernet",
-- 
2.22.1



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

* Re: [PATCH net-next 0/2] net: phy: realtek: support NBase-T MMD EEE registers on RTL8125
  2019-08-16 19:55 [PATCH net-next 0/2] net: phy: realtek: support NBase-T MMD EEE registers on RTL8125 Heiner Kallweit
  2019-08-16 19:56 ` [PATCH net-next 1/2] net: phy: add EEE-related constants Heiner Kallweit
  2019-08-16 19:57 ` [PATCH net-next 2/2] net: phy: realtek: support NBase-T MMD EEE registers on RTL8125 Heiner Kallweit
@ 2019-08-19 20:05 ` " David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2019-08-19 20:05 UTC (permalink / raw)
  To: hkallweit1; +Cc: andrew, f.fainelli, netdev

From: Heiner Kallweit <hkallweit1@gmail.com>
Date: Fri, 16 Aug 2019 21:55:40 +0200

> Add missing EEE-related constants, including the new MMD EEE registers
> for NBase-T / 802.3bz. Based on that emulate the new 802.3bz MMD EEE
> registers for 2.5Gbps EEE on RTL8125.

Series applied.

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

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-16 19:55 [PATCH net-next 0/2] net: phy: realtek: support NBase-T MMD EEE registers on RTL8125 Heiner Kallweit
2019-08-16 19:56 ` [PATCH net-next 1/2] net: phy: add EEE-related constants Heiner Kallweit
2019-08-16 19:57 ` [PATCH net-next 2/2] net: phy: realtek: support NBase-T MMD EEE registers on RTL8125 Heiner Kallweit
2019-08-19 20:05 ` [PATCH net-next 0/2] " David Miller

Netdev Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/netdev/0 netdev/git/0.git
	git clone --mirror https://lore.kernel.org/netdev/1 netdev/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 netdev netdev/ https://lore.kernel.org/netdev \
		netdev@vger.kernel.org netdev@archiver.kernel.org
	public-inbox-index netdev

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.netdev


AGPL code for this site: git clone https://public-inbox.org/ public-inbox