Skip to content

Commit 495a374

Browse files
decsnymmahadevan108
authored andcommitted
drivers: ethernet: ksz8081: RMII override RNB part
I for the life of me do not know what is going on here with the RNB chip but it seems this override must be set in order for the chip to work, regardless of strap-in configuration, and if not set explicitly, the value after a reset for these two bits will be seemingly random and inconsistent. And it was working before by luck before removing a second redundant reset in a recent commit, because apparently the register was getting the opposite of the reset value according to the datasheet which makes it work. The result of these bits after reset seem to vary depending on host mcu, board, debugger, number of times reset, type of reset, and with a pinch of random chance after keeping all variables seemingly the same, so let's just set it to the value that works explicitly, even if it doesn't make sense. The bit here doesn't have clear documentation but it seems it's for using RMII regardless of the strap in option, which is what we want to do anyways if we know the interface type from DT, so I think it's fine, considering it is making this driver work again. Signed-off-by: Declan Snyder <[email protected]>
1 parent 9687773 commit 495a374

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/ethernet/phy/phy_microchip_ksz8081.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
2626
#define PHY_MC_KSZ8081_OMSO_REG 0x16
2727
#define PHY_MC_KSZ8081_OMSO_FACTORY_MODE_MASK BIT(15)
2828
#define PHY_MC_KSZ8081_OMSO_NAND_TREE_MASK BIT(5)
29+
#define PHY_MC_KSZ8081_OMSO_RMII_OVERRIDE_MASK BIT(1)
30+
#define PHY_MC_KSZ8081_OMSO_MII_OVERRIDE_MASK BIT(0)
2931

3032
#define PHY_MC_KSZ8081_CTRL2_REG 0x1F
3133
#define PHY_MC_KSZ8081_CTRL2_REF_CLK_SEL BIT(7)
@@ -235,6 +237,10 @@ static int phy_mc_ksz8081_static_cfg(const struct device *dev)
235237

236238
omso &= ~PHY_MC_KSZ8081_OMSO_FACTORY_MODE_MASK &
237239
~PHY_MC_KSZ8081_OMSO_NAND_TREE_MASK;
240+
if (config->phy_iface == KSZ8081_RMII) {
241+
omso &= ~PHY_MC_KSZ8081_OMSO_MII_OVERRIDE_MASK;
242+
omso |= PHY_MC_KSZ8081_OMSO_RMII_OVERRIDE_MASK;
243+
}
238244

239245
ret = phy_mc_ksz8081_write(dev, PHY_MC_KSZ8081_OMSO_REG, (uint32_t)omso);
240246
if (ret) {

0 commit comments

Comments
 (0)