Debian Codegraph @

thirdparty/analogdevicesinc/no-OS/fmcomms1/AD9523/AD9523.h

raw symbols SCIP
1 /***************************************************************************//**
2 * @file AD9523.h
3 * @brief Header file of AD9523 Driver.
4 * @author DBogdan ([email protected])
5 ********************************************************************************
6 * Copyright 2012(c) Analog Devices, Inc.
7 *
8 * All rights reserved.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are met:
12 * - Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * - Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
17 * distribution.
18 * - Neither the name of Analog Devices, Inc. nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 * - The use of this software may or may not infringe the patent rights
22 * of one or more patent holders. This license does not release you
23 * from the requirement that you obtain separate licenses from these
24 * patent holders to use this software.
25 * - Use of the software either in source or binary form, must be run
26 * on or directly connected to an Analog Devices Inc. component.
27 *
28 * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
29 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
30 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
31 * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
32 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33 * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
34 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
35 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
36 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 *
39 ********************************************************************************
40 * SVN Revision: $WCREV$
41 *******************************************************************************/
42 #ifndef _AD9523_H_
43 #define _AD9523_H_
44
45 /*****************************************************************************/
46 /***************************** Include Files *********************************/
47 /*****************************************************************************/
48 #include <stdint.h>
49
50 /******************************************************************************/
51 /****************************** AD9523 ****************************************/
52 /******************************************************************************/
53 /* Registers */
54
55 #define AD9523_READ (1 << 15)
56 #define AD9523_WRITE (0 << 15)
57 #define AD9523_CNT(x) (((x) - 1) << 13)
58 #define AD9523_ADDR(x) ((x) & 0xFFF)
59
60 #define AD9523_R1B (1 << 16)
61 #define AD9523_R2B (2 << 16)
62 #define AD9523_R3B (3 << 16)
63 #define AD9523_TRANSF_LEN(x) ((x) >> 16)
64
65 #define AD9523_SERIAL_PORT_CONFIG (AD9523_R1B | 0x0)
66 #define AD9523_VERSION_REGISTER (AD9523_R1B | 0x2)
67 #define AD9523_PART_REGISTER (AD9523_R1B | 0x3)
68 #define AD9523_READBACK_CTRL (AD9523_R1B | 0x4)
69
70 #define AD9523_EEPROM_CUSTOMER_VERSION_ID (AD9523_R2B | 0x6)
71
72 #define AD9523_PLL1_REF_A_DIVIDER (AD9523_R2B | 0x11)
73 #define AD9523_PLL1_REF_B_DIVIDER (AD9523_R2B | 0x13)
74 #define AD9523_PLL1_REF_TEST_DIVIDER (AD9523_R1B | 0x14)
75 #define AD9523_PLL1_FEEDBACK_DIVIDER (AD9523_R2B | 0x17)
76 #define AD9523_PLL1_CHARGE_PUMP_CTRL (AD9523_R2B | 0x19)
77 #define AD9523_PLL1_INPUT_RECEIVERS_CTRL (AD9523_R1B | 0x1A)
78 #define AD9523_PLL1_REF_CTRL (AD9523_R1B | 0x1B)
79 #define AD9523_PLL1_MISC_CTRL (AD9523_R1B | 0x1C)
80 #define AD9523_PLL1_LOOP_FILTER_CTRL (AD9523_R1B | 0x1D)
81
82 #define AD9523_PLL2_CHARGE_PUMP (AD9523_R1B | 0xF0)
83 #define AD9523_PLL2_FEEDBACK_DIVIDER_AB (AD9523_R1B | 0xF1)
84 #define AD9523_PLL2_CTRL (AD9523_R1B | 0xF2)
85 #define AD9523_PLL2_VCO_CTRL (AD9523_R1B | 0xF3)
86 #define AD9523_PLL2_VCO_DIVIDER (AD9523_R1B | 0xF4)
87 #define AD9523_PLL2_LOOP_FILTER_CTRL (AD9523_R2B | 0xF6)
88 #define AD9523_PLL2_R2_DIVIDER (AD9523_R1B | 0xF7)
89
90 #define AD9523_CHANNEL_CLOCK_DIST(ch) (AD9523_R3B | (0x192 + 3 * ch))
91
92 #define AD9523_PLL1_OUTPUT_CTRL (AD9523_R1B | 0x1BA)
93 #define AD9523_PLL1_OUTPUT_CHANNEL_CTRL (AD9523_R1B | 0x1BB)
94
95 #define AD9523_READBACK_0 (AD9523_R1B | 0x22C)
96 #define AD9523_READBACK_1 (AD9523_R1B | 0x22D)
97
98 #define AD9523_STATUS_SIGNALS (AD9523_R3B | 0x232)
99 #define AD9523_POWER_DOWN_CTRL (AD9523_R1B | 0x233)
100 #define AD9523_IO_UPDATE (AD9523_R1B | 0x234)
101
102 #define AD9523_EEPROM_DATA_XFER_STATUS (AD9523_R1B | 0xB00)
103 #define AD9523_EEPROM_ERROR_READBACK (AD9523_R1B | 0xB01)
104 #define AD9523_EEPROM_CTRL1 (AD9523_R1B | 0xB02)
105 #define AD9523_EEPROM_CTRL2 (AD9523_R1B | 0xB03)
106
107 /* AD9523_SERIAL_PORT_CONFIG */
108
109 #define AD9523_SER_CONF_SDO_ACTIVE (1 << 7)
110 #define AD9523_SER_CONF_SOFT_RESET (1 << 5)
111
112 /* AD9523_READBACK_CTRL */
113 #define AD9523_READBACK_CTRL_READ_BUFFERED (1 << 0)
114
115 /* AD9523_PLL1_CHARGE_PUMP_CTRL */
116 #define AD9523_PLL1_CHARGE_PUMP_CURRENT_nA(x) (((x) / 500) & 0x7F)
117 #define AD9523_PLL1_CHARGE_PUMP_TRISTATE (1 << 7)
118 #define AD9523_PLL1_CHARGE_PUMP_MODE_NORMAL (3 << 8)
119 #define AD9523_PLL1_CHARGE_PUMP_MODE_PUMP_DOWN (2 << 8)
120 #define AD9523_PLL1_CHARGE_PUMP_MODE_PUMP_UP (1 << 8)
121 #define AD9523_PLL1_CHARGE_PUMP_MODE_TRISTATE (0 << 8)
122 #define AD9523_PLL1_BACKLASH_PW_MIN (0 << 10)
123 #define AD9523_PLL1_BACKLASH_PW_LOW (1 << 10)
124 #define AD9523_PLL1_BACKLASH_PW_HIGH (2 << 10)
125 #define AD9523_PLL1_BACKLASH_PW_MAX (3 << 10)
126
127 /* AD9523_PLL1_INPUT_RECEIVERS_CTRL */
128 #define AD9523_PLL1_REF_TEST_RCV_EN (1 << 7)
129 #define AD9523_PLL1_REFB_DIFF_RCV_EN (1 << 6)
130 #define AD9523_PLL1_REFA_DIFF_RCV_EN (1 << 5)
131 #define AD9523_PLL1_REFB_RCV_EN (1 << 4)
132 #define AD9523_PLL1_REFA_RCV_EN (1 << 3)
133 #define AD9523_PLL1_REFA_REFB_PWR_CTRL_EN (1 << 2)
134 #define AD9523_PLL1_OSC_IN_CMOS_NEG_INP_EN (1 << 1)
135 #define AD9523_PLL1_OSC_IN_DIFF_EN (1 << 0)
136
137 /* AD9523_PLL1_REF_CTRL */
138 #define AD9523_PLL1_BYPASS_REF_TEST_DIV_EN (1 << 7)
139 #define AD9523_PLL1_BYPASS_FEEDBACK_DIV_EN (1 << 6)
140 #define AD9523_PLL1_ZERO_DELAY_MODE_INT (1 << 5)
141 #define AD9523_PLL1_ZERO_DELAY_MODE_EXT (0 << 5)
142 #define AD9523_PLL1_OSC_IN_PLL_FEEDBACK_EN (1 << 4)
143 #define AD9523_PLL1_ZD_IN_CMOS_NEG_INP_EN (1 << 3)
144 #define AD9523_PLL1_ZD_IN_DIFF_EN (1 << 2)
145 #define AD9523_PLL1_REFB_CMOS_NEG_INP_EN (1 << 1)
146 #define AD9523_PLL1_REFA_CMOS_NEG_INP_EN (1 << 0)
147
148 /* AD9523_PLL1_MISC_CTRL */
149 #define AD9523_PLL1_REFB_INDEP_DIV_CTRL_EN (1 << 7)
150 #define AD9523_PLL1_OSC_CTRL_FAIL_VCC_BY2_EN (1 << 6)
151 #define AD9523_PLL1_REF_MODE(x) ((x) << 2)
152 #define AD9523_PLL1_BYPASS_REFB_DIV (1 << 1)
153 #define AD9523_PLL1_BYPASS_REFA_DIV (1 << 0)
154
155 /* AD9523_PLL1_LOOP_FILTER_CTRL */
156 #define AD9523_PLL1_LOOP_FILTER_RZERO(x) ((x) & 0xF)
157
158 /* AD9523_PLL2_CHARGE_PUMP */
159 #define AD9523_PLL2_CHARGE_PUMP_CURRENT_nA(x) ((x) / 3500)
160
161 /* AD9523_PLL2_FEEDBACK_DIVIDER_AB */
162 #define AD9523_PLL2_FB_NDIV_A_CNT(x) (((x) & 0x3) << 6)
163 #define AD9523_PLL2_FB_NDIV_B_CNT(x) (((x) & 0x3F) << 0)
164 #define AD9523_PLL2_FB_NDIV(a, b) (4 * (b) + (a))
165
166 /* AD9523_PLL2_CTRL */
167 #define AD9523_PLL2_CHARGE_PUMP_MODE_NORMAL (3 << 0)
168 #define AD9523_PLL2_CHARGE_PUMP_MODE_PUMP_DOWN (2 << 0)
169 #define AD9523_PLL2_CHARGE_PUMP_MODE_PUMP_UP (1 << 0)
170 #define AD9523_PLL2_CHARGE_PUMP_MODE_TRISTATE (0 << 0)
171 #define AD9523_PLL2_BACKLASH_PW_MIN (0 << 2)
172 #define AD9523_PLL2_BACKLASH_PW_LOW (1 << 2)
173 #define AD9523_PLL2_BACKLASH_PW_HIGH (2 << 2)
174 #define AD9523_PLL2_BACKLASH_PW_MAX (3 << 1)
175 #define AD9523_PLL2_BACKLASH_CTRL_EN (1 << 4)
176 #define AD9523_PLL2_FREQ_DOUBLER_EN (1 << 5)
177 #define AD9523_PLL2_LOCK_DETECT_PWR_DOWN_EN (1 << 7)
178
179 /* AD9523_PLL2_VCO_CTRL */
180 #define AD9523_PLL2_VCO_CALIBRATE (1 << 1)
181 #define AD9523_PLL2_FORCE_VCO_MIDSCALE (1 << 2)
182 #define AD9523_PLL2_FORCE_REFERENCE_VALID (1 << 3)
183 #define AD9523_PLL2_FORCE_RELEASE_SYNC (1 << 4)
184
185 /* AD9523_PLL2_VCO_DIVIDER */
186 #define AD9523_PLL2_VCO_DIV_M1(x) ((((x) - 3) & 0x3) << 0)
187 #define AD9523_PLL2_VCO_DIV_M2(x) ((((x) - 3) & 0x3) << 4)
188 #define AD9523_PLL2_VCO_DIV_M1_PWR_DOWN_EN (1 << 2)
189 #define AD9523_PLL2_VCO_DIV_M2_PWR_DOWN_EN (1 << 6)
190
191 /* AD9523_PLL2_LOOP_FILTER_CTRL */
192 #define AD9523_PLL2_LOOP_FILTER_CPOLE1(x) (((x) & 0x7) << 0)
193 #define AD9523_PLL2_LOOP_FILTER_RZERO(x) (((x) & 0x7) << 3)
194 #define AD9523_PLL2_LOOP_FILTER_RPOLE2(x) (((x) & 0x7) << 6)
195 #define AD9523_PLL2_LOOP_FILTER_RZERO_BYPASS_EN (1 << 8)
196
197 /* AD9523_PLL2_R2_DIVIDER */
198 #define AD9523_PLL2_R2_DIVIDER_VAL(x) (((x) & 0x1F) << 0)
199
200 /* AD9523_CHANNEL_CLOCK_DIST */
201 #define AD9523_CLK_DIST_DIV_PHASE(x) (((x) & 0x3F) << 18)
202 #define AD9523_CLK_DIST_DIV_PHASE_REV(x) ((ret >> 18) & 0x3F)
203 #define AD9523_CLK_DIST_DIV(x) ((((x) - 1) & 0x3FF) << 8)
204 #define AD9523_CLK_DIST_DIV_REV(x) (((ret >> 8) & 0x3FF) + 1)
205 #define AD9523_CLK_DIST_INV_DIV_OUTPUT_EN (1 << 7)
206 #define AD9523_CLK_DIST_IGNORE_SYNC_EN (1 << 6)
207 #define AD9523_CLK_DIST_PWR_DOWN_EN (1 << 5)
208 #define AD9523_CLK_DIST_LOW_PWR_MODE_EN (1 << 4)
209 #define AD9523_CLK_DIST_DRIVER_MODE(x) (((x) & 0xF) << 0)
210
211 /* AD9523_PLL1_OUTPUT_CTRL */
212 #define AD9523_PLL1_OUTP_CTRL_VCO_DIV_SEL_CH6_M2 (1 << 7)
213 #define AD9523_PLL1_OUTP_CTRL_VCO_DIV_SEL_CH5_M2 (1 << 6)
214 #define AD9523_PLL1_OUTP_CTRL_VCO_DIV_SEL_CH4_M2 (1 << 5)
215 #define AD9523_PLL1_OUTP_CTRL_CMOS_DRV_WEAK (1 << 4)
216 #define AD9523_PLL1_OUTP_CTRL_OUTPUT_DIV_1 (0 << 0)
217 #define AD9523_PLL1_OUTP_CTRL_OUTPUT_DIV_2 (1 << 0)
218 #define AD9523_PLL1_OUTP_CTRL_OUTPUT_DIV_4 (2 << 0)
219 #define AD9523_PLL1_OUTP_CTRL_OUTPUT_DIV_8 (4 << 0)
220 #define AD9523_PLL1_OUTP_CTRL_OUTPUT_DIV_16 (8 << 0)
221
222 /* AD9523_PLL1_OUTPUT_CHANNEL_CTRL */
223 #define AD9523_PLL1_OUTP_CH_CTRL_OUTPUT_PWR_DOWN_EN (1 << 7)
224 #define AD9523_PLL1_OUTP_CH_CTRL_VCO_DIV_SEL_CH9_M2 (1 << 6)
225 #define AD9523_PLL1_OUTP_CH_CTRL_VCO_DIV_SEL_CH8_M2 (1 << 5)
226 #define AD9523_PLL1_OUTP_CH_CTRL_VCO_DIV_SEL_CH7_M2 (1 << 4)
227 #define AD9523_PLL1_OUTP_CH_CTRL_VCXO_SRC_SEL_CH3 (1 << 3)
228 #define AD9523_PLL1_OUTP_CH_CTRL_VCXO_SRC_SEL_CH2 (1 << 2)
229 #define AD9523_PLL1_OUTP_CH_CTRL_VCXO_SRC_SEL_CH1 (1 << 1)
230 #define AD9523_PLL1_OUTP_CH_CTRL_VCXO_SRC_SEL_CH0 (1 << 0)
231
232 /* AD9523_READBACK_0 */
233 #define AD9523_READBACK_0_STAT_PLL2_REF_CLK (1 << 7)
234 #define AD9523_READBACK_0_STAT_PLL2_FB_CLK (1 << 6)
235 #define AD9523_READBACK_0_STAT_VCXO (1 << 5)
236 #define AD9523_READBACK_0_STAT_REF_TEST (1 << 4)
237 #define AD9523_READBACK_0_STAT_REFB (1 << 3)
238 #define AD9523_READBACK_0_STAT_REFA (1 << 2)
239 #define AD9523_READBACK_0_STAT_PLL2_LD (1 << 1)
240 #define AD9523_READBACK_0_STAT_PLL1_LD (1 << 0)
241
242 /* AD9523_READBACK_1 */
243 #define AD9523_READBACK_1_HOLDOVER_ACTIVE (1 << 3)
244 #define AD9523_READBACK_1_AUTOMODE_SEL_REFB (1 << 2)
245 #define AD9523_READBACK_1_VCO_CALIB_IN_PROGRESS (1 << 0)
246
247 /* AD9523_STATUS_SIGNALS */
248 #define AD9523_STATUS_SIGNALS_SYNC_MAN_CTRL (1 << 16)
249 #define AD9523_STATUS_MONITOR_01_PLL12_LOCKED (0x302)
250 /* AD9523_POWER_DOWN_CTRL */
251 #define AD9523_POWER_DOWN_CTRL_PLL1_PWR_DOWN (1 << 2)
252 #define AD9523_POWER_DOWN_CTRL_PLL2_PWR_DOWN (1 << 1)
253 #define AD9523_POWER_DOWN_CTRL_DIST_PWR_DOWN (1 << 0)
254
255 /* AD9523_IO_UPDATE */
256 #define AD9523_IO_UPDATE_EN (1 << 0)
257
258 /* AD9523_EEPROM_DATA_XFER_STATUS */
259 #define AD9523_EEPROM_DATA_XFER_IN_PROGRESS (1 << 0)
260
261 /* AD9523_EEPROM_ERROR_READBACK */
262 #define AD9523_EEPROM_ERROR_READBACK_FAIL (1 << 0)
263
264 /* AD9523_EEPROM_CTRL1 */
265 #define AD9523_EEPROM_CTRL1_SOFT_EEPROM (1 << 1)
266 #define AD9523_EEPROM_CTRL1_EEPROM_WRITE_PROT_DIS (1 << 0)
267
268 /* AD9523_EEPROM_CTRL2 */
269 #define AD9523_EEPROM_CTRL2_REG2EEPROM (1 << 0)
270
271 #define AD9523_NUM_CHAN 14
272 #define AD9523_NUM_CHAN_ALT_CLK_SRC 10
273
274 /******************************************************************************/
275 /************************ Types Definitions ***********************************/
276 /******************************************************************************/
277 enum outp_drv_mode
278 {
279 TRISTATE,
280 LVPECL_8mA,
281 LVDS_4mA,
282 LVDS_7mA,
283 HSTL0_16mA,
284 HSTL1_8mA,
285 CMOS_CONF1,
286 CMOS_CONF2,
287 CMOS_CONF3,
288 CMOS_CONF4,
289 CMOS_CONF5,
290 CMOS_CONF6,
291 CMOS_CONF7,
292 CMOS_CONF8,
293 CMOS_CONF9
294 };
295
296 enum ref_sel_mode
297 {
298 NONEREVERTIVE_STAY_ON_REFB,
299 REVERT_TO_REFA,
300 SELECT_REFA,
301 SELECT_REFB,
302 EXT_REF_SEL
303 };
304
305 /**
306 * struct ad9523_channel_spec - Output channel configuration
307 *
308 * @channel_num: Output channel number.
309 * @divider_output_invert_en: Invert the polarity of the output clock.
310 * @sync_ignore_en: Ignore chip-level SYNC signal.
311 * @low_power_mode_en: Reduce power used in the differential output modes.
312 * @use_alt_clock_src: Channel divider uses alternative clk source.
313 * @output_dis: Disables, powers down the entire channel.
314 * @driver_mode: Output driver mode (logic level family).
315 * @divider_phase: Divider initial phase after a SYNC. Range 0..63
316 LSB = 1/2 of a period of the divider input clock.
317 * @channel_divider: 10-bit channel divider.
318 * @extended_name: Optional descriptive channel name.
319 */
320
321 struct ad9523_channel_spec
322 {
323 unsigned channel_num;
324 unsigned char divider_output_invert_en;
325 unsigned char sync_ignore_en;
326 unsigned char low_power_mode_en;
327 unsigned char use_alt_clock_src; /* CH0..CH3 VCXO, CH4..CH9 VCO2 */
328 unsigned char output_dis;
329 unsigned char driver_mode;
330 unsigned char divider_phase;
331 unsigned short channel_divider;
332 char extended_name[16];
333 };
334
335 enum pll1_rzero_resistor {
336 RZERO_883_OHM,
337 RZERO_677_OHM,
338 RZERO_341_OHM,
339 RZERO_135_OHM,
340 RZERO_10_OHM,
341 RZERO_USE_EXT_RES = 8,
342 };
343
344 enum rpole2_resistor {
345 RPOLE2_900_OHM,
346 RPOLE2_450_OHM,
347 RPOLE2_300_OHM,
348 RPOLE2_225_OHM,
349 };
350
351 enum rzero_resistor {
352 RZERO_3250_OHM,
353 RZERO_2750_OHM,
354 RZERO_2250_OHM,
355 RZERO_2100_OHM,
356 RZERO_3000_OHM,
357 RZERO_2500_OHM,
358 RZERO_2000_OHM,
359 RZERO_1850_OHM,
360 };
361
362 enum cpole1_capacitor {
363 CPOLE1_0_PF,
364 CPOLE1_8_PF,
365 CPOLE1_16_PF,
366 CPOLE1_24_PF,
367 _CPOLE1_24_PF, /* place holder */
368 CPOLE1_32_PF,
369 CPOLE1_40_PF,
370 CPOLE1_48_PF,
371 };
372
373 /**
374 * struct ad9523_platform_data - platform specific information
375 *
376 * @vcxo_freq: External VCXO frequency in Hz
377 * @refa_diff_rcv_en: REFA differential/single-ended input selection.
378 * @refb_diff_rcv_en: REFB differential/single-ended input selection.
379 * @zd_in_diff_en: Zero Delay differential/single-ended input selection.
380 * @osc_in_diff_en: OSC differential/ single-ended input selection.
381 * @refa_cmos_neg_inp_en: REFA single-ended neg./pos. input enable.
382 * @refb_cmos_neg_inp_en: REFB single-ended neg./pos. input enable.
383 * @zd_in_cmos_neg_inp_en: Zero Delay single-ended neg./pos. input enable.
384 * @osc_in_cmos_neg_inp_en: OSC single-ended neg./pos. input enable.
385 * @refa_r_div: PLL1 10-bit REFA R divider.
386 * @refb_r_div: PLL1 10-bit REFB R divider.
387 * @pll1_feedback_div: PLL1 10-bit Feedback N divider.
388 * @pll1_charge_pump_current_nA: Magnitude of PLL1 charge pump current (nA).
389 * @zero_delay_mode_internal_en: Internal, external Zero Delay mode selection.
390 * @osc_in_feedback_en: PLL1 feedback path, local feedback from
391 * the OSC_IN receiver or zero delay mode
392 * @pll1_loop_filter_rzero: PLL1 Loop Filter Zero Resistor selection.
393 * @ref_mode: Reference selection mode.
394 * @pll2_charge_pump_current_nA: Magnitude of PLL2 charge pump current (nA).
395 * @pll2_ndiv_a_cnt: PLL2 Feedback N-divider, A Counter, range 0..4.
396 * @pll2_ndiv_b_cnt: PLL2 Feedback N-divider, B Counter, range 0..63.
397 * @pll2_freq_doubler_en: PLL2 frequency doubler enable.
398 * @pll2_r2_div: PLL2 R2 divider, range 0..31.
399 * @pll2_vco_diff_m1: VCO1 divider, range 3..5.
400 * @pll2_vco_diff_m2: VCO2 divider, range 3..5.
401 * @rpole2: PLL2 loop filter Rpole resistor value.
402 * @rzero: PLL2 loop filter Rzero resistor value.
403 * @cpole1: PLL2 loop filter Cpole capacitor value.
404 * @rzero_bypass_en: PLL2 loop filter Rzero bypass enable.
405 * @num_channels: Array size of struct ad9523_channel_spec.
406 * @channels: Pointer to channel array.
407 * @name: Optional alternative iio device name.
408 */
409
410 struct ad9523_platform_data
411 {
412 unsigned long vcxo_freq;
413
414 /* Differential/ Single-Ended Input Configuration */
415 unsigned char refa_diff_rcv_en;
416 unsigned char refb_diff_rcv_en;
417 unsigned char zd_in_diff_en;
418 unsigned char osc_in_diff_en;
419
420 /*
421 * Valid if differential input disabled
422 * if not true defaults to pos input
423 */
424 unsigned char refa_cmos_neg_inp_en;
425 unsigned char refb_cmos_neg_inp_en;
426 unsigned char zd_in_cmos_neg_inp_en;
427 unsigned char osc_in_cmos_neg_inp_en;
428
429 /* PLL1 Setting */
430 unsigned short refa_r_div;
431 unsigned short refb_r_div;
432 unsigned short pll1_feedback_div;
433 unsigned short pll1_charge_pump_current_nA;
434 unsigned char zero_delay_mode_internal_en;
435 unsigned char osc_in_feedback_en;
436 unsigned char pll1_loop_filter_rzero;
437
438 /* Reference */
439 unsigned char ref_mode;
440
441 /* PLL2 Setting */
442 unsigned int pll2_charge_pump_current_nA;
443 unsigned char pll2_ndiv_a_cnt;
444 unsigned char pll2_ndiv_b_cnt;
445 unsigned char pll2_freq_doubler_en;
446 unsigned char pll2_r2_div;
447 unsigned char pll2_vco_diff_m1; /* 3..5 */
448 unsigned char pll2_vco_diff_m2; /* 3..5 */
449
450 /* Loop Filter PLL2 */
451 unsigned char rpole2;
452 unsigned char rzero;
453 unsigned char cpole1;
454 unsigned char rzero_bypass_en;
455
456 /* Output Channel Configuration */
457 int num_channels;
458 struct ad9523_channel_spec *channels;
459
460 char name[16];
461 };
462
463 #define ARRAY_SIZE(ar) (sizeof(ar)/sizeof(ar[0]))
464
465 /******************************************************************************/
466 /************************ Functions Declarations ******************************/
467 /******************************************************************************/
468 /** Initializes the AD9523. */
469 int32_t ad9523_setup();
470 /** Resets the device. */
471 int32_t ad9523_reset();
472 /** Determines the achievable output frequency for the DAC CLK channel */
473 uint32_t ad9523_clk_round_rate_DAC_CLK(uint32_t rate);
474 /** Determines the achievable output frequency for the DAC DCO CLK channel */
475 uint32_t ad9523_clk_round_rate_DAC_DCO_CLK(uint32_t rate);
476 /** Determines the achievable output frequency for the DAC REF CLK channel */
477 uint32_t ad9523_clk_round_rate_DAC_REF_CLK(uint32_t rate);
478 /** Sets the output frequency for channel 0. */
479 int64_t ad9523_out_altvoltage_ZD_OUTPUT_frequency(int64_t Hz);
480 /** Sets the phase for channel 0. */
481 int64_t ad9523_out_altvoltage_ZD_OUTPUT_phase(int64_t rad);
482 /** Powers down / enables channel 0. */
483 int64_t ad9523_out_altvoltage_ZD_OUTPUT_raw(int64_t raw_data);
484 /** Sets the output frequency for channel 12. */
485 int64_t ad9523_out_altvoltage_DAC_CLK_frequency(int64_t Hz);
486 /** Sets the phase for channel 12. */
487 int64_t ad9523_out_altvoltage_DAC_CLK_phase(int64_t rad);
488 /** Powers down / enables channel 12. */
489 int64_t ad9523_out_altvoltage_DAC_CLK_raw(int64_t raw_data);
490 /** Sets the output frequency for channel 2. */
491 int64_t ad9523_out_altvoltage_ADC_CLK_frequency(int64_t Hz);
492 /** Sets the phase for channel 2. */
493 int64_t ad9523_out_altvoltage_ADC_CLK_phase(int64_t rad);
494 /** Powers down / enables channel 2. */
495 int64_t ad9523_out_altvoltage_ADC_CLK_raw(int64_t raw_data);
496 /** Sets the output frequency for channel 10. */
497 int64_t ad9523_out_altvoltage_DAC_REF_CLK_frequency(int64_t Hz);
498 /** Sets the phase for channel 10. */
499 int64_t ad9523_out_altvoltage_DAC_REF_CLK_phase(int64_t rad);
500 /** Powers down / enables channel 10. */
501 int64_t ad9523_out_altvoltage_DAC_REF_CLK_raw(int64_t raw_data);
502 /** Sets the output frequency for channel 5. */
503 int64_t ad9523_out_altvoltage_TX_LO_REF_CLK_frequency(int64_t Hz);
504 /** Sets the phase for channel 5. */
505 int64_t ad9523_out_altvoltage_TX_LO_REF_CLK_phase(int64_t rad);
506 /** Powers down / enables channel 5. */
507 int64_t ad9523_out_altvoltage_TX_LO_REF_CLK_raw(int64_t raw_data);
508 /** Sets the output frequency for channel 6. */
509 int64_t ad9523_out_altvoltage_DAC_DCO_CLK_frequency(int64_t Hz);
510 /** Sets the phase for channel 6. */
511 int64_t ad9523_out_altvoltage_DAC_DCO_CLK_phase(int64_t rad);
512 /** Powers down / enables channel 6. */
513 int64_t ad9523_out_altvoltage_DAC_DCO_CLK_raw(int64_t raw_data);
514 /** Sets the output frequency for channel 7. */
515 int64_t ad9523_out_altvoltage_ADC_SYNC_CLK_frequency(int64_t Hz);
516 /** Sets the phase for channel 7. */
517 int64_t ad9523_out_altvoltage_ADC_SYNC_CLK_phase(int64_t rad);
518 /** Powers down / enables channel 7. */
519 int64_t ad9523_out_altvoltage_ADC_SYNC_CLK_raw(int64_t raw_data);
520 /** Sets the output frequency for channel 9. */
521 int64_t ad9523_out_altvoltage_RX_LO_REF_CLK_frequency(int64_t Hz);
522 /** Sets the phase for channel 9. */
523 int64_t ad9523_out_altvoltage_RX_LO_REF_CLK_phase(int64_t rad);
524 /** Powers down / enables channel 9. */
525 int64_t ad9523_out_altvoltage_RX_LO_REF_CLK_raw(int64_t raw_data);
526 /** Returns the state of the PLL2 feedback clock */
527 int32_t ad9523_pll2_feedback_clk_present();
528 /** Returns the state of the PLL2 reference clock */
529 int32_t ad9523_pll2_reference_clk_present();
530 /** Returns the state of the PLL1 reference clock A */
531 int32_t ad9523_pll1_reference_clk_a_present();
532 /** Returns the state of the PLL1 reference clock B */
533 int32_t ad9523_pll1_reference_clk_b_present();
534 /** Returns the state of the PLL1 reference clock test */
535 int32_t ad9523_pll1_reference_clk_test_present();
536 /** Returns the state of the VCXO clock */
537 int32_t ad9523_vcxo_clk_present();
538 /** Stores the current device configuration into on-chip EEPROM. */
539 int32_t ad9523_store_eeprom();
540 /** Triggers the clock distribution synchronization functionality. */
541 int32_t ad9523_sync_dividers();
542
543 #endif // __AD9523_H__