From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ben Warren Date: Thu, 29 Jan 2009 00:27:46 -0800 Subject: [U-Boot] [PATCH v2 6/9] AVR32: macb - Search for PHY id In-Reply-To: <90cf8dc35c3d1df4f7ab0c0fbdac2f3fa14df761.1232710611.git.gunnar@rangoy.com> References: <028f0528eb84570f84077f82e9e149576cc83b26.1232710611.git.gunnar@rangoy.com> <656ec970cbe6bc965e1b9d3712c88d71cfe7c98b.1232710611.git.gunnar@rangoy.com> <0f5003722b57a41a859c9d9f90caba4c265534cc.1232710611.git.gunnar@rangoy.com> <7e5f5fd7693284246714c42b6a3014f82f670b82.1232710611.git.gunnar@rangoy.com> <90cf8dc35c3d1df4f7ab0c0fbdac2f3fa14df761.1232710611.git.gunnar@rangoy.com> Message-ID: <49816882.1080807@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 Gunnar Rangoy 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. > > This patch adds a config option, CONFIG_MACB_SEARCH_PHY, which when > enabled tells the driver to search for the PHY address. > > Signed-off-by: Gunnar Rangoy > Signed-off-by: Paul Driveklepp > Signed-off-by: Olav Morken > --- > drivers/net/macb.c | 31 +++++++++++++++++++++++++++++++ > 1 files changed, 31 insertions(+), 0 deletions(-) > > diff --git a/drivers/net/macb.c b/drivers/net/macb.c > index d47a052..c8beb82 100644 > --- a/drivers/net/macb.c > +++ b/drivers/net/macb.c > @@ -327,6 +327,30 @@ static void macb_phy_reset(struct macb_device *macb) > netdev->name, status); > } > > +#ifdef CONFIG_MACB_SEARCH_PHY > +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; > +} > +#endif /* CONFIG_MACB_SEARCH_PHY */ > + > + > static int macb_phy_init(struct macb_device *macb) > { > struct eth_device *netdev = &macb->netdev; > @@ -335,6 +359,13 @@ static int macb_phy_init(struct macb_device *macb) > int media, speed, duplex; > int i; > > +#ifdef CONFIG_MACB_SEARCH_PHY > + /* Auto-detect phy_addr */ > + if (!macb_phy_find(macb)) { > + return 0; > + } > +#endif /* CONFIG_MACB_SEARCH_PHY */ > + > /* Check if the PHY is up to snuff... */ > phy_id = macb_mdio_read(macb, MII_PHYSID1); > if (phy_id == 0xffff) { > Added to net repo. thanks, Ben