lan937x_mdio_bus_preinit(9)
π lan937x_mdio_bus_preinit π
okay so bestie, welcome to the Kernel API Manual, and today's main character is lan937x_mdio_bus_preinit β the little function that gets your MDIO bus ready before you go talking to PHYs. yes we're doing networking lore today, buckle up π
β¨ NAME β¨
lan937x_mdio_bus_preinit β pre-initialize the MDIO bus so you can actually access PHYs.
like, it's the warm-up stretch before the gym, but for a switch. no cap πͺ
π¦ SYNOPSIS π¦
int lan937x_mdio_bus_preinit (struct ksz_device *dev , bool side_mdio );
one function, two args, zero drama. it returns an int btw, which you'll care about in a sec π
πΈ ARGUMENTS πΈ
devβ pointer to the device structure. yes, the struct. the whole vibe of the device lives in there π«Άside_mdioβ a boolean telling everyone whether the PHYs are accessed over a side MDIO bus.true? side MDIO bus.false? not that. it's giving "choose your fighter" β¨
π DESCRIPTION π
so here's the tea: this function configures the LAN937x switch for PHY access β either through SPI or through the side MDIO bus β and it unlocks the registers you need for each of those access modes. literally its whole job. iconic behavior honestly π
π Operation Modes π
- SPI Access β enables SPI indirect access, which addresses clock domain crossing issues when SPI is the thing being used for PHY access. yes, clock domain crossing issues. we respect them. we address them. slay β°β¨
- MDIO Access β grants access to the internal PHYs over the side MDIO bus. this one is required when you're using the MDIO bus for PHY management. required!! not optional!! periodt π
ngl, pick the mode that matches how your PHYs are actually wired up β the two paths unlock different registers, so it's not a "whatever, same thing" situation π
π₯ RETURN π₯
0on success π- an error code on failure π (and yes, that means you should actually check it. don't just ignore the return value, bestie. vibe check your errors.)
π§ SEE ALSO π§
- Kernel file
./drivers/net/dsa/microchip/lan937x_main.cβ the source, go read it, it's right there π lan937x_create_phy_addr_map(9)lan937x_mdio_register(9)
both of those are also very much worth a look, iykyk π¦
and that's the page!! straight from the ./drivers/net/dsa/microchip directory, dated October 2026, living under the Kernel API Manual banner. go forth and preinit your MDIO bus, you've got this πβ¨π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms