static int arc_emac_mdio_write(struct mii_bus *bus, int phy_addr, int reg_num, u16 value) { struct arc_emac_priv *priv = bus->priv; arc_reg_set(priv, R_MDIO, 0x50020000 | (phy_addr << 23) | (reg_num << 18) | value); return arc_mdio_complete_wait(priv); }
/** * arc_mdio_write - MDIO interface write function. * @bus: Pointer to MII bus structure. * @phy_addr: Address of the PHY device. * @reg_num: PHY register to write to. * @value: Value to be written into the register. * * returns: 0 on success, -ETIMEDOUT on a timeout. * * Writes the value to the requested register. */ static int arc_mdio_write(struct mii_bus *bus, int phy_addr, int reg_num, u16 value) { struct arc_emac_priv *priv = bus->priv; dev_dbg(priv->dev, "arc_mdio_write(phy_addr=%i, reg_num=%x, value=%x)\n", phy_addr, reg_num, value); arc_reg_set(priv, R_MDIO, 0x50020000 | (phy_addr << 23) | (reg_num << 18) | value); return arc_mdio_complete_wait(priv); }
static int arc_emac_mdio_read(struct mii_bus *bus, int phy_addr, int reg_num) { struct arc_emac_priv *priv = bus->priv; int error; arc_reg_set(priv, R_MDIO, 0x60020000 | (phy_addr << 23) | (reg_num << 18)); error = arc_mdio_complete_wait(priv); if (error < 0) return error; return arc_reg_get(priv, R_MDIO) & 0xffff; }
/** * arc_mdio_read - MDIO interface read function. * @bus: Pointer to MII bus structure. * @phy_addr: Address of the PHY device. * @reg_num: PHY register to read. * * returns: The register contents on success, -ETIMEDOUT on a timeout. * * Reads the contents of the requested register from the requested PHY * address. */ static int arc_mdio_read(struct mii_bus *bus, int phy_addr, int reg_num) { struct arc_emac_priv *priv = bus->priv; unsigned int value; int error; arc_reg_set(priv, R_MDIO, 0x60020000 | (phy_addr << 23) | (reg_num << 18)); error = arc_mdio_complete_wait(priv); if (error < 0) return error; value = arc_reg_get(priv, R_MDIO) & 0xffff; dev_dbg(priv->dev, "arc_mdio_read(phy_addr=%i, reg_num=%x) = %x\n", phy_addr, reg_num, value); return value; }