Ejemplo n.º 1
0
static int sr_mdio_read(struct net_device *netdev, int phy_id, int loc)
{
	struct usbnet *dev = netdev_priv(netdev);
	__le16 res;
	int rc = 0;

	if (phy_id) {
		netdev_dbg(netdev, "Only internal phy supported\n");
		return 0;
	}

	/* Access NSR_LINKST bit for link status instead of MII_BMSR */
	if (loc == MII_BMSR) {
		u8 value;

		sr_read_reg(dev, SR_NSR, &value);
		if (value & NSR_LINKST)
			rc = 1;
	}
	sr_share_read_word(dev, 1, loc, &res);
	if (rc == 1)
		res = le16_to_cpu(res) | BMSR_LSTATUS;
	else
		res = le16_to_cpu(res) & ~BMSR_LSTATUS;

	netdev_dbg(netdev, "sr_mdio_read() phy_id=0x%02x, loc=0x%02x, returns=0x%04x\n",
		   phy_id, loc, res);

	return res;
}
Ejemplo n.º 2
0
/* sr9700_android mii-phy register read by word */
static int sr9700_android_mdio_read(struct net_device *netdev, int phy_id, int loc)
{
	struct usbnet *dev = netdev_priv(netdev);

	__le16 res;
#ifdef	MII_BUG_FIX
	int rc = 0;
#endif

	if (phy_id) {
		netdev_dbg(dev->net, "Only internal phy supported");
		return 0;
	}

#ifdef	MII_BUG_FIX
	if(loc == MII_BMSR){
			u8 value;
			sr_read_reg(dev, NSR, &value);
			if(value & NSR_LINKST) {
				rc = 1;
			}
	}
	sr_share_read_word(dev, 1, loc, &res);
	if(rc == 1)
			return (le16_to_cpu(res) | BMSR_LSTATUS);
	else
			return (le16_to_cpu(res) & ~BMSR_LSTATUS);
#else
	sr_share_read_word(dev, 1, loc, &res);
#endif

	netdev_dbg(dev->net,
	       "sr9700_android_mdio_read() phy_id=0x%02x, loc=0x%02x, returns=0x%04x",
	       phy_id, loc, le16_to_cpu(res));

	return le16_to_cpu(res);
}
Ejemplo n.º 3
0
static int sr_read_eeprom_word(struct usbnet *dev, u8 offset, void *value)
{
	return sr_share_read_word(dev, 0, offset, value);
}