All pastes #809788 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-12-09 07:07 UTC
rendered paste body
/* 70*3 = 210 ms  
 * I hope this is enougth
 */
#define MAX_PHY 140 
void write_phy(struct net_device *dev, u8 adr, u8 data)
{
        u32 phy;
        int i;

        phy = 0xff0000;
        phy |= adr;
        phy |= 0x80; /* this should enable writing */
        phy |= (data<<8);

        //PHY_ADR, PHY_R and PHY_W  are contig and treated as one dword
        write_nic_dword(dev,PHY_ADR, phy);

        phy= 0xffff00;
        phy |= adr;

        write_nic_dword(dev,PHY_ADR, phy);
        for(i=0;i<MAX_PHY;i++){
                phy=read_nic_dword(dev,PHY_ADR);
                phy= phy & 0xff0000;
                phy= phy >> 16;
                if(phy == data){ //SUCCESS!
                        force_pci_posting(dev);
                        mdelay(3); //random value
#ifdef DEBUG_BB
                        DMESG("Phy wr %x,%x",adr,data);
#endif
                        return;
                }else{
                        force_pci_posting(dev);
                        mdelay(3); //random value
                }
        }
        DMESGW ("Phy writing %x %x failed!", adr,data);
}