no-OS
altera_adxcvr.h
Go to the documentation of this file.
1 /***************************************************************************/
39 #ifndef ALTERA_ADXCVR_H_
40 #define ALTERA_ADXCVR_H_
41 
42 /******************************************************************************/
43 /***************************** Include Files **********************************/
44 /******************************************************************************/
45 #include <stdint.h>
46 #include <stdbool.h>
47 
48 /******************************************************************************/
49 /********************** Macros and Constants Definitions **********************/
50 /******************************************************************************/
51 
52 /* XCVR Registers */
53 
54 #define XCVR_REG_ARBITRATION 0x000
55 #define XCVR_ARBITRATION_MASK 0xFF
56 #define XCVR_ARBITRATION_GET_AVMM 0x02
57 #define XCVR_ARBITRATION_RELEASE_AVMM_CALIB 0x01
58 #define XCVR_ARBITRATION_RELEASE_AVMM 0x03
59 
60 #define XCVR_REG_CALIB_ATX_PLL_EN 0x100
61 #define XCVR_CALIB_ATX_PLL_EN_MASK 0x01
62 #define XCVR_CALIB_ATX_PLL_EN 0x01
63 
64 #define XCVR_REG_CAPAB_ATX_PLL_STAT 0x280
65 #define XCVR_CAPAB_ATX_PLL_CAL_BSY_MASK 0x02
66 #define XCVR_CAPAB_ATX_PLL_CAL_DONE 0x00
67 
68 
69 #define XCVR_REG_CALIB_PMA_EN 0x100
70 #define XCVR_CALIB_TX_TERM_VOD_MASK 0x20
71 #define XCVR_CALIB_TX_TERM_VOD_EN 0x20
72 #define XCVR_CALIB_CMU_CDR_PLL_EN_MASK 0x02
73 #define XCVR_CALIB_CMU_CDR_PLL_EN 0x02
74 
75 #define XCVR_REG_CAPAB_PMA 0x281
76 #define XCVR_CAPAB_RX_CAL_BUSY_EN_MASK 0x20
77 #define XCVR_CAPAB_RX_CAL_BUSY_EN 0x20
78 #define XCVR_CAPAB_RX_CAL_BUSY_DIS 0x00
79 #define XCVR_CAPAB_RX_CAL_BUSY_MASK 0x02
80 #define XCVR_CAPAB_RX_CAL_DONE 0x00
81 #define XCVR_CAPAB_TX_CAL_BUSY_EN_MASK 0x10
82 #define XCVR_CAPAB_TX_CAL_BUSY_EN 0x10
83 #define XCVR_CAPAB_TX_CAL_BUSY_DIS 0x00
84 #define XCVR_CAPAB_TX_CAL_BUSY_MASK 0x01
85 #define XCVR_CAPAB_TX_CAL_DONE 0x00
86 
87 #define XCVR_REG_RATE_SWITCH_FLAG 0x166
88 #define XCVR_RATE_SWITCH_FLAG_MASK 0x80
89 #define XCVR_RATE_SWITCH_FLAG_RATE_SWITCH 0x00
90 #define XCVR_RATE_SWITCH_FLAG_NO_RATE_SWITCH 0x80
91 
92 /******************************************************************************/
93 /*************************** Types Declarations *******************************/
94 /******************************************************************************/
95 struct adxcvr {
96  const char *name;
97  uint32_t base;
99  uint32_t lanes_per_link;
100  uint32_t adxcfg_base[4];
101  uint32_t atx_pll_base;
102  uint32_t reset_counter;
103  uint32_t lane_rate_khz;
104  uint32_t parent_rate_khz;
106 };
107 
108 struct adxcvr_init {
109  const char *name;
110  uint32_t base;
111  uint32_t adxcfg_base[4];
112  uint32_t atx_pll_base;
113  uint32_t lane_rate_khz;
114  uint32_t parent_rate_khz;
115 };
116 
117 /******************************************************************************/
118 /************************ Functions Declarations ******************************/
119 /******************************************************************************/
120 int32_t adxcvr_init(struct adxcvr **ad_xcvr,
121  const struct adxcvr_init *init);
122 int32_t adxcvr_remove(struct adxcvr *xcvr);
123 void adxcvr_post_lane_rate_change(struct adxcvr *xcvr,
124  unsigned int lane_rate_khz);
125 int32_t adxcvr_round_rate(struct adxcvr *xcvr, uint32_t rate_khz);
126 int32_t adxcvr_set_rate(struct adxcvr *xcvr,
127  uint32_t rate_khz);
128 uint32_t adxcvr_recalc_rate(struct adxcvr *xcvr);
129 
130 void adxcvr_pre_lane_rate_change(struct adxcvr *xcvr);
131 void adxcvr_post_lane_rate_change(struct adxcvr *xcvr,
132  unsigned int lane_rate);
133 
134 void atx_pll_acquire_arbitration(struct adxcvr *xcvr);
135 void atx_pll_release_arbitration(struct adxcvr *xcvr,
136  bool calibrate);
137 int32_t atx_pll_write(struct adxcvr *xcvr, uint32_t reg, uint32_t val);
138 int32_t atx_pll_read(struct adxcvr *xcvr, uint32_t reg, uint32_t *val);
139 void atx_pll_update(struct adxcvr *xcvr, uint32_t reg,
140  uint32_t mask, uint32_t val);
141 int32_t atx_pll_calibration_check(struct adxcvr *xcvr);
142 int32_t xcvr_calib_tx(struct adxcvr *xcvr);
143 
144 void adxcfg_acquire_arbitration(struct adxcvr *xcvr,
145  uint32_t lane);
146 void adxcfg_release_arbitration(struct adxcvr *xcvr,
147  uint32_t lane, bool calibrate);
148 int32_t adxcfg_write(struct adxcvr *xcvr, uint32_t lane, uint32_t reg,
149  uint32_t val);
150 int32_t adxcfg_read(struct adxcvr *xcvr, uint32_t lane,
151  uint32_t reg, uint32_t *val);
152 void adxcfg_update(struct adxcvr *xcvr, uint32_t lane,
153  uint32_t reg, uint32_t mask, uint32_t val);
154 int32_t adxcfg_calibration_check(struct adxcvr *xcvr, uint32_t lane,
155  bool tx);
156 #endif
157 
altera_a10_cdr_pll.h
Driver for the Altera CDR/CMU PLL dynamic reconfiguration.
xcvr_calib_tx
int32_t xcvr_calib_tx(struct adxcvr *xcvr)
xcvr_calib_tx
Definition: altera_adxcvr.c:317
timeout
uint32_t timeout
Definition: ad413x.c:54
atx_pll_calibration_check
int32_t atx_pll_calibration_check(struct adxcvr *xcvr)
atx_pll_calibration_check
Definition: altera_adxcvr.c:253
adxcvr::lane_rate_khz
uint32_t lane_rate_khz
Definition: altera_adxcvr.h:103
adxcfg_write
int32_t adxcfg_write(struct adxcvr *xcvr, uint32_t lane, uint32_t reg, uint32_t val)
adxcfg_write
Definition: altera_adxcvr.c:198
adxcvr::parent_rate_khz
uint32_t parent_rate_khz
Definition: altera_adxcvr.h:104
XCVR_CAPAB_TX_CAL_BUSY_MASK
#define XCVR_CAPAB_TX_CAL_BUSY_MASK
Definition: altera_adxcvr.h:84
adxcvr::name
const char * name
Definition: altera_adxcvr.h:96
atx_pll_read
int32_t atx_pll_read(struct adxcvr *xcvr, uint32_t reg, uint32_t *val)
atx_pll_read
Definition: altera_adxcvr.c:156
adxcvr_post_lane_rate_change
void adxcvr_post_lane_rate_change(struct adxcvr *xcvr, unsigned int lane_rate_khz)
adxcvr_post_lane_rate_change
Definition: altera_adxcvr.c:398
xcvr_calib_tx
int32_t xcvr_calib_tx(struct adxcvr *xcvr)
xcvr_calib_tx
Definition: altera_adxcvr.c:317
adxcvr_release_arbitration
void adxcvr_release_arbitration(uint32_t addr, bool calibrate)
adxcvr_release_arbitration
Definition: altera_adxcvr.c:132
adxcfg_update
void adxcfg_update(struct adxcvr *xcvr, uint32_t lane, uint32_t reg, uint32_t mask, uint32_t val)
adxcfg_update
Definition: altera_adxcvr.c:220
ADXCVR_REG_SYNTH_CONF
#define ADXCVR_REG_SYNTH_CONF
Definition: altera_adxcvr.c:78
ADXCVR_RESETN
#define ADXCVR_RESETN
Definition: altera_adxcvr.c:70
adxcfg_release_arbitration
void adxcfg_release_arbitration(struct adxcvr *xcvr, uint32_t lane, bool calibrate)
adxcfg_release_arbitration
Definition: altera_adxcvr.c:244
XCVR_CALIB_TX_TERM_VOD_EN
#define XCVR_CALIB_TX_TERM_VOD_EN
Definition: altera_adxcvr.h:71
adxcvr
ADI JESD204B/C AXI_ADXCVR Highspeed Transceiver Device structure.
Definition: altera_adxcvr.h:95
adxcfg_release_arbitration
void adxcfg_release_arbitration(struct adxcvr *xcvr, uint32_t lane, bool calibrate)
adxcfg_release_arbitration
Definition: altera_adxcvr.c:244
adxcvr::is_transmit
bool is_transmit
Definition: altera_adxcvr.h:98
altera_a10_cdr_pll_set_rate
int32_t altera_a10_cdr_pll_set_rate(struct adxcvr *xcvr, uint32_t rate_khz)
altera_a10_cdr_pll_set_rate
Definition: altera_a10_cdr_pll.c:363
adxcvr::initial_recalc
bool initial_recalc
Definition: altera_adxcvr.h:105
adxcvr_set_rate
int32_t adxcvr_set_rate(struct adxcvr *xcvr, uint32_t rate_khz)
adxcvr_init
Definition: altera_adxcvr.c:420
atx_pll_read
int32_t atx_pll_read(struct adxcvr *xcvr, uint32_t reg, uint32_t *val)
atx_pll_read
Definition: altera_adxcvr.c:156
altera_a10_cdr_pll_round_rate
long altera_a10_cdr_pll_round_rate(struct adxcvr *xcvr, uint32_t rate_khz)
altera_a10_cdr_pll_round_rate
Definition: altera_a10_cdr_pll.c:341
adxcvr::atx_pll_base
uint32_t atx_pll_base
Definition: altera_adxcvr.h:101
atx_pll_write
int32_t atx_pll_write(struct adxcvr *xcvr, uint32_t reg, uint32_t val)
atx_pll_write
Definition: altera_adxcvr.c:146
adxcvr::base
uint32_t base
Definition: altera_adxcvr.h:97
adxcvr_init
int32_t adxcvr_init(struct adxcvr **ad_xcvr, const struct adxcvr_init *init)
adxcvr_init
Definition: altera_adxcvr.c:443
adxcfg_read
int32_t adxcfg_read(struct adxcvr *xcvr, uint32_t lane, uint32_t reg, uint32_t *val)
adxcfg_read
Definition: altera_adxcvr.c:209
adxcvr_set_rate
int32_t adxcvr_set_rate(struct adxcvr *xcvr, uint32_t rate_khz)
adxcvr_init
Definition: altera_adxcvr.c:420
atx_pll_release_arbitration
void atx_pll_release_arbitration(struct adxcvr *xcvr, bool calibrate)
atx_pll_release_arbitration
Definition: altera_adxcvr.c:189
XCVR_ARBITRATION_GET_AVMM
#define XCVR_ARBITRATION_GET_AVMM
Definition: altera_adxcvr.h:56
XCVR_CAPAB_RX_CAL_BUSY_MASK
#define XCVR_CAPAB_RX_CAL_BUSY_MASK
Definition: altera_adxcvr.h:79
bool
bool
Definition: common.h:54
XCVR_REG_CAPAB_ATX_PLL_STAT
#define XCVR_REG_CAPAB_ATX_PLL_STAT
Definition: altera_adxcvr.h:64
adxcfg_acquire_arbitration
void adxcfg_acquire_arbitration(struct adxcvr *xcvr, uint32_t lane)
adxcfg_acquire_arbitration
Definition: altera_adxcvr.c:234
ADXCVR_REG_STATUS2
#define ADXCVR_REG_STATUS2
Definition: altera_adxcvr.c:75
no_os_mdelay
void no_os_mdelay(uint32_t msecs)
Wait until msecs milliseconds passed.
Definition: aducm3029_delay.c:132
adxcfg_acquire_arbitration
void adxcfg_acquire_arbitration(struct adxcvr *xcvr, uint32_t lane)
adxcfg_acquire_arbitration
Definition: altera_adxcvr.c:234
XCVR_REG_CAPAB_PMA
#define XCVR_REG_CAPAB_PMA
Definition: altera_adxcvr.h:75
ADXCVR_REG_STATUS
#define ADXCVR_REG_STATUS
Definition: altera_adxcvr.c:72
no_os_error.h
Error codes definition.
adxcvr_round_rate
int32_t adxcvr_round_rate(struct adxcvr *xcvr, uint32_t rate_khz)
adxcvr_round_rate
Definition: altera_adxcvr.c:409
adxcvr_remove
int32_t adxcvr_remove(struct adxcvr *xcvr)
adxcvr_remove
Definition: altera_adxcvr.c:494
altera_adxcvr.h
Driver for the Altera ADXCVR Configuration.
atx_pll_calibration_check
int32_t atx_pll_calibration_check(struct adxcvr *xcvr)
atx_pll_calibration_check
Definition: altera_adxcvr.c:253
adxcvr_init::adxcfg_base
uint32_t adxcfg_base[4]
Definition: altera_adxcvr.h:111
XCVR_CAPAB_RX_CAL_BUSY_EN_MASK
#define XCVR_CAPAB_RX_CAL_BUSY_EN_MASK
Definition: altera_adxcvr.h:76
altera_a10_atx_pll_recalc_rate
uint32_t altera_a10_atx_pll_recalc_rate(struct adxcvr *xcvr)
altera_a10_atx_pll_recalc_rate
Definition: altera_a10_atx_pll.c:289
atx_pll_release_arbitration
void atx_pll_release_arbitration(struct adxcvr *xcvr, bool calibrate)
atx_pll_release_arbitration
Definition: altera_adxcvr.c:189
adxcvr_write
int32_t adxcvr_write(struct adxcvr *xcvr, uint32_t reg_addr, uint32_t reg_val)
adxcvr_write
Definition: altera_adxcvr.c:87
ADXCVR_STATUS2_XCVR
#define ADXCVR_STATUS2_XCVR(x)
Definition: altera_adxcvr.c:76
adxcvr_init
Definition: altera_adxcvr.h:108
XCVR_CAPAB_ATX_PLL_CAL_BSY_MASK
#define XCVR_CAPAB_ATX_PLL_CAL_BSY_MASK
Definition: altera_adxcvr.h:65
XCVR_CAPAB_ATX_PLL_CAL_DONE
#define XCVR_CAPAB_ATX_PLL_CAL_DONE
Definition: altera_adxcvr.h:66
adxcvr_read
int32_t adxcvr_read(struct adxcvr *xcvr, uint32_t reg_addr, uint32_t *reg_val)
adxcvr_read
Definition: altera_adxcvr.c:99
adxcvr_init::name
const char * name
Definition: altera_adxcvr.h:109
adxcvr_init::base
uint32_t base
Definition: altera_adxcvr.h:110
atx_pll_update
void atx_pll_update(struct adxcvr *xcvr, uint32_t reg, uint32_t mask, uint32_t val)
atx_pll_update
Definition: altera_adxcvr.c:166
adxcvr::adxcfg_base
uint32_t adxcfg_base[4]
Definition: altera_adxcvr.h:100
XCVR_CAPAB_RX_CAL_BUSY_DIS
#define XCVR_CAPAB_RX_CAL_BUSY_DIS
Definition: altera_adxcvr.h:78
XCVR_ARBITRATION_RELEASE_AVMM_CALIB
#define XCVR_ARBITRATION_RELEASE_AVMM_CALIB
Definition: altera_adxcvr.h:57
altera_a10_atx_pll_round_rate
int32_t altera_a10_atx_pll_round_rate(struct adxcvr *xcvr, uint32_t rate_khz)
altera_a10_atx_pll_round_rate
Definition: altera_a10_atx_pll.c:191
adxcfg_calibration_check
int32_t adxcfg_calibration_check(struct adxcvr *xcvr, uint32_t lane, bool tx)
adxcfg_calibration_check
Definition: altera_adxcvr.c:280
adxcfg_read
int32_t adxcfg_read(struct adxcvr *xcvr, uint32_t lane, uint32_t reg, uint32_t *val)
adxcfg_read
Definition: altera_adxcvr.c:209
altera_a10_cdr_pll_recalc_rate
uint32_t altera_a10_cdr_pll_recalc_rate(struct adxcvr *xcvr)
altera_a10_cdr_pll_recalc_rate
Definition: altera_a10_cdr_pll.c:485
atx_pll_update
void atx_pll_update(struct adxcvr *xcvr, uint32_t reg, uint32_t mask, uint32_t val)
atx_pll_update
Definition: altera_adxcvr.c:166
ADXCVR_STATUS
#define ADXCVR_STATUS
Definition: altera_adxcvr.c:73
adxcfg_calibration_check
int32_t adxcfg_calibration_check(struct adxcvr *xcvr, uint32_t lane, bool tx)
adxcfg_calibration_check
Definition: altera_adxcvr.c:280
adxcvr_init::atx_pll_base
uint32_t atx_pll_base
Definition: altera_adxcvr.h:112
adxcvr_init::lane_rate_khz
uint32_t lane_rate_khz
Definition: altera_adxcvr.h:113
adxcvr_pre_lane_rate_change
void adxcvr_pre_lane_rate_change(struct adxcvr *xcvr)
adxcvr_pre_lane_rate_change
Definition: altera_adxcvr.c:350
NO_OS_BIT
#define NO_OS_BIT(x)
Definition: no_os_util.h:51
adxcvr_recalc_rate
uint32_t adxcvr_recalc_rate(struct adxcvr *xcvr)
adxcvr_recalc_rate
Definition: altera_adxcvr.c:432
XCVR_ARBITRATION_RELEASE_AVMM
#define XCVR_ARBITRATION_RELEASE_AVMM
Definition: altera_adxcvr.h:58
adxcvr_pre_lane_rate_change
void adxcvr_pre_lane_rate_change(struct adxcvr *xcvr)
adxcvr_pre_lane_rate_change
Definition: altera_adxcvr.c:350
no_os_udelay
void no_os_udelay(uint32_t usecs)
Wait until usecs microseconds passed.
Definition: aducm3029_delay.c:120
adxcvr_acquire_arbitration
void adxcvr_acquire_arbitration(struct adxcvr *xcvr, uint32_t addr, uint32_t status_reg)
adxcvr_acquire_arbitration
Definition: altera_adxcvr.c:111
altera_a10_atx_pll_set_rate
int32_t altera_a10_atx_pll_set_rate(struct adxcvr *xcvr, uint32_t rate_khz)
altera_a10_atx_pll_set_rate
Definition: altera_a10_atx_pll.c:212
altera_a10_atx_pll.h
atx_pll_acquire_arbitration
void atx_pll_acquire_arbitration(struct adxcvr *xcvr)
atx_pll_acquire_arbitration
Definition: altera_adxcvr.c:180
adxcvr::reset_counter
uint32_t reset_counter
Definition: altera_adxcvr.h:102
adxcvr_round_rate
int32_t adxcvr_round_rate(struct adxcvr *xcvr, uint32_t rate_khz)
adxcvr_round_rate
Definition: altera_adxcvr.c:409
XCVR_CAPAB_TX_CAL_BUSY_EN_MASK
#define XCVR_CAPAB_TX_CAL_BUSY_EN_MASK
Definition: altera_adxcvr.h:81
adxcvr_remove
int32_t adxcvr_remove(struct adxcvr *xcvr)
adxcvr_remove
Definition: altera_adxcvr.c:494
XCVR_CALIB_TX_TERM_VOD_MASK
#define XCVR_CALIB_TX_TERM_VOD_MASK
Definition: altera_adxcvr.h:70
adxcfg_update
void adxcfg_update(struct adxcvr *xcvr, uint32_t lane, uint32_t reg, uint32_t mask, uint32_t val)
adxcfg_update
Definition: altera_adxcvr.c:220
ADXCVR_REG_RESETN
#define ADXCVR_REG_RESETN
Definition: altera_adxcvr.c:69
adxcvr_finalize_lane_rate_change
void adxcvr_finalize_lane_rate_change(struct adxcvr *xcvr)
adxcvr_finalize_lane_rate_change
Definition: altera_adxcvr.c:364
adxcvr::lanes_per_link
uint32_t lanes_per_link
Definition: altera_adxcvr.h:99
no_os_util.h
Header file of utility functions.
atx_pll_acquire_arbitration
void atx_pll_acquire_arbitration(struct adxcvr *xcvr)
atx_pll_acquire_arbitration
Definition: altera_adxcvr.c:180
adxcvr_recalc_rate
uint32_t adxcvr_recalc_rate(struct adxcvr *xcvr)
adxcvr_recalc_rate
Definition: altera_adxcvr.c:432
adxcvr_post_lane_rate_change
void adxcvr_post_lane_rate_change(struct adxcvr *xcvr, unsigned int lane_rate_khz)
adxcvr_post_lane_rate_change
Definition: altera_adxcvr.c:398
XCVR_REG_CALIB_PMA_EN
#define XCVR_REG_CALIB_PMA_EN
Definition: altera_adxcvr.h:69
adxcvr_init::parent_rate_khz
uint32_t parent_rate_khz
Definition: altera_adxcvr.h:114
atx_pll_write
int32_t atx_pll_write(struct adxcvr *xcvr, uint32_t reg, uint32_t val)
atx_pll_write
Definition: altera_adxcvr.c:146
adxcvr_init
int32_t adxcvr_init(struct adxcvr **ad_xcvr, const struct adxcvr_init *init)
adxcvr_init
Definition: altera_adxcvr.c:443
adxcfg_write
int32_t adxcfg_write(struct adxcvr *xcvr, uint32_t lane, uint32_t reg, uint32_t val)
adxcfg_write
Definition: altera_adxcvr.c:198
XCVR_CAPAB_TX_CAL_BUSY_EN
#define XCVR_CAPAB_TX_CAL_BUSY_EN
Definition: altera_adxcvr.h:82