From c835f5c8463f34e780e696ea42779fb571356d64 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sat, 22 Feb 2025 21:33:11 +0100 Subject: net: ravb: Drop empty init callback The init function does nothing, the bb_miiphy_init() already checks whether the .init callback is assigned, and if not, skips calling it. Remove the empty init function. The entire init callback will be removed in follow up patches. Reviewed-by: Paul Barker Signed-off-by: Marek Vasut --- drivers/net/ravb.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'drivers') diff --git a/drivers/net/ravb.c b/drivers/net/ravb.c index 7286ad19598..5df557da7da 100644 --- a/drivers/net/ravb.c +++ b/drivers/net/ravb.c @@ -560,11 +560,6 @@ static int ravb_remove(struct udevice *dev) return 0; } -static int ravb_bb_init(struct bb_miiphy_bus *bus) -{ - return 0; -} - static int ravb_bb_mdio_active(struct bb_miiphy_bus *bus) { struct ravb_priv *eth = bus->priv; @@ -626,7 +621,6 @@ static int ravb_bb_delay(struct bb_miiphy_bus *bus) struct bb_miiphy_bus bb_miiphy_buses[] = { { .name = "ravb", - .init = ravb_bb_init, .mdio_active = ravb_bb_mdio_active, .mdio_tristate = ravb_bb_mdio_tristate, .set_mdio = ravb_bb_set_mdio, -- cgit v1.2.3 From 4e984c1160f2d23c4ad5dd31df6f809a3994a4ee Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sat, 22 Feb 2025 21:33:12 +0100 Subject: net: sh_eth: Drop empty init callback The init function does nothing, the bb_miiphy_init() already checks whether the .init callback is assigned, and if not, skips calling it. Remove the empty init function. The entire init callback will be removed in follow up patches. Reviewed-by: Paul Barker Signed-off-by: Marek Vasut --- drivers/net/sh_eth.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'drivers') diff --git a/drivers/net/sh_eth.c b/drivers/net/sh_eth.c index f1ce994cfd5..b607b9a3a43 100644 --- a/drivers/net/sh_eth.c +++ b/drivers/net/sh_eth.c @@ -777,11 +777,6 @@ U_BOOT_DRIVER(eth_sh_ether) = { }; /******* for bb_miiphy *******/ -static int sh_eth_bb_init(struct bb_miiphy_bus *bus) -{ - return 0; -} - static int sh_eth_bb_mdio_active(struct bb_miiphy_bus *bus) { struct sh_eth_dev *eth = bus->priv; @@ -852,7 +847,6 @@ static int sh_eth_bb_delay(struct bb_miiphy_bus *bus) struct bb_miiphy_bus bb_miiphy_buses[] = { { .name = "sh_eth", - .init = sh_eth_bb_init, .mdio_active = sh_eth_bb_mdio_active, .mdio_tristate = sh_eth_bb_mdio_tristate, .set_mdio = sh_eth_bb_set_mdio, -- cgit v1.2.3 From 165fba6c91ce99e7ed40a83e11a937e571fe1e1a Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sat, 22 Feb 2025 21:33:13 +0100 Subject: net: designware: Drop NULL priv assignment This is unnecessary, the unset structure member is initialized to NULL by default, drop the assignment. Reviewed-by: Paul Barker Signed-off-by: Marek Vasut --- drivers/net/designware.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers') diff --git a/drivers/net/designware.c b/drivers/net/designware.c index 2ab03015ffa..c17b4078d5a 100644 --- a/drivers/net/designware.c +++ b/drivers/net/designware.c @@ -1041,7 +1041,6 @@ struct bb_miiphy_bus bb_miiphy_buses[] = { .get_mdio = dw_eth_bb_get_mdio, .set_mdc = dw_eth_bb_set_mdc, .delay = dw_eth_bb_delay, - .priv = NULL, } }; -- cgit v1.2.3 From 83064d5e3be0857cea39439a140aed151c103532 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sat, 22 Feb 2025 21:33:14 +0100 Subject: net: ravb: Reorder bb_miiphy functions Move the bb_miiphy functions before MDIO registration. This is a preparatory patch, the functions will be referenced around the MDIO registration in the follow up patches. No functional change. Reviewed-by: Paul Barker Signed-off-by: Marek Vasut --- drivers/net/ravb.c | 117 +++++++++++++++++++++++++++-------------------------- 1 file changed, 59 insertions(+), 58 deletions(-) (limited to 'drivers') diff --git a/drivers/net/ravb.c b/drivers/net/ravb.c index 5df557da7da..381cf250ea2 100644 --- a/drivers/net/ravb.c +++ b/drivers/net/ravb.c @@ -490,6 +490,65 @@ static void ravb_stop(struct udevice *dev) ravb_reset(dev); } +/* Bitbang MDIO access */ +static int ravb_bb_mdio_active(struct bb_miiphy_bus *bus) +{ + struct ravb_priv *eth = bus->priv; + + setbits_le32(eth->iobase + RAVB_REG_PIR, PIR_MMD); + + return 0; +} + +static int ravb_bb_mdio_tristate(struct bb_miiphy_bus *bus) +{ + struct ravb_priv *eth = bus->priv; + + clrbits_le32(eth->iobase + RAVB_REG_PIR, PIR_MMD); + + return 0; +} + +static int ravb_bb_set_mdio(struct bb_miiphy_bus *bus, int v) +{ + struct ravb_priv *eth = bus->priv; + + if (v) + setbits_le32(eth->iobase + RAVB_REG_PIR, PIR_MDO); + else + clrbits_le32(eth->iobase + RAVB_REG_PIR, PIR_MDO); + + return 0; +} + +static int ravb_bb_get_mdio(struct bb_miiphy_bus *bus, int *v) +{ + struct ravb_priv *eth = bus->priv; + + *v = (readl(eth->iobase + RAVB_REG_PIR) & PIR_MDI) >> 3; + + return 0; +} + +static int ravb_bb_set_mdc(struct bb_miiphy_bus *bus, int v) +{ + struct ravb_priv *eth = bus->priv; + + if (v) + setbits_le32(eth->iobase + RAVB_REG_PIR, PIR_MDC); + else + clrbits_le32(eth->iobase + RAVB_REG_PIR, PIR_MDC); + + return 0; +} + +static int ravb_bb_delay(struct bb_miiphy_bus *bus) +{ + udelay(10); + + return 0; +} + static int ravb_probe(struct udevice *dev) { struct eth_pdata *pdata = dev_get_plat(dev); @@ -560,64 +619,6 @@ static int ravb_remove(struct udevice *dev) return 0; } -static int ravb_bb_mdio_active(struct bb_miiphy_bus *bus) -{ - struct ravb_priv *eth = bus->priv; - - setbits_le32(eth->iobase + RAVB_REG_PIR, PIR_MMD); - - return 0; -} - -static int ravb_bb_mdio_tristate(struct bb_miiphy_bus *bus) -{ - struct ravb_priv *eth = bus->priv; - - clrbits_le32(eth->iobase + RAVB_REG_PIR, PIR_MMD); - - return 0; -} - -static int ravb_bb_set_mdio(struct bb_miiphy_bus *bus, int v) -{ - struct ravb_priv *eth = bus->priv; - - if (v) - setbits_le32(eth->iobase + RAVB_REG_PIR, PIR_MDO); - else - clrbits_le32(eth->iobase + RAVB_REG_PIR, PIR_MDO); - - return 0; -} - -static int ravb_bb_get_mdio(struct bb_miiphy_bus *bus, int *v) -{ - struct ravb_priv *eth = bus->priv; - - *v = (readl(eth->iobase + RAVB_REG_PIR) & PIR_MDI) >> 3; - - return 0; -} - -static int ravb_bb_set_mdc(struct bb_miiphy_bus *bus, int v) -{ - struct ravb_priv *eth = bus->priv; - - if (v) - setbits_le32(eth->iobase + RAVB_REG_PIR, PIR_MDC); - else - clrbits_le32(eth->iobase + RAVB_REG_PIR, PIR_MDC); - - return 0; -} - -static int ravb_bb_delay(struct bb_miiphy_bus *bus) -{ - udelay(10); - - return 0; -} - struct bb_miiphy_bus bb_miiphy_buses[] = { { .name = "ravb", -- cgit v1.2.3 From d8a1768eea5ef3abbff9d0353599b7757ebccb4a Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sat, 22 Feb 2025 21:33:15 +0100 Subject: net: sh_eth: Reorder bb_miiphy functions Move the bb_miiphy functions before MDIO registration. This is a preparatory patch, the functions will be referenced around the MDIO registration in the follow up patches. No functional change. Signed-off-by: Marek Vasut Reviewed-by: Paul Barker --- drivers/net/sh_eth.c | 136 +++++++++++++++++++++++++-------------------------- 1 file changed, 68 insertions(+), 68 deletions(-) (limited to 'drivers') diff --git a/drivers/net/sh_eth.c b/drivers/net/sh_eth.c index b607b9a3a43..6bd12ee3f19 100644 --- a/drivers/net/sh_eth.c +++ b/drivers/net/sh_eth.c @@ -643,6 +643,74 @@ static void sh_ether_stop(struct udevice *dev) sh_eth_stop(&priv->shdev); } +/******* for bb_miiphy *******/ +static int sh_eth_bb_mdio_active(struct bb_miiphy_bus *bus) +{ + struct sh_eth_dev *eth = bus->priv; + struct sh_eth_info *port_info = ð->port_info[eth->port]; + + sh_eth_write(port_info, sh_eth_read(port_info, PIR) | PIR_MMD, PIR); + + return 0; +} + +static int sh_eth_bb_mdio_tristate(struct bb_miiphy_bus *bus) +{ + struct sh_eth_dev *eth = bus->priv; + struct sh_eth_info *port_info = ð->port_info[eth->port]; + + sh_eth_write(port_info, sh_eth_read(port_info, PIR) & ~PIR_MMD, PIR); + + return 0; +} + +static int sh_eth_bb_set_mdio(struct bb_miiphy_bus *bus, int v) +{ + struct sh_eth_dev *eth = bus->priv; + struct sh_eth_info *port_info = ð->port_info[eth->port]; + + if (v) + sh_eth_write(port_info, + sh_eth_read(port_info, PIR) | PIR_MDO, PIR); + else + sh_eth_write(port_info, + sh_eth_read(port_info, PIR) & ~PIR_MDO, PIR); + + return 0; +} + +static int sh_eth_bb_get_mdio(struct bb_miiphy_bus *bus, int *v) +{ + struct sh_eth_dev *eth = bus->priv; + struct sh_eth_info *port_info = ð->port_info[eth->port]; + + *v = (sh_eth_read(port_info, PIR) & PIR_MDI) >> 3; + + return 0; +} + +static int sh_eth_bb_set_mdc(struct bb_miiphy_bus *bus, int v) +{ + struct sh_eth_dev *eth = bus->priv; + struct sh_eth_info *port_info = ð->port_info[eth->port]; + + if (v) + sh_eth_write(port_info, + sh_eth_read(port_info, PIR) | PIR_MDC, PIR); + else + sh_eth_write(port_info, + sh_eth_read(port_info, PIR) & ~PIR_MDC, PIR); + + return 0; +} + +static int sh_eth_bb_delay(struct bb_miiphy_bus *bus) +{ + udelay(10); + + return 0; +} + static int sh_ether_probe(struct udevice *udev) { struct eth_pdata *pdata = dev_get_plat(udev); @@ -776,74 +844,6 @@ U_BOOT_DRIVER(eth_sh_ether) = { .flags = DM_FLAG_ALLOC_PRIV_DMA, }; -/******* for bb_miiphy *******/ -static int sh_eth_bb_mdio_active(struct bb_miiphy_bus *bus) -{ - struct sh_eth_dev *eth = bus->priv; - struct sh_eth_info *port_info = ð->port_info[eth->port]; - - sh_eth_write(port_info, sh_eth_read(port_info, PIR) | PIR_MMD, PIR); - - return 0; -} - -static int sh_eth_bb_mdio_tristate(struct bb_miiphy_bus *bus) -{ - struct sh_eth_dev *eth = bus->priv; - struct sh_eth_info *port_info = ð->port_info[eth->port]; - - sh_eth_write(port_info, sh_eth_read(port_info, PIR) & ~PIR_MMD, PIR); - - return 0; -} - -static int sh_eth_bb_set_mdio(struct bb_miiphy_bus *bus, int v) -{ - struct sh_eth_dev *eth = bus->priv; - struct sh_eth_info *port_info = ð->port_info[eth->port]; - - if (v) - sh_eth_write(port_info, - sh_eth_read(port_info, PIR) | PIR_MDO, PIR); - else - sh_eth_write(port_info, - sh_eth_read(port_info, PIR) & ~PIR_MDO, PIR); - - return 0; -} - -static int sh_eth_bb_get_mdio(struct bb_miiphy_bus *bus, int *v) -{ - struct sh_eth_dev *eth = bus->priv; - struct sh_eth_info *port_info = ð->port_info[eth->port]; - - *v = (sh_eth_read(port_info, PIR) & PIR_MDI) >> 3; - - return 0; -} - -static int sh_eth_bb_set_mdc(struct bb_miiphy_bus *bus, int v) -{ - struct sh_eth_dev *eth = bus->priv; - struct sh_eth_info *port_info = ð->port_info[eth->port]; - - if (v) - sh_eth_write(port_info, - sh_eth_read(port_info, PIR) | PIR_MDC, PIR); - else - sh_eth_write(port_info, - sh_eth_read(port_info, PIR) & ~PIR_MDC, PIR); - - return 0; -} - -static int sh_eth_bb_delay(struct bb_miiphy_bus *bus) -{ - udelay(10); - - return 0; -} - struct bb_miiphy_bus bb_miiphy_buses[] = { { .name = "sh_eth", -- cgit v1.2.3 From bc8d7288e31a43b8ec18d3bf39cc7cb69709251e Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sat, 22 Feb 2025 21:33:17 +0100 Subject: net: designware: Reorder bb_miiphy functions Move the bb_miiphy functions before MDIO registration. This is a preparatory patch, the functions will be referenced around the MDIO registration in the follow up patches. No functional change. Signed-off-by: Marek Vasut Reviewed-by: Paul Barker --- drivers/net/designware.c | 158 +++++++++++++++++++++++------------------------ 1 file changed, 79 insertions(+), 79 deletions(-) (limited to 'drivers') diff --git a/drivers/net/designware.c b/drivers/net/designware.c index c17b4078d5a..95a459cec2a 100644 --- a/drivers/net/designware.c +++ b/drivers/net/designware.c @@ -226,6 +226,85 @@ static int dw_dm_mdio_init(const char *name, void *priv) } #endif +#if IS_ENABLED(CONFIG_BITBANGMII) && IS_ENABLED(CONFIG_DM_GPIO) +static int dw_eth_bb_mdio_active(struct bb_miiphy_bus *bus) +{ + struct dw_eth_dev *priv = bus->priv; + struct gpio_desc *desc = &priv->mdio_gpio; + + desc->flags = 0; + dm_gpio_set_dir_flags(&priv->mdio_gpio, GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE); + + return 0; +} + +static int dw_eth_bb_mdio_tristate(struct bb_miiphy_bus *bus) +{ + struct dw_eth_dev *priv = bus->priv; + struct gpio_desc *desc = &priv->mdio_gpio; + + desc->flags = 0; + dm_gpio_set_dir_flags(&priv->mdio_gpio, GPIOD_IS_IN); + + return 0; +} + +static int dw_eth_bb_set_mdio(struct bb_miiphy_bus *bus, int v) +{ + struct dw_eth_dev *priv = bus->priv; + + if (v) + dm_gpio_set_value(&priv->mdio_gpio, 1); + else + dm_gpio_set_value(&priv->mdio_gpio, 0); + + return 0; +} + +static int dw_eth_bb_get_mdio(struct bb_miiphy_bus *bus, int *v) +{ + struct dw_eth_dev *priv = bus->priv; + + *v = dm_gpio_get_value(&priv->mdio_gpio); + + return 0; +} + +static int dw_eth_bb_set_mdc(struct bb_miiphy_bus *bus, int v) +{ + struct dw_eth_dev *priv = bus->priv; + + if (v) + dm_gpio_set_value(&priv->mdc_gpio, 1); + else + dm_gpio_set_value(&priv->mdc_gpio, 0); + + return 0; +} + +static int dw_eth_bb_delay(struct bb_miiphy_bus *bus) +{ + struct dw_eth_dev *priv = bus->priv; + + udelay(priv->bb_delay); + return 0; +} + +struct bb_miiphy_bus bb_miiphy_buses[] = { + { + .name = BB_MII_DEVNAME, + .mdio_active = dw_eth_bb_mdio_active, + .mdio_tristate = dw_eth_bb_mdio_tristate, + .set_mdio = dw_eth_bb_set_mdio, + .get_mdio = dw_eth_bb_get_mdio, + .set_mdc = dw_eth_bb_set_mdc, + .delay = dw_eth_bb_delay, + } +}; + +int bb_miiphy_buses_num = ARRAY_SIZE(bb_miiphy_buses); +#endif + static void tx_descs_init(struct dw_eth_dev *priv) { struct eth_dma_regs *dma_p = priv->dma_regs_p; @@ -967,82 +1046,3 @@ static struct pci_device_id supported[] = { }; U_BOOT_PCI_DEVICE(eth_designware, supported); - -#if IS_ENABLED(CONFIG_BITBANGMII) && IS_ENABLED(CONFIG_DM_GPIO) -static int dw_eth_bb_mdio_active(struct bb_miiphy_bus *bus) -{ - struct dw_eth_dev *priv = bus->priv; - struct gpio_desc *desc = &priv->mdio_gpio; - - desc->flags = 0; - dm_gpio_set_dir_flags(&priv->mdio_gpio, GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE); - - return 0; -} - -static int dw_eth_bb_mdio_tristate(struct bb_miiphy_bus *bus) -{ - struct dw_eth_dev *priv = bus->priv; - struct gpio_desc *desc = &priv->mdio_gpio; - - desc->flags = 0; - dm_gpio_set_dir_flags(&priv->mdio_gpio, GPIOD_IS_IN); - - return 0; -} - -static int dw_eth_bb_set_mdio(struct bb_miiphy_bus *bus, int v) -{ - struct dw_eth_dev *priv = bus->priv; - - if (v) - dm_gpio_set_value(&priv->mdio_gpio, 1); - else - dm_gpio_set_value(&priv->mdio_gpio, 0); - - return 0; -} - -static int dw_eth_bb_get_mdio(struct bb_miiphy_bus *bus, int *v) -{ - struct dw_eth_dev *priv = bus->priv; - - *v = dm_gpio_get_value(&priv->mdio_gpio); - - return 0; -} - -static int dw_eth_bb_set_mdc(struct bb_miiphy_bus *bus, int v) -{ - struct dw_eth_dev *priv = bus->priv; - - if (v) - dm_gpio_set_value(&priv->mdc_gpio, 1); - else - dm_gpio_set_value(&priv->mdc_gpio, 0); - - return 0; -} - -static int dw_eth_bb_delay(struct bb_miiphy_bus *bus) -{ - struct dw_eth_dev *priv = bus->priv; - - udelay(priv->bb_delay); - return 0; -} - -struct bb_miiphy_bus bb_miiphy_buses[] = { - { - .name = BB_MII_DEVNAME, - .mdio_active = dw_eth_bb_mdio_active, - .mdio_tristate = dw_eth_bb_mdio_tristate, - .set_mdio = dw_eth_bb_set_mdio, - .get_mdio = dw_eth_bb_get_mdio, - .set_mdc = dw_eth_bb_set_mdc, - .delay = dw_eth_bb_delay, - } -}; - -int bb_miiphy_buses_num = ARRAY_SIZE(bb_miiphy_buses); -#endif -- cgit v1.2.3 From 8cc464c334553e571d002081ba0089edb9afc1e6 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sat, 22 Feb 2025 21:33:19 +0100 Subject: net: miiphybb: Drop bb_miiphy_init() and .init callback The .init callback is not called by any function, drop it. There are no more users of the init callback, drop the entire mechanism. Reviewed-by: Paul Barker Signed-off-by: Marek Vasut --- drivers/net/phy/miiphybb.c | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'drivers') diff --git a/drivers/net/phy/miiphybb.c b/drivers/net/phy/miiphybb.c index 9f5f9b12c9f..75d9537b355 100644 --- a/drivers/net/phy/miiphybb.c +++ b/drivers/net/phy/miiphybb.c @@ -17,17 +17,6 @@ #include #include -int bb_miiphy_init(void) -{ - int i; - - for (i = 0; i < bb_miiphy_buses_num; i++) - if (bb_miiphy_buses[i].init != NULL) - bb_miiphy_buses[i].init(&bb_miiphy_buses[i]); - - return 0; -} - static inline struct bb_miiphy_bus *bb_miiphy_getbus(const char *devname) { int i; -- cgit v1.2.3 From ce6431141a4ad220935bbe27dd12ab569f38e263 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sat, 22 Feb 2025 21:33:20 +0100 Subject: net: designware: Drop bus index There is literally one single bbmiiphy bus in this driver, remove the bus index handling. Signed-off-by: Marek Vasut Reviewed-by: Paul Barker --- drivers/net/designware.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'drivers') diff --git a/drivers/net/designware.c b/drivers/net/designware.c index 95a459cec2a..de697060d28 100644 --- a/drivers/net/designware.c +++ b/drivers/net/designware.c @@ -905,8 +905,6 @@ int designware_eth_probe(struct udevice *dev) #if IS_ENABLED(CONFIG_BITBANGMII) && IS_ENABLED(CONFIG_DM_GPIO) if (dev_read_bool(dev, "snps,bitbang-mii")) { - int bus_idx; - debug("\n%s: use bitbang mii..\n", dev->name); ret = gpio_request_by_name(dev, "snps,mdc-gpio", 0, &priv->mdc_gpio, GPIOD_IS_OUT @@ -924,16 +922,11 @@ int designware_eth_probe(struct udevice *dev) } priv->bb_delay = dev_read_u32_default(dev, "snps,bitbang-delay", 1); - for (bus_idx = 0; bus_idx < bb_miiphy_buses_num; bus_idx++) { - if (!bb_miiphy_buses[bus_idx].priv) { - bb_miiphy_buses[bus_idx].priv = priv; - strlcpy(bb_miiphy_buses[bus_idx].name, priv->bus->name, - MDIO_NAME_LEN); - priv->bus->read = bb_miiphy_read; - priv->bus->write = bb_miiphy_write; - break; - } - } + bb_miiphy_buses[0].priv = priv; + strlcpy(bb_miiphy_buses[0].name, priv->bus->name, + MDIO_NAME_LEN); + priv->bus->read = bb_miiphy_read; + priv->bus->write = bb_miiphy_write; } #endif ret = dw_phy_init(priv, dev); -- cgit v1.2.3 From a6a38bba5d14d68d2d86e137b7408393f29c5b7a Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sat, 22 Feb 2025 21:33:21 +0100 Subject: net: designware: Extract bbmiiphy initialization into dedicated function Pull the bbmiiphy initialization code from designware_eth_probe() into dedicated function, dw_bb_mdio_init(), just like all the other MDIO initialization functions. Keep check for "snps,bitbang-mii" in the designware_eth_probe(), so the driver can initialize this MDIO only in case the property is present, and initialize regular DW MDIO in case it is not present. The dw_bb_mdio_init() allocates its own MDIO instance, because thus far code gated behind "snps,bitbang-mii" did depend on allocation of MDIO bus by the other two MDIO bus options and then rewrote the newly allocated MDIO bus callbacks, which is wrong, instead allocate proper MDIO bus with the correct callbacks outright. Signed-off-by: Marek Vasut Reviewed-by: Paul Barker --- drivers/net/designware.c | 95 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 63 insertions(+), 32 deletions(-) (limited to 'drivers') diff --git a/drivers/net/designware.c b/drivers/net/designware.c index de697060d28..c88b8df28ed 100644 --- a/drivers/net/designware.c +++ b/drivers/net/designware.c @@ -303,6 +303,50 @@ struct bb_miiphy_bus bb_miiphy_buses[] = { }; 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(); + int ret; + + if (!bus) { + printf("Failed to allocate MDIO bus\n"); + return -ENOMEM; + } + + debug("\n%s: use bitbang mii..\n", dev->name); + ret = gpio_request_by_name(dev, "snps,mdc-gpio", 0, + &dwpriv->mdc_gpio, + GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE); + if (ret) { + debug("no mdc-gpio\n"); + return ret; + } + ret = gpio_request_by_name(dev, "snps,mdio-gpio", 0, + &dwpriv->mdio_gpio, + GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE); + if (ret) { + debug("no mdio-gpio\n"); + return ret; + } + dwpriv->bb_delay = dev_read_u32_default(dev, "snps,bitbang-delay", 1); + + dwpriv->bus = bus; + dwpriv->dev = dev; + + bb_miiphy_buses[0].priv = dwpriv; + snprintf(bus->name, sizeof(bus->name), "%s", name); + strlcpy(bb_miiphy_buses[0].name, bus->name, MDIO_NAME_LEN); + bus->read = bb_miiphy_read; + bus->write = bb_miiphy_write; +#if CONFIG_IS_ENABLED(DM_GPIO) + bus->reset = dw_mdio_reset; +#endif + bus->priv = dwpriv; + + return mdio_register(bus); +} #endif static void tx_descs_init(struct dw_eth_dev *priv) @@ -801,6 +845,7 @@ int designware_eth_probe(struct udevice *dev) { struct eth_pdata *pdata = dev_get_plat(dev); struct dw_eth_dev *priv = dev_get_priv(dev); + bool __maybe_unused bbmiiphy = false; phys_addr_t iobase = pdata->iobase; void *ioaddr; int ret, err; @@ -891,44 +936,30 @@ int designware_eth_probe(struct udevice *dev) priv->interface = pdata->phy_interface; priv->max_speed = pdata->max_speed; -#if IS_ENABLED(CONFIG_DM_MDIO) - ret = dw_dm_mdio_init(dev->name, dev); -#else - ret = dw_mdio_init(dev->name, dev); -#endif - if (ret) { - err = ret; - goto mdio_err; - } - priv->bus = miiphy_get_dev_by_name(dev->name); - priv->dev = dev; - #if IS_ENABLED(CONFIG_BITBANGMII) && IS_ENABLED(CONFIG_DM_GPIO) - if (dev_read_bool(dev, "snps,bitbang-mii")) { - debug("\n%s: use bitbang mii..\n", dev->name); - ret = gpio_request_by_name(dev, "snps,mdc-gpio", 0, - &priv->mdc_gpio, GPIOD_IS_OUT - | GPIOD_IS_OUT_ACTIVE); + bbmiiphy = dev_read_bool(dev, "snps,bitbang-mii"); + if (bbmiiphy) { + ret = dw_bb_mdio_init(dev->name, dev); if (ret) { - debug("no mdc-gpio\n"); - return ret; + err = ret; + goto mdio_err; } - ret = gpio_request_by_name(dev, "snps,mdio-gpio", 0, - &priv->mdio_gpio, GPIOD_IS_OUT - | GPIOD_IS_OUT_ACTIVE); + } else +#endif + { +#if IS_ENABLED(CONFIG_DM_MDIO) + ret = dw_dm_mdio_init(dev->name, dev); +#else + ret = dw_mdio_init(dev->name, dev); +#endif if (ret) { - debug("no mdio-gpio\n"); - return ret; + err = ret; + goto mdio_err; } - priv->bb_delay = dev_read_u32_default(dev, "snps,bitbang-delay", 1); - - bb_miiphy_buses[0].priv = priv; - strlcpy(bb_miiphy_buses[0].name, priv->bus->name, - MDIO_NAME_LEN); - priv->bus->read = bb_miiphy_read; - priv->bus->write = bb_miiphy_write; + priv->bus = miiphy_get_dev_by_name(dev->name); + priv->dev = dev; } -#endif + ret = dw_phy_init(priv, dev); debug("%s, ret=%d\n", __func__, ret); if (!ret) -- cgit v1.2.3 From 1b879bf5552bce022350bb96d616e5b2838af952 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sat, 22 Feb 2025 21:33:23 +0100 Subject: net: miiphybb: Introduce bb_miiphy_alloc()/bb_miiphy_free() wrappers Introduce bb_miiphy_alloc()/bb_miiphy_free() wrappers to allocate and free struct bb_miiphy_bus. Make struct bb_miiphy_bus wrap struct mii_dev, which will become useful later in bb_miiphy_bus accessors, which would be able to access struct bb_miiphy_bus using container_of, even if the PHY stack only passes in the inner struct mii_dev . Reviewed-by: Paul Barker Signed-off-by: Marek Vasut --- drivers/net/phy/miiphybb.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'drivers') diff --git a/drivers/net/phy/miiphybb.c b/drivers/net/phy/miiphybb.c index 75d9537b355..66d98d6cc26 100644 --- a/drivers/net/phy/miiphybb.c +++ b/drivers/net/phy/miiphybb.c @@ -14,6 +14,7 @@ #include #include +#include #include #include @@ -30,6 +31,24 @@ static inline struct bb_miiphy_bus *bb_miiphy_getbus(const char *devname) return NULL; } +struct bb_miiphy_bus *bb_miiphy_alloc(void) +{ + struct bb_miiphy_bus *bus; + + bus = malloc(sizeof(*bus)); + if (!bus) + return bus; + + mdio_init(&bus->mii); + + return bus; +} + +void bb_miiphy_free(struct bb_miiphy_bus *bus) +{ + free(bus); +} + /***************************************************************************** * * Utility to send the preamble, address, and register (common to read -- cgit v1.2.3 From 079eaca6e7b480509ff45e5a589d68d46376c525 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sat, 22 Feb 2025 21:33:25 +0100 Subject: net: ravb: 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. Reviewed-by: Paul Barker Signed-off-by: Marek Vasut --- drivers/net/ravb.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/net/ravb.c b/drivers/net/ravb.c index 381cf250ea2..0018b694ec1 100644 --- a/drivers/net/ravb.c +++ b/drivers/net/ravb.c @@ -553,6 +553,7 @@ static int ravb_probe(struct udevice *dev) { struct eth_pdata *pdata = dev_get_plat(dev); struct ravb_priv *eth = dev_get_priv(dev); + struct bb_miiphy_bus *bb_miiphy; struct mii_dev *mdiodev; void __iomem *iobase; int ret; @@ -564,17 +565,29 @@ static int ravb_probe(struct udevice *dev) if (ret < 0) goto err_mdio_alloc; - mdiodev = mdio_alloc(); - if (!mdiodev) { + bb_miiphy = bb_miiphy_alloc(); + if (!bb_miiphy) { ret = -ENOMEM; goto err_mdio_alloc; } + mdiodev = &bb_miiphy->mii; + mdiodev->read = bb_miiphy_read; mdiodev->write = bb_miiphy_write; bb_miiphy_buses[0].priv = eth; snprintf(mdiodev->name, sizeof(mdiodev->name), dev->name); + /* Copy the bus accessors, name and private data */ + bb_miiphy->mdio_active = ravb_bb_mdio_active; + bb_miiphy->mdio_tristate = ravb_bb_mdio_tristate; + bb_miiphy->set_mdio = ravb_bb_set_mdio; + bb_miiphy->get_mdio = ravb_bb_get_mdio; + bb_miiphy->set_mdc = ravb_bb_set_mdc; + bb_miiphy->delay = ravb_bb_delay; + strlcpy(bb_miiphy->name, "ravb", MDIO_NAME_LEN); + bb_miiphy->priv = eth; + ret = mdio_register(mdiodev); if (ret < 0) goto err_mdio_register; @@ -599,7 +612,7 @@ static int ravb_probe(struct udevice *dev) err_mdio_reset: clk_release_bulk(ð->clks); err_mdio_register: - mdio_free(mdiodev); + bb_miiphy_free(bb_miiphy); err_mdio_alloc: unmap_physmem(eth->iobase, MAP_NOCACHE); return ret; -- cgit v1.2.3 From 08eefb5e792dd05e0c2b87c7a71d0de596fa01ba Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sat, 22 Feb 2025 21:33:26 +0100 Subject: net: sh_eth: 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 --- drivers/net/sh_eth.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/net/sh_eth.c b/drivers/net/sh_eth.c index 6bd12ee3f19..e78d64d77c3 100644 --- a/drivers/net/sh_eth.c +++ b/drivers/net/sh_eth.c @@ -716,6 +716,7 @@ static int sh_ether_probe(struct udevice *udev) struct eth_pdata *pdata = dev_get_plat(udev); struct sh_ether_priv *priv = dev_get_priv(udev); struct sh_eth_dev *eth = &priv->shdev; + struct bb_miiphy_bus *bb_miiphy; struct mii_dev *mdiodev; int ret; @@ -726,17 +727,29 @@ static int sh_ether_probe(struct udevice *udev) if (ret < 0) return ret; #endif - mdiodev = mdio_alloc(); - if (!mdiodev) { + bb_miiphy = bb_miiphy_alloc(); + if (!bb_miiphy) { ret = -ENOMEM; return ret; } + mdiodev = &bb_miiphy->mii; + mdiodev->read = bb_miiphy_read; mdiodev->write = bb_miiphy_write; bb_miiphy_buses[0].priv = eth; snprintf(mdiodev->name, sizeof(mdiodev->name), udev->name); + /* Copy the bus accessors, name and private data */ + bb_miiphy->mdio_active = sh_eth_bb_mdio_active; + bb_miiphy->mdio_tristate = sh_eth_bb_mdio_tristate; + bb_miiphy->set_mdio = sh_eth_bb_set_mdio; + bb_miiphy->get_mdio = sh_eth_bb_get_mdio; + bb_miiphy->set_mdc = sh_eth_bb_set_mdc; + bb_miiphy->delay = sh_eth_bb_delay; + strlcpy(bb_miiphy->name, "sh_eth", MDIO_NAME_LEN); + bb_miiphy->priv = eth; + ret = mdio_register(mdiodev); if (ret < 0) goto err_mdio_register; @@ -771,7 +784,7 @@ err_phy_config: clk_disable(&priv->clk); #endif err_mdio_register: - mdio_free(mdiodev); + bb_miiphy_free(bb_miiphy); return ret; } -- cgit v1.2.3 From cbb69c2fafcc7c7e9b2336a658128cb394d8d3e4 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sat, 22 Feb 2025 21:33:27 +0100 Subject: net: designware: 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 --- drivers/net/designware.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'drivers') 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 -- cgit v1.2.3 From ed4ab7c5e0e9e85c369bb6f7f2f5316788102e2c Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sat, 22 Feb 2025 21:33:28 +0100 Subject: net: miiphybb: Use container_of() in bb_miiphy_getbus() Replace the name based look up in bb_miiphy_getbus() with trivial container_of() call. This works because the struct bb_miiphy_bus always embeds the matching struct mii_dev . This also makes the code much simpler and more efficient. Reviewed-by: Paul Barker Signed-off-by: Marek Vasut --- drivers/net/phy/miiphybb.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'drivers') diff --git a/drivers/net/phy/miiphybb.c b/drivers/net/phy/miiphybb.c index 66d98d6cc26..553af2c1032 100644 --- a/drivers/net/phy/miiphybb.c +++ b/drivers/net/phy/miiphybb.c @@ -18,17 +18,9 @@ #include #include -static inline struct bb_miiphy_bus *bb_miiphy_getbus(const char *devname) +static inline struct bb_miiphy_bus *bb_miiphy_getbus(struct mii_dev *miidev) { - int i; - - /* Search the correct bus */ - for (i = 0; i < bb_miiphy_buses_num; i++) { - if (!strcmp(bb_miiphy_buses[i].name, devname)) { - return &bb_miiphy_buses[i]; - } - } - return NULL; + return container_of(miidev, struct bb_miiphy_bus, mii); } struct bb_miiphy_bus *bb_miiphy_alloc(void) @@ -141,7 +133,7 @@ int bb_miiphy_read(struct mii_dev *miidev, int addr, int devad, int reg) int j; /* counter */ struct bb_miiphy_bus *bus; - bus = bb_miiphy_getbus(miidev->name); + bus = bb_miiphy_getbus(miidev); if (bus == NULL) { return -1; } @@ -209,7 +201,7 @@ int bb_miiphy_write(struct mii_dev *miidev, int addr, int devad, int reg, struct bb_miiphy_bus *bus; int j; /* counter */ - bus = bb_miiphy_getbus(miidev->name); + bus = bb_miiphy_getbus(miidev); if (bus == NULL) { /* Bus not found! */ return -1; -- cgit v1.2.3 From a23f9a786b010177839d6fe9f67c717f17f74368 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sat, 22 Feb 2025 21:33:29 +0100 Subject: net: miiphybb: Drop name field from struct bb_miiphy_bus The struct bb_miiphy_bus embeds struct struct mii_dev, which already contains one copy of name field. Drop the duplicate top level copy of name field. The a38x code does static assignment of disparate names, use snprintf(...) to fill in matching name in probe to avoid any breakage. Reviewed-by: Paul Barker Signed-off-by: Marek Vasut --- drivers/net/designware.c | 5 +---- drivers/net/ravb.c | 6 +----- drivers/net/sh_eth.c | 6 +----- 3 files changed, 3 insertions(+), 14 deletions(-) (limited to 'drivers') diff --git a/drivers/net/designware.c b/drivers/net/designware.c index 74cf8271e67..5124982e683 100644 --- a/drivers/net/designware.c +++ b/drivers/net/designware.c @@ -292,7 +292,6 @@ static int dw_eth_bb_delay(struct bb_miiphy_bus *bus) struct bb_miiphy_bus bb_miiphy_buses[] = { { - .name = BB_MII_DEVNAME, .mdio_active = dw_eth_bb_mdio_active, .mdio_tristate = dw_eth_bb_mdio_tristate, .set_mdio = dw_eth_bb_set_mdio, @@ -340,7 +339,6 @@ static int dw_bb_mdio_init(const char *name, struct udevice *dev) bb_miiphy_buses[0].priv = dwpriv; snprintf(bus->name, sizeof(bus->name), "%s", name); - strlcpy(bb_miiphy_buses[0].name, bus->name, MDIO_NAME_LEN); bus->read = bb_miiphy_read; bus->write = bb_miiphy_write; #if CONFIG_IS_ENABLED(DM_GPIO) @@ -348,14 +346,13 @@ static int dw_bb_mdio_init(const char *name, struct udevice *dev) #endif bus->priv = dwpriv; - /* Copy the bus accessors, name and private data */ + /* Copy the bus accessors 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); } diff --git a/drivers/net/ravb.c b/drivers/net/ravb.c index 0018b694ec1..86787183488 100644 --- a/drivers/net/ravb.c +++ b/drivers/net/ravb.c @@ -578,14 +578,13 @@ static int ravb_probe(struct udevice *dev) bb_miiphy_buses[0].priv = eth; snprintf(mdiodev->name, sizeof(mdiodev->name), dev->name); - /* Copy the bus accessors, name and private data */ + /* Copy the bus accessors and private data */ bb_miiphy->mdio_active = ravb_bb_mdio_active; bb_miiphy->mdio_tristate = ravb_bb_mdio_tristate; bb_miiphy->set_mdio = ravb_bb_set_mdio; bb_miiphy->get_mdio = ravb_bb_get_mdio; bb_miiphy->set_mdc = ravb_bb_set_mdc; bb_miiphy->delay = ravb_bb_delay; - strlcpy(bb_miiphy->name, "ravb", MDIO_NAME_LEN); bb_miiphy->priv = eth; ret = mdio_register(mdiodev); @@ -634,7 +633,6 @@ static int ravb_remove(struct udevice *dev) struct bb_miiphy_bus bb_miiphy_buses[] = { { - .name = "ravb", .mdio_active = ravb_bb_mdio_active, .mdio_tristate = ravb_bb_mdio_tristate, .set_mdio = ravb_bb_set_mdio, @@ -666,8 +664,6 @@ int ravb_of_to_plat(struct udevice *dev) pdata->max_speed = dev_read_u32_default(dev, "max-speed", 1000); - sprintf(bb_miiphy_buses[0].name, dev->name); - return 0; } diff --git a/drivers/net/sh_eth.c b/drivers/net/sh_eth.c index e78d64d77c3..49065ebe717 100644 --- a/drivers/net/sh_eth.c +++ b/drivers/net/sh_eth.c @@ -740,14 +740,13 @@ static int sh_ether_probe(struct udevice *udev) bb_miiphy_buses[0].priv = eth; snprintf(mdiodev->name, sizeof(mdiodev->name), udev->name); - /* Copy the bus accessors, name and private data */ + /* Copy the bus accessors and private data */ bb_miiphy->mdio_active = sh_eth_bb_mdio_active; bb_miiphy->mdio_tristate = sh_eth_bb_mdio_tristate; bb_miiphy->set_mdio = sh_eth_bb_set_mdio; bb_miiphy->get_mdio = sh_eth_bb_get_mdio; bb_miiphy->set_mdc = sh_eth_bb_set_mdc; bb_miiphy->delay = sh_eth_bb_delay; - strlcpy(bb_miiphy->name, "sh_eth", MDIO_NAME_LEN); bb_miiphy->priv = eth; ret = mdio_register(mdiodev); @@ -829,8 +828,6 @@ int sh_ether_of_to_plat(struct udevice *dev) if (cell) pdata->max_speed = fdt32_to_cpu(*cell); - sprintf(bb_miiphy_buses[0].name, dev->name); - return 0; } @@ -859,7 +856,6 @@ U_BOOT_DRIVER(eth_sh_ether) = { struct bb_miiphy_bus bb_miiphy_buses[] = { { - .name = "sh_eth", .mdio_active = sh_eth_bb_mdio_active, .mdio_tristate = sh_eth_bb_mdio_tristate, .set_mdio = sh_eth_bb_set_mdio, -- cgit v1.2.3 From fd54dac34527049be7be2add91953631725e76c5 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sat, 22 Feb 2025 21:33:31 +0100 Subject: net: ravb: Drop use of miiphy_get_dev_by_name() Instead of doing another lookup, trivially access the struct mii_dev embedded in struct bb_miiphy_bus . No functional change. Reviewed-by: Paul Barker Signed-off-by: Marek Vasut --- drivers/net/ravb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/net/ravb.c b/drivers/net/ravb.c index 86787183488..b790de98b48 100644 --- a/drivers/net/ravb.c +++ b/drivers/net/ravb.c @@ -591,7 +591,7 @@ static int ravb_probe(struct udevice *dev) if (ret < 0) goto err_mdio_register; - eth->bus = miiphy_get_dev_by_name(dev->name); + eth->bus = &bb_miiphy->mii; /* Bring up PHY */ ret = clk_enable_bulk(ð->clks); -- cgit v1.2.3 From 6d76c997e991776609e4d90e6e6fc99b3b5f1d4c Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sat, 22 Feb 2025 21:33:32 +0100 Subject: net: sh_eth: Drop use of miiphy_get_dev_by_name() Instead of doing another lookup, trivially access the struct mii_dev embedded in struct bb_miiphy_bus . No functional change. Signed-off-by: Marek Vasut Reviewed-by: Paul Barker --- drivers/net/sh_eth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/net/sh_eth.c b/drivers/net/sh_eth.c index 49065ebe717..b1e35aaf291 100644 --- a/drivers/net/sh_eth.c +++ b/drivers/net/sh_eth.c @@ -753,7 +753,7 @@ static int sh_ether_probe(struct udevice *udev) if (ret < 0) goto err_mdio_register; - priv->bus = miiphy_get_dev_by_name(udev->name); + priv->bus = &bb_miiphy->mii; eth->port = CFG_SH_ETHER_USE_PORT; eth->port_info[eth->port].phy_addr = CFG_SH_ETHER_PHY_ADDR; -- cgit v1.2.3 From 4e6fed49becc7e8d9639966fd34695583192a3ee Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sat, 22 Feb 2025 21:33:33 +0100 Subject: net: miiphybb: Drop bb_miiphy_buses and bb_miiphy_buses_num Neither bb_miiphy_buses nor bb_miiphy_buses_num are used anymore. Drop both of them. Reviewed-by: Paul Barker Signed-off-by: Marek Vasut --- drivers/net/designware.c | 14 -------------- drivers/net/ravb.c | 13 ------------- drivers/net/sh_eth.c | 14 -------------- 3 files changed, 41 deletions(-) (limited to 'drivers') diff --git a/drivers/net/designware.c b/drivers/net/designware.c index 5124982e683..5a6e89c0575 100644 --- a/drivers/net/designware.c +++ b/drivers/net/designware.c @@ -290,19 +290,6 @@ static int dw_eth_bb_delay(struct bb_miiphy_bus *bus) return 0; } -struct bb_miiphy_bus bb_miiphy_buses[] = { - { - .mdio_active = dw_eth_bb_mdio_active, - .mdio_tristate = dw_eth_bb_mdio_tristate, - .set_mdio = dw_eth_bb_set_mdio, - .get_mdio = dw_eth_bb_get_mdio, - .set_mdc = dw_eth_bb_set_mdc, - .delay = dw_eth_bb_delay, - } -}; - -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); @@ -337,7 +324,6 @@ static int dw_bb_mdio_init(const char *name, struct udevice *dev) dwpriv->bus = bus; dwpriv->dev = dev; - bb_miiphy_buses[0].priv = dwpriv; snprintf(bus->name, sizeof(bus->name), "%s", name); bus->read = bb_miiphy_read; bus->write = bb_miiphy_write; diff --git a/drivers/net/ravb.c b/drivers/net/ravb.c index b790de98b48..cb727ae9bc1 100644 --- a/drivers/net/ravb.c +++ b/drivers/net/ravb.c @@ -575,7 +575,6 @@ static int ravb_probe(struct udevice *dev) mdiodev->read = bb_miiphy_read; mdiodev->write = bb_miiphy_write; - bb_miiphy_buses[0].priv = eth; snprintf(mdiodev->name, sizeof(mdiodev->name), dev->name); /* Copy the bus accessors and private data */ @@ -631,18 +630,6 @@ static int ravb_remove(struct udevice *dev) return 0; } -struct bb_miiphy_bus bb_miiphy_buses[] = { - { - .mdio_active = ravb_bb_mdio_active, - .mdio_tristate = ravb_bb_mdio_tristate, - .set_mdio = ravb_bb_set_mdio, - .get_mdio = ravb_bb_get_mdio, - .set_mdc = ravb_bb_set_mdc, - .delay = ravb_bb_delay, - }, -}; -int bb_miiphy_buses_num = ARRAY_SIZE(bb_miiphy_buses); - static const struct eth_ops ravb_ops = { .start = ravb_start, .send = ravb_send, diff --git a/drivers/net/sh_eth.c b/drivers/net/sh_eth.c index b1e35aaf291..83e48609224 100644 --- a/drivers/net/sh_eth.c +++ b/drivers/net/sh_eth.c @@ -737,7 +737,6 @@ static int sh_ether_probe(struct udevice *udev) mdiodev->read = bb_miiphy_read; mdiodev->write = bb_miiphy_write; - bb_miiphy_buses[0].priv = eth; snprintf(mdiodev->name, sizeof(mdiodev->name), udev->name); /* Copy the bus accessors and private data */ @@ -853,16 +852,3 @@ U_BOOT_DRIVER(eth_sh_ether) = { .plat_auto = sizeof(struct eth_pdata), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; - -struct bb_miiphy_bus bb_miiphy_buses[] = { - { - .mdio_active = sh_eth_bb_mdio_active, - .mdio_tristate = sh_eth_bb_mdio_tristate, - .set_mdio = sh_eth_bb_set_mdio, - .get_mdio = sh_eth_bb_get_mdio, - .set_mdc = sh_eth_bb_set_mdc, - .delay = sh_eth_bb_delay, - } -}; - -int bb_miiphy_buses_num = ARRAY_SIZE(bb_miiphy_buses); -- cgit v1.2.3