Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 169fbdc6 authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'dsa-new-binding'



Andrew Lunn says:

====================
New DSA bind, switches as devices

The interesting patches here are the last three. They implement a new
binding for DSA, which removes a few limitations of the current DSA
binding. In particular, it allows switches to be true Linux devices.
These devices can be on any type of bus, unlike the old DSA binding
which assumes MDIO. See the commit log for more details. The second to
last patch modifies an existing boards device tree to use the new
binding, giving a good example of how switches can be true MDIO
devices. The last patch documents the new binding.

Thanks go to Florian and Vivien for reviewing, testing and bug fixing
these patches.

Tested-by: default avatarVivien Didelot <vivien.didelot@savoirfairelinux.com>
Tested-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>

Since V1:

* Add lots of reviewed-by's
* Fix rtable comment
* dsa2: Clear cpu port mask in dsa_cpu_port_unapply()
* dsa2: Only set dsa_port_mask when port successfully configured
* dsa: clear {dsa|cpu}_port_mask on destroy

Since RFC:

* Split the mv88e6xxx MDIO refactor into a rename patch and a refactor
  patch.
* Extend commit message with comment about wrong of_node_put()
* Fix destroy of cpu and dsa ports.
* Rename _DSA_TAG_LAST to DSA_TAG_LAST and add a comment.
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 76f21b99 8c5ad1d6
Loading
Loading
Loading
Loading
+276 −2
Original line number Diff line number Diff line
Marvell Distributed Switch Architecture Device Tree Bindings
------------------------------------------------------------
Distributed Switch Architecture Device Tree Bindings
----------------------------------------------------

Two bindings exist, one of which has been deprecated due to
limitations.

Current Binding
---------------

Switches are true Linux devices and can be probes by any means. Once
probed, they register to the DSA framework, passing a node
pointer. This node is expected to fulfil the following binding, and
may contain additional properties as required by the device it is
embedded within.

Required properties:

- ports		: A container for child nodes representing switch ports.

Optional properties:

- dsa,member	: A two element list indicates which DSA cluster, and position
		  within the cluster a switch takes. <0 0> is cluster 0,
		  switch 0. <0 1> is cluster 0, switch 1. <1 0> is cluster 1,
		  switch 0. A switch not part of any cluster (single device
		  hanging off a CPU port) must not specify this property

The ports container has the following properties

Required properties:

- #address-cells	: Must be 1
- #size-cells		: Must be 0

Each port children node must have the following mandatory properties:
- reg			: Describes the port address in the switch
- label			: Describes the label associated with this port, which
                          will become the netdev name. Special labels are
			  "cpu" to indicate a CPU port and "dsa" to
			  indicate an uplink/downlink port between switches in
			  the cluster.

A port labelled "dsa" has the following mandatory property:

- link			: Should be a list of phandles to other switch's DSA
			  port. This port is used as the outgoing port
			  towards the phandle ports. The full routing
			  information must be given, not just the one hop
			  routes to neighbouring switches.

A port labelled "cpu" has the following mandatory property:

- ethernet		: Should be a phandle to a valid Ethernet device node.
                          This host device is what the switch port is
			  connected to.

Port child nodes may also contain the following optional standardised
properties, described in binding documents:

- phy-handle		: Phandle to a PHY on an MDIO bus. See
			  Documentation/devicetree/bindings/net/ethernet.txt
			  for details.

- phy-mode		: See
			  Documentation/devicetree/bindings/net/ethernet.txt
			  for details.

- fixed-link		: Fixed-link subnode describing a link to a non-MDIO
			  managed entity. See
			  Documentation/devicetree/bindings/net/fixed-link.txt
			  for details.

Example

The following example shows three switches on three MDIO busses,
linked into one DSA cluster.

&mdio1 {
	#address-cells = <1>;
	#size-cells = <0>;

	switch0: switch0@0 {
		compatible = "marvell,mv88e6085";
		#address-cells = <1>;
		#size-cells = <0>;
		reg = <0>;

		dsa,member = <0 0>;

		ports {
			#address-cells = <1>;
			#size-cells = <0>;
			port@0 {
				reg = <0>;
				label = "lan0";
			};

			port@1 {
				reg = <1>;
				label = "lan1";
			};

			port@2 {
				reg = <2>;
				label = "lan2";
			};

			switch0port5: port@5 {
				reg = <5>;
				label = "dsa";
				phy-mode = "rgmii-txid";
				link = <&switch1port6
					&switch2port9>;
				fixed-link {
					speed = <1000>;
					full-duplex;
				};
			};

			port@6 {
				reg = <6>;
				label = "cpu";
				ethernet = <&fec1>;
				fixed-link {
					speed = <100>;
					full-duplex;
				};
			};
		};
	};
};

&mdio2 {
	#address-cells = <1>;
	#size-cells = <0>;

	switch1: switch1@0 {
		compatible = "marvell,mv88e6085";
		#address-cells = <1>;
		#size-cells = <0>;
		reg = <0>;

		dsa,member = <0 1>;

		ports {
			#address-cells = <1>;
			#size-cells = <0>;
			port@0 {
				reg = <0>;
				label = "lan3";
				phy-handle = <&switch1phy0>;
			};

			port@1 {
				reg = <1>;
				label = "lan4";
				phy-handle = <&switch1phy1>;
			};

			port@2 {
				reg = <2>;
				label = "lan5";
				phy-handle = <&switch1phy2>;
			};

			switch1port5: port@5 {
				reg = <5>;
				label = "dsa";
				link = <&switch2port9>;
				phy-mode = "rgmii-txid";
				fixed-link {
					speed = <1000>;
					full-duplex;
				};
			};

			switch1port6: port@6 {
				reg = <6>;
				label = "dsa";
				phy-mode = "rgmii-txid";
				link = <&switch0port5>;
				fixed-link {
					speed = <1000>;
					full-duplex;
				};
			};
		};
		mdio-bus {
			#address-cells = <1>;
			#size-cells = <0>;
			switch1phy0: switch1phy0@0 {
				reg = <0>;
			};
			switch1phy1: switch1phy0@1 {
				reg = <1>;
			};
			switch1phy2: switch1phy0@2 {
				reg = <2>;
			};
		};
	 };
};

&mdio4 {
	#address-cells = <1>;
	#size-cells = <0>;

	switch2: switch2@0 {
		compatible = "marvell,mv88e6085";
		#address-cells = <1>;
		#size-cells = <0>;
		reg = <0>;

		dsa,member = <0 2>;

		ports {
			#address-cells = <1>;
			#size-cells = <0>;
			port@0 {
				reg = <0>;
				label = "lan6";
			};

			port@1 {
				reg = <1>;
				label = "lan7";
			};

			port@2 {
				reg = <2>;
				label = "lan8";
			};

			port@3 {
				reg = <3>;
				label = "optical3";
				fixed-link {
					speed = <1000>;
					full-duplex;
					link-gpios = <&gpio6 2
					      GPIO_ACTIVE_HIGH>;
				};
			};

			port@4 {
				reg = <4>;
				label = "optical4";
				fixed-link {
					speed = <1000>;
					full-duplex;
					link-gpios = <&gpio6 3
					      GPIO_ACTIVE_HIGH>;
				};
			};

			switch2port9: port@9 {
				reg = <9>;
				label = "dsa";
				phy-mode = "rgmii-txid";
				link = <&switch1port5
					&switch0port5>;
				fixed-link {
					speed = <1000>;
					full-duplex;
				};
			};
		};
	};
};

Deprecated Binding
------------------

The deprecated binding makes use of a platform device to represent the
switches. The switches themselves are not Linux devices, and make use
of an MDIO bus for management.

Required properties:
- compatible		: Should be "marvell,dsa"
+170 −158
Original line number Diff line number Diff line
@@ -85,41 +85,17 @@
			reg = <1>;
			#address-cells = <1>;
			#size-cells = <0>;
		};

		mdio_mux_2: mdio@2 {
			reg = <2>;
			#address-cells = <1>;
			#size-cells = <0>;
		};

		mdio_mux_4: mdio@4 {
			reg = <4>;
			switch0: switch0@0 {
				compatible = "marvell,mv88e6085";
				#address-cells = <1>;
				#size-cells = <0>;
		};

		mdio_mux_8: mdio@8 {
			reg = <8>;
			#address-cells = <1>;
			#size-cells = <0>;
		};
	};

	dsa {
		compatible = "marvell,dsa";
		#address-cells = <2>;
		#size-cells = <0>;
		dsa,ethernet = <&fec1>;
		dsa,mii-bus = <&mdio_mux_1>;
				reg = <0>;
				dsa,member = <0 0>;

		/* 6352 - Primary - 7 ports */
		switch0: switch@0-0 {
				ports {
					#address-cells = <1>;
					#size-cells = <0>;
			reg = <0x00 0>;
			eeprom-length = <512>;

					port@0 {
						reg = <0>;
						label = "lan0";
@@ -141,7 +117,6 @@
						phy-mode = "rgmii-txid";
						link = <&switch1port6
							&switch2port9>;

						fixed-link {
							speed = <1000>;
							full-duplex;
@@ -151,36 +126,47 @@
					port@6 {
						reg = <6>;
						label = "cpu";

						ethernet = <&fec1>;
						fixed-link {
							speed = <100>;
							full-duplex;
						};
					};

				};
			};
		};

		mdio_mux_2: mdio@2 {
			reg = <2>;
			#address-cells = <1>;
			#size-cells = <0>;

		/* 6352 - Secondary - 7 ports */
		switch1: switch@0-1 {
			switch1: switch1@0 {
				compatible = "marvell,mv88e6085";
				#address-cells = <1>;
				#size-cells = <0>;
			reg = <0x00 1>;
			eeprom-length = <512>;
			mii-bus = <&mdio_mux_2>;
				reg = <0>;
				dsa,member = <0 1>;

				ports {
					#address-cells = <1>;
					#size-cells = <0>;
					port@0 {
						reg = <0>;
						label = "lan3";
						phy-handle = <&switch1phy0>;
					};

					port@1 {
						reg = <1>;
						label = "lan4";
						phy-handle = <&switch1phy1>;
					};

					port@2 {
						reg = <2>;
						label = "lan5";
						phy-handle = <&switch1phy2>;
					};

					switch1port5: port@5 {
@@ -188,7 +174,6 @@
						label = "dsa";
						link = <&switch2port9>;
						phy-mode = "rgmii-txid";

						fixed-link {
							speed = <1000>;
							full-duplex;
@@ -200,21 +185,43 @@
						label = "dsa";
						phy-mode = "rgmii-txid";
						link = <&switch0port5>;

						fixed-link {
							speed = <1000>;
							full-duplex;
						};
					};
				};
				mdio {
					#address-cells = <1>;
					#size-cells = <0>;
					switch1phy0: switch1phy0@0 {
						reg = <0>;
					};
					switch1phy1: switch1phy0@1 {
						reg = <1>;
					};
					switch1phy2: switch1phy0@2 {
						reg = <2>;
					};
				};
			};
		};

		/* 6185 - 10 ports */
		switch2: switch@0-2 {
		mdio_mux_4: mdio@4 {
			#address-cells = <1>;
			#size-cells = <0>;
			reg = <0x00 2>;
			mii-bus = <&mdio_mux_4>;
			reg = <4>;

			switch2: switch2@0 {
				compatible = "marvell,mv88e6085";
				#address-cells = <1>;
				#size-cells = <0>;
				reg = <0>;
				dsa,member = <0 2>;

				ports {
					#address-cells = <1>;
					#size-cells = <0>;
					port@0 {
						reg = <0>;
						label = "lan6";
@@ -233,7 +240,6 @@
					port@3 {
						reg = <3>;
						label = "optical3";

						fixed-link {
							speed = <1000>;
							full-duplex;
@@ -245,7 +251,6 @@
					port@4 {
						reg = <4>;
						label = "optical4";

						fixed-link {
							speed = <1000>;
							full-duplex;
@@ -260,7 +265,6 @@
						phy-mode = "rgmii-txid";
						link = <&switch1port5
							&switch0port5>;

						fixed-link {
							speed = <1000>;
							full-duplex;
@@ -268,6 +272,14 @@
					};
				};
			};
		};

		mdio_mux_8: mdio@8 {
			reg = <8>;
			#address-cells = <1>;
			#size-cells = <0>;
		};
	};

	reg_vcc_3v3_mcu: regulator-vcc-3v3-mcu {
		compatible = "regulator-fixed";
+2 −2
Original line number Diff line number Diff line
@@ -804,7 +804,7 @@ static int bcm_sf2_sw_fdb_dump(struct dsa_switch *ds, int port,
			       int (*cb)(struct switchdev_obj *obj))
{
	struct bcm_sf2_priv *priv = ds_to_priv(ds);
	struct net_device *dev = ds->ports[port];
	struct net_device *dev = ds->ports[port].netdev;
	struct bcm_sf2_arl_entry results[2];
	unsigned int count = 0;
	int ret;
@@ -1248,7 +1248,7 @@ static void bcm_sf2_sw_fixed_link_update(struct dsa_switch *ds, int port,
		 * state machine and make it go in PHY_FORCING state instead.
		 */
		if (!status->link)
			netif_carrier_off(ds->ports[port]);
			netif_carrier_off(ds->ports[port].netdev);
		status->duplex = 1;
	} else {
		status->link = 1;
+175 −92

File changed.

Preview size limit exceeded, changes collapsed.

+6 −0
Original line number Diff line number Diff line
@@ -600,6 +600,12 @@ struct mv88e6xxx_priv_state {

	/* set to size of eeprom if supported by the switch */
	int		eeprom_len;

	/* Device node for the MDIO bus */
	struct device_node *mdio_np;

	/* And the MDIO bus itself */
	struct mii_bus *mdio_bus;
};

enum stat_type {
Loading