Skip to content

Commit a428b51

Browse files
committed
drivers:frequency:adf4371: Added the README documentation for ADF4371
Added the README file for the ADF4371 driver. Modified the sphinx drivers_doc.rst file to add the corresponding source. Added changes based on reviewer's comments. Signed-off-by: Carl Ian Gamutan <[email protected]>
1 parent 1cc7551 commit a428b51

File tree

2 files changed

+233
-0
lines changed

2 files changed

+233
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.. include:: ../../../../../drivers/frequency/adf4371/README.rst
Lines changed: 232 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,232 @@
1+
ADF4371 no-OS Driver
2+
====================
3+
4+
Supported Devices
5+
-----------------
6+
7+
- :adi:`ADF4371`
8+
- :adi:`ADF4372`
9+
10+
Overview
11+
--------
12+
13+
The ADF4371 features an RF output frequency range of 62.5 MHz to 32,000
14+
MHz. The ADF4371 includes a fractional-N synthesizer and an integer N
15+
synthesizer with a high resolution 39-bit fractional modulus. The device
16+
implements fractional-N or integer N phase-locked loop (PLL) frequency
17+
synthesizers with an external loop filter and an external reference
18+
frequency. The wideband microwave voltage-controlled oscillator (VCO)
19+
design generates frequencies from 62.5 MHz to 32,000 MHz. The ADF4371
20+
has an integrated VCO with a fundamental output frequency ranging from
21+
4000 MHz to 8000 MHz and connects to divide-by circuits that permit
22+
generation of RF output frequencies as low as 62.5 MHz.
23+
24+
Applications
25+
-------------
26+
27+
- Wireless infrastructure (multicarrier global system for mobile
28+
communication, 5G) power-down modes
29+
- Test equipment and instrumentation
30+
- Clock generation
31+
- Aerospace and defense
32+
33+
Operation Modes
34+
---------------
35+
36+
+------------------+--------------------------+--------------------------+-----------------------------+
37+
| Mode Name | Description | Configuration Bits | Typical Use |
38+
+==================+==========================+==========================+=============================+
39+
| Tristate | High impedance output | ADF4371_MUXOUT_TRISTATE | Disable output when not used|
40+
+------------------+--------------------------+--------------------------+-----------------------------+
41+
| Digital Lock | Digital lock detect | ADF4371_MUXOUT_DIG_LOCK | Monitor PLL lock status |
42+
+------------------+--------------------------+--------------------------+-----------------------------+
43+
| Charge Pump Up | Charge pump up signal | ADF4371_MUXOUT_CH_PUMP_UP| Upward charge pump operation|
44+
+------------------+--------------------------+--------------------------+-----------------------------+
45+
| Charge Pump Down | Charge pump down signal | ADF4371_MUXOUT_CH | Downward charge pump |
46+
| | | _PUMP_DOWN | operation |
47+
+------------------+--------------------------+--------------------------+-----------------------------+
48+
| RDIV2 | Reference clock ÷2 | ADF4371_MUXOUT_RDIV2 | Divided reference output |
49+
+------------------+--------------------------+--------------------------+-----------------------------+
50+
| N Divider Output | N divider signal | ADF4371_MUXOUT_N_DIV_OUT | Debug PLL divider settings |
51+
+------------------+--------------------------+--------------------------+-----------------------------+
52+
| VCO Test | VCO test mode | ADF4371_MUXOUT_VCO_TEST | Test VCO performance |
53+
+------------------+--------------------------+--------------------------+-----------------------------+
54+
| High | Output forced high | ADF4371_MUXOUT_HIGH | Override for test |
55+
+------------------+--------------------------+--------------------------+-----------------------------+
56+
| VCO Cal R Band | VCO cal for R band | ADF4371_MUXOUT_VCO | Calibrate VCO R band |
57+
| | | _CALIB_R_B | |
58+
+------------------+--------------------------+--------------------------+-----------------------------+
59+
| VCO Cal N Band | VCO cal for N band | ADF4371_MUXOUT | Calibrate VCO N band |
60+
| | | _VCO_CALIB_N_BAND | |
61+
+------------------+--------------------------+--------------------------+-----------------------------+
62+
63+
Device Configuration
64+
--------------------
65+
66+
Initialization
67+
~~~~~~~~~~~~~~
68+
69+
The function ``adf4371_init()`` configures the device with given
70+
parameters and allocates the necessary resources. The function
71+
``adf4371_remove()`` releases these resources and removes the device
72+
instance from the system.
73+
74+
SPI Communication Functions
75+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
76+
77+
The SPI communication functions for the ADF4371 device serve to enable
78+
efficient data transactions between the device and a controlling system.
79+
The ``adf4371_write`` function allows writing an 8-bit value to a
80+
specified 16-bit register by building a command from the register
81+
address and write operation, which is then transmitted through a 3-byte
82+
buffer over SPI. It confirms success with a return code of 0, or an
83+
appropriate negative error code upon failure.
84+
85+
The ``adf4371_write_bulk`` function extends this capability by
86+
facilitating the writing of multiple bytes from an array to a device
87+
register, using a buffer that incorporates the write command, the
88+
register address, and the data. Like ``adf4371_write``, it returns 0
89+
upon success, with negative codes indicating errors. The
90+
``adf4371_read`` function, on the other hand, reads an 8-bit value from
91+
a defined 16-bit register by issuing a read command and storing the
92+
result from the SPI response.
93+
94+
Register and Frequency Configuration
95+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
96+
97+
The ``adf4371_update`` function operates by reading a register’s current
98+
value, applying a bitmask to clear certain bits, and then writing back
99+
the modified value to update specific bits of the register. It returns 0
100+
to indicate a successful operation or a negative error code if any step
101+
fails. This function is crucial for ensuring precise control over the
102+
ADF4371 device’s configuration and is often employed in modifying
103+
registers to ensure they adhere to desired specifications.
104+
105+
The ``adf4371_pll_fract_n_compute`` function calculates the PLL (Phase
106+
Locked Loop) parameters such as integer and fractional division
107+
components for the VCO (Voltage Controlled Oscillator) based on its
108+
frequency and the PFD (Phase Frequency Detector) frequency.
109+
110+
In contrast, ``adf4371_pll_fract_n_get_rate`` computes the output
111+
frequency for a specific channel, returning it as a 64-bit integer.
112+
Finally, ``adf4371_set_freq`` sets a channel’s frequency by validating
113+
the frequency, adjusting dividers, computing the necessary PLL
114+
parameters, and updating device registers accordingly, returning 0 for
115+
success or a negative error upon failure.
116+
117+
Channel Control
118+
~~~~~~~~~~~~~~~
119+
120+
The ``adf4371_channel_power_down`` function modifies the power state of
121+
a specified channel in the ADF4371 device by altering the register bit
122+
corresponding to the power-down state, effectively enabling or disabling
123+
the channel power as needed. It takes a device pointer, channel number,
124+
and a boolean to indicate power state, and returns 0 on success or a
125+
negative error code upon failure.
126+
127+
Meanwhile, ``adf4371_channel_config`` manages the frequency
128+
configuration and power state of channels, ensuring each channel’s
129+
frequency matches its desired setting. It iterates over channels, sets
130+
frequencies if needed, and utilizes ``adf4371_channel_power_down`` to
131+
power up channels, reporting 0 on success and a negative code if an
132+
error occurs during operations.
133+
134+
Device Setup and Initialization
135+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
136+
137+
The setup and operation of the ADF4371 involve several key steps
138+
primarily facilitated through SPI communication. Initially, the SPI
139+
interface is configured by writing specific values to registers, namely
140+
REG0000 and REG0001, to establish a 4-wire SPI operation. This is the
141+
foundation for subsequent initialization and operation.
142+
143+
The initialization sequence requires writing to registers in reverse
144+
order, from address 0x7C to address 0x10, to prepare the device for
145+
frequency updates. Following initialization, the frequency update
146+
sequence involves modifying the R, MOD2, FRAC1, FRAC2, and INT
147+
registers, ensuring accurate phase-frequency detector operation. The
148+
ADF4371’s channel control manages the power state and frequency settings
149+
for each channel.
150+
151+
Clock Control
152+
~~~~~~~~~~~~~
153+
154+
The ``adf4371_clk_recalc_rate`` function recalculates and outputs the
155+
current frequency rate for a specified channel on the ADF4371 device. It
156+
checks if the specified channel number is valid, invokes
157+
``adf4371_pll_fract_n_get_rate`` to obtain the recalculated rate, and
158+
stores it in the provided location. It returns 0 on success or -1 if the
159+
channel is invalid.
160+
161+
The ``adf4371_clk_round_rate`` function sets the desired frequency to
162+
the closest achievable rate. It directly assigns the input rate to the
163+
location pointed to by ``rounded_rate`` and consistently returns 0,
164+
indicating success. Meanwhile, ``adf4371_clk_set_rate`` aims to adjust
165+
the output frequency for a specified channel. It checks for valid
166+
channel inputs before calling ``adf4371_set_freq`` to set the new
167+
frequency, returning the outcome of this operation, which is 0 for
168+
success and -1 if the channel is invalid.
169+
170+
Driver Initialization Example
171+
-----------------------------
172+
173+
.. code-block:: C
174+
175+
#include "no_os_spi.h"
176+
#include "xilinx_spi.h"
177+
#include "adf4371.h"
178+
#include "parameters.h"
179+
180+
181+
#define MULTIDEVICE_INSTANCE_COUNT 1
182+
#define ADF4371_CS 0
183+
184+
185+
/* ADF4371 channel specifications */
186+
struct adf4371_chan_spec adf_chan_spec[1] = {
187+
{
188+
.num = 2,
189+
.power_up_frequency = 12000000000,
190+
}
191+
};
192+
193+
194+
/* SPI initialization parameters */
195+
struct no_os_spi_init_param clkchip_spi_init_param = {
196+
.device_id = 1,
197+
.max_speed_hz = 1000000,
198+
.mode = NO_OS_SPI_MODE_0,
199+
.chip_select = ADF4371_CS,
200+
.platform_ops = &xil_spi_ops,
201+
.extra = NULL
202+
};
203+
204+
205+
/* ADF4371 initialization parameters */
206+
struct adf4371_init_param adf4371_param = {
207+
.spi_init = &clkchip_spi_init_param,
208+
.spi_3wire_enable = true,
209+
.clkin_frequency = 50000000,
210+
.muxout_select = 1,
211+
.num_channels = 1,
212+
.channels = adf_chan_spec
213+
};
214+
215+
216+
int main(void) {
217+
int32_t ret;
218+
struct adf4371_dev* adf4371_dev[MULTIDEVICE_INSTANCE_COUNT];
219+
struct no_os_clk_hw adf4371_hw[MULTIDEVICE_INSTANCE_COUNT];
220+
221+
222+
for (int i = 0; i < MULTIDEVICE_INSTANCE_COUNT; i++) {
223+
ret = adf4371_init(&adf4371_dev[i], &adf4371_param);
224+
if (ret) {
225+
return ret; // Initialization failed
226+
}
227+
// Additional configuration or operations with adf4371_dev[i] can be performed here
228+
}
229+
230+
231+
return 0; // Successful execution
232+
}

0 commit comments

Comments
 (0)