From: Marek Vasut Date: Sat, 22 Feb 2025 20:33:24 +0000 (+0100) Subject: arm: mvebu: a38x: Allocate bb_miiphy using bb_miiphy_alloc() and fill in callbacks X-Git-Tag: v2025.07-rc1~18^2~76^2~9 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7ab90e1c9e7679f2b5697737599cfa179cebee40;p=pandora-u-boot.git arm: mvebu: a38x: Allocate bb_miiphy using bb_miiphy_alloc() and fill in callbacks Allocate bb_miiphy using bb_miiphy_alloc() and fill in callbacks currently listed in bb_miiphy_buses[] array. This is a temporary duplication of assignment to avoid breakage, which will be removed in follow up patches. At this point, the bb_miiphy callbacks can reach these accessors by doing container_of() on struct mii_dev. Signed-off-by: Marek Vasut Reviewed-by: Paul Barker --- diff --git a/board/gdsys/a38x/ihs_phys.c b/board/gdsys/a38x/ihs_phys.c index 86708ee6715..a121898be52 100644 --- a/board/gdsys/a38x/ihs_phys.c +++ b/board/gdsys/a38x/ihs_phys.c @@ -221,22 +221,35 @@ static int mii_delay(struct bb_miiphy_bus *bus) int register_miiphy_bus(uint k, struct mii_dev **bus) { - int retval; - struct mii_dev *mdiodev = mdio_alloc(); + struct bb_miiphy_bus *bb_miiphy = bb_miiphy_alloc(); + struct mii_dev *mdiodev; char *name = bb_miiphy_buses[k].name; + int retval; - if (!mdiodev) + if (!bb_miiphy) return -ENOMEM; + + mdiodev = &bb_miiphy->mii; strlcpy(mdiodev->name, name, MDIO_NAME_LEN); mdiodev->read = bb_miiphy_read; mdiodev->write = bb_miiphy_write; + /* Copy the bus accessors, name and private data */ + bb_miiphy->mdio_active = mii_mdio_active; + bb_miiphy->mdio_tristate = mii_mdio_tristate; + bb_miiphy->set_mdio = mii_set_mdio; + bb_miiphy->get_mdio = mii_get_mdio; + bb_miiphy->set_mdc = mii_set_mdc; + bb_miiphy->delay = mii_delay; + strlcpy(bb_miiphy->name, name, MDIO_NAME_LEN); + bb_miiphy->priv = &gpio_mii_set[k]; + retval = mdio_register(mdiodev); if (retval < 0) return retval; *bus = miiphy_get_dev_by_name(name); - return mii_mdio_init(&bb_miiphy_buses[k]); + return mii_mdio_init(bb_miiphy); } struct porttype *get_porttype(uint octo_phy_mask, uint k)