summaryrefslogtreecommitdiff
path: root/drivers/net/macb.c
diff options
context:
space:
mode:
authorGunnar Rangoy <gunnar@rangoy.com>2009-01-23 12:56:31 +0100
committerBen Warren <biggerbadderben@gmail.com>2009-01-28 23:59:28 -0800
commitfc01ea1e27d5b124f0a1868d0ce569f156d58dfe (patch)
treee50e4cdadf14776e713c0ccd340cc8ba76974c3f /drivers/net/macb.c
parentaf8626e0c08a780d9ded1d9c4883a89355f60e75 (diff)
downloadu-boot-imx-fc01ea1e27d5b124f0a1868d0ce569f156d58dfe.zip
u-boot-imx-fc01ea1e27d5b124f0a1868d0ce569f156d58dfe.tar.gz
u-boot-imx-fc01ea1e27d5b124f0a1868d0ce569f156d58dfe.tar.bz2
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: Gunnar Rangoy <gunnar@rangoy.com> Signed-off-by: Paul Driveklepp <pauldriveklepp@gmail.com> Signed-off-by: Olav Morken <olavmrk@gmail.com> Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
Diffstat (limited to 'drivers/net/macb.c')
-rw-r--r--drivers/net/macb.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 98e8c73..af0409b 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -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) {