Skip to contentSkip to conversation

net: phy: marvell: fix and extend downshift support

PATCH In review Heiner Kallweit 4 participants 16 messages Oct 28, 2019 – Oct 30, 2019

Subsystems (3)
lore
Share & tools
lore

Heiner Kallweit

author maintainer
#0 lore raw

cover net: phy: marvell: fix and extend downshift support

This series includes two fixes and two extensions for downshift support.

Heiner Kallweit (4):
net: phy: marvell: fix typo in constant

    MII_M1011_PHY_SRC_DOWNSHIFT_MASK

net: phy: marvell: fix downshift function naming
net: phy: marvell: add downshift support for M88E1111
net: phy: marvell: add PHY tunable support for more PHY versions

 drivers/net/phy/marvell.c | 112 ++++++++++++++++++++++++++++++++------
 1 file changed, 94 insertions(+), 18 deletions(-)
Signature · 1 line
2.23.0
author maintainer
#1 lore raw

PATCH 1/4 net: phy: marvell: fix typo in constant MII_M1011_PHY_SRC_DOWNSHIFT_MASK

Fix typo and use PHY_SCR for PHY-specific Control Register.

Fixes a3bdfce7bf9c ("net: phy: marvell: support downshift as PHY tunable")
---
 drivers/net/phy/marvell.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/phy/marvell.c +4 -4
index 0a814fde1..e77fc25ba 100644
@@ -53,7 +53,7 @@
 
 #define MII_M1011_PHY_SCR			0x10
 #define MII_M1011_PHY_SCR_DOWNSHIFT_EN		BIT(11)
-#define MII_M1011_PHY_SRC_DOWNSHIFT_MASK	GENMASK(14, 12)
+#define MII_M1011_PHY_SCR_DOWNSHIFT_MASK	GENMASK(14, 12)
 #define MII_M1011_PHY_SCR_DOWNSHIFT_MAX		8
 #define MII_M1011_PHY_SCR_MDI			(0x0 << 5)
 #define MII_M1011_PHY_SCR_MDI_X			(0x1 << 5)
@@ -793,7 +793,7 @@ static int m88e1111_get_downshift(struct phy_device *phydev, u8 *data)
 		return val;
 
 	enable = FIELD_GET(MII_M1011_PHY_SCR_DOWNSHIFT_EN, val);
-	cnt = FIELD_GET(MII_M1011_PHY_SRC_DOWNSHIFT_MASK, val) + 1;
+	cnt = FIELD_GET(MII_M1011_PHY_SCR_DOWNSHIFT_MASK, val) + 1;
 
 	*data = enable ? cnt : DOWNSHIFT_DEV_DISABLE;
 
@@ -812,11 +812,11 @@ static int m88e1111_set_downshift(struct phy_device *phydev, u8 cnt)
 				      MII_M1011_PHY_SCR_DOWNSHIFT_EN);
 
 	val = MII_M1011_PHY_SCR_DOWNSHIFT_EN;
-	val |= FIELD_PREP(MII_M1011_PHY_SRC_DOWNSHIFT_MASK, cnt - 1);
+	val |= FIELD_PREP(MII_M1011_PHY_SCR_DOWNSHIFT_MASK, cnt - 1);
 
 	return phy_modify(phydev, MII_M1011_PHY_SCR,
 			  MII_M1011_PHY_SCR_DOWNSHIFT_EN |
-			  MII_M1011_PHY_SRC_DOWNSHIFT_MASK,
+			  MII_M1011_PHY_SCR_DOWNSHIFT_MASK,
 			  val);
 }
 
Signature · 1 line
2.23.0
maintainer Reviewed-by on v1 1/4
#2 lore raw

Re: [PATCH net-next 1/4] net: phy: marvell: fix typo in constant MII_M1011_PHY_SRC_DOWNSHIFT_MASK

Quoted 4 lines · Heiner Kallweit

Fix typo and use PHY_SCR for PHY-specific Control Register.

Fixes a3bdfce7bf9c ("net: phy: marvell: support downshift as PHY tunable")

Andrew

Reviewed-by on v1 1/4
#3 lore raw

Re: [PATCH net-next 1/4] net: phy: marvell: fix typo in constant MII_M1011_PHY_SRC_DOWNSHIFT_MASK

In reply to Heiner Kallweit
Quoted 4 lines · Heiner Kallweit

Fix typo and use PHY_SCR for PHY-specific Control Register.

Fixes a3bdfce7bf9c ("net: phy: marvell: support downshift as PHY tunable")

Providing a Fixes tag here sounds a bit excessive, but this looking good.

Signature · 1 line
Florian
author maintainer
#4 lore raw

PATCH 2/4 net: phy: marvell: fix downshift function naming

In reply to Heiner Kallweit

I got access to the M88E1111 datasheet, and this PHY version uses another register for downshift configuration. Therefore change prefix to m88e1011, aligned with constants like MII_M1011_PHY_SCR.

Fixes a3bdfce7bf9c ("net: phy: marvell: support downshift as PHY tunable")
---
 drivers/net/phy/marvell.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)
drivers/net/phy/marvell.c +15 -15
index e77fc25ba..68ef84c23 100644
@@ -784,7 +784,7 @@ static int m88e1111_config_init(struct phy_device *phydev)
 	return genphy_soft_reset(phydev);
 }
 
-static int m88e1111_get_downshift(struct phy_device *phydev, u8 *data)
+static int m88e1011_get_downshift(struct phy_device *phydev, u8 *data)
 {
 	int val, cnt, enable;
 
@@ -800,7 +800,7 @@ static int m88e1111_get_downshift(struct phy_device *phydev, u8 *data)
 	return 0;
 }
 
-static int m88e1111_set_downshift(struct phy_device *phydev, u8 cnt)
+static int m88e1011_set_downshift(struct phy_device *phydev, u8 cnt)
 {
 	int val;
 
@@ -820,29 +820,29 @@ static int m88e1111_set_downshift(struct phy_device *phydev, u8 cnt)
 			  val);
 }
 
-static int m88e1111_get_tunable(struct phy_device *phydev,
+static int m88e1011_get_tunable(struct phy_device *phydev,
 				struct ethtool_tunable *tuna, void *data)
 {
 	switch (tuna->id) {
 	case ETHTOOL_PHY_DOWNSHIFT:
-		return m88e1111_get_downshift(phydev, data);
+		return m88e1011_get_downshift(phydev, data);
 	default:
 		return -EOPNOTSUPP;
 	}
 }
 
-static int m88e1111_set_tunable(struct phy_device *phydev,
+static int m88e1011_set_tunable(struct phy_device *phydev,
 				struct ethtool_tunable *tuna, const void *data)
 {
 	switch (tuna->id) {
 	case ETHTOOL_PHY_DOWNSHIFT:
-		return m88e1111_set_downshift(phydev, *(const u8 *)data);
+		return m88e1011_set_downshift(phydev, *(const u8 *)data);
 	default:
 		return -EOPNOTSUPP;
 	}
 }
 
-static void m88e1111_link_change_notify(struct phy_device *phydev)
+static void m88e1011_link_change_notify(struct phy_device *phydev)
 {
 	int status;
 
@@ -875,7 +875,7 @@ static int m88e1116r_config_init(struct phy_device *phydev)
 	if (err < 0)
 		return err;
 
-	err = m88e1111_set_downshift(phydev, 8);
+	err = m88e1011_set_downshift(phydev, 8);
 	if (err < 0)
 		return err;
 
@@ -1177,7 +1177,7 @@ static int m88e1540_get_tunable(struct phy_device *phydev,
 	case ETHTOOL_PHY_FAST_LINK_DOWN:
 		return m88e1540_get_fld(phydev, data);
 	case ETHTOOL_PHY_DOWNSHIFT:
-		return m88e1111_get_downshift(phydev, data);
+		return m88e1011_get_downshift(phydev, data);
 	default:
 		return -EOPNOTSUPP;
 	}
@@ -1190,7 +1190,7 @@ static int m88e1540_set_tunable(struct phy_device *phydev,
 	case ETHTOOL_PHY_FAST_LINK_DOWN:
 		return m88e1540_set_fld(phydev, data);
 	case ETHTOOL_PHY_DOWNSHIFT:
-		return m88e1111_set_downshift(phydev, *(const u8 *)data);
+		return m88e1011_set_downshift(phydev, *(const u8 *)data);
 	default:
 		return -EOPNOTSUPP;
 	}
@@ -2283,9 +2283,9 @@ static struct phy_driver marvell_drivers[] = {
 		.get_sset_count = marvell_get_sset_count,
 		.get_strings = marvell_get_strings,
 		.get_stats = marvell_get_stats,
-		.get_tunable = m88e1111_get_tunable,
-		.set_tunable = m88e1111_set_tunable,
-		.link_change_notify = m88e1111_link_change_notify,
+		.get_tunable = m88e1011_get_tunable,
+		.set_tunable = m88e1011_set_tunable,
+		.link_change_notify = m88e1011_link_change_notify,
 	},
 	{
 		.phy_id = MARVELL_PHY_ID_88E1318S,
@@ -2425,7 +2425,7 @@ static struct phy_driver marvell_drivers[] = {
 		.get_stats = marvell_get_stats,
 		.get_tunable = m88e1540_get_tunable,
 		.set_tunable = m88e1540_set_tunable,
-		.link_change_notify = m88e1111_link_change_notify,
+		.link_change_notify = m88e1011_link_change_notify,
 	},
 	{
 		.phy_id = MARVELL_PHY_ID_88E1545,
@@ -2488,7 +2488,7 @@ static struct phy_driver marvell_drivers[] = {
 		.get_stats = marvell_get_stats,
 		.get_tunable = m88e1540_get_tunable,
 		.set_tunable = m88e1540_set_tunable,
-		.link_change_notify = m88e1111_link_change_notify,
+		.link_change_notify = m88e1011_link_change_notify,
 	},
 };
 
Signature · 1 line
2.23.0
maintainer Reviewed-by on v1 2/4
#5 lore raw

Re: [PATCH net-next 2/4] net: phy: marvell: fix downshift function naming

Quoted 7 lines · Heiner Kallweit

I got access to the M88E1111 datasheet, and this PHY version uses another register for downshift configuration. Therefore change prefix to m88e1011, aligned with constants like MII_M1011_PHY_SCR.

Fixes a3bdfce7bf9c ("net: phy: marvell: support downshift as PHY tunable")

Andrew

Reviewed-by on v1 2/4
#6 lore raw

Re: [PATCH net-next 2/4] net: phy: marvell: fix downshift function naming

In reply to Heiner Kallweit
Quoted 7 lines · Heiner Kallweit

I got access to the M88E1111 datasheet, and this PHY version uses another register for downshift configuration. Therefore change prefix to m88e1011, aligned with constants like MII_M1011_PHY_SCR.

Fixes a3bdfce7bf9c ("net: phy: marvell: support downshift as PHY tunable")

Providing a Fixes tag here sounds a bit excessive, but this looking good:

Signature · 1 line
Florian
author maintainer
#7 lore raw

PATCH 3/4 net: phy: marvell: add downshift support for M88E1111

In reply to Heiner Kallweit

This patch adds downshift support for M88E1111. This PHY version uses another register for downshift configuration, reading downshift status is possible via the same register as for other PHY versions.

---
 drivers/net/phy/marvell.c | 64 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 64 insertions(+)
drivers/net/phy/marvell.c +64 -0
index 68ef84c23..aa4864c67 100644
@@ -66,6 +66,9 @@
 #define MII_M1111_PHY_LED_DIRECT	0x4100
 #define MII_M1111_PHY_LED_COMBINE	0x411c
 #define MII_M1111_PHY_EXT_CR		0x14
+#define MII_M1111_PHY_EXT_CR_DOWNSHIFT_MASK	GENMASK(11, 9)
+#define MII_M1111_PHY_EXT_CR_DOWNSHIFT_MAX	8
+#define MII_M1111_PHY_EXT_CR_DOWNSHIFT_EN	BIT(8)
 #define MII_M1111_RGMII_RX_DELAY	BIT(7)
 #define MII_M1111_RGMII_TX_DELAY	BIT(1)
 #define MII_M1111_PHY_EXT_SR		0x1b
@@ -784,6 +787,64 @@ static int m88e1111_config_init(struct phy_device *phydev)
 	return genphy_soft_reset(phydev);
 }
 
+static int m88e1111_get_downshift(struct phy_device *phydev, u8 *data)
+{
+	int val, cnt, enable;
+
+	val = phy_read(phydev, MII_M1111_PHY_EXT_CR);
+	if (val < 0)
+		return val;
+
+	enable = FIELD_GET(MII_M1111_PHY_EXT_CR_DOWNSHIFT_EN, val);
+	cnt = FIELD_GET(MII_M1111_PHY_EXT_CR_DOWNSHIFT_MASK, val) + 1;
+
+	*data = enable ? cnt : DOWNSHIFT_DEV_DISABLE;
+
+	return 0;
+}
+
+static int m88e1111_set_downshift(struct phy_device *phydev, u8 cnt)
+{
+	int val;
+
+	if (cnt > MII_M1111_PHY_EXT_CR_DOWNSHIFT_MAX)
+		return -E2BIG;
+
+	if (!cnt)
+		return phy_clear_bits(phydev, MII_M1111_PHY_EXT_CR,
+				      MII_M1111_PHY_EXT_CR_DOWNSHIFT_EN);
+
+	val = MII_M1111_PHY_EXT_CR_DOWNSHIFT_EN;
+	val |= FIELD_PREP(MII_M1111_PHY_EXT_CR_DOWNSHIFT_MASK, cnt - 1);
+
+	return phy_modify(phydev, MII_M1111_PHY_EXT_CR,
+			  MII_M1111_PHY_EXT_CR_DOWNSHIFT_EN |
+			  MII_M1111_PHY_EXT_CR_DOWNSHIFT_MASK,
+			  val);
+}
+
+static int m88e1111_get_tunable(struct phy_device *phydev,
+				struct ethtool_tunable *tuna, void *data)
+{
+	switch (tuna->id) {
+	case ETHTOOL_PHY_DOWNSHIFT:
+		return m88e1111_get_downshift(phydev, data);
+	default:
+		return -EOPNOTSUPP;
+	}
+}
+
+static int m88e1111_set_tunable(struct phy_device *phydev,
+				struct ethtool_tunable *tuna, const void *data)
+{
+	switch (tuna->id) {
+	case ETHTOOL_PHY_DOWNSHIFT:
+		return m88e1111_set_downshift(phydev, *(const u8 *)data);
+	default:
+		return -EOPNOTSUPP;
+	}
+}
+
 static int m88e1011_get_downshift(struct phy_device *phydev, u8 *data)
 {
 	int val, cnt, enable;
@@ -2245,6 +2306,9 @@ static struct phy_driver marvell_drivers[] = {
 		.get_sset_count = marvell_get_sset_count,
 		.get_strings = marvell_get_strings,
 		.get_stats = marvell_get_stats,
+		.get_tunable = m88e1111_get_tunable,
+		.set_tunable = m88e1111_set_tunable,
+		.link_change_notify = m88e1011_link_change_notify,
 	},
 	{
 		.phy_id = MARVELL_PHY_ID_88E1118,
Signature · 1 line
2.23.0
maintainer
#8 lore raw

Re: [PATCH net-next 3/4] net: phy: marvell: add downshift support for M88E1111

Quoted 3 lines · Heiner Kallweit

This patch adds downshift support for M88E1111. This PHY version uses another register for downshift configuration, reading downshift status is possible via the same register as for other PHY versions.

Hi Heiner

I think this method is also valid for the 88E1145.

Andrew

author maintainer
#9 lore raw

Re: [PATCH net-next 3/4] net: phy: marvell: add downshift support for M88E1111

Quoted 7 lines · Andrew Lunn
Quoted 3 lines · Heiner Kallweit

This patch adds downshift support for M88E1111. This PHY version uses another register for downshift configuration, reading downshift status is possible via the same register as for other PHY versions.

Hi Heiner

Hi Andrew,

Quoted 2 lines

I think this method is also valid for the 88E1145.

for this one I don't have the datasheet, therefore I didn't consider it. Then we can add downshift support for 88E1145 in a follow-up patch, similar to patch 4.

Quoted 2 lines

Andrew

Heiner

author maintainer
#10 lore raw

Re: [PATCH net-next 3/4] net: phy: marvell: add downshift support for M88E1111

In reply to Andrew Lunn
Quoted 7 lines · Andrew Lunn
Quoted 3 lines · Heiner Kallweit

This patch adds downshift support for M88E1111. This PHY version uses another register for downshift configuration, reading downshift status is possible via the same register as for other PHY versions.

Hi Heiner

Hi Andrew,

Quoted 2 lines

I think this method is also valid for the 88E1145.

I had a look at the Marvell DSDT and indeed 88E114X has same downshift support as 88E1111 (what's called MAD_PHY_DOWNSHIFT_TYPE1 in the DSDT). So I will submit a follow-up patch to add downshift support for 88E1145.

Quoted 2 lines

Andrew

Heiner

Reviewed-by on v1 3/4
#11 lore raw

Re: [PATCH net-next 3/4] net: phy: marvell: add downshift support for M88E1111

In reply to Heiner Kallweit
Quoted 5 lines · Heiner Kallweit

This patch adds downshift support for M88E1111. This PHY version uses another register for downshift configuration, reading downshift status is possible via the same register as for other PHY versions.

Signature · 1 line
Florian
author maintainer
#12 lore raw

PATCH 4/4 net: phy: marvell: add PHY tunable support for more PHY versions

In reply to Heiner Kallweit

More PHY versions are compatible with the existing downshift implementation, so let's add downshift support for them.

---
 drivers/net/phy/marvell.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/net/phy/marvell.c +12 -0
index aa4864c67..cb6570ac6 100644
@@ -2287,6 +2287,9 @@ static struct phy_driver marvell_drivers[] = {
 		.get_sset_count = marvell_get_sset_count,
 		.get_strings = marvell_get_strings,
 		.get_stats = marvell_get_stats,
+		.get_tunable = m88e1011_get_tunable,
+		.set_tunable = m88e1011_set_tunable,
+		.link_change_notify = m88e1011_link_change_notify,
 	},
 	{
 		.phy_id = MARVELL_PHY_ID_88E1111,
@@ -2444,6 +2447,9 @@ static struct phy_driver marvell_drivers[] = {
 		.get_sset_count = marvell_get_sset_count,
 		.get_strings = marvell_get_strings,
 		.get_stats = marvell_get_stats,
+		.get_tunable = m88e1011_get_tunable,
+		.set_tunable = m88e1011_set_tunable,
+		.link_change_notify = m88e1011_link_change_notify,
 	},
 	{
 		.phy_id = MARVELL_PHY_ID_88E1510,
@@ -2467,6 +2473,9 @@ static struct phy_driver marvell_drivers[] = {
 		.get_strings = marvell_get_strings,
 		.get_stats = marvell_get_stats,
 		.set_loopback = genphy_loopback,
+		.get_tunable = m88e1011_get_tunable,
+		.set_tunable = m88e1011_set_tunable,
+		.link_change_notify = m88e1011_link_change_notify,
 	},
 	{
 		.phy_id = MARVELL_PHY_ID_88E1540,
@@ -2510,6 +2519,9 @@ static struct phy_driver marvell_drivers[] = {
 		.get_sset_count = marvell_get_sset_count,
 		.get_strings = marvell_get_strings,
 		.get_stats = marvell_get_stats,
+		.get_tunable = m88e1540_get_tunable,
+		.set_tunable = m88e1540_set_tunable,
+		.link_change_notify = m88e1011_link_change_notify,
 	},
 	{
 		.phy_id = MARVELL_PHY_ID_88E3016,
Signature · 1 line
2.23.0