From patchwork Sat Apr 11 19:26:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Dembicki X-Patchwork-Id: 237700 List-Id: U-Boot discussion From: paweldembicki at gmail.com (Pawel Dembicki) Date: Sat, 11 Apr 2020 21:26:20 +0200 Subject: [PATCH] net: mvgbe: add support for differ PHY addresses Message-ID: <20200411192619.24133-1-paweldembicki@gmail.com> 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 Cc: Chris Packham Signed-off-by: Pawel Dembicki --- drivers/net/mvgbe.c | 23 ++++++++++++++++++++--- drivers/net/mvgbe.h | 4 ++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/drivers/net/mvgbe.c b/drivers/net/mvgbe.c index 037e59ec6e..d40fb5af81 100644 --- a/drivers/net/mvgbe.c +++ b/drivers/net/mvgbe.c @@ -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; diff --git a/drivers/net/mvgbe.h b/drivers/net/mvgbe.h index 44541c0a85..f37d4c3d59 100644 --- a/drivers/net/mvgbe.h +++ b/drivers/net/mvgbe.h @@ -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