A very simple solution for accessing any MDIO bus from user-space.
The kernel module and userspace application communicate via netlink.
Current code stands as a proof-of-concept and it's subject for further development, requiring several improvements and enhancements.
git clone and compile your kernel
setup tool-chain
export CROSS_COMPILE=aarch64-linux-gnu-
export ARCH=arm64
compile
make KBUILD_DIR=<path to kernel>
load kernel module using insmod
NXP MDIO proxy module loaded
use the mdio-app tool to read/write phy registers
root@localhost:~# ./mdio-app
Usage:
./mdio-app <bus> <addr> c22 <reg> [data]
./mdio-app <bus> <addr> c45 <devad> <reg> [data]
Example reading PHYID from an AQR113c ethernet phy.
root@localhost:~# ./mdio-app 1afd000 0 c45 1e 3
Got back: data=0x1c12
root@localhost:~# ./mdio-app 1afd000 0 c45 1e 2
Got back: data=0x31c3
Florin Chiculita <florinlaurentiu.chiculita@nxp.com> <your name here>
Clean-up code
Improve userspace application usage
U-Boot mdio syntax
Allow range of registers
Enumerating all mdio busses and phys
Kernel API mdio_find_bus() is available only on newer kernels but can be backported with ease.