cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Adventurer
Adventurer
8,961 Views
Registered: ‎08-23-2012

How to configure GMII to RGMII in PL?

Jump to solution

Vivado 2014.4.1

GMII2RGMII v3 in default configuration

Zynq 7020

PS Ethernet #1 routed to GMII2RGMII v3 in PL to external Marvell PHY 88E1510

Standalone-Software based on XAPP1026 v51 (RAW_TCP only)

BSP with default cofiguration of xapp1026 (incl lwip 141)

 

 

this works:

1.) autonegotiation to connected PC with configured fixed transfer-rate in all modes (10/100/1000MBits/s) and auto (=> 1 Gbits/s)

=> communication MAC to PHY via mdio works

 

2.)

autonegotiation to connected PC with configured fixed transfer-rate 10 MBits/s and TCP communication in both directions.

 

3.)

reconfigure GMII2RGMII to use external clock 25 MHz. Now BSP has to be configured to fixed rate of 100Mbits/s and PC also.

 

NOT working:

Any other speed with autoconfiguration

 

I think,

- Clock generation runs with default speed (2.5 MHz / 10 Mbits/s)

- This SW is not able to configure GMII2RGMII via mdio to switch to the right clock.

 

Questions:

1.) Do you have example code to configure GMII2RGMII in PL to switch the clock?

2.) What do I have to do to get it run on Linux?

 

 

 

 

 

 

 

0 Kudos
1 Solution

Accepted Solutions
Highlighted
Adventurer
Adventurer
15,642 Views
Registered: ‎08-23-2012

Answer 1.)

This is simple ;-)

 

Just insert this code at the beginning of main():

 

[..]

int main()
{
    struct netif *netif, server_netif;
    struct ip_addr ipaddr, netmask, gw;

    /* the mac address of the board. this should be unique per board */
    unsigned char mac_ethernet_address[] = { 0x00, 0x0a, 0x35, 0x00, 0x01, 0x02 };

// ----------------------------------------------------------------------
    XEmacPs_Config *Config;
    XEmacPs EmacPsInstance;
    XEmacPs* EmacPsInstancePtr = (XEmacPs*) &EmacPsInstance;
    int Status;
    u16 PhyReg;

    if(XLWIP_CONFIG_EMAC_NUMBER == 1)
    {
        Config = XEmacPs_LookupConfig(XPAR_XEMACPS_1_DEVICE_ID);
        xil_printf("EMAC #1: Initializing GMII2RGMII !!!\r\n");

        Status = XEmacPs_CfgInitialize(EmacPsInstancePtr, Config, XPAR_XEMACPS_1_BASEADDR);
        if (Status != XST_SUCCESS)
        {
            xil_printf("Error in initialize\r\n");
            return XST_FAILURE;
        }

// Reset:
        Status = XEmacPs_PhyWrite(EmacPsInstancePtr, 8, 0x10, 0x0001);
        sleep(1);
        Status = XEmacPs_PhyRead(EmacPsInstancePtr, 8, 0x10, &PhyReg);
        xil_printf("GMII2RGMII_Reg_0x10= 0x%04x\r\n",PhyReg);

// 10 Mbits/s:
//        Status = XEmacPs_PhyWrite(EmacPsInstancePtr, 8, 0x10, 0x0000);

// 100 Mbits/s:
//        Status = XEmacPs_PhyWrite(EmacPsInstancePtr, 8, 0x10, 0x2000);

// 1000 Mbits/s:
        Status = XEmacPs_PhyWrite(EmacPsInstancePtr, 8, 0x10, 0x0040);

        Status = XEmacPs_PhyRead(EmacPsInstancePtr, 8, 0x10, &PhyReg);
        xil_printf("GMII2RGMII_Reg_0x10= 0x%04x\r\n",PhyReg);
    }

// ----------------------------------------------------------------------
    netif = &server_netif;

    if (init_platform() < 0) {
        xil_printf("ERROR initializing platform.\r\n");
        return -1;
    }

[..]

 

 

 

Answer to 2.)

This code should be inserted into the bootloader??

 

 

View solution in original post

0 Kudos
3 Replies
Highlighted
Adventurer
Adventurer
15,643 Views
Registered: ‎08-23-2012

Answer 1.)

This is simple ;-)

 

Just insert this code at the beginning of main():

 

[..]

int main()
{
    struct netif *netif, server_netif;
    struct ip_addr ipaddr, netmask, gw;

    /* the mac address of the board. this should be unique per board */
    unsigned char mac_ethernet_address[] = { 0x00, 0x0a, 0x35, 0x00, 0x01, 0x02 };

// ----------------------------------------------------------------------
    XEmacPs_Config *Config;
    XEmacPs EmacPsInstance;
    XEmacPs* EmacPsInstancePtr = (XEmacPs*) &EmacPsInstance;
    int Status;
    u16 PhyReg;

    if(XLWIP_CONFIG_EMAC_NUMBER == 1)
    {
        Config = XEmacPs_LookupConfig(XPAR_XEMACPS_1_DEVICE_ID);
        xil_printf("EMAC #1: Initializing GMII2RGMII !!!\r\n");

        Status = XEmacPs_CfgInitialize(EmacPsInstancePtr, Config, XPAR_XEMACPS_1_BASEADDR);
        if (Status != XST_SUCCESS)
        {
            xil_printf("Error in initialize\r\n");
            return XST_FAILURE;
        }

// Reset:
        Status = XEmacPs_PhyWrite(EmacPsInstancePtr, 8, 0x10, 0x0001);
        sleep(1);
        Status = XEmacPs_PhyRead(EmacPsInstancePtr, 8, 0x10, &PhyReg);
        xil_printf("GMII2RGMII_Reg_0x10= 0x%04x\r\n",PhyReg);

// 10 Mbits/s:
//        Status = XEmacPs_PhyWrite(EmacPsInstancePtr, 8, 0x10, 0x0000);

// 100 Mbits/s:
//        Status = XEmacPs_PhyWrite(EmacPsInstancePtr, 8, 0x10, 0x2000);

// 1000 Mbits/s:
        Status = XEmacPs_PhyWrite(EmacPsInstancePtr, 8, 0x10, 0x0040);

        Status = XEmacPs_PhyRead(EmacPsInstancePtr, 8, 0x10, &PhyReg);
        xil_printf("GMII2RGMII_Reg_0x10= 0x%04x\r\n",PhyReg);
    }

// ----------------------------------------------------------------------
    netif = &server_netif;

    if (init_platform() < 0) {
        xil_printf("ERROR initializing platform.\r\n");
        return -1;
    }

[..]

 

 

 

Answer to 2.)

This code should be inserted into the bootloader??

 

 

View solution in original post

0 Kudos
Highlighted
Visitor
Visitor
8,482 Views
Registered: ‎12-12-2008

Why do you try to reset the RGMII block with bit 0 when the manual states that reset is bit 15?

0 Kudos
Highlighted
Adventurer
Adventurer
607 Views
Registered: ‎02-19-2016

Thanks so much guinness, I believe this is what I need. 

In my xparameters_ps.h file, I am missing the definition for XPAR_XEMACPS_1_DEVICE_ID.  Do you know why that might be?  I am using Vivado/SDK 2015.4  I have the EMIO/MDIO pins selected in the Vivado Block Diagram for that ethernet controller.

 

Thanks!

0 Kudos