ref: db821f2de25161522bee09d69f9a9e0962f7ca06
parent: d1a416fc43cc0cbab3a881531d24f839ff722fee
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sat Apr 19 13:32:27 EDT 2025
kernel: add experimental devmii phy debug driver This drivers allows poking at phy registers for the drivers that register their mii bus by calling addmiibus(). This requires some changes to port/ethermii.c: - Register access needs to be serialized (using a QLock) - Provide hooks for addmiibus()/delmiibus() - Added Mii.name field which needs to be populated by driver Devmii exports the following: + Qbus, /* #Φ/busN */ + Qphy, /* #Φ/busN/phyN */ + Qctl, /* #Φ/busN/phyN/ctl */ + Qmii, /* #Φ/busN/phyN/mii (clause22) */ + Qmmd, /* #Φ/busN/phyN/mmd (clause45) */ In its root, it lists all the mii buses (usually named by the ethernet interface name that registers it). In the root, it shows numbered directories for all the phy's on the bus. And each phy directory contains a textual ctl file, that when read returns status of the phy. The following commands can be written: - reset (reset the phy) - status (update phy status) - autoneg (restart auto-negotiation) The "mii" file allows raw clause22 register access (register number encoded in the offset 0-31). The "mmd" file allows raw clause45 register access (register number encoded in lower 16-bits, upper bits [16-20] encode the device address, so accessing ID1/2 registers 1.1/1.2 is offset 0x10001 and 0x10002 respectively.