lan937x_mdio_bus_preinit(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 🌈

  1. 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 ⏰✨
  2. 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 πŸ”₯

  • 0 on 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 🧚

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