[PATCH v3 17/23] net: designware: Allocate bb_miiphy using bb_miiphy_alloc() and fill in callbacks
Marek Vasut
marek.vasut+renesas at mailbox.org
Sat Feb 22 21:33:27 CET 2025
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 <marek.vasut+renesas at mailbox.org>
---
Cc: Christian Marangi <ansuelsmth at gmail.com>
Cc: Ilias Apalodimas <ilias.apalodimas at linaro.org>
Cc: Jerome Forissier <jerome.forissier at linaro.org>
Cc: Jim Liu <JJLIU0 at nuvoton.com>
Cc: Joe Hershberger <joe.hershberger at ni.com>
Cc: Mario Six <mario.six at gdsys.cc>
Cc: Michal Simek <michal.simek at amd.com>
Cc: Nobuhiro Iwamatsu <iwamatsu at nigauri.org>
Cc: Paul Barker <paul.barker.ct at bp.renesas.com>
Cc: Ramon Fried <rfried.dev at gmail.com>
Cc: Simon Glass <sjg at chromium.org>
Cc: Sughosh Ganu <sughosh.ganu at linaro.org>
Cc: Tom Rini <trini at konsulko.com>
Cc: u-boot at lists.denx.de
---
V2: New patch
V3: No change
---
drivers/net/designware.c | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
diff --git a/drivers/net/designware.c b/drivers/net/designware.c
index c88b8df28ed..74cf8271e67 100644
--- a/drivers/net/designware.c
+++ b/drivers/net/designware.c
@@ -307,14 +307,17 @@ int bb_miiphy_buses_num = ARRAY_SIZE(bb_miiphy_buses);
static int dw_bb_mdio_init(const char *name, struct udevice *dev)
{
struct dw_eth_dev *dwpriv = dev_get_priv(dev);
- struct mii_dev *bus = mdio_alloc();
+ struct bb_miiphy_bus *bb_miiphy = bb_miiphy_alloc();
+ struct mii_dev *bus;
int ret;
- if (!bus) {
+ if (!bb_miiphy) {
printf("Failed to allocate MDIO bus\n");
return -ENOMEM;
}
+ bus = &bb_miiphy->mii;
+
debug("\n%s: use bitbang mii..\n", dev->name);
ret = gpio_request_by_name(dev, "snps,mdc-gpio", 0,
&dwpriv->mdc_gpio,
@@ -345,6 +348,15 @@ static int dw_bb_mdio_init(const char *name, struct udevice *dev)
#endif
bus->priv = dwpriv;
+ /* Copy the bus accessors, name and private data */
+ bb_miiphy->mdio_active = dw_eth_bb_mdio_active;
+ bb_miiphy->mdio_tristate = dw_eth_bb_mdio_tristate;
+ bb_miiphy->set_mdio = dw_eth_bb_set_mdio;
+ bb_miiphy->get_mdio = dw_eth_bb_get_mdio;
+ bb_miiphy->set_mdc = dw_eth_bb_set_mdc;
+ bb_miiphy->delay = dw_eth_bb_delay;
+ strlcpy(bb_miiphy->name, bus->name, MDIO_NAME_LEN);
+
return mdio_register(bus);
}
#endif
@@ -968,7 +980,12 @@ int designware_eth_probe(struct udevice *dev)
/* continue here for cleanup if no PHY found */
err = ret;
mdio_unregister(priv->bus);
- mdio_free(priv->bus);
+#if IS_ENABLED(CONFIG_BITBANGMII) && IS_ENABLED(CONFIG_DM_GPIO)
+ if (bbmiiphy)
+ bb_miiphy_free(container_of(priv->bus, struct bb_miiphy_bus, mii));
+ else
+#endif
+ mdio_free(priv->bus);
mdio_err:
#ifdef CONFIG_CLK
--
2.47.2
More information about the U-Boot
mailing list