[PATCH net-next v11 2/5] net: spacemit: Add K1 Ethernet MAC
Andrew Lunn
andrew at lunn.ch
Fri Sep 12 14:10:51 PDT 2025
> +static u32 emac_rd(struct emac_priv *priv, u32 reg)
> +{
> + return readl(priv->iobase + reg);
> +}
> +static int emac_mii_read(struct mii_bus *bus, int phy_addr, int regnum)
> +{
> + struct emac_priv *priv = bus->priv;
> + u32 cmd = 0, val;
> + int ret;
> +
> + cmd |= FIELD_PREP(MREGBIT_PHY_ADDRESS, phy_addr);
> + cmd |= FIELD_PREP(MREGBIT_REGISTER_ADDRESS, regnum);
> + cmd |= MREGBIT_START_MDIO_TRANS | MREGBIT_MDIO_READ_WRITE;
> +
> + emac_wr(priv, MAC_MDIO_DATA, 0x0);
> + emac_wr(priv, MAC_MDIO_CONTROL, cmd);
> +
> + ret = readl_poll_timeout(priv->iobase + MAC_MDIO_CONTROL, val,
> + !(val & MREGBIT_START_MDIO_TRANS), 100, 10000);
> +
> + if (ret)
> + return ret;
> +
> + val = emac_rd(priv, MAC_MDIO_DATA);
> + return val;
emac_rd() returns a u32. Is it guaranteed by the hardware that the
upper word is 0? Maybe this needs to be masked?
Andrew
More information about the linux-riscv
mailing list