|
51 | 51 |
|
52 | 52 | #ifndef BLADERF_NIOS_BUILD
|
53 | 53 | # include "bladerf_priv.h"
|
| 54 | +# include "capabilities.h" |
54 | 55 | # include "log.h"
|
55 | 56 | # include "rel_assert.h"
|
56 | 57 |
|
@@ -2284,10 +2285,21 @@ int lms_set_precalculated_frequency(struct bladerf *dev, bladerf_module mod,
|
2284 | 2285 | {
|
2285 | 2286 | /* Select the base address based on which PLL we are configuring */
|
2286 | 2287 | const uint8_t base = (mod == BLADERF_MODULE_RX) ? 0x20 : 0x10;
|
| 2288 | + |
2287 | 2289 | uint8_t data;
|
2288 | 2290 | uint8_t vcocap_reg_state;
|
2289 | 2291 | int status, dsm_status;
|
2290 | 2292 |
|
| 2293 | + /* Utilize atomic writes to the PLL registers, if possible. This |
| 2294 | + * "multiwrite" is indicated by the MSB being set. */ |
| 2295 | +# ifdef BLADERF_NIOS_BUILD |
| 2296 | + const uint8_t pll_base = base | 0x80; |
| 2297 | +# else |
| 2298 | + const uint8_t pll_base = |
| 2299 | + have_cap(dev, BLADERF_CAP_ATOMIC_NINT_NFRAC_WRITE) ? |
| 2300 | + (base | 0x80) : base; |
| 2301 | +# endif |
| 2302 | + |
2291 | 2303 | f->vcocap_result = 0xff;
|
2292 | 2304 |
|
2293 | 2305 | /* Turn on the DSMs */
|
@@ -2324,25 +2336,25 @@ int lms_set_precalculated_frequency(struct bladerf *dev, bladerf_module mod,
|
2324 | 2336 | }
|
2325 | 2337 |
|
2326 | 2338 | data = f->nint >> 1;
|
2327 |
| - status = LMS_WRITE(dev, base + 0, data); |
| 2339 | + status = LMS_WRITE(dev, pll_base + 0, data); |
2328 | 2340 | if (status != 0) {
|
2329 | 2341 | goto error;
|
2330 | 2342 | }
|
2331 | 2343 |
|
2332 | 2344 | data = ((f->nint & 1) << 7) | ((f->nfrac >> 16) & 0x7f);
|
2333 |
| - status = LMS_WRITE(dev, base + 1, data); |
| 2345 | + status = LMS_WRITE(dev, pll_base + 1, data); |
2334 | 2346 | if (status != 0) {
|
2335 | 2347 | goto error;
|
2336 | 2348 | }
|
2337 | 2349 |
|
2338 | 2350 | data = ((f->nfrac >> 8) & 0xff);
|
2339 |
| - status = LMS_WRITE(dev, base + 2, data); |
| 2351 | + status = LMS_WRITE(dev, pll_base + 2, data); |
2340 | 2352 | if (status != 0) {
|
2341 | 2353 | goto error;
|
2342 | 2354 | }
|
2343 | 2355 |
|
2344 | 2356 | data = (f->nfrac & 0xff);
|
2345 |
| - status = LMS_WRITE(dev, base + 3, data); |
| 2357 | + status = LMS_WRITE(dev, pll_base + 3, data); |
2346 | 2358 | if (status != 0) {
|
2347 | 2359 | goto error;
|
2348 | 2360 | }
|
|
0 commit comments