Skip to content

Commit d7c47f5

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. Added doxygen directive. Signed-off-by: Carl Ian Gamutan <[email protected]>
1 parent 1cc7551 commit d7c47f5

File tree

2 files changed

+235
-0
lines changed

2 files changed

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

0 commit comments

Comments
 (0)