static int bcm_sf2_sw_mdio_read(struct mii_bus *bus, int addr, int regnum) { struct bcm_sf2_priv *priv = bus->priv; /* Intercept reads from Broadcom pseudo-PHY address, else, send * them to our master MDIO bus controller */ if (addr == BRCM_PSEUDO_PHY_ADDR && priv->indir_phy_mask & BIT(addr)) return bcm_sf2_sw_indir_rw(priv, 1, addr, regnum, 0); else return mdiobus_read(priv->master_mii_bus, addr, regnum); }
static int bcm_sf2_sw_phy_read(struct dsa_switch *ds, int addr, int regnum) { /* Intercept reads from the MDIO broadcast address or Broadcom * pseudo-PHY address */ switch (addr) { case 0: case BRCM_PSEUDO_PHY_ADDR: return bcm_sf2_sw_indir_rw(ds, 1, addr, regnum, 0); default: return 0xffff; } }
static int bcm_sf2_sw_mdio_write(struct mii_bus *bus, int addr, int regnum, u16 val) { struct bcm_sf2_priv *priv = bus->priv; /* Intercept writes to the Broadcom pseudo-PHY address, else, * send them to our master MDIO bus controller */ if (addr == BRCM_PSEUDO_PHY_ADDR && priv->indir_phy_mask & BIT(addr)) return bcm_sf2_sw_indir_rw(priv, 0, addr, regnum, val); else return mdiobus_write_nested(priv->master_mii_bus, addr, regnum, val); }
static int bcm_sf2_sw_phy_write(struct dsa_switch *ds, int addr, int regnum, u16 val) { /* Intercept writes to the MDIO broadcast address or Broadcom * pseudo-PHY address */ switch (addr) { case 0: case BRCM_PSEUDO_PHY_ADDR: bcm_sf2_sw_indir_rw(ds, 0, addr, regnum, val); break; } return 0; }