Skip to content

Commit

Permalink
drivers: ethernet: ksz8081: RMII override RNB part
Browse files Browse the repository at this point in the history
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]>
(cherry picked from commit 495a374)
  • Loading branch information
decsny authored and github-actions[bot] committed Nov 5, 2024
1 parent 7076559 commit 6bddaaa
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/ethernet/phy/phy_microchip_ksz8081.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
#define PHY_MC_KSZ8081_OMSO_REG 0x16
#define PHY_MC_KSZ8081_OMSO_FACTORY_MODE_MASK BIT(15)
#define PHY_MC_KSZ8081_OMSO_NAND_TREE_MASK BIT(5)
#define PHY_MC_KSZ8081_OMSO_RMII_OVERRIDE_MASK BIT(1)
#define PHY_MC_KSZ8081_OMSO_MII_OVERRIDE_MASK BIT(0)

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

omso &= ~PHY_MC_KSZ8081_OMSO_FACTORY_MODE_MASK &
~PHY_MC_KSZ8081_OMSO_NAND_TREE_MASK;
if (config->phy_iface == KSZ8081_RMII) {
omso &= ~PHY_MC_KSZ8081_OMSO_MII_OVERRIDE_MASK;
omso |= PHY_MC_KSZ8081_OMSO_RMII_OVERRIDE_MASK;
}

ret = phy_mc_ksz8081_write(dev, PHY_MC_KSZ8081_OMSO_REG, (uint32_t)omso);
if (ret) {
Expand Down

0 comments on commit 6bddaaa

Please sign in to comment.