From 0e5f1b8f052bfc8f2a30ae4dd958371242b4b8dd Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Fri, 28 Feb 2025 13:02:52 +0100 Subject: pinctrl: renesas: Drop special RZN1 entry from Makefile The RZN1 symbol name is CONFIG_RZN1, there is no CONFIG_ARCH_RZN1. Since RZN1 enables CONFIG_ARCH_RENESAS as well, remove the special RZN1 entry from Makefile, the RZN1 pinctrl driver will still be pulled in via CONFIG_ARCH_RENESAS. Fixes: e4aea57fa773 ("pinctrl: renesas: add R906G032 driver") Signed-off-by: Marek Vasut Reviewed-by: Paul Barker --- drivers/pinctrl/Makefile | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers') diff --git a/drivers/pinctrl/Makefile b/drivers/pinctrl/Makefile index 634047a91f4..5e76c860727 100644 --- a/drivers/pinctrl/Makefile +++ b/drivers/pinctrl/Makefile @@ -15,7 +15,6 @@ obj-$(CONFIG_ARCH_MTMIPS) += mtmips/ obj-$(CONFIG_ARCH_NPCM) += nuvoton/ obj-$(CONFIG_PINCTRL_QCOM) += qcom/ obj-$(CONFIG_ARCH_RENESAS) += renesas/ -obj-$(CONFIG_ARCH_RZN1) += renesas/ obj-$(CONFIG_PINCTRL_SANDBOX) += pinctrl-sandbox.o obj-$(CONFIG_PINCTRL_SUNXI) += sunxi/ obj-$(CONFIG_$(XPL_)PINCTRL_TEGRA) += tegra/ -- cgit v1.2.3 From c9671c9036d465e0681d947b0b7a76019a096758 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sun, 2 Mar 2025 02:24:42 +0100 Subject: net: miiphybb: Split off struct bb_miiphy_bus_ops Move miiphybb operations into separate struct bb_miiphy_bus_ops structure, add pointer to struct bb_miiphy_bus_ops into the base struct bb_miiphy_bus and access the ops through this pointer in miiphybb generic code. The variable reshuffling in miiphybb.c cannot be easily avoided. Signed-off-by: Marek Vasut Reviewed-by: Paul Barker --- drivers/net/designware.c | 18 +++-- drivers/net/phy/miiphybb.c | 178 +++++++++++++++++++++++---------------------- drivers/net/ravb.c | 16 ++-- drivers/net/sh_eth.c | 16 ++-- 4 files changed, 122 insertions(+), 106 deletions(-) (limited to 'drivers') diff --git a/drivers/net/designware.c b/drivers/net/designware.c index 5a6e89c0575..045bff476d1 100644 --- a/drivers/net/designware.c +++ b/drivers/net/designware.c @@ -290,6 +290,15 @@ static int dw_eth_bb_delay(struct bb_miiphy_bus *bus) return 0; } +static const struct bb_miiphy_bus_ops dw_eth_bb_miiphy_bus_ops = { + .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, +}; + static int dw_bb_mdio_init(const char *name, struct udevice *dev) { struct dw_eth_dev *dwpriv = dev_get_priv(dev); @@ -330,16 +339,9 @@ static int dw_bb_mdio_init(const char *name, struct udevice *dev) #if CONFIG_IS_ENABLED(DM_GPIO) bus->reset = dw_mdio_reset; #endif + bus->ops = &dw_eth_bb_miiphy_bus_ops; bus->priv = dwpriv; - /* 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; - return mdio_register(bus); } #endif diff --git a/drivers/net/phy/miiphybb.c b/drivers/net/phy/miiphybb.c index 553af2c1032..e6106341eb3 100644 --- a/drivers/net/phy/miiphybb.c +++ b/drivers/net/phy/miiphybb.c @@ -46,8 +46,8 @@ void bb_miiphy_free(struct bb_miiphy_bus *bus) * Utility to send the preamble, address, and register (common to read * and write). */ -static void miiphy_pre(struct bb_miiphy_bus *bus, char read, - unsigned char addr, unsigned char reg) +static void miiphy_pre(struct bb_miiphy_bus *bus, const struct bb_miiphy_bus_ops *ops, + char read, unsigned char addr, unsigned char reg) { int j; @@ -59,62 +59,62 @@ static void miiphy_pre(struct bb_miiphy_bus *bus, char read, * but it is safer and will be much more robust. */ - bus->mdio_active(bus); - bus->set_mdio(bus, 1); + ops->mdio_active(bus); + ops->set_mdio(bus, 1); for (j = 0; j < 32; j++) { - bus->set_mdc(bus, 0); - bus->delay(bus); - bus->set_mdc(bus, 1); - bus->delay(bus); + ops->set_mdc(bus, 0); + ops->delay(bus); + ops->set_mdc(bus, 1); + ops->delay(bus); } /* send the start bit (01) and the read opcode (10) or write (10) */ - bus->set_mdc(bus, 0); - bus->set_mdio(bus, 0); - bus->delay(bus); - bus->set_mdc(bus, 1); - bus->delay(bus); - bus->set_mdc(bus, 0); - bus->set_mdio(bus, 1); - bus->delay(bus); - bus->set_mdc(bus, 1); - bus->delay(bus); - bus->set_mdc(bus, 0); - bus->set_mdio(bus, read); - bus->delay(bus); - bus->set_mdc(bus, 1); - bus->delay(bus); - bus->set_mdc(bus, 0); - bus->set_mdio(bus, !read); - bus->delay(bus); - bus->set_mdc(bus, 1); - bus->delay(bus); + ops->set_mdc(bus, 0); + ops->set_mdio(bus, 0); + ops->delay(bus); + ops->set_mdc(bus, 1); + ops->delay(bus); + ops->set_mdc(bus, 0); + ops->set_mdio(bus, 1); + ops->delay(bus); + ops->set_mdc(bus, 1); + ops->delay(bus); + ops->set_mdc(bus, 0); + ops->set_mdio(bus, read); + ops->delay(bus); + ops->set_mdc(bus, 1); + ops->delay(bus); + ops->set_mdc(bus, 0); + ops->set_mdio(bus, !read); + ops->delay(bus); + ops->set_mdc(bus, 1); + ops->delay(bus); /* send the PHY address */ for (j = 0; j < 5; j++) { - bus->set_mdc(bus, 0); + ops->set_mdc(bus, 0); if ((addr & 0x10) == 0) { - bus->set_mdio(bus, 0); + ops->set_mdio(bus, 0); } else { - bus->set_mdio(bus, 1); + ops->set_mdio(bus, 1); } - bus->delay(bus); - bus->set_mdc(bus, 1); - bus->delay(bus); + ops->delay(bus); + ops->set_mdc(bus, 1); + ops->delay(bus); addr <<= 1; } /* send the register address */ for (j = 0; j < 5; j++) { - bus->set_mdc(bus, 0); + ops->set_mdc(bus, 0); if ((reg & 0x10) == 0) { - bus->set_mdio(bus, 0); + ops->set_mdio(bus, 0); } else { - bus->set_mdio(bus, 1); + ops->set_mdio(bus, 1); } - bus->delay(bus); - bus->set_mdc(bus, 1); - bus->delay(bus); + ops->delay(bus); + ops->set_mdc(bus, 1); + ops->delay(bus); reg <<= 1; } } @@ -132,56 +132,59 @@ int bb_miiphy_read(struct mii_dev *miidev, int addr, int devad, int reg) int v; int j; /* counter */ struct bb_miiphy_bus *bus; + const struct bb_miiphy_bus_ops *ops; bus = bb_miiphy_getbus(miidev); if (bus == NULL) { return -1; } - miiphy_pre (bus, 1, addr, reg); + ops = bus->ops; + + miiphy_pre(bus, ops, 1, addr, reg); /* tri-state our MDIO I/O pin so we can read */ - bus->set_mdc(bus, 0); - bus->mdio_tristate(bus); - bus->delay(bus); - bus->set_mdc(bus, 1); - bus->delay(bus); + ops->set_mdc(bus, 0); + ops->mdio_tristate(bus); + ops->delay(bus); + ops->set_mdc(bus, 1); + ops->delay(bus); /* check the turnaround bit: the PHY should be driving it to zero */ - bus->get_mdio(bus, &v); + ops->get_mdio(bus, &v); if (v != 0) { /* puts ("PHY didn't drive TA low\n"); */ for (j = 0; j < 32; j++) { - bus->set_mdc(bus, 0); - bus->delay(bus); - bus->set_mdc(bus, 1); - bus->delay(bus); + ops->set_mdc(bus, 0); + ops->delay(bus); + ops->set_mdc(bus, 1); + ops->delay(bus); } /* There is no PHY, return */ return -1; } - bus->set_mdc(bus, 0); - bus->delay(bus); + ops->set_mdc(bus, 0); + ops->delay(bus); /* read 16 bits of register data, MSB first */ rdreg = 0; for (j = 0; j < 16; j++) { - bus->set_mdc(bus, 1); - bus->delay(bus); + ops->set_mdc(bus, 1); + ops->delay(bus); rdreg <<= 1; - bus->get_mdio(bus, &v); + ops->get_mdio(bus, &v); rdreg |= (v & 0x1); - bus->set_mdc(bus, 0); - bus->delay(bus); + ops->set_mdc(bus, 0); + ops->delay(bus); } - bus->set_mdc(bus, 1); - bus->delay(bus); - bus->set_mdc(bus, 0); - bus->delay(bus); - bus->set_mdc(bus, 1); - bus->delay(bus); + ops->set_mdc(bus, 1); + ops->delay(bus); + ops->set_mdc(bus, 0); + ops->delay(bus); + ops->set_mdc(bus, 1); + ops->delay(bus); debug("%s[%s](0x%x) @ 0x%x = 0x%04x\n", __func__, miidev->name, reg, addr, rdreg); @@ -199,6 +202,7 @@ int bb_miiphy_write(struct mii_dev *miidev, int addr, int devad, int reg, u16 value) { struct bb_miiphy_bus *bus; + const struct bb_miiphy_bus_ops *ops; int j; /* counter */ bus = bb_miiphy_getbus(miidev); @@ -207,42 +211,44 @@ int bb_miiphy_write(struct mii_dev *miidev, int addr, int devad, int reg, return -1; } - miiphy_pre (bus, 0, addr, reg); + ops = bus->ops; + + miiphy_pre(bus, ops, 0, addr, reg); /* send the turnaround (10) */ - bus->set_mdc(bus, 0); - bus->set_mdio(bus, 1); - bus->delay(bus); - bus->set_mdc(bus, 1); - bus->delay(bus); - bus->set_mdc(bus, 0); - bus->set_mdio(bus, 0); - bus->delay(bus); - bus->set_mdc(bus, 1); - bus->delay(bus); + ops->set_mdc(bus, 0); + ops->set_mdio(bus, 1); + ops->delay(bus); + ops->set_mdc(bus, 1); + ops->delay(bus); + ops->set_mdc(bus, 0); + ops->set_mdio(bus, 0); + ops->delay(bus); + ops->set_mdc(bus, 1); + ops->delay(bus); /* write 16 bits of register data, MSB first */ for (j = 0; j < 16; j++) { - bus->set_mdc(bus, 0); + ops->set_mdc(bus, 0); if ((value & 0x00008000) == 0) { - bus->set_mdio(bus, 0); + ops->set_mdio(bus, 0); } else { - bus->set_mdio(bus, 1); + ops->set_mdio(bus, 1); } - bus->delay(bus); - bus->set_mdc(bus, 1); - bus->delay(bus); + ops->delay(bus); + ops->set_mdc(bus, 1); + ops->delay(bus); value <<= 1; } /* * Tri-state the MDIO line. */ - bus->mdio_tristate(bus); - bus->set_mdc(bus, 0); - bus->delay(bus); - bus->set_mdc(bus, 1); - bus->delay(bus); + ops->mdio_tristate(bus); + ops->set_mdc(bus, 0); + ops->delay(bus); + ops->set_mdc(bus, 1); + ops->delay(bus); return 0; } diff --git a/drivers/net/ravb.c b/drivers/net/ravb.c index cb727ae9bc1..bd4900270a2 100644 --- a/drivers/net/ravb.c +++ b/drivers/net/ravb.c @@ -549,6 +549,15 @@ static int ravb_bb_delay(struct bb_miiphy_bus *bus) return 0; } +static const struct bb_miiphy_bus_ops ravb_bb_miiphy_bus_ops = { + .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, +}; + static int ravb_probe(struct udevice *dev) { struct eth_pdata *pdata = dev_get_plat(dev); @@ -578,12 +587,7 @@ static int ravb_probe(struct udevice *dev) snprintf(mdiodev->name, sizeof(mdiodev->name), dev->name); /* 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; + bb_miiphy->ops = &ravb_bb_miiphy_bus_ops; bb_miiphy->priv = eth; ret = mdio_register(mdiodev); diff --git a/drivers/net/sh_eth.c b/drivers/net/sh_eth.c index 83e48609224..0693c240fbd 100644 --- a/drivers/net/sh_eth.c +++ b/drivers/net/sh_eth.c @@ -711,6 +711,15 @@ static int sh_eth_bb_delay(struct bb_miiphy_bus *bus) return 0; } +static const struct bb_miiphy_bus_ops sh_ether_bb_miiphy_bus_ops = { + .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, +}; + static int sh_ether_probe(struct udevice *udev) { struct eth_pdata *pdata = dev_get_plat(udev); @@ -740,12 +749,7 @@ static int sh_ether_probe(struct udevice *udev) snprintf(mdiodev->name, sizeof(mdiodev->name), udev->name); /* 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; + bb_miiphy->ops = &sh_ether_bb_miiphy_bus_ops; bb_miiphy->priv = eth; ret = mdio_register(mdiodev); -- cgit v1.2.3 From 3374d3783a575db7dd2dc9f2f74b7523e547b130 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sun, 2 Mar 2025 02:24:43 +0100 Subject: net: miiphybb: Wrap driver side bb_miiphy_read/write() accessors Do not call bb_miiphy_read()/bb_miiphy_write() accessors directly in drivers, instead call them through wrapper functions. Those are meant to be used as function parameter adaptation layer between struct mii_dev callback function parameters and what the miiphybb does expect and will soon expect. This is a preparatory patch, no functional change. Signed-off-by: Marek Vasut Reviewed-by: Paul Barker --- drivers/net/designware.c | 16 ++++++++++++++-- drivers/net/ravb.c | 16 ++++++++++++++-- drivers/net/sh_eth.c | 16 ++++++++++++++-- 3 files changed, 42 insertions(+), 6 deletions(-) (limited to 'drivers') diff --git a/drivers/net/designware.c b/drivers/net/designware.c index 045bff476d1..3c3450aa778 100644 --- a/drivers/net/designware.c +++ b/drivers/net/designware.c @@ -299,6 +299,18 @@ static const struct bb_miiphy_bus_ops dw_eth_bb_miiphy_bus_ops = { .delay = dw_eth_bb_delay, }; +static int dw_bb_miiphy_read(struct mii_dev *miidev, int addr, + int devad, int reg) +{ + return bb_miiphy_read(miidev, addr, devad, reg); +} + +static int dw_bb_miiphy_write(struct mii_dev *miidev, int addr, + int devad, int reg, u16 value) +{ + return bb_miiphy_write(miidev, addr, devad, reg, value); +} + static int dw_bb_mdio_init(const char *name, struct udevice *dev) { struct dw_eth_dev *dwpriv = dev_get_priv(dev); @@ -334,8 +346,8 @@ static int dw_bb_mdio_init(const char *name, struct udevice *dev) dwpriv->dev = dev; snprintf(bus->name, sizeof(bus->name), "%s", name); - bus->read = bb_miiphy_read; - bus->write = bb_miiphy_write; + bus->read = dw_bb_miiphy_read; + bus->write = dw_bb_miiphy_write; #if CONFIG_IS_ENABLED(DM_GPIO) bus->reset = dw_mdio_reset; #endif diff --git a/drivers/net/ravb.c b/drivers/net/ravb.c index bd4900270a2..9a17ac97cce 100644 --- a/drivers/net/ravb.c +++ b/drivers/net/ravb.c @@ -558,6 +558,18 @@ static const struct bb_miiphy_bus_ops ravb_bb_miiphy_bus_ops = { .delay = ravb_bb_delay, }; +static int ravb_bb_miiphy_read(struct mii_dev *miidev, int addr, + int devad, int reg) +{ + return bb_miiphy_read(miidev, addr, devad, reg); +} + +static int ravb_bb_miiphy_write(struct mii_dev *miidev, int addr, + int devad, int reg, u16 value) +{ + return bb_miiphy_write(miidev, addr, devad, reg, value); +} + static int ravb_probe(struct udevice *dev) { struct eth_pdata *pdata = dev_get_plat(dev); @@ -582,8 +594,8 @@ static int ravb_probe(struct udevice *dev) mdiodev = &bb_miiphy->mii; - mdiodev->read = bb_miiphy_read; - mdiodev->write = bb_miiphy_write; + mdiodev->read = ravb_bb_miiphy_read; + mdiodev->write = ravb_bb_miiphy_write; snprintf(mdiodev->name, sizeof(mdiodev->name), dev->name); /* Copy the bus accessors and private data */ diff --git a/drivers/net/sh_eth.c b/drivers/net/sh_eth.c index 0693c240fbd..cef531c8c6f 100644 --- a/drivers/net/sh_eth.c +++ b/drivers/net/sh_eth.c @@ -720,6 +720,18 @@ static const struct bb_miiphy_bus_ops sh_ether_bb_miiphy_bus_ops = { .delay = sh_eth_bb_delay, }; +static int sh_eth_bb_miiphy_read(struct mii_dev *miidev, int addr, + int devad, int reg) +{ + return bb_miiphy_read(miidev, addr, devad, reg); +} + +static int sh_eth_bb_miiphy_write(struct mii_dev *miidev, int addr, + int devad, int reg, u16 value) +{ + return bb_miiphy_write(miidev, addr, devad, reg, value); +} + static int sh_ether_probe(struct udevice *udev) { struct eth_pdata *pdata = dev_get_plat(udev); @@ -744,8 +756,8 @@ static int sh_ether_probe(struct udevice *udev) mdiodev = &bb_miiphy->mii; - mdiodev->read = bb_miiphy_read; - mdiodev->write = bb_miiphy_write; + mdiodev->read = sh_eth_bb_miiphy_read; + mdiodev->write = sh_eth_bb_miiphy_write; snprintf(mdiodev->name, sizeof(mdiodev->name), udev->name); /* Copy the bus accessors and private data */ -- cgit v1.2.3 From c5318bdcf80965fddccf68146c7838816aedb154 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sun, 2 Mar 2025 02:24:44 +0100 Subject: net: miiphybb: Pass struct bb_miiphy_bus_ops directly to bb_miiphy_read/write() The access to struct bb_miiphy_bus_ops via ops pointer in struct bb_miiphy_bus is not necessary with wrappers added in previous patch. Pass the ops pointer directly to both bb_miiphy_read() and bb_miiphy_write() functions. Signed-off-by: Marek Vasut Reviewed-by: Paul Barker --- drivers/net/designware.c | 7 ++++--- drivers/net/phy/miiphybb.c | 13 ++++--------- drivers/net/ravb.c | 7 ++++--- drivers/net/sh_eth.c | 7 ++++--- 4 files changed, 16 insertions(+), 18 deletions(-) (limited to 'drivers') diff --git a/drivers/net/designware.c b/drivers/net/designware.c index 3c3450aa778..2069e34be15 100644 --- a/drivers/net/designware.c +++ b/drivers/net/designware.c @@ -302,13 +302,15 @@ static const struct bb_miiphy_bus_ops dw_eth_bb_miiphy_bus_ops = { static int dw_bb_miiphy_read(struct mii_dev *miidev, int addr, int devad, int reg) { - return bb_miiphy_read(miidev, addr, devad, reg); + return bb_miiphy_read(miidev, &dw_eth_bb_miiphy_bus_ops, + addr, devad, reg); } static int dw_bb_miiphy_write(struct mii_dev *miidev, int addr, int devad, int reg, u16 value) { - return bb_miiphy_write(miidev, addr, devad, reg, value); + return bb_miiphy_write(miidev, &dw_eth_bb_miiphy_bus_ops, + addr, devad, reg, value); } static int dw_bb_mdio_init(const char *name, struct udevice *dev) @@ -351,7 +353,6 @@ static int dw_bb_mdio_init(const char *name, struct udevice *dev) #if CONFIG_IS_ENABLED(DM_GPIO) bus->reset = dw_mdio_reset; #endif - bus->ops = &dw_eth_bb_miiphy_bus_ops; bus->priv = dwpriv; return mdio_register(bus); diff --git a/drivers/net/phy/miiphybb.c b/drivers/net/phy/miiphybb.c index e6106341eb3..9481ba76f51 100644 --- a/drivers/net/phy/miiphybb.c +++ b/drivers/net/phy/miiphybb.c @@ -126,21 +126,19 @@ static void miiphy_pre(struct bb_miiphy_bus *bus, const struct bb_miiphy_bus_ops * Returns: * 0 on success */ -int bb_miiphy_read(struct mii_dev *miidev, int addr, int devad, int reg) +int bb_miiphy_read(struct mii_dev *miidev, const struct bb_miiphy_bus_ops *ops, + int addr, int devad, int reg) { unsigned short rdreg; /* register working value */ int v; int j; /* counter */ struct bb_miiphy_bus *bus; - const struct bb_miiphy_bus_ops *ops; bus = bb_miiphy_getbus(miidev); if (bus == NULL) { return -1; } - ops = bus->ops; - miiphy_pre(bus, ops, 1, addr, reg); /* tri-state our MDIO I/O pin so we can read */ @@ -198,11 +196,10 @@ int bb_miiphy_read(struct mii_dev *miidev, int addr, int devad, int reg) * Returns: * 0 on success */ -int bb_miiphy_write(struct mii_dev *miidev, int addr, int devad, int reg, - u16 value) +int bb_miiphy_write(struct mii_dev *miidev, const struct bb_miiphy_bus_ops *ops, + int addr, int devad, int reg, u16 value) { struct bb_miiphy_bus *bus; - const struct bb_miiphy_bus_ops *ops; int j; /* counter */ bus = bb_miiphy_getbus(miidev); @@ -211,8 +208,6 @@ int bb_miiphy_write(struct mii_dev *miidev, int addr, int devad, int reg, return -1; } - ops = bus->ops; - miiphy_pre(bus, ops, 0, addr, reg); /* send the turnaround (10) */ diff --git a/drivers/net/ravb.c b/drivers/net/ravb.c index 9a17ac97cce..65ba107fc00 100644 --- a/drivers/net/ravb.c +++ b/drivers/net/ravb.c @@ -561,13 +561,15 @@ static const struct bb_miiphy_bus_ops ravb_bb_miiphy_bus_ops = { static int ravb_bb_miiphy_read(struct mii_dev *miidev, int addr, int devad, int reg) { - return bb_miiphy_read(miidev, addr, devad, reg); + return bb_miiphy_read(miidev, &ravb_bb_miiphy_bus_ops, + addr, devad, reg); } static int ravb_bb_miiphy_write(struct mii_dev *miidev, int addr, int devad, int reg, u16 value) { - return bb_miiphy_write(miidev, addr, devad, reg, value); + return bb_miiphy_write(miidev, &ravb_bb_miiphy_bus_ops, + addr, devad, reg, value); } static int ravb_probe(struct udevice *dev) @@ -599,7 +601,6 @@ static int ravb_probe(struct udevice *dev) snprintf(mdiodev->name, sizeof(mdiodev->name), dev->name); /* Copy the bus accessors and private data */ - bb_miiphy->ops = &ravb_bb_miiphy_bus_ops; bb_miiphy->priv = eth; ret = mdio_register(mdiodev); diff --git a/drivers/net/sh_eth.c b/drivers/net/sh_eth.c index cef531c8c6f..738dc43cdc7 100644 --- a/drivers/net/sh_eth.c +++ b/drivers/net/sh_eth.c @@ -723,13 +723,15 @@ static const struct bb_miiphy_bus_ops sh_ether_bb_miiphy_bus_ops = { static int sh_eth_bb_miiphy_read(struct mii_dev *miidev, int addr, int devad, int reg) { - return bb_miiphy_read(miidev, addr, devad, reg); + return bb_miiphy_read(miidev, &sh_ether_bb_miiphy_bus_ops, + addr, devad, reg); } static int sh_eth_bb_miiphy_write(struct mii_dev *miidev, int addr, int devad, int reg, u16 value) { - return bb_miiphy_write(miidev, addr, devad, reg, value); + return bb_miiphy_write(miidev, &sh_ether_bb_miiphy_bus_ops, + addr, devad, reg, value); } static int sh_ether_probe(struct udevice *udev) @@ -761,7 +763,6 @@ static int sh_ether_probe(struct udevice *udev) snprintf(mdiodev->name, sizeof(mdiodev->name), udev->name); /* Copy the bus accessors and private data */ - bb_miiphy->ops = &sh_ether_bb_miiphy_bus_ops; bb_miiphy->priv = eth; ret = mdio_register(mdiodev); -- cgit v1.2.3 From 7cded10da35730ff27062d19b8ad72242be8038f Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sun, 2 Mar 2025 02:24:45 +0100 Subject: net: miiphybb: Pass struct mii_dev directly to bb_miiphy_read/write() Access to MDIO bus private data can be provided by both struct mii_dev .priv member and struct bb_miiphy_bus .priv member, use the former directly and remove .priv from the later. Drop unused bb_miiphy_getbus(). This removes any dependency on struct bb_miiphy_bus from the miiphybb code, except for helper functions which will be removed later. Signed-off-by: Marek Vasut Reviewed-by: Paul Barker --- drivers/net/designware.c | 24 +++--- drivers/net/phy/miiphybb.c | 188 ++++++++++++++++++++------------------------- drivers/net/ravb.c | 23 +++--- drivers/net/sh_eth.c | 23 +++--- 4 files changed, 121 insertions(+), 137 deletions(-) (limited to 'drivers') diff --git a/drivers/net/designware.c b/drivers/net/designware.c index 2069e34be15..4827811dce3 100644 --- a/drivers/net/designware.c +++ b/drivers/net/designware.c @@ -227,9 +227,9 @@ 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) +static int dw_eth_bb_mdio_active(struct mii_dev *miidev) { - struct dw_eth_dev *priv = bus->priv; + struct dw_eth_dev *priv = miidev->priv; struct gpio_desc *desc = &priv->mdio_gpio; desc->flags = 0; @@ -238,9 +238,9 @@ static int dw_eth_bb_mdio_active(struct bb_miiphy_bus *bus) return 0; } -static int dw_eth_bb_mdio_tristate(struct bb_miiphy_bus *bus) +static int dw_eth_bb_mdio_tristate(struct mii_dev *miidev) { - struct dw_eth_dev *priv = bus->priv; + struct dw_eth_dev *priv = miidev->priv; struct gpio_desc *desc = &priv->mdio_gpio; desc->flags = 0; @@ -249,9 +249,9 @@ static int dw_eth_bb_mdio_tristate(struct bb_miiphy_bus *bus) return 0; } -static int dw_eth_bb_set_mdio(struct bb_miiphy_bus *bus, int v) +static int dw_eth_bb_set_mdio(struct mii_dev *miidev, int v) { - struct dw_eth_dev *priv = bus->priv; + struct dw_eth_dev *priv = miidev->priv; if (v) dm_gpio_set_value(&priv->mdio_gpio, 1); @@ -261,18 +261,18 @@ static int dw_eth_bb_set_mdio(struct bb_miiphy_bus *bus, int v) return 0; } -static int dw_eth_bb_get_mdio(struct bb_miiphy_bus *bus, int *v) +static int dw_eth_bb_get_mdio(struct mii_dev *miidev, int *v) { - struct dw_eth_dev *priv = bus->priv; + struct dw_eth_dev *priv = miidev->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) +static int dw_eth_bb_set_mdc(struct mii_dev *miidev, int v) { - struct dw_eth_dev *priv = bus->priv; + struct dw_eth_dev *priv = miidev->priv; if (v) dm_gpio_set_value(&priv->mdc_gpio, 1); @@ -282,9 +282,9 @@ static int dw_eth_bb_set_mdc(struct bb_miiphy_bus *bus, int v) return 0; } -static int dw_eth_bb_delay(struct bb_miiphy_bus *bus) +static int dw_eth_bb_delay(struct mii_dev *miidev) { - struct dw_eth_dev *priv = bus->priv; + struct dw_eth_dev *priv = miidev->priv; udelay(priv->bb_delay); return 0; diff --git a/drivers/net/phy/miiphybb.c b/drivers/net/phy/miiphybb.c index 9481ba76f51..60c791b707b 100644 --- a/drivers/net/phy/miiphybb.c +++ b/drivers/net/phy/miiphybb.c @@ -18,11 +18,6 @@ #include #include -static inline struct bb_miiphy_bus *bb_miiphy_getbus(struct mii_dev *miidev) -{ - return container_of(miidev, struct bb_miiphy_bus, mii); -} - struct bb_miiphy_bus *bb_miiphy_alloc(void) { struct bb_miiphy_bus *bus; @@ -46,7 +41,7 @@ void bb_miiphy_free(struct bb_miiphy_bus *bus) * Utility to send the preamble, address, and register (common to read * and write). */ -static void miiphy_pre(struct bb_miiphy_bus *bus, const struct bb_miiphy_bus_ops *ops, +static void miiphy_pre(struct mii_dev *miidev, const struct bb_miiphy_bus_ops *ops, char read, unsigned char addr, unsigned char reg) { int j; @@ -59,62 +54,62 @@ static void miiphy_pre(struct bb_miiphy_bus *bus, const struct bb_miiphy_bus_ops * but it is safer and will be much more robust. */ - ops->mdio_active(bus); - ops->set_mdio(bus, 1); + ops->mdio_active(miidev); + ops->set_mdio(miidev, 1); for (j = 0; j < 32; j++) { - ops->set_mdc(bus, 0); - ops->delay(bus); - ops->set_mdc(bus, 1); - ops->delay(bus); + ops->set_mdc(miidev, 0); + ops->delay(miidev); + ops->set_mdc(miidev, 1); + ops->delay(miidev); } /* send the start bit (01) and the read opcode (10) or write (10) */ - ops->set_mdc(bus, 0); - ops->set_mdio(bus, 0); - ops->delay(bus); - ops->set_mdc(bus, 1); - ops->delay(bus); - ops->set_mdc(bus, 0); - ops->set_mdio(bus, 1); - ops->delay(bus); - ops->set_mdc(bus, 1); - ops->delay(bus); - ops->set_mdc(bus, 0); - ops->set_mdio(bus, read); - ops->delay(bus); - ops->set_mdc(bus, 1); - ops->delay(bus); - ops->set_mdc(bus, 0); - ops->set_mdio(bus, !read); - ops->delay(bus); - ops->set_mdc(bus, 1); - ops->delay(bus); + ops->set_mdc(miidev, 0); + ops->set_mdio(miidev, 0); + ops->delay(miidev); + ops->set_mdc(miidev, 1); + ops->delay(miidev); + ops->set_mdc(miidev, 0); + ops->set_mdio(miidev, 1); + ops->delay(miidev); + ops->set_mdc(miidev, 1); + ops->delay(miidev); + ops->set_mdc(miidev, 0); + ops->set_mdio(miidev, read); + ops->delay(miidev); + ops->set_mdc(miidev, 1); + ops->delay(miidev); + ops->set_mdc(miidev, 0); + ops->set_mdio(miidev, !read); + ops->delay(miidev); + ops->set_mdc(miidev, 1); + ops->delay(miidev); /* send the PHY address */ for (j = 0; j < 5; j++) { - ops->set_mdc(bus, 0); + ops->set_mdc(miidev, 0); if ((addr & 0x10) == 0) { - ops->set_mdio(bus, 0); + ops->set_mdio(miidev, 0); } else { - ops->set_mdio(bus, 1); + ops->set_mdio(miidev, 1); } - ops->delay(bus); - ops->set_mdc(bus, 1); - ops->delay(bus); + ops->delay(miidev); + ops->set_mdc(miidev, 1); + ops->delay(miidev); addr <<= 1; } /* send the register address */ for (j = 0; j < 5; j++) { - ops->set_mdc(bus, 0); + ops->set_mdc(miidev, 0); if ((reg & 0x10) == 0) { - ops->set_mdio(bus, 0); + ops->set_mdio(miidev, 0); } else { - ops->set_mdio(bus, 1); + ops->set_mdio(miidev, 1); } - ops->delay(bus); - ops->set_mdc(bus, 1); - ops->delay(bus); + ops->delay(miidev); + ops->set_mdc(miidev, 1); + ops->delay(miidev); reg <<= 1; } } @@ -132,57 +127,51 @@ int bb_miiphy_read(struct mii_dev *miidev, const struct bb_miiphy_bus_ops *ops, unsigned short rdreg; /* register working value */ int v; int j; /* counter */ - struct bb_miiphy_bus *bus; - bus = bb_miiphy_getbus(miidev); - if (bus == NULL) { - return -1; - } - - miiphy_pre(bus, ops, 1, addr, reg); + miiphy_pre(miidev, ops, 1, addr, reg); /* tri-state our MDIO I/O pin so we can read */ - ops->set_mdc(bus, 0); - ops->mdio_tristate(bus); - ops->delay(bus); - ops->set_mdc(bus, 1); - ops->delay(bus); + ops->set_mdc(miidev, 0); + ops->mdio_tristate(miidev); + ops->delay(miidev); + ops->set_mdc(miidev, 1); + ops->delay(miidev); /* check the turnaround bit: the PHY should be driving it to zero */ - ops->get_mdio(bus, &v); + ops->get_mdio(miidev, &v); if (v != 0) { /* puts ("PHY didn't drive TA low\n"); */ for (j = 0; j < 32; j++) { - ops->set_mdc(bus, 0); - ops->delay(bus); - ops->set_mdc(bus, 1); - ops->delay(bus); + ops->set_mdc(miidev, 0); + ops->delay(miidev); + ops->set_mdc(miidev, 1); + ops->delay(miidev); } /* There is no PHY, return */ return -1; } - ops->set_mdc(bus, 0); - ops->delay(bus); + ops->set_mdc(miidev, 0); + ops->delay(miidev); /* read 16 bits of register data, MSB first */ rdreg = 0; for (j = 0; j < 16; j++) { - ops->set_mdc(bus, 1); - ops->delay(bus); + ops->set_mdc(miidev, 1); + ops->delay(miidev); rdreg <<= 1; - ops->get_mdio(bus, &v); + ops->get_mdio(miidev, &v); rdreg |= (v & 0x1); - ops->set_mdc(bus, 0); - ops->delay(bus); + ops->set_mdc(miidev, 0); + ops->delay(miidev); } - ops->set_mdc(bus, 1); - ops->delay(bus); - ops->set_mdc(bus, 0); - ops->delay(bus); - ops->set_mdc(bus, 1); - ops->delay(bus); + ops->set_mdc(miidev, 1); + ops->delay(miidev); + ops->set_mdc(miidev, 0); + ops->delay(miidev); + ops->set_mdc(miidev, 1); + ops->delay(miidev); debug("%s[%s](0x%x) @ 0x%x = 0x%04x\n", __func__, miidev->name, reg, addr, rdreg); @@ -199,51 +188,44 @@ int bb_miiphy_read(struct mii_dev *miidev, const struct bb_miiphy_bus_ops *ops, int bb_miiphy_write(struct mii_dev *miidev, const struct bb_miiphy_bus_ops *ops, int addr, int devad, int reg, u16 value) { - struct bb_miiphy_bus *bus; int j; /* counter */ - bus = bb_miiphy_getbus(miidev); - if (bus == NULL) { - /* Bus not found! */ - return -1; - } - - miiphy_pre(bus, ops, 0, addr, reg); + miiphy_pre(miidev, ops, 0, addr, reg); /* send the turnaround (10) */ - ops->set_mdc(bus, 0); - ops->set_mdio(bus, 1); - ops->delay(bus); - ops->set_mdc(bus, 1); - ops->delay(bus); - ops->set_mdc(bus, 0); - ops->set_mdio(bus, 0); - ops->delay(bus); - ops->set_mdc(bus, 1); - ops->delay(bus); + ops->set_mdc(miidev, 0); + ops->set_mdio(miidev, 1); + ops->delay(miidev); + ops->set_mdc(miidev, 1); + ops->delay(miidev); + ops->set_mdc(miidev, 0); + ops->set_mdio(miidev, 0); + ops->delay(miidev); + ops->set_mdc(miidev, 1); + ops->delay(miidev); /* write 16 bits of register data, MSB first */ for (j = 0; j < 16; j++) { - ops->set_mdc(bus, 0); + ops->set_mdc(miidev, 0); if ((value & 0x00008000) == 0) { - ops->set_mdio(bus, 0); + ops->set_mdio(miidev, 0); } else { - ops->set_mdio(bus, 1); + ops->set_mdio(miidev, 1); } - ops->delay(bus); - ops->set_mdc(bus, 1); - ops->delay(bus); + ops->delay(miidev); + ops->set_mdc(miidev, 1); + ops->delay(miidev); value <<= 1; } /* * Tri-state the MDIO line. */ - ops->mdio_tristate(bus); - ops->set_mdc(bus, 0); - ops->delay(bus); - ops->set_mdc(bus, 1); - ops->delay(bus); + ops->mdio_tristate(miidev); + ops->set_mdc(miidev, 0); + ops->delay(miidev); + ops->set_mdc(miidev, 1); + ops->delay(miidev); return 0; } diff --git a/drivers/net/ravb.c b/drivers/net/ravb.c index 65ba107fc00..52547b27aff 100644 --- a/drivers/net/ravb.c +++ b/drivers/net/ravb.c @@ -491,27 +491,27 @@ static void ravb_stop(struct udevice *dev) } /* Bitbang MDIO access */ -static int ravb_bb_mdio_active(struct bb_miiphy_bus *bus) +static int ravb_bb_mdio_active(struct mii_dev *miidev) { - struct ravb_priv *eth = bus->priv; + struct ravb_priv *eth = miidev->priv; setbits_le32(eth->iobase + RAVB_REG_PIR, PIR_MMD); return 0; } -static int ravb_bb_mdio_tristate(struct bb_miiphy_bus *bus) +static int ravb_bb_mdio_tristate(struct mii_dev *miidev) { - struct ravb_priv *eth = bus->priv; + struct ravb_priv *eth = miidev->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) +static int ravb_bb_set_mdio(struct mii_dev *miidev, int v) { - struct ravb_priv *eth = bus->priv; + struct ravb_priv *eth = miidev->priv; if (v) setbits_le32(eth->iobase + RAVB_REG_PIR, PIR_MDO); @@ -521,18 +521,18 @@ static int ravb_bb_set_mdio(struct bb_miiphy_bus *bus, int v) return 0; } -static int ravb_bb_get_mdio(struct bb_miiphy_bus *bus, int *v) +static int ravb_bb_get_mdio(struct mii_dev *miidev, int *v) { - struct ravb_priv *eth = bus->priv; + struct ravb_priv *eth = miidev->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) +static int ravb_bb_set_mdc(struct mii_dev *miidev, int v) { - struct ravb_priv *eth = bus->priv; + struct ravb_priv *eth = miidev->priv; if (v) setbits_le32(eth->iobase + RAVB_REG_PIR, PIR_MDC); @@ -542,7 +542,7 @@ static int ravb_bb_set_mdc(struct bb_miiphy_bus *bus, int v) return 0; } -static int ravb_bb_delay(struct bb_miiphy_bus *bus) +static int ravb_bb_delay(struct mii_dev *miidev) { udelay(10); @@ -598,6 +598,7 @@ static int ravb_probe(struct udevice *dev) mdiodev->read = ravb_bb_miiphy_read; mdiodev->write = ravb_bb_miiphy_write; + mdiodev->priv = eth; snprintf(mdiodev->name, sizeof(mdiodev->name), dev->name); /* Copy the bus accessors and private data */ diff --git a/drivers/net/sh_eth.c b/drivers/net/sh_eth.c index 738dc43cdc7..c898a2204d8 100644 --- a/drivers/net/sh_eth.c +++ b/drivers/net/sh_eth.c @@ -644,9 +644,9 @@ static void sh_ether_stop(struct udevice *dev) } /******* for bb_miiphy *******/ -static int sh_eth_bb_mdio_active(struct bb_miiphy_bus *bus) +static int sh_eth_bb_mdio_active(struct mii_dev *miidev) { - struct sh_eth_dev *eth = bus->priv; + struct sh_eth_dev *eth = miidev->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); @@ -654,9 +654,9 @@ static int sh_eth_bb_mdio_active(struct bb_miiphy_bus *bus) return 0; } -static int sh_eth_bb_mdio_tristate(struct bb_miiphy_bus *bus) +static int sh_eth_bb_mdio_tristate(struct mii_dev *miidev) { - struct sh_eth_dev *eth = bus->priv; + struct sh_eth_dev *eth = miidev->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); @@ -664,9 +664,9 @@ static int sh_eth_bb_mdio_tristate(struct bb_miiphy_bus *bus) return 0; } -static int sh_eth_bb_set_mdio(struct bb_miiphy_bus *bus, int v) +static int sh_eth_bb_set_mdio(struct mii_dev *miidev, int v) { - struct sh_eth_dev *eth = bus->priv; + struct sh_eth_dev *eth = miidev->priv; struct sh_eth_info *port_info = ð->port_info[eth->port]; if (v) @@ -679,9 +679,9 @@ static int sh_eth_bb_set_mdio(struct bb_miiphy_bus *bus, int v) return 0; } -static int sh_eth_bb_get_mdio(struct bb_miiphy_bus *bus, int *v) +static int sh_eth_bb_get_mdio(struct mii_dev *miidev, int *v) { - struct sh_eth_dev *eth = bus->priv; + struct sh_eth_dev *eth = miidev->priv; struct sh_eth_info *port_info = ð->port_info[eth->port]; *v = (sh_eth_read(port_info, PIR) & PIR_MDI) >> 3; @@ -689,9 +689,9 @@ static int sh_eth_bb_get_mdio(struct bb_miiphy_bus *bus, int *v) return 0; } -static int sh_eth_bb_set_mdc(struct bb_miiphy_bus *bus, int v) +static int sh_eth_bb_set_mdc(struct mii_dev *miidev, int v) { - struct sh_eth_dev *eth = bus->priv; + struct sh_eth_dev *eth = miidev->priv; struct sh_eth_info *port_info = ð->port_info[eth->port]; if (v) @@ -704,7 +704,7 @@ static int sh_eth_bb_set_mdc(struct bb_miiphy_bus *bus, int v) return 0; } -static int sh_eth_bb_delay(struct bb_miiphy_bus *bus) +static int sh_eth_bb_delay(struct mii_dev *miidev) { udelay(10); @@ -760,6 +760,7 @@ static int sh_ether_probe(struct udevice *udev) mdiodev->read = sh_eth_bb_miiphy_read; mdiodev->write = sh_eth_bb_miiphy_write; + mdiodev->priv = eth; snprintf(mdiodev->name, sizeof(mdiodev->name), udev->name); /* Copy the bus accessors and private data */ -- cgit v1.2.3 From 596d67e5163834893e9b59d7a5cb9e9a1cd8bc24 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sun, 2 Mar 2025 02:24:46 +0100 Subject: net: miiphybb: Drop priv from struct bb_miiphy_bus Remove the priv member from struct bb_miiphy_bus and its assignment from drivers. This turns struct bb_miiphy_bus int struct mii_dev wrapper, to be cleaned up next. Signed-off-by: Marek Vasut Reviewed-by: Paul Barker --- drivers/net/ravb.c | 3 --- drivers/net/sh_eth.c | 3 --- 2 files changed, 6 deletions(-) (limited to 'drivers') diff --git a/drivers/net/ravb.c b/drivers/net/ravb.c index 52547b27aff..dcd8ba9283f 100644 --- a/drivers/net/ravb.c +++ b/drivers/net/ravb.c @@ -601,9 +601,6 @@ static int ravb_probe(struct udevice *dev) mdiodev->priv = eth; snprintf(mdiodev->name, sizeof(mdiodev->name), dev->name); - /* Copy the bus accessors and private data */ - bb_miiphy->priv = eth; - ret = mdio_register(mdiodev); if (ret < 0) goto err_mdio_register; diff --git a/drivers/net/sh_eth.c b/drivers/net/sh_eth.c index c898a2204d8..c2e2f3fc6c6 100644 --- a/drivers/net/sh_eth.c +++ b/drivers/net/sh_eth.c @@ -763,9 +763,6 @@ static int sh_ether_probe(struct udevice *udev) mdiodev->priv = eth; snprintf(mdiodev->name, sizeof(mdiodev->name), udev->name); - /* Copy the bus accessors and private data */ - bb_miiphy->priv = eth; - ret = mdio_register(mdiodev); if (ret < 0) goto err_mdio_register; -- cgit v1.2.3 From ce7e9a5a636215d2f09ae35acf552b07f4d5b66f Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sun, 2 Mar 2025 02:24:47 +0100 Subject: net: designware: Switch back to mdio_alloc() Use mdio_alloc() again to allocate MDIO bus. This is possible because all the miiphybb parameters and ops passing is handled in at bb_miiphy_read()/bb_miiphy_write() level. This also fixes previously missed bb_miiphy_free() in .remove callback of this driver. which does not pose a problem anymore. Fixes: cbb69c2fafcc ("net: designware: Allocate bb_miiphy using bb_miiphy_alloc() and fill in callbacks") Signed-off-by: Marek Vasut Reviewed-by: Paul Barker --- drivers/net/designware.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) (limited to 'drivers') diff --git a/drivers/net/designware.c b/drivers/net/designware.c index 4827811dce3..0f93c25e3fe 100644 --- a/drivers/net/designware.c +++ b/drivers/net/designware.c @@ -316,17 +316,14 @@ static int dw_bb_miiphy_write(struct mii_dev *miidev, int addr, static int dw_bb_mdio_init(const char *name, struct udevice *dev) { struct dw_eth_dev *dwpriv = dev_get_priv(dev); - struct bb_miiphy_bus *bb_miiphy = bb_miiphy_alloc(); - struct mii_dev *bus; + struct mii_dev *bus = mdio_alloc(); int ret; - if (!bb_miiphy) { + if (!bus) { 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, @@ -855,7 +852,6 @@ 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; @@ -947,8 +943,7 @@ int designware_eth_probe(struct udevice *dev) priv->max_speed = pdata->max_speed; #if IS_ENABLED(CONFIG_BITBANGMII) && IS_ENABLED(CONFIG_DM_GPIO) - bbmiiphy = dev_read_bool(dev, "snps,bitbang-mii"); - if (bbmiiphy) { + if (dev_read_bool(dev, "snps,bitbang-mii")) { ret = dw_bb_mdio_init(dev->name, dev); if (ret) { err = ret; @@ -978,12 +973,7 @@ int designware_eth_probe(struct udevice *dev) /* continue here for cleanup if no PHY found */ err = ret; mdio_unregister(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_free(priv->bus); mdio_err: #ifdef CONFIG_CLK -- cgit v1.2.3 From 877e29cfb1a72d929e79a66281228010d330c7f5 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sun, 2 Mar 2025 02:24:48 +0100 Subject: net: ravb: Switch back to mdio_alloc() Use mdio_alloc() again to allocate MDIO bus. This is possible because all the miiphybb parameters and ops passing is handled in at bb_miiphy_read()/bb_miiphy_write() level. This also fixes previously missed bb_miiphy_free() in .remove callback of this driver. which does not pose a problem anymore. Fixes: 079eaca6e7b4 ("net: ravb: Allocate bb_miiphy using bb_miiphy_alloc() and fill in callbacks") Signed-off-by: Marek Vasut Reviewed-by: Paul Barker --- drivers/net/ravb.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'drivers') diff --git a/drivers/net/ravb.c b/drivers/net/ravb.c index dcd8ba9283f..6129929568a 100644 --- a/drivers/net/ravb.c +++ b/drivers/net/ravb.c @@ -576,7 +576,6 @@ 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; @@ -588,14 +587,12 @@ static int ravb_probe(struct udevice *dev) if (ret < 0) goto err_mdio_alloc; - bb_miiphy = bb_miiphy_alloc(); - if (!bb_miiphy) { + mdiodev = mdio_alloc(); + if (!mdiodev) { ret = -ENOMEM; goto err_mdio_alloc; } - mdiodev = &bb_miiphy->mii; - mdiodev->read = ravb_bb_miiphy_read; mdiodev->write = ravb_bb_miiphy_write; mdiodev->priv = eth; @@ -605,7 +602,7 @@ static int ravb_probe(struct udevice *dev) if (ret < 0) goto err_mdio_register; - eth->bus = &bb_miiphy->mii; + eth->bus = mdiodev; /* Bring up PHY */ ret = clk_enable_bulk(ð->clks); @@ -625,7 +622,7 @@ static int ravb_probe(struct udevice *dev) err_mdio_reset: clk_release_bulk(ð->clks); err_mdio_register: - bb_miiphy_free(bb_miiphy); + mdio_free(mdiodev); err_mdio_alloc: unmap_physmem(eth->iobase, MAP_NOCACHE); return ret; -- cgit v1.2.3 From f6fba8385745b560678c02997d8fe448c1679ca5 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sun, 2 Mar 2025 02:24:49 +0100 Subject: net: sh_eth: Switch back to mdio_alloc() Use mdio_alloc() again to allocate MDIO bus. This is possible because all the miiphybb parameters and ops passing is handled in at bb_miiphy_read()/bb_miiphy_write() level. This also fixes previously missed bb_miiphy_free() in .remove callback of this driver. which does not pose a problem anymore. Fixes: 08eefb5e792d ("net: sh_eth: Allocate bb_miiphy using bb_miiphy_alloc() and fill in callbacks") Signed-off-by: Marek Vasut Reviewed-by: Paul Barker --- drivers/net/sh_eth.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'drivers') diff --git a/drivers/net/sh_eth.c b/drivers/net/sh_eth.c index c2e2f3fc6c6..f695a3a41d2 100644 --- a/drivers/net/sh_eth.c +++ b/drivers/net/sh_eth.c @@ -739,7 +739,6 @@ 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; @@ -750,14 +749,12 @@ static int sh_ether_probe(struct udevice *udev) if (ret < 0) return ret; #endif - bb_miiphy = bb_miiphy_alloc(); - if (!bb_miiphy) { + mdiodev = mdio_alloc(); + if (!mdiodev) { ret = -ENOMEM; return ret; } - mdiodev = &bb_miiphy->mii; - mdiodev->read = sh_eth_bb_miiphy_read; mdiodev->write = sh_eth_bb_miiphy_write; mdiodev->priv = eth; @@ -767,7 +764,7 @@ static int sh_ether_probe(struct udevice *udev) if (ret < 0) goto err_mdio_register; - priv->bus = &bb_miiphy->mii; + priv->bus = mdiodev; eth->port = CFG_SH_ETHER_USE_PORT; eth->port_info[eth->port].phy_addr = CFG_SH_ETHER_PHY_ADDR; @@ -797,7 +794,7 @@ err_phy_config: clk_disable(&priv->clk); #endif err_mdio_register: - bb_miiphy_free(bb_miiphy); + mdio_free(mdiodev); return ret; } -- cgit v1.2.3 From 256306593ecdde5fe01ecc5108d564e76ea8ba65 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sun, 2 Mar 2025 02:24:51 +0100 Subject: net: miiphybb: Drop bb_miiphy_alloc()/bb_miiphy_free() and struct bb_miiphy_bus These functions are no longer necessary, remove them. The struct bb_miiphy_bus is no longer necessary either, remove it as well. Signed-off-by: Marek Vasut Reviewed-by: Paul Barker --- drivers/net/phy/miiphybb.c | 19 ------------------- 1 file changed, 19 deletions(-) (limited to 'drivers') diff --git a/drivers/net/phy/miiphybb.c b/drivers/net/phy/miiphybb.c index 60c791b707b..76463da7299 100644 --- a/drivers/net/phy/miiphybb.c +++ b/drivers/net/phy/miiphybb.c @@ -14,28 +14,9 @@ #include #include -#include #include #include -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 0648671dd3b056b8cbf725bce1a715e6a48406f2 Mon Sep 17 00:00:00 2001 From: Paul Barker Date: Tue, 4 Mar 2025 19:44:35 +0000 Subject: clk: rzg2l: Ignore disable for core clocks Following on from commit 9a699a0a0d62 ("clk: rzg2l: Ignore enable for core clocks"), we also need to ignore attempts to disable core clocks to avoid the need for conditionals around clk_disable_bulk() calls in drivers which support both RZ/G2L and other Renesas SoCs. Signed-off-by: Paul Barker Reviewed-by: Marek Vasut --- drivers/clk/renesas/rzg2l-cpg.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'drivers') diff --git a/drivers/clk/renesas/rzg2l-cpg.c b/drivers/clk/renesas/rzg2l-cpg.c index 3c5340df8ee..7fce1f70d13 100644 --- a/drivers/clk/renesas/rzg2l-cpg.c +++ b/drivers/clk/renesas/rzg2l-cpg.c @@ -70,17 +70,12 @@ static int rzg2l_cpg_clk_set(struct clk *clk, bool enable) dev_dbg(clk->dev, "%s %s clock %u\n", enable ? "enable" : "disable", is_mod_clk(clk->id) ? "module" : "core", cpg_clk_id); - if (!is_mod_clk(clk->id)) { - /* - * Non-module clocks are always on. Ignore attempts to enable - * them and reject attempts to disable them. - */ - if (enable) - return 0; - - dev_err(clk->dev, "ID %lu is not a module clock\n", clk->id); - return -EINVAL; - } + /* + * Non-module clocks are always on. Ignore attempts to enable or disable + * them. + */ + if (!is_mod_clk(clk->id)) + return 0; for (i = 0; i < data->info->num_mod_clks; i++) { if (data->info->mod_clks[i].id == cpg_clk_id) { -- cgit v1.2.3 From 78e15e2dd9ca79a2dd8c821197ddd8239f09e753 Mon Sep 17 00:00:00 2001 From: Paul Barker Date: Tue, 4 Mar 2025 20:07:07 +0000 Subject: net: ravb: Add dependency on CONFIG_BITBANGMII The Renesas RAVB driver always requires bitbang MDIO bus support. Fixes: 8ae51b6f324e ("net: ravb: Add Renesas Ethernet RAVB driver") Signed-off-by: Paul Barker Reviewed-by: Marek Vasut --- drivers/net/Kconfig | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 1563404ca17..b9d8972ef08 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -852,6 +852,7 @@ config RENESAS_ETHER_SWITCH config RENESAS_RAVB bool "Renesas Ethernet AVB MAC" depends on RCAR_64 + select BITBANGMII select PHYLIB select PHY_ETHERNET_ID help -- cgit v1.2.3 From 4226433858318be5914688963436ad41cbe2298d Mon Sep 17 00:00:00 2001 From: Paul Barker Date: Tue, 4 Mar 2025 20:07:08 +0000 Subject: net: ravb: Fix RX frame size limit The value written to the RFLR register includes the length of the CRC data at the end of each Ethernet frame. So we need to increase the value written to this register to ensure that we can receive full size frames. While we're here we can also copy the improved comment from the Linux kernel. Fixes: 8ae51b6f324e ("net: ravb: Add Renesas Ethernet RAVB driver") Signed-off-by: Paul Barker Signed-off-by: Marek Vasut # Fix comment Reviewed-by: Marek Vasut --- drivers/net/ravb.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/net/ravb.c b/drivers/net/ravb.c index 6129929568a..c39bef17b79 100644 --- a/drivers/net/ravb.c +++ b/drivers/net/ravb.c @@ -354,8 +354,15 @@ static int ravb_mac_init(struct ravb_priv *eth) /* Disable MAC Interrupt */ writel(0, eth->iobase + RAVB_REG_ECSIPR); - /* Recv frame limit set register */ - writel(RFLR_RFL_MIN, eth->iobase + RAVB_REG_RFLR); + /* + * Set receive frame length + * + * The length set here describes the frame from the destination address + * up to and including the CRC data. However only the frame data, + * excluding the CRC, are transferred to memory. To allow for the + * largest frames add the CRC length to the maximum Rx descriptor size. + */ + writel(RFLR_RFL_MIN + ETH_FCS_LEN, eth->iobase + RAVB_REG_RFLR); return 0; } -- cgit v1.2.3