control-mdio

CLI reference

glasgow run control-mdio

Configure Ethernet PHYs and query their status via the standard two-wire MDC/MDIO management interface. Both Clause 22 and Clause 45 operations are supported.

usage: glasgow run control-mdio [-h] [-V VOLTS] [--mdc PIN] [--mdio PIN]
                                [-f FREQ]
-h, --help

show this help message and exit

-V <volts>, --voltage <volts>

bus power (range: 1.8..5 V, or ‘S<port>’ to follow the voltage sensed on a port; default: unchanged)

--mdc <pin>

bind management data clock to PIN (default: ‘A0’, required)

--mdio <pin>

bind management data input/output to PIN (default: ‘A1’, required)

-f <freq>, --frequency <freq>

set MDC frequency to FREQ kHz (default: 1000)

API reference

class glasgow.applet.control.mdio.ControlMDIOPorts(*, supply: glasgow.abstract.GlasgowSupply, mdc: amaranth.lib.io.PortLike, mdio: amaranth.lib.io.PortLike)
supply: GlasgowSupply

bus power

mdc: PortLike

management data clock

mdio: PortLike

management data input/output

class glasgow.applet.control.mdio.ControlMDIOInterface(logger: Logger, assembly: AbstractAssembly, ports: ControlMDIOPorts)

MDIO controller.

ports is a ControlMDIOPorts. The mdio pin should have a pull-down.

property clock: ClockDivisor

MDC clock divisor.

async c22_read(phy: int, reg: int) → int

Read Clause 22 (SMI/MIIM) register reg of PHY phy.

async c22_write(phy: int, reg: int, value: int)

Write value to Clause 22 (MIIM) register reg of PHY phy.

async c45_read(phy: int, dev: int, reg: int) → int

Read Clause 45 (MDIO) register reg of MMD dev of PHY phy.

async c45_write(phy: int, dev: int, reg: int, value: int)

Write value to Clause 45 (MDIO) register reg of MMD dev of PHY phy.

async get_phy_id() → tuple[int, int, int]

Read PHY identification.

Returns a tuple (oui24, model, rev), where oui24 is the OUI in the canonical (non-bit-reversed) representation; in it, two least significant bits are always 0.