The switch devices are component slaves. Such devices have a "switch" property in the DSA device tree which is a phandle to the switch device. When the slaves bind they register to DSA. So the DSA can match the switch to the correct switch instance in the device tree, keep a reference to the device tree node during parsing of the device tree.
Signed-off-by: Andrew Lunn <and...@lunn.ch> --- Documentation/devicetree/bindings/net/dsa/dsa.txt | 2 ++ include/net/dsa.h | 3 +++ net/dsa/dsa.c | 6 +++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/net/dsa/dsa.txt b/Documentation/devicetree/bindings/net/dsa/dsa.txt index 5fdbbcdf8c4b..f99e5694a61f 100644 --- a/Documentation/devicetree/bindings/net/dsa/dsa.txt +++ b/Documentation/devicetree/bindings/net/dsa/dsa.txt @@ -27,6 +27,8 @@ Each of these switch child nodes should have the following required properties: A switch child node has the following optional property: +- switch : A phandle to a switch device. + - eeprom-length : Set to the length of an EEPROM connected to the switch. Must be set if the switch can not detect the presence and/or size of a connected EEPROM, diff --git a/include/net/dsa.h b/include/net/dsa.h index f6b8001a500f..ea4cfdf1b549 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -48,6 +48,9 @@ struct dsa_chip_data { */ struct device_node *of_node; + /* Device tree node pointer for the switch chip device. */ + struct device_node *of_chip; + /* * The names of the switch's ports. Use "cpu" to * designate the switch port that the cpu is connected to, diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c index a139c35061a1..f2af801554ec 100644 --- a/net/dsa/dsa.c +++ b/net/dsa/dsa.c @@ -662,7 +662,7 @@ static void dsa_of_free_platform_data(struct dsa_platform_data *pd) static int dsa_of_probe(struct device *dev, struct dsa_platform_data *pd) { struct device_node *np = dev->of_node; - struct device_node *child, *mdio, *ethernet, *port; + struct device_node *child, *chip, *mdio, *ethernet, *port; struct mii_bus *mdio_bus, *mdio_bus_switch; struct net_device *ethernet_dev; struct dsa_chip_data *cd; @@ -712,6 +712,10 @@ static int dsa_of_probe(struct device *dev, struct dsa_platform_data *pd) cd->of_node = child; + chip = of_parse_phandle(child, "switch", 0); + if (chip) + cd->of_chip = chip; + /* When assigning the host device, increment its refcount */ cd->host_dev = get_device(&mdio_bus->dev); -- 2.7.0