| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
#ifndef __AD9517_H__ |
| 43 |
#define __AD9517_H__ |
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
#include <stdint.h> |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
#define AD9517_READ (1 << 15) |
| 54 |
#define AD9517_WRITE (0 << 15) |
| 55 |
#define AD9517_CNT(x) ((x - 1) << 13) |
| 56 |
#define AD9517_ADDR(x) (x & 0x3FF) |
| 57 |
|
| 58 |
#define AD9517_T1B (1 << 16) |
| 59 |
#define AD9517_T2B (2 << 16) |
| 60 |
#define AD9517_T3B (3 << 16) |
| 61 |
#define AD9517_TRANSF_LEN(x) ((uint32_t)x >> 16) |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
#define AD9517_REG_SERIAL_PORT_CONFIG (AD9517_T1B | 0x000) |
| 67 |
#define AD9517_REG_PART_ID (AD9517_T1B | 0x003) |
| 68 |
#define AD9517_REG_READBACK_CTRL (AD9517_T1B | 0x004) |
| 69 |
|
| 70 |
|
| 71 |
#define AD9517_REG_PFD_CHARGE_PUMP (AD9517_T1B | 0x010) |
| 72 |
#define AD9517_REG_R_COUNTER (AD9517_T2B | 0x012) |
| 73 |
#define AD9517_REG_A_COUNTER (AD9517_T1B | 0x013) |
| 74 |
#define AD9517_REG_B_COUNTER (AD9517_T2B | 0x015) |
| 75 |
#define AD9517_REG_PLL_CTRL_1 (AD9517_T1B | 0x016) |
| 76 |
#define AD9517_REG_PLL_CTRL_2 (AD9517_T1B | 0x017) |
| 77 |
#define AD9517_REG_PLL_CTRL_3 (AD9517_T1B | 0x018) |
| 78 |
#define AD9517_REG_PLL_CTRL_4 (AD9517_T1B | 0x019) |
| 79 |
#define AD9517_REG_PLL_CTRL_5 (AD9517_T1B | 0x01A) |
| 80 |
#define AD9517_REG_PLL_CTRL_6 (AD9517_T1B | 0x01B) |
| 81 |
#define AD9517_REG_PLL_CTRL_7 (AD9517_T1B | 0x01C) |
| 82 |
#define AD9517_REG_PLL_CTRL_8 (AD9517_T1B | 0x01D) |
| 83 |
#define AD9517_REG_PLL_READBACK (AD9517_T1B | 0x01F) |
| 84 |
|
| 85 |
|
| 86 |
#define AD9517_REG_OUT4_DELAY_BYPASS (AD9517_T1B | 0x0A0) |
| 87 |
#define AD9517_REG_OUT4_DELAY_FULL_SCALE (AD9517_T1B | 0x0A1) |
| 88 |
#define AD9517_REG_OUT4_DELAY_FRACTION (AD9517_T1B | 0x0A2) |
| 89 |
#define AD9517_REG_OUT5_DELAY_BYPASS (AD9517_T1B | 0x0A3) |
| 90 |
#define AD9517_REG_OUT5_DELAY_FULL_SCALE (AD9517_T1B | 0x0A4) |
| 91 |
#define AD9517_REG_OUT5_DELAY_FRACTION (AD9517_T1B | 0x0A5) |
| 92 |
#define AD9517_REG_OUT6_DELAY_BYPASS (AD9517_T1B | 0x0A6) |
| 93 |
#define AD9517_REG_OUT6_DELAY_FULL_SCALE (AD9517_T1B | 0x0A7) |
| 94 |
#define AD9517_REG_OUT6_DELAY_FRACTION (AD9517_T1B | 0x0A8) |
| 95 |
#define AD9517_REG_OUT7_DELAY_BYPASS (AD9517_T1B | 0x0A9) |
| 96 |
#define AD9517_REG_OUT7_DELAY_FULL_SCALE (AD9517_T1B | 0x0AA) |
| 97 |
#define AD9517_REG_OUT7_DELAY_FRACTION (AD9517_T1B | 0x0AB) |
| 98 |
|
| 99 |
|
| 100 |
#define AD9517_REG_LVPECL_OUT0 (AD9517_T1B | 0x0F0) |
| 101 |
#define AD9517_REG_LVPECL_OUT1 (AD9517_T1B | 0x0F1) |
| 102 |
#define AD9517_REG_LVPECL_OUT2 (AD9517_T1B | 0x0F4) |
| 103 |
#define AD9517_REG_LVPECL_OUT3 (AD9517_T1B | 0x0F5) |
| 104 |
|
| 105 |
|
| 106 |
#define AD9517_REG_LVDS_CMOS_OUT4 (AD9517_T1B | 0x140) |
| 107 |
#define AD9517_REG_LVDS_CMOS_OUT5 (AD9517_T1B | 0x141) |
| 108 |
#define AD9517_REG_LVDS_CMOS_OUT6 (AD9517_T1B | 0x142) |
| 109 |
#define AD9517_REG_LVDS_CMOS_OUT7 (AD9517_T1B | 0x143) |
| 110 |
|
| 111 |
|
| 112 |
#define AD9517_REG_DIVIDER_0_0 (AD9517_T1B | 0x190) |
| 113 |
#define AD9517_REG_DIVIDER_0_1 (AD9517_T1B | 0x191) |
| 114 |
#define AD9517_REG_DIVIDER_0_2 (AD9517_T1B | 0x192) |
| 115 |
#define AD9517_REG_DIVIDER_1_0 (AD9517_T1B | 0x196) |
| 116 |
#define AD9517_REG_DIVIDER_1_1 (AD9517_T1B | 0x197) |
| 117 |
#define AD9517_REG_DIVIDER_1_2 (AD9517_T1B | 0x198) |
| 118 |
|
| 119 |
|
| 120 |
#define AD9517_REG_LVDS_CMOS_DIVIDER_2_0 (AD9517_T1B | 0x199) |
| 121 |
#define AD9517_REG_LVDS_CMOS_DIVIDER_2_1 (AD9517_T1B | 0x19A) |
| 122 |
#define AD9517_REG_LVDS_CMOS_DIVIDER_2_2 (AD9517_T1B | 0x19B) |
| 123 |
#define AD9517_REG_LVDS_CMOS_DIVIDER_2_3 (AD9517_T1B | 0x19C) |
| 124 |
#define AD9517_REG_LVDS_CMOS_DIVIDER_2_4 (AD9517_T1B | 0x19D) |
| 125 |
#define AD9517_REG_LVDS_CMOS_DIVIDER_3_0 (AD9517_T1B | 0x19E) |
| 126 |
#define AD9517_REG_LVDS_CMOS_DIVIDER_3_1 (AD9517_T1B | 0x19F) |
| 127 |
#define AD9517_REG_LVDS_CMOS_DIVIDER_3_2 (AD9517_T1B | 0x1A0) |
| 128 |
#define AD9517_REG_LVDS_CMOS_DIVIDER_3_3 (AD9517_T1B | 0x1A1) |
| 129 |
#define AD9517_REG_LVDS_CMOS_DIVIDER_3_4 (AD9517_T1B | 0x1A2) |
| 130 |
|
| 131 |
|
| 132 |
#define AD9517_REG_VCO_DIVIDER (AD9517_T1B | 0x1E0) |
| 133 |
#define AD9517_REG_INPUT_CLKS (AD9517_T1B | 0x1E1) |
| 134 |
|
| 135 |
|
| 136 |
#define AD9517_REG_POWER_DOWN_SYNC (AD9517_T1B | 0x230) |
| 137 |
|
| 138 |
|
| 139 |
#define AD9517_REG_UPDATE_ALL_REGS (AD9517_T1B | 0x232) |
| 140 |
|
| 141 |
|
| 142 |
#define AD9517_SDO_ACTIVE ((1 << 7) | (1 << 0)) |
| 143 |
#define AD9517_LSB_FIRST ((1 << 6) | (1 << 1)) |
| 144 |
#define AD9517_SOFT_RESET ((1 << 5) | (1 << 2)) |
| 145 |
#define AD9517_LONG_INSTRUCTION ((1 << 4) | (1 << 3)) |
| 146 |
|
| 147 |
|
| 148 |
#define AD9517_REG_BANK_SELECTION (1 << 0) |
| 149 |
|
| 150 |
|
| 151 |
#define AD9517_PFD_POLARITY (1 << 7) |
| 152 |
#define AD9517_CP_CURRENT(x) ((x & 0x7) << 4) |
| 153 |
#define AD9517_CP_MODE(x) ((x & 0x3) << 2) |
| 154 |
#define AD9517_PLL_POWER_DOWN(x) ((x & 0x3) << 0) |
| 155 |
|
| 156 |
|
| 157 |
#define AD9517_R_COUNTER(x) ((x & 0x3FFF) << 0) |
| 158 |
|
| 159 |
|
| 160 |
#define AD9517_A_COUNTER(x) ((x & 0x3F) << 0) |
| 161 |
|
| 162 |
|
| 163 |
#define AD9517_B_COUNTER(x) ((x & 0x1FFF) << 0) |
| 164 |
|
| 165 |
|
| 166 |
#define AD9517_CP_VCP_DIV2 (1 << 7) |
| 167 |
#define AD9517_RESET_R_COUNTER (1 << 6) |
| 168 |
#define AD9517_RESET_A_B_COUNTERS (1 << 5) |
| 169 |
#define AD9517_RESET_ALL_COUNTERS (1 << 4) |
| 170 |
#define AD9517_B_COUNTER_BYPASS (1 << 3) |
| 171 |
#define AD9517_PRESCALER_P(x) ((x & 0x7) << 0) |
| 172 |
|
| 173 |
|
| 174 |
#define AD9517_STATUS_PIN_CTRL(x) ((x & 0x3F) << 2) |
| 175 |
#define AD9517_ANTIBACKLASH_PULSE_WIDTH(x) ((x & 0x3) << 0) |
| 176 |
|
| 177 |
|
| 178 |
#define AD9517_LOCK_DETECT_COUNTER(x) ((x & 0x3) << 5) |
| 179 |
#define AD9517_DIGITAL_LOCK_DETECT_WINDOW (1 << 4) |
| 180 |
#define AD9517_DIS_DIGITAL_LOCK_DETECT (1 << 3) |
| 181 |
#define AD9517_VCO_CAL_DIVIDER(x) ((x & 0x3) << 1) |
| 182 |
#define AD9517_VCO_CAL_NOW (1 << 0) |
| 183 |
|
| 184 |
|
| 185 |
#define AD9517_SYNC_PIN_RESET(x) ((x & 0x3) << 6) |
| 186 |
#define AD9517_R_PATH_DELAY(x) ((x & 0x7) << 3) |
| 187 |
#define AD9517_N_PATH_DELAY(x) ((x & 0x7) << 0) |
| 188 |
|
| 189 |
|
| 190 |
#define AD9517_REF_FREQ_MONITOR_THRESHOLD (1 << 6) |
| 191 |
#define AD9517_LD_PIN_CTRL(x) ((x & 0x3F) << 0) |
| 192 |
|
| 193 |
|
| 194 |
#define AD9517_VCO_FREQ_MONITOR (1 << 7) |
| 195 |
#define AD9517_REF2_FREQ_MONITOR (1 << 6) |
| 196 |
#define AD9517_REF1_FREQ_MONITOR (1 << 5) |
| 197 |
#define AD9517_REFMON_PIN_CTRL(x) ((x & 0x1F) << 0) |
| 198 |
|
| 199 |
|
| 200 |
#define AD9517_DIS_SWITCHOVER_DEGLITCH (1 << 7) |
| 201 |
#define AD9517_SELECT_REF2 (1 << 6) |
| 202 |
#define AD9517_USE_REF_SEL_PIN (1 << 5) |
| 203 |
#define AD9517_REF2_POWER_ON (1 << 2) |
| 204 |
#define AD9517_REF1_POWER_ON (1 << 1) |
| 205 |
#define AD9517_DIFF_REF (1 << 0) |
| 206 |
|
| 207 |
|
| 208 |
#define AD9517_PLL_STATUS_REG_DIS (1 << 4) |
| 209 |
#define AD9517_LD_PIN_COMPARATOR_EN (1 << 3) |
| 210 |
#define AD9517_HOLDOVER_EN ((1 << 2) | (1 << 0)) |
| 211 |
#define AD9517_EXT_HOLDOVER_CTRL (1 << 1) |
| 212 |
|
| 213 |
|
| 214 |
#define AD9517_VCO_CAL_FINISHED (1 << 6) |
| 215 |
#define AD9517_HOLDOVER_ACTIVE (1 << 5) |
| 216 |
#define AD9517_REF2_SELECTED (1 << 4) |
| 217 |
#define AD9517_VCO_FREQ_GREATER (1 << 3) |
| 218 |
#define AD9517_REF2_FREQ_GREATER (1 << 2) |
| 219 |
#define AD9517_REF1_FREQ_GREATER (1 << 1) |
| 220 |
#define AD9517_DIGITAL_LOCK_DETECT (1 << 0) |
| 221 |
|
| 222 |
|
| 223 |
#define AD9517_OUT_DELAY_BYPASS (1 << 0) |
| 224 |
|
| 225 |
|
| 226 |
#define AD9517_OUT_RAMP_CAPACITORS(x) ((x & 0x7) << 3) |
| 227 |
#define AD9517_OUT_RAMP_CURRENT(x) ((x & 0x7) << 0) |
| 228 |
|
| 229 |
|
| 230 |
#define AD9517_OUT_DELAY_FRACTION(x) ((x & 0x3F) << 0) |
| 231 |
|
| 232 |
|
| 233 |
#define AD9517_OUT_LVPECL_INVERT (1 << 4) |
| 234 |
#define AD9517_OUT_LVPECL_DIFF_VOLTAGE(x) ((x & 0x3) << 2) |
| 235 |
#define AD9517_OUT_LVPECL_POWER_DOWN(x) ((x & 0x3) << 0) |
| 236 |
|
| 237 |
|
| 238 |
#define AD9517_OUT_LVDS_CMOS_INVERT(x) ((x & 0x7) << 5) |
| 239 |
#define AD9517_OUT_CMOS_B (1 << 4) |
| 240 |
#define AD9517_OUT_LVDS_CMOS (1 << 3) |
| 241 |
#define AD9517_OUT_LVDS_OUTPUT_CURRENT(x) ((x & 0x3) << 1) |
| 242 |
#define AD9517_OUT_LVDS_CMOS_POWER_DOWN (1 << 0) |
| 243 |
|
| 244 |
|
| 245 |
#define AD9517_DIVIDER_LOW_CYCLES(x) ((x & 0xF) << 4) |
| 246 |
#define AD9517_DIVIDER_HIGH_CYCLES(x) ((x & 0xF) << 0) |
| 247 |
|
| 248 |
|
| 249 |
#define AD9517_DIVIDER_BYPASS (1 << 7) |
| 250 |
#define AD9517_LVPECL_DIVIDER_NOSYNC (1 << 6) |
| 251 |
#define AD9517_LVPECL_DIVIDER_FORCE_HIGH (1 << 5) |
| 252 |
#define AD9517_DIVIDER_START_HIGH (1 << 4) |
| 253 |
#define AD9517_DIVIDER_PHASE_OFFSET(x) ((x & 0xF) << 0) |
| 254 |
|
| 255 |
|
| 256 |
#define AD9517_DIVIDER_DIRECT_TO_OUTPUT (1 << 1) |
| 257 |
#define AD9517_DIVIDER_DCCOFF (1 << 0) |
| 258 |
|
| 259 |
|
| 260 |
#define AD9517_LOW_CYCLES_DIVIDER_1(x) ((x & 0xF) << 4) |
| 261 |
#define AD9517_HIGH_CYCLES_DIVIDER_1(x) ((x & 0xF) << 0) |
| 262 |
|
| 263 |
|
| 264 |
#define AD9517_PHASE_OFFSET_DIVIDER_2(x) ((x & 0xF) << 4) |
| 265 |
#define AD9517_PHASE_OFFSET_DIVIDER_1(x) ((x & 0xF) << 0) |
| 266 |
|
| 267 |
|
| 268 |
#define AD9517_LOW_CYCLES_DIVIDER_2(x) ((x & 0xF) << 4) |
| 269 |
#define AD9517_HIGH_CYCLES_DIVIDER_2(x) ((x & 0xF) << 0) |
| 270 |
|
| 271 |
|
| 272 |
#define AD9517_BYPASS_DIVIDER_2 (1 << 5) |
| 273 |
#define AD9517_BYPASS_DIVIDER_1 (1 << 4) |
| 274 |
#define AD9517_LVDS_CMOS_DIVIDER_NOSYNC (1 << 3) |
| 275 |
#define AD9517_LVDS_CMOS_DIVIDER_FORCE_HIGH (1 << 2) |
| 276 |
#define AD9517_START_HIGH_DIVIDER_2 (1 << 1) |
| 277 |
#define AD9517_START_HIGH_DIVIDER_1 (1 << 0) |
| 278 |
|
| 279 |
|
| 280 |
#define AD9517_DIVIDER_DCCOFF (1 << 0) |
| 281 |
|
| 282 |
|
| 283 |
#define AD9517_VCO_DIVIDER(x) ((x & 0x7) << 0) |
| 284 |
|
| 285 |
|
| 286 |
#define AD9517_POWER_DOWN_CLK_INPUT_SECTION (1 << 4) |
| 287 |
#define AD9517_POWER_DOWN_VCO_CLK_INTERFACE (1 << 3) |
| 288 |
#define AD9517_POWER_DOWN_VCO_CLK (1 << 2) |
| 289 |
#define AD9517_SEL_VCO_CLK (1 << 1) |
| 290 |
#define AD9517_BYPASS_VCO_DIVIDER (1 << 0) |
| 291 |
|
| 292 |
|
| 293 |
#define AD9517_POWER_DOWN_SYNC (1 << 2) |
| 294 |
#define AD9517_POWER_DOWN_DIST_REF (1 << 1) |
| 295 |
#define AD9517_SOFT_SYNC (1 << 0) |
| 296 |
|
| 297 |
|
| 298 |
#define AD9517_UPDATE_ALL_REGS (1 << 0) |
| 299 |
|
| 300 |
#define AD9517_MIN_VCO_FREQ 1450000000 |
| 301 |
#define AD9517_MAX_VCO_FREQ 1800000000 |
| 302 |
#define AD9517_MAX_PFD_FREQ 100000000 |
| 303 |
#define AD9517_MAX_PRESCLAER_OUT_FREQ 300000000 |
| 304 |
|
| 305 |
|
| 306 |
struct ad9517_platform_data |
| 307 |
{ |
| 308 |
|
| 309 |
int32_t ref_1_freq; |
| 310 |
int32_t ref_2_freq; |
| 311 |
uint8_t diff_ref_en; |
| 312 |
uint8_t ref_1_power_on; |
| 313 |
uint8_t ref_2_power_on; |
| 314 |
uint8_t ref_sel_pin_en; |
| 315 |
uint8_t ref_sel_pin; |
| 316 |
uint8_t ref_2_en; |
| 317 |
|
| 318 |
|
| 319 |
int64_t ext_clk_freq; |
| 320 |
|
| 321 |
|
| 322 |
int64_t int_vco_freq; |
| 323 |
|
| 324 |
|
| 325 |
int32_t vco_clk_sel; |
| 326 |
|
| 327 |
uint8_t power_down_vco_clk; |
| 328 |
uint8_t name[16]; |
| 329 |
}; |
| 330 |
|
| 331 |
|
| 332 |
struct ad9517_lvpecl_channel_spec |
| 333 |
{ |
| 334 |
uint8_t channel_num; |
| 335 |
uint8_t out_invert_en; |
| 336 |
uint8_t out_diff_voltage; |
| 337 |
uint8_t name[16]; |
| 338 |
}; |
| 339 |
|
| 340 |
enum out_diff_voltage_options |
| 341 |
{ |
| 342 |
LVPECL_400mV, |
| 343 |
LVPECL_600mV, |
| 344 |
LVPECL_780mV, |
| 345 |
LVPECL_960mV, |
| 346 |
}; |
| 347 |
|
| 348 |
|
| 349 |
struct ad9517_lvds_cmos_channel_spec |
| 350 |
{ |
| 351 |
uint8_t channel_num; |
| 352 |
uint8_t out_invert; |
| 353 |
uint8_t logic_level; |
| 354 |
uint8_t cmos_b_en; |
| 355 |
uint8_t out_lvds_current; |
| 356 |
uint8_t name[16]; |
| 357 |
}; |
| 358 |
|
| 359 |
enum logic_level_options |
| 360 |
{ |
| 361 |
LVDS, |
| 362 |
CMOS |
| 363 |
}; |
| 364 |
|
| 365 |
enum out_lvds_current_options |
| 366 |
{ |
| 367 |
LVDS_1_75mA, |
| 368 |
LVDS_3_5mA, |
| 369 |
LVDS_5_25mA, |
| 370 |
LVDS_7mA, |
| 371 |
}; |
| 372 |
|
| 373 |
|
| 374 |
|
| 375 |
|
| 376 |
|
| 377 |
#ifdef OLD_VERSION |
| 378 |
int32_t ad9517_setup(int32_t spiBaseAddr, int32_t ssNo); |
| 379 |
#else |
| 380 |
int32_t ad9517_setup(uint32_t spi_device_id, uint8_t slave_select); |
| 381 |
#endif |
| 382 |
|
| 383 |
int32_t ad9517_write(uint32_t regAddr, uint16_t regVal); |
| 384 |
|
| 385 |
int32_t ad9517_read(uint32_t regAddr); |
| 386 |
|
| 387 |
int32_t ad9517_update(void); |
| 388 |
|
| 389 |
int64_t ad9517_vco_frequency(int64_t frequency); |
| 390 |
|
| 391 |
int64_t ad9517_frequency(int32_t channel, int64_t frequency); |
| 392 |
|
| 393 |
int32_t ad9517_phase(int32_t channel, int32_t phase); |
| 394 |
|
| 395 |
int32_t ad9517_power_mode(int32_t channel, int32_t mode); |
| 396 |
|
| 397 |
#endif |