Пример #1
0
static int lpc_mdio_read(struct mii_bus *bus, int phy_id, int phyreg)
{
	//printk("xxxxxxxxxxx ent\n" );
	//int lps = myread(bus, phy_id, phyreg);

	struct netdata_local *pldat = bus->priv;
	unsigned long timeout = jiffies + ((HZ * 100) / 1000); /* 100mS */
	int lps;

	writel(((phy_id << 8) | phyreg), LPC_ENET_MADR(pldat->net_base));
	writel(LPC_MCMD_READ, LPC_ENET_MCMD(pldat->net_base));

	/* Wait for unbusy status */
	while (readl(LPC_ENET_MIND(pldat->net_base)) & LPC_MIND_BUSY) {
		//if (jiffies > timeout) {
		if (time_after(jiffies, timeout)) {
			//printk("yyyyyyyyyyyyyyy mind=%x, mrdd=%x\n", readl(LPC_ENET_MIND(pldat->net_base)), readl(LPC_ENET_MRDD(pldat->net_base)));
			printk("yyyyyyyyyyyyyyy mind=%x, mrdd=%x timeout=%u jiffies=%u\n", readl(LPC_ENET_MIND(pldat->net_base)), readl(LPC_ENET_MRDD(pldat->net_base)), timeout, jiffies);
			mdelay(100);
			printk("yyyyyyyyyyyyyyy mind=%x, mrdd=%x timeout=%u jiffies=%u\n", readl(LPC_ENET_MIND(pldat->net_base)), readl(LPC_ENET_MRDD(pldat->net_base)), timeout, jiffies);
			return -EIO;
		}
		cpu_relax();
	}

	lps = (int) readl(LPC_ENET_MRDD(pldat->net_base));
	writel(0, LPC_ENET_MCMD(pldat->net_base));
	
	//printk("xxxxxxxxxxx lps=%x jffies=%x\n", lps, jiffies);
	return lps;
}
Пример #2
0
static int lpc_mdio_write(struct mii_bus *bus, int phy_id, int phyreg,
			u16 phydata)
{
	struct netdata_local *pldat = bus->priv;
	unsigned long timeout = jiffies + msecs_to_jiffies(100);

	writel(((phy_id << 8) | phyreg), LPC_ENET_MADR(pldat->net_base));
	writel(phydata, LPC_ENET_MWTD(pldat->net_base));

	/* Wait for completion */
	while (readl(LPC_ENET_MIND(pldat->net_base)) & LPC_MIND_BUSY) {
		if (time_after(jiffies, timeout))
			return -EIO;
		cpu_relax();
	}

	return 0;
}
Пример #3
0
/*
 * MAC<--->PHY support functions
 */
static int lpc_mdio_read(struct mii_bus *bus, int phy_id, int phyreg)
{
	struct netdata_local *pldat = bus->priv;
	unsigned long timeout = jiffies + msecs_to_jiffies(100);
	int lps;

	writel(((phy_id << 8) | phyreg), LPC_ENET_MADR(pldat->net_base));
	writel(LPC_MCMD_READ, LPC_ENET_MCMD(pldat->net_base));

	/* Wait for unbusy status */
	while (readl(LPC_ENET_MIND(pldat->net_base)) & LPC_MIND_BUSY) {
		if (time_after(jiffies, timeout))
			return -EIO;
		cpu_relax();
	}

	lps = readl(LPC_ENET_MRDD(pldat->net_base));
	writel(0, LPC_ENET_MCMD(pldat->net_base));

	return lps;
}