This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
如题,目前采用硬件方案是6670 SGMII SERDES 接口外接88E6122 SWITCH芯片的P4/P5 SERDES 接口
该模块设计参考的是 EVMC6474 相关硬件方案,目前进行代码移植后移植无法调通相关链路。
做过一些检查,暂时还没什么头绪。求相关调试开发案例或者指导性文档,新手求教~~
#include "phy.h" #define SW_BREAKPOINT asm( " .long 0x1001E000" ); extern Uint16 phyregs[32]; Uint16 phy_getReg(int phynum, int regnum) { Uint16 value; MDIO_USERACCESS0 = 0 // Read Phy Id 1 | ( 1 << 31 ) // [31] Go | ( 0 << 30 ) // [30] Read | ( 0 << 29 ) // [29] Ack | (regnum << 21 ) // [25-21] PHY register address | (phynum << 16 ) // [20-16] PHY address | ( 0 << 0 ) // [15-0] Data ; while( MDIO_USERACCESS0 & 0x80000000 ); // Wait for Results value = MDIO_USERACCESS0; return value; } void phy_setReg(int phynum, int regnum, Uint16 data) { Uint16 value; MDIO_USERACCESS0 = 0 // Read Phy Id 1 | ( 1 << 31 ) // [31] Go | ( 1 << 30 ) // [30] Write | ( 0 << 29 ) // [29] Ack | (regnum << 21 ) // [25-21] PHY register address | (phynum << 16 ) // [20-16] PHY address | ( data << 0 ) // [15-0] Data ; while( MDIO_USERACCESS0 & 0x80000000 ); // Wait for Results value = MDIO_USERACCESS0; } void emac_getStats(int portnum) { Int16 i; // Configure for statistics phy_setReg(0x1b, 26, 0x6660); // Capture statistics on port phy_setReg(0x1b, 29, 0xdc00 | (Uint16)portnum); for (i = 0; i < 32; i++) { while ((phy_getReg(0x1b, 29) & 0x8000) != 0); phy_setReg(0x1b, 29, 0xcc00 | (Uint16)i); while ((phy_getReg(0x1b, 29) & 0x8000) != 0); phyregs[i] = phy_getReg(0x1b, 31); } } void sgmii_init() { //SGMII register initialization SGMII_SOFT_RESET = 0x00000001; while (SGMII_SOFT_RESET != 0x00000000); SGMII_SOFT_RESET = 0x00000002; // write 1 to rt_soft_reset /* Wait until reset occurs */ SGMII_CONTROL = 0x20; // to set SGMII loopback mode use 0x35 SGMII_SOFT_RESET = 0x00000000; // write 1 to rt_soft_reset // SGMII_MR_ADV_ABILITY = 0x9401; // full dupex and 100Mbps bits are set SGMII_MR_ADV_ABILITY = 0x9801; // full dupex and Gig bits are set // SerDes config registers SGMII_TX_CFG = 0x00000ea3; // programming serdes to be in master mode TX swapped SGMII_RX_CFG = 0x00081023; SGMII_AUX_CFG = 0x0000000B; // PLL multiplier } void phy_wait(Uint32 delay) { volatile Uint32 i, n; delay = delay * 0x39; n = 0; for (i = 0; i < delay; i++) { n = n + 1; } } void phy_init() { /* ---------------------------------------------------------------- * * * * Init PHY / MDIO * * * * ---------------------------------------------------------------- */ MDIO_CONTROL = 0x4000001f; // Enable MII interface // Turn PPU off to make copper PHY visible at SMI address 0x01 phy_setReg(27, 4, 0x0081); // Configure Marvell 88E6122 PHY phy_setReg(0xe, 26, 0x47); // Set PHY port 6 SERDES to 0.7V swing phy_setReg(0xd, 26, 0x47); // Set PHY port 5 SERDES to 0.7V swing phy_setReg(0x0e, 0, 0x8140); // Configure PHY port 6 SERDES --> Faraday 1 at 1000mpbs, full duplex phy_setReg(0x0d, 0, 0x8140); // Configure PHY port 5 SERDES --> Faraday 2 at 1000mbps, full duplex phy_setReg(0x15, 0x1, 0x043e); // Force internal switch --> port 5 SERDES to 1000MPBS, full Duplex phy_setReg(0x16, 0x1, 0x043e); // Force internal switch --> port 6 SERDES to 1000MBPS, full Duplex // Force 1000mps at copper PHY, disable auto-negotiate // phy_setReg(1, 0, 0x8140); // 0x8140 = 1000mbps // Force 100mps at copper PHY, disable auto-negotiate phy_setReg(1, 0, 0xa100); // 0xa100 = 100mbps // Wait for link establishment phy_wait( 4000000 ); }
硬件调试要遵循以下步骤:
1. 电源和时钟是否满足datasheet的要求
2. 芯片上电时序是否满足datasheet的要求
3. SGMII SERDES速率是否正确
4. 有的switch只支持force mode,自协商不支持,你可以先配置成force mode做测试
5. 只有当link up的状态为1时,才能开始发包
6. 你可以把论坛中STK 的GE测试代码用来调试你自己的单板,里面会打印很多信息可以参考。