From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ben Warren Date: Thu, 16 Oct 2008 23:01:01 -0700 Subject: [U-Boot] [PATCH 06/10] AVR32: macb - Search for PHY id In-Reply-To: <18376c3cf23d5128e150674daf36a3e680caf4cc.1223643536.git.olavmrk@gmail.com> References: <18376c3cf23d5128e150674daf36a3e680caf4cc.1223643536.git.olavmrk@gmail.com> Message-ID: <48F82A1D.6060509@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Olav Morken wrote: > This patch adds support for searching through available PHY-addresses in > the macb-driver. This is needed for the ATEVK1100 evaluation board, > where the PHY-address will be initialized to either 1 or 7. > > Signed-off-by: Gunnar Rangoy > Signed-off-by: Paul Driveklepp > Signed-off-by: Olav Morken > --- > drivers/net/macb.c | 28 ++++++++++++++++++++++++++++ > 1 files changed, 28 insertions(+), 0 deletions(-) > > diff --git a/drivers/net/macb.c b/drivers/net/macb.c > index 4fef374..561669b 100644 > --- a/drivers/net/macb.c > +++ b/drivers/net/macb.c > @@ -338,6 +338,27 @@ static void macb_phy_reset(struct macb_device *macb) > netdev->name, status); > } > > +static int macb_phy_find(struct macb_device *macb) > +{ > + int i; > + u16 phy_id; > + > + /* Search for PHY... */ > + for (i = 0; i < 32; i++) { > + macb->phy_addr=i; > + phy_id = macb_mdio_read(macb, MII_PHYSID1); > + if (phy_id != 0xffff) { > + printf("%s: PHY present at %d\n", macb->netdev.name, i); > + return 1; > + } > + } > + > + /* PHY isn't up to snuff */ > + printf("%s: PHY not found", macb->netdev.name); > + > + return 0; > +} > + > static int macb_phy_init(struct macb_device *macb) > { > struct eth_device *netdev = &macb->netdev; > @@ -346,6 +367,13 @@ static int macb_phy_init(struct macb_device *macb) > int media, speed, duplex; > int i; > > + if (macb->phy_addr == 0xff) { > + /* Auto-detect phy_addr */ > + if (!macb_phy_find(macb)) { > + return 0; > + } > + } > + > /* Check if the PHY is up to snuff... */ > phy_id = macb_mdio_read(macb, MII_PHYSID1); > if (phy_id == 0xffff) { > Applied to net/testing. regards, Ben