Exemplo n.º 1
0
int hieth_mdio_read(struct hieth_mdio_local *ld, int phy_addr, int regnum)
{
	int val = 0;
	hieth_assert((!(phy_addr & (~0x1F))) && (!(regnum & (~0x1F))));

	local_lock(ld);

	if (!wait_mdio_ready(ld)) {
		hieth_error("mdio busy");
		goto error_exit;
	}

	mdio_start_phyread(ld, phy_addr, regnum);

	if (wait_mdio_ready(ld))
		val = mdio_get_phyread_val(ld);
	else
		hieth_error("read timeout");

error_exit:

	local_unlock(ld);

	hieth_trace(4, "phy_addr = %d, regnum = %d, val = 0x%04x",
						phy_addr, regnum, val);

	return val;
}
Exemplo n.º 2
0
static int higmac_mdio_read(struct higmac_mdio_local *ld,
		char *devname, unsigned char phy,
		unsigned char reg, unsigned short *value)
{
	int timeout = 1000;

	if (!wait_mdio_ready(ld))
		return -1;

	mdio_start_phyread(ld, phy, reg);

	while (!wait_mdio_ready(ld) && timeout-- > 0)
		udelay(1);

	if (timeout <= 0 || !test_mdio_read_data_done(ld)) {
		*value = 0;
		/* it should return Error(-1), but miiphy_read() will
		 * print error info, it's annoying
		 */
		return 0;
	}

	*value = mdio_get_phyread_val(ld);

	higmac_trace(2, "mdio read phy:%x, reg:%x = %x\n", phy, reg, *value);

	return 0;
}