[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230914161226.563423jjeuywfe57@skbuf>
Date: Thu, 14 Sep 2023 19:12:26 +0300
From: Vladimir Oltean <olteanv@...il.com>
To: "Russell King (Oracle)" <linux@...linux.org.uk>
Cc: Arınç ÜNAL <arinc.unal@...nc9.com>,
Andrew Lunn <andrew@...n.ch>,
Florian Fainelli <f.fainelli@...il.com>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Rob Herring <robh+dt@...nel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
Conor Dooley <conor+dt@...nel.org>,
Woojung Huh <woojung.huh@...rochip.com>,
UNGLinuxDriver@...rochip.com,
Linus Walleij <linus.walleij@...aro.org>,
Alvin Šipraga <alsi@...g-olufsen.dk>,
Daniel Golle <daniel@...rotopia.org>,
Landen Chao <Landen.Chao@...iatek.com>,
DENG Qingfang <dqfext@...il.com>,
Sean Wang <sean.wang@...iatek.com>,
Matthias Brugger <matthias.bgg@...il.com>,
AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>,
mithat.guner@...ont.com, erkin.bozoglu@...ont.com,
netdev@...r.kernel.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-mediatek@...ts.infradead.org
Subject: Re: [PATCH 2/4] dt-bindings: net: dsa: document internal MDIO bus
On Wed, Sep 13, 2023 at 04:59:19PM +0100, Russell King (Oracle) wrote:
> However, phylink pretty much requires phy-mode to be specified to be
> something sane for shared ports, so I wouldn't be in favour of relaxing
> the checkinng in dsa_shared_port_validate_of()... not unless you're
> now going to accept the approach I originally proposed to have DSA
> drivers tell the core (and thus phylink) what phy-mode and other link
> parameters should be used when they are missing from DT.
Ok, so with a missing phy-mode on the CPU port, phylink_parse_fixedlink() ->
phy_lookup_setting() will return NULL and that will print a phylink_warn(),
but other than that, phylink_mac_link_up() does get called at the right
speed and duplex.
I agree that for sane behavior it should be specified, but it appears
that even with PHY_INTERFACE_MODE_NA something can be hacked up...
[ 4.818368] sja1105 spi0.1: Failed to read phy-mode or phy-interface-type property for port 4
[ 4.864667] sja1105 spi0.1: OF node /soc/spi@...0000/ethernet-switch@...orts/port@4 of CPU port 4 lacks the required "phy-mode" property
[ 4.882957] sja1105 spi0.1: pl->link_config.speed 1000 pl->link_config.duplex 1 pl->supported 00,00000000,00000000,00000240
[ 4.894189] sja1105 spi0.1: phy_setting speed -1 duplex -1 bit -1
[ 4.900283] sja1105 spi0.1: fixed link full duplex 1000Mbps not recognised
[ 4.907798] sja1105 spi0.1: configuring for fixed/ link mode
[ 4.916183] sja1105 spi0.1 swp5 (uninitialized): PHY [mdio@...4000:06] driver [Broadcom BCM5464] (irq=POLL)
[ 4.934770] sja1105 spi0.1 swp2 (uninitialized): PHY [mdio@...4000:03] driver [Broadcom BCM5464] (irq=POLL)
[ 4.951619] sja1105 spi0.1 swp3 (uninitialized): PHY [mdio@...4000:04] driver [Broadcom BCM5464] (irq=POLL)
[ 4.968349] sja1105 spi0.1 swp4 (uninitialized): PHY [mdio@...4000:05] driver [Broadcom BCM5464] (irq=POLL)
[ 4.984017] fsl-gianfar soc:ethernet@...0000 eth2: entered promiscuous mode
[ 4.991327] DSA: tree 0 setup
[ 4.995129] sja1105 spi0.1: sja1105_mac_link_up: port 4 interface speed 1000 duplex 1
[ 5.005004] sja1105 spi0.1: Link is Up - 1Gbps/Full - flow control off
diff --git a/arch/arm/boot/dts/nxp/ls/ls1021a-tsn.dts b/arch/arm/boot/dts/nxp/ls/ls1021a-tsn.dts
index 1ea32fff4120..0bfffcb51af9 100644
--- a/arch/arm/boot/dts/nxp/ls/ls1021a-tsn.dts
+++ b/arch/arm/boot/dts/nxp/ls/ls1021a-tsn.dts
@@ -90,7 +90,7 @@ port@3 {
port@4 {
/* Internal port connected to eth2 */
ethernet = <&enet2>;
- phy-mode = "rgmii";
+// phy-mode = "rgmii";
rx-internal-delay-ps = <0>;
tx-internal-delay-ps = <0>;
reg = <4>;
diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c
index a23d980d28f5..dba1fa545a9c 100644
--- a/drivers/net/dsa/sja1105/sja1105_main.c
+++ b/drivers/net/dsa/sja1105/sja1105_main.c
@@ -327,6 +327,8 @@ static int sja1105_init_mii_settings(struct sja1105_private *priv)
mii->xmii_mode[i] = XMII_MODE_SGMII;
mii->special[i] = true;
break;
+ case PHY_INTERFACE_MODE_NA:
+ break;
unsupported:
default:
dev_err(dev, "Unsupported PHY mode %s on port %d!\n",
@@ -1205,11 +1207,10 @@ static int sja1105_parse_ports_node(struct sja1105_private *priv,
/* Get PHY mode from DT */
err = of_get_phy_mode(child, &phy_mode);
if (err) {
- dev_err(dev, "Failed to read phy-mode or "
+ dev_warn(dev, "Failed to read phy-mode or "
"phy-interface-type property for port %d\n",
index);
- of_node_put(child);
- return -ENODEV;
+ phy_mode = PHY_INTERFACE_MODE_NA;
}
phy_node = of_parse_phandle(child, "phy-handle", 0);
@@ -1383,6 +1384,8 @@ static void sja1105_mac_link_up(struct dsa_switch *ds, int port,
{
struct sja1105_private *priv = ds->priv;
+ dev_err(ds->dev, "%s: port %d interface %s speed %d duplex %d\n", __func__, port, phy_modes(interface), speed, duplex);
+
sja1105_adjust_port_config(priv, port, speed);
sja1105_inhibit_tx(priv, BIT(port), false);
@@ -1414,7 +1417,10 @@ static void sja1105_phylink_get_caps(struct dsa_switch *ds, int port,
* config (the xMII Mode table cannot be dynamically
* reconfigured), and we have to program that early.
*/
- __set_bit(phy_mode, config->supported_interfaces);
+ if (phy_mode == PHY_INTERFACE_MODE_NA)
+ phy_interface_set_rgmii(config->supported_interfaces);
+ else
+ __set_bit(phy_mode, config->supported_interfaces);
}
/* The MAC does not support pause frames, and also doesn't
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index 0d7354955d62..674689011059 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -841,6 +841,15 @@ static int phylink_parse_fixedlink(struct phylink *pl,
if (autoneg)
phylink_set(pl->supported, Autoneg);
+ phylink_err(pl, "pl->link_config.speed %d pl->link_config.duplex %d pl->supported %*pb\n",
+ pl->link_config.speed, pl->link_config.duplex, __ETHTOOL_LINK_MODE_MASK_NBITS,
+ pl->supported);
+
+ phylink_err(pl, "phy_setting speed %d duplex %d bit %d\n",
+ s ? s->speed : -1,
+ s ? s->duplex : -1,
+ s ? s->bit : -1);
+
if (s) {
__set_bit(s->bit, pl->supported);
__set_bit(s->bit, pl->link_config.lp_advertising);
diff --git a/net/dsa/port.c b/net/dsa/port.c
index 5f01bd4f9dec..34e5dc48f0ff 100644
--- a/net/dsa/port.c
+++ b/net/dsa/port.c
@@ -1927,6 +1927,16 @@ static const char * const dsa_switches_apply_workarounds[] = {
#if IS_ENABLED(CONFIG_NET_DSA_SMSC_LAN9303_I2C)
"smsc,lan9303-i2c",
#endif
+ "nxp,sja1105e",
+ "nxp,sja1105t",
+ "nxp,sja1105p",
+ "nxp,sja1105q",
+ "nxp,sja1105r",
+ "nxp,sja1105s",
+ "nxp,sja1110a",
+ "nxp,sja1110b",
+ "nxp,sja1110c",
+ "nxp,sja1110d",
NULL,
};
Powered by blists - more mailing lists