Skip to content
Snippets Groups Projects
Commit fc01ea1e authored by Gunnar Rangoy's avatar Gunnar Rangoy Committed by Ben Warren
Browse files

AVR32: macb - Search for PHY id


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: default avatarGunnar Rangoy <gunnar@rangoy.com>
Signed-off-by: default avatarPaul Driveklepp <pauldriveklepp@gmail.com>
Signed-off-by: default avatarOlav Morken <olavmrk@gmail.com>
Signed-off-by: default avatarBen Warren <biggerbadderben@gmail.com>
parent af8626e0
No related branches found
No related tags found
No related merge requests found
......@@ -317,6 +317,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;
......@@ -325,6 +349,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) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment