Skip to contentSkip to conversation

net: mvgbe: add support for differ PHY addresses

PATCH New Pawel Dembicki 2 participants 2 messages Apr 11, 2020 – Apr 28, 2020 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: mvgbe: add support for differ PHY addresses

PHYs on some boards have not subsequential addresses. This patch introduces define PHY_BASE_ADR2, which allow to configure separate PHY addresses for both interfaces.

Cc Joe Hershberger <[email protected]>
Cc Chris Packham <[email protected]>
---
 drivers/net/mvgbe.c | 23 ++++++++++++++++++++---
 drivers/net/mvgbe.h |  4 ++++
 2 files changed, 24 insertions(+), 3 deletions(-)
drivers/net/mvgbe.c +20 -3
index 037e59ec6e..d40fb5af81 100644
@@ -874,7 +874,15 @@ int mvgbe_initialize(bd_t *bis)
 		eth_register(dev);
 
 #if defined(CONFIG_PHYLIB)
-		mvgbe_phylib_init(dev, PHY_BASE_ADR + devnum);
+
+		if (devnum == 0)
+			mvgbe_phylib_init(dev, PHY_BASE_ADR);
+		else
+#if defined(PHY_BASE_ADR2)
+			mvgbe_phylib_init(dev, PHY_BASE_ADR2);
+#else
+			mvgbe_phylib_init(dev, PHY_BASE_ADR + devnum);
+#endif
 #elif defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
 		int retval;
 		struct mii_dev *mdiodev = mdio_alloc();
@@ -888,8 +896,17 @@ int mvgbe_initialize(bd_t *bis)
 		if (retval < 0)
 			return retval;
 		/* Set phy address of the port */
-		miiphy_write(dev->name, MV_PHY_ADR_REQUEST,
-				MV_PHY_ADR_REQUEST, PHY_BASE_ADR + devnum);
+		if (devnum == 0)
+			miiphy_write(dev->name, MV_PHY_ADR_REQUEST,
+				     MV_PHY_ADR_REQUEST, PHY_BASE_ADR);
+		else
+#if defined(PHY_BASE_ADR2)
+			miiphy_write(dev->name, MV_PHY_ADR_REQUEST,
+				     MV_PHY_ADR_REQUEST, PHY_BASE_ADR2);
+#else
+			miiphy_write(dev->name, MV_PHY_ADR_REQUEST,
+				     MV_PHY_ADR_REQUEST, PHY_BASE_ADR + devnum);
+#endif
 #endif
 	}
 	return 0;
drivers/net/mvgbe.h +4 -0
index 44541c0a85..f37d4c3d59 100644
@@ -18,6 +18,10 @@
 #define PHY_BASE_ADR		0x08	/* default phy base addr */
 #endif
 
+#if defined(CONFIG_PHY_BASE_ADR2)
+#define PHY_BASE_ADR2		CONFIG_PHY_BASE_ADR2
+#endif
+
 /* Constants */
 #define INT_CAUSE_UNMASK_ALL		0x0007ffff
 #define INT_CAUSE_UNMASK_ALL_EXT	0x0011ffff
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/1 net: mvgbe: add support for differ PHY addresses

Hi Pawel,

Sorry for the delay replying.

Quoted 4 lines · Pawel Dembicki,

PHYs on some boards have not subsequential addresses. This patch introduces define PHY_BASE_ADR2, which allow to configure separate PHY addresses for both interfaces.

These days this kind of information should really be coming via the devicetree. Infact as far as I can tell the current code should support specifying the phy address this way.

Quoted 69 lines
Cc Joe Hershberger <[email protected]>
Cc Chris Packham <[email protected]>
---
 drivers/net/mvgbe.c | 23 ++++++++++++++++++++---
 drivers/net/mvgbe.h |  4 ++++
 2 files changed, 24 insertions(+), 3 deletions(-)
drivers/net/mvgbe.c +20 -3
index 037e59ec6e..d40fb5af81 100644
@@ -874,7 +874,15 @@ int mvgbe_initialize(bd_t *bis)
                eth_register(dev);
 
 #if defined(CONFIG_PHYLIB)
-               mvgbe_phylib_init(dev, PHY_BASE_ADR + devnum);
+
+               if (devnum == 0)
+                       mvgbe_phylib_init(dev, PHY_BASE_ADR);
+               else
+#if defined(PHY_BASE_ADR2)
+                       mvgbe_phylib_init(dev, PHY_BASE_ADR2);
+#else
+                       mvgbe_phylib_init(dev, PHY_BASE_ADR + devnum);
+#endif
 #elif defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
                int retval;
                struct mii_dev *mdiodev = mdio_alloc();
@@ -888,8 +896,17 @@ int mvgbe_initialize(bd_t *bis)
                if (retval < 0)
                        return retval;
                /* Set phy address of the port */
-               miiphy_write(dev->name, MV_PHY_ADR_REQUEST,
-                               MV_PHY_ADR_REQUEST, PHY_BASE_ADR + devnum);
+               if (devnum == 0)
+                       miiphy_write(dev->name, MV_PHY_ADR_REQUEST,
+                                    MV_PHY_ADR_REQUEST, PHY_BASE_ADR);
+               else
+#if defined(PHY_BASE_ADR2)
+                       miiphy_write(dev->name, MV_PHY_ADR_REQUEST,
+                                    MV_PHY_ADR_REQUEST, PHY_BASE_ADR2);
+#else
+                       miiphy_write(dev->name, MV_PHY_ADR_REQUEST,
+                                    MV_PHY_ADR_REQUEST, PHY_BASE_ADR +
 devnum);
+#endif
 #endif
        }
        return 0;
drivers/net/mvgbe.h +4 -1
index 44541c0a85..f37d4c3d59 100644
@@ -18,6 +18,10 @@
 #define PHY_BASE_ADR           0x08    /* default phy base addr */
 #endif
 
+#if defined(CONFIG_PHY_BASE_ADR2)
+#define PHY_BASE_ADR2          CONFIG_PHY_BASE_ADR2
+#endif
+
 /* Constants */
 #define INT_CAUSE_UNMASK_ALL           0x0007ffff
 #define INT_CAUSE_UNMASK_ALL_EXT       0x0011ffff
--

2.20.1