phy_write(9)
πΈ phy_write(9) πΈ
okay bestie so this is a page straight out of the Kernel API Manual β the kernel's own little handbook β and it's all about one tiny but iconic function. Pull up a chair. π«Ά
β¨ NAME β¨
phy_write β the convenience function for writing to a given PHY register. that's it, that's the whole vibe. it writes a value to a register. lowkey the whole point of the function.
π SYNOPSIS π
int phy_write (struct phy_device *phydev , u32 regnum , u16 val );
three little arguments, one int coming back at you. she's compact. she's efficient. she ate.
π¦ ARGUMENTS π¦
phydevβ thephy_devicestruct. this is your main character β the device object you're doing the writing on.regnumβ the register number to write. it's au32, so pick your register and go πvalβ the value to write toregnum. it's au16, and it's literally going into the register. girl's got a destination.
π NOTE π
MUST NOT be called from interrupt context. not a suggestion, not a soft recommendation β MUST NOT. and the reason is so real: the bus read/write functions may wait for an interrupt to conclude the operation. so if you're already in interrupt context, you'd be out here waiting on an interrupt. π do not do that to yourself.
periodt. no interrupt context. π«
π SEE ALSO π
the kernel file this all lives in is ./include/linux/phy.h, and here's the whole extended friend group β every single one of them, no gatekeeping π
- the interface & clock girlies:
enum phy_interface_t(9),phy_modes(9),rgmii_clock(9),enum link_inband_signalling(9),phy_interface_mode_is_rgmii(9),phy_interface_mode_is_8023z(9),phy_interface_is_rgmii(9) - the bus & stats crew:
struct mdio_bus_stats(9),struct mii_bus(9),mdiobus_alloc(9) - the state & device squad:
enum phy_state(9),struct phy_c45_device_ids(9),struct phy_oatc14_sqi_capability(9),struct phy_device(9),struct phy_driver(9),phy_module_driver(9) - the diagnostics darlings:
struct phy_tdr_config(9),struct phy_mse_capability(9),struct phy_mse_snapshot(9) - the plca + led besties:
struct phy_plca_cfg(9),struct phy_plca_status(9),struct phy_led(9) - the id-comparison cuties:
phy_id_compare(9),phy_id_compare_vendor(9),phy_id_compare_model(9),phydev_id_compare(9) - the little status checks:
phy_is_started(9),phy_driver_is_genphy(9),phy_disable_eee_mode(9),phy_can_wakeup(9),phy_may_wakeup(9),phy_is_pseudo_fixed_link(9),phy_on_sfp(9) - the read/write & bit-twiddling icons:
phy_read(9),__phy_read(9),__phy_write(9),__phy_modify_changed(9),phy_read_mmd_poll_timeout(9),__phy_set_bits(9),__phy_clear_bits(9),phy_set_bits(9),phy_clear_bits(9),__phy_set_bits_mmd(9),__phy_clear_bits_mmd(9),phy_set_bits_mmd(9),phy_clear_bits_mmd(9) - the interrupt & timestamp gang:
phy_interrupt_is_valid(9),phy_polling_mode(9),phy_has_hwtstamp(9),phy_has_rxtstamp(9),phy_has_tsinfo(9),phy_has_txtstamp(9),phy_is_default_hwtstamp(9)
go read all of them. i'll wait. π
and that's the whole page, bestie!! this one shipped from ./include/linux and it's dated October 2026 β so yeah, future-dated kernel lore, we love to see it πβ¨ stay out of interrupt context and go write those registers responsibly π
π
π¦ 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