UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Explorer
Explorer
1,445 Views
Registered: ‎01-13-2016

zc706 setting up SI5324C-C-GM

I'm running the zc706 board with linux, and I need to set the MGT reference clock up so I can use the SFP on the board.

 

Apparently I need to program the SI5324 chip because it doesn't work on its own from startup, but I don't quite know how the i2c system works. Do I just need to figure out which i2c entry under dev is and write what I want to send to the SI chip to that file?

Tags (2)
0 Kudos
6 Replies
Scholar hbucher
Scholar
1,429 Views
Registered: ‎03-22-2016

Re: zc706 setting up SI5324C-C-GM

@lm_atl there is an example on GitHub

https://github.com/RTSYork/zc706_10g_example

vitorian.com --- We do this for fun. Always give kudos. Accept as solution if your question was answered.
I will not answer to personal messages - use the forums instead.
Explorer
Explorer
1,376 Views
Registered: ‎02-22-2012

Re: zc706 setting up SI5324C-C-GM

SFP reference clock can be picked also from ZC706 on board Si570, routed via IBUFDS/OBUFDS FPGA and J36/J31 - J67/J68. It is not ideal (jitter introduction on SFP reference clock). I used it in this test.

0 Kudos
Scholar hbucher
Scholar
1,369 Views
Registered: ‎03-22-2016

Re: zc706 setting up SI5324C-C-GM

@primoz_beltram If I am not mistaken, that is exactly what XAPP1305 does on ZCU102.

 

vitorian.com --- We do this for fun. Always give kudos. Accept as solution if your question was answered.
I will not answer to personal messages - use the forums instead.
0 Kudos
Explorer
Explorer
1,361 Views
Registered: ‎02-22-2012

Re: zc706 setting up SI5324C-C-GM

I got the hint from @dtheodor forum post here and with UG954 I manged to make it work. It was good enough for my tests for links with speed up to 5Gbps.

0 Kudos
Scholar hbucher
Scholar
1,354 Views
Registered: ‎03-22-2016

Re: zc706 setting up SI5324C-C-GM

@primoz_beltram @lm_atl Just do this

 

#include <stdio.h>
#include <stdint.h>
#include "platform.h"
#include "xiicps.h"

#define I2C_DEV 0
#define I2C_CLK 100000

#define I2C_BUS_SWITCH 0x74
#define I2C_SI5324 0x68
#define I2C_BUS_SWITCH_DIR_SI5324 (1 << 4)

int i2c_write(XIicPs* i2c_dev, uint8_t dev_id, uint8_t* buffer, int size);
int i2c_write_await(XIicPs* i2c_dev, uint8_t dev_id, uint8_t* buffer, int size);
int i2c_recv(XIicPs* i2c_dev, uint8_t dev_id, uint8_t* buffer, int buf_max);
int i2c_write_single_reg(XIicPs* i2c_dev, uint8_t dev_id, uint8_t reg_address, uint8_t reg_value);
int i2c_init_clk();

int i2c_write(XIicPs* i2c_dev, uint8_t dev_id, uint8_t* buffer, int size)
{
while(XIicPs_BusIsBusy(i2c_dev));
return XIicPs_MasterSendPolled(i2c_dev, buffer, size, dev_id);
}

int i2c_write_await(XIicPs* i2c_dev, uint8_t dev_id, uint8_t* buffer, int size)
{
int rv = 0;
rv = i2c_write(i2c_dev, dev_id, buffer, size);
if(rv != XST_SUCCESS)
return rv;
while(XIicPs_BusIsBusy(i2c_dev));
return XST_SUCCESS;
}

int i2c_recv(XIicPs* i2c_dev, uint8_t dev_id, uint8_t* buffer, int buf_max)
{
while(XIicPs_BusIsBusy(i2c_dev));
return XIicPs_MasterRecvPolled(i2c_dev, buffer, buf_max, dev_id);
}

int i2c_write_single_reg(XIicPs* i2c_dev, uint8_t dev_id, uint8_t reg_address, uint8_t reg_value)
{
uint8_t buf[2] = {reg_address, reg_value};

return i2c_write_await(i2c_dev, dev_id, buf, 2);
}

int i2c_init_clk()
{
// We only need the I2C device for the clock setup, so just move it all here instead
XIicPs i2c_dev;
int rv = 0;

XIicPs_Config* cfg = XIicPs_LookupConfig(I2C_DEV);
if(cfg == NULL)
{
printf("Could not lookup config for device %d\r\n", I2C_DEV);
return -1;
}

rv = XIicPs_CfgInitialize(&i2c_dev, cfg, cfg->BaseAddress);
if(rv != XST_SUCCESS)
{
printf("Could not init I2C device\r\n");
return -1;
}

rv = XIicPs_SelfTest(&i2c_dev);
if(rv != XST_SUCCESS)
{
printf("I2C Self-test failed\r\n");
return -1;
}

XIicPs_SetSClk(&i2c_dev, I2C_CLK);

// Ok, try and read from the bus switch
uint8_t val = 0;
rv = i2c_recv(&i2c_dev, I2C_BUS_SWITCH, &val, 1);
if(rv != XST_SUCCESS)
{
printf("i2c_recv failed with code %d\r\n", rv);
return -1;
}

val = I2C_BUS_SWITCH_DIR_SI5324;
rv = i2c_write_await(&i2c_dev, I2C_BUS_SWITCH, &val, 1);
if(rv != XST_SUCCESS)
{
printf("i2c_send failed with code %d\r\n", rv);
return -1;
}

rv = i2c_recv(&i2c_dev, I2C_BUS_SWITCH, &val, 1);
if(rv != XST_SUCCESS)
{
printf("i2c_read failed with code %d\r\n", rv);
return -1;
}

i2c_write_single_reg(&i2c_dev, I2C_SI5324, 0x0, 0x54); // FREE_RUN
i2c_write_single_reg(&i2c_dev, I2C_SI5324, 0x1, 0xE4); // CK_PRIOR2,CK_PRIOR1
i2c_write_single_reg(&i2c_dev, I2C_SI5324, 0x2, 0x12); // BWSEL was 32
i2c_write_single_reg(&i2c_dev, I2C_SI5324, 0x3, 0x15); // CKSEL_REG
i2c_write_single_reg(&i2c_dev, I2C_SI5324, 0x4, 0x92); // AUTOSEL_REG
i2c_write_single_reg(&i2c_dev, I2C_SI5324, 0xa, 0x08); // DSBL2_REG
i2c_write_single_reg(&i2c_dev, I2C_SI5324, 0xb, 0x40); // PD_CK2
i2c_write_single_reg(&i2c_dev, I2C_SI5324, 0x19, 0xA0); // N1_HS
i2c_write_single_reg(&i2c_dev, I2C_SI5324, 0x1f, 0x00); // NC1_LS[19:16]
i2c_write_single_reg(&i2c_dev, I2C_SI5324, 0x20, 0x00); // NC1_LS[15:8]
i2c_write_single_reg(&i2c_dev, I2C_SI5324, 0x21, 0x03); // NC1_LS[7:0]
i2c_write_single_reg(&i2c_dev, I2C_SI5324, 0x28, 0xC2); // N2_HS, N2_LS[19:16]
i2c_write_single_reg(&i2c_dev, I2C_SI5324, 0x29, 0x49); // N2_LS[15:8]
i2c_write_single_reg(&i2c_dev, I2C_SI5324, 0x2a, 0xEF); // N2_LS[7:0]
i2c_write_single_reg(&i2c_dev, I2C_SI5324, 0x2b, 0x00); // N31[18:16]
i2c_write_single_reg(&i2c_dev, I2C_SI5324, 0x2c, 0x77); // N31[15:8]
i2c_write_single_reg(&i2c_dev, I2C_SI5324, 0x2d, 0x0B); // N31[7:0]
i2c_write_single_reg(&i2c_dev, I2C_SI5324, 0x2e, 0x00); // N32[18:16]
i2c_write_single_reg(&i2c_dev, I2C_SI5324, 0x2f, 0x77); // N32[15:8]
i2c_write_single_reg(&i2c_dev, I2C_SI5324, 0x30, 0x0B); // N32[7:0]
i2c_write_single_reg(&i2c_dev, I2C_SI5324, 0x88, 0x40); // RST_REG,ICAL

return XST_SUCCESS;
}

int main()
{
int bufId = 0;
init_platform();

printf("Hello World\n\r");
if(i2c_init_clk() != XST_SUCCESS)
return -1;

while(1);

cleanup_platform();
return 0;
}
vitorian.com --- We do this for fun. Always give kudos. Accept as solution if your question was answered.
I will not answer to personal messages - use the forums instead.
0 Kudos
Adventurer
Adventurer
1,332 Views
Registered: ‎06-03-2008

Re: zc706 setting up SI5324C-C-GM

@primoz_beltram I am glad that my post helped :)
0 Kudos