no-OS
|
Driver for the Xilinx High-speed transceiver dynamic reconfiguration. More...
#include <stdlib.h>
#include <stdio.h>
#include <inttypes.h>
#include "no_os_util.h"
#include "no_os_error.h"
#include "axi_adxcvr.h"
#include "xilinx_transceiver.h"
#include "no_os_print_log.h"
Macros | |
#define | OUT_DIV_ADDR 0x88 |
#define | OUT_DIV_TX_OFFSET 0x4 |
#define | OUT_DIV_RX_OFFSET 0x0 |
#define | RXCDR_CFG0_ADDR 0xa8 |
#define | RXCDR_CFG0_MASK 0xffff |
#define | RXCDR_CFG1_ADDR 0xa9 |
#define | RXCDR_CFG1_MASK 0xffff |
#define | RXCDR_CFG2_ADDR 0xaa |
#define | RXCDR_CFG2_MASK 0xffff |
#define | RXCDR_CFG3_ADDR 0xab |
#define | RXCDR_CFG3_MASK 0xffff |
#define | RXCDR_CFG4_ADDR 0xac |
#define | RXCDR_CFG4_MASK 0x00ff |
#define | RX_DFE_LPM_CFG_ADDR 0x29 |
#define | RX_DFE_LPM_CFG_MASK 0xffff |
#define | QPLL_CFG0_ADDR 0x32 |
#define | QPLL_CFG0_LOWBAND_MASK 0x0040 |
#define | QPLL_CFG1_ADDR 0x33 |
#define | QPLL_REFCLK_DIV_M_MASK 0xf800 |
#define | QPLL_REFCLK_DIV_M_OFFSET 11 |
#define | QPLL_REFCLK_DIV_M(x) ((x) << 11) |
#define | QPLL_FBDIV_N_ADDR 0x36 |
#define | QPLL_FBDIV_N_MASK 0x03ff |
#define | QPLL_FBDIV_RATIO_ADDR 0x37 |
#define | QPLL_FBDIV_RATIO_MASK 0x0040 |
#define | CPLL_CFG0_ADDR 0x5c |
#define | CPLL_CFG0_MASK 0xff00 |
#define | CPLL_CFG1_ADDR 0x5d |
#define | CPLL_CFG1_MASK 0xffff |
#define | CPLL_REFCLK_DIV_M_ADDR 0x5e |
#define | CPLL_REFCLK_DIV_M_MASK 0x1f00 |
#define | CPLL_FB_DIV_45_N1_MASK 0x0080 |
#define | CPLL_FBDIV_N2_MASK 0x007f |
#define | RX_CLK25_DIV 0x11 |
#define | RX_CLK25_DIV_OFFSET 6 |
#define | RX_CLK25_DIV_MASK 0x07c0 |
#define | TX_CLK25_DIV 0x6a |
#define | TX_CLK25_DIV_MASK 0x1f |
#define | GTH34_SYSCLK_QPLL1 2 |
#define | GTX_RX_PRBS_ERR_CNT 0x15c /* 16-bit */ |
#define | GTH3_RX_PRBS_ERR_CNT 0x15E /* 32-bit */ |
#define | GTH4_RX_PRBS_ERR_CNT 0x25E /* 32-bit also applied for GTY */ |
#define | GTH34_QPLL_FBDIV(xcvr, x) (0x14 + xilinx_xcvr_qpll_sel((xcvr), (x)) * 0x80) |
#define | GTH34_QPLL_REFCLK_DIV(xcvr, x) (0x18 + xilinx_xcvr_qpll_sel((xcvr), (x)) * 0x80) |
#define | GTY4_QPLL_CLKOUT_RATE(xcvr, x) (0x0E + xilinx_xcvr_qpll_sel((xcvr), (x)) * 0x80) |
Functions | |
int | xilinx_xcvr_drp_update (struct xilinx_xcvr *xcvr, uint32_t drp_port, uint32_t reg, uint32_t mask, uint32_t val) |
int | xilinx_xcvr_configure_cdr (struct xilinx_xcvr *xcvr, uint32_t drp_port, uint32_t lane_rate, uint32_t out_div, bool lpm_enable) |
int | xilinx_xcvr_configure_lpm_dfe_mode (struct xilinx_xcvr *xcvr, uint32_t drp_port, bool lpm) |
int | xilinx_xcvr_calc_cpll_config (struct xilinx_xcvr *xcvr, uint32_t refclk_khz, uint32_t lane_rate_khz, struct xilinx_xcvr_cpll_config *conf, uint32_t *out_div) |
int | xilinx_xcvr_calc_qpll_config (struct xilinx_xcvr *xcvr, uint32_t sys_clk_sel, uint32_t refclk_khz, uint32_t lane_rate_khz, struct xilinx_xcvr_qpll_config *conf, uint32_t *out_div) |
int | xilinx_xcvr_gtx2_cpll_read_config (struct xilinx_xcvr *xcvr, uint32_t drp_port, struct xilinx_xcvr_cpll_config *conf) |
int | xilinx_xcvr_cpll_read_config (struct xilinx_xcvr *xcvr, uint32_t drp_port, struct xilinx_xcvr_cpll_config *conf) |
int | xilinx_xcvr_cpll_write_config (struct xilinx_xcvr *xcvr, uint32_t drp_port, const struct xilinx_xcvr_cpll_config *conf) |
int | xilinx_xcvr_cpll_calc_lane_rate (struct xilinx_xcvr *xcvr, uint32_t refclk_hz, const struct xilinx_xcvr_cpll_config *conf, uint32_t out_div) |
int | xilinx_xcvr_qpll_read_config (struct xilinx_xcvr *xcvr, uint32_t drp_port, uint32_t sys_clk_sel, struct xilinx_xcvr_qpll_config *conf) |
int | xilinx_xcvr_qpll_write_config (struct xilinx_xcvr *xcvr, uint32_t sys_clk_sel, uint32_t drp_port, const struct xilinx_xcvr_qpll_config *conf) |
int | xilinx_xcvr_qpll_calc_lane_rate (struct xilinx_xcvr *xcvr, uint32_t refclk_hz, const struct xilinx_xcvr_qpll_config *conf, uint32_t out_div) |
int | xilinx_xcvr_read_out_div (struct xilinx_xcvr *xcvr, uint32_t drp_port, uint32_t *rx_out_div, uint32_t *tx_out_div) |
int | xilinx_xcvr_write_out_div (struct xilinx_xcvr *xcvr, uint32_t drp_port, int32_t rx_out_div, int32_t tx_out_div) |
int | xilinx_xcvr_write_prog_div (struct xilinx_xcvr *xcvr, uint32_t drp_port, int32_t rx_prog_div, int32_t tx_prog_div) |
int | xilinx_xcvr_write_prog_div_rate (struct xilinx_xcvr *xcvr, uint32_t drp_port, int32_t rx_rate, int32_t tx_rate) |
int | xilinx_xcvr_write_async_gearbox_en (struct xilinx_xcvr *xcvr, uint32_t drp_port, bool en) |
int | xilinx_xcvr_write_rx_clk25_div (struct xilinx_xcvr *xcvr, uint32_t drp_port, uint32_t div) |
int | xilinx_xcvr_write_tx_clk25_div (struct xilinx_xcvr *xcvr, uint32_t drp_port, uint32_t div) |
int | xilinx_xcvr_prbsel_enc_get (struct xilinx_xcvr *xcvr, uint32_t prbs, bool reverse_lu) |
int | xilinx_xcvr_prbs_err_cnt_get (struct xilinx_xcvr *xcvr, uint32_t drp_port, uint32_t *cnt) |
Driver for the Xilinx High-speed transceiver dynamic reconfiguration.
Copyright 2018(c) Analog Devices, Inc.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define CPLL_CFG0_ADDR 0x5c |
#define CPLL_CFG0_MASK 0xff00 |
#define CPLL_CFG1_ADDR 0x5d |
#define CPLL_CFG1_MASK 0xffff |
#define CPLL_FB_DIV_45_N1_MASK 0x0080 |
#define CPLL_FBDIV_N2_MASK 0x007f |
#define CPLL_REFCLK_DIV_M_ADDR 0x5e |
#define CPLL_REFCLK_DIV_M_MASK 0x1f00 |
#define GTH34_QPLL_FBDIV | ( | xcvr, | |
x | |||
) | (0x14 + xilinx_xcvr_qpll_sel((xcvr), (x)) * 0x80) |
#define GTH34_QPLL_REFCLK_DIV | ( | xcvr, | |
x | |||
) | (0x18 + xilinx_xcvr_qpll_sel((xcvr), (x)) * 0x80) |
#define GTH34_SYSCLK_QPLL1 2 |
#define GTH3_RX_PRBS_ERR_CNT 0x15E /* 32-bit */ |
#define GTH4_RX_PRBS_ERR_CNT 0x25E /* 32-bit also applied for GTY */ |
#define GTX_RX_PRBS_ERR_CNT 0x15c /* 16-bit */ |
#define GTY4_QPLL_CLKOUT_RATE | ( | xcvr, | |
x | |||
) | (0x0E + xilinx_xcvr_qpll_sel((xcvr), (x)) * 0x80) |
#define OUT_DIV_ADDR 0x88 |
#define OUT_DIV_RX_OFFSET 0x0 |
#define OUT_DIV_TX_OFFSET 0x4 |
#define QPLL_CFG0_ADDR 0x32 |
#define QPLL_CFG0_LOWBAND_MASK 0x0040 |
#define QPLL_CFG1_ADDR 0x33 |
#define QPLL_FBDIV_N_ADDR 0x36 |
#define QPLL_FBDIV_N_MASK 0x03ff |
#define QPLL_FBDIV_RATIO_ADDR 0x37 |
#define QPLL_FBDIV_RATIO_MASK 0x0040 |
#define QPLL_REFCLK_DIV_M | ( | x | ) | ((x) << 11) |
#define QPLL_REFCLK_DIV_M_MASK 0xf800 |
#define QPLL_REFCLK_DIV_M_OFFSET 11 |
#define RX_CLK25_DIV 0x11 |
#define RX_CLK25_DIV_MASK 0x07c0 |
#define RX_CLK25_DIV_OFFSET 6 |
#define RX_DFE_LPM_CFG_ADDR 0x29 |
#define RX_DFE_LPM_CFG_MASK 0xffff |
#define RXCDR_CFG0_ADDR 0xa8 |
#define RXCDR_CFG0_MASK 0xffff |
#define RXCDR_CFG1_ADDR 0xa9 |
#define RXCDR_CFG1_MASK 0xffff |
#define RXCDR_CFG2_ADDR 0xaa |
#define RXCDR_CFG2_MASK 0xffff |
#define RXCDR_CFG3_ADDR 0xab |
#define RXCDR_CFG3_MASK 0xffff |
#define RXCDR_CFG4_ADDR 0xac |
#define RXCDR_CFG4_MASK 0x00ff |
#define TX_CLK25_DIV 0x6a |
#define TX_CLK25_DIV_MASK 0x1f |
int xilinx_xcvr_calc_cpll_config | ( | struct xilinx_xcvr * | xcvr, |
uint32_t | refclk_khz, | ||
uint32_t | lane_rate_khz, | ||
struct xilinx_xcvr_cpll_config * | conf, | ||
uint32_t * | out_div | ||
) |
Configure Channel PLL.
Ref: https://www.xilinx.com/support/documentation/user_guides/ug476_7Series_Transceivers.pdf Page: 48 Vco_Freq = (RefClk * n1 * n2) / m LineRate = (Vco_Freq * 2) / d
int xilinx_xcvr_calc_qpll_config | ( | struct xilinx_xcvr * | xcvr, |
uint32_t | sys_clk_sel, | ||
uint32_t | refclk_khz, | ||
uint32_t | lane_rate_khz, | ||
struct xilinx_xcvr_qpll_config * | conf, | ||
uint32_t * | out_div | ||
) |
Calculate Quad PLL configuration parameters.
Ref: https://www.xilinx.com/support/documentation/user_guides/ug476_7Series_Transceivers.pdf Page: 55 Vco_Freq = (refclk_khz * n) / m LineRate = Vco_Freq / d
Make sure to not confuse Vco_Freq with fPLLClkout. fPLLClkout = (refclk_khz * n) / (m * 2), so technically Vco_Freq = 2 * fPLLClkout And the 2 is reduced in both equations.
Ref: https://www.xilinx.com/support/documentation/user_guides/ug578-ultrascale-gty-transceivers.pdf Page: 49 For GTY4: LineRate = (2 * Vco_Freq) / d Try Full-rate
int xilinx_xcvr_configure_cdr | ( | struct xilinx_xcvr * | xcvr, |
uint32_t | drp_port, | ||
uint32_t | lane_rate, | ||
uint32_t | out_div, | ||
bool | lpm_enable | ||
) |
Configure the Clock Data Recovery circuit.
int xilinx_xcvr_configure_lpm_dfe_mode | ( | struct xilinx_xcvr * | xcvr, |
uint32_t | drp_port, | ||
bool | lpm | ||
) |
Selection of Low-Power mode (LPM) or Decision Feedback Equalization (DFE).
int xilinx_xcvr_cpll_calc_lane_rate | ( | struct xilinx_xcvr * | xcvr, |
uint32_t | refclk_hz, | ||
const struct xilinx_xcvr_cpll_config * | conf, | ||
uint32_t | out_div | ||
) |
Calculate Channel PLL lane rate.
int xilinx_xcvr_cpll_read_config | ( | struct xilinx_xcvr * | xcvr, |
uint32_t | drp_port, | ||
struct xilinx_xcvr_cpll_config * | conf | ||
) |
Read Channel PLL configuration.
int xilinx_xcvr_cpll_write_config | ( | struct xilinx_xcvr * | xcvr, |
uint32_t | drp_port, | ||
const struct xilinx_xcvr_cpll_config * | conf | ||
) |
Write Channel PLL configuration.
int xilinx_xcvr_drp_update | ( | struct xilinx_xcvr * | xcvr, |
uint32_t | drp_port, | ||
uint32_t | reg, | ||
uint32_t | mask, | ||
uint32_t | val | ||
) |
int xilinx_xcvr_gtx2_cpll_read_config | ( | struct xilinx_xcvr * | xcvr, |
uint32_t | drp_port, | ||
struct xilinx_xcvr_cpll_config * | conf | ||
) |
int xilinx_xcvr_prbs_err_cnt_get | ( | struct xilinx_xcvr * | xcvr, |
uint32_t | drp_port, | ||
uint32_t * | cnt | ||
) |
Get PRBS error counter value.
int xilinx_xcvr_prbsel_enc_get | ( | struct xilinx_xcvr * | xcvr, |
uint32_t | prbs, | ||
bool | reverse_lu | ||
) |
Get PRBS generator test pattern control setting.
int xilinx_xcvr_qpll_calc_lane_rate | ( | struct xilinx_xcvr * | xcvr, |
uint32_t | refclk_hz, | ||
const struct xilinx_xcvr_qpll_config * | conf, | ||
uint32_t | out_div | ||
) |
Calculate Quad PLL lane rate.
int xilinx_xcvr_qpll_read_config | ( | struct xilinx_xcvr * | xcvr, |
uint32_t | drp_port, | ||
uint32_t | sys_clk_sel, | ||
struct xilinx_xcvr_qpll_config * | conf | ||
) |
Read Quad PLL configuration.
int xilinx_xcvr_qpll_write_config | ( | struct xilinx_xcvr * | xcvr, |
uint32_t | sys_clk_sel, | ||
uint32_t | drp_port, | ||
const struct xilinx_xcvr_qpll_config * | conf | ||
) |
Write Quad PLL configuration.
int xilinx_xcvr_read_out_div | ( | struct xilinx_xcvr * | xcvr, |
uint32_t | drp_port, | ||
uint32_t * | rx_out_div, | ||
uint32_t * | tx_out_div | ||
) |
Read TX/RXOUT_DIV value.
int xilinx_xcvr_write_async_gearbox_en | ( | struct xilinx_xcvr * | xcvr, |
uint32_t | drp_port, | ||
bool | en | ||
) |
TX Asynchronous Gearbox.
int xilinx_xcvr_write_out_div | ( | struct xilinx_xcvr * | xcvr, |
uint32_t | drp_port, | ||
int32_t | rx_out_div, | ||
int32_t | tx_out_div | ||
) |
Write TX/RXOUT_DIV value.
int xilinx_xcvr_write_prog_div | ( | struct xilinx_xcvr * | xcvr, |
uint32_t | drp_port, | ||
int32_t | rx_prog_div, | ||
int32_t | tx_prog_div | ||
) |
Write RX/TX programmable divider ratio.
int xilinx_xcvr_write_prog_div_rate | ( | struct xilinx_xcvr * | xcvr, |
uint32_t | drp_port, | ||
int32_t | rx_rate, | ||
int32_t | tx_rate | ||
) |
Set programmable divider ratio (RX|TX_PROGDIV_RATE), pre-divider value.
int xilinx_xcvr_write_rx_clk25_div | ( | struct xilinx_xcvr * | xcvr, |
uint32_t | drp_port, | ||
uint32_t | div | ||
) |
Write RX_CLK25_DIV value.
int xilinx_xcvr_write_tx_clk25_div | ( | struct xilinx_xcvr * | xcvr, |
uint32_t | drp_port, | ||
uint32_t | div | ||
) |
Write RX_CLK25_DIV value.