/* stmmac_mdio_write @bus: points to the mii_bus structure @phyaddr: MII addr reg bits 15-11 @phyreg: MII addr reg bits 10-6 @phydata: phy data Description: it writes the data into the MII register from within the device.  */
static int stmmac_mdio_write(struct mii_bus *bus, int phyaddr, int phyreg, u16 phydata)
/* stmmac_mdio_write @bus: points to the mii_bus structure @phyaddr: MII addr reg bits 15-11 @phyreg: MII addr reg bits 10-6 @phydata: phy data Description: it writes the data into the MII register from within the device.  */
static int stmmac_mdio_write(struct mii_bus *bus, int phyaddr, int phyreg, u16 phydata)
{
	struct net_device *ndev = bus->priv;
	struct stmmac_priv *priv = netdev_priv(ndev);
	unsigned long ioaddr = ndev->base_addr;
	unsigned int mii_address = priv->mac_type->hw.mii.addr;
	unsigned int mii_data = priv->mac_type->hw.mii.data;
	u16 value =
	    (((phyaddr << 11) & (0x0000F800)) | ((phyreg << 6) & (0x000007C0)))
	    | MII_WRITE;
	value |= MII_BUSY;
	do {} while (((readl(ioaddr + mii_address)) & MII_BUSY) == 1);
	writel(phydata, ioaddr + mii_data);
	writel(value, ioaddr + mii_address);
	do {} while (((readl(ioaddr + mii_address)) & MII_BUSY) == 1);
	return 0;
}