net: mdio-uclass: name MDIO according to device-name property if preset
authorAlex Marginean <alexandru.marginean@nxp.com>
Thu, 25 Jul 2019 09:33:17 +0000 (12:33 +0300)
committerJoe Hershberger <joe.hershberger@ni.com>
Wed, 4 Sep 2019 16:37:19 +0000 (11:37 -0500)
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.

Signed-off-by: Alex Marginean <alexm.osslist@gmail.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
net/mdio-uclass.c

index 1c0d25272a36fd82ed34cb805c81eb9d302651a9..6f922e80b6fb2ff0d0411b6cb9b01961c4d46aca 100644 (file)
@@ -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