phytool下载地址
https://github.com/wkz/phytool
phytool
Linux MDIO register access
Usage
<0-0xffff> phytool print IFACE/ADDR[/REG] Clause 22: ADDR := <0-0x1f> REG := <0-0x1f> Clause 45 (not supported by all MDIO drivers): ADDR := PORT:DEV PORT := <0-0x1f> DEV := <0-0x1f> REG := <0-0xffff>
The read and write commands are simple register level accessors. The
print command will pretty-print a register. When using the print
command, the register is optional. If left out, the most common
registers will be shown.Examples
~ # phytool print eth0/0 ieee-phy: id:0x01410eb1 ieee-phy: reg:BMCR(0x00) val:0x1140 flags: -reset -loopback +aneg-enable -power-down -isolate -aneg-restart -collision-test speed: 1000-full ieee-phy: reg:BMSR(0x01) val:0x7949 capabilities: -100-b4 +100-f +100-h +10-f +10-h -100-t2-f -100-t2-h flags: +ext-status -aneg-complete -remote-fault +aneg-capable -link -jabber +ext-register
举例说明:
phytool write eth0/0/31 0x0c44 //eth0 为网口; 0为端口,默认为0,不用关注; 31为页寄存器; 0x0c44是要写入的值
phytool read eth0/0/19 //eth0 为网口; 0为端口,默认为0,不用关注; 19为寄存器
phytool write eth0/0/19 0x5f00 //写入寄存器19, 值为0x5f00
phytool read eth0/0/19 //读取寄存器19
phytool write eth0/0/31 0x0000 //切换到寄存器0
phytool write eth0/0/0 0x9040 //复位phy芯片
需要注意的是每个寄存器都有一个页地址,如果要写入该寄存器,需要先切换到对应分页,也就是上面例子的
phytool write eth0/0/31 0x0c44 ,意思是切换到0x0c44的页
寄存器19在0x0c44页下面,然后就可以写入值了, phytool write eth0/0/19 0x5f00
上述操作的数值均可以使用16进制表示