| 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 |
|
| 43 |
|
| 44 |
#include "ad9528.h" |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
enum { |
| 50 |
AD9528_STAT_PLL1_LD, |
| 51 |
AD9528_STAT_PLL2_LD, |
| 52 |
AD9528_STAT_REFA, |
| 53 |
AD9528_STAT_REFB, |
| 54 |
AD9528_STAT_REFAB_MISSING, |
| 55 |
AD9528_STAT_VCXO, |
| 56 |
AD9528_STAT_PLL1_FB_CLK, |
| 57 |
AD9528_STAT_PLL2_FB_CLK, |
| 58 |
AD9528_SYNC, |
| 59 |
}; |
| 60 |
|
| 61 |
enum { |
| 62 |
AD9528_VCO, |
| 63 |
AD9528_VCXO, |
| 64 |
AD9528_NUM_CLK_SRC, |
| 65 |
}; |
| 66 |
|
| 67 |
struct ad9528_state |
| 68 |
{ |
| 69 |
uint32_t vco_out_freq[AD9528_NUM_CLK_SRC]; |
| 70 |
}ad9528_st; |
| 71 |
|
| 72 |
|
| 73 |
#define AD_IFE(_pde, _a, _b) ((pdata->_pde) ? _a : _b) |
| 74 |
#define AD_IF(_pde, _a) AD_IFE(_pde, _a, 0) |
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
int32_t ad9528_spi_read(spi_device *dev, |
| 86 |
uint32_t reg_addr, |
| 87 |
uint32_t *reg_data) |
| 88 |
{ |
| 89 |
uint8_t buf[3]; |
| 90 |
int32_t ret = 0; |
| 91 |
|
| 92 |
*reg_data = 0; |
| 93 |
buf[0] = 0x80 | (reg_addr >> 8); |
| 94 |
buf[1] = reg_addr & 0xFF; |
| 95 |
buf[2] = 0x00; |
| 96 |
ret = ad_spi_xfer(dev, buf, 3); |
| 97 |
*reg_data = buf[2]; |
| 98 |
|
| 99 |
return ret; |
| 100 |
} |
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
int32_t ad9528_spi_write(spi_device *dev, |
| 112 |
uint32_t reg_addr, |
| 113 |
uint32_t reg_data) |
| 114 |
{ |
| 115 |
uint8_t buf[3]; |
| 116 |
int32_t ret = 0; |
| 117 |
|
| 118 |
buf[0] = (uint8_t) reg_addr >> 8; |
| 119 |
buf[1] = (uint8_t) reg_addr & 0xFF; |
| 120 |
buf[2] = (uint8_t) reg_data; |
| 121 |
ret |= ad_spi_xfer(dev, buf, 3); |
| 122 |
|
| 123 |
return ret; |
| 124 |
} |
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
int32_t ad9528_spi_read_n(spi_device *dev, |
| 137 |
uint32_t reg_addr, |
| 138 |
uint32_t *reg_data) |
| 139 |
{ |
| 140 |
uint8_t buf[3]; |
| 141 |
int32_t ret = 0; |
| 142 |
uint8_t index; |
| 143 |
|
| 144 |
*reg_data = 0; |
| 145 |
for(index = 0; index < AD9528_TRANSF_LEN(reg_addr); index++) |
| 146 |
{ |
| 147 |
buf[0] = 0x80 | (reg_addr >> 8); |
| 148 |
buf[1] = reg_addr & 0xFF; |
| 149 |
buf[2] = 0x00; |
| 150 |
ret |= ad_spi_xfer(dev, buf, 3); |
| 151 |
reg_addr--; |
| 152 |
*reg_data <<= 8; |
| 153 |
*reg_data |= buf[2]; |
| 154 |
} |
| 155 |
|
| 156 |
return ret; |
| 157 |
} |
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
int32_t ad9528_spi_write_n(spi_device *dev, |
| 170 |
uint32_t reg_addr, |
| 171 |
uint32_t reg_data) |
| 172 |
{ |
| 173 |
uint8_t buf[3]; |
| 174 |
int32_t ret = 0; |
| 175 |
uint8_t index; |
| 176 |
|
| 177 |
for(index = 0; index < AD9528_TRANSF_LEN(reg_addr); index++) |
| 178 |
{ |
| 179 |
buf[0] = reg_addr >> 8; |
| 180 |
buf[1] = reg_addr & 0xFF; |
| 181 |
buf[2] = (reg_data >> ((AD9528_TRANSF_LEN(reg_addr) - index - 1) * 8)) & 0xFF; |
| 182 |
ret |= ad_spi_xfer(dev, buf, 3); |
| 183 |
reg_addr--; |
| 184 |
} |
| 185 |
|
| 186 |
return ret; |
| 187 |
} |
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
int32_t ad9528_poll(spi_device *dev, |
| 199 |
uint32_t reg_addr, |
| 200 |
uint32_t mask, |
| 201 |
uint32_t data) |
| 202 |
{ |
| 203 |
uint32_t reg_data; |
| 204 |
uint8_t timeout = 100; |
| 205 |
int32_t ret; |
| 206 |
|
| 207 |
do { |
| 208 |
ret = ad9528_spi_read_n(dev, reg_addr, ®_data); |
| 209 |
if (ret < 0) |
| 210 |
return ret; |
| 211 |
mdelay(1); |
| 212 |
} while (((reg_data & mask) != data) && --timeout); |
| 213 |
|
| 214 |
return timeout ? 0 : -1; |
| 215 |
|
| 216 |
return 0; |
| 217 |
} |
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
int32_t ad9528_io_update(spi_device *dev) |
| 225 |
{ |
| 226 |
return ad9528_spi_write_n(dev, AD9528_IO_UPDATE, AD9528_IO_UPDATE_EN); |
| 227 |
} |
| 228 |
|
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
int32_t ad9528_sync(spi_device *dev) |
| 235 |
{ |
| 236 |
int32_t ret; |
| 237 |
|
| 238 |
ret = ad9528_spi_write_n(dev, AD9528_CHANNEL_SYNC, AD9528_CHANNEL_SYNC_SET); |
| 239 |
if (ret < 0) |
| 240 |
return ret; |
| 241 |
|
| 242 |
ret = ad9528_io_update(dev); |
| 243 |
if (ret < 0) |
| 244 |
return ret; |
| 245 |
|
| 246 |
ret = ad9528_spi_write_n(dev, AD9528_CHANNEL_SYNC, 0); |
| 247 |
if (ret < 0) |
| 248 |
return ret; |
| 249 |
|
| 250 |
ret = ad9528_io_update(dev); |
| 251 |
if (ret < 0) |
| 252 |
return ret; |
| 253 |
|
| 254 |
if (ad9528_poll(dev, AD9528_READBACK, AD9528_VCXO_OK, AD9528_VCXO_OK) < 0) |
| 255 |
{ |
| 256 |
ret = -1; |
| 257 |
ad_printf("AD9528 VCXO missing!\n"); |
| 258 |
} |
| 259 |
|
| 260 |
if (ad9528_poll(dev, AD9528_READBACK, AD9528_PLL2_LOCKED, AD9528_PLL2_LOCKED) < 0) |
| 261 |
{ |
| 262 |
ret = -1; |
| 263 |
ad_printf("AD9528 PLL2 NOT locked!\n"); |
| 264 |
} |
| 265 |
|
| 266 |
return ret; |
| 267 |
} |
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
|
| 272 |
|
| 273 |
|
| 274 |
int32_t ad9528_init(ad9528_platform_data *pdata) |
| 275 |
{ |
| 276 |
uint32_t i; |
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
pdata->spi3wire = 0; |
| 281 |
pdata->ref_mode = 0; |
| 282 |
pdata->refa_en = 0; |
| 283 |
pdata->refa_diff_rcv_en = 0; |
| 284 |
pdata->refa_cmos_neg_inp_en = 0; |
| 285 |
pdata->refa_r_div = 1; |
| 286 |
pdata->refb_en = 0; |
| 287 |
pdata->refb_diff_rcv_en = 0; |
| 288 |
pdata->refb_cmos_neg_inp_en = 0; |
| 289 |
pdata->refb_r_div = 1; |
| 290 |
pdata->vcxo_freq = 0; |
| 291 |
pdata->osc_in_diff_en = 1; |
| 292 |
pdata->osc_in_cmos_neg_inp_en = 0; |
| 293 |
pdata->pll1_feedback_div = 1; |
| 294 |
pdata->pll1_feedback_src_vcxo = 1; |
| 295 |
pdata->pll1_charge_pump_current_nA = 5000; |
| 296 |
pdata->pll1_bypass_en = 0; |
| 297 |
pdata->pll2_charge_pump_current_nA = 805000; |
| 298 |
pdata->pll2_freq_doubler_en = 0; |
| 299 |
pdata->pll2_r1_div = 1; |
| 300 |
pdata->pll2_vco_diff_m1 = 1; |
| 301 |
pdata->pll2_ndiv_a_cnt = 1; |
| 302 |
pdata->pll2_ndiv_b_cnt = 1; |
| 303 |
pdata->pll2_n2_div = 1; |
| 304 |
pdata->sysref_src = SYSREF_SRC_INTERNAL; |
| 305 |
pdata->sysref_k_div = 512; |
| 306 |
pdata->rpole2 = RPOLE2_900_OHM; |
| 307 |
pdata->rzero= RZERO_1850_OHM; |
| 308 |
pdata->cpole1 = CPOLE1_16_PF; |
| 309 |
pdata->rzero_bypass_en = 0; |
| 310 |
|
| 311 |
for (i = 0; i < pdata->num_channels; i++) |
| 312 |
{ |
| 313 |
(&pdata->channels[i])->channel_num = 0; |
| 314 |
(&pdata->channels[i])->sync_ignore_en = 0; |
| 315 |
(&pdata->channels[i])->output_dis = 0; |
| 316 |
(&pdata->channels[i])->driver_mode = DRIVER_MODE_LVDS; |
| 317 |
(&pdata->channels[i])->signal_source = SOURCE_VCO; |
| 318 |
(&pdata->channels[i])->divider_phase = 0; |
| 319 |
(&pdata->channels[i])->channel_divider = 1; |
| 320 |
} |
| 321 |
|
| 322 |
return(0); |
| 323 |
} |
| 324 |
|
| 325 |
|
| 326 |
|
| 327 |
|
| 328 |
|
| 329 |
|
| 330 |
|
| 331 |
int32_t ad9528_setup(spi_device *dev, ad9528_platform_data *pdata) |
| 332 |
{ |
| 333 |
struct ad9528_state *st = &ad9528_st; |
| 334 |
ad9528_channel_spec *chan; |
| 335 |
uint32_t active_mask = 0; |
| 336 |
uint32_t ignoresync_mask = 0; |
| 337 |
uint32_t vco_freq; |
| 338 |
uint32_t vco_ctrl; |
| 339 |
uint32_t sysref_ctrl; |
| 340 |
uint32_t reg_data; |
| 341 |
int32_t ret, i; |
| 342 |
|
| 343 |
ret = ad9528_spi_write_n(dev, AD9528_SERIAL_PORT_CONFIG, |
| 344 |
AD9528_SER_CONF_SOFT_RESET | |
| 345 |
(pdata->spi3wire ? 0 : |
| 346 |
AD9528_SER_CONF_SDO_ACTIVE)); |
| 347 |
if (ret < 0) |
| 348 |
return ret; |
| 349 |
|
| 350 |
ret = ad9528_spi_write_n(dev, AD9528_SERIAL_PORT_CONFIG_B, |
| 351 |
AD9528_SER_CONF_READ_BUFFERED); |
| 352 |
if (ret < 0) |
| 353 |
return ret; |
| 354 |
|
| 355 |
ret = ad9528_io_update(dev); |
| 356 |
if (ret < 0) |
| 357 |
return ret; |
| 358 |
|
| 359 |
ret = ad9528_spi_read_n(dev, AD9528_CHIP_ID, ®_data); |
| 360 |
if (ret < 0) |
| 361 |
return ret; |
| 362 |
|
| 363 |
if ((reg_data & 0xFFFFFF) != AD9528_SPI_MAGIC) { |
| 364 |
ad_printf("AD9528 SPI Read Verify failed (0x%X).\n", reg_data); |
| 365 |
return -1; |
| 366 |
} |
| 367 |
|
| 368 |
|
| 369 |
|
| 370 |
|
| 371 |
ret = ad9528_spi_write_n(dev, AD9528_PLL1_REF_A_DIVIDER, |
| 372 |
pdata->refa_r_div); |
| 373 |
if (ret < 0) |
| 374 |
return ret; |
| 375 |
|
| 376 |
ret = ad9528_spi_write_n(dev, AD9528_PLL1_REF_B_DIVIDER, |
| 377 |
pdata->refb_r_div); |
| 378 |
if (ret < 0) |
| 379 |
return ret; |
| 380 |
|
| 381 |
ret = ad9528_spi_write_n(dev, AD9528_PLL1_FEEDBACK_DIVIDER, |
| 382 |
pdata->pll1_feedback_div); |
| 383 |
if (ret < 0) |
| 384 |
return ret; |
| 385 |
|
| 386 |
ret = ad9528_spi_write_n(dev, AD9528_PLL1_CHARGE_PUMP_CTRL, |
| 387 |
AD_IFE(pll1_bypass_en, AD9528_PLL1_CHARGE_PUMP_TRISTATE, |
| 388 |
AD9528_PLL1_CHARGE_PUMP_CURRENT_nA(pdata-> |
| 389 |
pll1_charge_pump_current_nA) | |
| 390 |
AD9528_PLL1_CHARGE_PUMP_MODE_NORMAL | |
| 391 |
AD9528_PLL1_CHARGE_PUMP_AUTO_TRISTATE_DIS)); |
| 392 |
if (ret < 0) |
| 393 |
return ret; |
| 394 |
|
| 395 |
ret = ad9528_spi_write_n(dev, AD9528_PLL1_CTRL, |
| 396 |
AD_IFE(pll1_bypass_en, |
| 397 |
AD_IF(osc_in_diff_en, AD9528_PLL1_OSC_IN_DIFF_EN) | |
| 398 |
AD_IF(osc_in_cmos_neg_inp_en, |
| 399 |
AD9528_PLL1_OSC_IN_CMOS_NEG_INP_EN) | |
| 400 |
AD9528_PLL1_REFB_BYPASS_EN | AD9528_PLL1_REFA_BYPASS_EN | |
| 401 |
AD9528_PLL1_FEEDBACK_BYPASS_EN, |
| 402 |
AD_IF(refa_en, AD9528_PLL1_REFA_RCV_EN) | |
| 403 |
AD_IF(refb_en, AD9528_PLL1_REFB_RCV_EN) | |
| 404 |
AD_IF(osc_in_diff_en, AD9528_PLL1_OSC_IN_DIFF_EN) | |
| 405 |
AD_IF(osc_in_cmos_neg_inp_en, |
| 406 |
AD9528_PLL1_OSC_IN_CMOS_NEG_INP_EN) | |
| 407 |
AD_IF(refa_diff_rcv_en, AD9528_PLL1_REFA_DIFF_RCV_EN) | |
| 408 |
AD_IF(refb_diff_rcv_en, AD9528_PLL1_REFB_DIFF_RCV_EN)) | |
| 409 |
AD_IF(refa_cmos_neg_inp_en, AD9528_PLL1_REFA_CMOS_NEG_INP_EN) | |
| 410 |
AD_IF(refb_cmos_neg_inp_en, AD9528_PLL1_REFB_CMOS_NEG_INP_EN) | |
| 411 |
AD_IF(pll1_feedback_src_vcxo, AD9528_PLL1_SOURCE_VCXO) | |
| 412 |
AD9528_PLL1_REF_MODE(pdata->ref_mode)); |
| 413 |
if (ret < 0) |
| 414 |
return ret; |
| 415 |
|
| 416 |
|
| 417 |
|
| 418 |
|
| 419 |
|
| 420 |
ret = ad9528_spi_write_n(dev, AD9528_PLL2_CHARGE_PUMP, |
| 421 |
AD9528_PLL2_CHARGE_PUMP_CURRENT_nA(pdata-> |
| 422 |
pll2_charge_pump_current_nA)); |
| 423 |
if (ret < 0) |
| 424 |
return ret; |
| 425 |
|
| 426 |
ret = ad9528_spi_write_n(dev, AD9528_PLL2_FEEDBACK_DIVIDER_AB, |
| 427 |
AD9528_PLL2_FB_NDIV_A_CNT(pdata->pll2_ndiv_a_cnt) | |
| 428 |
AD9528_PLL2_FB_NDIV_B_CNT(pdata->pll2_ndiv_b_cnt)); |
| 429 |
if (ret < 0) |
| 430 |
return ret; |
| 431 |
|
| 432 |
ret = ad9528_spi_write_n(dev, AD9528_PLL2_CTRL, |
| 433 |
AD9528_PLL2_CHARGE_PUMP_MODE_NORMAL | |
| 434 |
AD_IF(pll2_freq_doubler_en, AD9528_PLL2_FREQ_DOUBLER_EN)); |
| 435 |
if (ret < 0) |
| 436 |
return ret; |
| 437 |
|
| 438 |
vco_freq = (pdata->vcxo_freq * (pdata->pll2_freq_doubler_en ? 2 : 1) |
| 439 |
/ pdata->pll2_r1_div) * AD9528_PLL2_FB_NDIV(pdata-> |
| 440 |
pll2_ndiv_a_cnt, pdata->pll2_ndiv_b_cnt); |
| 441 |
|
| 442 |
vco_ctrl = AD_IF(pll2_freq_doubler_en || pdata->pll2_r1_div != 1, |
| 443 |
AD9528_PLL2_DOUBLER_R1_EN); |
| 444 |
ret = ad9528_spi_write_n(dev, AD9528_PLL2_VCO_CTRL, vco_ctrl); |
| 445 |
if (ret < 0) |
| 446 |
return ret; |
| 447 |
|
| 448 |
ret = ad9528_spi_write_n(dev, AD9528_PLL2_VCO_DIVIDER, |
| 449 |
AD9528_PLL2_VCO_DIV_M1(pdata->pll2_vco_diff_m1) | |
| 450 |
AD_IFE(pll2_vco_diff_m1, 0, |
| 451 |
AD9528_PLL2_VCO_DIV_M1_PWR_DOWN_EN)); |
| 452 |
if (ret < 0) |
| 453 |
return ret; |
| 454 |
|
| 455 |
if (pdata->pll2_vco_diff_m1) |
| 456 |
st->vco_out_freq[AD9528_VCO] = |
| 457 |
vco_freq / pdata->pll2_vco_diff_m1; |
| 458 |
else |
| 459 |
st->vco_out_freq[AD9528_VCO] = vco_freq; |
| 460 |
|
| 461 |
st->vco_out_freq[AD9528_VCXO] = pdata->vcxo_freq; |
| 462 |
|
| 463 |
ret = ad9528_spi_write_n(dev, AD9528_PLL2_R1_DIVIDER, |
| 464 |
AD9528_PLL2_R1_DIV(pdata->pll2_r1_div)); |
| 465 |
if (ret < 0) |
| 466 |
return ret; |
| 467 |
|
| 468 |
ret = ad9528_spi_write_n(dev, AD9528_PLL2_N2_DIVIDER, |
| 469 |
AD9528_PLL2_N2_DIV(pdata->pll2_n2_div)); |
| 470 |
if (ret < 0) |
| 471 |
return ret; |
| 472 |
|
| 473 |
ret = ad9528_spi_write_n(dev, AD9528_PLL2_LOOP_FILTER_CTRL, |
| 474 |
AD9528_PLL2_LOOP_FILTER_CPOLE1(pdata->cpole1) | |
| 475 |
AD9528_PLL2_LOOP_FILTER_RZERO(pdata->rzero) | |
| 476 |
AD9528_PLL2_LOOP_FILTER_RPOLE2(pdata->rpole2) | |
| 477 |
AD_IF(rzero_bypass_en, |
| 478 |
AD9528_PLL2_LOOP_FILTER_RZERO_BYPASS_EN)); |
| 479 |
if (ret < 0) |
| 480 |
return ret; |
| 481 |
|
| 482 |
|
| 483 |
for (i = 0; i < pdata->num_channels; i++) { |
| 484 |
chan = &pdata->channels[i]; |
| 485 |
|
| 486 |
if (chan->output_dis) |
| 487 |
continue; |
| 488 |
|
| 489 |
if (chan->channel_num < AD9528_NUM_CHAN) { |
| 490 |
active_mask |= (1 << chan->channel_num); |
| 491 |
if (chan->sync_ignore_en) |
| 492 |
ignoresync_mask |= (1 << chan->channel_num); |
| 493 |
|
| 494 |
ret = ad9528_spi_write_n(dev, |
| 495 |
AD9528_CHANNEL_OUTPUT(chan->channel_num), |
| 496 |
AD9528_CLK_DIST_DRIVER_MODE(chan->driver_mode) | |
| 497 |
AD9528_CLK_DIST_DIV(chan->channel_divider) | |
| 498 |
AD9528_CLK_DIST_DIV_PHASE(chan->divider_phase) | |
| 499 |
AD9528_CLK_DIST_CTRL(chan->signal_source)); |
| 500 |
if (ret < 0) |
| 501 |
return ret; |
| 502 |
} |
| 503 |
} |
| 504 |
|
| 505 |
ret = ad9528_spi_write_n(dev, AD9528_CHANNEL_PD_EN, |
| 506 |
AD9528_CHANNEL_PD_MASK(~active_mask)); |
| 507 |
if (ret < 0) |
| 508 |
return ret; |
| 509 |
|
| 510 |
ret = ad9528_spi_write_n(dev, AD9528_CHANNEL_SYNC_IGNORE, |
| 511 |
AD9528_CHANNEL_IGNORE_MASK(ignoresync_mask)); |
| 512 |
if (ret < 0) |
| 513 |
return ret; |
| 514 |
|
| 515 |
ret = ad9528_spi_write_n(dev, AD9528_SYSREF_K_DIVIDER, |
| 516 |
AD9528_SYSREF_K_DIV(pdata->sysref_k_div)); |
| 517 |
if (ret < 0) |
| 518 |
return ret; |
| 519 |
|
| 520 |
sysref_ctrl = AD9528_SYSREF_PATTERN_MODE(SYSREF_PATTERN_CONTINUOUS) | |
| 521 |
AD9528_SYSREF_SOURCE(pdata->sysref_src); |
| 522 |
ret = ad9528_spi_write_n(dev, AD9528_SYSREF_CTRL, sysref_ctrl); |
| 523 |
if (ret < 0) |
| 524 |
return ret; |
| 525 |
|
| 526 |
ret = ad9528_spi_write_n(dev, AD9528_PD_EN, AD9528_PD_BIAS); |
| 527 |
if (ret < 0) |
| 528 |
return ret; |
| 529 |
|
| 530 |
ret = ad9528_io_update(dev); |
| 531 |
if (ret < 0) |
| 532 |
return ret; |
| 533 |
|
| 534 |
ret = ad9528_spi_write_n(dev, AD9528_PLL2_VCO_CTRL, |
| 535 |
vco_ctrl | AD9528_PLL2_VCO_CALIBRATE); |
| 536 |
if (ret < 0) |
| 537 |
return ret; |
| 538 |
|
| 539 |
ret = ad9528_io_update(dev); |
| 540 |
if (ret < 0) |
| 541 |
return ret; |
| 542 |
|
| 543 |
ret = ad9528_poll(dev, AD9528_READBACK, |
| 544 |
AD9528_IS_CALIBRATING, 0); |
| 545 |
if (ret < 0) |
| 546 |
return ret; |
| 547 |
|
| 548 |
sysref_ctrl |= AD9528_SYSREF_PATTERN_REQ; |
| 549 |
ret = ad9528_spi_write_n(dev, AD9528_SYSREF_CTRL, sysref_ctrl); |
| 550 |
if (ret < 0) |
| 551 |
return ret; |
| 552 |
|
| 553 |
ret = ad9528_io_update(dev); |
| 554 |
if (ret < 0) |
| 555 |
return ret; |
| 556 |
|
| 557 |
ret = ad9528_sync(dev); |
| 558 |
if (ret < 0) |
| 559 |
return ret; |
| 560 |
|
| 561 |
return 0; |
| 562 |
} |