static int bcm5400_init(struct mii_phy* phy) { u16 data; /* Configure for gigabit full duplex */ data = phy_read(phy, MII_BCM5400_AUXCONTROL); data |= MII_BCM5400_AUXCONTROL_PWR10BASET; phy_write(phy, MII_BCM5400_AUXCONTROL, data); data = phy_read(phy, MII_BCM5400_GB_CONTROL); data |= MII_BCM5400_GB_CONTROL_FULLDUPLEXCAP; phy_write(phy, MII_BCM5400_GB_CONTROL, data); udelay(100); /* Reset and configure cascaded 10/100 PHY */ (void)reset_one_mii_phy(phy, 0x1f); data = __phy_read(phy, 0x1f, MII_BCM5201_MULTIPHY); data |= MII_BCM5201_MULTIPHY_SERIALMODE; __phy_write(phy, 0x1f, MII_BCM5201_MULTIPHY, data); data = phy_read(phy, MII_BCM5400_AUXCONTROL); data &= ~MII_BCM5400_AUXCONTROL_PWR10BASET; phy_write(phy, MII_BCM5400_AUXCONTROL, data); return 0; }
static int reset_one_mii_phy(struct mii_phy* phy, int phy_id) { u16 val; int limit = 10000; val = __phy_read(phy, phy_id, MII_BMCR); val &= ~(BMCR_ISOLATE | BMCR_PDOWN); val |= BMCR_RESET; __phy_write(phy, phy_id, MII_BMCR, val); udelay(100); while (--limit) { val = __phy_read(phy, phy_id, MII_BMCR); if ((val & BMCR_RESET) == 0) break; udelay(10); } if ((val & BMCR_ISOLATE) && limit > 0) __phy_write(phy, phy_id, MII_BMCR, val & ~BMCR_ISOLATE); return limit <= 0; }
static int bcm5401_init(struct mii_phy* phy) { u16 data; int rev; rev = phy_read(phy, MII_PHYSID2) & 0x000f; if (rev == 0 || rev == 3) { /* Some revisions of 5401 appear to need this * initialisation sequence to disable, according * to OF, "tap power management" * * WARNING ! OF and Darwin don't agree on the * register addresses. OF seem to interpret the * register numbers below as decimal * * Note: This should (and does) match tg3_init_5401phy_dsp * in the tg3.c driver. -DaveM */ phy_write(phy, 0x18, 0x0c20); phy_write(phy, 0x17, 0x0012); phy_write(phy, 0x15, 0x1804); phy_write(phy, 0x17, 0x0013); phy_write(phy, 0x15, 0x1204); phy_write(phy, 0x17, 0x8006); phy_write(phy, 0x15, 0x0132); phy_write(phy, 0x17, 0x8006); phy_write(phy, 0x15, 0x0232); phy_write(phy, 0x17, 0x201f); phy_write(phy, 0x15, 0x0a20); } /* Configure for gigabit full duplex */ data = phy_read(phy, MII_BCM5400_GB_CONTROL); data |= MII_BCM5400_GB_CONTROL_FULLDUPLEXCAP; phy_write(phy, MII_BCM5400_GB_CONTROL, data); udelay(10); /* Reset and configure cascaded 10/100 PHY */ (void)reset_one_mii_phy(phy, 0x1f); data = __phy_read(phy, 0x1f, MII_BCM5201_MULTIPHY); data |= MII_BCM5201_MULTIPHY_SERIALMODE; __phy_write(phy, 0x1f, MII_BCM5201_MULTIPHY, data); return 0; }
static int rtl821x_write_page(struct phy_device *phydev, int page) { return __phy_write(phydev, RTL821x_PAGE_SELECT, page); }
static inline void phy_write(struct gem *gp, int reg, u16 val) { __phy_write(gp, gp->mii_phy_addr, reg, val); }
static inline void _phy_write(struct net_device *dev, int mii_id, int reg, int val) { struct gem *gp = dev->priv; __phy_write(gp, mii_id, reg, val & 0xffff); }