This is an old revision of the document!
This driver supports the
The AXI ADC HDL driver is the driver for the HDL interface core which is used on various FPGA designs. The driver is implemented as an Linux IIO driver. It's register map can be found here: Base register map (common to all cores)
Source | Mainlined? |
---|---|
drivers/iio/adc/cf_axi_adc_core.c | WIP |
Function | File |
---|---|
driver | drivers/iio/adc/ad9467.c |
driver | drivers/iio/adc/ad9361_conv.c |
driver | drivers/iio/adc/ad9371_conv.c |
driver | drivers/iio/adc/cf_axi_adc_core.c |
driver | drivers/iio/adc/cf_axi_adc_ring.c |
driver | drivers/iio/adc/cf_axi_adc_ring_stream.c |
include | drivers/iio/adc/cf_axi_adc.h |
The AXI ADC driver is a platform driver and can currently only be instantiated via device tree.
Required devicetree properties:
Example:
&fmc_spi { adc_ad9467: ad9467@0 { #address-cells = <1>; #size-cells = <0>; compatible = "ad9467"; reg = <0>; spi-max-frequency = <10000000>; clocks = <&clk_ad9517 3>; clock-names = "adc_clk"; adi,spi-3wire-enable; }; }; &fpga_axi { rx_dma: rx-dmac@44A30000 { compatible = "adi,axi-dmac-1.00.a"; reg = <0x44A30000 0x10000>; #dma-cells = <1>; interrupts = <0 57 0>; clocks = <&clkc 16>; dma-channel { adi,type = <0>; }; }; cf_ad9467_core_0: cf-ad9467-core-lpc@44A00000 { compatible = "xlnx,cf-ad9467-core-1.00.a"; reg = <0x44A00000 0x10000>; dmas = <&rx_dma 0>; dma-names = "rx"; spibus-connected = <&adc_ad9467>; } ; };
Configure kernel with “make menuconfig” (alternatively use “make xconfig” or “make qconfig”)
The AXI ADC HDL driver depends on CONFIG_SPI
Configure kernel with “make menuconfig” (alternatively use “make xconfig” or “make qconfig”)
Linux Kernel Configuration Device Drivers ---> <*> Industrial I/O support ---> --- Industrial I/O support -*- Enable ring buffer support within IIO -*- Industrial I/O lock free software ring -*- Enable triggered sampling support *** Analog to digital converters *** [--snip--] <*> Analog Devices AD9467 AD9643 High-Speed AXI ADC driver [--snip--]
Each and every IIO device, typically a hardware chip, has a device folder under /sys/bus/iio/devices/iio:deviceX. Where X is the IIO index of the device. Under every of these directory folders reside a set of files, depending on the characteristics and features of the hardware device in question. These files are consistently generalized and documented in the IIO ABI documentation. In order to determine which IIO deviceX corresponds to which hardware device, the user can read the name file /sys/bus/iio/devices/iio:deviceX/name. In case the sequence in which the iio device drivers are loaded/registered is constant, the numbering is constant and may be known in advance.
This specifies any shell prompt running on the target
root:/> cd /sys/bus/iio/devices/ root:/sys/bus/iio/devices> ls iio:device4 iio:trigger0 root:/sys/bus/iio/devices> cd iio:device4 root:/sys/bus/iio/devices/iio:device4> ls -l drwxr-xr-x 2 root root 0 Jan 1 00:00 buffer -r--r--r-- 1 root root 4096 Jan 1 00:00 dev -rw-r--r-- 1 root root 4096 Jan 1 00:00 in_voltage0_calibbias -rw-r--r-- 1 root root 4096 Jan 1 00:00 in_voltage0_calibphase -rw-r--r-- 1 root root 4096 Jan 1 00:00 in_voltage0_calibscale -rw-r--r-- 1 root root 4096 Jan 1 00:00 in_voltage0_filter_high_pass_3db_frequency -rw-r--r-- 1 root root 4096 Jan 1 00:00 in_voltage0_test_mode -rw-r--r-- 1 root root 4096 Jan 1 00:00 in_voltage1_calibbias -rw-r--r-- 1 root root 4096 Jan 1 00:00 in_voltage1_calibphase -rw-r--r-- 1 root root 4096 Jan 1 00:00 in_voltage1_calibscale -rw-r--r-- 1 root root 4096 Jan 1 00:00 in_voltage1_filter_high_pass_3db_frequency -rw-r--r-- 1 root root 4096 Jan 1 00:00 in_voltage1_test_mode -rw-r--r-- 1 root root 4096 Jan 1 00:00 in_voltage_sampling_frequency -rw-r--r-- 1 root root 4096 Jan 1 00:00 in_voltage_scale -r--r--r-- 1 root root 4096 Jan 1 00:00 in_voltage_scale_available -r--r--r-- 1 root root 4096 Jan 1 00:00 in_voltage_test_mode_available -r--r--r-- 1 root root 4096 Jan 1 00:00 name drwxr-xr-x 2 root root 0 Jan 1 00:00 scan_elements lrwxrwxrwx 1 root root 0 Jan 1 00:00 subsystem -> ../../../../bus/iio -rw-r--r-- 1 root root 4096 Jan 1 00:00 uevent root:/sys/bus/iio/devices/iio:device4>
This specifies any shell prompt running on the target
root:/sys/bus/iio/devices/iio:device4> cat name cf-ad9643-core-lpc
Description:
scale to be applied to in_voltageX_raw in order to obtain the measured voltage in millivolts.
This specifies any shell prompt running on the target
root:/sys/bus/iio/devices/iio:device4> cat in_voltage_scale 0.026703
This specifies any shell prompt running on the target
root:/sys/bus/iio/devices/iio:device4> cat in_voltage_scale_available 0.031738 0.031403 0.031067 0.030731 0.030396 0.030060 0.029724 0.029388 0.029053 0.028717 0.028381 0.028046 0.027710 0.027374 0.027039 0.026703 0.026367 0.026031 0.025696 0.025360 0.025024 0.024689 0.024353 0.024017 0.023682 0.023346 0.023010 0.022675 0.022339 0.022003 0.021667 0.021332
Description:
in_voltage0_calibscale
in_voltage1_calibscale
Set the channel calibration gain. Writing to these files will set the calibration gain for the respective channel. Valid values are in the range of 0..1.999999
This specifies any shell prompt running on the target
root:/sys/bus/iio/devices/iio:device4> cat in_voltage0_calibscale 1.000000
Description:
in_voltage0_calibbias
in_voltage1_calibbias
Set the channel calibration bias/offset. Writing to these files will set the calibration bias for the respective channel. Valid values are in the range of +/- 16384.
This specifies any shell prompt running on the target
root:/sys/bus/iio/devices/iio:device4> cat in_voltage0_calibscale 1.0
Description:
Show available test modes supported by the underlying ADC. These test modes are typically used to test the high speed digital interface between the converter and interface adaptor.
This specifies any shell prompt running on the target
root:/sys/bus/iio/devices/iio:device4> cat in_voltage_test_mode_available off midscale_short pos_fullscale neg_fullscale checkerboard pn_long pn_short one_zero_toggle
Description:
in_voltage0_test_mode
in_voltage1_test_mode
Enter test modes supported by the underlying ADC. These test modes are typically used to test the high speed digital interface between the converter and interface adaptor.
This specifies any shell prompt running on the target
root:/sys/bus/iio/devices/iio:device4> echo one_zero_toggle > in_voltage0_test_mode root:/sys/bus/iio/devices/iio:device4> cat in_voltage0_test_mode one_zero_toggle root:/sys/bus/iio/devices/iio:device4> echo off > in_voltage0_test_mode
in_voltage0_test_mode:off
This specifies any shell prompt running on the target
root:/sys/bus/iio/devices/iio:device4/buffer> ls bytes_per_datum enable subsystem length uevent root:/sys/bus/iio/devices/iio:device4/buffer>
The Industrial I/O subsystem provides support for various ring buffer based data acquisition methods. Apart from device specific hardware buffer support, the user can chose between two different software ring buffer implementations. One is the IIO lock free software ring, and the other is based on Linux kfifo. Devices with buffer support feature an additional sub-folder in the /sys/bus/iio/devices/deviceX/ folder hierarchy. Called deviceX:bufferY, where Y defaults to 0, for devices with a single buffer.
Every buffer implementation features a set of files:
length
Get/set the number of sample sets that may be held by the buffer.
enable
Enables/disables the buffer. This file should be written last, after length and selection of scan elements.
watermark
A single positive integer specifying the maximum number of scan
elements to wait for.
Poll will block until the watermark is reached.
Blocking read will wait until the minimum between the requested
read amount or the low water mark is available.
Non-blocking read will retrieve the available samples from the
buffer even if there are less samples then watermark level. This
allows the application to block on poll with a timeout and read
the available samples after the timeout expires and thus have a
maximum delay guarantee.
data_available
A read-only value indicating the bytes of data available in the
buffer. In the case of an output buffer, this indicates the
amount of empty space available to write data to. In the case of
an input buffer, this indicates the amount of data available for
reading.
length_align_bytes
Using the high-speed interface. DMA buffers may have an alignment requirement for the buffer length.
Newer versions of the kernel will report the alignment requirements
associated with a device through the `length_align_bytes` property.
scan_elements
The scan_elements directory contains interfaces for elements that will be captured for a single triggered sample set in the buffer.
This specifies any shell prompt running on the target
root:/sys/bus/iio/devices/iio:device4/scan_elements> ls in_voltage0_en in_voltage0_index in_voltage0_type in_voltage1_en in_voltage1_index in_voltage1_type root:/sys/bus/iio/devices/iio:device4/scan_elements>
in_voltageX_en / in_voltageX-voltageY_en / timestamp_en:
Scan element control for triggered data capture.
Writing 1 will enable the scan element, writing 0 will disable it
in_voltageX_type / in_voltageX-voltageY_type / timestamp_type:
Description of the scan element data storage within the buffer
and therefore in the form in which it is read from user-space.
Form is [s|u]bits/storage-bits. s or u specifies if signed
(2's complement) or unsigned. bits is the number of bits of
data and storage-bits is the space (after padding) that it
occupies in the buffer. Note that some devices will have
additional information in the unused bits so to get a clean
value, the bits value must be used to mask the buffer output
value appropriately. The storage-bits value also specifies the
data alignment. So u12/16 will be a unsigned 12 bit integer
stored in a 16 bit location aligned to a 16 bit boundary.
For other storage combinations this attribute will be extended
appropriately.
in_voltageX_index / in_voltageX-voltageY_index / timestamp_index:
A single positive integer specifying the position of this
scan element in the buffer. Note these are not dependent on
what is enabled and may not be contiguous. Thus for user-space
to establish the full layout these must be used in conjunction
with all _en attributes to establish which channels are present,
and the relevant _type attributes to establish the data storage
format.