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