| 1 |
diff --git a/ad9361/sw/ad9361.c b/ad9361/sw/ad9361.c |
| 2 |
index fb41cec..b82d6f3 100644 |
| 3 |
--- a/ad9361/sw/ad9361.c |
| 4 |
+++ b/ad9361/sw/ad9361.c |
| 5 |
@@ -577,7 +577,15 @@ int32_t ad9361_spi_readm(struct spi_device *spi, uint32_t reg, |
| 6 |
buf[0] = cmd >> 8; |
| 7 |
buf[1] = cmd & 0xFF; |
| 8 |
|
| 9 |
+#ifdef NUAND_MODIFICATIONS |
| 10 |
+ // no-op to clear warning |
| 11 |
+ buf[0] = buf[1]; |
| 12 |
+ |
| 13 |
+ // use alternate spi_read |
| 14 |
+ ret = spi_read(spi, cmd, rbuf, num); |
| 15 |
+#else |
| 16 |
ret = spi_write_then_read(spi, &buf[0], 2, rbuf, num); |
| 17 |
+#endif // NUAND_MODIFICATIONS |
| 18 |
if (ret < 0) { |
| 19 |
dev_err(&spi->dev, "Read Error %"PRId32, ret); |
| 20 |
return ret; |
| 21 |
@@ -668,7 +676,13 @@ int32_t ad9361_spi_write(struct spi_device *spi, |
| 22 |
buf[1] = cmd & 0xFF; |
| 23 |
buf[2] = val; |
| 24 |
|
| 25 |
+#ifdef NUAND_MODIFICATIONS |
| 26 |
+ // use alternate spi_write |
| 27 |
+ ret = spi_write(spi, cmd, &(buf[2]), 1); |
| 28 |
+#else |
| 29 |
ret = spi_write_then_read(spi, buf, 3, NULL, 0); |
| 30 |
+#endif // NUAND_MODIFICATIONS |
| 31 |
+ |
| 32 |
if (ret < 0) { |
| 33 |
dev_err(&spi->dev, "Write Error %"PRId32, ret); |
| 34 |
return ret; |
| 35 |
@@ -749,7 +763,17 @@ static int32_t ad9361_spi_writem(struct spi_device *spi, |
| 36 |
for (i = 0; i < num; i++) |
| 37 |
buf[2 + i] = tbuf[i]; |
| 38 |
#endif |
| 39 |
+ |
| 40 |
+#ifdef NUAND_MODIFICATIONS |
| 41 |
+ // no-op to clear warning |
| 42 |
+ buf[0] = buf[1]; |
| 43 |
+ |
| 44 |
+ // use alternate spi_write |
| 45 |
+ ret = spi_write(spi, cmd, tbuf, num); |
| 46 |
+#else |
| 47 |
ret = spi_write_then_read(spi, buf, num + 2, NULL, 0); |
| 48 |
+#endif // NUAND_MODIFICATIONS |
| 49 |
+ |
| 50 |
if (ret < 0) { |
| 51 |
dev_err(&spi->dev, "Write Error %"PRId32, ret); |
| 52 |
return ret; |
| 53 |
@@ -814,11 +838,22 @@ int32_t ad9361_find_opt(uint8_t *field, uint32_t size, uint32_t *ret_start) |
| 54 |
{ |
| 55 |
int32_t i, cnt = 0, max_cnt = 0, start, max_start = 0; |
| 56 |
|
| 57 |
+#ifdef NUAND_MODIFICATIONS |
| 58 |
+ // add check for failed optimal value search |
| 59 |
+ bool found_0 = false; |
| 60 |
+ bool found_1 = false; |
| 61 |
+#endif // NUAND_MODIFICATIONS |
| 62 |
+ |
| 63 |
for(i = 0, start = -1; i < (int64_t)size; i++) { |
| 64 |
if (field[i] == 0) { |
| 65 |
if (start == -1) |
| 66 |
start = i; |
| 67 |
cnt++; |
| 68 |
+ |
| 69 |
+#ifdef NUAND_MODIFICATIONS |
| 70 |
+ found_0 = true; |
| 71 |
+#endif // NUAND_MODIFICATIONS |
| 72 |
+ |
| 73 |
} else { |
| 74 |
if (cnt > max_cnt) { |
| 75 |
max_cnt = cnt; |
| 76 |
@@ -826,6 +861,11 @@ int32_t ad9361_find_opt(uint8_t *field, uint32_t size, uint32_t *ret_start) |
| 77 |
} |
| 78 |
start = -1; |
| 79 |
cnt = 0; |
| 80 |
+ |
| 81 |
+#ifdef NUAND_MODIFICATIONS |
| 82 |
+ found_1 = true; |
| 83 |
+#endif // NUAND_MODIFICATIONS |
| 84 |
+ |
| 85 |
} |
| 86 |
} |
| 87 |
|
| 88 |
@@ -836,6 +876,13 @@ int32_t ad9361_find_opt(uint8_t *field, uint32_t size, uint32_t *ret_start) |
| 89 |
|
| 90 |
*ret_start = max_start; |
| 91 |
|
| 92 |
+#ifdef NUAND_MODIFICATIONS |
| 93 |
+ if (!found_0 || !found_1) { |
| 94 |
+ // All of the values were the same. This is not a healthy result. |
| 95 |
+ return -1; |
| 96 |
+ } |
| 97 |
+#endif // NUAND_MODIFICATIONS |
| 98 |
+ |
| 99 |
return max_cnt; |
| 100 |
} |
| 101 |
|
| 102 |
@@ -871,6 +918,17 @@ int32_t ad9361_1rx1tx_channel_map(struct ad9361_rf_phy *phy, bool tx, int32_t ch |
| 103 |
*/ |
| 104 |
int32_t ad9361_reset(struct ad9361_rf_phy *phy) |
| 105 |
{ |
| 106 |
+#ifdef NUAND_MODIFICATIONS |
| 107 |
+ // use alternate gpio accessors |
| 108 |
+ if (gpio_is_valid(phy->gpio, phy->pdata->gpio_resetb)) { |
| 109 |
+ gpio_set_value(phy->gpio, phy->pdata->gpio_resetb, 0); |
| 110 |
+ mdelay(1); |
| 111 |
+ gpio_set_value(phy->gpio, phy->pdata->gpio_resetb, 1); |
| 112 |
+ mdelay(1); |
| 113 |
+ dev_dbg(&phy->spi->dev, "%s: by GPIO", __func__); |
| 114 |
+ return 0; |
| 115 |
+ } |
| 116 |
+#else |
| 117 |
if (gpio_is_valid(phy->pdata->gpio_resetb)) { |
| 118 |
gpio_set_value(phy->pdata->gpio_resetb, 0); |
| 119 |
mdelay(1); |
| 120 |
@@ -879,6 +937,7 @@ int32_t ad9361_reset(struct ad9361_rf_phy *phy) |
| 121 |
dev_dbg(&phy->spi->dev, "%s: by GPIO", __func__); |
| 122 |
return 0; |
| 123 |
} |
| 124 |
+#endif // NUAND_MODIFICATIONS |
| 125 |
|
| 126 |
/* SPI Soft Reset was removed from the register map, since it doesn't |
| 127 |
* work reliably. Without a prober HW reset randomness may happen. |
| 128 |
@@ -3378,7 +3437,17 @@ static int32_t ad9361_pp_port_setup(struct ad9361_rf_phy *phy, bool restore_c3) |
| 129 |
ad9361_spi_write(spi, REG_RX_CLOCK_DATA_DELAY, pd->port_ctrl.rx_clk_data_delay); |
| 130 |
ad9361_spi_write(spi, REG_TX_CLOCK_DATA_DELAY, pd->port_ctrl.tx_clk_data_delay); |
| 131 |
|
| 132 |
+#ifdef NUAND_MODIFICATIONS |
| 133 |
+ // set up digital interface slew and drive strength |
| 134 |
+ ad9361_spi_write(spi, REG_LVDS_BIAS_CTRL, pd->port_ctrl.lvds_bias_ctrl | CLK_OUT_SLEW(pd->port_ctrl.clk_out_slew)); |
| 135 |
+ ad9361_spi_write(spi, REG_DIGITAL_IO_CTRL, DATACLK_SLEW(pd->port_ctrl.dataclk_slew) | DATA_PORT_SLEW(pd->port_ctrl.data_port_slew)); |
| 136 |
+ ad9361_spi_writef(spi, REG_DIGITAL_IO_CTRL, DATACLK_DRIVE, pd->port_ctrl.dataclk_drive); |
| 137 |
+ ad9361_spi_writef(spi, REG_DIGITAL_IO_CTRL, DATA_PORT_DRIVE, pd->port_ctrl.data_port_drive); |
| 138 |
+ ad9361_spi_writef(spi, REG_DIGITAL_IO_CTRL, CLK_OUT_DRIVE, pd->port_ctrl.clk_out_drive); |
| 139 |
+#else |
| 140 |
ad9361_spi_write(spi, REG_LVDS_BIAS_CTRL, pd->port_ctrl.lvds_bias_ctrl); |
| 141 |
+#endif // NUAND_MODIFICATIONS |
| 142 |
+ |
| 143 |
// ad9361_spi_write(spi, REG_DIGITAL_IO_CTRL, pd->port_ctrl.digital_io_ctrl); |
| 144 |
ad9361_spi_write(spi, REG_LVDS_INVERT_CTRL1, pd->port_ctrl.lvds_invert[0]); |
| 145 |
ad9361_spi_write(spi, REG_LVDS_INVERT_CTRL2, pd->port_ctrl.lvds_invert[1]); |
| 146 |
@@ -4893,26 +4962,49 @@ int32_t ad9361_mcs(struct ad9361_rf_phy *phy, int32_t step) |
| 147 |
MCS_REFCLK_SCALE_EN, 1); |
| 148 |
break; |
| 149 |
case 2: |
| 150 |
+#ifdef NUAND_MODIFICATIONS |
| 151 |
+ // use alternate gpio accessors |
| 152 |
+ if(!gpio_is_valid(phy->gpio, phy->pdata->gpio_sync)) |
| 153 |
+ break; |
| 154 |
+#else |
| 155 |
if(!gpio_is_valid(phy->pdata->gpio_sync)) |
| 156 |
break; |
| 157 |
+#endif // NUAND_MODIFICATIONS |
| 158 |
/* |
| 159 |
* NOTE: This is not a regular GPIO - |
| 160 |
* HDL ensures Multi-chip Synchronization SYNC_IN Pulse Timing |
| 161 |
* relative to rising and falling edge of REF_CLK |
| 162 |
*/ |
| 163 |
+#ifdef NUAND_MODIFICATIONS |
| 164 |
+ // use alternate gpio accessors |
| 165 |
+ if(!gpio_is_valid(phy->gpio, phy->pdata->gpio_sync)) |
| 166 |
+ break; |
| 167 |
+ gpio_set_value(phy->gpio, phy->pdata->gpio_sync, 1); |
| 168 |
+ gpio_set_value(phy->gpio, phy->pdata->gpio_sync, 0); |
| 169 |
+#else |
| 170 |
gpio_set_value(phy->pdata->gpio_sync, 1); |
| 171 |
gpio_set_value(phy->pdata->gpio_sync, 0); |
| 172 |
break; |
| 173 |
+#endif // NUAND_MODIFICATIONS |
| 174 |
case 3: |
| 175 |
ad9361_spi_writef(phy->spi, REG_MULTICHIP_SYNC_AND_TX_MON_CTRL, |
| 176 |
mcs_mask, MCS_BB_ENABLE | MCS_DIGITAL_CLK_ENABLE | MCS_RF_ENABLE); |
| 177 |
break; |
| 178 |
case 4: |
| 179 |
+#ifdef NUAND_MODIFICATIONS |
| 180 |
+ // use alternate gpio accessors |
| 181 |
+ if(!gpio_is_valid(phy->gpio, phy->pdata->gpio_sync)) |
| 182 |
+ break; |
| 183 |
+ gpio_set_value(phy->gpio, phy->pdata->gpio_sync, 1); |
| 184 |
+ gpio_set_value(phy->gpio, phy->pdata->gpio_sync, 0); |
| 185 |
+ break; |
| 186 |
+#else |
| 187 |
if(!gpio_is_valid(phy->pdata->gpio_sync)) |
| 188 |
break; |
| 189 |
gpio_set_value(phy->pdata->gpio_sync, 1); |
| 190 |
gpio_set_value(phy->pdata->gpio_sync, 0); |
| 191 |
break; |
| 192 |
+#endif // NUAND_MODIFICATIONS |
| 193 |
case 5: |
| 194 |
ad9361_spi_writef(phy->spi, REG_MULTICHIP_SYNC_AND_TX_MON_CTRL, |
| 195 |
mcs_mask, MCS_RF_ENABLE); |
| 196 |
@@ -5758,10 +5850,20 @@ int32_t ad9361_validate_enable_fir(struct ad9361_rf_phy *phy) |
| 197 |
#else |
| 198 |
int32_t i; |
| 199 |
uint32_t num; |
| 200 |
+#ifdef NUAND_MODIFICATIONS |
| 201 |
+ // fix memory overrun :x |
| 202 |
+ num = sizeof(rx)/sizeof(rx[0]); |
| 203 |
+#else |
| 204 |
num = sizeof(rx); |
| 205 |
+#endif // NUAND_MODIFICATIONS |
| 206 |
for (i = 0; i < num; i++) |
| 207 |
rx[i] = phy->filt_rx_path_clks[i]; |
| 208 |
+#ifdef NUAND_MODIFICATIONS |
| 209 |
+ // fix memory overrun :x |
| 210 |
+ num = sizeof(tx)/sizeof(tx[0]); |
| 211 |
+#else |
| 212 |
num = sizeof(tx); |
| 213 |
+#endif // NUAND_MODIFICATIONS |
| 214 |
for (i = 0; i < num; i++) |
| 215 |
tx[i] = phy->filt_tx_path_clks[i]; |
| 216 |
#endif |
| 217 |
diff --git a/ad9361/sw/ad9361.h b/ad9361/sw/ad9361.h |
| 218 |
index 376978d..03aea32 100644 |
| 219 |
--- a/ad9361/sw/ad9361.h |
| 220 |
+++ b/ad9361/sw/ad9361.h |
| 221 |
@@ -3042,6 +3042,15 @@ struct port_control { |
| 222 |
uint8_t digital_io_ctrl; |
| 223 |
uint8_t lvds_bias_ctrl; |
| 224 |
uint8_t lvds_invert[2]; |
| 225 |
+#ifdef NUAND_MODIFICATIONS |
| 226 |
+ // add digital interface drive and clock skew |
| 227 |
+ uint8_t clk_out_drive; |
| 228 |
+ uint8_t dataclk_drive; |
| 229 |
+ uint8_t data_port_drive; |
| 230 |
+ uint8_t clk_out_slew; |
| 231 |
+ uint8_t dataclk_slew; |
| 232 |
+ uint8_t data_port_slew; |
| 233 |
+#endif // NUAND_MODIFICATIONS |
| 234 |
}; |
| 235 |
|
| 236 |
struct ctrl_outs_control { |
| 237 |
@@ -3115,7 +3124,12 @@ enum ad9361_pdata_rx_freq { |
| 238 |
}; |
| 239 |
|
| 240 |
enum ad9361_pdata_tx_freq { |
| 241 |
+#ifdef NUAND_MODIFICATIONS |
| 242 |
+ // this is a name conflict on some platforms |
| 243 |
+ IGNORE_FREQ, |
| 244 |
+#else |
| 245 |
IGNORE, |
| 246 |
+#endif // NUAND_MODIFICATIONS |
| 247 |
DAC_FREQ, |
| 248 |
T2_FREQ, |
| 249 |
T1_FREQ, |
| 250 |
@@ -3310,6 +3324,10 @@ struct ad9361_rf_phy { |
| 251 |
enum dev_id dev_sel; |
| 252 |
uint8_t id_no; |
| 253 |
struct spi_device *spi; |
| 254 |
+#ifdef NUAND_MODIFICATIONS |
| 255 |
+ // add gpio device struct |
| 256 |
+ struct gpio_device *gpio; |
| 257 |
+#endif // NUAND_MODIFICATIONS |
| 258 |
struct clk *clk_refin; |
| 259 |
struct clk *clks[NUM_AD9361_CLKS]; |
| 260 |
struct refclk_scale *ref_clk_scale[NUM_AD9361_CLKS]; |
| 261 |
diff --git a/ad9361/sw/ad9361_api.c b/ad9361/sw/ad9361_api.c |
| 262 |
index f565163..180315d 100644 |
| 263 |
--- a/ad9361/sw/ad9361_api.c |
| 264 |
+++ b/ad9361/sw/ad9361_api.c |
| 265 |
@@ -72,7 +72,12 @@ static struct axiadc_chip_info axiadc_chip_info_tbl[] = |
| 266 |
* |
| 267 |
* Note: This function will/may affect the data path. |
| 268 |
*/ |
| 269 |
+#ifdef NUAND_MODIFICATIONS |
| 270 |
+// add *userdata parameter |
| 271 |
+int32_t ad9361_init (struct ad9361_rf_phy **ad9361_phy, AD9361_InitParam *init_param, void *userdata) |
| 272 |
+#else |
| 273 |
int32_t ad9361_init (struct ad9361_rf_phy **ad9361_phy, AD9361_InitParam *init_param) |
| 274 |
+#endif // NUAND_MODIFICATIONS |
| 275 |
{ |
| 276 |
struct ad9361_rf_phy *phy; |
| 277 |
int32_t ret = 0; |
| 278 |
@@ -89,6 +94,14 @@ int32_t ad9361_init (struct ad9361_rf_phy **ad9361_phy, AD9361_InitParam *init_p |
| 279 |
return -ENOMEM; |
| 280 |
} |
| 281 |
|
| 282 |
+#ifdef NUAND_MODIFICATIONS |
| 283 |
+ // allocate gpio struct |
| 284 |
+ phy->gpio = (struct gpio_device *)zmalloc(sizeof(*phy->gpio)); |
| 285 |
+ if (!phy->gpio) { |
| 286 |
+ return -ENOMEM; |
| 287 |
+ } |
| 288 |
+#endif // NUAND_MODIFICATIONS |
| 289 |
+ |
| 290 |
phy->clk_refin = (struct clk *)zmalloc(sizeof(*phy->clk_refin)); |
| 291 |
if (!phy->clk_refin) { |
| 292 |
return -ENOMEM; |
| 293 |
@@ -111,6 +124,15 @@ int32_t ad9361_init (struct ad9361_rf_phy **ad9361_phy, AD9361_InitParam *init_p |
| 294 |
phy->adc_state->phy = phy; |
| 295 |
#endif |
| 296 |
|
| 297 |
+#ifdef NUAND_MODIFICATIONS |
| 298 |
+ /* Ensure phy->clks and phy->ref_clk_scale are adequately nulled */ |
| 299 |
+ for (size_t i = 0; i < NUM_AD9361_CLKS; ++i) { |
| 300 |
+ phy->clks[i] = NULL; |
| 301 |
+ phy->ref_clk_scale[i] = NULL; |
| 302 |
+ } |
| 303 |
+ phy->clk_data.clks = NULL; |
| 304 |
+#endif // NUAND_MODIFICATIONS |
| 305 |
+ |
| 306 |
/* Device selection */ |
| 307 |
phy->dev_sel = init_param->dev_sel; |
| 308 |
|
| 309 |
@@ -338,6 +360,16 @@ int32_t ad9361_init (struct ad9361_rf_phy **ad9361_phy, AD9361_InitParam *init_p |
| 310 |
phy->pdata->port_ctrl.lvds_bias_ctrl |= (init_param->lvds_rx_onchip_termination_enable << 5); |
| 311 |
phy->pdata->rx1rx2_phase_inversion_en = init_param->rx1rx2_phase_inversion_en; |
| 312 |
|
| 313 |
+#ifdef NUAND_MODIFICATIONS |
| 314 |
+ // settings for digital interface drive and slew |
| 315 |
+ phy->pdata->port_ctrl.clk_out_drive = init_param->clk_out_drive & 0x1; |
| 316 |
+ phy->pdata->port_ctrl.dataclk_drive = init_param->dataclk_drive & 0x1; |
| 317 |
+ phy->pdata->port_ctrl.data_port_drive = init_param->data_port_drive & 0x1; |
| 318 |
+ phy->pdata->port_ctrl.clk_out_slew = init_param->clk_out_slew & 0x3; |
| 319 |
+ phy->pdata->port_ctrl.dataclk_slew = init_param->dataclk_slew & 0x3; |
| 320 |
+ phy->pdata->port_ctrl.data_port_slew = init_param->data_port_slew & 0x3; |
| 321 |
+#endif // NUAND_MODIFICATIONS |
| 322 |
+ |
| 323 |
/* GPO Control */ |
| 324 |
phy->pdata->gpo_ctrl.gpo0_inactive_state_high_en = init_param->gpo0_inactive_state_high_enable; |
| 325 |
phy->pdata->gpo_ctrl.gpo1_inactive_state_high_en = init_param->gpo1_inactive_state_high_enable; |
| 326 |
@@ -407,11 +439,28 @@ int32_t ad9361_init (struct ad9361_rf_phy **ad9361_phy, AD9361_InitParam *init_p |
| 327 |
phy->bist_tone_level_dB = 0; |
| 328 |
phy->bist_tone_mask = 0; |
| 329 |
|
| 330 |
+#ifdef NUAND_MODIFICATIONS |
| 331 |
+ // initialize SPI and GPIO |
| 332 |
+ ret = spi_init(phy, userdata); |
| 333 |
+ if (ret < 0) { |
| 334 |
+ goto out; |
| 335 |
+ } |
| 336 |
+ |
| 337 |
+ ret = gpio_init(phy, userdata); |
| 338 |
+ if (ret < 0) { |
| 339 |
+ goto out; |
| 340 |
+ } |
| 341 |
+#endif // NUAND_MODIFICATIONS |
| 342 |
+ |
| 343 |
ad9361_reset(phy); |
| 344 |
|
| 345 |
ret = ad9361_spi_read(phy->spi, REG_PRODUCT_ID); |
| 346 |
if ((ret & PRODUCT_ID_MASK) != PRODUCT_ID_9361) { |
| 347 |
printf("%s : Unsupported PRODUCT_ID 0x%X", __func__, (unsigned int)ret); |
| 348 |
+#ifdef NUAND_MODIFICATIONS |
| 349 |
+ // this missing newline, so help me god... |
| 350 |
+ printf("\n"); |
| 351 |
+#endif // NUAND_MODIFICATIONS |
| 352 |
ret = -ENODEV; |
| 353 |
goto out; |
| 354 |
} |
| 355 |
@@ -432,8 +481,16 @@ int32_t ad9361_init (struct ad9361_rf_phy **ad9361_phy, AD9361_InitParam *init_p |
| 356 |
goto out; |
| 357 |
|
| 358 |
#ifndef AXI_ADC_NOT_PRESENT |
| 359 |
+#ifdef NUAND_MODIFICATIONS |
| 360 |
+ // use alternate axiadc accessors |
| 361 |
+ axiadc_init(phy, userdata); |
| 362 |
+ ret = axiadc_read(phy->adc_state, ADI_REG_VERSION, &(phy->adc_state->pcore_version)); |
| 363 |
+ if (ret < 0) |
| 364 |
+ goto out; |
| 365 |
+#else |
| 366 |
axiadc_init(phy); |
| 367 |
phy->adc_state->pcore_version = axiadc_read(phy->adc_state, ADI_REG_VERSION); |
| 368 |
+#endif // NUAND_MODIFICATIONS |
| 369 |
#endif |
| 370 |
|
| 371 |
ad9361_init_gain_tables(phy); |
| 372 |
@@ -449,7 +506,10 @@ int32_t ad9361_init (struct ad9361_rf_phy **ad9361_phy, AD9361_InitParam *init_p |
| 373 |
goto out; |
| 374 |
#endif |
| 375 |
|
| 376 |
+#ifndef NUAND_MODIFICATIONS |
| 377 |
+ // reduce console noise |
| 378 |
printf("%s : AD936x Rev %d successfully initialized\n", __func__, (int)rev); |
| 379 |
+#endif // !NUAND_MODIFICATIONS |
| 380 |
|
| 381 |
*ad9361_phy = phy; |
| 382 |
|
| 383 |
@@ -463,12 +523,60 @@ out: |
| 384 |
#endif |
| 385 |
free(phy->clk_refin); |
| 386 |
free(phy->pdata); |
| 387 |
+ |
| 388 |
+#ifdef NUAND_MODIFICATIONS |
| 389 |
+ // free gpio struct, and also the clock stuff |
| 390 |
+ free(phy->gpio); |
| 391 |
+ free(phy->clk_data.clks); |
| 392 |
+ for (size_t i = 0; i < NUM_AD9361_CLKS; ++i) { |
| 393 |
+ free(phy->clks[i]); |
| 394 |
+ free(phy->ref_clk_scale[i]); |
| 395 |
+ } |
| 396 |
+#endif // NUAND_MODIFICATIONS |
| 397 |
+ |
| 398 |
free(phy); |
| 399 |
printf("%s : AD936x initialization error\n", __func__); |
| 400 |
|
| 401 |
return -ENODEV; |
| 402 |
} |
| 403 |
|
| 404 |
+#ifdef NUAND_MODIFICATIONS |
| 405 |
+/** |
| 406 |
+ * Deinitialize the AD9361 part. |
| 407 |
+ * @return 0 in case of success, negative error code otherwise. |
| 408 |
+ */ |
| 409 |
+int32_t ad9361_deinit (struct ad9361_rf_phy *phy) |
| 410 |
+{ |
| 411 |
+ if (phy) { |
| 412 |
+ /* Put AD9361 part into reset */ |
| 413 |
+ if (gpio_is_valid(phy->gpio, phy->pdata->gpio_resetb)) { |
| 414 |
+ gpio_set_value(phy->gpio, phy->pdata->gpio_resetb, 0); |
| 415 |
+ } |
| 416 |
+ } |
| 417 |
+ |
| 418 |
+ if (phy) { |
| 419 |
+ free(phy->spi); |
| 420 |
+ free(phy->gpio); |
| 421 |
+#ifndef AXI_ADC_NOT_PRESENT |
| 422 |
+ free(phy->adc_conv); |
| 423 |
+ free(phy->adc_state); |
| 424 |
+#endif |
| 425 |
+ free(phy->clk_refin); |
| 426 |
+ free(phy->clk_data.clks); |
| 427 |
+ free(phy->pdata); |
| 428 |
+ |
| 429 |
+ for (size_t i = 0; i < NUM_AD9361_CLKS; ++i) { |
| 430 |
+ free(phy->clks[i]); |
| 431 |
+ free(phy->ref_clk_scale[i]); |
| 432 |
+ } |
| 433 |
+ |
| 434 |
+ free(phy); |
| 435 |
+ } |
| 436 |
+ |
| 437 |
+ return 0; |
| 438 |
+} |
| 439 |
+#endif // NUAND_MODIFICATIONS |
| 440 |
+ |
| 441 |
/** |
| 442 |
* Set the Enable State Machine (ENSM) mode. |
| 443 |
* @param phy The AD9361 current state structure. |
| 444 |
@@ -1797,8 +1905,14 @@ int32_t ad9361_set_no_ch_mode(struct ad9361_rf_phy *phy, uint8_t no_ch_mode) |
| 445 |
phy->clks[TX_RFPLL]->rate = ad9361_rfpll_recalc_rate(phy->ref_clk_scale[TX_RFPLL]); |
| 446 |
|
| 447 |
#ifndef AXI_ADC_NOT_PRESENT |
| 448 |
+#ifdef NUAND_MODIFICATIONS |
| 449 |
+ // use alternate axiadc accessors |
| 450 |
+ axiadc_init(phy, phy->adc_state->userdata); |
| 451 |
+#else |
| 452 |
axiadc_init(phy); |
| 453 |
+#endif // NUAND_MODIFICATIONS |
| 454 |
#endif |
| 455 |
+ |
| 456 |
ad9361_setup(phy); |
| 457 |
#ifndef AXI_ADC_NOT_PRESENT |
| 458 |
/* platform specific wrapper to call ad9361_post_setup() */ |
| 459 |
diff --git a/ad9361/sw/ad9361_api.h b/ad9361/sw/ad9361_api.h |
| 460 |
index 77ffa44..ff5d7c5 100644 |
| 461 |
--- a/ad9361/sw/ad9361_api.h |
| 462 |
+++ b/ad9361/sw/ad9361_api.h |
| 463 |
@@ -240,6 +240,15 @@ typedef struct |
| 464 |
uint8_t rx1rx2_phase_inversion_en; /* adi,rx1-rx2-phase-inversion-enable */ |
| 465 |
uint8_t lvds_invert1_control; /* adi,lvds-invert1-control */ |
| 466 |
uint8_t lvds_invert2_control; /* adi,lvds-invert2-control */ |
| 467 |
+#ifdef NUAND_MODIFICATIONS |
| 468 |
+ // add digital interface drive and clock slew |
| 469 |
+ uint8_t clk_out_drive; |
| 470 |
+ uint8_t dataclk_drive; |
| 471 |
+ uint8_t data_port_drive; |
| 472 |
+ uint8_t clk_out_slew; |
| 473 |
+ uint8_t dataclk_slew; |
| 474 |
+ uint8_t data_port_slew; |
| 475 |
+#endif // NUAND_MODIFICATIONS |
| 476 |
/* GPO Control */ |
| 477 |
uint8_t gpo0_inactive_state_high_enable; /* adi,gpo0-inactive-state-high-enable */ |
| 478 |
uint8_t gpo1_inactive_state_high_enable; /* adi,gpo1-inactive-state-high-enable */ |
| 479 |
@@ -355,8 +364,15 @@ enum ad9361_ensm_mode { |
| 480 |
/******************************************************************************/ |
| 481 |
/************************ Functions Declarations ******************************/ |
| 482 |
/******************************************************************************/ |
| 483 |
+#ifdef NUAND_MODIFICATIONS |
| 484 |
+/* Initialize the AD9361 part. */ |
| 485 |
+int32_t ad9361_init (struct ad9361_rf_phy **ad9361_phy, AD9361_InitParam *init_param, void *userdata); |
| 486 |
+/* Deinitialize the AD9361 part. */ |
| 487 |
+int32_t ad9361_deinit (struct ad9361_rf_phy *phy); |
| 488 |
+#else |
| 489 |
/* Initialize the AD9361 part. */ |
| 490 |
int32_t ad9361_init (struct ad9361_rf_phy **ad9361_phy, AD9361_InitParam *init_param); |
| 491 |
+#endif // NUAND_MODIFICATIONS |
| 492 |
/* Set the Enable State Machine (ENSM) mode. */ |
| 493 |
int32_t ad9361_set_en_state_machine_mode (struct ad9361_rf_phy *phy, uint32_t mode); |
| 494 |
/* Get the Enable State Machine (ENSM) mode. */ |
| 495 |
@@ -365,6 +381,8 @@ |
| 496 |
int32_t ad9361_set_rx_rf_gain (struct ad9361_rf_phy *phy, uint8_t ch, int32_t gain_db); |
| 497 |
/* Get current receive RF gain for the selected channel. */ |
| 498 |
int32_t ad9361_get_rx_rf_gain (struct ad9361_rf_phy *phy, uint8_t ch, int32_t *gain_db); |
| 499 |
+/* Get RFIC temperature */ |
| 500 |
+int32_t ad9361_get_temp(struct ad9361_rf_phy *phy); |
| 501 |
/* Set the RX RF bandwidth. */ |
| 502 |
int32_t ad9361_set_rx_rf_bandwidth (struct ad9361_rf_phy *phy, uint32_t bandwidth_hz); |
| 503 |
/* Get the RX RF bandwidth. */ |
| 504 |
diff --git a/ad9361/sw/ad9361_conv.c b/ad9361/sw/ad9361_conv.c |
| 505 |
index b20cb71..0491f91 100644 |
| 506 |
--- a/ad9361/sw/ad9361_conv.c |
| 507 |
+++ b/ad9361/sw/ad9361_conv.c |
| 508 |
@@ -59,7 +59,18 @@ int32_t ad9361_hdl_loopback(struct ad9361_rf_phy *phy, bool enable) |
| 509 |
struct axiadc_state *st = phy->adc_state; |
| 510 |
int32_t reg, addr, chan; |
| 511 |
|
| 512 |
+#ifdef NUAND_MODIFICATIONS |
| 513 |
+ int ret; |
| 514 |
+ uint32_t readval; |
| 515 |
+ |
| 516 |
+ ret = axiadc_read(st, 0x4000, &readval); |
| 517 |
+ if (ret < 0) |
| 518 |
+ return ret; |
| 519 |
+ |
| 520 |
+ uint32_t version = readval; |
| 521 |
+#else |
| 522 |
uint32_t version = axiadc_read(st, 0x4000); |
| 523 |
+#endif // NUAND_MODIFICATIONS |
| 524 |
|
| 525 |
/* Still there but implemented a bit different */ |
| 526 |
if (PCORE_VERSION_MAJOR(version) > 7) |
| 527 |
@@ -68,7 +79,15 @@ int32_t ad9361_hdl_loopback(struct ad9361_rf_phy *phy, bool enable) |
| 528 |
addr = 0x4414; |
| 529 |
|
| 530 |
for (chan = 0; chan < conv->chip_info->num_channels; chan++) { |
| 531 |
+#ifdef NUAND_MODIFICATIONS |
| 532 |
+ ret = axiadc_read(st, addr + (chan) * 0x40, &readval); |
| 533 |
+ if (ret < 0) |
| 534 |
+ return ret; |
| 535 |
+ |
| 536 |
+ reg = (int32_t)readval; |
| 537 |
+#else |
| 538 |
reg = axiadc_read(st, addr + (chan) * 0x40); |
| 539 |
+#endif // NUAND_MODIFICATIONS |
| 540 |
|
| 541 |
if (PCORE_VERSION_MAJOR(version) > 7) { |
| 542 |
if (enable && reg != 0x8) { |
| 543 |
@@ -156,10 +175,23 @@ static int32_t ad9361_dig_tune_iodelay(struct ad9361_rf_phy *phy, bool tx) |
| 544 |
ADI_PN_ERR | ADI_PN_OOS); |
| 545 |
mdelay(10); |
| 546 |
|
| 547 |
+#ifdef NUAND_MODIFICATIONS |
| 548 |
+ uint32_t stat, tmp; |
| 549 |
+ |
| 550 |
+ for (chan = 0, stat = 0; chan < num_chan; chan++) { |
| 551 |
+ ret = axiadc_read(st, ADI_REG_CHAN_STATUS(chan), &tmp); |
| 552 |
+ if (ret < 0) |
| 553 |
+ return ret; |
| 554 |
+ stat |= tmp; |
| 555 |
+ } |
| 556 |
+ field[j] = stat; |
| 557 |
+#else |
| 558 |
+ |
| 559 |
for (chan = 0, ret = 0; chan < num_chan; chan++) |
| 560 |
ret |= axiadc_read(st, ADI_REG_CHAN_STATUS(chan)); |
| 561 |
|
| 562 |
field[j] = ret; |
| 563 |
+#endif // NUAND_MODIFICATIONS |
| 564 |
} |
| 565 |
|
| 566 |
c0 = ad9361_find_opt(&field[0], 32, &s0); |
| 567 |
@@ -233,6 +265,23 @@ int32_t ad9361_dig_interface_timing_analysis(struct ad9361_rf_phy *phy, |
| 568 |
|
| 569 |
mdelay(1); |
| 570 |
|
| 571 |
+#ifdef NUAND_MODIFICATIONS |
| 572 |
+ uint32_t tmp, stat; |
| 573 |
+ ret = axiadc_read(st, ADI_REG_STATUS, &stat); |
| 574 |
+ if (ret < 0) |
| 575 |
+ return ret; |
| 576 |
+ |
| 577 |
+ if (stat & ADI_STATUS) { |
| 578 |
+ for (chan = 0, stat = 0; chan < 4; chan++) { |
| 579 |
+ ret = axiadc_read(st, ADI_REG_CHAN_STATUS(chan), &tmp); |
| 580 |
+ if (ret < 0) |
| 581 |
+ return ret; |
| 582 |
+ stat |= tmp; |
| 583 |
+ } |
| 584 |
+ } else { |
| 585 |
+ stat = 1; |
| 586 |
+ } |
| 587 |
+#else |
| 588 |
if (axiadc_read(st, ADI_REG_STATUS) & ADI_STATUS) { |
| 589 |
for (chan = 0, ret = 0; chan < 4; chan++) |
| 590 |
ret |= axiadc_read(st, ADI_REG_CHAN_STATUS(chan)); |
| 591 |
@@ -240,6 +289,7 @@ int32_t ad9361_dig_interface_timing_analysis(struct ad9361_rf_phy *phy, |
| 592 |
else { |
| 593 |
ret = 1; |
| 594 |
} |
| 595 |
+#endif // NUAND_MODIFICATIONS |
| 596 |
|
| 597 |
field[i][j] = ret; |
| 598 |
} |
| 599 |
@@ -291,7 +341,13 @@ int32_t ad9361_dig_tune(struct ad9361_rf_phy *phy, uint32_t max_freq, |
| 600 |
dev_dbg(&phy->spi->dev, "%s: freq %"PRIu32" flags 0x%X\n", __func__, |
| 601 |
max_freq, flags); |
| 602 |
|
| 603 |
+#ifdef NUAND_MODIFICATIONS |
| 604 |
+ ret = axiadc_read(st, 0x4000, &hdl_dac_version); |
| 605 |
+ if (ret < 0) |
| 606 |
+ return ret; |
| 607 |
+#else |
| 608 |
hdl_dac_version = axiadc_read(st, 0x4000); |
| 609 |
+#endif // NUAND_MODIFICATIONS |
| 610 |
|
| 611 |
if ((phy->pdata->dig_interface_tune_skipmode == 2) || |
| 612 |
(flags & RESTORE_DEFAULT)) { |
| 613 |
@@ -345,6 +401,25 @@ int32_t ad9361_dig_tune(struct ad9361_rf_phy *phy, uint32_t max_freq, |
| 614 |
ADI_PN_ERR | ADI_PN_OOS); |
| 615 |
mdelay(4); |
| 616 |
|
| 617 |
+#ifdef NUAND_MODIFICATIONS |
| 618 |
+ uint32_t stat; |
| 619 |
+ ret = axiadc_read(st, ADI_REG_STATUS, &stat); |
| 620 |
+ if (ret < 0) |
| 621 |
+ return ret; |
| 622 |
+ |
| 623 |
+ if ((t == 1) || (stat & ADI_STATUS)) { |
| 624 |
+ for (chan = 0, stat = 0; chan < num_chan; chan++) { |
| 625 |
+ ret = axiadc_read(st, ADI_REG_CHAN_STATUS(chan), &tmp); |
| 626 |
+ if (ret < 0) |
| 627 |
+ return ret; |
| 628 |
+ stat |= tmp; |
| 629 |
+ } |
| 630 |
+ } else { |
| 631 |
+ stat = 1; |
| 632 |
+ } |
| 633 |
+ |
| 634 |
+ field[i][j] |= stat; |
| 635 |
+#else |
| 636 |
if ((t == 1) || (axiadc_read(st, ADI_REG_STATUS) & ADI_STATUS)) { |
| 637 |
for (chan = 0, ret = 0; chan < num_chan; chan++) { |
| 638 |
ret |= axiadc_read(st, ADI_REG_CHAN_STATUS(chan)); |
| 639 |
@@ -355,6 +430,7 @@ int32_t ad9361_dig_tune(struct ad9361_rf_phy *phy, uint32_t max_freq, |
| 640 |
} |
| 641 |
|
| 642 |
field[i][j] |= ret; |
| 643 |
+#endif // NUAND_MODIFICATIONS |
| 644 |
} |
| 645 |
} |
| 646 |
if ((flags & BE_MOREVERBOSE) && max_freq) { |
| 647 |
@@ -414,6 +490,48 @@ int32_t ad9361_dig_tune(struct ad9361_rf_phy *phy, uint32_t max_freq, |
| 648 |
axiadc_write(st, 0x4000 + ADI_REG_RSTN, ADI_RSTN | ADI_MMCM_RSTN); |
| 649 |
|
| 650 |
for (chan = 0; chan < num_chan; chan++) { |
| 651 |
+#ifdef NUAND_MODIFICATIONS |
| 652 |
+ ret = axiadc_read(st, ADI_REG_CHAN_CNTRL(chan), &saved_chan_ctrl0[chan]); |
| 653 |
+ if (ret < 0) |
| 654 |
+ return ret; |
| 655 |
+ |
| 656 |
+ ret = axiadc_write(st, ADI_REG_CHAN_CNTRL(chan), |
| 657 |
+ ADI_FORMAT_SIGNEXT | ADI_FORMAT_ENABLE | |
| 658 |
+ ADI_ENABLE | ADI_IQCOR_ENB); |
| 659 |
+ if (ret < 0) |
| 660 |
+ return ret; |
| 661 |
+ |
| 662 |
+ ret = axiadc_set_pnsel(st, chan, ADC_PN_CUSTOM); |
| 663 |
+ if (ret < 0) |
| 664 |
+ return ret; |
| 665 |
+ |
| 666 |
+ ret = axiadc_read(st, 0x4414 + (chan) * 0x40, &saved_chan_ctrl6[chan]); |
| 667 |
+ if (ret < 0) |
| 668 |
+ return ret; |
| 669 |
+ |
| 670 |
+ if (PCORE_VERSION_MAJOR(hdl_dac_version) > 7) |
| 671 |
+ { |
| 672 |
+ ret = axiadc_read(st, 0x4418 + (chan) * 0x40, &saved_dsel[chan]); |
| 673 |
+ if (ret < 0) |
| 674 |
+ return ret; |
| 675 |
+ |
| 676 |
+ ret = axiadc_write(st, 0x4418 + (chan) * 0x40, 9); |
| 677 |
+ if (ret < 0) |
| 678 |
+ return ret; |
| 679 |
+ |
| 680 |
+ ret = axiadc_write(st, 0x4414 + (chan) * 0x40, 0); /* !IQCOR_ENB */ |
| 681 |
+ if (ret < 0) |
| 682 |
+ return ret; |
| 683 |
+ |
| 684 |
+ ret = axiadc_write(st, 0x4044, 0x1); |
| 685 |
+ if (ret < 0) |
| 686 |
+ return ret; |
| 687 |
+ } else { |
| 688 |
+ ret = axiadc_write(st, 0x4414 + (chan) * 0x40, 1); /* DAC_PN_ENB */ |
| 689 |
+ if (ret < 0) |
| 690 |
+ return ret; |
| 691 |
+ } |
| 692 |
+#else |
| 693 |
saved_chan_ctrl0[chan] = axiadc_read(st, ADI_REG_CHAN_CNTRL(chan)); |
| 694 |
axiadc_write(st, ADI_REG_CHAN_CNTRL(chan), |
| 695 |
ADI_FORMAT_SIGNEXT | ADI_FORMAT_ENABLE | |
| 696 |
@@ -429,10 +547,18 @@ int32_t ad9361_dig_tune(struct ad9361_rf_phy *phy, uint32_t max_freq, |
| 697 |
} |
| 698 |
else |
| 699 |
axiadc_write(st, 0x4414 + (chan) * 0x40, 1); /* DAC_PN_ENB */ |
| 700 |
- |
| 701 |
+#endif // NUAND_MODIFICATIONS |
| 702 |
} |
| 703 |
if (PCORE_VERSION_MAJOR(hdl_dac_version) < 8) { |
| 704 |
+#ifdef NUAND_MODIFICATIONS |
| 705 |
+ ret = axiadc_read(st, 0x4048, &tmp); |
| 706 |
+ if (ret < 0) |
| 707 |
+ return ret; |
| 708 |
+ |
| 709 |
+ saved = tmp; |
| 710 |
+#else |
| 711 |
saved = tmp = axiadc_read(st, 0x4048); |
| 712 |
+#endif // NUAND_MODIFICATIONS |
| 713 |
tmp &= ~0xF; |
| 714 |
tmp |= 1; |
| 715 |
axiadc_write(st, 0x4048, tmp); |
| 716 |
@@ -508,8 +634,21 @@ int32_t ad9361_post_setup(struct ad9361_rf_phy *phy) |
| 717 |
|
| 718 |
num_chan = (conv->chip_info->num_channels > 4) ? 4 : conv->chip_info->num_channels; |
| 719 |
|
| 720 |
+#ifdef NUAND_MODIFICATIONS |
| 721 |
+ ret = axiadc_write(st, ADI_REG_CNTRL, rx2tx2 ? 0 : ADI_R1_MODE); |
| 722 |
+ if (ret < 0) |
| 723 |
+ return ret; |
| 724 |
+ |
| 725 |
+ uint32_t u32tmp; |
| 726 |
+ ret = axiadc_read(st, 0x4048, &u32tmp); |
| 727 |
+ if (ret < 0) |
| 728 |
+ return ret; |
| 729 |
+ |
| 730 |
+ tmp = (int32_t)u32tmp; |
| 731 |
+#else |
| 732 |
axiadc_write(st, ADI_REG_CNTRL, rx2tx2 ? 0 : ADI_R1_MODE); |
| 733 |
tmp = axiadc_read(st, 0x4048); |
| 734 |
+#endif // NUAND_MODIFICATIONS |
| 735 |
|
| 736 |
if (!rx2tx2) { |
| 737 |
axiadc_write(st, 0x4048, tmp | BIT(5)); /* R1_MODE */ |
| 738 |
@@ -539,14 +678,29 @@ int32_t ad9361_post_setup(struct ad9361_rf_phy *phy) |
| 739 |
|
| 740 |
flags = 0x0; |
| 741 |
|
| 742 |
+#ifdef NUAND_MODIFICATIONS |
| 743 |
+ ret = axiadc_read(st, 0x0004, &u32tmp); |
| 744 |
+ if (ret < 0) |
| 745 |
+ return ret; |
| 746 |
+ ret = ad9361_dig_tune(phy, ((conv->chip_info->num_channels > 4) || |
| 747 |
+ u32tmp) ? 0 : 61440000, flags); |
| 748 |
+#else |
| 749 |
ret = ad9361_dig_tune(phy, ((conv->chip_info->num_channels > 4) || |
| 750 |
axiadc_read(st, 0x0004)) ? 0 : 61440000, flags); |
| 751 |
+#endif // NUAND_MODIFICATIONS |
| 752 |
if (ret < 0) |
| 753 |
return ret; |
| 754 |
|
| 755 |
if (flags & (DO_IDELAY | DO_ODELAY)) { |
| 756 |
+#ifdef NUAND_MODIFICATIONS |
| 757 |
+ ret = axiadc_read(st, ADI_REG_ID, &u32tmp); |
| 758 |
+ if (ret < 0) |
| 759 |
+ return ret; |
| 760 |
+ ret = ad9361_dig_tune(phy, u32tmp ? 0 : 61440000, flags & BE_VERBOSE); |
| 761 |
+#else |
| 762 |
ret = ad9361_dig_tune(phy, (axiadc_read(st, ADI_REG_ID)) ? |
| 763 |
0 : 61440000, flags & BE_VERBOSE); |
| 764 |
+#endif // NUAND_MODIFICATIONS |
| 765 |
if (ret < 0) |
| 766 |
return ret; |
| 767 |
} |
| 768 |
diff --git a/ad9361/sw/common.h b/ad9361/sw/common.h |
| 769 |
index bd4b7f7..b140494 100644 |
| 770 |
--- a/ad9361/sw/common.h |
| 771 |
+++ b/ad9361/sw/common.h |
| 772 |
@@ -47,6 +47,10 @@ |
| 773 |
/******************************************************************************/ |
| 774 |
/********************** Macros and Constants Definitions **********************/ |
| 775 |
/******************************************************************************/ |
| 776 |
+#ifdef NUAND_MODIFICATIONS |
| 777 |
+// just use errno |
| 778 |
+#include <errno.h> |
| 779 |
+#else |
| 780 |
#define EIO 5 /* I/O error */ |
| 781 |
#define EAGAIN 11 /* Try again */ |
| 782 |
#define ENOMEM 12 /* Out of memory */ |
| 783 |
@@ -54,15 +58,22 @@ |
| 784 |
#define ENODEV 19 /* No such device */ |
| 785 |
#define EINVAL 22 /* Invalid argument */ |
| 786 |
#define ETIMEDOUT 110 /* Connection timed out */ |
| 787 |
+#endif // NUAND_MODIFICATIONS |
| 788 |
|
| 789 |
/******************************************************************************/ |
| 790 |
/*************************** Types Declarations *******************************/ |
| 791 |
/******************************************************************************/ |
| 792 |
+ |
| 793 |
+#ifdef NUAND_MODIFICATIONS |
| 794 |
+// just use stdbool |
| 795 |
+#include <stdbool.h> |
| 796 |
+#else |
| 797 |
#if defined (__STDC__) && (__STDC_VERSION__ >= 199901L) |
| 798 |
#include <stdbool.h> |
| 799 |
#else |
| 800 |
typedef enum { false, true } bool; |
| 801 |
#endif |
| 802 |
+#endif // NUAND_MODIFICATIONS |
| 803 |
|
| 804 |
struct clk { |
| 805 |
const char *name; |
| 806 |
diff --git a/ad9361/sw/util.h b/ad9361/sw/util.h |
| 807 |
index 3c88529..f4f7385 100644 |
| 808 |
--- a/ad9361/sw/util.h |
| 809 |
+++ b/ad9361/sw/util.h |
| 810 |
@@ -50,12 +50,24 @@ |
| 811 |
#include "common.h" |
| 812 |
#include "config.h" |
| 813 |
|
| 814 |
+#ifdef NUAND_MODIFICATIONS |
| 815 |
+// include adc/dac core headers |
| 816 |
+#include "adc_core.h" |
| 817 |
+#include "dac_core.h" |
| 818 |
+#endif // NUAND_MODIFICATIONS |
| 819 |
|
| 820 |
/******************************************************************************/ |
| 821 |
/********************** Macros and Constants Definitions **********************/ |
| 822 |
/******************************************************************************/ |
| 823 |
#define SUCCESS 0 |
| 824 |
+#ifdef NUAND_MODIFICATIONS |
| 825 |
+// guard on ARRAY_SIZE (already defined in libbladeRF) |
| 826 |
+#ifndef ARRAY_SIZE |
| 827 |
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) |
| 828 |
+#endif |
| 829 |
+#else |
| 830 |
+#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) |
| 831 |
+#endif // NUAND_MODIFICATIONS |
| 832 |
#define min(x, y) (((x) < (y)) ? (x) : (y)) |
| 833 |
#define min_t(type, x, y) (type)min((type)(x), (type)(y)) |
| 834 |
#define max(x, y) (((x) > (y)) ? (x) : (y)) |
| 835 |
@@ -68,6 +80,24 @@ |
| 836 |
#define CLK_IGNORE_UNUSED BIT(3) |
| 837 |
#define CLK_GET_RATE_NOCACHE BIT(6) |
| 838 |
|
| 839 |
+#ifdef NUAND_MODIFICATIONS |
| 840 |
+// Fix a whole slew of MSVC compiler errors... |
| 841 |
+#if defined(HAVE_VERBOSE_MESSAGES) |
| 842 |
+#define dev_err(dev, format, ...) {printf(format, ## __VA_ARGS__);printf("\n"); } |
| 843 |
+#define dev_warn(dev, format, ...) {printf(format, ## __VA_ARGS__);printf("\n"); } |
| 844 |
+#if defined(HAVE_DEBUG_MESSAGES) |
| 845 |
+#define dev_dbg(dev, format, ...) {printf(format, ## __VA_ARGS__);printf("\n"); } |
| 846 |
+#else |
| 847 |
+#define dev_dbg(dev, format, ...) { if (0) printf(format, ## __VA_ARGS__); } |
| 848 |
+#endif |
| 849 |
+#define printk(format, ...) printf(format, ## __VA_ARGS__) |
| 850 |
+#else |
| 851 |
+#define dev_err(dev, format, ...) { if (0) printf(format, ## __VA_ARGS__); } |
| 852 |
+#define dev_warn(dev, format, ...) { if (0) printf(format, ## __VA_ARGS__); } |
| 853 |
+#define dev_dbg(dev, format, ...) { if (0) printf(format, ## __VA_ARGS__); } |
| 854 |
+#define printk(format, ...) { if (0) printf(format, ## __VA_ARGS__); } |
| 855 |
+#endif |
| 856 |
+#else |
| 857 |
#if defined(HAVE_VERBOSE_MESSAGES) |
| 858 |
#define dev_err(dev, format, ...) ({printf(format, ## __VA_ARGS__);printf("\n"); }) |
| 859 |
#define dev_warn(dev, format, ...) ({printf(format, ## __VA_ARGS__);printf("\n"); }) |
| 860 |
@@ -83,18 +113,39 @@ |
| 861 |
#define dev_dbg(dev, format, ...) ({ if (0) printf(format, ## __VA_ARGS__); }) |
| 862 |
#define printk(format, ...) ({ if (0) printf(format, ## __VA_ARGS__); }) |
| 863 |
#endif |
| 864 |
+#endif // NUAND_MODIFICATIONS |
| 865 |
|
| 866 |
struct device { |
| 867 |
+#ifdef NUAND_MODIFICATIONS |
| 868 |
+ // fix MSVC code C2016 |
| 869 |
+ void *noop; |
| 870 |
+#endif // NUAND_MODIFICATIONS |
| 871 |
}; |
| 872 |
|
| 873 |
struct spi_device { |
| 874 |
struct device dev; |
| 875 |
uint8_t id_no; |
| 876 |
+#ifdef NUAND_MODIFICATIONS |
| 877 |
+ // add userdata field |
| 878 |
+ void *userdata; |
| 879 |
+#endif // NUAND_MODIFICATIONS |
| 880 |
+}; |
| 881 |
+ |
| 882 |
+#ifdef NUAND_MODIFICATIONS |
| 883 |
+// gpio_device struct |
| 884 |
+struct gpio_device { |
| 885 |
+ void *userdata; |
| 886 |
}; |
| 887 |
+#endif // NUAND_MODIFICATIONS |
| 888 |
|
| 889 |
struct axiadc_state { |
| 890 |
struct ad9361_rf_phy *phy; |
| 891 |
uint32_t pcore_version; |
| 892 |
+#ifdef NUAND_MODIFICATIONS |
| 893 |
+ // add DAC DDS state, userdata |
| 894 |
+ struct dds_state dac_dds_state; |
| 895 |
+ void *userdata; |
| 896 |
+#endif // NUAND_MODIFICATIONS |
| 897 |
}; |
| 898 |
|
| 899 |
struct axiadc_chip_info { |