| 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 |
#include <inttypes.h> |
| 44 |
#include <string.h> |
| 45 |
#include "ad9361.h" |
| 46 |
#include "platform.h" |
| 47 |
#include "config.h" |
| 48 |
|
| 49 |
#ifndef AXI_ADC_NOT_PRESENT |
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
int32_t ad9361_hdl_loopback(struct ad9361_rf_phy *phy, bool enable) |
| 57 |
{ |
| 58 |
struct axiadc_converter *conv = phy->adc_conv; |
| 59 |
struct axiadc_state *st = phy->adc_state; |
| 60 |
int32_t reg, addr, chan; |
| 61 |
|
| 62 |
uint32_t version = axiadc_read(st, 0x4000); |
| 63 |
|
| 64 |
|
| 65 |
if (PCORE_VERSION_MAJOR(version) > 7) |
| 66 |
addr = 0x4418; |
| 67 |
else |
| 68 |
addr = 0x4414; |
| 69 |
|
| 70 |
for (chan = 0; chan < conv->chip_info->num_channels; chan++) { |
| 71 |
reg = axiadc_read(st, addr + (chan) * 0x40); |
| 72 |
|
| 73 |
if (PCORE_VERSION_MAJOR(version) > 7) { |
| 74 |
if (enable && reg != 0x8) { |
| 75 |
conv->scratch_reg[chan] = reg; |
| 76 |
reg = 0x8; |
| 77 |
} else if (reg == 0x8) { |
| 78 |
reg = conv->scratch_reg[chan]; |
| 79 |
} |
| 80 |
} else { |
| 81 |
|
| 82 |
if (enable) |
| 83 |
reg |= BIT(1); |
| 84 |
else |
| 85 |
reg &= ~BIT(1); |
| 86 |
} |
| 87 |
axiadc_write(st, addr + (chan) * 0x40, reg); |
| 88 |
} |
| 89 |
|
| 90 |
return 0; |
| 91 |
} |
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
static int32_t ad9361_iodelay_set(struct axiadc_state *st, unsigned lane, |
| 102 |
unsigned val, bool tx) |
| 103 |
{ |
| 104 |
if (tx) { |
| 105 |
if (PCORE_VERSION_MAJOR(st->pcore_version) > 8) |
| 106 |
axiadc_write(st, 0x4000 + ADI_REG_DELAY(lane), val); |
| 107 |
else |
| 108 |
return -ENODEV; |
| 109 |
} else { |
| 110 |
axiadc_idelay_set(st, lane, val); |
| 111 |
} |
| 112 |
|
| 113 |
return 0; |
| 114 |
} |
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
static int32_t ad9361_midscale_iodelay(struct ad9361_rf_phy *phy, bool tx) |
| 123 |
{ |
| 124 |
struct axiadc_state *st = phy->adc_state; |
| 125 |
int32_t ret = 0, i; |
| 126 |
|
| 127 |
for (i = 0; i < 7; i++) |
| 128 |
ret |= ad9361_iodelay_set(st, i, 15, tx); |
| 129 |
|
| 130 |
return 0; |
| 131 |
} |
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
static int32_t ad9361_dig_tune_iodelay(struct ad9361_rf_phy *phy, bool tx) |
| 140 |
{ |
| 141 |
struct axiadc_converter *conv = phy->adc_conv; |
| 142 |
struct axiadc_state *st = phy->adc_state; |
| 143 |
int32_t ret, i, j, chan, num_chan; |
| 144 |
uint32_t s0, c0; |
| 145 |
uint8_t field[32]; |
| 146 |
|
| 147 |
num_chan = (conv->chip_info->num_channels > 4) ? 4 : conv->chip_info->num_channels; |
| 148 |
|
| 149 |
for (i = 0; i < 7; i++) { |
| 150 |
for (j = 0; j < 32; j++) { |
| 151 |
ad9361_iodelay_set(st, i, j, tx); |
| 152 |
mdelay(1); |
| 153 |
|
| 154 |
for (chan = 0; chan < num_chan; chan++) |
| 155 |
axiadc_write(st, ADI_REG_CHAN_STATUS(chan), |
| 156 |
ADI_PN_ERR | ADI_PN_OOS); |
| 157 |
mdelay(10); |
| 158 |
|
| 159 |
for (chan = 0, ret = 0; chan < num_chan; chan++) |
| 160 |
ret |= axiadc_read(st, ADI_REG_CHAN_STATUS(chan)); |
| 161 |
|
| 162 |
field[j] = ret; |
| 163 |
} |
| 164 |
|
| 165 |
c0 = ad9361_find_opt(&field[0], 32, &s0); |
| 166 |
ad9361_iodelay_set(st, i, s0 + c0 / 2, tx); |
| 167 |
|
| 168 |
dev_dbg(&phy->spi->dev, |
| 169 |
"%s Lane %"PRId32", window cnt %"PRIu32" , start %"PRIu32", IODELAY set to %"PRIu32"\n", |
| 170 |
tx ? "TX" :"RX", i , c0, s0, s0 + c0 / 2); |
| 171 |
} |
| 172 |
|
| 173 |
return 0; |
| 174 |
} |
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
static void ad9361_dig_tune_verbose_print(struct ad9361_rf_phy *phy, |
| 184 |
uint8_t field[][16], bool tx) |
| 185 |
{ |
| 186 |
int32_t i, j; |
| 187 |
|
| 188 |
printk("SAMPL CLK: %"PRIu32" tuning: %s\n", |
| 189 |
clk_get_rate(phy, phy->ref_clk_scale[RX_SAMPL_CLK]), tx ? "TX" : "RX"); |
| 190 |
printk(" "); |
| 191 |
for (i = 0; i < 16; i++) |
| 192 |
printk("%"PRIx32":", i); |
| 193 |
printk("\n"); |
| 194 |
|
| 195 |
for (i = 0; i < 2; i++) { |
| 196 |
printk("%"PRIx32":", i); |
| 197 |
for (j = 0; j < 16; j++) { |
| 198 |
printk("%c ", (field[i][j] ? '#' : 'o')); |
| 199 |
} |
| 200 |
printk("\n"); |
| 201 |
} |
| 202 |
printk("\n"); |
| 203 |
} |
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
int32_t ad9361_dig_interface_timing_analysis(struct ad9361_rf_phy *phy, |
| 213 |
char *buf, int32_t buflen) |
| 214 |
{ |
| 215 |
struct axiadc_state *st = phy->adc_state; |
| 216 |
int32_t ret, i, j, chan, len = 0; |
| 217 |
uint8_t field[16][16]; |
| 218 |
uint8_t rx; |
| 219 |
|
| 220 |
dev_dbg(&phy->spi->dev, "%s:\n", __func__); |
| 221 |
|
| 222 |
rx = ad9361_spi_read(phy->spi, REG_RX_CLOCK_DATA_DELAY); |
| 223 |
|
| 224 |
ad9361_bist_prbs(phy, BIST_INJ_RX); |
| 225 |
|
| 226 |
for (i = 0; i < 16; i++) { |
| 227 |
for (j = 0; j < 16; j++) { |
| 228 |
ad9361_spi_write(phy->spi, REG_RX_CLOCK_DATA_DELAY, |
| 229 |
DATA_CLK_DELAY(j) | RX_DATA_DELAY(i)); |
| 230 |
for (chan = 0; chan < 4; chan++) |
| 231 |
axiadc_write(st, ADI_REG_CHAN_STATUS(chan), |
| 232 |
ADI_PN_ERR | ADI_PN_OOS); |
| 233 |
|
| 234 |
mdelay(1); |
| 235 |
|
| 236 |
if (axiadc_read(st, ADI_REG_STATUS) & ADI_STATUS) { |
| 237 |
for (chan = 0, ret = 0; chan < 4; chan++) |
| 238 |
ret |= axiadc_read(st, ADI_REG_CHAN_STATUS(chan)); |
| 239 |
} |
| 240 |
else { |
| 241 |
ret = 1; |
| 242 |
} |
| 243 |
|
| 244 |
field[i][j] = ret; |
| 245 |
} |
| 246 |
} |
| 247 |
|
| 248 |
ad9361_spi_write(phy->spi, REG_RX_CLOCK_DATA_DELAY, rx); |
| 249 |
|
| 250 |
ad9361_bist_prbs(phy, BIST_DISABLE); |
| 251 |
|
| 252 |
len += snprintf(buf + len, buflen, "CLK: %"PRIu32" Hz 'o' = PASS\n", |
| 253 |
clk_get_rate(phy, phy->ref_clk_scale[RX_SAMPL_CLK])); |
| 254 |
len += snprintf(buf + len, buflen, "DC"); |
| 255 |
for (i = 0; i < 16; i++) |
| 256 |
len += snprintf(buf + len, buflen, "%"PRIx32":", i); |
| 257 |
len += snprintf(buf + len, buflen, "\n"); |
| 258 |
|
| 259 |
for (i = 0; i < 16; i++) { |
| 260 |
len += snprintf(buf + len, buflen, "%"PRIx32":", i); |
| 261 |
for (j = 0; j < 16; j++) { |
| 262 |
len += snprintf(buf + len, buflen, "%c ", |
| 263 |
(field[i][j] ? '.' : 'o')); |
| 264 |
} |
| 265 |
len += snprintf(buf + len, buflen, "\n"); |
| 266 |
} |
| 267 |
len += snprintf(buf + len, buflen, "\n"); |
| 268 |
|
| 269 |
return len; |
| 270 |
} |
| 271 |
|
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
|
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
int32_t ad9361_dig_tune(struct ad9361_rf_phy *phy, uint32_t max_freq, |
| 280 |
enum dig_tune_flags flags) |
| 281 |
{ |
| 282 |
struct axiadc_converter *conv = phy->adc_conv; |
| 283 |
struct axiadc_state *st = phy->adc_state; |
| 284 |
int32_t ret, i, j, k, chan, t, num_chan, err = 0; |
| 285 |
uint32_t s0, s1, c0, c1, tmp, saved = 0; |
| 286 |
uint8_t field[2][16]; |
| 287 |
uint32_t saved_dsel[4], saved_chan_ctrl6[4], saved_chan_ctrl0[4]; |
| 288 |
uint32_t rates[3] = {25000000U, 40000000U, 61440000U}; |
| 289 |
uint32_t hdl_dac_version; |
| 290 |
|
| 291 |
dev_dbg(&phy->spi->dev, "%s: freq %"PRIu32" flags 0x%X\n", __func__, |
| 292 |
max_freq, flags); |
| 293 |
|
| 294 |
hdl_dac_version = axiadc_read(st, 0x4000); |
| 295 |
|
| 296 |
if ((phy->pdata->dig_interface_tune_skipmode == 2) || |
| 297 |
(flags & RESTORE_DEFAULT)) { |
| 298 |
|
| 299 |
ad9361_spi_write(phy->spi, REG_RX_CLOCK_DATA_DELAY, |
| 300 |
phy->pdata->port_ctrl.rx_clk_data_delay); |
| 301 |
|
| 302 |
ad9361_spi_write(phy->spi, REG_TX_CLOCK_DATA_DELAY, |
| 303 |
phy->pdata->port_ctrl.tx_clk_data_delay); |
| 304 |
|
| 305 |
return 0; |
| 306 |
} |
| 307 |
|
| 308 |
|
| 309 |
ad9361_tx_mute(phy, 1); |
| 310 |
|
| 311 |
if (flags & DO_IDELAY) |
| 312 |
ad9361_midscale_iodelay(phy, 0); |
| 313 |
|
| 314 |
if (flags & DO_ODELAY) |
| 315 |
ad9361_midscale_iodelay(phy, 1); |
| 316 |
|
| 317 |
if (!phy->pdata->fdd) { |
| 318 |
ad9361_set_ensm_mode(phy, true, false); |
| 319 |
ad9361_ensm_force_state(phy, ENSM_STATE_FDD); |
| 320 |
} else { |
| 321 |
ad9361_ensm_force_state(phy, ENSM_STATE_ALERT); |
| 322 |
ad9361_ensm_restore_prev_state(phy); |
| 323 |
} |
| 324 |
|
| 325 |
num_chan = (conv->chip_info->num_channels > 4) ? 4 : |
| 326 |
conv->chip_info->num_channels; |
| 327 |
|
| 328 |
ad9361_bist_prbs(phy, BIST_INJ_RX); |
| 329 |
|
| 330 |
for (t = 0; t < 2; t++) { |
| 331 |
memset(field, 0, 32); |
| 332 |
for (k = 0; (uint32_t)k < (max_freq ? ARRAY_SIZE(rates) : 1); k++) { |
| 333 |
if (max_freq) |
| 334 |
ad9361_set_trx_clock_chain_freq(phy, |
| 335 |
((phy->pdata->port_ctrl.pp_conf[2] & LVDS_MODE) || !phy->pdata->rx2tx2) ? |
| 336 |
rates[k] : rates[k] / 2); |
| 337 |
for (i = 0; i < 2; i++) { |
| 338 |
for (j = 0; j < 16; j++) { |
| 339 |
ad9361_spi_write(phy->spi, |
| 340 |
REG_RX_CLOCK_DATA_DELAY + t, |
| 341 |
RX_DATA_DELAY(i == 0 ? j : 0) | |
| 342 |
DATA_CLK_DELAY(i ? j : 0)); |
| 343 |
for (chan = 0; chan < num_chan; chan++) |
| 344 |
axiadc_write(st, ADI_REG_CHAN_STATUS(chan), |
| 345 |
ADI_PN_ERR | ADI_PN_OOS); |
| 346 |
mdelay(4); |
| 347 |
|
| 348 |
if ((t == 1) || (axiadc_read(st, ADI_REG_STATUS) & ADI_STATUS)) { |
| 349 |
for (chan = 0, ret = 0; chan < num_chan; chan++) { |
| 350 |
ret |= axiadc_read(st, ADI_REG_CHAN_STATUS(chan)); |
| 351 |
} |
| 352 |
} |
| 353 |
else { |
| 354 |
ret = 1; |
| 355 |
} |
| 356 |
|
| 357 |
field[i][j] |= ret; |
| 358 |
} |
| 359 |
} |
| 360 |
if ((flags & BE_MOREVERBOSE) && max_freq) { |
| 361 |
ad9361_dig_tune_verbose_print(phy, field, t); |
| 362 |
} |
| 363 |
} |
| 364 |
|
| 365 |
c0 = ad9361_find_opt(&field[0][0], 16, &s0); |
| 366 |
c1 = ad9361_find_opt(&field[1][0], 16, &s1); |
| 367 |
|
| 368 |
if (!c0 && !c1) { |
| 369 |
ad9361_dig_tune_verbose_print(phy, field, t); |
| 370 |
dev_err(&phy->spi->dev, "%s: Tuning %s FAILED!", __func__, |
| 371 |
t ? "TX" : "RX"); |
| 372 |
err |= -EIO; |
| 373 |
} else if (flags & BE_VERBOSE) { |
| 374 |
ad9361_dig_tune_verbose_print(phy, field, t); |
| 375 |
} |
| 376 |
|
| 377 |
if (c1 > c0) |
| 378 |
ad9361_spi_write(phy->spi, REG_RX_CLOCK_DATA_DELAY + t, |
| 379 |
DATA_CLK_DELAY(s1 + c1 / 2) | |
| 380 |
RX_DATA_DELAY(0)); |
| 381 |
else |
| 382 |
ad9361_spi_write(phy->spi, REG_RX_CLOCK_DATA_DELAY + t, |
| 383 |
DATA_CLK_DELAY(0) | |
| 384 |
RX_DATA_DELAY(s0 + c0 / 2)); |
| 385 |
|
| 386 |
if (t == 0) { |
| 387 |
if (flags & DO_IDELAY) |
| 388 |
ad9361_dig_tune_iodelay(phy, 0); |
| 389 |
|
| 390 |
|
| 391 |
ad9361_bist_prbs(phy, BIST_DISABLE); |
| 392 |
|
| 393 |
axiadc_write(st, ADI_REG_RSTN, ADI_MMCM_RSTN); |
| 394 |
axiadc_write(st, ADI_REG_RSTN, ADI_RSTN | ADI_MMCM_RSTN); |
| 395 |
|
| 396 |
if (phy->pdata->dig_interface_tune_skipmode == 1) { |
| 397 |
|
| 398 |
if (!(flags & SKIP_STORE_RESULT)) |
| 399 |
phy->pdata->port_ctrl.rx_clk_data_delay = |
| 400 |
ad9361_spi_read(phy->spi, REG_RX_CLOCK_DATA_DELAY); |
| 401 |
|
| 402 |
if (!phy->pdata->fdd) { |
| 403 |
ad9361_set_ensm_mode(phy, phy->pdata->fdd, |
| 404 |
phy->pdata->ensm_pin_ctrl); |
| 405 |
ad9361_ensm_restore_prev_state(phy); |
| 406 |
} |
| 407 |
|
| 408 |
ad9361_tx_mute(phy, 0); |
| 409 |
|
| 410 |
return 0; |
| 411 |
} |
| 412 |
|
| 413 |
ad9361_bist_loopback(phy, 1); |
| 414 |
axiadc_write(st, 0x4000 + ADI_REG_RSTN, ADI_RSTN | ADI_MMCM_RSTN); |
| 415 |
|
| 416 |
for (chan = 0; chan < num_chan; chan++) { |
| 417 |
saved_chan_ctrl0[chan] = axiadc_read(st, ADI_REG_CHAN_CNTRL(chan)); |
| 418 |
axiadc_write(st, ADI_REG_CHAN_CNTRL(chan), |
| 419 |
ADI_FORMAT_SIGNEXT | ADI_FORMAT_ENABLE | |
| 420 |
ADI_ENABLE | ADI_IQCOR_ENB); |
| 421 |
axiadc_set_pnsel(st, chan, ADC_PN_CUSTOM); |
| 422 |
saved_chan_ctrl6[chan] = axiadc_read(st, 0x4414 + (chan) * 0x40); |
| 423 |
if (PCORE_VERSION_MAJOR(hdl_dac_version) > 7) |
| 424 |
{ |
| 425 |
saved_dsel[chan] = axiadc_read(st, 0x4418 + (chan) * 0x40); |
| 426 |
axiadc_write(st, 0x4418 + (chan) * 0x40, 9); |
| 427 |
axiadc_write(st, 0x4414 + (chan) * 0x40, 0); |
| 428 |
axiadc_write(st, 0x4044, 0x1); |
| 429 |
} |
| 430 |
else |
| 431 |
axiadc_write(st, 0x4414 + (chan) * 0x40, 1); |
| 432 |
|
| 433 |
} |
| 434 |
if (PCORE_VERSION_MAJOR(hdl_dac_version) < 8) { |
| 435 |
saved = tmp = axiadc_read(st, 0x4048); |
| 436 |
tmp &= ~0xF; |
| 437 |
tmp |= 1; |
| 438 |
axiadc_write(st, 0x4048, tmp); |
| 439 |
|
| 440 |
} |
| 441 |
} else { |
| 442 |
if (flags & DO_ODELAY) |
| 443 |
ad9361_dig_tune_iodelay(phy, 1); |
| 444 |
|
| 445 |
ad9361_bist_loopback(phy, 0); |
| 446 |
|
| 447 |
if (PCORE_VERSION_MAJOR(hdl_dac_version) < 8) |
| 448 |
axiadc_write(st, 0x4048, saved); |
| 449 |
|
| 450 |
for (chan = 0; chan < num_chan; chan++) { |
| 451 |
axiadc_write(st, ADI_REG_CHAN_CNTRL(chan), |
| 452 |
saved_chan_ctrl0[chan]); |
| 453 |
axiadc_set_pnsel(st, chan, ADC_PN9); |
| 454 |
if (PCORE_VERSION_MAJOR(hdl_dac_version) > 7) |
| 455 |
{ |
| 456 |
axiadc_write(st, 0x4418 + (chan) * 0x40, saved_dsel[chan]); |
| 457 |
axiadc_write(st, 0x4044, 0x1); |
| 458 |
} |
| 459 |
|
| 460 |
axiadc_write(st, 0x4414 + (chan) * 0x40, saved_chan_ctrl6[chan]); |
| 461 |
|
| 462 |
} |
| 463 |
|
| 464 |
if (err == -EIO) { |
| 465 |
ad9361_spi_write(phy->spi, REG_RX_CLOCK_DATA_DELAY, |
| 466 |
phy->pdata->port_ctrl.rx_clk_data_delay); |
| 467 |
|
| 468 |
ad9361_spi_write(phy->spi, REG_TX_CLOCK_DATA_DELAY, |
| 469 |
phy->pdata->port_ctrl.tx_clk_data_delay); |
| 470 |
if (!max_freq) |
| 471 |
err = 0; |
| 472 |
} else if (!(flags & SKIP_STORE_RESULT)) { |
| 473 |
phy->pdata->port_ctrl.rx_clk_data_delay = |
| 474 |
ad9361_spi_read(phy->spi, REG_RX_CLOCK_DATA_DELAY); |
| 475 |
phy->pdata->port_ctrl.tx_clk_data_delay = |
| 476 |
ad9361_spi_read(phy->spi, REG_TX_CLOCK_DATA_DELAY); |
| 477 |
} |
| 478 |
|
| 479 |
if (!phy->pdata->fdd) { |
| 480 |
ad9361_set_ensm_mode(phy, phy->pdata->fdd, phy->pdata->ensm_pin_ctrl); |
| 481 |
ad9361_ensm_restore_prev_state(phy); |
| 482 |
} |
| 483 |
|
| 484 |
axiadc_write(st, ADI_REG_RSTN, ADI_MMCM_RSTN); |
| 485 |
axiadc_write(st, ADI_REG_RSTN, ADI_RSTN | ADI_MMCM_RSTN); |
| 486 |
|
| 487 |
ad9361_tx_mute(phy, 0); |
| 488 |
|
| 489 |
return err; |
| 490 |
} |
| 491 |
} |
| 492 |
|
| 493 |
return -EINVAL; |
| 494 |
} |
| 495 |
|
| 496 |
|
| 497 |
|
| 498 |
|
| 499 |
|
| 500 |
|
| 501 |
int32_t ad9361_post_setup(struct ad9361_rf_phy *phy) |
| 502 |
{ |
| 503 |
struct axiadc_converter *conv = phy->adc_conv; |
| 504 |
struct axiadc_state *st = phy->adc_state; |
| 505 |
int32_t rx2tx2 = phy->pdata->rx2tx2; |
| 506 |
int32_t tmp, num_chan, flags; |
| 507 |
int32_t i, ret; |
| 508 |
|
| 509 |
num_chan = (conv->chip_info->num_channels > 4) ? 4 : conv->chip_info->num_channels; |
| 510 |
|
| 511 |
axiadc_write(st, ADI_REG_CNTRL, rx2tx2 ? 0 : ADI_R1_MODE); |
| 512 |
tmp = axiadc_read(st, 0x4048); |
| 513 |
|
| 514 |
if (!rx2tx2) { |
| 515 |
axiadc_write(st, 0x4048, tmp | BIT(5)); |
| 516 |
axiadc_write(st, 0x404c, |
| 517 |
(phy->pdata->port_ctrl.pp_conf[2] & LVDS_MODE) ? 1 : 0); |
| 518 |
} |
| 519 |
else { |
| 520 |
tmp &= ~BIT(5); |
| 521 |
axiadc_write(st, 0x4048, tmp); |
| 522 |
axiadc_write(st, 0x404c, |
| 523 |
(phy->pdata->port_ctrl.pp_conf[2] & LVDS_MODE) ? 3 : 1); |
| 524 |
} |
| 525 |
|
| 526 |
#ifdef ALTERA_PLATFORM |
| 527 |
axiadc_write(st, 0x404c, 1); |
| 528 |
#endif |
| 529 |
|
| 530 |
for (i = 0; i < num_chan; i++) { |
| 531 |
axiadc_write(st, ADI_REG_CHAN_CNTRL_1(i), |
| 532 |
ADI_DCFILT_OFFSET(0)); |
| 533 |
axiadc_write(st, ADI_REG_CHAN_CNTRL_2(i), |
| 534 |
(i & 1) ? 0x00004000 : 0x40000000); |
| 535 |
axiadc_write(st, ADI_REG_CHAN_CNTRL(i), |
| 536 |
ADI_FORMAT_SIGNEXT | ADI_FORMAT_ENABLE | |
| 537 |
ADI_ENABLE | ADI_IQCOR_ENB); |
| 538 |
} |
| 539 |
|
| 540 |
flags = 0x0; |
| 541 |
|
| 542 |
ret = ad9361_dig_tune(phy, ((conv->chip_info->num_channels > 4) || |
| 543 |
axiadc_read(st, 0x0004)) ? 0 : 61440000, flags); |
| 544 |
if (ret < 0) |
| 545 |
return ret; |
| 546 |
|
| 547 |
if (flags & (DO_IDELAY | DO_ODELAY)) { |
| 548 |
ret = ad9361_dig_tune(phy, (axiadc_read(st, ADI_REG_ID)) ? |
| 549 |
0 : 61440000, flags & BE_VERBOSE); |
| 550 |
if (ret < 0) |
| 551 |
return ret; |
| 552 |
} |
| 553 |
|
| 554 |
ret = ad9361_set_trx_clock_chain(phy, |
| 555 |
phy->pdata->rx_path_clks, |
| 556 |
phy->pdata->tx_path_clks); |
| 557 |
|
| 558 |
ad9361_ensm_force_state(phy, ENSM_STATE_ALERT); |
| 559 |
ad9361_ensm_restore_prev_state(phy); |
| 560 |
|
| 561 |
return ret; |
| 562 |
} |
| 563 |
#else |
| 564 |
|
| 565 |
|
| 566 |
|
| 567 |
|
| 568 |
|
| 569 |
|
| 570 |
int32_t ad9361_hdl_loopback(struct ad9361_rf_phy *phy, bool enable) |
| 571 |
{ |
| 572 |
return -ENODEV; |
| 573 |
} |
| 574 |
|
| 575 |
|
| 576 |
|
| 577 |
|
| 578 |
|
| 579 |
|
| 580 |
|
| 581 |
|
| 582 |
int32_t ad9361_dig_tune(struct ad9361_rf_phy *phy, uint32_t max_freq, |
| 583 |
enum dig_tune_flags flags) |
| 584 |
{ |
| 585 |
return 0; |
| 586 |
} |
| 587 |
|
| 588 |
|
| 589 |
|
| 590 |
|
| 591 |
|
| 592 |
|
| 593 |
int32_t ad9361_post_setup(struct ad9361_rf_phy *phy) |
| 594 |
{ |
| 595 |
return 0; |
| 596 |
} |
| 597 |
#endif |