no-OS
Loading...
Searching...
No Matches
adf4382.h
Go to the documentation of this file.
1/***************************************************************************/
34#ifndef _ADF4382_H_
35#define _ADF4382_H_
36
37#include <stdint.h>
38#include <string.h>
39#include "no_os_units.h"
40#include "no_os_util.h"
41#include "no_os_spi.h"
42
43/* ADF4382 REG0000 Map */
44#define ADF4382_SOFT_RESET_R_MSK NO_OS_BIT(7)
45#define ADF4382_LSB_FIRST_R_MSK NO_OS_BIT(6)
46#define ADF4382_ADDRESS_ASC_R_MSK NO_OS_BIT(5)
47#define ADF4382_SDO_ACTIVE_R_MSK NO_OS_BIT(4)
48#define ADF4382_SDO_ACTIVE_MSK NO_OS_BIT(3)
49#define ADF4382_ADDRESS_ASC_MSK NO_OS_BIT(2)
50#define ADF4382_LSB_FIRST_MSK NO_OS_BIT(1)
51#define ADF4382_SOFT_RESET_MSK NO_OS_BIT(0)
52#define ADF4382_RESET_CMD 0x81
53
54/* ADF4382 REG0000 NO_OS_BIT Definition */
55#define ADF4382_SDO_ACTIVE_SPI_3W 0x0
56#define ADF4382_SDO_ACTIVE_SPI_4W 0x1
57
58#define ADF4382_ADDR_ASC_AUTO_DECR 0x0
59#define ADF4382_ADDR_ASC_AUTO_INCR 0x1
60
61#define ADF4382_LSB_FIRST_MSB 0x0
62#define ADF4382_LSB_FIRST_LSB 0x1
63
64#define ADF4382_SOFT_RESET_N_OP 0x0
65#define ADF4382_SOFT_RESET_EN 0x1
66
67/* ADF4382 REG0001 Map */
68#define ADF4382_SINGLE_INSTR_MSK NO_OS_BIT(7)
69#define ADF4382_MASTER_RB_CTRL_MSK NO_OS_BIT(5)
70
71/* ADF4382 REG0001 NO_OS_BIT Definition */
72#define ADF4382_SPI_STREAM_EN 0x0
73#define ADF4382_SPI_STREAM_DIS 0x1
74
75#define ADF4382_RB_SLAVE_REG 0x0
76#define ADF4382_RB_MASTER_REG 0x1
77
78/* ADF4382 REG0003 NO_OS_BIT Definition */
79#define ADF4382_CHIP_TYPE 0x06
80
81/* ADF4382 REG0004 NO_OS_BIT Definition */
82#define ADF4382_PRODUCT_ID_LSB 0x08
83#define ADF4383_PRODUCT_ID_LSB 0x0F
84
85/* ADF4382 REG0005 NO_OS_BIT Definition */
86#define ADF4382_PRODUCT_ID_MSB 0x00
87#define ADF4383_PRODUCT_ID_MSB 0x00
88
89/* ADF4382 REG000A Map */
90#define ADF4382_SCRATCHPAD_MSK NO_OS_GENMASK(7, 0)
91
92/* ADF4382 REG000C NO_OS_BIT Definition */
93#define ADF4382_VENDOR_ID_LSB 0x56
94
95/* ADF4382 REG000D NO_OS_BIT Definition */
96#define ADF4382_VENDOR_ID_MSB 0x04
97
98/* ADF4382 REG000F NO_OS_BIT Definition */
99#define ADF4382_M_S_TRANSF_NO_OS_BIT_MSK NO_OS_BIT(0)
100
101/* ADF4382 REG0010 Map*/
102#define ADF4382_N_INT_LSB_MSK NO_OS_GENMASK(7, 0)
103
104/* ADF4382 REG0011 Map*/
105#define ADF4382_CLKOUT_DIV_MSK NO_OS_GENMASK(7, 5)
106#define ADF4382_INV_CLK_OUT_MSK NO_OS_BIT(4)
107#define ADF4382_N_INT_MSB_MSK NO_OS_GENMASK(3, 0)
108
109/* ADF4382 REG0012 Map */
110#define ADF4382_FRAC1WORD_LSB_MSK NO_OS_GENMASK(7, 0)
111
112/* ADF4382 REG0013 Map */
113#define ADF4382_FRAC1WORD_MID_MSK NO_OS_GENMASK(7, 0)
114
115/* ADF4382 REG0014 Map */
116#define ADF4382_FRAC1WORD_MSB_MSK NO_OS_GENMASK(7, 0)
117
118/* ADF4382 REG0015 Map */
119#define ADF4382_M_VCO_BAND_LSB_MSK NO_OS_BIT(7)
120#define ADF4382_M_VCO_CORE_MSK NO_OS_BIT(6)
121#define ADF4382_BIAS_DEC_MODE_MSK NO_OS_GENMASK(5, 3)
122#define ADF4382_INT_MODE_MSK NO_OS_BIT(2)
123#define ADF4382_PFD_POL_MSK NO_OS_BIT(1)
124#define ADF4382_FRAC1WORD_MSB NO_OS_BIT(0)
125
126/* ADF4382 REG0016 Map */
127#define ADF4382_M_VCO_BAND_MSB_MSK NO_OS_GENMASK(7, 0)
128
129/* ADF4382 REG0017 Map */
130#define ADF4382_FRAC2WORD_LSB_MSK NO_OS_GENMASK(7, 0)
131
132/* ADF4382 REG0018 Map */
133#define ADF4382_FRAC2WORD_MID_MSK NO_OS_GENMASK(7, 0)
134
135/* ADF4382 REG0019 Map */
136#define ADF4382_FRAC2WORD_MSB_MSK NO_OS_GENMASK(7, 0)
137
138/* ADF4382 REG001A Map */
139#define ADF4382_MOD2WORD_LSB_MSK NO_OS_GENMASK(7, 0)
140
141/* ADF4382 REG001B Map */
142#define ADF4382_MOD2WORD_MID_MSK NO_OS_GENMASK(7, 0)
143
144/* ADF4382 REG001C Map */
145#define ADF4382_MOD2WORD_MSB_MSK NO_OS_GENMASK(7, 0)
146
147/* ADF4382 REG001D Map */
148#define ADF4382_FINE_BLEED_LSB_MSK NO_OS_GENMASK(7, 0)
149
150/* ADF4382 REG001E Map */
151#define ADF4382_EN_PHASE_RESYNC_MSK NO_OS_BIT(7)
152#define ADF4382_EN_REF_RST_MSK NO_OS_BIT(6)
153#define ADF4382_TIMED_SYNC_MSK NO_OS_BIT(5)
154#define ADF4382_COARSE_BLEED_MSK NO_OS_GENMASK(4, 1)
155#define ADF4382_FINE_BLEED_MSB_MSK NO_OS_BIT(0)
156
157/* ADF4382 REG001F Map */
158#define ADF4382_SW_SYNC_MSK NO_OS_BIT(7)
159#define ADF4382_SPARE_1F_MSK NO_OS_BIT(6)
160#define ADF4382_BLEED_POL_MSK NO_OS_BIT(5)
161#define ADF4382_EN_BLEED_MSK NO_OS_BIT(4)
162#define ADF4382_CP_I_MSK NO_OS_GENMASK(3, 0)
163
164/* ADF4382 REG0020 Map */
165#define ADF4382_EN_AUTOCAL_MSK NO_OS_BIT(7)
166#define ADF4382_EN_RDBLR_MSK NO_OS_BIT(6)
167#define ADF4382_R_DIV_MSK NO_OS_GENMASK(5, 0)
168
169/* ADF4382 REG0021 Map */
170#define ADF4382_PHASE_WORD_LSB_MSK NO_OS_GENMASK(7, 0)
171
172/* ADF4382 REG0022 Map */
173#define ADF4382_PHASE_WORD_MID_MSK NO_OS_GENMASK(7, 0)
174
175/* ADF4382 REG0023 Map */
176#define ADF4382_PHASE_WORD_MSB_MSK NO_OS_GENMASK(7, 0)
177
178/* ADF4382 REG0024 Map */
179#define ADF4382_SPARE_24_MSK NO_OS_GENMASK(7, 5)
180#define ADF4382_DCLK_DIV_SEL_MSK NO_OS_BIT(4)
181#define ADF4382_DNCLK_DIV1_MSK NO_OS_GENMASK(3, 2)
182#define ADF4382_DCLK_DIV1_MSK NO_OS_GENMASK(1, 0)
183
184/* ADF4382 REG0025 Map */
185#define ADF4382_RESYNC_WAIT_LSB_MSK NO_OS_GENMASK(7, 0)
186
187/* ADF4382 REG0026 Map */
188#define ADF4382_RESYNC_WAIT_MSB_MSK NO_OS_GENMASK(7, 0)
189
190/* ADF4382 REG0027 Map */
191#define ADF4382_CAL_BLEED_FINE_MIN_MSK NO_OS_GENMASK(7, 4)
192#define ADF4382_BLEED_ADJ_SCALE_MSK NO_OS_GENMASK(3, 0)
193
194/* ADF4382 REG0028 Map */
195#define ADF4382_PH_RESYNC_RB_SEL_MSK NO_OS_BIT(7)
196#define ADF4382_LSB_P1_MSK NO_OS_BIT(6)
197#define ADF4382_VAR_MOD_EN_MSK NO_OS_BIT(5)
198#define ADF4382_DITHER1_SCALE_MSK NO_OS_GENMASK(4, 2)
199#define ADF4382_EN_DITHER2_MSK NO_OS_BIT(1)
200#define ADF4382_EN_DITHER1_MSK NO_OS_BIT(0)
201
202/* ADF4382 REG0029 Map */
203#define ADF4382_CLK2_OPWR_MSK NO_OS_GENMASK(7, 4)
204#define ADF4382_CLK1_OPWR_MSK NO_OS_GENMASK(3, 0)
205
206/* ADF4382 REG002A Map */
207#define ADF4382_FN_DBL_MSK NO_OS_BIT(7)
208#define ADF4382_PD_NDIV_TL_MSK NO_OS_BIT(6)
209#define ADF4382_CLKOUT_BST_MSK NO_OS_BIT(5)
210#define ADF4382_PD_SYNC_MSK NO_OS_BIT(4)
211#define ADF4382_PD_CLK_MSK NO_OS_BIT(3)
212#define ADF4382_PD_RDET_MSK NO_OS_BIT(2)
213#define ADF4382_PD_ADC_MSK NO_OS_BIT(1)
214#define ADF4382_PD_CALGEN_MSK NO_OS_BIT(0)
215
216/* ADF4382 REG002B Map */
217#define ADF4382_PD_ALL_MSK NO_OS_BIT(7)
218#define ADF4382_PD_RDIV_TL_MSK NO_OS_BIT(6)
219#define ADF4382_PD_NDIV_MSK NO_OS_BIT(5)
220#define ADF4382_PD_VCO_MSK NO_OS_BIT(4)
221#define ADF4382_PD_LD_MSK NO_OS_BIT(3)
222#define ADF4382_PD_PFDCP_MSK NO_OS_BIT(2)
223#define ADF4382_PD_CLKOUT1_MSK NO_OS_BIT(1)
224#define ADF4382_PD_CLKOUT2_MSK NO_OS_BIT(0)
225
226/* ADF4382 REG002C Map */
227#define ADF4382_LDWIN_PW_MSK NO_OS_GENMASK(7, 5)
228#define ADF4382_LD_COUNT_OPWR_MSK NO_OS_GENMASK(4, 0)
229
230/* ADF4382 REG002D Map */
231#define ADF4382_EN_DNCLK_MSK NO_OS_BIT(7)
232#define ADF4382_EN_DRCLK_MSK NO_OS_BIT(6)
233#define ADF4382_EN_LOL_MSK NO_OS_BIT(5)
234#define ADF4382_EN_LDWIN_MSK NO_OS_BIT(4)
235#define ADF4382_PDET_POL_MSK NO_OS_BIT(3)
236#define ADF4382_RST_LD_MSK NO_OS_BIT(2)
237#define ADF4382_LD_O_CTRL_MSK NO_OS_GENMASK(1, 0)
238
239/* ADF4382 REG002E Map */
240#define ADF4382_MUXOUT_MSK NO_OS_GENMASK(7, 4)
241#define ADF4382_ABPW_WD_MSK NO_OS_BIT(3)
242#define ADF4382_EN_CPTEST_MSK NO_OS_BIT(2)
243#define ADF4382_CP_DOWN_MSK NO_OS_BIT(1)
244#define ADF4382_CP_UP_MSK NO_OS_BIT(0)
245
246/* ADF4382 REG002F Map*/
247#define ADF4382_BST_REF_MSK NO_OS_BIT(7)
248#define ADF4382_FILT_REF_MSK NO_OS_BIT(6)
249#define ADF4382_RDBLR_DC_MSK NO_OS_GENMASK(5, 0)
250
251/* ADF4382 REG0030 Map */
252#define ADF4382_MUTE_NCLK_MSK NO_OS_BIT(7)
253#define ADF4382_MUTE_RCLK_MSK NO_OS_BIT(6)
254#define ADF4382_REF_SEL_MSK NO_OS_BIT(5)
255#define ADF4382_INV_RDBLR_MSK NO_OS_BIT(4)
256#define ADF4382_RDBLR_DEL_SEL_MSK NO_OS_GENMASK(3, 0)
257
258/* ADF4382 REG0031 Map */
259#define ADF4382_SYNC_DEL_MSK NO_OS_GENMASK(7, 5)
260#define ADF4382_RST_SYS_MSK NO_OS_BIT(4)
261#define ADF4382_EN_ADC_CLK_MSK NO_OS_BIT(3)
262#define ADF4382_EN_VCAL_MSK NO_OS_BIT(2)
263#define ADF4382_CAL_CT_SEL_MSK NO_OS_BIT(1)
264#define ADF4382_DCLK_MODE_MSK NO_OS_BIT(0)
265
266/* ADF4382 REG0032 Map */
267#define ADF4382_SPARE_32_MSK NO_OS_BIT(7)
268#define ADF4382_BLEED_ADJ_CAL_MSK NO_OS_BIT(6)
269#define ADF4382_DEL_MODE_MSK NO_OS_BIT(5)
270#define ADF4382_EN_AUTO_ALIGN_MSK NO_OS_BIT(4)
271#define ADF4382_PHASE_ADJ_POL_MSK NO_OS_BIT(3)
272#define ADF4382_EFM3_MODE_MSK NO_OS_GENMASK(2, 0)
273
274/* ADF4382 REG0033 Map */
275#define ADF4382_PHASE_ADJUST_MSK NO_OS_GENMASK(7, 0)
276
277/* ADF4382 REG0034 Map */
278#define ADF4382_PHASE_ADJ_MSK NO_OS_BIT(7)
279#define ADF4382_DRCLK_DEL_MSK NO_OS_GENMASK(6, 4)
280#define ADF4382_DNCLK_DEL_MSK NO_OS_GENMASK(3, 1)
281#define ADF4382_RST_CNTR_MSK NO_OS_BIT(0)
282
283/* ADF4382 REG0035 Map */
284#define ADF4382_SPARE_35_MSK NO_OS_GENMASK(7, 6)
285#define ADF4382_M_VCO_BIAS_MSK NO_OS_GENMASK(5, 0)
286
287/* ADF4382 REG0036 Map */
288#define ADF4382_CLKODIV_DB_MSK NO_OS_BIT(7)
289#define ADF4382_DCLK_DIV_DB_MSK NO_OS_BIT(6)
290#define ADF4382_SPARE_36_MSK NO_OS_GENMASK(5, 2)
291#define ADF4382_EN_LUT_GEN_MSK NO_OS_BIT(1)
292#define ADF4382_EN_LUT_CAL_MSK NO_OS_BIT(0)
293
294/* ADF4382 REG0037 Map */
295#define ADF4382_CAL_COUNT_TO_MSK NO_OS_GENMASK(7, 0)
296
297/* ADF4382 REG0038 Map */
298#define ADF4382_CAL_VTUNE_TO_LSB_MSK NO_OS_GENMASK(7, 0)
299
300/* ADF4382 REG0039 Map */
301#define ADF4382_O_VCO_DB_MSK NO_OS_BIT(7)
302#define ADF4382_CAL_VTUNE_TO_MSB_MSK NO_OS_GENMASK(6, 0)
303
304/* ADF4382 REG003A Map */
305#define ADF4382_CAL_VCO_TO_LSB_MSK NO_OS_GENMASK(7, 0)
306
307/* ADF4382 REG003B Map */
308#define ADF4382_DEL_CTRL_DB_MSK NO_OS_BIT(7)
309#define ADF4382_CAL_VCO_TO_MSB_MSK NO_OS_GENMASK(6, 0)
310
311/* ADF4382 REG003C Map */
312#define ADF4382_CNTR_DIV_WORD_MSK NO_OS_GENMASK(7, 0)
313
314/* ADF4382 REG003D Map */
315#define ADF4382_SPARE_3D_MSK NO_OS_BIT(7)
316#define ADF4382_SYNC_SP_DB_MSK NO_OS_BIT(6)
317#define ADF4382_CMOS_OV_MSK NO_OS_BIT(5)
318#define ADF4382_READ_MODE_MSK NO_OS_BIT(4)
319#define ADF4382_CNTR_DIV_WORD_MSB_MSK NO_OS_GENMASK(3, 0)
320
321/* ADF4382 REG003E Map */
322#define ADF4382_ADC_CLK_DIV_MSK NO_OS_GENMASK(7, 0)
323
324/* ADF4382 REG003F Map */
325#define ADF4382_EN_ADC_CNV_MSK NO_OS_BIT(7)
326#define ADF4382_EN_ADC_VTEST_MSK NO_OS_BIT(6)
327#define ADF4382_ADC_VTEST_SEL_MSK NO_OS_BIT(5)
328#define ADF4382_ADC_MUX_SEL_MSK NO_OS_BIT(4)
329#define ADF4382_ADC_F_CONV_MSK NO_OS_BIT(3)
330#define ADF4382_ADC_C_CONV_MSK NO_OS_BIT(2)
331#define ADF4382_EN_ADC_MSK NO_OS_BIT(1)
332#define ADF4382_SPARE_3F_MSK NO_OS_BIT(0)
333
334/* ADF4382 REG0040 Map */
335#define ADF4382_EXT_DIV_DEC_SEL_MSK NO_OS_BIT(7)
336#define ADF4382_ADC_CLK_TEST_SEL_MSK NO_OS_BIT(6)
337#define ADF4382_MUTE_CLKOUT2_MSK NO_OS_GENMASK(5, 3)
338#define ADF4382_MUTE_CLKOUT1_MSK NO_OS_GENMASK(2, 0)
339
340/* ADF4382 REG0041 Map */
341#define ADF4382_EXT_DIV_MSK NO_OS_GENMASK(7, 5)
342#define ADF4382_EN_VCO_CAP_TEST_MSK NO_OS_BIT(4)
343#define ADF4382_EN_CALGEN_CAP_TEST_MSK NO_OS_BIT(3)
344#define ADF4382_EN_CP_CAP_TEST_MSK NO_OS_BIT(2)
345#define ADF4382_CAP_TEST_STATE_MSK NO_OS_BIT(1)
346#define ADF4382_TRANS_LOOP_SEL_MSK NO_OS_BIT(0)
347
348/* ADF4382 REG0042 Map */
349#define ADF4382_NDIV_PWRUP_TIMEOUT_MSK NO_OS_GENMASK(7, 0)
350
351/* ADF4382 REG0043 Map */
352#define ADF4382_CAL_BLEED_FINE_MAX_MSK NO_OS_GENMASK(7, 0)
353
354/* ADF4382 REG0044 Map */
355#define ADF4382_VCAL_ZERO_MSK NO_OS_BIT(7)
356#define ADF4382_VPTAT_CALGEN_MSK NO_OS_GENMASK(6, 0)
357
358/* ADF4382 REG0045 Map */
359#define ADF4382_SPARE_45_MSK NO_OS_BIT(7)
360#define ADF4382_VCTAT_CALGEN_MSK NO_OS_GENMASK(6, 0)
361
362/* ADF4382 REG0046 Map */
363#define ADF4382_NVMDIN_MSK NO_OS_GENMASK(7, 0)
364
365/* ADF4382 REG0047 Map */
366#define ADF4382_SPARE_47_MSK NO_OS_BIT(7)
367#define ADF4382_NVMADDR_MSK NO_OS_GENMASK(6, 3)
368#define ADF4382_NVMNO_OS_BIT_SEL NO_OS_GENMASK(2, 0)
369
370/* ADF4382 REG0048 Map */
371#define ADF4382_TRIM_LATCH_MSK NO_OS_BIT(7)
372#define ADF4382_NVMTEST_MSK NO_OS_BIT(6)
373#define ADF4382_NVMPROG_MSK NO_OS_BIT(5)
374#define ADF4382_NVMRD_MSK NO_OS_BIT(4)
375#define ADF4382_NVMSTART_MSK NO_OS_BIT(3)
376#define ADF4382_NVMON_MSK NO_OS_BIT(2)
377#define ADF4382_MARGIN_MSK NO_OS_GENMASK(1, 0)
378
379/* ADF4382 REG0049 Map */
380#define ADF4382_NVMDOUT_MSK NO_OS_GENMASK(7, 0)
381
382/* ADF4382 REG004A Map */
383#define ADF4382_SCAN_MODE_CODE_MSK NO_OS_GENMASK(7, 0)
384
385/* ADF4382 REG004B Map */
386#define ADF4382_TEMP_OFFSET_MSK NO_OS_GENMASK(7, 0)
387
388/* ADF4382 REG004C Map */
389#define ADF4382_SPARE_4C_MSK NO_OS_GENMASK(7, 6)
390#define ADF4382_TEMP_SLOPE_MSK NO_OS_GENMASK(5, 0)
391
392/* ADF4382 REG004D Map */
393#define ADF4382_VCO_FSM_TEST_MUX_MSK NO_OS_GENMASK(7, 5)
394#define ADF4382_SPARE_4D_MSK NO_OS_GENMASK(4, 3)
395#define ADF4382_O_VCO_BIAS_MSK NO_OS_BIT(2)
396#define ADF4382_O_VCO_BAND_MSK NO_OS_BIT(1)
397#define ADF4382_O_VCO_CORE_MSK NO_OS_BIT(0)
398
399/* ADF4382 REG004E Map */
400#define ADF4382_SPARE_4E_MSK NO_OS_GENMASK(7, 5)
401#define ADF4382_EN_TWO_PASS_CAL_MSK NO_OS_BIT(4)
402#define ADF4382_TWO_PASS_BAND_START_MSK NO_OS_GENMASK(3, 0)
403
404/* ADF4382 REG004F Map */
405#define ADF4382_LUT_SCALE_MSK NO_OS_GENMASK(7, 0)
406
407/* ADF4382 REG0050 Map */
408#define ADF4382_SPARE0_MSK NO_OS_GENMASK(7, 0)
409
410/* ADF4382 REG0051 Map */
411#define ADF4382_SPARE1_MSK NO_OS_GENMASK(7, 0)
412
413/* ADF4382 REG0052 Map */
414#define ADF4382_SYNC_REF_SPARE_MSK NO_OS_GENMASK(7, 4)
415#define ADF4382_SYNC_MON_DEL_MSK NO_OS_GENMASK(3, 0)
416
417/* ADF4382 REG0053 Map */
418#define ADF4382_SPARE_53_MSK NO_OS_BIT(7)
419#define ADF4382_PD_SYNC_MON_MSK NO_OS_BIT(6)
420#define ADF4382_SYNC_SEL_MSK NO_OS_BIT(5)
421#define ADF4382_RST_SYNC_MON_MSK NO_OS_BIT(4)
422#define ADF4382_SYNC_SH_DEL_MSK NO_OS_GENMASK(3, 0)
423
424/* ADF4382 REG0054 Map */
425#define ADF4382_ADC_ST_CNV_MSK NO_OS_BIT(0)
426
427/* ADF4382 REG0058 Map */
428#define ADF4382_FSM_BUSY_MSK NO_OS_BIT(1)
429#define ADF4382_LOCKED_MSK NO_OS_BIT(0)
430
431/* ADF4382 REG005E Map */
432#define ADF4382_VCO_BAND_LSB_MSK NO_OS_GENMASK(7, 0)
433
434/* ADF4382 REG005F Map */
435#define ADF4382_VCO_CORE_MSK NO_OS_BIT(1)
436#define ADF4382_VCO_BAND_MSB_MSK NO_OS_BIT(0)
437
438/* ADF4382 REG0200 Map */
439#define ADF4382_LUT_WR_ADDR_MSK NO_OS_GENMASK(5, 1)
440#define ADF4382_O_VCO_LUT_MSK NO_OS_BIT(0)
441
442/* ADF4382 REG0201 Map */
443#define ADF4382_M_LUT_BAND_LSB_MSK NO_OS_GENMASK(7, 0)
444
445/* ADF4382 REG0202 Map */
446#define ADF4382_M_LUT_N_LSB_MSK NO_OS_GENMASK(7, 2)
447#define ADF4382_M_LUT_CORE_MSK NO_OS_BIT(1)
448#define ADF4382_M_LUT_BAND_MSB_MSK NO_OS_BIT(0)
449
450/* ADF4382 REG0203 Map */
451#define ADF4382_M_LUT_N_MSB_MSK NO_OS_GENMASK(5, 0)
452
453#define ADF4382_SPI_3W_CFG(x) (no_os_field_prep(ADF4382_SDO_ACTIVE_MSK, x) | \
454 no_os_field_prep(ADF4382_SDO_ACTIVE_R_MSK, x))
455
456#define ADF4382_BLEED_MSB_MSK (ADF4382_COARSE_BLEED_MSK | \
457 ADF4382_FINE_BLEED_MSB_MSK)
458
459#define ADF4382_SPI_SCRATCHPAD_TEST 0x5A
460
461/* Specifications */
462#define ADF4382_SPI_WRITE_CMD 0x0
463#define ADF4382_SPI_READ_CMD 0x8000
464#define ADF4382_SPI_DUMMY_DATA 0x00
465#define ADF4382_BUFF_SIZE_BYTES 3
466#define ADF4382_VCO_FREQ_MIN 11000000000U // 11GHz
467#define ADF4382_VCO_FREQ_MAX 22000000000U // 22GHz
468#define ADF4383_VCO_FREQ_MIN 10000000000U // 10GHz
469#define ADF4383_VCO_FREQ_MAX 20000000000U // 20GHz
470#define ADF4382A_VCO_FREQ_MIN 11500000000U // 11.5GHz
471#define ADF4382A_VCO_FREQ_MAX 21000000000U // 21GHz
472#define ADF4382_MOD1WORD 0x2000000U // 2^25
473#define ADF4382_MOD2WORD_MAX 0xFFFFFFU // 2^24 - 1
474#define ADF4382_PHASE_RESYNC_MOD2WORD_MAX 0x1FFFFU // 2^17 - 1
475#define ADF4382_CHANNEL_SPACING_MAX 78125U
476#define ADF4382_PFD_FREQ_MAX 625000000U // 625MHz
477#define ADF4382_PFD_FREQ_FRAC_MAX 250000000U // 250MHz
478#define ADF4382_PFD_FREQ_MIN 5400000U // 5.4MHz
479#define ADF4382_DCLK_DIV1_0_MAX 160000000U // 160MHz
480#define ADF4382_DCLK_DIV1_1_MAX 320000000U // 320MHz
481#define ADF4382_CLKOUT_DIV_REG_VAL_MAX 4
482#define ADF4382A_CLKOUT_DIV_REG_VAL_MAX 2
483
484#define ADF4383_RFOUT_MAX 20000000000U
485#define ADF4383_RFOUT_MIN 625000000U
486#define ADF4382_RFOUT_MAX 22000000000U
487#define ADF4382_RFOUT_MIN 687500000U
488#define ADF4382A_RFOUT_MAX 21000000000U
489#define ADF4382A_RFOUT_MIN 2875000000U
490#define ADF4382_REF_CLK_MAX 5000000000U
491#define ADF4382_REF_CLK_MIN 10000000
492#define ADF4382_REF_DIV_MAX 63
493#define ADF4382_OUT_PWR_MAX 15
494#define ADF4382_CPI_VAL_MAX 15
495#define ADF4382_BLEED_WORD_MAX 8191
496
497#define ADF4382_VPTAT_CALGEN 46
498#define ADF4382_VCTAT_CALGEN 82
499#define ADF4382_FASTCAL_VPTAT_CALGEN 7
500#define ADF4382_FASTCAL_VCTAT_CALGEN 21
501#define ADF4382_PHASE_BLEED_CNST 2044000
502#define ADF4382_VCO_CAL_CNT 183
503#define ADF4382_VCO_CAL_VTUNE 640
504#define ADF4382_VCO_CAL_ALC 123
505#define ADF4382_POR_DELAY_US 200
506#define ADF4382_LKD_DELAY_US 1000
507#define ADF4382_COARSE_BLEED_CONST 180U // 180 microseconds
508#define ADF4382_FINE_BLEED_CONST_1 512U // 512 microseconds
509#define ADF4382_FINE_BLEED_CONST_2 250U // 250 microseconds
510#define ADF4382_CAL_VTUNE_TO 124U
511#define ADF4382_FSM_BUSY_LOOP_CNT 100U
512
513#define MHZ MEGA
514#define S_TO_NS NANO
515#define PS_TO_S PICO
516#define NS_TO_PS KHZ_PER_MHZ
517
526
548
558 uint64_t ref_freq_hz;
559 uint64_t freq;
561 uint8_t ref_div;
562 uint8_t cp_i;
563 uint16_t bleed_word;
564 uint8_t ld_count;
565 uint32_t phase_adj;
566 uint8_t en_lut_gen;
567 uint8_t en_lut_cal;
568 uint64_t vco_max;
569 uint64_t vco_min;
570 uint64_t freq_max;
571 uint64_t freq_min;
574 uint32_t cal_vtune_to;
575 // N_INT variable to trigger auto calibration
576 uint16_t n_int;
577};
578
583struct reg_sequence {
584 uint16_t reg;
585 uint8_t val;
586};
587
592static const struct reg_sequence adf4382_reg_defaults[] = {
593 { 0x000, 0x18 },
594 { 0x00a, 0xA5 },
595 { 0x200, 0x00 },
596 { 0x201, 0x00 },
597 { 0x202, 0x00 },
598 { 0x203, 0x00 },
599 { 0x203, 0x00 },
600 { 0x203, 0x00 },
601 { 0x100, 0x25 },
602 { 0x101, 0x3F },
603 { 0x102, 0x3F },
604 { 0x103, 0x3F },
605 { 0x104, 0x3F },
606 { 0x105, 0x3F },
607 { 0x106, 0x3F },
608 { 0x107, 0x3F },
609 { 0x108, 0x3F },
610 { 0x109, 0x25 },
611 { 0x10A, 0x25 },
612 { 0x10B, 0x3F },
613 { 0x10C, 0x3F },
614 { 0x10D, 0x3F },
615 { 0x10E, 0x3F },
616 { 0x10F, 0x3F },
617 { 0x110, 0x3F },
618 { 0x111, 0x3F },
619 { 0x054, 0x00 },
620 { 0x053, 0x45 },
621 { 0x052, 0x00 },
622 { 0x051, 0x00 },
623 { 0x050, 0x00 },
624 { 0x04f, 0x08 },
625 { 0x04e, 0x06 },
626 { 0x04d, 0x00 },
627 { 0x04c, 0x2B },
628 { 0x04b, 0x5D },
629 { 0x04a, 0x00 },
630 { 0x048, 0x00 },
631 { 0x047, 0x00 },
632 { 0x046, 0x00 },
633 { 0x045, 0x52 },
634 { 0x044, 0x2E },
635 { 0x043, 0xB8 },
636 { 0x042, 0x01 },
637 { 0x041, 0x00 },
638 { 0x040, 0x00 },
639 { 0x03f, 0x82 },
640 { 0x03e, 0x4E },
641 { 0x03d, 0x00 },
642 { 0x03c, 0x00 },
643 { 0x03b, 0x00 },
644 { 0x03a, 0xFA },
645 { 0x039, 0x00 },
646 { 0x038, 0x7C },
647 { 0x037, 0xCA },
648 { 0x036, 0xC0 },
649 { 0x035, 0x00 },
650 { 0x034, 0x36 },
651 { 0x033, 0x00 },
652 { 0x032, 0x40 },
653 { 0x031, 0x63 },
654 { 0x030, 0x0F },
655 { 0x02f, 0x3F },
656 { 0x02e, 0x00 },
657 { 0x02d, 0xF1 },
658 { 0x02c, 0x0E },
659 { 0x02b, 0x01 },
660 { 0x02a, 0x30 },
661 { 0x029, 0x09 },
662 { 0x028, 0x00 },
663 { 0x027, 0xF0 },
664 { 0x026, 0x00 },
665 { 0x025, 0x01 },
666 { 0x024, 0x01 },
667 { 0x023, 0x00 },
668 { 0x022, 0x00 },
669 { 0x021, 0x00 },
670 { 0x020, 0xC1 },
671 { 0x01f, 0x0F },
672 { 0x01e, 0x20 },
673 { 0x01d, 0x00 },
674 { 0x01c, 0x00 },
675 { 0x01b, 0x00 },
676 { 0x01a, 0x00 },
677 { 0x019, 0x00 },
678 { 0x018, 0x00 },
679 { 0x017, 0x00 },
680 { 0x016, 0x00 },
681 { 0x015, 0x06 },
682 { 0x014, 0x00 },
683 { 0x013, 0x00 },
684 { 0x012, 0x00 },
685 { 0x011, 0x00 },
686 { 0x010, 0x50 },
687};
688
690int adf4382_spi_write(struct adf4382_dev *dev, uint16_t reg_addr, uint8_t data);
691
693int adf4382_spi_read(struct adf4382_dev *dev, uint16_t reg_addr, uint8_t *data);
694
696int adf4382_spi_update_bits(struct adf4382_dev *dev, uint16_t reg_addr,
697 uint8_t mask, uint8_t data);
698
700int adf4382_reg_dump(struct adf4382_dev *dev);
701
703int adf4382_set_ref_clk(struct adf4382_dev *dev, uint64_t val);
704
706int adf4382_get_ref_clk(struct adf4382_dev *dev, uint64_t *val);
707
709int adf4382_set_en_ref_doubler(struct adf4382_dev *dev, bool en);
710
712int adf4382_get_en_ref_doubler(struct adf4382_dev *dev, bool *en);
713
715int adf4382_set_ref_div(struct adf4382_dev *dev, int32_t div);
716
718int adf4382_get_ref_div(struct adf4382_dev *dev, int32_t *div);
719
721int adf4382_set_cp_i(struct adf4382_dev *dev, int32_t reg_val);
722
724int adf4382_get_cp_i(struct adf4382_dev *dev, int32_t *reg_val);
725
727int adf4382_set_bleed_word(struct adf4382_dev *dev, int32_t word);
728
730int adf4382_get_bleed_word(struct adf4382_dev *dev, int32_t *word);
731
733int adf4382_set_rfout(struct adf4382_dev *dev, uint64_t val);
734
736int adf4382_get_rfout(struct adf4382_dev *dev, uint64_t *val);
737
739int adf4382_set_out_power(struct adf4382_dev *dev, uint8_t ch, int32_t pwr);
740
742int adf4382_get_out_power(struct adf4382_dev *dev, uint8_t ch, int32_t *pwr);
743
745int adf4382_set_en_chan(struct adf4382_dev *dev, uint8_t ch, bool en);
746
748int adf4382_get_en_chan(struct adf4382_dev *dev, uint8_t ch, bool *en);
749
751int adf4382_set_freq(struct adf4382_dev *dev);
752
754int adf4382_set_en_fast_calibration(struct adf4382_dev *dev, bool en_fast_cal);
755
757int adf4382_set_en_lut_calibration(struct adf4382_dev *dev, bool en_lut_cal);
758
760int adf4382_get_en_lut_calibration(struct adf4382_dev *dev, bool *en);
761
763int adf4382_set_change_freq(struct adf4382_dev *dev);
764
766int adf4382_get_change_rfout(struct adf4382_dev *dev, uint64_t *val);
767
769int adf4382_set_change_rfout(struct adf4382_dev *dev, uint64_t val);
770
773
775int adf4382_get_start_calibration(struct adf4382_dev *dev, bool *start_cal);
776
778int adf4382_set_phase_adjust(struct adf4382_dev *dev, uint32_t phase_ps);
779
781int adf4382_set_phase_pol(struct adf4382_dev *dev, bool polarity);
782
784int adf4382_get_phase_pol(struct adf4382_dev *dev, bool *polarity);
785
787int adf4382_set_ezsync_setup(struct adf4382_dev *dev, bool sync);
788
790int adf4382_set_timed_sync_setup(struct adf4382_dev *dev, bool sync);
791
793int adf4382_get_phase_sync_setup(struct adf4382_dev *dev, bool *en);
794
796int adf4382_set_sw_sync(struct adf4382_dev *dev, bool sw_sync);
797
799int adf4382_get_sw_sync(struct adf4382_dev *dev, bool *sw_sync);
800
803
805int adf4382_init(struct adf4382_dev **device,
807
809int adf4382_remove(struct adf4382_dev *dev);
810
811#endif
struct ad7616_init_param init_param
Definition ad7616_sdz.c:109
int adf4382_get_en_chan(struct adf4382_dev *dev, uint8_t ch, bool *en)
Gets the value the output channel if it is enabled or disable.
Definition adf4382.c:505
int adf4382_get_en_ref_doubler(struct adf4382_dev *dev, bool *en)
Gets the value the doubler if it is enabled or disable and stores it it the dev structure.
Definition adf4382.c:270
int adf4382_spi_read(struct adf4382_dev *dev, uint16_t reg_addr, uint8_t *data)
Reads data from ADF4382 over SPI.
Definition adf4382.c:99
int adf4382_set_sw_sync(struct adf4382_dev *dev, bool sw_sync)
Set Software SYNC Request. Setting SW_SYNC resets the RF block. Clearing SW_SYNC makes ready for a ne...
Definition adf4382.c:1846
int adf4382_set_en_lut_calibration(struct adf4382_dev *dev, bool en_lut_cal)
Sets Fast calibration LUT Calibration. Refer to en_fastcal function to first generate fastcal Lookup ...
Definition adf4382.c:1004
int adf4382_set_en_fast_calibration(struct adf4382_dev *dev, bool en_fast_cal)
Fast calibration function. Computes Minimum VCO frequency (fmin), uses the minimum NDIV value to gene...
Definition adf4382.c:778
int adf4382_get_ref_div(struct adf4382_dev *dev, int32_t *div)
Gets the value the reference divider.
Definition adf4382.c:316
int adf4382_set_freq(struct adf4382_dev *dev)
Set the output frequency.
Definition adf4382.c:1347
int adf4382_set_en_ref_doubler(struct adf4382_dev *dev, bool en)
Set the reference doubler to enable or disable based on the passed parameter. If the parameter is dif...
Definition adf4382.c:248
int adf4382_set_ezsync_setup(struct adf4382_dev *dev, bool sync)
Set the EZSYNC features' initial state. Awaits the SW_SYNC toggle.
Definition adf4382.c:1711
int adf4382_get_en_lut_calibration(struct adf4382_dev *dev, bool *en)
Gets Fast calibration LUT Calibration status.
Definition adf4382.c:984
int adf4382_set_timed_sync_setup(struct adf4382_dev *dev, bool sync)
Set Timed SYNC features' initial state. Uses SYNC pin.
Definition adf4382.c:1754
int adf4382_set_rfout(struct adf4382_dev *dev, uint64_t val)
Set the desired output frequency and reset everything over to maximum supported value of 22GHz (21GHz...
Definition adf4382.c:534
int adf4382_spi_update_bits(struct adf4382_dev *dev, uint16_t reg_addr, uint8_t mask, uint8_t data)
Updates the values of the ADF4382 register.
Definition adf4382.c:137
int adf4382_set_change_rfout(struct adf4382_dev *dev, uint64_t val)
Set the desired output frequency and reset everything over to maximum supported value of 22GHz (21GHz...
Definition adf4382.c:1087
int adf4382_set_en_chan(struct adf4382_dev *dev, uint8_t ch, bool en)
Set the output channel to enable or disable based on the passed parameter. If the parameter is differ...
Definition adf4382.c:482
int adf4382_get_cp_i(struct adf4382_dev *dev, int32_t *reg_val)
Gets the charge pump value from the register. The value will be between 0 and 15 on 8 bits....
Definition adf4382.c:360
adf4382_dev_id
Supported device ids.
Definition adf4382.h:521
@ ID_ADF4383
Definition adf4382.h:524
@ ID_ADF4382A
Definition adf4382.h:523
@ ID_ADF4382
Definition adf4382.h:522
int adf4382_set_bleed_word(struct adf4382_dev *dev, int32_t word)
Set the bleed word, which represents the value of the bleed current written to the register space.
Definition adf4382.c:382
int adf4382_set_cp_i(struct adf4382_dev *dev, int32_t reg_val)
Set the charge pump value which will be written to the register. The value will be between 0 and 15 o...
Definition adf4382.c:339
int adf4382_get_out_power(struct adf4382_dev *dev, uint8_t ch, int32_t *pwr)
Gets the output power register value.
Definition adf4382.c:455
int adf4382_get_rfout(struct adf4382_dev *dev, uint64_t *val)
Gets the user proposed output frequency.
Definition adf4382.c:572
int adf4382_spi_write(struct adf4382_dev *dev, uint16_t reg_addr, uint8_t data)
Writes data to ADF4382 over SPI.
Definition adf4382.c:69
int adf4382_get_change_rfout(struct adf4382_dev *dev, uint64_t *val)
Gets the user proposed output frequency from the device tree without reading from the device....
Definition adf4382.c:1072
int adf4382_init(struct adf4382_dev **device, struct adf4382_init_param *init_param)
Initializes the ADF4382.
Definition adf4382.c:1993
int adf4382_get_phase_sync_setup(struct adf4382_dev *dev, bool *en)
Gets the value of the SYNC powerdown bit.
Definition adf4382.c:1826
int adf4382_set_change_freq(struct adf4382_dev *dev)
Set the output frequency. This will set the required registers to device but skip NDIV value,...
Definition adf4382.c:1152
int adf4382_get_sw_sync(struct adf4382_dev *dev, bool *sw_sync)
Gets the value of the SW_SYNC bit.
Definition adf4382.c:1863
int adf4382_set_out_power(struct adf4382_dev *dev, uint8_t ch, int32_t pwr)
Set the output power register value of a channel and reset everything over to maximum supported value...
Definition adf4382.c:431
int adf4382_get_phase_pol(struct adf4382_dev *dev, bool *polarity)
Gets the polarity of the phase adjust.
Definition adf4382.c:1692
int adf4382_set_phase_adjust(struct adf4382_dev *dev, uint32_t phase_ps)
Set the phase adjustment in pico-seconds. The phase adjust will enable the Bleed current option as we...
Definition adf4382.c:1608
int adf4382_set_vco_cal_timeout(struct adf4382_dev *dev)
Computes and sets the VCO Calibration Timeout values.
Definition adf4382.c:1884
int adf4382_get_start_calibration(struct adf4382_dev *dev, bool *start_cal)
Get the status of start calibration. Will always return zero to allow users set it multiple times to ...
Definition adf4382.c:1324
int adf4382_set_ref_clk(struct adf4382_dev *dev, uint64_t val)
Set the desired reference frequency and reset everything over to maximum supported value of 5GHz to t...
Definition adf4382.c:203
int adf4382_remove(struct adf4382_dev *dev)
Free resources allocated for ADF4382.
Definition adf4382.c:2114
int adf4382_get_ref_clk(struct adf4382_dev *dev, uint64_t *val)
Gets the user proposed reference frequency.
Definition adf4382.c:230
int adf4382_set_phase_pol(struct adf4382_dev *dev, bool polarity)
Set the phase polarity. If pol = 0 then it will add the phase value otherwise it will subtract the ph...
Definition adf4382.c:1676
int adf4382_get_bleed_word(struct adf4382_dev *dev, int32_t *word)
Gets the value of the set bleed word.
Definition adf4382.c:401
int adf4382_reg_dump(struct adf4382_dev *dev)
Will output on the terminal the values of all the ADF4382 registers.
Definition adf4382.c:161
int adf4382_set_start_calibration(struct adf4382_dev *dev)
Set REG0010 value in device structure to the device to start autocal.
Definition adf4382.c:1335
int adf4382_set_ref_div(struct adf4382_dev *dev, int32_t div)
Set the reference divider value and reset everything over to maximum supported value of 63 to the max...
Definition adf4382.c:292
Header file of SPI Interface.
Header file of Units.
Header file of utility functions.
ADF4382 Device Descriptor.
Definition adf4382.h:553
uint8_t en_lut_cal
Definition adf4382.h:567
struct no_os_spi_desc * spi_desc
Definition adf4382.h:555
uint8_t en_lut_gen
Definition adf4382.h:566
bool ref_doubler_en
Definition adf4382.h:560
uint8_t cp_i
Definition adf4382.h:562
uint64_t vco_min
Definition adf4382.h:569
uint32_t phase_adj
Definition adf4382.h:565
uint16_t n_int
Definition adf4382.h:576
uint8_t ref_div
Definition adf4382.h:561
uint32_t cal_vtune_to
Definition adf4382.h:574
uint8_t clkout_div_reg_val_max
Definition adf4382.h:572
uint64_t vco_max
Definition adf4382.h:568
uint16_t bleed_word
Definition adf4382.h:563
uint8_t ld_count
Definition adf4382.h:564
uint8_t max_lpf_cap_value_uf
Definition adf4382.h:573
uint64_t ref_freq_hz
Definition adf4382.h:558
uint64_t freq_max
Definition adf4382.h:570
bool spi_3wire_en
Definition adf4382.h:556
bool cmos_3v3
Definition adf4382.h:557
uint64_t freq_min
Definition adf4382.h:571
uint64_t freq
Definition adf4382.h:559
ADF4382 Initialization Parameters structure.
Definition adf4382.h:531
uint16_t bleed_word
Definition adf4382.h:541
uint8_t max_lpf_cap_value_uf
Definition adf4382.h:545
bool ref_doubler_en
Definition adf4382.h:538
struct no_os_spi_init_param * spi_init
Definition adf4382.h:533
bool spi_3wire_en
Definition adf4382.h:534
uint8_t cp_i
Definition adf4382.h:540
uint8_t ld_count
Definition adf4382.h:542
enum adf4382_dev_id id
Definition adf4382.h:546
bool cmos_3v3
Definition adf4382.h:535
uint64_t ref_freq_hz
Definition adf4382.h:536
uint8_t ref_div
Definition adf4382.h:539
uint8_t en_lut_cal
Definition adf4382.h:544
uint8_t en_lut_gen
Definition adf4382.h:543
uint64_t freq
Definition adf4382.h:537
ADF4382 register initialization.
Definition ad9361_util.h:63
Structure holding SPI descriptor.
Definition no_os_spi.h:180
Structure holding the parameters for SPI initialization.
Definition no_os_spi.h:128
ADF4382 register format structure for default values.
Definition adf4371.c:180
uint8_t val
Definition adf4371.c:182
uint16_t reg
Definition adf4371.c:181