/* Resets a PHY block and optionally waits for the reset to complete. @mmd should be 0 for 10/100/1000 PHYs and the device address to reset for 10G PHYs.  */
int t3_phy_reset(struct cphy *phy, int mmd, int wait)
/* Resets a PHY block and optionally waits for the reset to complete. @mmd should be 0 for 10/100/1000 PHYs and the device address to reset for 10G PHYs.  */
int t3_phy_reset(struct cphy *phy, int mmd, int wait)
{
	int err;
	unsigned int ctl;
	err = t3_mdio_change_bits(phy, mmd, MDIO_CTRL1, MDIO_CTRL1_LPOWER,
				  MDIO_CTRL1_RESET);
	if (err || !wait)
		return err;
	do {
		err = t3_mdio_read(phy, mmd, MDIO_CTRL1, &ctl);
		if (err)
			return err;
		ctl &= MDIO_CTRL1_RESET;
		if (ctl)
			msleep(1);
	} while (ctl && --wait);
	return ctl ? -1 : 0;
}