diff options
author | Ralf Baechle <ralf@linux-mips.org> | 2005-10-20 07:01:28 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@pobox.com> | 2005-10-20 16:06:11 -0400 |
commit | 59b81827071a8ae7f399da533d268e1e33bfeeb7 (patch) | |
tree | 71b98092ae01162cc33c08617d24b7803f1f89de /drivers/net/sb1250-mac.c | |
parent | 902f90735b693550eb51a3989895f3148b8229d8 (diff) |
[PATCH] sb1250-mac: PHY probing fixes.
Improve sb1250-mac driver to probe for PHYs at addresses other
than 1, such as the PHYs on BigSur.
Signed-Off-By: Andy Isaacson <adi@broadcom.com>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Jeff Garzik <jgarzik@pobox.com>
Diffstat (limited to 'drivers/net/sb1250-mac.c')
-rw-r--r-- | drivers/net/sb1250-mac.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/drivers/net/sb1250-mac.c b/drivers/net/sb1250-mac.c index d4c8ecdfa4a7..aa4ca1821759 100644 --- a/drivers/net/sb1250-mac.c +++ b/drivers/net/sb1250-mac.c | |||
@@ -296,6 +296,7 @@ static void sbmac_set_rx_mode(struct net_device *dev); | |||
296 | static int sbmac_mii_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); | 296 | static int sbmac_mii_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); |
297 | static int sbmac_close(struct net_device *dev); | 297 | static int sbmac_close(struct net_device *dev); |
298 | static int sbmac_mii_poll(struct sbmac_softc *s,int noisy); | 298 | static int sbmac_mii_poll(struct sbmac_softc *s,int noisy); |
299 | static int sbmac_mii_probe(struct net_device *dev); | ||
299 | 300 | ||
300 | static void sbmac_mii_sync(struct sbmac_softc *s); | 301 | static void sbmac_mii_sync(struct sbmac_softc *s); |
301 | static void sbmac_mii_senddata(struct sbmac_softc *s,unsigned int data, int bitcnt); | 302 | static void sbmac_mii_senddata(struct sbmac_softc *s,unsigned int data, int bitcnt); |
@@ -433,6 +434,9 @@ static uint64_t sbmac_orig_hwaddr[MAX_UNITS]; | |||
433 | 434 | ||
434 | #define MII_BMCR 0x00 /* Basic mode control register (rw) */ | 435 | #define MII_BMCR 0x00 /* Basic mode control register (rw) */ |
435 | #define MII_BMSR 0x01 /* Basic mode status register (ro) */ | 436 | #define MII_BMSR 0x01 /* Basic mode status register (ro) */ |
437 | #define MII_PHYIDR1 0x02 | ||
438 | #define MII_PHYIDR2 0x03 | ||
439 | |||
436 | #define MII_K1STSR 0x0A /* 1K Status Register (ro) */ | 440 | #define MII_K1STSR 0x0A /* 1K Status Register (ro) */ |
437 | #define MII_ANLPAR 0x05 /* Autonegotiation lnk partner abilities (rw) */ | 441 | #define MII_ANLPAR 0x05 /* Autonegotiation lnk partner abilities (rw) */ |
438 | 442 | ||
@@ -2432,6 +2436,15 @@ static int sbmac_open(struct net_device *dev) | |||
2432 | return -EBUSY; | 2436 | return -EBUSY; |
2433 | 2437 | ||
2434 | /* | 2438 | /* |
2439 | * Probe phy address | ||
2440 | */ | ||
2441 | |||
2442 | if(sbmac_mii_probe(dev) == -1) { | ||
2443 | printk("%s: failed to probe PHY.\n", dev->name); | ||
2444 | return -EINVAL; | ||
2445 | } | ||
2446 | |||
2447 | /* | ||
2435 | * Configure default speed | 2448 | * Configure default speed |
2436 | */ | 2449 | */ |
2437 | 2450 | ||
@@ -2464,6 +2477,29 @@ static int sbmac_open(struct net_device *dev) | |||
2464 | return 0; | 2477 | return 0; |
2465 | } | 2478 | } |
2466 | 2479 | ||
2480 | static int sbmac_mii_probe(struct net_device *dev) | ||
2481 | { | ||
2482 | int i; | ||
2483 | struct sbmac_softc *s = netdev_priv(dev); | ||
2484 | u16 bmsr, id1, id2; | ||
2485 | u32 vendor, device; | ||
2486 | |||
2487 | for (i=1; i<31; i++) { | ||
2488 | bmsr = sbmac_mii_read(s, i, MII_BMSR); | ||
2489 | if (bmsr != 0) { | ||
2490 | s->sbm_phys[0] = i; | ||
2491 | id1 = sbmac_mii_read(s, i, MII_PHYIDR1); | ||
2492 | id2 = sbmac_mii_read(s, i, MII_PHYIDR2); | ||
2493 | vendor = ((u32)id1 << 6) | ((id2 >> 10) & 0x3f); | ||
2494 | device = (id2 >> 4) & 0x3f; | ||
2495 | |||
2496 | printk(KERN_INFO "%s: found phy %d, vendor %06x part %02x\n", | ||
2497 | dev->name, i, vendor, device); | ||
2498 | return i; | ||
2499 | } | ||
2500 | } | ||
2501 | return -1; | ||
2502 | } | ||
2467 | 2503 | ||
2468 | 2504 | ||
2469 | static int sbmac_mii_poll(struct sbmac_softc *s,int noisy) | 2505 | static int sbmac_mii_poll(struct sbmac_softc *s,int noisy) |