Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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>

authored by

Ralf Baechle and committed by
Jeff Garzik
59b81827 902f9073

+36
+36
drivers/net/sb1250-mac.c
··· 296 296 static int sbmac_mii_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); 297 297 static int sbmac_close(struct net_device *dev); 298 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 301 static void sbmac_mii_sync(struct sbmac_softc *s); 301 302 static void sbmac_mii_senddata(struct sbmac_softc *s,unsigned int data, int bitcnt); ··· 434 433 435 434 #define MII_BMCR 0x00 /* Basic mode control register (rw) */ 436 435 #define MII_BMSR 0x01 /* Basic mode status register (ro) */ 436 + #define MII_PHYIDR1 0x02 437 + #define MII_PHYIDR2 0x03 438 + 437 439 #define MII_K1STSR 0x0A /* 1K Status Register (ro) */ 438 440 #define MII_ANLPAR 0x05 /* Autonegotiation lnk partner abilities (rw) */ 439 441 ··· 2436 2432 return -EBUSY; 2437 2433 2438 2434 /* 2435 + * Probe phy address 2436 + */ 2437 + 2438 + if(sbmac_mii_probe(dev) == -1) { 2439 + printk("%s: failed to probe PHY.\n", dev->name); 2440 + return -EINVAL; 2441 + } 2442 + 2443 + /* 2439 2444 * Configure default speed 2440 2445 */ 2441 2446 ··· 2477 2464 return 0; 2478 2465 } 2479 2466 2467 + static int sbmac_mii_probe(struct net_device *dev) 2468 + { 2469 + int i; 2470 + struct sbmac_softc *s = netdev_priv(dev); 2471 + u16 bmsr, id1, id2; 2472 + u32 vendor, device; 2473 + 2474 + for (i=1; i<31; i++) { 2475 + bmsr = sbmac_mii_read(s, i, MII_BMSR); 2476 + if (bmsr != 0) { 2477 + s->sbm_phys[0] = i; 2478 + id1 = sbmac_mii_read(s, i, MII_PHYIDR1); 2479 + id2 = sbmac_mii_read(s, i, MII_PHYIDR2); 2480 + vendor = ((u32)id1 << 6) | ((id2 >> 10) & 0x3f); 2481 + device = (id2 >> 4) & 0x3f; 2482 + 2483 + printk(KERN_INFO "%s: found phy %d, vendor %06x part %02x\n", 2484 + dev->name, i, vendor, device); 2485 + return i; 2486 + } 2487 + } 2488 + return -1; 2489 + } 2480 2490 2481 2491 2482 2492 static int sbmac_mii_poll(struct sbmac_softc *s,int noisy)