Skip to contentSkip to conversation

net: phy: add Maxlinear GPY115/21x/24x driver

PATCH In review Xu Liang 4 participants 22 messages Jun 4, 2021 – Jun 24, 2021 2 messages not in the archive

Subsystems (4)
lore
Share & tools
lore

Xu Liang

author maintainer
#0 lore raw

PATCH v3 1/1 net: phy: add Maxlinear GPY115/21x/24x driver

Add driver to support the Maxlinear GPY115, GPY211, GPY212, GPY215, GPY241, GPY245 PHYs.

---
v2 changes:
Fix format warning from checkpath and some comments. Use smaller PHY ID mask.
Split FWV register mask.
Call phy_trigger_machine if necessary when clear interrupt.
v3 changes:
Replace unnecessary phy_modify_mmd_changed with phy_modify_mmd Move firmware version print to probe.

 MAINTAINERS               |   6 +
 drivers/net/phy/Kconfig   |   6 +
 drivers/net/phy/Makefile  |   1 +
 drivers/net/phy/mxl-gpy.c | 552 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 565 insertions(+)
 create mode 100644 drivers/net/phy/mxl-gpy.c
MAINTAINERS +6 -0
index 948706174fae..140b19d038fb 100644
@@ -11168,6 +11168,12 @@ W:	https://linuxtv.org
 T:	git git://linuxtv.org/media_tree.git
 F:	drivers/media/radio/radio-maxiradio*
 
+MAXLINEAR ETHERNET PHY DRIVER
+M:	Xu Liang <[email protected]>
+L:	[email protected]
+S:	Supported
+F:	drivers/net/phy/mxl-gpy.c
+
 MCAN MMIO DEVICE DRIVER
 M:	Chandrasekar Ramakrishnan <[email protected]>
 L:	[email protected]
drivers/net/phy/Kconfig +6 -0
index 288bf405ebdb..d02098774d80 100644
@@ -207,6 +207,12 @@ config MARVELL_88X2222_PHY
 	  Support for the Marvell 88X2222 Dual-port Multi-speed Ethernet
 	  Transceiver.
 
+config MXL_GPHY
+	tristate "Maxlinear PHYs"
+	help
+	  Support for the Maxlinear GPY115, GPY211, GPY212, GPY215,
+	  GPY241, GPY245 PHYs.
+
 config MICREL_PHY
 	tristate "Micrel PHYs"
 	help
drivers/net/phy/Makefile +1 -0
index bcda7ed2455d..1055fb73ac17 100644
@@ -70,6 +70,7 @@ obj-$(CONFIG_MICREL_PHY)	+= micrel.o
 obj-$(CONFIG_MICROCHIP_PHY)	+= microchip.o
 obj-$(CONFIG_MICROCHIP_T1_PHY)	+= microchip_t1.o
 obj-$(CONFIG_MICROSEMI_PHY)	+= mscc/
+obj-$(CONFIG_MXL_GPHY)		+= mxl-gpy.o
 obj-$(CONFIG_NATIONAL_PHY)	+= national.o
 obj-$(CONFIG_NXP_C45_TJA11XX_PHY)	+= nxp-c45-tja11xx.o
 obj-$(CONFIG_NXP_TJA11XX_PHY)	+= nxp-tja11xx.o
drivers/net/phy/mxl-gpy.c new file +552 -0

552 lines not on this page · raw message

Signature · 1 line
2.17.1
#1 lore raw
Quoted 60 lines · Xu Liang

Add driver to support the Maxlinear GPY115, GPY211, GPY212, GPY215, GPY241, GPY245 PHYs.

---
v2 changes:
Fix format warning from checkpath and some comments. Use smaller PHY ID mask.
Split FWV register mask.
Call phy_trigger_machine if necessary when clear interrupt.
v3 changes:
Replace unnecessary phy_modify_mmd_changed with phy_modify_mmd Move firmware version print to probe.

 MAINTAINERS               |   6 +
 drivers/net/phy/Kconfig   |   6 +
 drivers/net/phy/Makefile  |   1 +
 drivers/net/phy/mxl-gpy.c | 552 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 565 insertions(+)
 create mode 100644 drivers/net/phy/mxl-gpy.c
MAINTAINERS +6 -0
index 948706174fae..140b19d038fb 100644
@@ -11168,6 +11168,12 @@ W:	https://linuxtv.org
 T:	git git://linuxtv.org/media_tree.git
 F:	drivers/media/radio/radio-maxiradio*
 
+MAXLINEAR ETHERNET PHY DRIVER
+M:	Xu Liang <[email protected]>
+L:	[email protected]
+S:	Supported
+F:	drivers/net/phy/mxl-gpy.c
+
 MCAN MMIO DEVICE DRIVER
 M:	Chandrasekar Ramakrishnan <[email protected]>
 L:	[email protected]
drivers/net/phy/Kconfig +6 -0
index 288bf405ebdb..d02098774d80 100644
@@ -207,6 +207,12 @@ config MARVELL_88X2222_PHY
 	  Support for the Marvell 88X2222 Dual-port Multi-speed Ethernet
 	  Transceiver.
 
+config MXL_GPHY
+	tristate "Maxlinear PHYs"
+	help
+	  Support for the Maxlinear GPY115, GPY211, GPY212, GPY215,
+	  GPY241, GPY245 PHYs.
+
 config MICREL_PHY
 	tristate "Micrel PHYs"
 	help
drivers/net/phy/Makefile +0 -0
index bcda7ed2455d..1055fb73ac17 100644

drivers/net/phy/Makefile obj-$(CONFIG_MICREL_PHY) += micrel.o · line 73

Quoted 4 lines
drivers/net/phy/Makefile +1 -0
@@ -70,6 +70,7 @@ obj-$(CONFIG_MICREL_PHY)	+= micrel.o
 obj-$(CONFIG_MICROCHIP_PHY)	+= microchip.o
 obj-$(CONFIG_MICROCHIP_T1_PHY)	+= microchip_t1.o
 obj-$(CONFIG_MICROSEMI_PHY)	+= mscc/
+obj-$(CONFIG_MXL_GPHY)		+= mxl-gpy.o

Could you spell it out completely: CONFIG_MAXLINEAR_GPHY for consistency with the other vendor's and also to have some proper namespacing in case we see a non-Ethernet PHY being submitted for a Maxlinear product in the future?

Quoted 16 lines
drivers/net/phy/Makefile +0 -0
 obj-$(CONFIG_NATIONAL_PHY)	+= national.o
 obj-$(CONFIG_NXP_C45_TJA11XX_PHY)	+= nxp-c45-tja11xx.o
 obj-$(CONFIG_NXP_TJA11XX_PHY)	+= nxp-tja11xx.o
drivers/net/phy/mxl-gpy.c new file +7 -0
new file mode 100644
index 000000000000..3e3d3096e858
@@ -0,0 +1,552 @@
+// SPDX-License-Identifier: GPL-2.0+
+/* Copyright (C) 2021 Maxlinear Corporation
+ * Copyright (C) 2020 Intel Corporation
+ *
+ * Drivers for Maxlinear Ethernet GPY
+ *
+ */

drivers/net/phy/mxl-gpy.c line 17

Quoted 10 lines
drivers/net/phy/mxl-gpy.c new file +10 -0
+
+#include <linux/version.h>
+#include <linux/module.h>
+#include <linux/bitfield.h>
+#include <linux/phy.h>
+#include <linux/netdevice.h>
+
+/* PHY ID */
+#define PHY_ID_GPY		0x67C9DC00
+#define PHY_ID_MASK		GENMASK(31, 4)

Consider initializing your phy_driver with PHY_ID_MATCH_MODEL() which would take care of populating the mask accordingly.

[snip]

Quoted 23 lines
drivers/net/phy/mxl-gpy.c new file +23 -0
+
+static int gpy_read_abilities(struct phy_device *phydev)
+{
+	int ret;
+
+	ret = genphy_read_abilities(phydev);
+	if (ret < 0)
+		return ret;
+
+	/* Detect 2.5G/5G support. */
+	ret = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_STAT2);
+	if (ret < 0)
+		return ret;
+	if (!(ret & MDIO_PMA_STAT2_EXTABLE))
+		return 0;
+
+	ret = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PMA_EXTABLE);
+	if (ret < 0)
+		return ret;
+	if (!(ret & MDIO_PMA_EXTABLE_NBT))
+		return 0;
+
+	ret = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PMA_NG_EXTABLE);

drivers/net/phy/mxl-gpy.c line 111

Quoted 10 lines
drivers/net/phy/mxl-gpy.c new file +10 -0
+	if (ret < 0)
+		return ret;
+
+	linkmode_mod_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT,
+			 phydev->supported,
+			 ret & MDIO_PMA_NG_EXTABLE_2_5GBT);
+
+	linkmode_mod_bit(ETHTOOL_LINK_MODE_5000baseT_Full_BIT,
+			 phydev->supported,
+			 ret & MDIO_PMA_NG_EXTABLE_5GBT);

This does not access vendor specific registers, should not this be part of the standard genphy_read_abilities() or moved to a helper?

Quoted 6 lines
drivers/net/phy/mxl-gpy.c new file +6 -0
+
+	return 0;
+}
+
+static int gpy_config_init(struct phy_device *phydev)
+{

drivers/net/phy/mxl-gpy.c line 127

Quoted 10 lines
drivers/net/phy/mxl-gpy.c new file +10 -0
+	int ret;
+
+	/* Mask all interrupts */
+	ret = phy_write(phydev, PHY_IMASK, 0);
+	if (ret)
+		return ret;
+
+	/* Clear all pending interrupts */
+	ret = phy_read(phydev, PHY_ISTAT);
+	return ret < 0 ? ret : 0;

You can certainly simplify this to:

	return phy_read(phydev, PHY_ISTAT);

[snip]

drivers/net/phy/mxl-gpy.c line 551

Quoted 3 lines
drivers/net/phy/mxl-gpy.c new file +3 -0
+
+MODULE_DESCRIPTION("Maxlinear Ethernet GPY Driver");
+MODULE_AUTHOR("Maxlinear Corporation");

The author is not usually a company but an individual working on behalf of that company.

Signature · 1 line
Florian
author maintainer
#2 lore raw
Quoted 8 lines · Florian Fainelli

drivers/net/phy/mxl-gpy.c line 17

Quoted 4 lines
drivers/net/phy/mxl-gpy.c new file +3 -0
+/* PHY ID */
+#define PHY_ID_GPY 0x67C9DC00
+#define PHY_ID_MASK GENMASK(31, 4)

Consider initializing your phy_driver with PHY_ID_MATCH_MODEL() which would take care of populating the mask accordingly.

Thanks, I will update.

Quoted 28 lines
Quoted 28 lines
drivers/net/phy/mxl-gpy.c new file +28 -0
+
+static int gpy_read_abilities(struct phy_device *phydev)
+{
+ int ret;
+
+ ret = genphy_read_abilities(phydev);
+ if (ret < 0)
+ return ret;
+
+ /* Detect 2.5G/5G support. */
+ ret = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_STAT2);
+ if (ret < 0)
+ return ret;
+ if (!(ret & MDIO_PMA_STAT2_EXTABLE))
+ return 0;
+
+ ret = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PMA_EXTABLE);
+ if (ret < 0)
+ return ret;
+ if (!(ret & MDIO_PMA_EXTABLE_NBT))
+ return 0;
+
+ ret = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PMA_NG_EXTABLE);
+ if (ret < 0)
+ return ret;
+
+ linkmode_mod_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT,
+ phydev->supported,
Quoted 9 lines
Quoted 5 lines

+ ret & MDIO_PMA_NG_EXTABLE_2_5GBT);
+
+ linkmode_mod_bit(ETHTOOL_LINK_MODE_5000baseT_Full_BIT,
+ phydev->supported,
+ ret & MDIO_PMA_NG_EXTABLE_5GBT);

This does not access vendor specific registers, should not this be part of the standard genphy_read_abilities() or moved to a helper?

genphy_read_abilities does not cover 2.5G.

genphy_c45_pma_read_abilities checks C45 ids and this check fail if is_c45 is not set.

Mix of C22 and C45 is handled here, as our device support C22 with extension of C45.

Quoted 19 lines
Quoted 6 lines
drivers/net/phy/mxl-gpy.c new file +6 -0
+
+ return 0;
+}
+
+static int gpy_config_init(struct phy_device *phydev)
+{

drivers/net/phy/mxl-gpy.c line 127

Quoted 10 lines
drivers/net/phy/mxl-gpy.c new file +10 -0
+ int ret;
+
+ /* Mask all interrupts */
+ ret = phy_write(phydev, PHY_IMASK, 0);
+ if (ret)
+ return ret;
+
+ /* Clear all pending interrupts */
+ ret = phy_read(phydev, PHY_ISTAT);
+ return ret < 0 ? ret : 0;

You can certainly simplify this to:

Quoted 2 lines

return phy_read(phydev, PHY_ISTAT);

I'm thinking to clearly differentiate negative, 0, and positive.

I had experience that a positive value is treated as error sometimes.

Quoted 10 lines

[snip]

drivers/net/phy/mxl-gpy.c line 551

Quoted 3 lines
drivers/net/phy/mxl-gpy.c new file +3 -0
+
+MODULE_DESCRIPTION("Maxlinear Ethernet GPY Driver");
+MODULE_AUTHOR("Maxlinear Corporation");

The author is not usually a company but an individual working on behalf of that company.

Signature · 1 line
Florian

Ok, I will update.

author maintainer
#14 lore raw
In reply to Florian Fainelli
Quoted 24 lines · Florian Fainelli
Quoted 24 lines
drivers/net/phy/Kconfig +0 -0
index 288bf405ebdb..d02098774d80 100644
@@ -207,6 +207,12 @@ config MARVELL_88X2222_PHY

Support for the Marvell 88X2222 Dual-port Multi-speed Ethernet Transceiver.

drivers/net/phy/Kconfig +6 -0
+config MXL_GPHY
+ tristate "Maxlinear PHYs"
+ help
+ Support for the Maxlinear GPY115, GPY211, GPY212, GPY215,
+ GPY241, GPY245 PHYs.
+

config MICREL_PHY
tristate "Micrel PHYs"
help

drivers/net/phy/Makefile +0 -0
index bcda7ed2455d..1055fb73ac17 100644
@@ -70,6 +70,7 @@ obj-$(CONFIG_MICREL_PHY) += micrel.o

obj-$(CONFIG_MICROCHIP_PHY) += microchip.o

Quoted 8 lines
Quoted 3 lines

obj-$(CONFIG_MICROCHIP_T1_PHY) += microchip_t1.o
obj-$(CONFIG_MICROSEMI_PHY) += mscc/
+obj-$(CONFIG_MXL_GPHY) += mxl-gpy.o

Could you spell it out completely: CONFIG_MAXLINEAR_GPHY for consistency with the other vendor's and also to have some proper namespacing in case we see a non-Ethernet PHY being submitted for a Maxlinear product in the future?

I will fix in v4 patch.

Thank you.

#15 lore raw
In reply to Xu Liang

Hello,

Quoted 2 lines

Add driver to support the Maxlinear GPY115, GPY211, GPY212, GPY215, GPY241, GPY245 PHYs.

to me this seems like an evolution of the Lantiq XWAY PHYs for which we already have a driver: intel-xway.c.
Intel took over Lantiq some years ago and last year MaxLinear then took over what was formerly Lantiq from Intel.

From what I can tell right away: the interrupt handling still seems to be the same. Also the GPHY firmware version register also was there on older SoCs (with two or more GPHYs embedded into the SoC). SGMII support is new. And I am not sure about Wake-on-LAN.

Have you considered adding support for these new PHYs to intel-xway.c?

Best regards,
Martin

maintainer
#3 lore raw
In reply to Liang Xu
Quoted 36 lines
Quoted 27 lines
Quoted 27 lines
drivers/net/phy/mxl-gpy.c new file +27 -0
+static int gpy_read_abilities(struct phy_device *phydev)
+{
+ int ret;
+
+ ret = genphy_read_abilities(phydev);
+ if (ret < 0)
+ return ret;
+
+ /* Detect 2.5G/5G support. */
+ ret = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_STAT2);
+ if (ret < 0)
+ return ret;
+ if (!(ret & MDIO_PMA_STAT2_EXTABLE))
+ return 0;
+
+ ret = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PMA_EXTABLE);
+ if (ret < 0)
+ return ret;
+ if (!(ret & MDIO_PMA_EXTABLE_NBT))
+ return 0;
+
+ ret = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PMA_NG_EXTABLE);
+ if (ret < 0)
+ return ret;
+
+ linkmode_mod_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT,
+ phydev->supported,
Quoted 9 lines
Quoted 5 lines

+ ret & MDIO_PMA_NG_EXTABLE_2_5GBT);
+
+ linkmode_mod_bit(ETHTOOL_LINK_MODE_5000baseT_Full_BIT,
+ phydev->supported,
+ ret & MDIO_PMA_NG_EXTABLE_5GBT);

This does not access vendor specific registers, should not this be part of the standard genphy_read_abilities() or moved to a helper?

Quoted 4 lines

genphy_read_abilities does not cover 2.5G.

genphy_c45_pma_read_abilities checks C45 ids and this check fail if is_c45 is not set.

You appear to of ignored my comment about this. Please add the helper to the core as i suggested, and then use genphy_c45_pma_read_abilities().

Andrew

author maintainer
#16 lore raw
In reply to Martin Blumenstingl
Quoted 17 lines · Martin Blumenstingl

This email was sent from outside of MaxLinear.

Hello,

Quoted 2 lines

Add driver to support the Maxlinear GPY115, GPY211, GPY212, GPY215, GPY241, GPY245 PHYs.

to me this seems like an evolution of the Lantiq XWAY PHYs for which we already have a driver: intel-xway.c.
Intel took over Lantiq some years ago and last year MaxLinear then took over what was formerly Lantiq from Intel.

From what I can tell right away: the interrupt handling still seems
to be the same. Also the GPHY firmware version register also was there on older SoCs (with two or more GPHYs embedded into the SoC). SGMII support is new. And I am not sure about Wake-on-LAN.

Quoted 7 lines

Have you considered adding support for these new PHYs to intel-xway.c?

Best regards,
Martin

I'm thinking to separate them.

They are based on different IP and have many differences.

The XWAY PHYs are going to EoL (or maybe already EoL).

It creates difficulty for the test coverage to put together.

author maintainer
#4 lore raw
In reply to Andrew Lunn
Quoted 40 lines · Andrew Lunn

This email was sent from outside of MaxLinear.

Quoted 37 lines
Quoted 26 lines
Quoted 26 lines
drivers/net/phy/mxl-gpy.c new file +26 -0
+static int gpy_read_abilities(struct phy_device *phydev)
+{
+ int ret;
+
+ ret = genphy_read_abilities(phydev);
+ if (ret < 0)
+ return ret;
+
+ /* Detect 2.5G/5G support. */
+ ret = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_STAT2);
+ if (ret < 0)
+ return ret;
+ if (!(ret & MDIO_PMA_STAT2_EXTABLE))
+ return 0;
+
+ ret = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PMA_EXTABLE);
+ if (ret < 0)
+ return ret;
+ if (!(ret & MDIO_PMA_EXTABLE_NBT))
+ return 0;
+
+ ret = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PMA_NG_EXTABLE);
+ if (ret < 0)
+ return ret;
+
+ linkmode_mod_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT,
Quoted 9 lines
Quoted 6 lines

+ phydev->supported,
+ ret & MDIO_PMA_NG_EXTABLE_2_5GBT);
+
+ linkmode_mod_bit(ETHTOOL_LINK_MODE_5000baseT_Full_BIT,
+ phydev->supported,
+ ret & MDIO_PMA_NG_EXTABLE_5GBT);

This does not access vendor specific registers, should not this be part of the standard genphy_read_abilities() or moved to a helper?

genphy_read_abilities does not cover 2.5G.

Quoted 8 lines
Quoted 2 lines

genphy_c45_pma_read_abilities checks C45 ids and this check fail if is_c45 is not set.

You appear to of ignored my comment about this. Please add the helper to the core as i suggested, and then use genphy_c45_pma_read_abilities().

Andrew

I'm new to upstream and do not know the process to change code in core.

Should I add the support function in same patch?

maintainer
#5 lore raw
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines

This does not access vendor specific registers, should not this be part of the standard genphy_read_abilities() or moved to a helper?

genphy_read_abilities does not cover 2.5G.

genphy_c45_pma_read_abilities checks C45 ids and this check fail if is_c45 is not set.

Quoted 7 lines
Quoted 6 lines

You appear to of ignored my comment about this. Please add the helper to the core as i suggested, and then use genphy_c45_pma_read_abilities().

Andrew

I'm new to upstream and do not know the process to change code in core.

Pretty much the same way you change code in a driver. Submit a path!

Please put it into a separate patch, so making a patch series. Please add some kernel doc style documentation, describing what the function does. Look at other functions in phy_device.c for examples.

Anybody can change core code. It just gets looked at closer, and need to be generic.

Andrew

maintainer
#17 lore raw
In reply to Liang Xu
Quoted 13 lines · Liang Xu
Quoted 12 lines · Martin Blumenstingl

This email was sent from outside of MaxLinear.

Hello,

Quoted 2 lines

Add driver to support the Maxlinear GPY115, GPY211, GPY212, GPY215, GPY241, GPY245 PHYs.

to me this seems like an evolution of the Lantiq XWAY PHYs for which we already have a driver: intel-xway.c.
Intel took over Lantiq some years ago and last year MaxLinear then took over what was formerly Lantiq from Intel.

Quoted 6 lines
Quoted 6 lines

From what I can tell right away: the interrupt handling still seems
to be the same. Also the GPHY firmware version register also was there on older SoCs (with two or more GPHYs embedded into the SoC). SGMII support is new. And I am not sure about Wake-on-LAN.

Have you considered adding support for these new PHYs to intel-xway.c?

The WOL interrupts are the same, which could imply WoL configuration is the same? If it is the same, it would be good to also add WoL to intel-xway.c.

What this new driver does not yet do is LEDs. It would be interesting to see if the LED control is the same. Hopefully, one day, generic LED support will get added. If this PHY and intel-xway.c has the same LED code, we will want to share it.

Quoted 1 line

They are based on different IP and have many differences.

Please could you list the differences? Is the datasheet available? I found a datasheet for the XWAY, so it would be nice to be able to compare them.

Quoted 1 line

The XWAY PHYs are going to EoL (or maybe already EoL).

That does not matter. They are going to be in use for the next 5 years or more, until all the products using them have died or been replaced. Linux supports hardware that is in use, not just what vendors sell today.

Quoted 1 line

It creates difficulty for the test coverage to put together.

That also does not really matter. If somebody has both, does the work to merge the drivers and overall we have less code and more features, the patch will be accepted.

Andrew

author maintainer
#6 lore raw
In reply to Andrew Lunn
Quoted 19 lines · Andrew Lunn

This email was sent from outside of MaxLinear.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines

This does not access vendor specific registers, should not this be part of the standard genphy_read_abilities() or moved to a helper?

genphy_read_abilities does not cover 2.5G.

genphy_c45_pma_read_abilities checks C45 ids and this check fail if is_c45 is not set.

Quoted 7 lines
Quoted 6 lines

You appear to of ignored my comment about this. Please add the helper to the core as i suggested, and then use genphy_c45_pma_read_abilities().

Andrew

I'm new to upstream and do not know the process to change code in core.

Pretty much the same way you change code in a driver. Submit a path!

Quoted 9 lines

Please put it into a separate patch, so making a patch series. Please add some kernel doc style documentation, describing what the function does. Look at other functions in phy_device.c for examples.

Anybody can change core code. It just gets looked at closer, and need to be generic.

Andrew

Thank you. I will create 2 patches for the core modification and driver separately

in next update.

author maintainer
#18 lore raw
In reply to Andrew Lunn
Quoted 43 lines · Andrew Lunn

This email was sent from outside of MaxLinear.

Quoted 13 lines · Liang Xu
Quoted 12 lines · Martin Blumenstingl

This email was sent from outside of MaxLinear.

Hello,

Quoted 2 lines

Add driver to support the Maxlinear GPY115, GPY211, GPY212, GPY215, GPY241, GPY245 PHYs.

to me this seems like an evolution of the Lantiq XWAY PHYs for which we already have a driver: intel-xway.c.
Intel took over Lantiq some years ago and last year MaxLinear then took over what was formerly Lantiq from Intel.

Quoted 6 lines
Quoted 6 lines

From what I can tell right away: the interrupt handling still seems
to be the same. Also the GPHY firmware version register also was there on older SoCs (with two or more GPHYs embedded into the SoC). SGMII support is new. And I am not sure about Wake-on-LAN.

Have you considered adding support for these new PHYs to intel-xway.c?

The WOL interrupts are the same, which could imply WoL configuration is the same? If it is the same, it would be good to also add WoL to intel-xway.c.

What this new driver does not yet do is LEDs. It would be interesting to see if the LED control is the same. Hopefully, one day, generic LED support will get added. If this PHY and intel-xway.c has the same LED code, we will want to share it.

Quoted 1 line

They are based on different IP and have many differences.

Please could you list the differences? Is the datasheet available? I found a datasheet for the XWAY, so it would be nice to be able to compare them.

Quoted 1 line

The XWAY PHYs are going to EoL (or maybe already EoL).

That does not matter. They are going to be in use for the next 5 years or more, until all the products using them have died or been replaced. Linux supports hardware that is in use, not just what vendors sell today.

Quoted 9 lines
Quoted 1 line

It creates difficulty for the test coverage to put together.

That also does not really matter. If somebody has both, does the work to merge the drivers and overall we have less code and more features, the patch will be accepted.

Andrew

The datasheet of GPY2xx are only available under NDA currently, since we have

to protect our IP for the new devices.

I do not know much about XWAY feature set, but I guess the difference should

be 2.5G support, C45 register set, PTP offload, MACsec offload, etc.

Problem of merging the both drivers would be the verification of the old devices

for which I do not have a test environment. I can't deliver code without testing,

and it will be big problem for me if it breaks function of existing user/customer.

We will check for options and need approval from company, but this will not be

possible short term within this merge window.

For now, can I upstream this new driver first, and merge the old driver into new one later?

We will enhance the new driver step by step with different features, but currently

we would like to make the first version available and working for our customers.

Thanks & Regards,

Xu Liang

#19 lore raw

On Mon, Jun 7, 2021 at 6:37 AM Liang Xu <[email protected]> wrote:
[...]

Quoted 6 lines
Quoted 6 lines
Quoted 1 line

It creates difficulty for the test coverage to put together.

That also does not really matter. If somebody has both, does the work to merge the drivers and overall we have less code and more features, the patch will be accepted.

Quoted 7 lines
Quoted 3 lines

Andrew

The datasheet of GPY2xx are only available under NDA currently, since we have

to protect our IP for the new devices.

I don't understand how knowledge about some registers can lead to IP being stolen by other vendors

Quoted 3 lines

I do not know much about XWAY feature set, but I guess the difference should

be 2.5G support, C45 register set, PTP offload, MACsec offload, etc.

I think [0] lists the functional differences - GPY115 and newer seem to differ from older PHYs in:
- xMII interface
- MACSEC
- IEEE-1588 v2 (PTP)
- Syn-E (not sure what this is)
- Thermal Sensor

Quoted 5 lines

Problem of merging the both drivers would be the verification of the old devices

for which I do not have a test environment. I can't deliver code without testing,

According to the GPY111 and GPY112 product pages the status is "Active" ("PARTS & PURCHASING" tab).
quote from the same tab:
"Active - the part is released for sale, standard product."

I believe that these are rebranded Lantiq PHYs:
GPY111 and GPY112 are using PHYID register values which are compatible with the intel-xway driver.
So I think you can use these PHYs for testing

Also people from the OpenWrt community (for example: me, possible also Aleksander and Hauke) can help testing on existing hardware

[...]

Quoted 4 lines

We will check for options and need approval from company, but this will not be

possible short term within this merge window.

I hope that it is possible with GPY111 and/or GPY112 as mentioned above

Quoted 2 lines

For now, can I upstream this new driver first, and merge the old driver into new one later?

My answer to this question depends on the actual differences between the "old" and "new" PHYs.
For example: if WoL and LED configuration are (mostly) identical then personally I vote for having one driver from the beginning

Best regards,
Martin

[0] https://www.maxlinear.com/products/connectivity/wired/ethernet/ethernet-transceivers-phy
[1] https://www.maxlinear.com/product/connectivity/wired/ethernet/ethernet-transceivers-phy/gpy111

author maintainer
#7 lore raw
In reply to Liang Xu
Quoted 27 lines · Liang Xu
Quoted 26 lines · Andrew Lunn

This email was sent from outside of MaxLinear.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines

This does not access vendor specific registers, should not this be part of the standard genphy_read_abilities() or moved to a helper?

genphy_read_abilities does not cover 2.5G.

genphy_c45_pma_read_abilities checks C45 ids and this check fail if is_c45 is not set.

Quoted 7 lines
Quoted 6 lines

You appear to of ignored my comment about this. Please add the helper to the core as i suggested, and then use genphy_c45_pma_read_abilities().

Andrew

I'm new to upstream and do not know the process to change code in core.

Pretty much the same way you change code in a driver. Submit a path!

Please put it into a separate patch, so making a patch series. Please add some kernel doc style documentation, describing what the function does. Look at other functions in phy_device.c for examples.

Anybody can change core code. It just gets looked at closer, and need to be generic.

Quoted 7 lines
Quoted 2 lines

Andrew

Thank you. I will create 2 patches for the core modification and driver separately

in next update.

Hi Andrew,

I need your advice regarding to our recent test in loopback.

My current implementation uses "genphy_loopback" to enable/disable loopback mode.

And it has intermittent issue (traffic not loopbacked) during the test with net-next.

There are difference in the implementation in net-next and Linux v5.12.

Net-next:

int genphy_loopback(struct phy_device *phydev, bool enable) {
    if (enable) {
        u16 val, ctl = BMCR_LOOPBACK;
        int ret;

        if (phydev->speed == SPEED_1000)
            ctl |= BMCR_SPEED1000;
        else if (phydev->speed == SPEED_100)
            ctl |= BMCR_SPEED100;

        if (phydev->duplex == DUPLEX_FULL)
            ctl |= BMCR_FULLDPLX;

        phy_modify(phydev, MII_BMCR, ~0, ctl);

        ret = phy_read_poll_timeout(phydev, MII_BMSR, val, val & BMSR_LSTATUS,
                    5000, 500000, true);
        if (ret)
            return ret;
    } else {
        phy_modify(phydev, MII_BMCR, BMCR_LOOPBACK, 0);

        phy_config_aneg(phydev);
    }

    return 0;
}

v5.12.11:

int genphy_loopback(struct phy_device *phydev, bool enable) {
    return phy_modify(phydev, MII_BMCR, BMCR_LOOPBACK, enable ? BMCR_LOOPBACK : 0);
}

Not sure whether anyone else reported similar issue.

Should I use phy_modify to set the LOOPBACK bit only in my driver implementation as force speed with loopback enable does not work in our device?

Thanks & Regards,

Xu Liang

maintainer
#8 lore raw
Quoted 34 lines

Net-next:

int genphy_loopback(struct phy_device *phydev, bool enable) {
    if (enable) {
        u16 val, ctl = BMCR_LOOPBACK;
        int ret;

        if (phydev->speed == SPEED_1000)
            ctl |= BMCR_SPEED1000;
        else if (phydev->speed == SPEED_100)
            ctl |= BMCR_SPEED100;

        if (phydev->duplex == DUPLEX_FULL)
            ctl |= BMCR_FULLDPLX;

        phy_modify(phydev, MII_BMCR, ~0, ctl);

        ret = phy_read_poll_timeout(phydev, MII_BMSR, val, val & BMSR_LSTATUS,
                    5000, 500000, true);
        if (ret)
            return ret;
    } else {
        phy_modify(phydev, MII_BMCR, BMCR_LOOPBACK, 0);

        phy_config_aneg(phydev);
    }

    return 0;
}

v5.12.11:

Quoted 8 lines

int genphy_loopback(struct phy_device *phydev, bool enable) {
    return phy_modify(phydev, MII_BMCR, BMCR_LOOPBACK, enable ? BMCR_LOOPBACK : 0);
}

Not sure whether anyone else reported similar issue.

The commit message says:

net: phy: genphy_loopback: add link speed configuration

In case of loopback, in most cases we need to disable autoneg support and force some speed configuration. Otherwise, depending on currently active auto negotiated link speed, the loopback may or may not work.

Quoted 3 lines

Should I use phy_modify to set the LOOPBACK bit only in my driver implementation as force speed with loopback enable does not work in our device?

So you appear to have the exact opposite problem, you need to use auto-neg, with yourself, in order to have link. So there are two solutions:

1) As you say, implement it in your driver

2) Add a second generic implementation, which enables autoneg, if it is not enabled, sets the loopback bit, and waits for the link to come up.

Does your PHY driver error out when asked to do a forced mode? It probably should, if your silicon does not support that part of C22.

Andrew

author maintainer
#9 lore raw
Quoted 62 lines · Andrew Lunn

This email was sent from outside of MaxLinear.

Quoted 34 lines

Net-next:

int genphy_loopback(struct phy_device *phydev, bool enable)

{
      if (enable) {
          u16 val, ctl = BMCR_LOOPBACK;
          int ret;

          if (phydev->speed == SPEED_1000)
              ctl |= BMCR_SPEED1000;
          else if (phydev->speed == SPEED_100)
              ctl |= BMCR_SPEED100;

          if (phydev->duplex == DUPLEX_FULL)
              ctl |= BMCR_FULLDPLX;

          phy_modify(phydev, MII_BMCR, ~0, ctl);

          ret = phy_read_poll_timeout(phydev, MII_BMSR, val,
                          val & BMSR_LSTATUS,
                      5000, 500000, true);
          if (ret)
              return ret;
      } else {
          phy_modify(phydev, MII_BMCR, BMCR_LOOPBACK, 0);

          phy_config_aneg(phydev);
      }

      return 0;
}

v5.12.11:

Quoted 8 lines

int genphy_loopback(struct phy_device *phydev, bool enable) {
return phy_modify(phydev, MII_BMCR, BMCR_LOOPBACK,
enable ? BMCR_LOOPBACK : 0);
}

Not sure whether anyone else reported similar issue.

The commit message says:

net: phy: genphy_loopback: add link speed configuration

In case of loopback, in most cases we need to disable autoneg support and force some speed configuration. Otherwise, depending on currently active auto negotiated link speed, the loopback may or may not work.

Quoted 3 lines

Should I use phy_modify to set the LOOPBACK bit only in my driver implementation as force speed with loopback enable does not work in our device?

So you appear to have the exact opposite problem, you need to use auto-neg, with yourself, in order to have link. So there are two solutions:

1) As you say, implement it in your driver

Quoted 9 lines

2) Add a second generic implementation, which enables autoneg, if it is not enabled, sets the loopback bit, and waits for the link to come up.

Does your PHY driver error out when asked to do a forced mode? It probably should, if your silicon does not support that part of C22.

Andrew

Thank you for prompt reply.

The forced mode is successful because we support forced mode in C22.

The problem happens in the speed change no matter it's forced or auto-neg in our device.

If I keep current status and just set the loopback bit, it works.

This may be specific to our device, if nobody else report issue in the genphy_loopback implementation in net-next.

Then I will implement it in my driver.

Thanks & Regards,

Xu Liang

maintainer
#10 lore raw
Quoted 12 lines · Liang Xu
Quoted 11 lines · Andrew Lunn

This email was sent from outside of MaxLinear.

Quoted 8 lines

Net-next:

int genphy_loopback(struct phy_device *phydev, bool enable)

{
      if (enable) {
          u16 val, ctl = BMCR_LOOPBACK;
          int ret;
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
          if (phydev->speed == SPEED_1000)
              ctl |= BMCR_SPEED1000;
          else if (phydev->speed == SPEED_100)
              ctl |= BMCR_SPEED100;

The problem happens in the speed change no matter it's forced or auto-neg in our device.

You say speed change. So do you just need to add support for 10Mbps, so there is no speed change? Or are you saying phydev->speed does not match the actual speed?

Andrew

author maintainer
#11 lore raw
Quoted 20 lines · Andrew Lunn

This email was sent from outside of MaxLinear.

Quoted 16 lines · Liang Xu
Quoted 15 lines · Andrew Lunn

This email was sent from outside of MaxLinear.

Quoted 12 lines

Net-next:

int genphy_loopback(struct phy_device *phydev, bool enable)

{
       if (enable) {
           u16 val, ctl = BMCR_LOOPBACK;
           int ret;

           if (phydev->speed == SPEED_1000)
               ctl |= BMCR_SPEED1000;
           else if (phydev->speed == SPEED_100)
               ctl |= BMCR_SPEED100;
Quoted 8 lines
Quoted 2 lines

The problem happens in the speed change no matter it's forced or auto-neg in our device.

You say speed change. So do you just need to add support for 10Mbps, so there is no speed change? Or are you saying phydev->speed does not match the actual speed?

Andrew

We have 2.5G link speed, so mismatch happens.

Thanks & Regards,

Xu Liang

maintainer
#12 lore raw
Quoted 23 lines · Liang Xu
Quoted 22 lines · Andrew Lunn

This email was sent from outside of MaxLinear.

Quoted 18 lines · Liang Xu
Quoted 15 lines · Andrew Lunn

This email was sent from outside of MaxLinear.

Quoted 12 lines

Net-next:

int genphy_loopback(struct phy_device *phydev, bool enable)

{
       if (enable) {
           u16 val, ctl = BMCR_LOOPBACK;
           int ret;

           if (phydev->speed == SPEED_1000)
               ctl |= BMCR_SPEED1000;
           else if (phydev->speed == SPEED_100)
               ctl |= BMCR_SPEED100;

The problem happens in the speed change no matter it's forced or auto-neg in our device.

Quoted 7 lines
Quoted 6 lines

You say speed change. So do you just need to add support for 10Mbps, so there is no speed change? Or are you saying phydev->speed does not match the actual speed?

Andrew

We have 2.5G link speed, so mismatch happens.

Ah, yes. Sorry.

Please implement it in your driver.

Andrew

author maintainer
#13 lore raw
Quoted 31 lines · Andrew Lunn

This email was sent from outside of MaxLinear.

Quoted 27 lines · Liang Xu
Quoted 26 lines · Andrew Lunn

This email was sent from outside of MaxLinear.

Quoted 12 lines · Liang Xu
Quoted 11 lines · Andrew Lunn

This email was sent from outside of MaxLinear.

Quoted 8 lines

Net-next:

int genphy_loopback(struct phy_device *phydev, bool enable)

{
        if (enable) {
            u16 val, ctl = BMCR_LOOPBACK;
            int ret;
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
            if (phydev->speed == SPEED_1000)
                ctl |= BMCR_SPEED1000;
            else if (phydev->speed == SPEED_100)
                ctl |= BMCR_SPEED100;

The problem happens in the speed change no matter it's forced or auto-neg in our device.

You say speed change. So do you just need to add support for 10Mbps, so there is no speed change? Or are you saying phydev->speed does not match the actual speed?

Quoted 9 lines
Quoted 3 lines
Quoted 2 lines

Andrew

We have 2.5G link speed, so mismatch happens.

Ah, yes. Sorry.

Please implement it in your driver.

Andrew

Sure. Thank you for advice.

Regards,

Xu Liang

#22 lore raw
In reply to a message not in the archive

Hi Liang,

On Wed, Jun 23, 2021 at 12:56 PM Liang Xu <[email protected]> wrote:
[...]

Quoted 4 lines

Hi Martin,

1) The legacy PHY GPY111 does not share the same register format and address for WoL and LED registers. Therefore code saving with a common driver is not possible.
2) The interrupt handling routine would be different when new features are added in driver, such as PTP offload, MACsec offload. These will be added step by step as enhancement patches afte initial version of this driver upstreamed.

I think that would leave only few shared registers with the older PHYs (and thus the intel-xway driver). Due to the lack of a public datasheet however I have no way to confirm this.
So with this information added to the patch description having a different driver is fine for me

Maybe Andrew can also share his opinion - based on this new information - as he previously also suggested to extend the intel-xway driver instead of creating a new one

Quoted 2 lines

3) The new PHY generation comes with a reasonable pre-configuration for the LED registers which does not need any modification usually.
In case a customer needs a specific configuration (e.g. traffic pulsing only, no link status) he needs to configure this via MDIO. There is also another option for a fixed preconfiguration with the support of an external flash. However, this is out of scope of the driver.

older PHYs also do this, but not all boards use a reasonable LED setup

Quoted 1 line

4) Many old products are mostly used on embedded devices which do not support WoL. Therefore there was no request yet to supported by the legacy XWAY driver.

my understanding of Andrew's argument is: "if the register layout is the same for old and new PHY then why would we do some extra effort to not add WoL support for the old PHYs"
Based on your information above the register layout is different, so that means two different implementations are needed anyways.

Best regards,
Martin

maintainer
#23 lore raw
Quoted 14 lines · Martin Blumenstingl

Hi Liang,

On Wed, Jun 23, 2021 at 12:56 PM Liang Xu <[email protected]> wrote:
[...]

Quoted 4 lines

Hi Martin,

1) The legacy PHY GPY111 does not share the same register format and address for WoL and LED registers. Therefore code saving with a common driver is not possible.
2) The interrupt handling routine would be different when new features are added in driver, such as PTP offload, MACsec offload. These will be added step by step as enhancement patches afte initial version of this driver upstreamed.

I think that would leave only few shared registers with the older PHYs (and thus the intel-xway driver). Due to the lack of a public datasheet however I have no way to confirm this.
So with this information added to the patch description having a different driver is fine for me

Quoted 3 lines

Maybe Andrew can also share his opinion - based on this new information - as he previously also suggested to extend the intel-xway driver instead of creating a new one

If the potential sharing is minimal, then a new driver makes sense. So please do expand the patch description with a good justification.

Quoted 10 lines
Quoted 2 lines

3) The new PHY generation comes with a reasonable pre-configuration for the LED registers which does not need any modification usually.
In case a customer needs a specific configuration (e.g. traffic pulsing only, no link status) he needs to configure this via MDIO. There is also another option for a fixed preconfiguration with the support of an external flash. However, this is out of scope of the driver.

older PHYs also do this, but not all boards use a reasonable LED setup

Quoted 1 line

4) Many old products are mostly used on embedded devices which do not support WoL. Therefore there was no request yet to supported by the legacy XWAY driver.

my understanding of Andrew's argument is: "if the register layout is the same for old and new PHY then why would we do some extra effort to not add WoL support for the old PHYs"
Based on your information above the register layout is different, so that means two different implementations are needed anyways.

It would be nice to add WoL support for the older devices. They might not be maxlinears latest and greatest, but there could be more of them actually in use at the moment than this new PHY.

Andrew