package/boot/uboot-ar71xx/src/drivers/net/phy/rtl8366_mii.c
//-------------------------------------------------------------------
// MII PHY read / write functions
//-------------------------------------------------------------------
MII PHY read / write functions
MII PHY read / write functions
static int rtl8366_getPhyReg(uint32_t phyNum, uint32_t reg, uint16_t *data)
{
    uint16_t phyAddr, regData;
    if (phyNum > RTL8366S_PHY_NO_MAX) {
		printf("rtl8366s: invalid phy number!\n");
		return -1;
	}
    if (phyNum > RTL8366S_PHY_ADDR_MAX) {
		printf("rtl8366s: invalid phy register number!\n");
		return -1;
	}
	if (rtl8366_writeRegister(RTL8366S_PHY_ACCESS_CTRL_REG,
                           RTL8366S_PHY_CTRL_READ))
        return -1;
    phyAddr = 0x8000 | (1 << (phyNum + RTL8366S_PHY_NO_OFFSET))
                     | (reg & RTL8366S_PHY_REG_MASK);
    if (rtl8366_writeRegister(phyAddr, 0))
        return -1;
    if (rtl8366_readRegister(RTL8366S_PHY_ACCESS_DATA_REG, &regData))
        return -1;
    if (data)
        *data = regData;
    return 0;
}
static int rtl8366_getPhyReg ( uint32_t phyNum , uint32_t reg , uint16_t * data ) { uint16_t phyAddr , regData ; if ( phyNum > RTL8366S_PHY_NO_MAX ) { printf ( " \n " ) ; return -1 ; } if ( phyNum > RTL8366S_PHY_ADDR_MAX ) { printf ( " \n " ) ; return -1 ; } if ( rtl8366_writeRegister ( RTL8366S_PHY_ACCESS_CTRL_REG , RTL8366S_PHY_CTRL_READ ) ) return -1 ; phyAddr = 0x8000 | ( 1 << ( phyNum + RTL8366S_PHY_NO_OFFSET ) ) | ( reg & RTL8366S_PHY_REG_MASK ) ; if ( rtl8366_writeRegister ( phyAddr , 0 ) ) return -1 ; if ( rtl8366_readRegister ( RTL8366S_PHY_ACCESS_DATA_REG , & regData ) ) return -1 ; if ( data ) * data = regData ; return 0 ; }
MII PHY read / write functions
MII PHY read / write functions