[PATCH net-next v4 3/3] net: stmmac: Add glue layer for Spacemit K3 SoC

Russell King (Oracle) linux at armlinux.org.uk
Tue Feb 3 09:48:00 PST 2026


On Fri, Jan 30, 2026 at 10:27:04AM +0800, Inochi Amaoto wrote:
> +/* ctrl register bits */
> +#define CTRL_PHY_INTF_RGMII		BIT(3)
> +#define CTRL_PHY_INTF_MII		BIT(4)
> +#define CTRL_WAKE_IRQ_EN		BIT(9)
> +#define CTRL_PHY_IRQ_EN			BIT(12)

Thanks for updating these.

> +static int spacemit_dwmac_update_ifconfig(struct plat_stmmacenet_data *plat_dat,
> +					  struct stmmac_resources *stmmac_res,
> +					  struct regmap *apmu,
> +					  unsigned int ctrl_offset)
> +{
> +	unsigned int mask = CTRL_PHY_INTF_MII | CTRL_PHY_INTF_RGMII | CTRL_WAKE_IRQ_EN;
> +	unsigned int val = 0;
> +
> +	switch (plat_dat->phy_interface) {
> +	case PHY_INTERFACE_MODE_MII:
> +		val = CTRL_PHY_INTF_MII;
> +		break;
> +
> +	case PHY_INTERFACE_MODE_RMII:
> +		break;
> +
> +	case PHY_INTERFACE_MODE_RGMII:
> +	case PHY_INTERFACE_MODE_RGMII_ID:
> +	case PHY_INTERFACE_MODE_RGMII_RXID:
> +	case PHY_INTERFACE_MODE_RGMII_TXID:
> +		val = CTRL_PHY_INTF_RGMII;
> +		break;
> +
> +	default:
> +		return -EOPNOTSUPP;
> +	}
> +
> +	if (stmmac_res->wol_irq >= 0)
> +		val |= CTRL_WAKE_IRQ_EN;
> +
> +	return regmap_update_bits(apmu, ctrl_offset, mask, val);

I would suggest that this is split into two parts - first, this is
renamed and reduced to just controlling CTRL_WAKE_IRQ_EN.

Next, a function hooked into plat_dat->set_phy_intf_sel which sets
the CTRL_PHY_INTF_RGMII and CTRL_PHY_INTF_MII bits as appropriate.
Note that this function is passed the dwmac's own phy_intf_sel
value from common.h which will be PHY_INTF_SEL_GMII_MII,
PHY_INTF_SEL_RGMII or PHY_INTF_SEL_RMII for you.

It would also be good to have plat_dat->get_interfaces populated
using phy_interface_set_rgmii(), and __set_bit(PHY_INTERFACE_MODE_MII)
and __set_bit(PHY_INTERFACE_MODE_RMII) to indicate to phylink which
interface modes are permissable.

Thanks.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!



More information about the linux-arm-kernel mailing list