MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / synopGMAC_attach

Function synopGMAC_attach

bsp/loongson/ls1cdev/drivers/net/synopGMAC_Dev.c:1209–1242  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1207 */
1208
1209s32 synopGMAC_attach (synopGMACdevice * gmacdev, u32 macBase, u32 dmaBase, u32 phyBase,u8 *mac_addr)
1210{
1211 /*Make sure the Device data strucure is cleared before we proceed further*/
1212 rt_memset((void *) gmacdev,0,sizeof(synopGMACdevice));
1213 /*Populate the mac and dma base addresses*/
1214 gmacdev->MacBase = macBase;
1215 gmacdev->DmaBase = dmaBase;
1216 gmacdev->PhyBase = phyBase;
1217// rt_kprintf("gmacdev->DmaBase = 0x%x\n", gmacdev->DmaBase);
1218// rt_kprintf("dmaBase = 0x%x\n", dmaBase);
1219 {
1220 int i,j;
1221 u16 data;
1222 for (i = phyBase,j=0;j<32;i=(i+1)&0x1f,j++)
1223 {
1224 synopGMAC_read_phy_reg(gmacdev->MacBase,i,2,&data);
1225 if(data != 0 && data != 0xffff) break;
1226 synopGMAC_read_phy_reg(gmacdev->MacBase,i,3,&data);
1227 if(data != 0 && data != 0xffff) break;
1228 }
1229
1230 if(j==32) {
1231 rt_kprintf("phy_detect: can't find PHY!\n");
1232 }
1233 gmacdev->PhyBase = i;
1234 }
1235
1236// synopGMAC_get_mac_addr(gmacdev, GmacAddr0High, GmacAddr0Low, mac_addr);
1237
1238 /* Program/flash in the station/IP's Mac address */
1239 synopGMAC_set_mac_addr(gmacdev,GmacAddr0High,GmacAddr0Low, mac_addr);
1240
1241 return 0;
1242}
1243
1244
1245

Callers 2

eth_initFunction · 0.70
rt_hw_eth_initFunction · 0.70

Calls 4

rt_memsetFunction · 0.85
rt_kprintfFunction · 0.85
synopGMAC_read_phy_regFunction · 0.70
synopGMAC_set_mac_addrFunction · 0.70

Tested by

no test coverage detected