void ethsw_phy_rw_reg(int phy_id, int reg, uint16 *data, int ext_bit, int rd)
{
    int status;

    if(rd)
    {
        status = ReadPHYReg(phy_id, reg, ext_bit);
        if (status >= 0) 
        {
            *data = (uint16)status;
        }
        else
        {
            printk("ERROR : ethsw_phy_read_reg(%d, %d, **)\n",phy_id,reg);
        }
    }
    else
    {
        status = WritePHYReg(phy_id, reg, *data, ext_bit);
        if (status < 0) 
        {
            printk("ERROR : ethsw_phy_wreg(%d, %d, 0x%04x)\n",phy_id,reg,*data);
        }
    }
}
Esempio n. 2
0
/******************************************************************************
 * Function:        BOOL MACIsLinked(void)
 *
 * PreCondition:    None
 *
 * Input:           None
 *
 * Output:          TRUE: If the PHY reports that a link partner is present
 *						  and the link has been up continuously since the last
 *						  call to MACIsLinked()
 *					FALSE: If the PHY reports no link partner, or the link went
 *						   down momentarily since the last call to MACIsLinked()
 *
 * Side Effects:    None
 *
 * Overview:        Returns the PHSTAT1.LLSTAT bit.
 *
 * Note:            None
 *****************************************************************************/
BOOL MACIsLinked(void) {
    // LLSTAT is a latching low link status bit.  Therefore, if the link
    // goes down and comes back up before a higher level stack program calls
    // MACIsLinked(), MACIsLinked() will still return FALSE.  The next
    // call to MACIsLinked() will return TRUE (unless the link goes down
    // again).
    return ReadPHYReg(PHSTAT1).PHSTAT1bits.LLSTAT;
}