From 1e17e4621137eae36b0f653e6686506485be219b Mon Sep 17 00:00:00 2001 From: zhangbaoqi Date: Fri, 4 Aug 2017 15:41:13 +0800 Subject: [PATCH] Fixup the gmac1 phy address for it can be used. Change-Id: I10c44dedd4e75c47001d30d83a7c778013b90344 --- sys/dev/gmac/synopGMAC_Dev.c | 18 ++++++++++++++++++ sys/dev/gmac/synopGMAC_network_interface.c | 2 -- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/sys/dev/gmac/synopGMAC_Dev.c b/sys/dev/gmac/synopGMAC_Dev.c index 58d7ff04..961200c5 100755 --- a/sys/dev/gmac/synopGMAC_Dev.c +++ b/sys/dev/gmac/synopGMAC_Dev.c @@ -1405,6 +1405,24 @@ s32 synopGMAC_attach (synopGMACdevice * gmacdev, u64 macBase, u64 dmaBase, u32 p gmacdev->PhyBase = phyBase; #else gmacdev->PhyBase = phyBase; + { + int i,j; + u16 data; + + for (i = phyBase,j=0;j<32;i=(i+1)&0x1f,j++) + { + synopGMAC_read_phy_reg(gmacdev->MacBase,i,2,&data); + if(data != 0 && data != 0xffff) break; + synopGMAC_read_phy_reg(gmacdev->MacBase,i,3,&data); + if(data != 0 && data != 0xffff) break; + } + + if(j==32) { + TR("phy_detect: can't find PHY!\n"); + } + + gmacdev->PhyBase = i; + } #endif /* Program/flash in the station/IP's Mac address */ diff --git a/sys/dev/gmac/synopGMAC_network_interface.c b/sys/dev/gmac/synopGMAC_network_interface.c index e16f3810..6fc6e0c7 100755 --- a/sys/dev/gmac/synopGMAC_network_interface.c +++ b/sys/dev/gmac/synopGMAC_network_interface.c @@ -525,8 +525,6 @@ s32 synopGMAC_setup_tx_desc_queue(synopGMACdevice * gmacdev,u32 no_of_desc, u32 /* first_desc is cached addr */ first_desc = (DmaDesc *)plat_alloc_memory(sizeof(DmaDesc) * no_of_desc+15); #endif - //first_desc is cache addr, dma_addr is uncache_to_phy addr mtf add - printf("===Tx first_desc:0x%x, dma_addr:0x%x\n", first_desc, dma_addr); if(first_desc == NULL){ TR("Error in Tx Descriptors memory allocation\n"); return -ESYNOPGMACNOMEM;