Skip to contentSkip to conversation

doc: bindings: Add description for MDIO MUX dts nodes

PATCH Superseded Alex Marginean 2 participants 4 messages Jun 18, 2019 1 message not in the archive Network drivers

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 2/4 doc: bindings: Add description for MDIO MUX dts nodes

Adds a short bindings document describing the expected structure of a MDIO MUX dts node. This is based on Linux binding and the example is in fact copied from there.

---
 doc/device-tree-bindings/net/mdio-mux.txt | 61 +++++++++++++++++++++++
 1 file changed, 61 insertions(+)
 create mode 100644 doc/device-tree-bindings/net/mdio-mux.txt
doc/device-tree-bindings/net/mdio-mux.txt new file +61 -0
new file mode 100644
index 0000000000..fdf817fd93
@@ -0,0 +1,61 @@
+The expected structure of an MDIO MUX device tree node is described here.  This
+is heavily based on current Linux specification.
+The MDIO buses downstream of the MUX should be described in the device tree as
+child nodes as indicated below.
+
+Required properties:
+mdio-parent-bus = a phandle to the MDIO bus used to perform actual I/O.  This is
+                  typically a real MDIO device, unless there are cascaded MUXes.
+#address-cells = <1>, each MDIO group is identified by one 32b value.
+#size-cells = <0>
+
+Other properties:
+The properties described here are sufficient for MDIO MUX DM class code, but
+MUX drivers may define additional properties, either required or optional.
+
+Required properties in child nodes:
+reg = value to be configured on the MUX to select the respective downstream
+      MDIO.
+
+Child nodes should normally contain PHY nodes, referenced by phandle from
+ethernet nodes of the eth interfaces using these PHYs.
+
+Example structure, extracted from Linux bindings document:
+
+	/* The parent MDIO bus. */
+	smi1: mdio at 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 at 2 {
+			reg = <2>;
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			phy11: ethernet-phy at 1 {
+				reg = <1>;
+				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 */
+			};
+		};
+	};
+
Signature · 1 line
2.17.1
#2 lore raw

PATCH 2/4 doc: bindings: Add description for MDIO MUX dts nodes

It looks like the first patch didn't make it through, blocked by google. Sorry about that I'll try to resend the series.

Does anyone else have issues with gmail blocking patches and emails? Any suggestions on how to get them through safely?

Sorry for the spam.
Alex

Quoted 78 lines · Alex Marginean

Adds a short bindings document describing the expected structure of a MDIO MUX dts node. This is based on Linux binding and the example is in fact copied from there.

---
  doc/device-tree-bindings/net/mdio-mux.txt | 61 +++++++++++++++++++++++
  1 file changed, 61 insertions(+)

create mode 100644 doc/device-tree-bindings/net/mdio-mux.txt

doc/device-tree-bindings/net/mdio-mux.txt new file +61 -0
new file mode 100644
index 0000000000..fdf817fd93
@@ -0,0 +1,61 @@
+The expected structure of an MDIO MUX device tree node is described here.  This
+is heavily based on current Linux specification.
+The MDIO buses downstream of the MUX should be described in the device tree as
+child nodes as indicated below.
+
+Required properties:
+mdio-parent-bus = a phandle to the MDIO bus used to perform actual I/O.  This is
+                  typically a real MDIO device, unless there are cascaded MUXes.
+#address-cells = <1>, each MDIO group is identified by one 32b value.
+#size-cells = <0>
+
+Other properties:
+The properties described here are sufficient for MDIO MUX DM class code, but
+MUX drivers may define additional properties, either required or optional.
+
+Required properties in child nodes:
+reg = value to be configured on the MUX to select the respective downstream
+      MDIO.
+
+Child nodes should normally contain PHY nodes, referenced by phandle from
+ethernet nodes of the eth interfaces using these PHYs.
+
+Example structure, extracted from Linux bindings document:
+
+	/* The parent MDIO bus. */
+	smi1: mdio at 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 at 2 {
+			reg = <2>;
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			phy11: ethernet-phy at 1 {
+				reg = <1>;
+				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 */
+			};
+		};
+	};
+
#3 lore raw

PATCH 3/4 test: dm_mdio: add a 2nd register to the emulated PHY

In reply to a message not in the archive

This 2nd register is used by the follow-up MDIO MUX test.

---
 drivers/net/mdio_sandbox.c | 16 +++++++++-------
 test/dm/mdio.c             |  3 +++
 2 files changed, 12 insertions(+), 7 deletions(-)
drivers/net/mdio_sandbox.c +9 -7
index 07515e078c..df053f5381 100644
@@ -9,11 +9,11 @@
 #include <miiphy.h>
 
 #define SANDBOX_PHY_ADDR	5
-#define SANDBOX_PHY_REG		0
+#define SANDBOX_PHY_REG_CNT	2
 
 struct mdio_sandbox_priv {
 	int enabled;
-	u16 reg;
+	u16 reg[SANDBOX_PHY_REG_CNT];
 };
 
 static int mdio_sandbox_read(struct udevice *dev, int addr, int devad, int reg)
@@ -27,10 +27,10 @@ static int mdio_sandbox_read(struct udevice *dev, int addr, int devad, int reg)
 		return -ENODEV;
 	if (devad != MDIO_DEVAD_NONE)
 		return -ENODEV;
-	if (reg != SANDBOX_PHY_REG)
+	if (reg < 0 || reg > SANDBOX_PHY_REG_CNT)
 		return -ENODEV;
 
-	return priv->reg;
+	return priv->reg[reg];
 }
 
 static int mdio_sandbox_write(struct udevice *dev, int addr, int devad, int reg,
@@ -45,10 +45,10 @@ static int mdio_sandbox_write(struct udevice *dev, int addr, int devad, int reg,
 		return -ENODEV;
 	if (devad != MDIO_DEVAD_NONE)
 		return -ENODEV;
-	if (reg != SANDBOX_PHY_REG)
+	if (reg < 0 || reg > SANDBOX_PHY_REG_CNT)
 		return -ENODEV;
 
-	priv->reg = val;
+	priv->reg[reg] = val;
 
 	return 0;
 }
@@ -56,8 +56,10 @@ static int mdio_sandbox_write(struct udevice *dev, int addr, int devad, int reg,
 static int mdio_sandbox_reset(struct udevice *dev)
 {
 	struct mdio_sandbox_priv *priv = dev_get_priv(dev);
+	int i;
 
-	priv->reg = 0;
+	for (i = 0; i < SANDBOX_PHY_REG_CNT; i++)
+		priv->reg[i] = 0;
 
 	return 0;
 }
test/dm/mdio.c +3 -0
index 5b66255f7d..dc229aed6d 100644
@@ -13,6 +13,9 @@
 
 /* macros copied over from mdio_sandbox.c */
 #define SANDBOX_PHY_ADDR	5
+#define SANDBOX_PHY_REG_CNT	2
+
+/* test using 1st register, 0 */
 #define SANDBOX_PHY_REG		0
 
 #define TEST_REG_VALUE		0xabcd
Signature · 1 line
2.17.1
#4 lore raw

PATCH 4/4 test: dm: add a test for MDIO MUX DM uclass

In reply to a message not in the archive

Adds a test using a makeshift MDIO MUX. The test is based on the existing MDIO test. It uses the last emulated PHY register to verify MUX selection.

---
 arch/Kconfig                   |  1 +
 arch/sandbox/dts/test.dts      | 21 +++++++-
 drivers/net/Kconfig            | 10 ++++
 drivers/net/Makefile           |  1 +
 drivers/net/mdio_mux_sandbox.c | 97 ++++++++++++++++++++++++++++++++++
 test/dm/Makefile               |  1 +
 test/dm/mdio_mux.c             | 80 ++++++++++++++++++++++++++++
 7 files changed, 210 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/mdio_mux_sandbox.c
 create mode 100644 test/dm/mdio_mux.c
arch/Kconfig +1 -0
index 1e62a7615d..1a0f1ab8a7 100644
@@ -122,6 +122,7 @@ config SANDBOX
 	imply PCH
 	imply PHYLIB
 	imply DM_MDIO
+	imply DM_MDIO_MUX
 
 config SH
 	bool "SuperH architecture"
arch/sandbox/dts/test.dts +20 -1
index dd50a951a8..a05e437abf 100644
@@ -808,7 +808,26 @@
 		dma-names = "m2m", "tx0", "rx0";
 	};
 
-	mdio-test {
+	/*
+	 * keep mdio-mux ahead of mdio, u-boot doesn't do reference count on
+	 * these devices and we don't want mdio-parent-bus to be released before
+	 * the mux.
+	 */
+	mdio-mux-test {
+		compatible = "sandbox,mdio-mux";
+		#address-cells = <1>;
+		#size-cells = <0>;
+		mdio-parent-bus = <&mdio>;
+
+		mdio-ch-test at 0 {
+			reg = <0>;
+		};
+		mdio-ch-test at 1 {
+			reg = <1>;
+		};
+	};
+
+	mdio: mdio-test {
 		compatible = "sandbox,mdio";
 	};
 };
drivers/net/Kconfig +10 -0
index 0dc26ac254..403df5e960 100644
@@ -46,6 +46,16 @@ config MDIO_SANDBOX
 
 	  This driver is used in for testing in test/dm/mdio.c
 
+config MDIO_MUX_SANDBOX
+	depends on DM_MDIO_MUX && MDIO_SANDBOX
+	default y
+	bool "Sandbox: Mocked MDIO-MUX driver"
+	help
+	  This driver implements dummy select/deselect ops mimicking a MUX on
+	  the MDIO bux.  It uses mdio_sandbox driver as parent MDIO.
+
+	  This driver is used for testing in test/dm/mdio.c
+
 menuconfig NETDEVICES
 	bool "Network device support"
 	depends on NET
drivers/net/Makefile +1 -0
index 40038427db..a3706ca27b 100644
@@ -78,3 +78,4 @@ obj-$(CONFIG_MEDIATEK_ETH) += mtk_eth.o
 obj-y += mscc_eswitch/
 obj-$(CONFIG_HIGMACV300_ETH) += higmacv300.o
 obj-$(CONFIG_MDIO_SANDBOX) += mdio_sandbox.o
+obj-$(CONFIG_MDIO_MUX_SANDBOX) += mdio_mux_sandbox.o
drivers/net/mdio_mux_sandbox.c new file +97 -0

97 lines not on this page · raw message

test/dm/Makefile +1 -0
index 3f042e3ab4..8b3477c136 100644
@@ -61,4 +61,5 @@ obj-$(CONFIG_TEE) += tee.o
 obj-$(CONFIG_VIRTIO_SANDBOX) += virtio.o
 obj-$(CONFIG_DMA) += dma.o
 obj-$(CONFIG_DM_MDIO) += mdio.o
+obj-$(CONFIG_DM_MDIO_MUX) += mdio_mux.o
 endif
test/dm/mdio_mux.c new file +80 -0

80 lines not on this page · raw message

Signature · 1 line
2.17.1