* Process interrupts from the PHY. * * should be called from the Stellaris Ethernet Interrupt Handler. This * function will read packets from the Stellaris Ethernet fifo and place them * into a pbuf queue. If the transmitter is idle and there is at least one packet * on the transmit queue, it will place it in the transmit fifo and start the * transmitter. * */
| 979 | * |
| 980 | */ |
| 981 | void |
| 982 | tivaif_process_phy_interrupt(net_device_t dev) |
| 983 | { |
| 984 | uint16_t ui16Val, ui16Status; |
| 985 | #if EEE_SUPPORT |
| 986 | uint16_t ui16EEEStatus; |
| 987 | #endif |
| 988 | uint32_t ui32Config, ui32Mode, ui32RxMaxFrameSize; |
| 989 | |
| 990 | /* Read the PHY interrupt status. This clears all interrupt sources. |
| 991 | * Note that we are only enabling sources in EPHY_MISR1 so we don't |
| 992 | * read EPHY_MISR2. |
| 993 | */ |
| 994 | ui16Val = EMACPHYRead(EMAC0_BASE, PHY_PHYS_ADDR, EPHY_MISR1); |
| 995 | |
| 996 | /* Read the current PHY status. */ |
| 997 | ui16Status = EMACPHYRead(EMAC0_BASE, PHY_PHYS_ADDR, EPHY_STS); |
| 998 | |
| 999 | /* If EEE mode support is requested then read the value of the Link |
| 1000 | * partners status |
| 1001 | */ |
| 1002 | #if EEE_SUPPORT |
| 1003 | ui16EEEStatus = EMACPHYMMDRead(EMAC0_BASE, PHY_PHYS_ADDR, 0x703D); |
| 1004 | #endif |
| 1005 | |
| 1006 | /* Has the link status changed? */ |
| 1007 | if(ui16Val & EPHY_MISR1_LINKSTAT) |
| 1008 | { |
| 1009 | /* Is link up or down now? */ |
| 1010 | if(ui16Status & EPHY_STS_LINK) |
| 1011 | { |
| 1012 | /* Tell lwIP the link is up. */ |
| 1013 | #if NO_SYS |
| 1014 | netif_set_link_up(psNetif); |
| 1015 | #else |
| 1016 | //tcpip_callback((tcpip_callback_fn)netif_set_link_up, psNetif); |
| 1017 | eth_device_linkchange(&(dev->parent), RT_TRUE); |
| 1018 | #endif |
| 1019 | |
| 1020 | /* if the link has been advertised as EEE capable then configure |
| 1021 | * the MAC register for LPI timers and manually set the PHY link |
| 1022 | * status bit |
| 1023 | */ |
| 1024 | #if EEE_SUPPORT |
| 1025 | if(ui16EEEStatus & 0x2) |
| 1026 | { |
| 1027 | EMACLPIConfig(EMAC0_BASE, true, 1000, 36); |
| 1028 | EMACLPILinkSet(EMAC0_BASE); |
| 1029 | g_bEEELinkActive = true; |
| 1030 | } |
| 1031 | #endif |
| 1032 | |
| 1033 | /* In this case we drop through since we may need to reconfigure |
| 1034 | * the MAC depending upon the speed and half/fui32l-duplex settings. |
| 1035 | */ |
| 1036 | } |
| 1037 | else |
| 1038 | { |
no test coverage detected