Debian Codegraph @

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

raw symbols SCIP
1 /***************************************************************************//**
2 * @file ADF4351.h
3 * @brief Header file of ADF4351 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 __ADF4351_H__
43 #define __ADF4351_H__
44
45 /* Channels */
46 #define ADF4351_RX_CHANNEL 0
47 #define ADF4351_TX_CHANNEL 1
48
49 /* Registers */
50 #define ADF4351_REG0 0
51 #define ADF4351_REG1 1
52 #define ADF4351_REG2 2
53 #define ADF4351_REG3 3
54 #define ADF4351_REG4 4
55 #define ADF4351_REG5 5
56
57 /* REG0 Bit Definitions */
58 #define ADF4351_REG0_FRACT(x) (((x) & 0xFFF) << 3)
59 #define ADF4351_REG0_INT(x) (((x) & 0xFFFF) << 15)
60
61 /* REG1 Bit Definitions */
62 #define ADF4351_REG1_MOD(x) (((x) & 0xFFF) << 3)
63 #define ADF4351_REG1_PHASE(x) (((x) & 0xFFF) << 15)
64 #define ADF4351_REG1_PRESCALER (1 << 27)
65 #define ADF4351_REG1_PHA_ADJ (1 << 28)
66
67 /* REG2 Bit Definitions */
68 #define ADF4351_REG2_COUNTER_RESET_EN (1 << 3)
69 #define ADF4351_REG2_CP_THREESTATE_EN (1 << 4)
70 #define ADF4351_REG2_POWER_DOWN_EN (1 << 5)
71 #define ADF4351_REG2_PD_POLARITY_POS (1 << 6)
72 #define ADF4351_REG2_LDP_6ns (1 << 7)
73 #define ADF4351_REG2_LDP_10ns (0 << 7)
74 #define ADF4351_REG2_LDF_FRACT_N (0 << 8)
75 #define ADF4351_REG2_LDF_INT_N (1 << 8)
76 #define ADF4351_REG2_CHARGE_PUMP_CURR_uA(x) (((((x)-312) / 312) & 0xF) << 9)
77 #define ADF4351_REG2_DOUBLE_BUFF_EN (1 << 13)
78 #define ADF4351_REG2_10BIT_R_CNT(x) ((x) << 14)
79 #define ADF4351_REG2_RDIV2_EN (1 << 24)
80 #define ADF4351_REG2_RMULT2_EN (1 << 25)
81 #define ADF4351_REG2_MUXOUT(x) ((x) << 26)
82 #define ADF4351_REG2_NOISE_MODE(x) ((x) << 29)
83
84 /* REG3 Bit Definitions */
85 #define ADF4351_REG3_12BIT_CLKDIV(x) ((x) << 3)
86 #define ADF4351_REG3_12BIT_CLKDIV_MODE(x) ((x) << 16)
87 #define ADF4351_REG3_12BIT_CSR_EN (1 << 18)
88 #define ADF4351_REG3_CHARGE_CANCELLATION_EN (1 << 21)
89 #define ADF4351_REG3_ANTI_BACKLASH_3ns_EN (1 << 22)
90 #define ADF4351_REG3_BAND_SEL_CLOCK_MODE_HIGH (1 << 23)
91
92 /* REG4 Bit Definitions */
93 #define ADF4351_REG4_OUTPUT_PWR(x) ((x) << 3)
94 #define ADF4351_REG4_RF_OUT_EN (1 << 5)
95 #define ADF4351_REG4_AUX_OUTPUT_PWR(x) ((x) << 6)
96 #define ADF4351_REG4_AUX_OUTPUT_EN (1 << 8)
97 #define ADF4351_REG4_AUX_OUTPUT_FUND (1 << 9)
98 #define ADF4351_REG4_AUX_OUTPUT_DIV (0 << 9)
99 #define ADF4351_REG4_MUTE_TILL_LOCK_EN (1 << 10)
100 #define ADF4351_REG4_VCO_PWRDOWN_EN (1 << 11)
101 #define ADF4351_REG4_8BIT_BAND_SEL_CLKDIV(x) ((x) << 12)
102 #define ADF4351_REG4_RF_DIV_SEL(x) ((x) << 20)
103 #define ADF4351_REG4_FEEDBACK_DIVIDED (0 << 23)
104 #define ADF4351_REG4_FEEDBACK_FUND (1 << 23)
105
106 /* REG5 Bit Definitions */
107 #define ADF4351_REG5_LD_PIN_MODE_LOW (0 << 22)
108 #define ADF4351_REG5_LD_PIN_MODE_DIGITAL (1 << 22)
109 #define ADF4351_REG5_LD_PIN_MODE_HIGH (3 << 22)
110
111 /* Specifications */
112 #define ADF4351_MAX_OUT_FREQ 4400000000ULL /* Hz */
113 #define ADF4351_MIN_OUT_FREQ 34375000 /* Hz */
114 #define ADF4351_MIN_VCO_FREQ 2200000000ULL /* Hz */
115 #define ADF4351_MAX_FREQ_45_PRESC 3000000000ULL /* Hz */
116 #define ADF4351_MAX_FREQ_PFD 32000000 /* Hz */
117 #define ADF4351_MAX_BANDSEL_CLK 125000 /* Hz */
118 #define ADF4351_MAX_FREQ_REFIN 250000000 /* Hz */
119 #define ADF4351_MAX_MODULUS 4095
120 #define ADF4351_MAX_R_CNT 1023
121
122 /******************************************************************************/
123 /************************ Types Definitions ***********************************/
124 /******************************************************************************/
125 struct adf4351_platform_data
126 {
127 uint32_t clkin;
128 uint32_t channel_spacing;
129 uint64_t power_up_frequency;
130
131 uint16_t ref_div_factor; /* 10-bit R counter */
132 uint8_t ref_doubler_en;
133 uint8_t ref_div2_en;
134
135 uint32_t r2_user_settings;
136 uint32_t r3_user_settings;
137 uint32_t r4_user_settings;
138 int32_t gpio_lock_detect;
139 };
140
141 /******************************************************************************/
142 /************************ Functions Declarations ******************************/
143 /******************************************************************************/
144 /** Initializes the ADF4351. */
145 int32_t adf4351_setup(int8_t channel);
146 /** Stores PLL 0 frequency in Hz. */
147 int64_t adf4351_out_altvoltage0_frequency(int64_t Hz, int8_t channel);
148 /** Stores PLL 0 frequency resolution/channel spacing in Hz. */
149 int32_t adf4351_out_altvoltage0_frequency_resolution(int32_t Hz, int8_t channel);
150 /** Sets PLL 0 REFin frequency in Hz. */
151 int64_t adf4351_out_altvoltage0_refin_frequency(int64_t Hz, int8_t channel);
152 /** Powers down the PLL. */
153 int32_t adf4351_out_altvoltage0_powerdown(int32_t pwd, int8_t channel);
154
155 #endif // __ADF4351_H__