chipphyrd(phyaddr, reg)
Read something from the phy
- if corerev is 0x80000000
- set phycontrol_addr to address of gmac common reg phycontrol
- set phyaccess_addr to address of gmac common reg phyaccess
- else
- set phycontrol_addr to address of gmac core reg phycontrol
- set phyaccess_addr to address of gmac core reg phyaccess
- write value from address phycontrol_addr into tmp
- binary and tmp with negation of 0x1f
- binary or tmp with phyaddr
- write tmp into reg at address phycontrol_addr
- write PA_START to tmp
- binary or tmp with phyaddr shifted by PA_ADDR_SHIFT bytes
- binary or tmp with reg shifted by PA_REG_SHIFT bytes
- write tmp into reg at address phyaccess_addr
- Spinwait until reg at address phyaccess_addr has bit PA_START unset, at most 1000 usecs, with a delay of 10 usecs
- write value of reg at address phyaccess_addr into tmp
- if bit PA_START is set in tmp
- return 0xffff, because of an error
- binary or tmp with PA_DATA_MASK and return it