no-OS
altera_adxcvr.h
Go to the documentation of this file.
1 /***************************************************************************/
33 #ifndef ALTERA_ADXCVR_H_
34 #define ALTERA_ADXCVR_H_
35 
36 /******************************************************************************/
37 /***************************** Include Files **********************************/
38 /******************************************************************************/
39 #include <stdint.h>
40 #include <stdbool.h>
41 
42 /******************************************************************************/
43 /********************** Macros and Constants Definitions **********************/
44 /******************************************************************************/
45 
46 /* XCVR Registers */
47 
48 #define XCVR_REG_ARBITRATION 0x000
49 #define XCVR_ARBITRATION_MASK 0xFF
50 #define XCVR_ARBITRATION_GET_AVMM 0x02
51 #define XCVR_ARBITRATION_RELEASE_AVMM_CALIB 0x01
52 #define XCVR_ARBITRATION_RELEASE_AVMM 0x03
53 
54 #define XCVR_REG_CALIB_ATX_PLL_EN 0x100
55 #define XCVR_CALIB_ATX_PLL_EN_MASK 0x01
56 #define XCVR_CALIB_ATX_PLL_EN 0x01
57 
58 #define XCVR_REG_CAPAB_ATX_PLL_STAT 0x280
59 #define XCVR_CAPAB_ATX_PLL_CAL_BSY_MASK 0x02
60 #define XCVR_CAPAB_ATX_PLL_CAL_DONE 0x00
61 
62 
63 #define XCVR_REG_CALIB_PMA_EN 0x100
64 #define XCVR_CALIB_TX_TERM_VOD_MASK 0x20
65 #define XCVR_CALIB_TX_TERM_VOD_EN 0x20
66 #define XCVR_CALIB_CMU_CDR_PLL_EN_MASK 0x02
67 #define XCVR_CALIB_CMU_CDR_PLL_EN 0x02
68 
69 #define XCVR_REG_CAPAB_PMA 0x281
70 #define XCVR_CAPAB_RX_CAL_BUSY_EN_MASK 0x20
71 #define XCVR_CAPAB_RX_CAL_BUSY_EN 0x20
72 #define XCVR_CAPAB_RX_CAL_BUSY_DIS 0x00
73 #define XCVR_CAPAB_RX_CAL_BUSY_MASK 0x02
74 #define XCVR_CAPAB_RX_CAL_DONE 0x00
75 #define XCVR_CAPAB_TX_CAL_BUSY_EN_MASK 0x10
76 #define XCVR_CAPAB_TX_CAL_BUSY_EN 0x10
77 #define XCVR_CAPAB_TX_CAL_BUSY_DIS 0x00
78 #define XCVR_CAPAB_TX_CAL_BUSY_MASK 0x01
79 #define XCVR_CAPAB_TX_CAL_DONE 0x00
80 
81 #define XCVR_REG_RATE_SWITCH_FLAG 0x166
82 #define XCVR_RATE_SWITCH_FLAG_MASK 0x80
83 #define XCVR_RATE_SWITCH_FLAG_RATE_SWITCH 0x00
84 #define XCVR_RATE_SWITCH_FLAG_NO_RATE_SWITCH 0x80
85 
86 /******************************************************************************/
87 /*************************** Types Declarations *******************************/
88 /******************************************************************************/
89 struct adxcvr {
90  const char *name;
91  uint32_t base;
93  uint32_t lanes_per_link;
94  uint32_t adxcfg_base[4];
95  uint32_t atx_pll_base;
96  uint32_t reset_counter;
97  uint32_t lane_rate_khz;
98  uint32_t parent_rate_khz;
100 };
101 
102 struct adxcvr_init {
103  const char *name;
104  uint32_t base;
105  uint32_t adxcfg_base[4];
106  uint32_t atx_pll_base;
107  uint32_t lane_rate_khz;
108  uint32_t parent_rate_khz;
109 };
110 
111 /******************************************************************************/
112 /************************ Functions Declarations ******************************/
113 /******************************************************************************/
114 int32_t adxcvr_init(struct adxcvr **ad_xcvr,
115  const struct adxcvr_init *init);
116 int32_t adxcvr_remove(struct adxcvr *xcvr);
117 void adxcvr_post_lane_rate_change(struct adxcvr *xcvr,
118  unsigned int lane_rate_khz);
119 int32_t adxcvr_round_rate(struct adxcvr *xcvr, uint32_t rate_khz);
120 int32_t adxcvr_set_rate(struct adxcvr *xcvr,
121  uint32_t rate_khz);
122 uint32_t adxcvr_recalc_rate(struct adxcvr *xcvr);
123 
124 void adxcvr_pre_lane_rate_change(struct adxcvr *xcvr);
125 void adxcvr_post_lane_rate_change(struct adxcvr *xcvr,
126  unsigned int lane_rate);
127 
128 void atx_pll_acquire_arbitration(struct adxcvr *xcvr);
129 void atx_pll_release_arbitration(struct adxcvr *xcvr,
130  bool calibrate);
131 int32_t atx_pll_write(struct adxcvr *xcvr, uint32_t reg, uint32_t val);
132 int32_t atx_pll_read(struct adxcvr *xcvr, uint32_t reg, uint32_t *val);
133 void atx_pll_update(struct adxcvr *xcvr, uint32_t reg,
134  uint32_t mask, uint32_t val);
135 int32_t atx_pll_calibration_check(struct adxcvr *xcvr);
136 int32_t xcvr_calib_tx(struct adxcvr *xcvr);
137 
138 void adxcfg_acquire_arbitration(struct adxcvr *xcvr,
139  uint32_t lane);
140 void adxcfg_release_arbitration(struct adxcvr *xcvr,
141  uint32_t lane, bool calibrate);
142 int32_t adxcfg_write(struct adxcvr *xcvr, uint32_t lane, uint32_t reg,
143  uint32_t val);
144 int32_t adxcfg_read(struct adxcvr *xcvr, uint32_t lane,
145  uint32_t reg, uint32_t *val);
146 void adxcfg_update(struct adxcvr *xcvr, uint32_t lane,
147  uint32_t reg, uint32_t mask, uint32_t val);
148 int32_t adxcfg_calibration_check(struct adxcvr *xcvr, uint32_t lane,
149  bool tx);
150 #endif
151 
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:312
timeout
uint32_t timeout
Definition: ad413x.c:49
no_os_alloc.h
atx_pll_calibration_check
int32_t atx_pll_calibration_check(struct adxcvr *xcvr)
atx_pll_calibration_check
Definition: altera_adxcvr.c:248
adxcvr::lane_rate_khz
uint32_t lane_rate_khz
Definition: altera_adxcvr.h:97
adxcfg_write
int32_t adxcfg_write(struct adxcvr *xcvr, uint32_t lane, uint32_t reg, uint32_t val)
adxcfg_write
Definition: altera_adxcvr.c:193
adxcvr::parent_rate_khz
uint32_t parent_rate_khz
Definition: altera_adxcvr.h:98
XCVR_CAPAB_TX_CAL_BUSY_MASK
#define XCVR_CAPAB_TX_CAL_BUSY_MASK
Definition: altera_adxcvr.h:78
adxcvr::name
const char * name
Definition: altera_adxcvr.h:90
atx_pll_read
int32_t atx_pll_read(struct adxcvr *xcvr, uint32_t reg, uint32_t *val)
atx_pll_read
Definition: altera_adxcvr.c:151
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:393
xcvr_calib_tx
int32_t xcvr_calib_tx(struct adxcvr *xcvr)
xcvr_calib_tx
Definition: altera_adxcvr.c:312
adxcvr_release_arbitration
void adxcvr_release_arbitration(uint32_t addr, bool calibrate)
adxcvr_release_arbitration
Definition: altera_adxcvr.c:127
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:215
ADXCVR_REG_SYNTH_CONF
#define ADXCVR_REG_SYNTH_CONF
Definition: altera_adxcvr.c:73
ADXCVR_RESETN
#define ADXCVR_RESETN
Definition: altera_adxcvr.c:65
adxcfg_release_arbitration
void adxcfg_release_arbitration(struct adxcvr *xcvr, uint32_t lane, bool calibrate)
adxcfg_release_arbitration
Definition: altera_adxcvr.c:239
XCVR_CALIB_TX_TERM_VOD_EN
#define XCVR_CALIB_TX_TERM_VOD_EN
Definition: altera_adxcvr.h:65
adxcvr
ADI JESD204B/C AXI_ADXCVR Highspeed Transceiver Device structure.
Definition: altera_adxcvr.h:89
adxcfg_release_arbitration
void adxcfg_release_arbitration(struct adxcvr *xcvr, uint32_t lane, bool calibrate)
adxcfg_release_arbitration
Definition: altera_adxcvr.c:239
adxcvr::is_transmit
bool is_transmit
Definition: altera_adxcvr.h:92
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:357
adxcvr::initial_recalc
bool initial_recalc
Definition: altera_adxcvr.h:99
adxcvr_set_rate
int32_t adxcvr_set_rate(struct adxcvr *xcvr, uint32_t rate_khz)
adxcvr_init
Definition: altera_adxcvr.c:415
atx_pll_read
int32_t atx_pll_read(struct adxcvr *xcvr, uint32_t reg, uint32_t *val)
atx_pll_read
Definition: altera_adxcvr.c:151
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:335
adxcvr::atx_pll_base
uint32_t atx_pll_base
Definition: altera_adxcvr.h:95
atx_pll_write
int32_t atx_pll_write(struct adxcvr *xcvr, uint32_t reg, uint32_t val)
atx_pll_write
Definition: altera_adxcvr.c:141
adxcvr::base
uint32_t base
Definition: altera_adxcvr.h:91
adxcvr_init
int32_t adxcvr_init(struct adxcvr **ad_xcvr, const struct adxcvr_init *init)
adxcvr_init
Definition: altera_adxcvr.c:438
adxcfg_read
int32_t adxcfg_read(struct adxcvr *xcvr, uint32_t lane, uint32_t reg, uint32_t *val)
adxcfg_read
Definition: altera_adxcvr.c:204
adxcvr_set_rate
int32_t adxcvr_set_rate(struct adxcvr *xcvr, uint32_t rate_khz)
adxcvr_init
Definition: altera_adxcvr.c:415
atx_pll_release_arbitration
void atx_pll_release_arbitration(struct adxcvr *xcvr, bool calibrate)
atx_pll_release_arbitration
Definition: altera_adxcvr.c:184
XCVR_ARBITRATION_GET_AVMM
#define XCVR_ARBITRATION_GET_AVMM
Definition: altera_adxcvr.h:50
XCVR_CAPAB_RX_CAL_BUSY_MASK
#define XCVR_CAPAB_RX_CAL_BUSY_MASK
Definition: altera_adxcvr.h:73
bool
bool
Definition: common.h:48
XCVR_REG_CAPAB_ATX_PLL_STAT
#define XCVR_REG_CAPAB_ATX_PLL_STAT
Definition: altera_adxcvr.h:58
adxcfg_acquire_arbitration
void adxcfg_acquire_arbitration(struct adxcvr *xcvr, uint32_t lane)
adxcfg_acquire_arbitration
Definition: altera_adxcvr.c:229
ADXCVR_REG_STATUS2
#define ADXCVR_REG_STATUS2
Definition: altera_adxcvr.c:70
no_os_mdelay
void no_os_mdelay(uint32_t msecs)
Wait until msecs milliseconds passed.
Definition: aducm3029_delay.c:126
adxcfg_acquire_arbitration
void adxcfg_acquire_arbitration(struct adxcvr *xcvr, uint32_t lane)
adxcfg_acquire_arbitration
Definition: altera_adxcvr.c:229
XCVR_REG_CAPAB_PMA
#define XCVR_REG_CAPAB_PMA
Definition: altera_adxcvr.h:69
ADXCVR_REG_STATUS
#define ADXCVR_REG_STATUS
Definition: altera_adxcvr.c:67
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:404
adxcvr_remove
int32_t adxcvr_remove(struct adxcvr *xcvr)
adxcvr_remove
Definition: altera_adxcvr.c:489
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:248
adxcvr_init::adxcfg_base
uint32_t adxcfg_base[4]
Definition: altera_adxcvr.h:105
XCVR_CAPAB_RX_CAL_BUSY_EN_MASK
#define XCVR_CAPAB_RX_CAL_BUSY_EN_MASK
Definition: altera_adxcvr.h:70
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:283
atx_pll_release_arbitration
void atx_pll_release_arbitration(struct adxcvr *xcvr, bool calibrate)
atx_pll_release_arbitration
Definition: altera_adxcvr.c:184
adxcvr_write
int32_t adxcvr_write(struct adxcvr *xcvr, uint32_t reg_addr, uint32_t reg_val)
adxcvr_write
Definition: altera_adxcvr.c:82
ADXCVR_STATUS2_XCVR
#define ADXCVR_STATUS2_XCVR(x)
Definition: altera_adxcvr.c:71
adxcvr_init
Definition: altera_adxcvr.h:102
XCVR_CAPAB_ATX_PLL_CAL_BSY_MASK
#define XCVR_CAPAB_ATX_PLL_CAL_BSY_MASK
Definition: altera_adxcvr.h:59
XCVR_CAPAB_ATX_PLL_CAL_DONE
#define XCVR_CAPAB_ATX_PLL_CAL_DONE
Definition: altera_adxcvr.h:60
adxcvr_read
int32_t adxcvr_read(struct adxcvr *xcvr, uint32_t reg_addr, uint32_t *reg_val)
adxcvr_read
Definition: altera_adxcvr.c:94
adxcvr_init::name
const char * name
Definition: altera_adxcvr.h:103
adxcvr_init::base
uint32_t base
Definition: altera_adxcvr.h:104
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:161
adxcvr::adxcfg_base
uint32_t adxcfg_base[4]
Definition: altera_adxcvr.h:94
XCVR_CAPAB_RX_CAL_BUSY_DIS
#define XCVR_CAPAB_RX_CAL_BUSY_DIS
Definition: altera_adxcvr.h:72
XCVR_ARBITRATION_RELEASE_AVMM_CALIB
#define XCVR_ARBITRATION_RELEASE_AVMM_CALIB
Definition: altera_adxcvr.h:51
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:185
adxcfg_calibration_check
int32_t adxcfg_calibration_check(struct adxcvr *xcvr, uint32_t lane, bool tx)
adxcfg_calibration_check
Definition: altera_adxcvr.c:275
adxcfg_read
int32_t adxcfg_read(struct adxcvr *xcvr, uint32_t lane, uint32_t reg, uint32_t *val)
adxcfg_read
Definition: altera_adxcvr.c:204
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:479
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:161
no_os_malloc
void * no_os_malloc(size_t size)
Allocate memory and return a pointer to it.
Definition: chibios_alloc.c:43
ADXCVR_STATUS
#define ADXCVR_STATUS
Definition: altera_adxcvr.c:68
adxcfg_calibration_check
int32_t adxcfg_calibration_check(struct adxcvr *xcvr, uint32_t lane, bool tx)
adxcfg_calibration_check
Definition: altera_adxcvr.c:275
adxcvr_init::atx_pll_base
uint32_t atx_pll_base
Definition: altera_adxcvr.h:106
adxcvr_init::lane_rate_khz
uint32_t lane_rate_khz
Definition: altera_adxcvr.h:107
adxcvr_pre_lane_rate_change
void adxcvr_pre_lane_rate_change(struct adxcvr *xcvr)
adxcvr_pre_lane_rate_change
Definition: altera_adxcvr.c:345
NO_OS_BIT
#define NO_OS_BIT(x)
Definition: no_os_util.h:45
adxcvr_recalc_rate
uint32_t adxcvr_recalc_rate(struct adxcvr *xcvr)
adxcvr_recalc_rate
Definition: altera_adxcvr.c:427
no_os_free
void no_os_free(void *ptr)
Deallocate memory previously allocated by a call to no_os_calloc or no_os_malloc.
Definition: chibios_alloc.c:69
XCVR_ARBITRATION_RELEASE_AVMM
#define XCVR_ARBITRATION_RELEASE_AVMM
Definition: altera_adxcvr.h:52
adxcvr_pre_lane_rate_change
void adxcvr_pre_lane_rate_change(struct adxcvr *xcvr)
adxcvr_pre_lane_rate_change
Definition: altera_adxcvr.c:345
no_os_udelay
void no_os_udelay(uint32_t usecs)
Wait until usecs microseconds passed.
Definition: aducm3029_delay.c:114
adxcvr_acquire_arbitration
void adxcvr_acquire_arbitration(struct adxcvr *xcvr, uint32_t addr, uint32_t status_reg)
adxcvr_acquire_arbitration
Definition: altera_adxcvr.c:106
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:206
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:175
adxcvr::reset_counter
uint32_t reset_counter
Definition: altera_adxcvr.h:96
adxcvr_round_rate
int32_t adxcvr_round_rate(struct adxcvr *xcvr, uint32_t rate_khz)
adxcvr_round_rate
Definition: altera_adxcvr.c:404
XCVR_CAPAB_TX_CAL_BUSY_EN_MASK
#define XCVR_CAPAB_TX_CAL_BUSY_EN_MASK
Definition: altera_adxcvr.h:75
adxcvr_remove
int32_t adxcvr_remove(struct adxcvr *xcvr)
adxcvr_remove
Definition: altera_adxcvr.c:489
XCVR_CALIB_TX_TERM_VOD_MASK
#define XCVR_CALIB_TX_TERM_VOD_MASK
Definition: altera_adxcvr.h:64
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:215
ADXCVR_REG_RESETN
#define ADXCVR_REG_RESETN
Definition: altera_adxcvr.c:64
adxcvr_finalize_lane_rate_change
void adxcvr_finalize_lane_rate_change(struct adxcvr *xcvr)
adxcvr_finalize_lane_rate_change
Definition: altera_adxcvr.c:359
adxcvr::lanes_per_link
uint32_t lanes_per_link
Definition: altera_adxcvr.h:93
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:175
adxcvr_recalc_rate
uint32_t adxcvr_recalc_rate(struct adxcvr *xcvr)
adxcvr_recalc_rate
Definition: altera_adxcvr.c:427
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:393
XCVR_REG_CALIB_PMA_EN
#define XCVR_REG_CALIB_PMA_EN
Definition: altera_adxcvr.h:63
adxcvr_init::parent_rate_khz
uint32_t parent_rate_khz
Definition: altera_adxcvr.h:108
atx_pll_write
int32_t atx_pll_write(struct adxcvr *xcvr, uint32_t reg, uint32_t val)
atx_pll_write
Definition: altera_adxcvr.c:141
adxcvr_init
int32_t adxcvr_init(struct adxcvr **ad_xcvr, const struct adxcvr_init *init)
adxcvr_init
Definition: altera_adxcvr.c:438
adxcfg_write
int32_t adxcfg_write(struct adxcvr *xcvr, uint32_t lane, uint32_t reg, uint32_t val)
adxcfg_write
Definition: altera_adxcvr.c:193
XCVR_CAPAB_TX_CAL_BUSY_EN
#define XCVR_CAPAB_TX_CAL_BUSY_EN
Definition: altera_adxcvr.h:76