int mcffec_miiphy_read(struct mii_dev *bus, int addr, int devad, int reg) { short rdreg; /* register working value */ #ifdef MII_DEBUG printf("miiphy_read(0x%x) @ 0x%x = ", reg, addr); #endif rdreg = mii_send(mk_mii_read(addr, reg)); #ifdef MII_DEBUG printf("0x%04x\n", rdreg); #endif return rdreg; }
void ppc405_phy_dump(struct net_device *dev) { unsigned long i; uint data; printk(KERN_DEBUG " Prepare for Phy dump....\n"); for (i = 0; i < 0x1A; i++) { if (ocp_enet_mdio_read(dev, mk_mii_read(i), &data)) return; printk(KERN_DEBUG "Phy reg 0x%lx ==> %4x\n", i, data); if (i == 0x07) i = 0x0f; } }
int mcffec_miiphy_read(char *devname, unsigned char addr, unsigned char reg, unsigned short *value) { short rdreg; /* register working value */ #ifdef MII_DEBUG printf("miiphy_read(0x%x) @ 0x%x = ", reg, addr); #endif rdreg = mii_send(mk_mii_read(addr, reg)); *value = rdreg; #ifdef MII_DEBUG printf("0x%04x\n", *value); #endif return 0; }
static int fs_enet_fec_mii_read(struct mii_bus *bus , int phy_id, int location) { struct fec_info* fec = bus->priv; struct fec __iomem *fecp = fec->fecp; int i, ret = -1; BUG_ON((in_be32(&fecp->fec_r_cntrl) & FEC_RCNTRL_MII_MODE) == 0); /* Add PHY address to register command. */ out_be32(&fecp->fec_mii_data, (phy_id << 23) | mk_mii_read(location)); for (i = 0; i < FEC_MII_LOOPS; i++) if ((in_be32(&fecp->fec_ievent) & FEC_ENET_MII) != 0) break; if (i < FEC_MII_LOOPS) { out_be32(&fecp->fec_ievent, FEC_ENET_MII); ret = in_be32(&fecp->fec_mii_data) & 0xffff; } return ret; }
int mii_discover_phy(struct eth_device *dev) { #define MAX_PHY_PASSES 11 struct fec_info_s *info = dev->priv; int phyaddr, pass; uint phyno, phytype; if (info->phyname_init) return info->phy_addr; phyaddr = -1; /* didn't find a PHY yet */ for (pass = 1; pass <= MAX_PHY_PASSES && phyaddr < 0; ++pass) { if (pass > 1) { /* PHY may need more time to recover from reset. * The LXT970 needs 50ms typical, no maximum is * specified, so wait 10ms before try again. * With 11 passes this gives it 100ms to wake up. */ udelay(10000); /* wait 10ms */ } for (phyno = 0; phyno < 32 && phyaddr < 0; ++phyno) { phytype = mii_send(mk_mii_read(phyno, PHY_PHYIDR1)); #ifdef ET_DEBUG printf("PHY type 0x%x pass %d type\n", phytype, pass); #endif if (phytype != 0xffff) { phyaddr = phyno; phytype <<= 16; phytype |= mii_send(mk_mii_read(phyno, PHY_PHYIDR2)); switch (phytype & 0xffffffff) { case PHY_ID_AMD79C874VC: strcpy(info->phy_name, STR_ID_AMD79C874VC); info->phyname_init = 1; break; default: strcpy(info->phy_name, "unknown"); info->phyname_init = 1; break; } #ifdef ET_DEBUG printf("PHY @ 0x%x pass %d type ", phyno, pass); switch (phytype & 0xffffffff) { case PHY_ID_AMD79C874VC: printf(STR_ID_AMD79C874VC); break; default: printf("0x%08x\n", phytype); break; } #endif } } } if (phyaddr < 0) printf("No PHY device found.\n"); return phyaddr; }
int mii_discover_phy(struct eth_device *dev) { #define MAX_PHY_PASSES 11 FEC_INFO_T *info = dev->priv; int phyaddr, pass; uint phyno, phytype; int i, found = 0; if (info->phyname_init) return info->phy_addr; phyaddr = -1; /* didn't find a PHY yet */ for (pass = 1; pass <= MAX_PHY_PASSES && phyaddr < 0; ++pass) { if (pass > 1) { /* PHY may need more time to recover from reset. * The LXT970 needs 50ms typical, no maximum is * specified, so wait 10ms before try again. * With 11 passes this gives it 100ms to wake up. */ udelay(10000); /* wait 10ms */ } for (phyno = 0; phyno < 32 && phyaddr < 0; ++phyno) { phytype = mii_send(mk_mii_read(phyno, PHY_PHYIDR1)); #ifdef ET_DEBUG printf("PHY type 0x%x pass %d type\n", phytype, pass); #endif if (phytype != 0xffff && phytype != 0) { phyaddr = phyno; phytype <<= 16; phytype |= mii_send(mk_mii_read(phyno, PHY_PHYIDR2)); #ifdef ET_DEBUG printf("PHY @ 0x%x pass %d\n", phyno, pass); #endif for (i = 0; i < (sizeof(phyinfo) / sizeof(phy_info_t)); i++) { if (phyinfo[i].phyid == phytype) { #ifdef ET_DEBUG printf("phyid %x - %s\n", phyinfo[i].phyid, phyinfo[i].strid); #endif strcpy(info->phy_name, phyinfo[i].strid); info->phyname_init = 1; found = 1; break; } } if (!found) { #ifdef ET_DEBUG printf("0x%08x\n", phytype); #endif strcpy(info->phy_name, "unknown"); info->phyname_init = 1; break; } } } } if (phyaddr < 0) printf("No PHY device found.\n"); return phyaddr; }