Skip to contentSkip to conversation

Marvell MDIO driver and new MDIO name property

PATCH Superseded Alex Marginean 6 participants 19 messages Jul 17, 2019 – Jul 24, 2019

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Marvell MDIO driver and new MDIO name property

This is a respin of the original Marvell MDIO driver submitted by Ken about one year ago, using the new MDIO DM code.
Added binding documents for mdio and marvell-mdio and introduced a new optional property for naming MDIO buses in case the driver can't reasonably pick a nice name by itself.

Alex Marginean (4):
net: mdio-uclass: name MDIO according to device-name property if
preset
doc: bindings: add mdio.txt describing generic MDIO properties
drivers: net: add marvell MDIO driver
arm: dts: Set custom names for cp110 master/slave MDIO buses

 arch/arm/dts/armada-cp110-master.dtsi         |   1 +
 arch/arm/dts/armada-cp110-slave.dtsi          |   1 +
 doc/device-tree-bindings/net/marvell-mdio.txt |  15 ++
 doc/device-tree-bindings/net/mdio.txt         |  36 +++
 drivers/net/Kconfig                           |  10 +
 drivers/net/Makefile                          |   1 +
 drivers/net/mvmdio.c                          | 236 ++++++++++++++++++
 net/mdio-uclass.c                             |  11 +
 8 files changed, 311 insertions(+)
 create mode 100644 doc/device-tree-bindings/net/marvell-mdio.txt
 create mode 100644 doc/device-tree-bindings/net/mdio.txt
 create mode 100644 drivers/net/mvmdio.c
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/4 net: mdio-uclass: name MDIO according to device-name property if preset

Use the optional property device-name to name the MDIO bus. This works around limitations with using the DT node name on devices such as Armada-8040, which integrates two cp100 cores, both featuring MDIOs at the same relative offsets and with the same DT node names.
The concept was originally proposed by Marvell as a custom property called mdio-name specific to Marvell driver. This patch uses the more generic property device-name and moves this into MDIO class code so other can use it as well.

---
 net/mdio-uclass.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
net/mdio-uclass.c +11 -0
index 36a404ff44..428f3a994f 100644
@@ -23,6 +23,17 @@ void dm_mdio_probe_devices(void)
 
 static int dm_mdio_post_bind(struct udevice *dev)
 {
+	const char *dt_name;
+
+	/* set a custom name for the MDIO device, if present in DT */
+	if (ofnode_valid(dev->node)) {
+		dt_name = ofnode_read_string(dev->node, "device-name");
+		if (dt_name) {
+			debug("renaming dev %s to %s\n", dev->name, dt_name);
+			device_set_name(dev, dt_name);
+		}
+	}
+
 	/*
 	 * MDIO command doesn't like spaces in names, don't allow them to keep
 	 * it happy
Signature · 1 line
2.17.1
#2 lore raw

PATCH 1/4 net: mdio-uclass: name MDIO according to device-name property if preset

Quoted 11 lines · Alex Marginean

Use the optional property device-name to name the MDIO bus. This works around limitations with using the DT node name on devices such as Armada-8040, which integrates two cp100 cores, both featuring MDIOs at the same relative offsets and with the same DT node names.
The concept was originally proposed by Marvell as a custom property called mdio-name specific to Marvell driver. This patch uses the more generic property device-name and moves this into MDIO class code so other can use it as well.

#3 lore raw

PATCH 1/4 net: mdio-uclass: name MDIO according to device-name property if preset

In reply to Alex Marginean
Quoted 7 lines · Alex Marginean

Use the optional property device-name to name the MDIO bus. This works around limitations with using the DT node name on devices such as Armada-8040, which integrates two cp100 cores, both featuring MDIOs at the same relative offsets and with the same DT node names.
The concept was originally proposed by Marvell as a custom property called mdio-name specific to Marvell driver. This patch uses the more generic

I was wondering whether such optional custom property name is accepted by the Linux devicetree committee or yet? The general goal is to use exact the same DT as kernel uses, at least for ARM, and that is what I learned from this ML.

Quoted 8 lines

property device-name and moves this into MDIO class code so other can use it as well.

---
 net/mdio-uclass.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

Anyway, the codes LGTM. So

Regards,
Bin

#4 lore raw

PATCH 1/4 net: mdio-uclass: name MDIO according to device-name property if preset

Quoted 10 lines · Bin Meng
Quoted 7 lines · Alex Marginean

Use the optional property device-name to name the MDIO bus. This works around limitations with using the DT node name on devices such as Armada-8040, which integrates two cp100 cores, both featuring MDIOs at the same relative offsets and with the same DT node names.
The concept was originally proposed by Marvell as a custom property called mdio-name specific to Marvell driver. This patch uses the more generic

Quoted 4 lines

I was wondering whether such optional custom property name is accepted by the Linux devicetree committee or yet? The general goal is to use exact the same DT as kernel uses, at least for ARM, and that is what I learned from this ML.

I didn't ask, my guess is they would not. The property is not actually describing HW, plus Linux wouldn't need this name anyway. As far as I know MDIOs in Linux are not addressable directly using user-space tools and for the purpose of probing devices and matching ethernet/PHY/MDIO this property is not useful. U-Boot on the other hand has the mdio cmd which requires unique names and also benefits from friendly names for MDIO buses.
There are other potential solutions for the unique name problem, like creating something out of the full DT path of the device, or resolve absolute base address and use that. These aren't as easy to use though.

Alex

Quoted 21 lines
Quoted 9 lines

property device-name and moves this into MDIO class code so other can use it as well.

---
  net/mdio-uclass.c | 11 +++++++++++
  1 file changed, 11 insertions(+)

Anyway, the codes LGTM. So

Regards,
Bin
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot

#5 lore raw

PATCH 1/4 net: mdio-uclass: name MDIO according to device-name property if preset

Hi Alex,

Quoted 17 lines · Alex Marginean
Quoted 10 lines · Bin Meng
Quoted 7 lines · Alex Marginean

Use the optional property device-name to name the MDIO bus. This works around limitations with using the DT node name on devices such as Armada-8040, which integrates two cp100 cores, both featuring MDIOs at the same relative offsets and with the same DT node names.
The concept was originally proposed by Marvell as a custom property called mdio-name specific to Marvell driver. This patch uses the more generic

Quoted 4 lines

I was wondering whether such optional custom property name is accepted by the Linux devicetree committee or yet? The general goal is to use exact the same DT as kernel uses, at least for ARM, and that is what I learned from this ML.

Quoted 10 lines

I didn't ask, my guess is they would not. The property is not actually describing HW, plus Linux wouldn't need this name anyway. As far as I know MDIOs in Linux are not addressable directly using user-space tools and for the purpose of probing devices and matching ethernet/PHY/MDIO this property is not useful. U-Boot on the other hand has the mdio cmd which requires unique names and also benefits from friendly names for MDIO buses.
There are other potential solutions for the unique name problem, like creating something out of the full DT path of the device, or resolve absolute base address and use that. These aren't as easy to use though.

Thanks for the clarification. Good enough for now :)

Regards,
Bin

#6 lore raw

PATCH 2/4 doc: bindings: add mdio.txt describing generic MDIO properties

In reply to Alex Marginean

Adds a binding document for mdio. A notable deviation from corresponding Linux binding is the introduction of device-name optional property, which can be used to name MDIO buses. Two reset optional properties described by Linux binding are also not present as they don't seem to be used in U-Boot at this time.

---
 doc/device-tree-bindings/net/mdio.txt | 36 +++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
 create mode 100644 doc/device-tree-bindings/net/mdio.txt
doc/device-tree-bindings/net/mdio.txt new file +36 -0
new file mode 100644
index 0000000000..1595325050
@@ -0,0 +1,36 @@
+Common MDIO bus properties.
+
+These are generic properties that can apply to any MDIO bus.
+
+Optional properties:
+	- device-name - If present it is used to name the device and MDIO bus.
+			The name must be unique and must not contain spaces.
+
+A list of child nodes, one per device on the bus is expected.  These could be
+PHYs, switches or similar devices and child nodes should follow the specific
+binding for the device type.
+
+Example :
+This example shows the structure used for the external MDIO bus on NXP LS1028A
+RDB board.  Note that this MDIO device is an integrated PCI function and
+requires no compatible property for probing.
+
+/* definition in SoC dtsi file */
+	pcie at 1f0000000 {
+
+		mdio0: pci at 0,3 {
+			#address-cells=<0>;
+			#size-cells=<1>;
+			reg = <0x000300 0 0 0 0>;
+			status = "disabled";
+			device-name = "emdio";
+		};
+	};
+/* definition of PHYs in RDB dts file */
+&mdio0 {
+	status = "okay";
+	rdb_phy0: phy at 2 {
+		reg = <2>;
+	};
+};
+
Signature · 1 line
2.17.1
#7 lore raw

PATCH 2/4 doc: bindings: add mdio.txt describing generic MDIO properties

Quoted 8 lines · Alex Marginean

Adds a binding document for mdio. A notable deviation from corresponding Linux binding is the introduction of device-name optional property, which can be used to name MDIO buses. Two reset optional properties described by Linux binding are also not present as they don't seem to be used in U-Boot at this time.

#8 lore raw

PATCH 2/4 doc: bindings: add mdio.txt describing generic MDIO properties

In reply to Alex Marginean
Quoted 7 lines · Alex Marginean

Adds a binding document for mdio. A notable deviation from corresponding Linux binding is the introduction of device-name optional property, which can be used to name MDIO buses. Two reset optional properties described by Linux binding are also not present as they don't seem to be used in U-Boot at this time.

Quoted 6 lines
---
 doc/device-tree-bindings/net/mdio.txt | 36 +++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
 create mode 100644 doc/device-tree-bindings/net/mdio.txt
#9 lore raw

PATCH 3/4 drivers: net: add marvell MDIO driver

In reply to Alex Marginean

This patch adds a separate driver for the MDIO interface of the Marvell Ethernet controllers based on driver model. There are two reasons to have a separate driver rather than including it inside the MAC driver itself:
*) The MDIO interface is shared by all Ethernet ports, so a driver
must guarantee non-concurrent accesses to this MDIO interface. The most logical way is to have a separate driver that handles this single MDIO interface, used by all Ethernet ports.
*) The MDIO interface is the same between the existing mv643xx_eth
driver and the new mvneta/mvpp2 driver. Even though it is for now only used by the mvneta/mvpp2 driver, it will in the future be used by the mv643xx_eth driver as well.

This driver supports SMI IEEE for 802.3 Clause 22 and XSMI for IEEE 802.3 Clause 45.

This patch also adds device tree binding for marvell MDIO driver.

---

I would really appreciate some help with testing of this patch as I don't have access to a Marvell device this would run on. Probing works, it's easy to test that. Nevo Hed has also been kind enough to run an older version of this patch at his end and it was working for him. For what is worth the actual driver code is practically unchanged from the original version sent by Ken, but it's still a good idea to have someone else verify it.

Thanks!

 doc/device-tree-bindings/net/marvell-mdio.txt |  15 ++
 drivers/net/Kconfig                           |  10 +
 drivers/net/Makefile                          |   1 +
 drivers/net/mvmdio.c                          | 236 ++++++++++++++++++
 4 files changed, 262 insertions(+)
 create mode 100644 doc/device-tree-bindings/net/marvell-mdio.txt
 create mode 100644 drivers/net/mvmdio.c
doc/device-tree-bindings/net/marvell-mdio.txt new file +15 -0
new file mode 100644
index 0000000000..e2038e2145
@@ -0,0 +1,15 @@
+* Marvell MDIO Ethernet Controller interface
+
+The Ethernet controllers of the Marvel Armada 3700 and Armada 7k/8k
+have an identical unit that provides an interface with the MDIO bus.
+This driver handles this MDIO interface.
+
+Mandatory properties:
+SoC specific:
+	- #address-cells: Must be <1>.
+	- #size-cells: Must be <0>.
+	- compatible: Should be "marvell,orion-mdio" (for SMI)
+				"marvell,xmdio"	     (for XSMI)
+	- reg: Base address and size SMI/XMSI bus.
+
+Please refer to "mdio.txt" for generic MDIO bus bindings.
drivers/net/Kconfig +10 -0
index 4d85fb1716..a982bc3ac5 100644
@@ -595,4 +595,14 @@ config FSL_ENETC
 	  This driver supports the NXP ENETC Ethernet controller found on some
 	  of the NXP SoCs.
 
+config MVMDIO
+	bool "Marvell MDIO interface support"
+	depends on DM_MDIO
+	help
+	  This driver supports the MDIO interface found in the network
+	  interface units of the Marvell EBU SoCs (Kirkwood, Orion5x,
+	  Dove, Armada 370, Armada XP, Armada 37xx and Armada7K/8K/8KP).
+
+	  This driver is used by the MVPP2 and MVNETA drivers.
+
 endif # NETDEVICES
drivers/net/Makefile +1 -0
index 97119cec7c..5921fa3e9c 100644
@@ -80,3 +80,4 @@ obj-$(CONFIG_HIGMACV300_ETH) += higmacv300.o
 obj-$(CONFIG_MDIO_SANDBOX) += mdio_sandbox.o
 obj-$(CONFIG_FSL_ENETC) += fsl_enetc.o fsl_enetc_mdio.o
 obj-$(CONFIG_MDIO_MUX_SANDBOX) += mdio_mux_sandbox.o
+obj-$(CONFIG_MVMDIO) += mvmdio.o
drivers/net/mvmdio.c new file +236 -0

236 lines not on this page · raw message

Signature · 1 line
2.17.1
#10 lore raw

PATCH 3/4 drivers: net: add marvell MDIO driver

Quoted 14 lines · Alex Marginean

This patch adds a separate driver for the MDIO interface of the Marvell Ethernet controllers based on driver model. There are two reasons to have a separate driver rather than including it inside the MAC driver itself:
*) The MDIO interface is shared by all Ethernet ports, so a driver
must guarantee non-concurrent accesses to this MDIO interface. The most logical way is to have a separate driver that handles this single MDIO interface, used by all Ethernet ports.
*) The MDIO interface is the same between the existing mv643xx_eth
driver and the new mvneta/mvpp2 driver. Even though it is for now only used by the mvneta/mvpp2 driver, it will in the future be used by the mv643xx_eth driver as well.

Quoted 7 lines

This driver supports SMI IEEE for 802.3 Clause 22 and XSMI for IEEE 802.3 Clause 45.

This patch also adds device tree binding for marvell MDIO driver.

#11 lore raw

PATCH 4/4 arm: dts: Set custom names for cp110 master/slave MDIO buses

In reply to Alex Marginean

Implicitly Marvell MDIO driver uses DT node names for devices, but in this case that is not unique. Set MDIO device names for master/slave to cpm/cps.

---
 arch/arm/dts/armada-cp110-master.dtsi | 1 +
 arch/arm/dts/armada-cp110-slave.dtsi  | 1 +
 2 files changed, 2 insertions(+)
arch/arm/dts/armada-cp110-master.dtsi +1 -0
index 551d00d774..6fb6166b79 100644
@@ -96,6 +96,7 @@
 				#size-cells = <0>;
 				compatible = "marvell,orion-mdio";
 				reg = <0x12a200 0x10>;
+				device-name = "cpm";
 			};
 
 			cpm_syscon0: system-controller at 440000 {
arch/arm/dts/armada-cp110-slave.dtsi +1 -0
index 2ea9004f1d..53c796dad6 100644
@@ -96,6 +96,7 @@
 				#size-cells = <0>;
 				compatible = "marvell,orion-mdio";
 				reg = <0x12a200 0x10>;
+				device-name = "cps";
 			};
 
 			cps_syscon0: system-controller at 440000 {
Signature · 1 line
2.17.1
#13 lore raw

PATCH 4/4 arm: dts: Set custom names for cp110 master/slave MDIO buses

Sorry for the late input

The cp110s have an mdio and an xmdio so
Locally I have been naming them cpm-xmdio, cpm-mdio, cps-xmdio, cps-mdio

I knew the new field is coming but didn't catch that the 'dtsi's patch

Quoted 15 lines · Joe Hershberger
Quoted 6 lines · Alex Marginean

Implicitly Marvell MDIO driver uses DT node names for devices, but in this case that is not unique. Set MDIO device names for master/slave to cpm/cps.

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot

#14 lore raw

PATCH 4/4 arm: dts: Set custom names for cp110 master/slave MDIO buses

In reply to Joe Hershberger

Sorry for the late input

The cp110s have an mdio and an xmdio so
Locally I have been naming them cpm-xmdio, cpm-mdio, cps-xmdio, cps-mdio

I knew the new field is coming but didn't catch that the 'dtsi's patch

[also apologies if you get this a second time]

Quoted 15 lines · Joe Hershberger
Quoted 6 lines · Alex Marginean

Implicitly Marvell MDIO driver uses DT node names for devices, but in this case that is not unique. Set MDIO device names for master/slave to cpm/cps.

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot

#15 lore raw

PATCH 4/4 arm: dts: Set custom names for cp110 master/slave MDIO buses

For context from upstream linux,
https://github.com/torvalds/linux/commit/f66b2aff46eaf0825dbe1560e28fcb845dd2a215

I was intending to submit the parallel change here once fully tested end-end on our hardware,
but if not too late my proposal is to name the above nodes as "cpm-mdio" & "cps-mdio"

Quoted 26 lines · Nevo Hed

Sorry for the late input

The cp110s have an mdio and an xmdio so
Locally I have been naming them cpm-xmdio, cpm-mdio, cps-xmdio, cps-mdio

I knew the new field is coming but didn't catch that the 'dtsi's patch

[also apologies if you get this a second time]

Quoted 15 lines · Joe Hershberger
Quoted 6 lines · Alex Marginean

Implicitly Marvell MDIO driver uses DT node names for devices, but in this case that is not unique. Set MDIO device names for master/slave to cpm/cps.

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot

#16 lore raw

PATCH 4/4 arm: dts: Set custom names for cp110 master/slave MDIO buses

Quoted 7 lines · Nevo Hed

For context from upstream linux,
https://github.com/torvalds/linux/commit/f66b2aff46eaf0825dbe1560e28fcb845dd2a215

I was intending to submit the parallel change here once fully tested end-end on our hardware,
but if not too late my proposal is to name the above nodes as "cpm-mdio" & "cps-mdio"

I'm OK with "-mdio", I can send a v2.
Please node that I used a property called 'device-name' rather than 'mdio-name', I'm not sure if you want to pick that up too or not.

Thanks!
Alex

Quoted 34 lines · Nevo Hed
Quoted 26 lines

Sorry for the late input

The cp110s have an mdio and an xmdio so
Locally I have been naming them cpm-xmdio, cpm-mdio, cps-xmdio, cps-mdio

I knew the new field is coming but didn't catch that the 'dtsi's patch

[also apologies if you get this a second time]

Quoted 15 lines · Joe Hershberger
Quoted 6 lines · Alex Marginean

Implicitly Marvell MDIO driver uses DT node names for devices, but in this case that is not unique. Set MDIO device names for master/slave to cpm/cps.

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot

#17 lore raw

PATCH 4/4 arm: dts: Set custom names for cp110 master/slave MDIO buses

Quoted 5 lines · Alex Marginean
Quoted 3 lines · Nevo Hed

For context from upstream linux,
https://github.com/torvalds/linux/commit/f66b2aff46eaf0825dbe1560e28fcb845dd2a215

Quoted 8 lines
Quoted 4 lines

I was intending to submit the parallel change here once fully tested end-end on our hardware,
but if not too late my proposal is to name the above nodes as "cpm-mdio" & "cps-mdio"

I'm OK with "-mdio", I can send a v2.
Please node that I used a property called 'device-name' rather than 'mdio-name', I'm not sure if you want to pick that up too or not.

Let me know when this is settled and I'll take the series.

Thanks,
-Joe

Quoted 39 lines
Quoted 29 lines · Nevo Hed
Quoted 26 lines

Sorry for the late input

The cp110s have an mdio and an xmdio so
Locally I have been naming them cpm-xmdio, cpm-mdio, cps-xmdio, cps-mdio

I knew the new field is coming but didn't catch that the 'dtsi's patch

[also apologies if you get this a second time]

Quoted 15 lines · Joe Hershberger
Quoted 6 lines · Alex Marginean

Implicitly Marvell MDIO driver uses DT node names for devices, but in this case that is not unique. Set MDIO device names for master/slave to cpm/cps.

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot

Quoted 5 lines

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot

#18 lore raw

cover Marvell MDIO driver and new MDIO name property

In reply to Alex Marginean

+Nevo, I forgot to CC you.
Alex

Quoted 26 lines · Alex Marginean

This is a respin of the original Marvell MDIO driver submitted by Ken about one year ago, using the new MDIO DM code.
Added binding documents for mdio and marvell-mdio and introduced a new optional property for naming MDIO buses in case the driver can't reasonably pick a nice name by itself.

Alex Marginean (4):
net: mdio-uclass: name MDIO according to device-name property if
preset
doc: bindings: add mdio.txt describing generic MDIO properties
drivers: net: add marvell MDIO driver
arm: dts: Set custom names for cp110 master/slave MDIO buses

  arch/arm/dts/armada-cp110-master.dtsi         |   1 +
  arch/arm/dts/armada-cp110-slave.dtsi          |   1 +
  doc/device-tree-bindings/net/marvell-mdio.txt |  15 ++
  doc/device-tree-bindings/net/mdio.txt         |  36 +++
  drivers/net/Kconfig                           |  10 +
  drivers/net/Makefile                          |   1 +
  drivers/net/mvmdio.c                          | 236 ++++++++++++++++++
  net/mdio-uclass.c                             |  11 +
  8 files changed, 311 insertions(+)

create mode 100644 doc/device-tree-bindings/net/marvell-mdio.txt create mode 100644 doc/device-tree-bindings/net/mdio.txt create mode 100644 drivers/net/mvmdio.c