netdev/of/phy: MDIO bus multiplexer support.
Subsystems (6)
v6 cover netdev/of/phy: MDIO bus multiplexer support.
From: David Daney <david.daney-YGCgFSpz5w/[email protected]>
This code has been working well for about six months on a couple of different configurations (boards), so I thought it would be a good time to send it out again, and I hope get it on the path towards merging.
v6: Correct Kconfig depends in 2/3 as noticed by David Miller. Test
against net-next.
v5: Correct Kconfig depends in 3/3 as noticed by David Miller.
v4: Correct some comment text and rename a couple of variables to
better reflect their purpose.
v3: Update binding to use "mdio-mux-gpio" compatible property.
Cleanups suggested by Grant Likely. Now uses the driver probe deferral mechanism if GPIOs or parent bus not available.
v2: Update bindings to use "reg" and "mdio-parent-bus" instead of
"cell-index" and "parent-bus"
v1:
We have several different boards with a multiplexer in the MDIO bus. There is an MDIO bus controller connected to a switching device with several child MDIO busses.
Everything is wired up using device tree bindings.
1/3 - New of_mdio_find_bus() function used to help configuring the
driver topology.
2/3 - MDIO bus multiplexer framework.
3/3 - A driver for a GPIO controlled multiplexer.
David Daney (3):
netdev/of/phy: New function: of_mdio_find_bus(). netdev/of/phy: Add MDIO bus multiplexer support. netdev/of/phy: Add MDIO bus multiplexer driven by GPIO lines.
.../devicetree/bindings/net/mdio-mux-gpio.txt | 127 +++++++++++++ Documentation/devicetree/bindings/net/mdio-mux.txt | 136 ++++++++++++++ drivers/net/phy/Kconfig | 19 ++ drivers/net/phy/Makefile | 2 + drivers/net/phy/mdio-mux-gpio.c | 142 +++++++++++++++ drivers/net/phy/mdio-mux.c | 192 ++++++++++++++++++++ drivers/net/phy/mdio_bus.c | 32 ++++ drivers/of/of_mdio.c | 2 + include/linux/mdio-mux.h | 21 ++ include/linux/of_mdio.h | 2 + 10 files changed, 675 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/net/mdio-mux-gpio.txt create mode 100644 Documentation/devicetree/bindings/net/mdio-mux.txt create mode 100644 drivers/net/phy/mdio-mux-gpio.c create mode 100644 drivers/net/phy/mdio-mux.c create mode 100644 include/linux/mdio-mux.h
Signature · 1 line
1.7.2.3
PATCH v6 1/3 netdev/of/phy: New function: of_mdio_find_bus().
From: David Daney <[email protected]>
Add of_mdio_find_bus() which allows an mii_bus to be located given its associated the device tree node.
This is needed by the follow-on patch to add a driver for MDIO bus multiplexers.
The of_mdiobus_register() function is modified so that the device tree node is recorded in the mii_bus. Then we can find it again by iterating over all mdio_bus_class devices.
Because the OF device tree has now become an integral part of the kernel, this can live in mdio_bus.c (which contains the needed mdio_bus_class structure) instead of of_mdio.c.
--- drivers/net/phy/mdio_bus.c | 32 ++++++++++++++++++++++++++++++++ drivers/of/of_mdio.c | 2 ++ include/linux/of_mdio.h | 2 ++ 3 files changed, 36 insertions(+), 0 deletions(-)
drivers/net/phy/mdio_bus.c +32 -0
@@ -88,6 +88,38 @@ static struct class mdio_bus_class = { .dev_release = mdiobus_release, }; +#ifdef CONFIG_OF_MDIO +/* Helper function for of_mdio_find_bus */ +static int of_mdio_bus_match (struct device *dev,void *mdio_bus_np) +{ +return dev->of_node == mdio_bus_np; +} +/** +* of_mdio_find_bus - Given an mii_bus node, find the mii_bus. +* @mdio_np: Pointer to the mii_bus. +* +* Returns a pointer to the mii_bus, or NULL if none found. +* +* Because the association of a device_node and mii_bus is made via +* of_mdiobus_register(), the mii_bus cannot be found before it is +* registered with of_mdiobus_register(). +* +*/ +struct mii_bus *of_mdio_find_bus (struct device_node *mdio_bus_np) +{ +struct device *d; + +if (!mdio_bus_np) +return NULL ; + + d =class_find_device (&mdio_bus_class,NULL , mdio_bus_np, + of_mdio_bus_match); + +return d ?to_mii_bus (d) :NULL ; +} +EXPORT_SYMBOL (of_mdio_find_bus); +#endif +/** * mdiobus_register - bring up all the PHYs on a given bus and attach them to bus * @bus: target mii_bus
drivers/of/of_mdio.c +2 -0
@@ -45,6 +45,8 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)for (i=0 ; i<PHY_MAX_ADDR ; i++) mdio->irq[i] =PHY_POLL ; + mdio->dev.of_node = np; +/* Register the MDIO bus */ rc =mdiobus_register (mdio);if (rc)
include/linux/of_mdio.h +2 -0
@@ -22,4 +22,6 @@ extern struct phy_device *of_phy_connect_fixed_link(struct net_device *dev,void (*hndlr)(struct net_device *), phy_interface_t iface); +extern struct mii_bus *of_mdio_find_bus (struct device_node *mdio_np); +#endif /* __LINUX_OF_MDIO_H */
Signature · 1 line
1.7.2.3
Re: [PATCH v6 1/3] netdev/of/phy: New function: of_mdio_find_bus().
From: David Daney <[email protected]>
Date: Wed, 2 May 2012 18:16:37 -0700
Quoted 12 lines
From: David Daney <[email protected]>
Add
of_mdio_find_bus()which allows anmii_busto be located given its associated the device tree node.This is needed by the follow-on patch to add a driver for MDIO bus multiplexers.
The
of_mdiobus_register()function is modified so that the device tree node is recorded in themii_bus. Then we can find it again by iterating over allmdio_bus_classdevices.
Quoted 5 lines
Because the OF device tree has now become an integral part of the kernel, this can live in
mdio_bus.c(which contains the neededmdio_bus_classstructure) instead ofof_mdio.c.Signed-off-by David Daney <[email protected]>
Applied.
PATCH v6 2/3 netdev/of/phy: Add MDIO bus multiplexer support.
In reply to David DaneyFrom: David Daney <[email protected]>
This patch adds a somewhat generic framework for MDIO bus multiplexers. It is modeled on the I2C multiplexer.
The multiplexer is needed if there are multiple PHYs with the same address connected to the same MDIO bus adepter, or if there is insufficient electrical drive capability for all the connected PHY devices.
Conceptually it could look something like this:
------------------
| Control Signal |
--------+---------
|
--------------- --------+------
| MDIO MASTER |---| Multiplexer |
--------------- --+-------+----
| |
C C
h h
i i
l l
d d
| |
--------- A B ---------
| | | | | |
| PHY@1 +-------+ +---+ PHY@1 |
| | | | | |
--------- | | ---------
--------- | | ---------
| | | | | |
| PHY@2 +-------+ +---+ PHY@2 |
| | | |
--------- ---------This framework configures the bus topology from device tree data. The mechanics of switching the multiplexer is left to device specific drivers.
The follow-on patch contains a multiplexer driven by GPIO lines.
--- Documentation/devicetree/bindings/net/mdio-mux.txt | 136 ++++++++++++++ drivers/net/phy/Kconfig | 9 + drivers/net/phy/Makefile | 1 + drivers/net/phy/mdio-mux.c | 192 ++++++++++++++++++++ include/linux/mdio-mux.h | 21 ++ 5 files changed, 359 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/net/mdio-mux.txt create mode 100644 drivers/net/phy/mdio-mux.c create mode 100644 include/linux/mdio-mux.h
Documentation/devicetree/bindings/net/mdio-mux.txt new file +136 -0
@@ -0,0 +1,136 @@ +Common MDIO bus multiplexer/switch properties. + +An MDIO bus multiplexer/switch will have several child busses that are +numbered uniquely in a device dependent manner. The nodes for an MDIO +bus multiplexer/switch will have one child node for each child bus. + +Required properties: +- mdio-parent-bus : phandle to the parent MDIO bus. +- #address-cells = <1>; +- #size-cells = <0>; + +Optional properties: +- Other properties specific to the multiplexer/switch hardware. + +Required properties for child nodes: +- #address-cells = <1>; +- #size-cells = <0>; +- reg : The sub-bus number. + + +Example : + + /* The parent MDIO bus. */ + smi1: mdio@1180000001900 { + compatible = "cavium,octeon-3860-mdio"; + #address-cells = <1>; + #size-cells = <0>; + reg = <0x11800 0x00001900 0x0 0x40>; + }; + + /* + An NXP sn74cbtlv3253 dual 1-of-4 switch controlled by a + pair of GPIO lines. Child busses 2 and 3 populated with 4 + PHYs each. + */ + mdio-mux { + compatible = "mdio-mux-gpio"; + gpios = <&gpio1 3 0>, <&gpio1 4 0>; + mdio-parent-bus = <&smi1>; + #address-cells = <1>; + #size-cells = <0>; + + mdio@2 { + reg = <2>; + #address-cells = <1>; + #size-cells = <0>; + + phy11: ethernet-phy@1 { + reg = <1>; + compatible = "marvell,88e1149r"; + marvell,reg-init = <3 0x10 0 0x5777>, + <3 0x11 0 0x00aa>, + <3 0x12 0 0x4105>, + <3 0x13 0 0x0a60>; + interrupt-parent = <&gpio>; + interrupts = <10 8>; /* Pin 10, active low */ + }; + phy12: ethernet-phy@2 { + reg = <2>; + compatible = "marvell,88e1149r"; + marvell,reg-init = <3 0x10 0 0x5777>, + <3 0x11 0 0x00aa>, + <3 0x12 0 0x4105>, + <3 0x13 0 0x0a60>; + interrupt-parent = <&gpio>; + interrupts = <10 8>; /* Pin 10, active low */ + }; + phy13: ethernet-phy@3 { + reg = <3>; + compatible = "marvell,88e1149r"; + marvell,reg-init = <3 0x10 0 0x5777>, + <3 0x11 0 0x00aa>, + <3 0x12 0 0x4105>, + <3 0x13 0 0x0a60>; + interrupt-parent = <&gpio>; + interrupts = <10 8>; /* Pin 10, active low */ + }; + phy14: ethernet-phy@4 { + reg = <4>; + compatible = "marvell,88e1149r"; + marvell,reg-init = <3 0x10 0 0x5777>, + <3 0x11 0 0x00aa>, + <3 0x12 0 0x4105>, + <3 0x13 0 0x0a60>; + interrupt-parent = <&gpio>; + interrupts = <10 8>; /* Pin 10, active low */ + }; + }; + + mdio@3 { + reg = <3>; + #address-cells = <1>; + #size-cells = <0>; + + phy21: ethernet-phy@1 { + reg = <1>; + compatible = "marvell,88e1149r"; + marvell,reg-init = <3 0x10 0 0x5777>, + <3 0x11 0 0x00aa>, + <3 0x12 0 0x4105>, + <3 0x13 0 0x0a60>; + interrupt-parent = <&gpio>; + interrupts = <12 8>; /* Pin 12, active low */ + }; + phy22: ethernet-phy@2 { + reg = <2>; + compatible = "marvell,88e1149r"; + marvell,reg-init = <3 0x10 0 0x5777>, + <3 0x11 0 0x00aa>, + <3 0x12 0 0x4105>, + <3 0x13 0 0x0a60>; + interrupt-parent = <&gpio>; + interrupts = <12 8>; /* Pin 12, active low */ + }; + phy23: ethernet-phy@3 { + reg = <3>; + compatible = "marvell,88e1149r"; + marvell,reg-init = <3 0x10 0 0x5777>, + <3 0x11 0 0x00aa>, + <3 0x12 0 0x4105>, + <3 0x13 0 0x0a60>; + interrupt-parent = <&gpio>; + interrupts = <12 8>; /* Pin 12, active low */ + }; + phy24: ethernet-phy@4 { + reg = <4>; + compatible = "marvell,88e1149r"; + marvell,reg-init = <3 0x10 0 0x5777>, + <3 0x11 0 0x00aa>, + <3 0x12 0 0x4105>, + <3 0x13 0 0x0a60>; + interrupt-parent = <&gpio>; + interrupts = <12 8>; /* Pin 12, active low */ + }; + }; + };
drivers/net/phy/Kconfig +9 -0
@@ -135,6 +135,15 @@ config MDIO_OCTEON If in doubt, say Y. +config MDIO_BUS_MUX + tristate + depends on OF_MDIO + help + This module provides a driver framework for MDIO bus + multiplexers which connect one of several child MDIO busses + to a parent bus. Switching between child busses is done by + device specific drivers. + endif # PHYLIB config MICREL_KS8995MA
drivers/net/phy/Makefile +1 -0
@@ -25,3 +25,4 @@ obj-$(CONFIG_MICREL_PHY) += micrel.o obj-$(CONFIG_MDIO_OCTEON) += mdio-octeon.o obj-$(CONFIG_MICREL_KS8995MA) += spi_ks8995.o obj-$(CONFIG_AMD_PHY) += amd.o +obj-$(CONFIG_MDIO_BUS_MUX) += mdio-mux.o
drivers/net/phy/mdio-mux.c new file +192 -0
192 lines not on this page · raw message
include/linux/mdio-mux.h new file +21 -0
@@ -0,0 +1,21 @@ +/* +* MDIO bus multiplexer framwork. +* +* This file is subject to the terms and conditions of the GNU General Public +* License. See the file "COPYING" in the main directory of this archive +* for more details. +* +* Copyright (C) 2011, 2012 Cavium, Inc. +*/ +#ifndef __LINUX_MDIO_MUX_H +#define __LINUX_MDIO_MUX_H +#include <linux/device.h> + +int mdio_mux_init (struct device *dev, +int (*switch_fn) (int cur,int desired,void *data), +void **mux_handle, +void *data); + +void mdio_mux_uninit (void *mux_handle); + +#endif /* __LINUX_MDIO_MUX_H */
Signature · 1 line
1.7.2.3
Re: [PATCH v6 2/3] netdev/of/phy: Add MDIO bus multiplexer support.
From: David Daney <[email protected]>
Date: Wed, 2 May 2012 18:16:38 -0700
Quoted 11 lines
From: David Daney <[email protected]>
This patch adds a somewhat generic framework for MDIO bus multiplexers. It is modeled on the I2C multiplexer.
The multiplexer is needed if there are multiple PHYs with the same address connected to the same MDIO bus adepter, or if there is insufficient electrical drive capability for all the connected PHY devices.
Conceptually it could look something like this:
...
Quoted 7 lines
This framework configures the bus topology from device tree data. The mechanics of switching the multiplexer is left to device specific drivers.
The follow-on patch contains a multiplexer driven by GPIO lines.
Signed-off-by David Daney <[email protected]>
Applied.
PATCH v6 3/3 netdev/of/phy: Add MDIO bus multiplexer driven by GPIO lines.
In reply to David DaneyFrom: David Daney <david.daney-YGCgFSpz5w/[email protected]>
The GPIO pins select which sub bus is connected to the master.
Initially tested with an sn74cbtlv3253 switch device wired into the MDIO bus.
--- .../devicetree/bindings/net/mdio-mux-gpio.txt | 127 +++++++++++++++++ drivers/net/phy/Kconfig | 10 ++ drivers/net/phy/Makefile | 1 + drivers/net/phy/mdio-mux-gpio.c | 142 ++++++++++++++++++++ 4 files changed, 280 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/net/mdio-mux-gpio.txt create mode 100644 drivers/net/phy/mdio-mux-gpio.c
Documentation/devicetree/bindings/net/mdio-mux-gpio.txt new file +127 -0
@@ -0,0 +1,127 @@ +Properties for an MDIO bus multiplexer/switch controlled by GPIO pins. + +This is a special case of a MDIO bus multiplexer. One or more GPIO +lines are used to control which child bus is connected. + +Required properties in addition to the generic multiplexer properties: + +- compatible : mdio-mux-gpio. +- gpios : GPIO specifiers for each GPIO line. One or more must be specified. + + +Example : + + /* The parent MDIO bus. */ + smi1: mdio@1180000001900 { + compatible = "cavium,octeon-3860-mdio"; + #address-cells = <1>; + #size-cells = <0>; + reg = <0x11800 0x00001900 0x0 0x40>; + }; + + /* + An NXP sn74cbtlv3253 dual 1-of-4 switch controlled by a + pair of GPIO lines. Child busses 2 and 3 populated with 4 + PHYs each. + */ + mdio-mux { + compatible = "mdio-mux-gpio"; + gpios = <&gpio1 3 0>, <&gpio1 4 0>; + mdio-parent-bus = <&smi1>; + #address-cells = <1>; + #size-cells = <0>; + + mdio@2 { + reg = <2>; + #address-cells = <1>; + #size-cells = <0>; + + phy11: ethernet-phy@1 { + reg = <1>; + compatible = "marvell,88e1149r"; + marvell,reg-init = <3 0x10 0 0x5777>, + <3 0x11 0 0x00aa>, + <3 0x12 0 0x4105>, + <3 0x13 0 0x0a60>; + interrupt-parent = <&gpio>; + interrupts = <10 8>; /* Pin 10, active low */ + }; + phy12: ethernet-phy@2 { + reg = <2>; + compatible = "marvell,88e1149r"; + marvell,reg-init = <3 0x10 0 0x5777>, + <3 0x11 0 0x00aa>, + <3 0x12 0 0x4105>, + <3 0x13 0 0x0a60>; + interrupt-parent = <&gpio>; + interrupts = <10 8>; /* Pin 10, active low */ + }; + phy13: ethernet-phy@3 { + reg = <3>; + compatible = "marvell,88e1149r"; + marvell,reg-init = <3 0x10 0 0x5777>, + <3 0x11 0 0x00aa>, + <3 0x12 0 0x4105>, + <3 0x13 0 0x0a60>; + interrupt-parent = <&gpio>; + interrupts = <10 8>; /* Pin 10, active low */ + }; + phy14: ethernet-phy@4 { + reg = <4>; + compatible = "marvell,88e1149r"; + marvell,reg-init = <3 0x10 0 0x5777>, + <3 0x11 0 0x00aa>, + <3 0x12 0 0x4105>, + <3 0x13 0 0x0a60>; + interrupt-parent = <&gpio>; + interrupts = <10 8>; /* Pin 10, active low */ + }; + }; + + mdio@3 { + reg = <3>; + #address-cells = <1>; + #size-cells = <0>; + + phy21: ethernet-phy@1 { + reg = <1>; + compatible = "marvell,88e1149r"; + marvell,reg-init = <3 0x10 0 0x5777>, + <3 0x11 0 0x00aa>, + <3 0x12 0 0x4105>, + <3 0x13 0 0x0a60>; + interrupt-parent = <&gpio>; + interrupts = <12 8>; /* Pin 12, active low */ + }; + phy22: ethernet-phy@2 { + reg = <2>; + compatible = "marvell,88e1149r"; + marvell,reg-init = <3 0x10 0 0x5777>, + <3 0x11 0 0x00aa>, + <3 0x12 0 0x4105>, + <3 0x13 0 0x0a60>; + interrupt-parent = <&gpio>; + interrupts = <12 8>; /* Pin 12, active low */ + }; + phy23: ethernet-phy@3 { + reg = <3>; + compatible = "marvell,88e1149r"; + marvell,reg-init = <3 0x10 0 0x5777>, + <3 0x11 0 0x00aa>, + <3 0x12 0 0x4105>, + <3 0x13 0 0x0a60>; + interrupt-parent = <&gpio>; + interrupts = <12 8>; /* Pin 12, active low */ + }; + phy24: ethernet-phy@4 { + reg = <4>; + compatible = "marvell,88e1149r"; + marvell,reg-init = <3 0x10 0 0x5777>, + <3 0x11 0 0x00aa>, + <3 0x12 0 0x4105>, + <3 0x13 0 0x0a60>; + interrupt-parent = <&gpio>; + interrupts = <12 8>; /* Pin 12, active low */ + }; + }; + };
drivers/net/phy/Kconfig +10 -0
@@ -144,6 +144,16 @@ config MDIO_BUS_MUX to a parent bus. Switching between child busses is done by device specific drivers. +config MDIO_BUS_MUX_GPIO + tristate "Support for GPIO controlled MDIO bus multiplexers" + depends on OF_GPIO && OF_MDIO + select MDIO_BUS_MUX + help + This module provides a driver for MDIO bus multiplexers that + are controlled via GPIO lines. The multiplexer connects one of + several child MDIO busses to a parent bus. Child bus + selection is under the control of GPIO lines. + endif # PHYLIB config MICREL_KS8995MA
drivers/net/phy/Makefile +1 -0
@@ -26,3 +26,4 @@ obj-$(CONFIG_MDIO_OCTEON) += mdio-octeon.o obj-$(CONFIG_MICREL_KS8995MA) += spi_ks8995.o obj-$(CONFIG_AMD_PHY) += amd.o obj-$(CONFIG_MDIO_BUS_MUX) += mdio-mux.o +obj-$(CONFIG_MDIO_BUS_MUX_GPIO) += mdio-mux-gpio.o
drivers/net/phy/mdio-mux-gpio.c new file +142 -0
142 lines not on this page · raw message
Signature · 1 line
1.7.2.3
Re: [PATCH v6 3/3] netdev/of/phy: Add MDIO bus multiplexer driven by GPIO lines.
From: David Daney <[email protected]>
Date: Wed, 2 May 2012 18:16:39 -0700
Quoted 8 lines
From: David Daney <[email protected]>
The GPIO pins select which sub bus is connected to the master.
Initially tested with an sn74cbtlv3253 switch device wired into the MDIO bus.
Signed-off-by David Daney <[email protected]>
Applied.
Quoted 6 lines · David Daney
From: David Daney <[email protected]>
This code has been working well for about six months on a couple of different configurations (boards), so I thought it would be a good time to send it out again, and I hope get it on the path towards merging.
David,
I'm trying to implement this feature on our boards, which don't use GPIOs but rather a memory-mapped FPGA. I control the mux by setting some bits in one of the FPGA registers.
Do you have a real device tree I can use as an example?
I'm not sure what the "parent" MDIO bus node is supposed to represent.
Is that that device that actually controls the muxing hardware, which
in our case would be the FPGA?
Signature · 2 lines
Timur Tabi Linux kernel developer at Freescale
Quoted 8 lines · On 05/18/2012 02:42 PM, Tabi Timur-B04825 wrote:
Quoted 6 lines · David Daney
From: David Daney<[email protected]>
This code has been working well for about six months on a couple of different configurations (boards), so I thought it would be a good time to send it out again, and I hope get it on the path towards merging.
Quoted 5 lines
David,
I'm trying to implement this feature on our boards, which don't use GPIOs but rather a memory-mapped FPGA. I control the mux by setting some bits in one of the FPGA registers.
You can either:
1) write a standard GPIO driver for the thing that controls the mux, and then use mdio-mux-gpio.c, or...
2) Write a new driver modeled on mdio-mux-gpio.c for your switch control.
Quoted 3 lines
Do you have a real device tree I can use as an example?
Attached.
Quoted 2 lines
I'm not sure what the "parent" MDIO bus node is supposed to represent.
Is that that device that actually controls the muxing hardware
No. It is the device that implements the master 802.3 clause {22,45} MDIO Station Management (STA) protocol.
Quoted 1 line
, which in our case would be the FPGA?
I have no idea what your FPGA implements, so it is hard to say.
A sane person would implement a separate MDIO STA controller for each bus, in which case you wouldn't use the multiplexer driver.
Only people dealing with insane hardware need the multiplexer. The patch in net-next has a nice ASCII art picture of such an insane design.
David Daney
Quoted 5 lines · David Daney
Quoted 2 lines
Quoted 2 lines
I'm not sure what the "parent" MDIO bus node is supposed to represent.
Is that that device that actually controls the muxing hardwareNo. It is the device that implements the master 802.3 clause {22,45} MDIO Station Management (STA) protocol.
Ah, I think I get it. It is *the* MDIO node that would normally exist if muxing we're necessary on the board. From the looks of it, that node would look exactly the same if you didn't need muxing?
Signature · 2 lines
Timur Tabi Linux kernel developer at Freescale
Quoted 11 lines · Timur Tabi
Quoted 5 lines · David Daney
Quoted 2 lines
Quoted 2 lines
I'm not sure what the "parent" MDIO bus node is supposed to represent.
Is that that device that actually controls the muxing hardwareNo. It is the device that implements the master 802.3 clause {22,45} MDIO Station Management (STA) protocol.
Ah, I think I get it. It is *the* MDIO node that would normally exist if muxing we're necessary on the board. From the looks of it, that node would look exactly the same if you didn't need muxing?
Yes. You may note in the DTS file I attached in the parent (sorry for the fubar mime types), that there are two, almost identical, MDIO masters. smi0 has two directly attached PHYs. smi1 goes to the mux, and each child of the mux has four attached PHYs.
This is a fairly complex configuration as the GPIOs controlling the MDIO mux are on I2C GPIO expanders which are themselves behind an I2C mux...
The nice thing about this is that the Linux I2C and MDIO infrastructure is all configured dynamically from the device tree and everything works well together with no locking issues. The addition of the deferred driver probe mechanism was the last part of the puzzle (I think... actually I don't know if all my I2C things are merged yet...).
David Daney
Quoted 4 lines · David Daney
Yes. You may note in the DTS file I attached in the parent (sorry for the fubar mime types), that there are two, almost identical, MDIO masters. smi0 has two directly attached PHYs. smi1 goes to the mux, and each child of the mux has four attached PHYs.
I'm till have trouble understanding all this. I'm just hacking things up in order to help me understand it, but it's a slow and painful process.
This call in mdio_mux_init() is failing:
parent_bus = of_mdio_find_bus(parent_bus_node);
It returns NULL. Here is my MDIO node:
fman0: fman@400000 {
enet0: ethernet@e0000 {
tbi-handle = <&tbi0>;
phy-handle = <&phy0>;
phy-connection-type = "sgmii";
};
mdio0: mdio@e1120 {
gpios = <&gpio0 0 0
&gpio0 1 0>;
tbi0: tbi-phy@8 {
reg = <0x8>;
device_type = "tbi-phy";
};
phy0: ethernet-phy@1c {
reg = <0x1c>;
};
};
};What am I missing? What do I need to do in order to get of_mdio_find_bus() to return a real value?
Signature · 2 lines
Timur Tabi Linux kernel developer at Freescale
Quoted 6 lines · Timur Tabi
Quoted 4 lines · David Daney
Yes. You may note in the DTS file I attached in the parent (sorry for the fubar mime types), that there are two, almost identical, MDIO masters. smi0 has two directly attached PHYs. smi1 goes to the mux, and each child of the mux has four attached PHYs.
Quoted 7 lines
I'm till have trouble understanding all this. I'm just hacking things up in order to help me understand it, but it's a slow and painful process.
This call in
mdio_mux_init()is failing:parent_bus = of_mdio_find_bus(parent_bus_node);
Well, the MDIO bus must have an associated device tree node.
For my OCTEON code, the MDIO bus device is created as a result of the call to of_platform_bus_probe(), which takes care of filling in all the device tree nodes of the devices it finds and creates.
Quoted 24 lines
It returns NULL. Here is my MDIO node:
fman0: fman@400000 { enet0: ethernet@e0000 { tbi-handle =<&tbi0>; phy-handle =<&phy0>; phy-connection-type = "sgmii"; }; mdio0: mdio@e1120 { gpios =<&gpio0 0 0 &gpio0 1 0>; tbi0: tbi-phy@8 { reg =<0x8>; device_type = "tbi-phy"; }; phy0: ethernet-phy@1c { reg =<0x1c>; }; }; };
Quoted 1 line
What am I missing?
For starters, I do not see any compatible properties that would allow the proper drivers to be bound to anything.
Also I see no MDIO mux node there, so it is unclear why you are even asking these questions.
David Daney
Quoted 5 lines · David Daney
Well, the MDIO bus must have an associated device tree node.
For my OCTEON code, the MDIO bus device is created as a result of the call to
of_platform_bus_probe(), which takes care of filling in all the device tree nodes of the devices it finds and creates.
Ok, let me give you some background. We actually already have MDIO muxing code in-house, but it's different from yours. So now I'm rewriting it to use your design instead.
So our current code looks for "virtual MDIO nodes", and we call mdiobus_alloc() and then of_mdiobus_register(). I think this is what I'm missing now.
I just don't know what to do next. Part of the problem is that I don't have much experience with MDIO drivers.
Quoted 24 lines
Quoted 24 lines
It returns NULL. Here is my MDIO node:
fman0: fman@400000 { enet0: ethernet@e0000 { tbi-handle =<&tbi0>; phy-handle =<&phy0>; phy-connection-type = "sgmii"; }; mdio0: mdio@e1120 { gpios =<&gpio0 0 0 &gpio0 1 0>; tbi0: tbi-phy@8 { reg =<0x8>; device_type = "tbi-phy"; }; phy0: ethernet-phy@1c { reg =<0x1c>; }; }; };
Quoted 4 lines
Quoted 1 line
What am I missing?
For starters, I do not see any compatible properties that would allow the proper drivers to be bound to anything.
Ok, that makes sense.
Quoted 2 lines
Also I see no MDIO mux node there, so it is unclear why you are even asking these questions.
I only gave you part of the device tree. Here's my mdio mux node:
mdio-mux {
compatible = "mdio-mux-gpio";
gpios = <&gpio0 0 0>, <&gpio0 1 0>;
mdio-parent-bus = <&mdio0>;
#address-cells = <1>;
#size-cells = <0>;
mdio@2 {
reg = <2>;
#address-cells = <1>;
#size-cells = <0>;
phy21: ethernet-phy@1 {
reg = <1>;
// compatible = "marvell,88e1149r", "ethernet-phy-ieee802.3-c22";
marvell,reg-init = <3 0x10 0 0x5777>,
<3 0x11 0 0x00aa>,
<3 0x12 0 0x4105>,
<3 0x13 0 0x0a60>;
interrupt-parent = <&gpio0>;
// interrupts = <10 8>; /* Pin 10, active low */
};
};
};
};Quoted 3 lines
David Daney
Signature · 2 lines
Timur Tabi Linux kernel developer at Freescale
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 12 lines · Timur Tabi
Quoted 5 lines · David Daney
Well, the MDIO bus must have an associated device tree node.
For my OCTEON code, the MDIO bus device is created as a result of the call to
of_platform_bus_probe(), which takes care of filling in all the device tree nodes of the devices it finds and creates.Ok, let me give you some background. We actually already have MDIO muxing code in-house, but it's different from yours. So now I'm rewriting it to use your design instead.
Quoted 5 lines
So our current code looks for "virtual MDIO nodes", and we call
mdiobus_alloc()and thenof_mdiobus_register(). I think this is what I'm missing now.I just don't know what to do next.
You will have to debug it and find out why the device match is failing, then fix it.
David Daney