Ejemplo n.º 1
0
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;
}
Ejemplo n.º 2
0
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;
}
Ejemplo n.º 3
0
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;
}