Skip to contentSkip to conversation

net: phy: Add driver for Motorcomm yt8521 gigabit ethernet

PATCH Superseded Frank 3 participants 3 messages Jul 11, 2022 – Jul 12, 2022

Subsystems (4)

v3 of 8 Superseded Latest is v8 →

lore
Share & tools
lore

Frank

author maintainer
#0 lore raw

PATCH v3 1/1 net: phy: Add driver for Motorcomm yt8521 gigabit ethernet

patch v3:
Hi Andrew
Thanks and based on your comments we modified the patch as below.

Quoted 5 lines

It is generally not that simple. Fibre, you probably want 1000BaseX, unless the fibre module is actually copper, and then you want SGMII. So you need something to talk to the fibre module and ask it what it is. That something is phylink. Phylink does not support both copper and fibre at the same time for one MAC.

yes, you said it and for MAC, it does not support copper and Fiber at same time. but from Physical Layer, you know, sometimes both Copper and Fiber cables are connected. in this case, Phy driver should do arbitration and report to MAC which media should be used and Link-up.
This is the reason that the driver has a "polling mode", and by default, also this driver takes fiber as first priority which matches phy chip default behavior.

patch v2:
Hi Andrew, Russell King, Peter,
Thanks and based on your comments we modified the patch as below.

Quoted 2 lines

So there's only two possible pages that can be used in the extended register space?

Yes,there is only two register space (utp and fiber).

Quoted 5 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+/* Extended Register's Data Register */
+#define YTPHY_PAGE_DATA                                0x1F

These are defined exactly the same way as below. Please reuse code where possible.

Yes, code will be reuse, but "YT8511_PAGE" need to be rename like "YTPHY_PAGE_DATA",as it is common register for yt phys.

patch v1:
Add a driver for the motorcomm yt8521 gigabit ethernet phy. We have verified the driver on StarFive VisionFive development board, which is developed by Shanghai StarFive Technology Co., Ltd.. On the board, yt8521 gigabit ethernet phy works in utp mode, RGMII interface, supports 1000M/100M/10M speeds, and wol(magic package).

---
 MAINTAINERS                 |   1 +
 drivers/net/phy/Kconfig     |   2 +-
 drivers/net/phy/motorcomm.c | 987 +++++++++++++++++++++++++++++++++++-
 3 files changed, 987 insertions(+), 3 deletions(-)
MAINTAINERS +1 -0
index a6d3bd9..59813c5 100644
@@ -13437,6 +13437,7 @@ F:	include/uapi/linux/meye.h
 
 MOTORCOMM PHY DRIVER
 M:	Peter Geis <[email protected]>
+M:	Frank <[email protected]>
 L:	[email protected]
 S:	Maintained
 F:	drivers/net/phy/motorcomm.c
drivers/net/phy/Kconfig +1 -1
index 9fee639..9061c76 100644
@@ -253,7 +253,7 @@ config MOTORCOMM_PHY
 	tristate "Motorcomm PHYs"
 	help
 	  Enables support for Motorcomm network PHYs.
-	  Currently supports the YT8511 gigabit PHY.
+	  Currently supports the YT8511, YT8521 Gigabit Ethernet PHYs.
 
 config NATIONAL_PHY
 	tristate "National Semiconductor PHYs"
drivers/net/phy/motorcomm.c +985 -2

1,028 lines not on this page · raw message

Signature · 1 line
2.31.0.windows.1
maintainer
#1 lore raw
Quoted 1 line · On Mon, 11 Jul 2022 18:37:06 +0800 Frank wrote:

Subject: [PATCH v3] net: phy: Add driver for Motorcomm yt8521 gigabit ethernet

Still does not build cleanly with W=1 C=1.

Please install sparse -
https://www.kernel.org/doc/html/latest/dev-tools/sparse.html

And build with W=1 C=1.

You can use make drivers/net/phy/motorcomm.o to rebuild just your module, otherwise the output will get noisy.

maintainer
#2 lore raw
In reply to Frank
Quoted 10 lines · Frank

patch v3:
Hi Andrew
Thanks and based on your comments we modified the patch as below.

Quoted 5 lines

It is generally not that simple. Fibre, you probably want 1000BaseX, unless the fibre module is actually copper, and then you want SGMII. So you need something to talk to the fibre module and ask it what it is. That something is phylink. Phylink does not support both copper and fibre at the same time for one MAC.

Quoted 6 lines

yes, you said it and for MAC, it does not support copper and Fiber at same time. but from Physical Layer, you know, sometimes both Copper and Fiber cables are connected. in this case, Phy driver should do arbitration and report to MAC which media should be used and Link-up.
This is the reason that the driver has a "polling mode", and by default, also this driver takes fiber as first priority which matches phy chip default behavior.

The Marvell 10G driver is another PHY which can be used for both Copper and Fibre. In order to do this, it has a few extra functions:

static int mv3310_sfp_insert(void *upstream, const struct sfp_eeprom_id *id)

{
        struct phy_device *phydev = upstream;
        __ETHTOOL_DECLARE_LINK_MODE_MASK(support) = { 0, };
        phy_interface_t iface;

        sfp_parse_support(phydev->sfp_bus, id, support);
        iface = sfp_select_interface(phydev->sfp_bus, support);

        if (iface != PHY_INTERFACE_MODE_10GBASER) {
                dev_err(&phydev->mdio.dev, "incompatible SFP module inserted\n");
                return -EINVAL;
        }
        return 0;
}

static const struct sfp_upstream_ops mv3310_sfp_ops = {
.attach = phy_sfp_attach,
.detach = phy_sfp_detach, .module_insert = mv3310_sfp_insert,
};

Also see the at803x driver.

This allows the PHY to report to phylink what it is doing, and to determine the host side interface mode. I would expect this driver to implement sfp_upstream_ops as well.

Andrew