Browse Source

Gmac: use gmac mac register to check link status.

Change-Id: I63be374fba78ee3673b32f4021ea64417fdb0d2f
Signed-off-by: QiaoChong <qiaochong@loongson.cn>
master
QiaoChong 6 years ago
parent
commit
49256565e8
  1. 40
      sys/dev/gmac/synopGMAC_Dev.c
  2. 10
      sys/dev/gmac/synopGMAC_network_interface.c

40
sys/dev/gmac/synopGMAC_Dev.c

@ -1145,6 +1145,7 @@ s32 synopGMAC_check_phy_init (synopGMACdevice * gmacdev)
{
//u32 addr;
u16 data;
#if 0
s32 status = -ESYNOPGMACNOERR;
s32 loop_count;
@ -1226,6 +1227,45 @@ s32 synopGMAC_check_phy_init (synopGMACdevice * gmacdev)
TR("Link is with 10M Speed \n");
printf("leave check phy init !!!!!!\n");
#else
data = synopGMACReadReg(gmacdev->MacBase,0xd8);
gmacdev->LinkState0 = data;
if((data & 8) == 0){
if(gmacdev->LinkState)
TR("No Link: %08x\n",data);
gmacdev->LinkState = 0;
gmacdev->DuplexMode = 0;
gmacdev->Speed = 0;
gmacdev->LoopBackMode = 0;
}
else{
//TR("Link UP: %08x\n",data);
if(gmacdev->LinkState!=data)
{
gmacdev->DuplexMode = (data & 1) ? FULLDUPLEX: HALFDUPLEX ;
TR("Link is up in %s mode\n",(gmacdev->DuplexMode == FULLDUPLEX) ? "FULL DUPLEX": "HALF DUPLEX");
/*if not set to Master configuration in case of Half duplex mode set it manually as Master*/
switch((data>>1)&3)
{
case 2:
gmacdev->Speed = SPEED1000;
TR("Link is with 1000M Speed \n");
break;
case 1:
gmacdev->Speed = SPEED100;
TR("Link is with 100M Speed \n");
break;
default:
gmacdev->Speed = SPEED10;
TR("Link is with 10M Speed \n");
break;
}
}
}
#endif
return -ESYNOPGMACNOERR;
}

10
sys/dev/gmac/synopGMAC_network_interface.c

@ -1150,7 +1150,7 @@ int synopGMAC_intr_handler(struct synopGMACNetworkAdapter * tp)
ifp = &(adapter->PInetdev->arpcom.ac_if);
if(gmacdev->LinkState == LINKUP)
if(gmacdev->LinkState)
ifp->if_flags = ifp->if_flags | IFF_RUNNING;
@ -1189,6 +1189,7 @@ int synopGMAC_intr_handler(struct synopGMACNetworkAdapter * tp)
if(dma_status_reg & GmacLineIntfIntr){
u16 data;
#if 0
status = synopGMAC_read_phy_reg(gmacdev->MacBase,gmacdev->PhyBase,PHY_SPECIFIC_STATUS_REG, &data);
//status = synopGMAC_read_phy_reg(gmacdev->MacBase,1,PHY_SPECIFIC_STATUS_REG, &data);
@ -1210,6 +1211,11 @@ int synopGMAC_intr_handler(struct synopGMACNetworkAdapter * tp)
}
}
#else
synopGMAC_check_phy_init(gmacdev);
if(gmacdev->LinkState != gmacdev->LinkState0)
synopGMAC_mac_init(gmacdev);
#endif
}
/*Now lets handle the DMA interrupts*/
interrupt = synopGMAC_get_interrupt_type(gmacdev);
@ -1743,7 +1749,7 @@ s32 synopGMAC_linux_xmit_frames(struct ifnet* ifp)
printf("xmit: TxBusy = %d\tTxNext = %d\n",gmacdev->TxBusy,gmacdev->TxNext);
#endif
//we use the function getmbuf() alloc mem, free it by m_freem()
if(((gmacdev->LinkState) & Mii_phy_status_link_up) != Mii_phy_status_link_up){
if(!gmacdev->LinkState){
while(ifp->if_snd.ifq_head != NULL){
IF_DEQUEUE(&ifp->if_snd, skb);
m_freem(skb);

Loading…
Cancel
Save