]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: mdio: realtek-rtl9300: Link I/O functions in info structure
authorMarkus Stockhausen <markus.stockhausen@gmx.de>
Thu, 21 May 2026 17:59:18 +0000 (19:59 +0200)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 26 May 2026 09:56:15 +0000 (11:56 +0200)
The MDIO controller registers of the different devices of the
Realtek Otto switch series are very similar. Nevertheless each
device will need to feed the whole command data distributed over
the controller registers slightly different.

E.g. the combined C22/command register has different field layouts.
On RTL930x bits 24-20 define the to-be-accessed C22 register number
while on RTL839x this is stored in bits 9-5.

Thus there need to be device specific read/write functions that
are called dynamically. Add them into the info structure and make
use of them where needed.

Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
Link: https://patch.msgid.link/20260521175918.1494797-10-markus.stockhausen@gmx.de
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/mdio/mdio-realtek-rtl9300.c

index 8130e376b59b80d174d2675cb4dae35be7f26305..65c59b8457d4419a58edfdf0b87afc5540bdd069 100644 (file)
@@ -94,6 +94,10 @@ struct otto_emdio_info {
        u8 num_buses;
        u8 num_ports;
        u16 num_pages;
+       int (*read_c22)(struct mii_bus *bus, int phy_id, int regnum);
+       int (*read_c45)(struct mii_bus *bus, int phy_id, int dev_addr, int regnum);
+       int (*write_c22)(struct mii_bus *bus, int phy_id, int regnum, u16 value);
+       int (*write_c45)(struct mii_bus *bus, int phy_id, int dev_addr, int regnum, u16 value);
 };
 
 struct otto_emdio_priv {
@@ -433,11 +437,11 @@ static int otto_emdio_probe_one(struct device *dev, struct otto_emdio_priv *priv
 
        bus->name = "Realtek Switch MDIO Bus";
        if (priv->smi_bus_is_c45[mdio_bus]) {
-               bus->read_c45 = otto_emdio_9300_read_c45;
-               bus->write_c45 = otto_emdio_9300_write_c45;
+               bus->read_c45 = priv->info->read_c45;
+               bus->write_c45 = priv->info->write_c45;
        } else {
-               bus->read = otto_emdio_9300_read_c22;
-               bus->write = otto_emdio_9300_write_c22;
+               bus->read = priv->info->read_c22;
+               bus->write = priv->info->write_c22;
        }
        bus->parent = dev;
        chan = bus->priv;
@@ -563,6 +567,10 @@ static const struct otto_emdio_info otto_emdio_9300_info = {
        .num_buses = RTL9300_NUM_BUSES,
        .num_ports = RTL9300_NUM_PORTS,
        .num_pages = RTL9300_NUM_PAGES,
+       .read_c22 = otto_emdio_9300_read_c22,
+       .read_c45 = otto_emdio_9300_read_c45,
+       .write_c22 = otto_emdio_9300_write_c22,
+       .write_c45 = otto_emdio_9300_write_c45,
 };
 
 static const struct of_device_id otto_emdio_ids[] = {