* [PATCH 0/2] net: mdio-mt7531-mmio: consolidate and improve probe
@ 2026-02-09 11:45 Christian Marangi
2026-02-09 11:45 ` [PATCH 1/2] net: mdio-mt7531-mmio: use common header priv struct Christian Marangi
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Christian Marangi @ 2026-02-09 11:45 UTC (permalink / raw)
To: Joe Hershberger, Ramon Fried, Jerome Forissier, Tom Rini, u-boot
Cc: Christian Marangi
This small series consolidate header usage of mdio-mt7531-mmio driver
and improve usage in preparation for support of OF PHY autoprobe.
This driver is still not used (as it will be used by AN7581/AN7583)
in the OF mode (it's used by MT7988 for the MDIO functions)
For OF PHY to be correctly autoprobed, the MDIO driver needs to attached
to the MDIO node (the parent of the PHY nodes)
With such change the MDIO driver can be binded with the MDIO node instead
of the switch node as previously required.
Christian Marangi (2):
net: mdio-mt7531-mmio: use common header priv struct
net: mdio-mt7531-mmio: improve parsing of switch register on probe
drivers/net/mdio-mt7531-mmio.c | 31 +++++++++++++++++--------------
1 file changed, 17 insertions(+), 14 deletions(-)
--
2.51.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] net: mdio-mt7531-mmio: use common header priv struct
2026-02-09 11:45 [PATCH 0/2] net: mdio-mt7531-mmio: consolidate and improve probe Christian Marangi
@ 2026-02-09 11:45 ` Christian Marangi
2026-02-09 11:45 ` [PATCH 2/2] net: mdio-mt7531-mmio: improve parsing of switch register on probe Christian Marangi
2026-02-23 22:48 ` [PATCH 0/2] net: mdio-mt7531-mmio: consolidate and improve probe Tom Rini
2 siblings, 0 replies; 4+ messages in thread
From: Christian Marangi @ 2026-02-09 11:45 UTC (permalink / raw)
To: Joe Hershberger, Ramon Fried, Jerome Forissier, Tom Rini, u-boot
Cc: Christian Marangi
Instead of having duplicate priv struct for mdio-mt7531-mmio driver in
both driver and header, use the one exposed by the header directly.
This make sure we have consistent priv struct if the driver will be
updated in the future.
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
drivers/net/mdio-mt7531-mmio.c | 24 +++++++++++-------------
1 file changed, 11 insertions(+), 13 deletions(-)
diff --git a/drivers/net/mdio-mt7531-mmio.c b/drivers/net/mdio-mt7531-mmio.c
index 3e325ca58da..58cb6e503b8 100644
--- a/drivers/net/mdio-mt7531-mmio.c
+++ b/drivers/net/mdio-mt7531-mmio.c
@@ -6,6 +6,8 @@
#include <linux/iopoll.h>
#include <miiphy.h>
+#include "mdio-mt7531-mmio.h"
+
#define MT7531_PHY_IAC 0x701c
#define MT7531_PHY_ACS_ST BIT(31)
#define MT7531_MDIO_REG_ADDR_CL22 GENMASK(29, 25)
@@ -25,11 +27,7 @@
#define MT7531_MDIO_TIMEOUT 100000
#define MT7531_MDIO_SLEEP 20
-struct mt7531_mdio_priv {
- phys_addr_t switch_regs;
-};
-
-static int mt7531_mdio_wait_busy(struct mt7531_mdio_priv *priv)
+static int mt7531_mdio_wait_busy(struct mt7531_mdio_mmio_priv *priv)
{
unsigned int busy;
@@ -38,7 +36,7 @@ static int mt7531_mdio_wait_busy(struct mt7531_mdio_priv *priv)
MT7531_MDIO_SLEEP, MT7531_MDIO_TIMEOUT);
}
-static int mt7531_mdio_read(struct mt7531_mdio_priv *priv, int addr, int devad, int reg)
+static int mt7531_mdio_read(struct mt7531_mdio_mmio_priv *priv, int addr, int devad, int reg)
{
u32 val;
@@ -75,7 +73,7 @@ static int mt7531_mdio_read(struct mt7531_mdio_priv *priv, int addr, int devad,
return val & MT7531_MDIO_RW_DATA;
}
-static int mt7531_mdio_write(struct mt7531_mdio_priv *priv, int addr, int devad,
+static int mt7531_mdio_write(struct mt7531_mdio_mmio_priv *priv, int addr, int devad,
int reg, u16 value)
{
u32 val;
@@ -115,7 +113,7 @@ static int mt7531_mdio_write(struct mt7531_mdio_priv *priv, int addr, int devad,
int mt7531_mdio_mmio_read(struct mii_dev *bus, int addr, int devad, int reg)
{
- struct mt7531_mdio_priv *priv = bus->priv;
+ struct mt7531_mdio_mmio_priv *priv = bus->priv;
return mt7531_mdio_read(priv, addr, devad, reg);
}
@@ -123,14 +121,14 @@ int mt7531_mdio_mmio_read(struct mii_dev *bus, int addr, int devad, int reg)
int mt7531_mdio_mmio_write(struct mii_dev *bus, int addr, int devad,
int reg, u16 value)
{
- struct mt7531_mdio_priv *priv = bus->priv;
+ struct mt7531_mdio_mmio_priv *priv = bus->priv;
return mt7531_mdio_write(priv, addr, devad, reg, value);
}
static int dm_mt7531_mdio_read(struct udevice *dev, int addr, int devad, int reg)
{
- struct mt7531_mdio_priv *priv = dev_get_priv(dev);
+ struct mt7531_mdio_mmio_priv *priv = dev_get_priv(dev);
return mt7531_mdio_read(priv, addr, devad, reg);
}
@@ -138,7 +136,7 @@ static int dm_mt7531_mdio_read(struct udevice *dev, int addr, int devad, int reg
static int dm_mt7531_mdio_write(struct udevice *dev, int addr, int devad,
int reg, u16 value)
{
- struct mt7531_mdio_priv *priv = dev_get_priv(dev);
+ struct mt7531_mdio_mmio_priv *priv = dev_get_priv(dev);
return mt7531_mdio_write(priv, addr, devad, reg, value);
}
@@ -150,7 +148,7 @@ static const struct mdio_ops mt7531_mdio_ops = {
static int mt7531_mdio_probe(struct udevice *dev)
{
- struct mt7531_mdio_priv *priv = dev_get_priv(dev);
+ struct mt7531_mdio_mmio_priv *priv = dev_get_priv(dev);
priv->switch_regs = dev_read_addr(dev);
if (priv->switch_regs == FDT_ADDR_T_NONE)
@@ -164,5 +162,5 @@ U_BOOT_DRIVER(mt7531_mdio) = {
.id = UCLASS_MDIO,
.probe = mt7531_mdio_probe,
.ops = &mt7531_mdio_ops,
- .priv_auto = sizeof(struct mt7531_mdio_priv),
+ .priv_auto = sizeof(struct mt7531_mdio_mmio_priv),
};
--
2.51.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] net: mdio-mt7531-mmio: improve parsing of switch register on probe
2026-02-09 11:45 [PATCH 0/2] net: mdio-mt7531-mmio: consolidate and improve probe Christian Marangi
2026-02-09 11:45 ` [PATCH 1/2] net: mdio-mt7531-mmio: use common header priv struct Christian Marangi
@ 2026-02-09 11:45 ` Christian Marangi
2026-02-23 22:48 ` [PATCH 0/2] net: mdio-mt7531-mmio: consolidate and improve probe Tom Rini
2 siblings, 0 replies; 4+ messages in thread
From: Christian Marangi @ 2026-02-09 11:45 UTC (permalink / raw)
To: Joe Hershberger, Ramon Fried, Jerome Forissier, Tom Rini, u-boot
Cc: Christian Marangi
The MDIO node is ALWAYS a parent of the MT7531 switch node and the MDIO
registers are in the MT7531 register space (in the context of MT7988
it's all memory-mapped)
With these assumption, we can simplify and permit better usage of PHY OF
automatic probing by binding the mt7531-mdio-mmio driver with the MDIO
node instead of the switch node.
For OF PHY to be correctly autoprobed, the MDIO driver needs to attached
to the MDIO node (the parent of the PHY nodes).
The driver will reach the parent node (the switch node) and will parse
the register address from there.
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
drivers/net/mdio-mt7531-mmio.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/net/mdio-mt7531-mmio.c b/drivers/net/mdio-mt7531-mmio.c
index 58cb6e503b8..930454a9b0e 100644
--- a/drivers/net/mdio-mt7531-mmio.c
+++ b/drivers/net/mdio-mt7531-mmio.c
@@ -149,8 +149,13 @@ static const struct mdio_ops mt7531_mdio_ops = {
static int mt7531_mdio_probe(struct udevice *dev)
{
struct mt7531_mdio_mmio_priv *priv = dev_get_priv(dev);
+ ofnode switch_node;
- priv->switch_regs = dev_read_addr(dev);
+ switch_node = ofnode_get_parent(dev_ofnode(dev));
+ if (!ofnode_valid(switch_node))
+ return -EINVAL;
+
+ priv->switch_regs = ofnode_get_addr(switch_node);
if (priv->switch_regs == FDT_ADDR_T_NONE)
return -EINVAL;
--
2.51.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] net: mdio-mt7531-mmio: consolidate and improve probe
2026-02-09 11:45 [PATCH 0/2] net: mdio-mt7531-mmio: consolidate and improve probe Christian Marangi
2026-02-09 11:45 ` [PATCH 1/2] net: mdio-mt7531-mmio: use common header priv struct Christian Marangi
2026-02-09 11:45 ` [PATCH 2/2] net: mdio-mt7531-mmio: improve parsing of switch register on probe Christian Marangi
@ 2026-02-23 22:48 ` Tom Rini
2 siblings, 0 replies; 4+ messages in thread
From: Tom Rini @ 2026-02-23 22:48 UTC (permalink / raw)
To: Joe Hershberger, Ramon Fried, Jerome Forissier, u-boot,
Christian Marangi
On Mon, 09 Feb 2026 12:45:04 +0100, Christian Marangi wrote:
> This small series consolidate header usage of mdio-mt7531-mmio driver
> and improve usage in preparation for support of OF PHY autoprobe.
>
> This driver is still not used (as it will be used by AN7581/AN7583)
> in the OF mode (it's used by MT7988 for the MDIO functions)
>
> For OF PHY to be correctly autoprobed, the MDIO driver needs to attached
> to the MDIO node (the parent of the PHY nodes)
>
> [...]
Applied to u-boot/next, thanks!
[1/2] net: mdio-mt7531-mmio: use common header priv struct
commit: 145487611f6875efc106be7f41e8544ff5bdadc9
[2/2] net: mdio-mt7531-mmio: improve parsing of switch register on probe
commit: 358f97fcca9a888e7f2c074d70460b92b5222c55
--
Tom
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-02-23 22:48 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-09 11:45 [PATCH 0/2] net: mdio-mt7531-mmio: consolidate and improve probe Christian Marangi
2026-02-09 11:45 ` [PATCH 1/2] net: mdio-mt7531-mmio: use common header priv struct Christian Marangi
2026-02-09 11:45 ` [PATCH 2/2] net: mdio-mt7531-mmio: improve parsing of switch register on probe Christian Marangi
2026-02-23 22:48 ` [PATCH 0/2] net: mdio-mt7531-mmio: consolidate and improve probe Tom Rini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox