Skip to content

Commit 2572ce6

Browse files
fancerdavem330
authored andcommitted
net: mdio: mdio-bitbang: Fix C45 read/write protocol
Based on the original code semantic in case of Clause 45 MDIO, the address command is supposed to be followed by the command sending the MMD address, not the CSR address. The commit 002dd3d ("net: mdio: mdio-bitbang: Separate C22 and C45 transactions") has erroneously broken that. So most likely due to an unfortunate variable name it switched the code to sending the CSR address. In our case it caused the protocol malfunction so the read operation always failed with the turnaround bit always been driven to one by PHY instead of zero. Fix that by getting back the correct behaviour: sending MMD address command right after the regular address command. Fixes: 002dd3d ("net: mdio: mdio-bitbang: Separate C22 and C45 transactions") Signed-off-by: Serge Semin <fancer.lancer@gmail.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent e94b590 commit 2572ce6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/net/mdio/mdio-bitbang.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ int mdiobb_read_c45(struct mii_bus *bus, int phy, int devad, int reg)
186186
struct mdiobb_ctrl *ctrl = bus->priv;
187187

188188
mdiobb_cmd_addr(ctrl, phy, devad, reg);
189-
mdiobb_cmd(ctrl, MDIO_C45_READ, phy, reg);
189+
mdiobb_cmd(ctrl, MDIO_C45_READ, phy, devad);
190190

191191
return mdiobb_read_common(bus, phy);
192192
}
@@ -222,7 +222,7 @@ int mdiobb_write_c45(struct mii_bus *bus, int phy, int devad, int reg, u16 val)
222222
struct mdiobb_ctrl *ctrl = bus->priv;
223223

224224
mdiobb_cmd_addr(ctrl, phy, devad, reg);
225-
mdiobb_cmd(ctrl, MDIO_C45_WRITE, phy, reg);
225+
mdiobb_cmd(ctrl, MDIO_C45_WRITE, phy, devad);
226226

227227
return mdiobb_write_common(bus, val);
228228
}

0 commit comments

Comments
 (0)