取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
Joseph
Visitor
Visitor
241 次查看
注册日期: ‎04-15-2021

Zynq7010不能与Microchip的PHY(KSZ8041)自协商

我使用的是Zynq7010开发板,PHY是KSZ8041连接zynq的PL端,我已经配置了zynq PL端连接KSZ8041,使用echo server代码可以通过MAC读写PHY的寄存器地址,但是不能自协商不能通过(等待超时),看了一段时间还是无法解决,希望能够有人帮忙查看下问题,感激不尽。

Joseph_0-1618565078259.png

Joseph_2-1618565195648.png

 

Joseph_1-1618565159255.png

 

static u32_t get_Microchip_phy_speed(XEmacPs *xemacpsp, u32_t phy_addr)
{
    u16_t temp;
    u16_t control;
    u16_t status;
    u16_t status_speed;
    u32_t timeout_counter = 0;

    xil_printf("Start PHY autonegotiation \r\n");


    XEmacPs_PhyRead(xemacpsp, phy_addr, 0x1E, &control);
    XEmacPs_PhyRead(xemacpsp, phy_addr, 0x1f, &control);//value is 0x8100

    XEmacPs_PhyWrite(xemacpsp,phy_addr, IEEE_PAGE_ADDRESS_REGISTER, 2);

    XEmacPs_PhyWrite(xemacpsp, phy_addr, IEEE_PAGE_ADDRESS_REGISTER, 0);

    XEmacPs_PhyRead(xemacpsp, phy_addr, IEEE_AUTONEGO_ADVERTISE_REG, &control);
    control |= IEEE_ASYMMETRIC_PAUSE_MASK;
    control |= IEEE_PAUSE_MASK;
    control |= ADVERTISE_100;
    control |= ADVERTISE_10;
    XEmacPs_PhyWrite(xemacpsp, phy_addr, IEEE_AUTONEGO_ADVERTISE_REG, control);
    XEmacPs_PhyRead(xemacpsp, phy_addr, IEEE_CONTROL_REG_OFFSET, &control);
    control |= IEEE_CTRL_AUTONEGOTIATE_ENABLE;
    control |= IEEE_STAT_AUTONEGOTIATE_RESTART;
    XEmacPs_PhyWrite(xemacpsp, phy_addr, IEEE_CONTROL_REG_OFFSET, control);

    XEmacPs_PhyRead(xemacpsp, phy_addr, IEEE_CONTROL_REG_OFFSET, &control);
    control |= IEEE_CTRL_RESET_MASK;
    XEmacPs_PhyWrite(xemacpsp, phy_addr, IEEE_CONTROL_REG_OFFSET, control);

    while (1) {
        XEmacPs_PhyRead(xemacpsp, phy_addr, IEEE_CONTROL_REG_OFFSET, &control);
        if (control & IEEE_CTRL_RESET_MASK)
            continue;
        else
            break;
    }

    XEmacPs_PhyRead(xemacpsp, phy_addr, IEEE_STATUS_REG_OFFSET, &status);

    xil_printf("Waiting for PHY to complete autonegotiation.\r\n");

    while ( !(status & IEEE_STAT_AUTONEGOTIATE_COMPLETE) ) {
        sleep(1);
        XEmacPs_PhyRead(xemacpsp, phy_addr,
                        IEEE_COPPER_SPECIFIC_STATUS_REG_2,  &temp);
        timeout_counter++;

        if (timeout_counter == 30) {
            xil_printf("Auto negotiation error \r\n");
            return XST_FAILURE;
        }
        XEmacPs_PhyRead(xemacpsp, phy_addr, IEEE_STATUS_REG_OFFSET, &status);//value alway is 0x7849
    }
    xil_printf("autonegotiation complete \r\n");

  // Read from Microchip page 0, register 0x1F (PHY Control)
  // http://ww1.microchip.com/downloads/en/DeviceDoc/00002117F.pdf
    XEmacPs_PhyRead(xemacpsp, phy_addr,0x1F,&status_speed);
    if (status_speed & 0x040)
        return 1000;
    else if(status_speed & 0x020)
        return 100;
    else if(status_speed & 0x010)
        return 10;

    return XST_SUCCESS;
}

 

相关图片和代码如上,程序一直等待自协商成功,但是直到超时都还没有成功。

0 项奖励
4 回复数
chaoz
Xilinx Employee
Xilinx Employee
174 次查看
注册日期: ‎09-14-2018

Hi @Joseph 

你们是自己写的driver?

我理解自协商是PHY之间自动完成, 对端连接的是什么?支持自协商吗?

 

----------------------------------------------------------------------------------------------
如果帖子有帮助,别忘“接受为解决方案”或“奖励”。谢谢!
Don't forget to "Accept as solution" or "Kudo" if it helps. Thanks!
----------------------------------------------------------------------------------------------

0 项奖励
Joseph
Visitor
Visitor
166 次查看
注册日期: ‎04-15-2021

你好,我这边是将zynq7010的PL端连接到了PHY(支持自协商),zynq端使用的是echo_server的demo,lwip也配置了自协商模式:

Joseph_0-1618802601796.png,上面的driver是https://www.fpgadeveloper.com/2018/05/board-bring-up-myir-myd-y7z010-dev-board.html/ 是该网站下提供的PHY芯片系列的初始化流程代码,我们也试图自己修改driver,但是依旧无法自协商。

0 项奖励
axmei
Contributor
Contributor
150 次查看
注册日期: ‎05-04-2018

看样子是硬件问题

0 项奖励
Joseph
Visitor
Visitor
145 次查看
注册日期: ‎04-15-2021

我也觉得是硬件问题,目前还没定位到问题,但是现在MAC是能够读写PHY寄存器的。

0 项奖励