mt7530: register OF node for internal MDIO bus
Subsystems (7)
PATCH 1/2 mt7530: register OF node for internal MDIO bus
The MT753x switches provide a switch-internal MDIO bus for the embedded PHYs.
Register a OF sub-node on the switch OF-node for this internal MDIO bus. This allows to configure the embedded PHYs using device-tree.
--- drivers/net/dsa/mt7530.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/net/dsa/mt7530.c +6 -1
@@ -2119,10 +2119,13 @@ mt7530_setup_mdio(struct mt7530_priv *priv) {struct dsa_switch *ds = priv->ds;struct device *dev = priv->dev; +struct device_node *np, *mnp;struct mii_bus *bus;static int idx;int ret; + np = priv->dev->of_node; + bus =devm_mdiobus_alloc (dev);if (!bus)return -ENOMEM ;
@@ -2141,7 +2144,9 @@ mt7530_setup_mdio(struct mt7530_priv *priv)if (priv->irq)mt7530_setup_mdio_irq (priv); - ret =devm_mdiobus_register (dev, bus); + mnp =of_get_child_by_name (np,"mdio" ); + ret =devm_of_mdiobus_register (dev, bus, mnp); +of_node_put (mnp);if (ret) {dev_err (dev,"failed to register MDIO bus: %d\n" , ret);if (priv->irq)
Signature · 1 line
2.39.2
PATCH 2/2 dt-bindings: net: dsa: mediatek,mt7530: document MDIO-bus
Document the ability to add nodes for the MDIO bus connecting the switch-internal PHYs.
--- .../devicetree/bindings/net/dsa/mediatek,mt7530.yaml | 6 ++++++ 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml +6 -0
@@ -128,6 +128,12 @@ properties: See Documentation/devicetree/bindings/regulator/mt6323-regulator.txt for details for the regulator setup on these boards. + mdio: + $ref: /schemas/net/mdio.yaml# + unevaluatedProperties: false + description: + Node for the internal MDIO bus connected to the embedded ethernet-PHYs. + mediatek,mcm: type: boolean description:
Signature · 1 line
2.39.2
Re: [PATCH 2/2] dt-bindings: net: dsa: mediatek,mt7530: document MDIO-bus
Quoted 2 lines · David Bauer
Document the ability to add nodes for the MDIO bus connecting the switch-internal PHYs.
This is quite interesting. Currently the PHY muxing feature for the MT7530 switch looks for some fake ethernet-phy definitions on the mdio-bus where the switch is also defined.
Looking at the binding here, there will be an mdio node under the switch node. This could be useful to define the ethernet-phys for PHY muxing here instead, so we don't waste the register addresses on the parent mdio-bus for fake things. It looks like this should work right out of the box. I will do some tests.
Are there any examples as to what to configure on the switch PHYs with this change?
Quoted 11 lines
Signed-off-by David Bauer <[email protected]>--- .../devicetree/bindings/net/dsa/mediatek,mt7530.yaml | 6 ++++++ 1 file changed, 6 insertions(+)Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml +0
-0
Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml properties: · line 135
Quoted 8 lines
Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml +5
-0@@ -128,6 +128,12 @@ properties: See Documentation/devicetree/bindings/regulator/mt6323-regulator.txt for details for the regulator setup on these boards. + mdio: + $ref: /schemas/net/mdio.yaml# + unevaluatedProperties: false + description: + Node for the internal MDIO bus connected to the embedded ethernet-PHYs.
Please set this property as false for mediatek,mt7988-switch as it doesn't use MDIO.
Arınç
Daniel Golle
maintainerRe: [PATCH 2/2] dt-bindings: net: dsa: mediatek,mt7530: document MDIO-bus
Quoted 23 lines · Arınç ÜNAL
Quoted 2 lines · David Bauer
Document the ability to add nodes for the MDIO bus connecting the switch-internal PHYs.
This is quite interesting. Currently the PHY muxing feature for the MT7530 switch looks for some fake ethernet-phy definitions on the mdio-bus where the switch is also defined.
Looking at the binding here, there will be an mdio node under the switch node. This could be useful to define the ethernet-phys for PHY muxing here instead, so we don't waste the register addresses on the parent mdio-bus for fake things. It looks like this should work right out of the box. I will do some tests.
Are there any examples as to what to configure on the switch PHYs with this change?
Quoted 6 lines
Signed-off-by David Bauer <[email protected]>--- .../devicetree/bindings/net/dsa/mediatek,mt7530.yaml | 6 ++++++ 1 file changed, 6 insertions(+)
Quoted 15 lines
Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml properties: · line 134
Quoted 12 lines
Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml +5
-0@@ -128,6 +128,12 @@ properties: See Documentation/devicetree/bindings/regulator/mt6323-regulator.txt for details for the regulator setup on these boards. + mdio: + $ref: /schemas/net/mdio.yaml# + unevaluatedProperties: false + description: + Node for the internal MDIO bus connected to the embedded ethernet-PHYs.Please set this property as false for mediatek,mt7988-switch as it doesn't use MDIO.
Well, quite the opposite is true. This change is **needed** on MT7988 as the built-in 1GE PHYs of the MT7988 are connected to the (internal) MDIO bus of the switch. And they do need calibration data assigned as nvmem via device tree.
tl;dr: Despite not being connected via MDIO itself also MT7988 exposes an internal MDIO bus for the switch PHYs.
Re: [PATCH 2/2] dt-bindings: net: dsa: mediatek,mt7530: document MDIO-bus
Quoted 40 lines · Daniel Golle
Quoted 23 lines · Arınç ÜNAL
Quoted 2 lines · David Bauer
Document the ability to add nodes for the MDIO bus connecting the switch-internal PHYs.
This is quite interesting. Currently the PHY muxing feature for the MT7530 switch looks for some fake ethernet-phy definitions on the mdio-bus where the switch is also defined.
Looking at the binding here, there will be an mdio node under the switch node. This could be useful to define the ethernet-phys for PHY muxing here instead, so we don't waste the register addresses on the parent mdio-bus for fake things. It looks like this should work right out of the box. I will do some tests.
Are there any examples as to what to configure on the switch PHYs with this change?
Quoted 6 lines
Signed-off-by David Bauer <[email protected]>--- .../devicetree/bindings/net/dsa/mediatek,mt7530.yaml | 6 ++++++ 1 file changed, 6 insertions(+)Quoted 15 lines
Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml properties: · line 134
Quoted 12 lines
Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml +5
-0@@ -128,6 +128,12 @@ properties: See Documentation/devicetree/bindings/regulator/mt6323-regulator.txt for details for the regulator setup on these boards. + mdio: + $ref: /schemas/net/mdio.yaml# + unevaluatedProperties: false + description: + Node for the internal MDIO bus connected to the embedded ethernet-PHYs.Please set this property as false for mediatek,mt7988-switch as it doesn't use MDIO.
Quoted 7 lines
Well, quite the opposite is true. This change is **needed** on MT7988 as the built-in 1GE PHYs of the MT7988 are connected to the (internal) MDIO bus of the switch. And they do need calibration data assigned as nvmem via device tree.
tl;dr: Despite not being connected via MDIO itself also MT7988 exposes an internal MDIO bus for the switch PHYs.
Got it, thanks.
Arınç
Re: [PATCH 2/2] dt-bindings: net: dsa: mediatek,mt7530: document MDIO-bus
In reply to Arınç ÜNALQuoted 7 lines · Arınç ÜNAL
Quoted 2 lines · David Bauer
Document the ability to add nodes for the MDIO bus connecting the switch-internal PHYs.
This is quite interesting. Currently the PHY muxing feature for the MT7530 switch looks for some fake ethernet-phy definitions on the mdio-bus where the switch is also defined.
Looking at the binding here, there will be an mdio node under the switch node. This could be useful to define the ethernet-phys for PHY muxing here instead, so we don't waste the register addresses on the parent mdio-bus for fake things. It looks like this should work right out of the box. I will do some tests.
Once I start using the mdio node it forces me to define all the PHYs which were defined as ports.
[ 4.159534] mt7530-mdio mdio-bus:1f lan0 (uninitialized): no phy at 1 [ 4.166002] mt7530-mdio mdio-bus:1f lan0 (uninitialized): failed to connect to PHY: -ENODEV [ 4.174421] mt7530-mdio mdio-bus:1f lan0 (uninitialized): error -19 setting up PHY for tree 0, switch 0, port 1 [ 4.185236] mt7530-mdio mdio-bus:1f lan1 (uninitialized): no phy at 2 [ 4.191753] mt7530-mdio mdio-bus:1f lan1 (uninitialized): failed to connect to PHY: -ENODEV [ 4.200150] mt7530-mdio mdio-bus:1f lan1 (uninitialized): error -19 setting up PHY for tree 0, switch 0, port 2 [ 4.210844] mt7530-mdio mdio-bus:1f lan2 (uninitialized): no phy at 3 [ 4.217361] mt7530-mdio mdio-bus:1f lan2 (uninitialized): failed to connect to PHY: -ENODEV [ 4.225734] mt7530-mdio mdio-bus:1f lan2 (uninitialized): error -19 setting up PHY for tree 0, switch 0, port 3 [ 4.236394] mt7530-mdio mdio-bus:1f lan3 (uninitialized): no phy at 4 [ 4.242901] mt7530-mdio mdio-bus:1f lan3 (uninitialized): failed to connect to PHY: -ENODEV [ 4.251297] mt7530-mdio mdio-bus:1f lan3 (uninitialized): error -19 setting up PHY for tree 0, switch 0, port 4
We can either force defining the PHYs on the mdio node which would break the ABI, or forget about doing PHY muxing this way.
Arınç
Andrew Lunn
maintainerRe: [PATCH 2/2] dt-bindings: net: dsa: mediatek,mt7530: document MDIO-bus
Quoted 9 lines · Arınç ÜNAL
Quoted 8 lines · Arınç ÜNAL
Quoted 2 lines · David Bauer
Document the ability to add nodes for the MDIO bus connecting the switch-internal PHYs.
This is quite interesting. Currently the PHY muxing feature for the MT7530 switch looks for some fake ethernet-phy definitions on the mdio-bus where the switch is also defined.
Quoted 8 lines
Quoted 5 lines
Looking at the binding here, there will be an mdio node under the switch node. This could be useful to define the ethernet-phys for PHY muxing here instead, so we don't waste the register addresses on the parent mdio-bus for fake things. It looks like this should work right out of the box. I will do some tests.
Once I start using the mdio node it forces me to define all the PHYs which were defined as ports.
Try setting ds->slave_mii_bus to the MDIO bus you register via of_mdiobus_register().
Andrew
Re: [PATCH 2/2] dt-bindings: net: dsa: mediatek,mt7530: document MDIO-bus
Quoted 16 lines · Andrew Lunn
Quoted 15 lines · Arınç ÜNAL
Quoted 13 lines · Arınç ÜNAL
Quoted 2 lines · David Bauer
Document the ability to add nodes for the MDIO bus connecting the switch-internal PHYs.
This is quite interesting. Currently the PHY muxing feature for the MT7530 switch looks for some fake ethernet-phy definitions on the mdio-bus where the switch is also defined.
Looking at the binding here, there will be an mdio node under the switch node. This could be useful to define the ethernet-phys for PHY muxing here instead, so we don't waste the register addresses on the parent mdio-bus for fake things. It looks like this should work right out of the box. I will do some tests.
Quoted 5 lines
Quoted 2 lines
Once I start using the mdio node it forces me to define all the PHYs which were defined as ports.
Try setting
ds->slave_mii_busto the MDIO bus you register viaof_mdiobus_register().
That seems to be the case already, under mt7530_setup_mdio():
bus = devm_mdiobus_alloc(dev); if (!bus) return -ENOMEM; ds->slave_mii_bus = bus;
The bus is registered with devm_of_mdiobus_register(), if that matters. (My current knowledge about OF or OF helpers for MDIO is next to nothing.)
The same behaviour is there.
Arınç
Andrew Lunn
maintainerRe: [PATCH 2/2] dt-bindings: net: dsa: mediatek,mt7530: document MDIO-bus
Quoted 11 lines
Quoted 2 lines
Try setting
ds->slave_mii_busto the MDIO bus you register viaof_mdiobus_register().That seems to be the case already, under
mt7530_setup_mdio():bus = devm_mdiobus_alloc(dev); if (!bus) return -ENOMEM; ds->slave_mii_bus = bus;
Quoted 4 lines
The bus is registered with
devm_of_mdiobus_register(), if that matters. (My current knowledge about OF or OF helpers for MDIO is next to nothing.)The same behaviour is there.
Maybe take a look at what is going on in dsa_slave_phy_setup() and dsa_slave_phy_connect().
The way i understand it, is it first looks in DT to see if there is a phy-handle, and if there is, it uses it. If not, it assumes there is a 1:1 mapping between port number and PHY address, and looks to see if a PHY has been found on ds->slave_mii_bus at that address, and uses it.
So i don't think you need to list the PHY, the fallback should be used.
Andrew
Re: [PATCH 2/2] dt-bindings: net: dsa: mediatek,mt7530: document MDIO-bus
Quoted 19 lines · Andrew Lunn
Quoted 11 lines
Quoted 2 lines
Try setting
ds->slave_mii_busto the MDIO bus you register viaof_mdiobus_register().That seems to be the case already, under
mt7530_setup_mdio():bus = devm_mdiobus_alloc(dev); if (!bus) return -ENOMEM; ds->slave_mii_bus = bus;Quoted 4 lines
The bus is registered with
devm_of_mdiobus_register(), if that matters. (My current knowledge about OF or OF helpers for MDIO is next to nothing.)The same behaviour is there.
Maybe take a look at what is going on in
dsa_slave_phy_setup()anddsa_slave_phy_connect().
Quoted 7 lines
The way i understand it, is it first looks in DT to see if there is a phy-handle, and if there is, it uses it. If not, it assumes there is a 1:1 mapping between port number and PHY address, and looks to see if a PHY has been found on
ds->slave_mii_busat that address, and uses it.So i don't think you need to list the PHY, the fallback should be used.
Thanks for pointing me in the right direction Andrew.
I applied this diff:
drivers/net/phy/mdio_bus.c +5 -1
@@ -117,8 +117,12 @@ struct phy_device *mdiobus_get_phy(struct mii_bus *bus, int addr) mdiodev = bus->mdio_map[addr]; -if (!mdiodev) +if (!mdiodev) { +dev_info (&bus->dev,"mdio device doesn't exist\n" );return NULL ; + } + +dev_info (&bus->dev,"mdio device exists\n" );if (!(mdiodev->flags &MDIO_DEVICE_FLAG_PHY ))return NULL ;
net/dsa/slave.c +1 -0
@@ -2487,6 +2487,7 @@ static int dsa_slave_phy_setup(struct net_device *slave_dev)/* We could not connect to a designated PHY or SFP, so try to * use the switch internal MDIO bus instead */ +netdev_err (slave_dev,"using switch's internal MDIO bus\n" ); ret =dsa_slave_phy_connect (slave_dev, dp->index, phy_flags); }if (ret) {
With or without this patch, the switch's internal MDIO bus is used to set up the PHYs.
DT that defines ethphy0 only, without this patch applied:
[ 4.660784] mt7530-mdio mdio-bus:1f wan (uninitialized): using switch's internal MDIO bus [ 4.669026] mdio_bus mt7530-0: mdio device exists [ 4.677693] mt7530-mdio mdio-bus:1f wan (uninitialized): PHY [mt7530-0:00] driver [MediaTek MT7530 PHY] (irq=POLL) [ 4.693238] mt7530-mdio mdio-bus:1f lan0 (uninitialized): using switch's internal MDIO bus [ 4.701589] mdio_bus mt7530-0: mdio device exists [ 4.707101] mt7530-mdio mdio-bus:1f lan0 (uninitialized): PHY [mt7530-0:01] driver [MediaTek MT7530 PHY] (irq=POLL) [ 4.718550] mt7530-mdio mdio-bus:1f lan1 (uninitialized): using switch's internal MDIO bus [ 4.726856] mdio_bus mt7530-0: mdio device exists [ 4.732384] mt7530-mdio mdio-bus:1f lan1 (uninitialized): PHY [mt7530-0:02] driver [MediaTek MT7530 PHY] (irq=POLL) [ 4.743822] mt7530-mdio mdio-bus:1f lan2 (uninitialized): using switch's internal MDIO bus [ 4.752154] mdio_bus mt7530-0: mdio device exists [ 4.757662] mt7530-mdio mdio-bus:1f lan2 (uninitialized): PHY [mt7530-0:03] driver [MediaTek MT7530 PHY] (irq=POLL) [ 4.769099] mt7530-mdio mdio-bus:1f lan3 (uninitialized): using switch's internal MDIO bus [ 4.781872] mdio_bus mt7530-0: mdio device exists [ 4.787413] mt7530-mdio mdio-bus:1f lan3 (uninitialized): PHY [mt7530-0:04] driver [MediaTek MT7530 PHY] (irq=POLL)
Same DT but with this patch applied:
[ 4.621547] mt7530-mdio mdio-bus:1f: configuring for fixed/trgmii link mode [ 4.631524] mt7530-mdio mdio-bus:1f wan (uninitialized): using switch's internal MDIO bus [ 4.639764] mdio_bus mt7530-0: mdio device exists [ 4.647770] mt7530-mdio mdio-bus:1f wan (uninitialized): PHY [mt7530-0:00] driver [MediaTek MT7530 PHY] (irq=POLL) [ 4.663898] mt7530-mdio mdio-bus:1f lan0 (uninitialized): using switch's internal MDIO bus [ 4.672253] mdio_bus mt7530-0: mdio device doesn't exist [ 4.677597] mt7530-mdio mdio-bus:1f lan0 (uninitialized): no phy at 1 [ 4.684053] mt7530-mdio mdio-bus:1f lan0 (uninitialized): failed to connect to PHY: -ENODEV [ 4.692435] mt7530-mdio mdio-bus:1f lan0 (uninitialized): error -19 setting up PHY for tree 0, switch 0, port 1 [ 4.703087] mt7530-mdio mdio-bus:1f lan1 (uninitialized): using switch's internal MDIO bus [ 4.711408] mdio_bus mt7530-0: mdio device doesn't exist [ 4.716731] mt7530-mdio mdio-bus:1f lan1 (uninitialized): no phy at 2 [ 4.723214] mt7530-mdio mdio-bus:1f lan1 (uninitialized): failed to connect to PHY: -ENODEV [ 4.731597] mt7530-mdio mdio-bus:1f lan1 (uninitialized): error -19 setting up PHY for tree 0, switch 0, port 2 [ 4.742199] mt7530-mdio mdio-bus:1f lan2 (uninitialized): using switch's internal MDIO bus [ 4.755431] mdio_bus mt7530-0: mdio device doesn't exist [ 4.760793] mt7530-mdio mdio-bus:1f lan2 (uninitialized): no phy at 3 [ 4.767263] mt7530-mdio mdio-bus:1f lan2 (uninitialized): failed to connect to PHY: -ENODEV [ 4.775632] mt7530-mdio mdio-bus:1f lan2 (uninitialized): error -19 setting up PHY for tree 0, switch 0, port 3 [ 4.786270] mt7530-mdio mdio-bus:1f lan3 (uninitialized): using switch's internal MDIO bus [ 4.794591] mdio_bus mt7530-0: mdio device doesn't exist [ 4.799944] mt7530-mdio mdio-bus:1f lan3 (uninitialized): no phy at 4 [ 4.806397] mt7530-mdio mdio-bus:1f lan3 (uninitialized): failed to connect to PHY: -ENODEV [ 4.814782] mt7530-mdio mdio-bus:1f lan3 (uninitialized): error -19 setting up PHY for tree 0, switch 0, port 4
DT without the mdio node defined, with this patch applied:
[ 4.650766] mt7530-mdio mdio-bus:1f: configuring for fixed/trgmii link mode [ 4.660687] mt7530-mdio mdio-bus:1f wan (uninitialized): using switch's internal MDIO bus [ 4.668937] mdio_bus mt7530-0: mdio device exists [ 4.677787] mt7530-mdio mdio-bus:1f wan (uninitialized): PHY [mt7530-0:00] driver [MediaTek MT7530 PHY] (irq=POLL) [ 4.693165] mt7530-mdio mdio-bus:1f lan0 (uninitialized): using switch's internal MDIO bus [ 4.701517] mdio_bus mt7530-0: mdio device exists [ 4.707029] mt7530-mdio mdio-bus:1f lan0 (uninitialized): PHY [mt7530-0:01] driver [MediaTek MT7530 PHY] (irq=POLL) [ 4.718469] mt7530-mdio mdio-bus:1f lan1 (uninitialized): using switch's internal MDIO bus [ 4.726773] mdio_bus mt7530-0: mdio device exists [ 4.732322] mt7530-mdio mdio-bus:1f lan1 (uninitialized): PHY [mt7530-0:02] driver [MediaTek MT7530 PHY] (irq=POLL) [ 4.743793] mt7530-mdio mdio-bus:1f lan2 (uninitialized): using switch's internal MDIO bus [ 4.752143] mdio_bus mt7530-0: mdio device exists [ 4.757662] mt7530-mdio mdio-bus:1f lan2 (uninitialized): PHY [mt7530-0:03] driver [MediaTek MT7530 PHY] (irq=POLL) [ 4.769105] mt7530-mdio mdio-bus:1f lan3 (uninitialized): using switch's internal MDIO bus [ 4.781905] mdio_bus mt7530-0: mdio device exists [ 4.787459] mt7530-mdio mdio-bus:1f lan3 (uninitialized): PHY [mt7530-0:04] driver [MediaTek MT7530 PHY] (irq=POLL)
This is how I define it, mind you no phandles.
switch@1f {
...
mdio {
#address-cells = <0x01>;
#size-cells = <0x00>;
ethernet-phy@0 {
reg = <0x00>;
};
};
};Like you said, if the mdio node is not defined, the driver will assume 1:1 mapping. If not, it will need all the PHYs to be defined on the mdio node along with on the ports node. Hence back to my original statement, we can either force defining the PHYs on the mdio node which would break the ABI, or forget about doing PHY muxing this way.
There are no MDIO operations needed on the PHYs for the PHY muxing anyway, so I'd rather do this some other way.
Thanks for the help.
Arınç
Andrew Lunn
maintainerRe: [PATCH 2/2] dt-bindings: net: dsa: mediatek,mt7530: document MDIO-bus
Quoted 141 lines · Arınç ÜNAL
Quoted 19 lines · Andrew Lunn
Quoted 11 lines
Quoted 2 lines
Try setting
ds->slave_mii_busto the MDIO bus you register viaof_mdiobus_register().That seems to be the case already, under
mt7530_setup_mdio():bus = devm_mdiobus_alloc(dev); if (!bus) return -ENOMEM; ds->slave_mii_bus = bus;Quoted 4 lines
The bus is registered with
devm_of_mdiobus_register(), if that matters. (My current knowledge about OF or OF helpers for MDIO is next to nothing.)The same behaviour is there.
Maybe take a look at what is going on in
dsa_slave_phy_setup()anddsa_slave_phy_connect().Quoted 7 lines
The way i understand it, is it first looks in DT to see if there is a phy-handle, and if there is, it uses it. If not, it assumes there is a 1:1 mapping between port number and PHY address, and looks to see if a PHY has been found on
ds->slave_mii_busat that address, and uses it.So i don't think you need to list the PHY, the fallback should be used.
Thanks for pointing me in the right direction Andrew.
I applied this diff:
drivers/net/phy/mdio_bus.c +5
-1@@ -117,8 +117,12 @@ struct phy_device *mdiobus_get_phy(struct mii_bus *bus, int addr) mdiodev = bus->mdio_map[addr]; -if (!mdiodev) +if (!mdiodev) { +dev_info (&bus->dev,"mdio device doesn't exist\n" );return NULL ; + } + +dev_info (&bus->dev,"mdio device exists\n" );if (!(mdiodev->flags &MDIO_DEVICE_FLAG_PHY ))return NULL ;net/dsa/slave.c +1
-0@@ -2487,6 +2487,7 @@ static int dsa_slave_phy_setup(struct net_device *slave_dev)/* We could not connect to a designated PHY or SFP, so try to * use the switch internal MDIO bus instead */ +netdev_err (slave_dev,"using switch's internal MDIO bus\n" ); ret =dsa_slave_phy_connect (slave_dev, dp->index, phy_flags); }if (ret) {With or without this patch, the switch's internal MDIO bus is used to set up the PHYs.
DT that defines ethphy0 only, without this patch applied:
[ 4.660784] mt7530-mdio mdio-bus:1f wan (uninitialized): using switch's internal MDIO bus [ 4.669026] mdio_bus mt7530-0: mdio device exists [ 4.677693] mt7530-mdio mdio-bus:1f wan (uninitialized): PHY [mt7530-0:00] driver [MediaTek MT7530 PHY] (irq=POLL) [ 4.693238] mt7530-mdio mdio-bus:1f lan0 (uninitialized): using switch's internal MDIO bus [ 4.701589] mdio_bus mt7530-0: mdio device exists [ 4.707101] mt7530-mdio mdio-bus:1f lan0 (uninitialized): PHY [mt7530-0:01] driver [MediaTek MT7530 PHY] (irq=POLL) [ 4.718550] mt7530-mdio mdio-bus:1f lan1 (uninitialized): using switch's internal MDIO bus [ 4.726856] mdio_bus mt7530-0: mdio device exists [ 4.732384] mt7530-mdio mdio-bus:1f lan1 (uninitialized): PHY [mt7530-0:02] driver [MediaTek MT7530 PHY] (irq=POLL) [ 4.743822] mt7530-mdio mdio-bus:1f lan2 (uninitialized): using switch's internal MDIO bus [ 4.752154] mdio_bus mt7530-0: mdio device exists [ 4.757662] mt7530-mdio mdio-bus:1f lan2 (uninitialized): PHY [mt7530-0:03] driver [MediaTek MT7530 PHY] (irq=POLL) [ 4.769099] mt7530-mdio mdio-bus:1f lan3 (uninitialized): using switch's internal MDIO bus [ 4.781872] mdio_bus mt7530-0: mdio device exists [ 4.787413] mt7530-mdio mdio-bus:1f lan3 (uninitialized): PHY [mt7530-0:04] driver [MediaTek MT7530 PHY] (irq=POLL)Same DT but with this patch applied:
[ 4.621547] mt7530-mdio mdio-bus:1f: configuring for fixed/trgmii link mode [ 4.631524] mt7530-mdio mdio-bus:1f wan (uninitialized): using switch's internal MDIO bus [ 4.639764] mdio_bus mt7530-0: mdio device exists [ 4.647770] mt7530-mdio mdio-bus:1f wan (uninitialized): PHY [mt7530-0:00] driver [MediaTek MT7530 PHY] (irq=POLL) [ 4.663898] mt7530-mdio mdio-bus:1f lan0 (uninitialized): using switch's internal MDIO bus [ 4.672253] mdio_bus mt7530-0: mdio device doesn't exist [ 4.677597] mt7530-mdio mdio-bus:1f lan0 (uninitialized): no phy at 1 [ 4.684053] mt7530-mdio mdio-bus:1f lan0 (uninitialized): failed to connect to PHY: -ENODEV [ 4.692435] mt7530-mdio mdio-bus:1f lan0 (uninitialized): error -19 setting up PHY for tree 0, switch 0, port 1 [ 4.703087] mt7530-mdio mdio-bus:1f lan1 (uninitialized): using switch's internal MDIO bus [ 4.711408] mdio_bus mt7530-0: mdio device doesn't exist [ 4.716731] mt7530-mdio mdio-bus:1f lan1 (uninitialized): no phy at 2 [ 4.723214] mt7530-mdio mdio-bus:1f lan1 (uninitialized): failed to connect to PHY: -ENODEV [ 4.731597] mt7530-mdio mdio-bus:1f lan1 (uninitialized): error -19 setting up PHY for tree 0, switch 0, port 2 [ 4.742199] mt7530-mdio mdio-bus:1f lan2 (uninitialized): using switch's internal MDIO bus [ 4.755431] mdio_bus mt7530-0: mdio device doesn't exist [ 4.760793] mt7530-mdio mdio-bus:1f lan2 (uninitialized): no phy at 3 [ 4.767263] mt7530-mdio mdio-bus:1f lan2 (uninitialized): failed to connect to PHY: -ENODEV [ 4.775632] mt7530-mdio mdio-bus:1f lan2 (uninitialized): error -19 setting up PHY for tree 0, switch 0, port 3 [ 4.786270] mt7530-mdio mdio-bus:1f lan3 (uninitialized): using switch's internal MDIO bus [ 4.794591] mdio_bus mt7530-0: mdio device doesn't exist [ 4.799944] mt7530-mdio mdio-bus:1f lan3 (uninitialized): no phy at 4 [ 4.806397] mt7530-mdio mdio-bus:1f lan3 (uninitialized): failed to connect to PHY: -ENODEV [ 4.814782] mt7530-mdio mdio-bus:1f lan3 (uninitialized): error -19 setting up PHY for tree 0, switch 0, port 4DT without the mdio node defined, with this patch applied:
[ 4.650766] mt7530-mdio mdio-bus:1f: configuring for fixed/trgmii link mode [ 4.660687] mt7530-mdio mdio-bus:1f wan (uninitialized): using switch's internal MDIO bus [ 4.668937] mdio_bus mt7530-0: mdio device exists [ 4.677787] mt7530-mdio mdio-bus:1f wan (uninitialized): PHY [mt7530-0:00] driver [MediaTek MT7530 PHY] (irq=POLL) [ 4.693165] mt7530-mdio mdio-bus:1f lan0 (uninitialized): using switch's internal MDIO bus [ 4.701517] mdio_bus mt7530-0: mdio device exists [ 4.707029] mt7530-mdio mdio-bus:1f lan0 (uninitialized): PHY [mt7530-0:01] driver [MediaTek MT7530 PHY] (irq=POLL) [ 4.718469] mt7530-mdio mdio-bus:1f lan1 (uninitialized): using switch's internal MDIO bus [ 4.726773] mdio_bus mt7530-0: mdio device exists [ 4.732322] mt7530-mdio mdio-bus:1f lan1 (uninitialized): PHY [mt7530-0:02] driver [MediaTek MT7530 PHY] (irq=POLL) [ 4.743793] mt7530-mdio mdio-bus:1f lan2 (uninitialized): using switch's internal MDIO bus [ 4.752143] mdio_bus mt7530-0: mdio device exists [ 4.757662] mt7530-mdio mdio-bus:1f lan2 (uninitialized): PHY [mt7530-0:03] driver [MediaTek MT7530 PHY] (irq=POLL) [ 4.769105] mt7530-mdio mdio-bus:1f lan3 (uninitialized): using switch's internal MDIO bus [ 4.781905] mdio_bus mt7530-0: mdio device exists [ 4.787459] mt7530-mdio mdio-bus:1f lan3 (uninitialized): PHY [mt7530-0:04] driver [MediaTek MT7530 PHY] (irq=POLL)This is how I define it, mind you no phandles.
switch@1f { ... mdio { #address-cells = <0x01>; #size-cells = <0x00>; ethernet-phy@0 { reg = <0x00>; }; }; };
Quoted 8 lines
Like you said, if the mdio node is not defined, the driver will assume 1:1 mapping. If not, it will need all the PHYs to be defined on the mdio node along with on the ports node. Hence back to my original statement, we can either force defining the PHYs on the mdio node which would break the ABI, or forget about doing PHY muxing this way.
There are no MDIO operations needed on the PHYs for the PHY muxing anyway, so I'd rather do this some other way.
The problem is __of_mdiobus_register() :-(
If there is a node in DT, the scanning of all addresses is disabled. It looks at just the addresses listed in DT. Plain mdiobus_register() by default looks at all addresses to discover if a PHY is there.
Hence when slave.c tries to connect to the PHY, only the PHY you listed in DT has been found.
I don't see a way around this, at least not without adding a new variant of of_mdiobus_register which combined DT with a bus scan.
Andrew
Re: [PATCH 2/2] dt-bindings: net: dsa: mediatek,mt7530: document MDIO-bus
In reply to Arınç ÜNALHi Arinc,
thanks for spotting this issue.
Quoted 144 lines · Arınç ÜNAL
Quoted 19 lines · Andrew Lunn
Quoted 9 lines
Quoted 2 lines
Try setting
ds->slave_mii_busto the MDIO bus you register viaof_mdiobus_register().That seems to be the case already, under
mt7530_setup_mdio():bus =
devm_mdiobus_alloc(dev);
if (!bus)
return-ENOMEM;Quoted 6 lines
ds->slave_mii_bus = bus;
The bus is registered with
devm_of_mdiobus_register(), if that matters. (My current knowledge about OF or OF helpers for MDIO is next to nothing.)The same behaviour is there.
Maybe take a look at what is going on in
dsa_slave_phy_setup()anddsa_slave_phy_connect().Quoted 7 lines
The way i understand it, is it first looks in DT to see if there is a phy-handle, and if there is, it uses it. If not, it assumes there is a 1:1 mapping between port number and PHY address, and looks to see if a PHY has been found on
ds->slave_mii_busat that address, and uses it.So i don't think you need to list the PHY, the fallback should be used.
Thanks for pointing me in the right direction Andrew.
I applied this diff:
drivers/net/phy/mdio_bus.c +5
-1@@ -117,8 +117,12 @@ struct phy_device *mdiobus_get_phy(struct mii_bus *bus, int addr) mdiodev = bus->mdio_map[addr]; - if (!mdiodev) + if (!mdiodev) { + dev_info(&bus->dev, "mdio device doesn't exist\n"); return NULL; + } + + dev_info(&bus->dev, "mdio device exists\n"); if (!(mdiodev->flags & MDIO_DEVICE_FLAG_PHY)) return NULL;net/dsa/slave.c +1
-0@@ -2487,6 +2487,7 @@ static int dsa_slave_phy_setup(struct net_device *slave_dev) /* We could not connect to a designated PHY or SFP, so try to * use the switch internal MDIO bus instead */ + netdev_err(slave_dev, "using switch's internal MDIO bus\n"); ret = dsa_slave_phy_connect(slave_dev, dp->index, phy_flags); } if (ret) {With or without this patch, the switch's internal MDIO bus is used to set up the PHYs.
DT that defines ethphy0 only, without this patch applied:
[ 4.660784] mt7530-mdio mdio-bus:1f wan (uninitialized): using switch's internal MDIO bus
[ 4.669026]mdio_busmt7530-0: mdio device exists
[ 4.677693] mt7530-mdio mdio-bus:1f wan (uninitialized): PHY [mt7530-0:00] driver [MediaTek MT7530 PHY] (irq=POLL) [ 4.693238] mt7530-mdio mdio-bus:1f lan0 (uninitialized): using switch's internal MDIO bus
[ 4.701589]mdio_busmt7530-0: mdio device exists
[ 4.707101] mt7530-mdio mdio-bus:1f lan0 (uninitialized): PHY [mt7530-0:01] driver [MediaTek MT7530 PHY] (irq=POLL) [ 4.718550] mt7530-mdio mdio-bus:1f lan1 (uninitialized): using switch's internal MDIO bus
[ 4.726856]mdio_busmt7530-0: mdio device exists
[ 4.732384] mt7530-mdio mdio-bus:1f lan1 (uninitialized): PHY [mt7530-0:02] driver [MediaTek MT7530 PHY] (irq=POLL) [ 4.743822] mt7530-mdio mdio-bus:1f lan2 (uninitialized): using switch's internal MDIO bus
[ 4.752154]mdio_busmt7530-0: mdio device exists
[ 4.757662] mt7530-mdio mdio-bus:1f lan2 (uninitialized): PHY [mt7530-0:03] driver [MediaTek MT7530 PHY] (irq=POLL) [ 4.769099] mt7530-mdio mdio-bus:1f lan3 (uninitialized): using switch's internal MDIO bus
[ 4.781872]mdio_busmt7530-0: mdio device exists
[ 4.787413] mt7530-mdio mdio-bus:1f lan3 (uninitialized): PHY [mt7530-0:04] driver [MediaTek MT7530 PHY] (irq=POLL)Same DT but with this patch applied:
[ 4.621547] mt7530-mdio mdio-bus:1f: configuring for fixed/trgmii link mode
[ 4.631524] mt7530-mdio mdio-bus:1f wan (uninitialized): using switch's internal MDIO bus
[ 4.639764]mdio_busmt7530-0: mdio device exists
[ 4.647770] mt7530-mdio mdio-bus:1f wan (uninitialized): PHY [mt7530-0:00] driver [MediaTek MT7530 PHY] (irq=POLL) [ 4.663898] mt7530-mdio mdio-bus:1f lan0 (uninitialized): using switch's internal MDIO bus
[ 4.672253]mdio_busmt7530-0: mdio device doesn't exist
[ 4.677597] mt7530-mdio mdio-bus:1f lan0 (uninitialized): no phy at 1
[ 4.684053] mt7530-mdio mdio-bus:1f lan0 (uninitialized): failed to connect to PHY:-ENODEV
[ 4.692435] mt7530-mdio mdio-bus:1f lan0 (uninitialized): error -19 setting up PHY for tree 0, switch 0, port 1 [ 4.703087] mt7530-mdio mdio-bus:1f lan1 (uninitialized): using switch's internal MDIO bus
[ 4.711408]mdio_busmt7530-0: mdio device doesn't exist
[ 4.716731] mt7530-mdio mdio-bus:1f lan1 (uninitialized): no phy at 2
[ 4.723214] mt7530-mdio mdio-bus:1f lan1 (uninitialized): failed to connect to PHY:-ENODEV
[ 4.731597] mt7530-mdio mdio-bus:1f lan1 (uninitialized): error -19 setting up PHY for tree 0, switch 0, port 2 [ 4.742199] mt7530-mdio mdio-bus:1f lan2 (uninitialized): using switch's internal MDIO bus
[ 4.755431]mdio_busmt7530-0: mdio device doesn't exist
[ 4.760793] mt7530-mdio mdio-bus:1f lan2 (uninitialized): no phy at 3
[ 4.767263] mt7530-mdio mdio-bus:1f lan2 (uninitialized): failed to connect to PHY:-ENODEV
[ 4.775632] mt7530-mdio mdio-bus:1f lan2 (uninitialized): error -19 setting up PHY for tree 0, switch 0, port 3 [ 4.786270] mt7530-mdio mdio-bus:1f lan3 (uninitialized): using switch's internal MDIO bus
[ 4.794591]mdio_busmt7530-0: mdio device doesn't exist
[ 4.799944] mt7530-mdio mdio-bus:1f lan3 (uninitialized): no phy at 4
[ 4.806397] mt7530-mdio mdio-bus:1f lan3 (uninitialized): failed to connect to PHY:-ENODEV
[ 4.814782] mt7530-mdio mdio-bus:1f lan3 (uninitialized): error -19 setting up PHY for tree 0, switch 0, port 4DT without the mdio node defined, with this patch applied:
[ 4.650766] mt7530-mdio mdio-bus:1f: configuring for fixed/trgmii link mode
[ 4.660687] mt7530-mdio mdio-bus:1f wan (uninitialized): using switch's internal MDIO bus
[ 4.668937]mdio_busmt7530-0: mdio device exists
[ 4.677787] mt7530-mdio mdio-bus:1f wan (uninitialized): PHY [mt7530-0:00] driver [MediaTek MT7530 PHY] (irq=POLL) [ 4.693165] mt7530-mdio mdio-bus:1f lan0 (uninitialized): using switch's internal MDIO bus
[ 4.701517]mdio_busmt7530-0: mdio device exists
[ 4.707029] mt7530-mdio mdio-bus:1f lan0 (uninitialized): PHY [mt7530-0:01] driver [MediaTek MT7530 PHY] (irq=POLL) [ 4.718469] mt7530-mdio mdio-bus:1f lan1 (uninitialized): using switch's internal MDIO bus
[ 4.726773]mdio_busmt7530-0: mdio device exists
[ 4.732322] mt7530-mdio mdio-bus:1f lan1 (uninitialized): PHY [mt7530-0:02] driver [MediaTek MT7530 PHY] (irq=POLL) [ 4.743793] mt7530-mdio mdio-bus:1f lan2 (uninitialized): using switch's internal MDIO bus
[ 4.752143]mdio_busmt7530-0: mdio device exists
[ 4.757662] mt7530-mdio mdio-bus:1f lan2 (uninitialized): PHY [mt7530-0:03] driver [MediaTek MT7530 PHY] (irq=POLL) [ 4.769105] mt7530-mdio mdio-bus:1f lan3 (uninitialized): using switch's internal MDIO bus
[ 4.781905]mdio_busmt7530-0: mdio device exists
[ 4.787459] mt7530-mdio mdio-bus:1f lan3 (uninitialized): PHY [mt7530-0:04] driver [MediaTek MT7530 PHY] (irq=POLL)This is how I define it, mind you no phandles.
switch@1f {
...
mdio {
#address-cells = <0x01>;
#size-cells = <0x00>;ethernet-phy@0 {
reg = <0x00>;
};
};
};
Quoted 5 lines
Like you said, if the mdio node is not defined, the driver will assume 1:1 mapping. If not, it will need all the PHYs to be defined on the mdio node along with on the ports node. Hence back to my original statement, we can either force defining the PHYs on the mdio node which would break the ABI, or forget about doing PHY muxing this way.
While i was not aware of this side effect, I don't see how this breaks the ABI.
Existing device-trees not defining the MDIO node will still continue to work.
Wouldn't we just skip the whole issue by documenting the need for defining all PHYs used on the switch when defining the MDIO bus?
Best
David
Quoted 7 lines
There are no MDIO operations needed on the PHYs for the PHY muxing anyway, so I'd rather do this some other way.
Thanks for the help.
Arınç
Re: [PATCH 2/2] dt-bindings: net: dsa: mediatek,mt7530: document MDIO-bus
Quoted 149 lines · David Bauer
Hi Arinc,
thanks for spotting this issue.
Quoted 144 lines · Arınç ÜNAL
Quoted 19 lines · Andrew Lunn
Quoted 9 lines
Quoted 2 lines
Try setting
ds->slave_mii_busto the MDIO bus you register viaof_mdiobus_register().That seems to be the case already, under
mt7530_setup_mdio():bus =
devm_mdiobus_alloc(dev);
if (!bus)
return-ENOMEM;Quoted 6 lines
ds->slave_mii_bus = bus;
The bus is registered with
devm_of_mdiobus_register(), if that matters. (My current knowledge about OF or OF helpers for MDIO is next to nothing.)The same behaviour is there.
Maybe take a look at what is going on in
dsa_slave_phy_setup()anddsa_slave_phy_connect().Quoted 7 lines
The way i understand it, is it first looks in DT to see if there is a phy-handle, and if there is, it uses it. If not, it assumes there is a 1:1 mapping between port number and PHY address, and looks to see if a PHY has been found on
ds->slave_mii_busat that address, and uses it.So i don't think you need to list the PHY, the fallback should be used.
Thanks for pointing me in the right direction Andrew.
I applied this diff:
drivers/net/phy/mdio_bus.c +5
-1@@ -117,8 +117,12 @@ struct phy_device *mdiobus_get_phy(struct mii_bus *bus, int addr) mdiodev = bus->mdio_map[addr]; - if (!mdiodev) + if (!mdiodev) { + dev_info(&bus->dev, "mdio device doesn't exist\n"); return NULL; + } + + dev_info(&bus->dev, "mdio device exists\n"); if (!(mdiodev->flags & MDIO_DEVICE_FLAG_PHY)) return NULL;net/dsa/slave.c +1
-0@@ -2487,6 +2487,7 @@ static int dsa_slave_phy_setup(struct net_device *slave_dev) /* We could not connect to a designated PHY or SFP, so try to * use the switch internal MDIO bus instead */ + netdev_err(slave_dev, "using switch's internal MDIO bus\n"); ret = dsa_slave_phy_connect(slave_dev, dp->index, phy_flags); } if (ret) {With or without this patch, the switch's internal MDIO bus is used to set up the PHYs.
DT that defines ethphy0 only, without this patch applied:
[ 4.660784] mt7530-mdio mdio-bus:1f wan (uninitialized): using switch's internal MDIO bus
[ 4.669026]mdio_busmt7530-0: mdio device exists
[ 4.677693] mt7530-mdio mdio-bus:1f wan (uninitialized): PHY [mt7530-0:00] driver [MediaTek MT7530 PHY] (irq=POLL) [ 4.693238] mt7530-mdio mdio-bus:1f lan0 (uninitialized): using switch's internal MDIO bus
[ 4.701589]mdio_busmt7530-0: mdio device exists
[ 4.707101] mt7530-mdio mdio-bus:1f lan0 (uninitialized): PHY [mt7530-0:01] driver [MediaTek MT7530 PHY] (irq=POLL) [ 4.718550] mt7530-mdio mdio-bus:1f lan1 (uninitialized): using switch's internal MDIO bus
[ 4.726856]mdio_busmt7530-0: mdio device exists
[ 4.732384] mt7530-mdio mdio-bus:1f lan1 (uninitialized): PHY [mt7530-0:02] driver [MediaTek MT7530 PHY] (irq=POLL) [ 4.743822] mt7530-mdio mdio-bus:1f lan2 (uninitialized): using switch's internal MDIO bus
[ 4.752154]mdio_busmt7530-0: mdio device exists
[ 4.757662] mt7530-mdio mdio-bus:1f lan2 (uninitialized): PHY [mt7530-0:03] driver [MediaTek MT7530 PHY] (irq=POLL) [ 4.769099] mt7530-mdio mdio-bus:1f lan3 (uninitialized): using switch's internal MDIO bus
[ 4.781872]mdio_busmt7530-0: mdio device exists
[ 4.787413] mt7530-mdio mdio-bus:1f lan3 (uninitialized): PHY [mt7530-0:04] driver [MediaTek MT7530 PHY] (irq=POLL)Same DT but with this patch applied:
[ 4.621547] mt7530-mdio mdio-bus:1f: configuring for fixed/trgmii link mode
[ 4.631524] mt7530-mdio mdio-bus:1f wan (uninitialized): using switch's internal MDIO bus
[ 4.639764]mdio_busmt7530-0: mdio device exists
[ 4.647770] mt7530-mdio mdio-bus:1f wan (uninitialized): PHY [mt7530-0:00] driver [MediaTek MT7530 PHY] (irq=POLL) [ 4.663898] mt7530-mdio mdio-bus:1f lan0 (uninitialized): using switch's internal MDIO bus
[ 4.672253]mdio_busmt7530-0: mdio device doesn't exist
[ 4.677597] mt7530-mdio mdio-bus:1f lan0 (uninitialized): no phy at 1
[ 4.684053] mt7530-mdio mdio-bus:1f lan0 (uninitialized): failed to connect to PHY:-ENODEV
[ 4.692435] mt7530-mdio mdio-bus:1f lan0 (uninitialized): error -19 setting up PHY for tree 0, switch 0, port 1 [ 4.703087] mt7530-mdio mdio-bus:1f lan1 (uninitialized): using switch's internal MDIO bus
[ 4.711408]mdio_busmt7530-0: mdio device doesn't exist
[ 4.716731] mt7530-mdio mdio-bus:1f lan1 (uninitialized): no phy at 2
[ 4.723214] mt7530-mdio mdio-bus:1f lan1 (uninitialized): failed to connect to PHY:-ENODEV
[ 4.731597] mt7530-mdio mdio-bus:1f lan1 (uninitialized): error -19 setting up PHY for tree 0, switch 0, port 2 [ 4.742199] mt7530-mdio mdio-bus:1f lan2 (uninitialized): using switch's internal MDIO bus
[ 4.755431]mdio_busmt7530-0: mdio device doesn't exist
[ 4.760793] mt7530-mdio mdio-bus:1f lan2 (uninitialized): no phy at 3
[ 4.767263] mt7530-mdio mdio-bus:1f lan2 (uninitialized): failed to connect to PHY:-ENODEV
[ 4.775632] mt7530-mdio mdio-bus:1f lan2 (uninitialized): error -19 setting up PHY for tree 0, switch 0, port 3 [ 4.786270] mt7530-mdio mdio-bus:1f lan3 (uninitialized): using switch's internal MDIO bus
[ 4.794591]mdio_busmt7530-0: mdio device doesn't exist
[ 4.799944] mt7530-mdio mdio-bus:1f lan3 (uninitialized): no phy at 4
[ 4.806397] mt7530-mdio mdio-bus:1f lan3 (uninitialized): failed to connect to PHY:-ENODEV
[ 4.814782] mt7530-mdio mdio-bus:1f lan3 (uninitialized): error -19 setting up PHY for tree 0, switch 0, port 4DT without the mdio node defined, with this patch applied:
[ 4.650766] mt7530-mdio mdio-bus:1f: configuring for fixed/trgmii link mode
[ 4.660687] mt7530-mdio mdio-bus:1f wan (uninitialized): using switch's internal MDIO bus
[ 4.668937]mdio_busmt7530-0: mdio device exists
[ 4.677787] mt7530-mdio mdio-bus:1f wan (uninitialized): PHY [mt7530-0:00] driver [MediaTek MT7530 PHY] (irq=POLL) [ 4.693165] mt7530-mdio mdio-bus:1f lan0 (uninitialized): using switch's internal MDIO bus
[ 4.701517]mdio_busmt7530-0: mdio device exists
[ 4.707029] mt7530-mdio mdio-bus:1f lan0 (uninitialized): PHY [mt7530-0:01] driver [MediaTek MT7530 PHY] (irq=POLL) [ 4.718469] mt7530-mdio mdio-bus:1f lan1 (uninitialized): using switch's internal MDIO bus
[ 4.726773]mdio_busmt7530-0: mdio device exists
[ 4.732322] mt7530-mdio mdio-bus:1f lan1 (uninitialized): PHY [mt7530-0:02] driver [MediaTek MT7530 PHY] (irq=POLL) [ 4.743793] mt7530-mdio mdio-bus:1f lan2 (uninitialized): using switch's internal MDIO bus
[ 4.752143]mdio_busmt7530-0: mdio device exists
[ 4.757662] mt7530-mdio mdio-bus:1f lan2 (uninitialized): PHY [mt7530-0:03] driver [MediaTek MT7530 PHY] (irq=POLL) [ 4.769105] mt7530-mdio mdio-bus:1f lan3 (uninitialized): using switch's internal MDIO bus
[ 4.781905]mdio_busmt7530-0: mdio device exists
[ 4.787459] mt7530-mdio mdio-bus:1f lan3 (uninitialized): PHY [mt7530-0:04] driver [MediaTek MT7530 PHY] (irq=POLL)This is how I define it, mind you no phandles.
switch@1f {
...
mdio {
#address-cells = <0x01>;
#size-cells = <0x00>;ethernet-phy@0 {
reg = <0x00>;
};
};
};
Quoted 7 lines
Quoted 5 lines
Like you said, if the mdio node is not defined, the driver will assume 1:1 mapping. If not, it will need all the PHYs to be defined on the mdio node along with on the ports node. Hence back to my original statement, we can either force defining the PHYs on the mdio node which would break the ABI, or forget about doing PHY muxing this way.
While i was not aware of this side effect, I don't see how this breaks the ABI.
Your patch doesn't break it, my then-intention of doing PHY muxing by utilising this would. Your first patch is perfectly fine as is.
Quoted 2 lines
Existing device-trees not defining the MDIO node will still continue to work.
Agreed, I also confirmed this with my test above.
Quoted 3 lines
Wouldn't we just skip the whole issue by documenting the need for defining all PHYs used on the switch when defining the MDIO bus?
Good idea, please do that.
Arınç
Re: [PATCH 2/2] dt-bindings: net: dsa: mediatek,mt7530: document MDIO-bus
In reply to David BauerQuoted 13 lines · David Bauer
Document the ability to add nodes for the MDIO bus connecting the switch-internal PHYs.
Signed-off-by David Bauer <[email protected]>--- .../devicetree/bindings/net/dsa/mediatek,mt7530.yaml | 6 ++++++ 1 file changed, 6 insertions(+)Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml +0
-0
Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml properties: · line 135
Quoted 8 lines
Documentation/devicetree/bindings/net/dsa/mediatek,mt7530.yaml +5
-0@@ -128,6 +128,12 @@ properties: See Documentation/devicetree/bindings/regulator/mt6323-regulator.txt for details for the regulator setup on these boards. + mdio: + $ref: /schemas/net/mdio.yaml# + unevaluatedProperties: false + description: + Node for the internal MDIO bus connected to the embedded ethernet-PHYs.
Maybe saying "connected to the internal switch PHYs" would better explain this.
Arınç
Quoted 7 lines · David Bauer
The MT753x switches provide a switch-internal MDIO bus for the embedded PHYs.
Register a OF sub-node on the switch OF-node for this internal MDIO bus. This allows to configure the embedded PHYs using device-tree.
Signed-off-by David Bauer <[email protected]>
I've got a similar commit in my tree for a while, yours is better because you care to of_node_put(mnp) ;)
And yes, this will be fine also if mnp is NULL, the MDIO bus will still be registered (just without the reference to the OF node) and also of_node_put is fine being called for NULL.
Quoted 36 lines
--- drivers/net/dsa/mt7530.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)drivers/net/dsa/mt7530.c +6
-1@@ -2119,10 +2119,13 @@ mt7530_setup_mdio(struct mt7530_priv *priv) {struct dsa_switch *ds = priv->ds;struct device *dev = priv->dev; +struct device_node *np, *mnp;struct mii_bus *bus;static int idx;int ret; + np = priv->dev->of_node; + bus =devm_mdiobus_alloc (dev);if (!bus)return -ENOMEM ;@@ -2141,7 +2144,9 @@ mt7530_setup_mdio(struct mt7530_priv *priv)if (priv->irq)mt7530_setup_mdio_irq (priv); - ret =devm_mdiobus_register (dev, bus); + mnp =of_get_child_by_name (np,"mdio" ); + ret =devm_of_mdiobus_register (dev, bus, mnp); +of_node_put (mnp);if (ret) {dev_err (dev,"failed to register MDIO bus: %d\n" , ret);if (priv->irq)Signature · 1 line
2.39.2
Andrew Lunn
maintainerQuoted 7 lines · David Bauer
The MT753x switches provide a switch-internal MDIO bus for the embedded PHYs.
Register a OF sub-node on the switch OF-node for this internal MDIO bus. This allows to configure the embedded PHYs using device-tree.
Signed-off-by David Bauer <[email protected]>
Hi David
Please read
https://www.kernel.org/doc/html/latest/process/maintainer-netdev.html
You should put the tree in the patch subject.
Also, net-next is closed at the moment due to the merge window. Please only post RFC patches during this time, and repost once net-next opens again.
Andrew