net: ibm: emac: fix fixed-link speed and duplex
Subsystems (2)
PATCH 1/1 net: ibm: emac: fix fixed-link speed and duplex
Since commit d99b408ed8e5 ("net: phy: fixed_phy: remove not needed initialization of phy_device members"), fixed_phy_register() no longer copies the fixed-link state into the new phy_device, phylib fills it in once the PHY state machine runs.
EMAC never attaches or starts the fixed PHY. emac_init_phy() copies phydev->speed and phydev->duplex right after registering it, so it now gets SPEED_UNKNOWN and DUPLEX_UNKNOWN and emac_configure() programs the MAC and RGMII bridge for 10 Mbps half duplex.
On the Meraki MX60, whose EMAC has a 1000 Mbps RGMII fixed-link to a QCA8327 switch, every transmitted frame reports carrier loss, the switch CPU port counts FCS errors and nothing is received.
Take the fixed-link parameters from the device tree, in both the "fixed-link" subnode and the legacy property form.
--- drivers/net/ethernet/ibm/emac/core.c | 36 +++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-)
drivers/net/ethernet/ibm/emac/core.c +35 -1
@@ -2696,6 +2696,40 @@ static int emac_dt_phy_probe(struct emac_instance *dev)return res; } +/* The fixed PHY is never started, so phylib never fills in its link state. +* Take the link parameters straight from the device tree. +*/ +static void emac_fixed_link_state (struct emac_instance *dev, +struct device_node *np) +{ +struct device_node *fixed_link; +u32 prop[5 ]; + + dev->phy.autoneg =AUTONEG_DISABLE ; + dev->phy.advertising =0 ; + + fixed_link =of_get_child_by_name (np,"fixed-link" ); +if (fixed_link) { +u32 speed =SPEED_UNKNOWN ; + +of_property_read_u32 (fixed_link,"speed" , &speed); + dev->phy.speed = speed; + dev->phy.duplex =of_property_read_bool (fixed_link,"full-duplex" ) ? +DUPLEX_FULL :DUPLEX_HALF ; + dev->phy.pause =of_property_read_bool (fixed_link,"pause" ); + dev->phy.asym_pause =of_property_read_bool (fixed_link, +"asym-pause" ); +of_node_put (fixed_link); + }else if (!of_property_read_u32_array (np,"fixed-link" , prop, +ARRAY_SIZE (prop))) { +/* legacy <phy_id duplex speed pause asym_pause> */ + dev->phy.duplex = prop[1 ] ?DUPLEX_FULL :DUPLEX_HALF ; + dev->phy.speed = prop[2 ]; + dev->phy.pause = prop[3 ]; + dev->phy.asym_pause = prop[4 ]; + } +} +static int emac_init_phy (struct emac_instance *dev) {struct device_node *np = dev->ofdev->dev.of_node;
@@ -2730,7 +2764,7 @@ static int emac_init_phy(struct emac_instance *dev) ndev->phydev =of_phy_find_device (np);if (res || !ndev->phydev)return res ? res : -EINVAL ; -emac_adjust_link (dev->ndev); +emac_fixed_link_state (dev, np);put_device (&ndev->phydev->mdio.dev); }return 0 ;
Signature · 1 line
2.56.0
Quoted 1 line
EMAC never attaches or starts the fixed PHY.
Maybe this is the real problem?
A fixed-link is meant to look like a PHY, attach it to the MAC and start it like a real PHY. That makes the MAC code simpler, no special cases for a fixed-link.
Andrew