This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
resources:tools-software:linux-drivers:iio-adc:ad400x [07 Nov 2018 08:56] – [Files] Mircea Caprioru | resources:tools-software:linux-drivers:iio-adc:ad400x [01 Feb 2024 21:48] (current) – Recommend the AD400x user guide Marcelo Schmitt | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== AD4003/ | + | ====== AD4003/ |
===== Supported Devices ===== | ===== Supported Devices ===== | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
* [[adi> | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
* [[adi> | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
* [[adi> | * [[adi> | ||
* [[adi> | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
* [[adi> | * [[adi> | ||
===== Evaluation Boards ===== | ===== Evaluation Boards ===== | ||
- | * [[adi> | + | * [[adi> |
+ | * [[adi> | ||
===== Description ===== | ===== Description ===== | ||
- | This is a Linux industrial I/O (IIO) subsystem driver, targeting single channel | + | Analog Devices [[adi> |
+ | |||
+ | This is the Linux industrial I/O ([[software: | ||
+ | |||
+ | See the [[resources: | ||
===== Status ===== | ===== Status ===== | ||
^ Source ^ Mainlined? ^ | ^ Source ^ Mainlined? ^ | ||
- | | [[linux.github> | + | | [[linux.github> |
===== Files ===== | ===== Files ===== | ||
^ Function ^ File ^ | ^ Function ^ File ^ | ||
- | | driver | + | | driver |
- | | devicetree bindings | [[linux.github> | + | | devicetree bindings | [[linux.github> |
+ | | ZedBoard example devicetree | [[linux.github> | ||
+ | | CoraZ7 example devicetree | [[linux.github> | ||
====== Driver setup ====== | ====== Driver setup ====== | ||
- | Since AD4003/ | + | |
+ | Since AD4003/ | ||
* [[resources: | * [[resources: | ||
* [[resources: | * [[resources: | ||
Line 38: | Line 57: | ||
<WRAP box bggreen>< | <WRAP box bggreen>< | ||
< | < | ||
- | & | + | properties: |
- | rx_dma: rx-dmac@44a30000 { | + | |
- | compatible = "adi,axi-dmac-1.00.a"; | + | enum: |
- | | + | |
- | #dma-cells = <1>; | + | |
- | interrupts = <0 57 0>; | + | |
- | | + | |
- | + | - adi, | |
- | adi,channels { | + | - adi, |
- | #size-cells = < | + | - adi, |
- | | + | - adi, |
- | + | - adi, | |
- | dma-channel@0 | + | - adi, |
- | | + | - adi, |
- | adi,source-bus-width = < | + | - adi, |
- | adi,source-bus-type = < | + | - adi, |
- | | + | - adi, |
- | adi, | + | - adi, |
- | }; | + | |
- | }; | + | |
- | | + | spi-max-frequency: |
- | + | ||
- | | + | dmas: |
- | | + | description: |
- | | + | DMA specifier, consisting of a phandle to DMA controller node. |
- | interrupt-parent | + | maxItems: |
- | interrupts | + | |
- | clocks | + | |
- | clock-names = "s_axi_aclk", | + | const: rx |
- | num-cs = < | + | |
- | | + | |
- | | + | |
- | | + | |
- | + | clock-names: | |
- | ad4020: | + | const: ref_clk |
- | | + | description: |
- | | + | |
- | | + | pwms: |
- | | + | description: |
- | | + | PWM used as trigger source for the SPI engine, also represents the |
- | | + | |
- | + | maxItems: 1 | |
- | | + | |
- | | + | pwm-names: |
- | | + | |
- | | + | |
- | | + | vref-supply: |
+ | description: | ||
+ | |||
+ | '# | ||
+ | const: | ||
+ | |||
+ | '# | ||
+ | const: 0 | ||
+ | |||
+ | patternProperties: | ||
+ | "^channel@([0-1])$": | ||
+ | $ref: adc.yaml | ||
+ | type: object | ||
+ | description: | ||
+ | |||
+ | properties: | ||
+ | | ||
+ | | ||
+ | |||
+ | diff-channels: true | ||
+ | |||
+ | required: | ||
+ | | ||
+ | |||
+ | additionalProperties: | ||
+ | |||
+ | required: | ||
+ | | ||
+ | | ||
+ | - dmas | ||
+ | - dma-names | ||
+ | - vref-supply | ||
+ | |||
+ | allOf: | ||
+ | - $ref: / | ||
+ | |||
+ | - if: | ||
+ | properties: | ||
+ | compatible: | ||
+ | contains: | ||
+ | enum: | ||
+ | - adi,adaq4003 | ||
+ | |||
+ | then: | ||
+ | required: | ||
+ | | ||
+ | | ||
+ | - dmas | ||
+ | - dma-names | ||
+ | - clocks | ||
+ | - clock-names | ||
+ | - pwms | ||
+ | - pwm-names | ||
+ | - vref-supply | ||
+ | |||
+ | unevaluatedProperties: | ||
+ | |||
+ | examples: | ||
+ | - | | ||
+ | spi { | ||
+ | # | ||
+ | #size-cells = < | ||
+ | /* Example for a AD400X devices */ | ||
+ | adc@0 { | ||
+ | compatible = "adi,ad4020"; | ||
+ | reg = <0>; | ||
+ | spi-max-frequency | ||
+ | | ||
+ | |||
+ | dmas = <&rx_dma 0>; | ||
+ | dma-names = "rx"; | ||
+ | |||
+ | #address-cells = < | ||
+ | # | ||
+ | |||
+ | channel@0 { | ||
+ | reg = < | ||
+ | diff-channels = <0 1>; | ||
+ | }; | ||
+ | }; | ||
+ | }; | ||
+ | - | | ||
+ | spi { | ||
+ | # | ||
+ | #size-cells = <0>; | ||
+ | |||
+ | /* Example for a ADAQ400X devices */ | ||
+ | | ||
+ | compatible = "adi, | ||
+ | reg = < | ||
+ | spi-max-frequency = <80000000>; | ||
+ | dmas = <& | ||
+ | dma-names = " | ||
+ | | ||
+ | clock-names = " | ||
+ | pwms = <& | ||
+ | pwm-names = " | ||
+ | vref-supply = <& | ||
+ | |||
+ | | ||
+ | #size-cells = <0>; | ||
+ | |||
+ | channel@0 { | ||
+ | reg = < | ||
+ | diff-channels = <0 1>; | ||
+ | }; | ||
+ | }; | ||
+ | }; | ||
</ | </ | ||
+ | |||
+ | See the [[resources: | ||
+ | |||
+ | ====== Adding Linux driver support ====== | ||
+ | |||
+ | ===== Enabling the driver ===== | ||
+ | |||
+ | Configure kernel with "make menuconfig" | ||
+ | "make qconfig" | ||
+ | |||
+ | <WRAP round help> | ||
+ | The AD400x driver depends on **CONFIG_SPI_MASTER** | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | Linux Kernel Configuration | ||
+ | Device Drivers | ||
+ | ... | ||
+ | < | ||
+ | --- Industrial I/O support | ||
+ | ... | ||
+ | Analog to digital converters | ||
+ | ... | ||
+ | < | ||
+ | ... | ||
+ | ... | ||
+ | ... | ||
+ | |||
+ | </ | ||
+ | |||
====== Driver testing ====== | ====== Driver testing ====== | ||
Line 98: | Line 254: | ||
<WRAP box bggreen>< | <WRAP box bggreen>< | ||
< | < | ||
- | root@analog:/ | + | root@analog: |
total 0 | total 0 | ||
- | lrwxrwxrwx 1 root root 0 Jan 1 1970 iio:device0 -> ../ | + | lrwxrwxrwx 1 root root 0 Apr 2 21:42 iio:device0 -> ../ |
- | lrwxrwxrwx 1 root root 0 Jan 1 1970 iio:device1 -> ../ | + | lrwxrwxrwx 1 root root 0 Apr 2 21:43 iio:device1 -> ../ |
- | lrwxrwxrwx 1 root root 0 Jan 1 1970 iio_sysfs_trigger -> ../ | + | lrwxrwxrwx 1 root root 0 Apr 2 21:42 iio_sysfs_trigger -> ../ |
- | root@analog:/ | + | root@analog: |
- | root@analog:/ | + | |
- | root@analog:/sys/ | + | |
total 0 | total 0 | ||
- | drwxrwxrwx | + | drwxr-xr-x |
- | -rw-rw-rw- 1 root root 4096 Jan 1 1970 dev | + | drwxr-xr-x 2 root root 0 Apr 2 21:43 buffer0 |
- | -rw-rw-rw- 1 root root 4096 Jan | + | -r--r--r-- 1 root root 4096 Apr 2 21:43 dev |
- | -rw-rw-rw- 1 root root 4096 Jan 1 1970 in_voltage0_scale | + | -rw-r--r-- 1 root root 4096 Apr 2 21:43 in_voltage0_offset |
- | -rw-rw-rw- 1 root root 4096 Jan 1 1970 name | + | -rw-r--r-- |
- | lrwxrwxrwx 1 root root 0 Nov | + | -rw-r--r-- 1 root root 4096 Apr 2 21:43 in_voltage0_scale |
- | drwxrwxrwx | + | -r--r--r-- 1 root root 4096 Apr 2 21:43 name |
- | -rw-rw-rw- 1 root root 4096 Jan 1 1970 sampling_frequency | + | lrwxrwxrwx 1 root root 0 Apr |
- | drwxrwxrwx | + | drwxr-xr-x |
- | lrwxrwxrwx 1 root root 0 Nov | + | -rw-r--r-- 1 root root 4096 Apr 2 21:43 sampling_frequency |
- | -rw-rw-rw- 1 root root 4096 Jan 1 1970 uevent | + | drwxr-xr-x |
+ | lrwxrwxrwx 1 root root 0 Apr | ||
+ | -rw-r--r-- 1 root root 4096 Apr 2 21:43 uevent | ||
</ | </ | ||
Line 126: | Line 281: | ||
<WRAP box bggreen>< | <WRAP box bggreen>< | ||
< | < | ||
- | root@analog:/ | + | root@analog: |
- | ad4020 | + | adaq4003 |
</ | </ | ||
Line 133: | Line 288: | ||
**Description: | **Description: | ||
- | Scale to be applied to in_voltagex_raw in order to obdatin | + | Scale to be applied to in_voltagex_raw in order to obtain |
<WRAP box bggreen>< | <WRAP box bggreen>< | ||
< | < | ||
- | root@analog:/ | + | root@analog: |
- | 0.002384185 | + | 0.019073486 |
</ | </ | ||
+ | |||
+ | === Configure sampling rate === | ||
+ | |||
+ | **__Description: | ||
+ | Configures the input sampling rate. | ||
+ | |||
+ | <WRAP box bggreen>< | ||
+ | < | ||
+ | root@analog: | ||
+ | 2000000 | ||
+ | </ | ||
+ | |||
+ | <WRAP box bggreen>< | ||
+ | < | ||
+ | root@analog: | ||
+ | root@analog: | ||
+ | 1000000 | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== Buffer management ===== | ||
+ | |||
+ | <WRAP box bggreen>< | ||
+ | < | ||
+ | root@analog: | ||
+ | total 0 | ||
+ | -r--r--r-- 1 root root 4096 Apr 3 08:11 data_available | ||
+ | -r--r--r-- 1 root root 4096 Apr 3 08:11 direction | ||
+ | -rw-r--r-- 1 root root 4096 Apr 3 08:11 enable | ||
+ | -rw-r--r-- 1 root root 4096 Apr 3 08:11 length | ||
+ | -r--r--r-- 1 root root 4096 Apr 3 08:11 length_align_bytes | ||
+ | -r--r--r-- 1 root root 4096 Apr 3 08:11 watermark | ||
+ | </ | ||
+ | |||
+ | {{page> | ||
+ | |||
+ | <WRAP box bggreen>< | ||
+ | < | ||
+ | root@analog: | ||
+ | total 0 | ||
+ | -rw-r--r-- 1 root root 4096 Apr 3 08:11 in_voltage0_en | ||
+ | -r--r--r-- 1 root root 4096 Apr 3 08:11 in_voltage0_index | ||
+ | -r--r--r-- 1 root root 4096 Apr 3 08:11 in_voltage0_type | ||
+ | </ | ||
+ | |||
+ | {{page> | ||
+ | |||
+ | <WRAP box bggreen>< | ||
+ | < | ||
+ | root@analog:/ | ||
+ | in_voltage0_en: | ||
+ | in_voltage0_index: | ||
+ | in_voltage0_type: | ||
+ | </ | ||
+ | |||
+ | ===== Buffer Example ===== | ||
+ | |||
+ | When the buffer is enabled, the ad400x driver prepares a read transfer and configures the [[resources: | ||
+ | |||
+ | <WRAP box bggreen>< | ||
+ | < | ||
+ | root@analog: | ||
+ | root@analog: | ||
+ | 1 | ||
+ | root@analog: | ||
+ | root@analog: | ||
+ | 32768 | ||
+ | </ | ||
+ | |||
+ | ==== Data interpretation ==== | ||
+ | |||
+ | Each buffer entry contains one sample. The amount of bits and their meaning will vary according to ADC precision and output code pattern (whether output code is twos complement or not). Buffer raw data may be retrieved by reading the character device associated with the ADC device. | ||
+ | |||
+ | <WRAP box bggreen>< | ||
+ | < | ||
+ | root@analog: | ||
+ | 4864 4889 4730 4716 4695 4678 4667 4659 4662 4676 4706 4738 4770 4789 4786 4785 4775 4763 4752 4737 4723 4703 4686 4673 4666 4672 4688 4715 4762 4799 4820 4821 | ||
+ | 4816 4807 4788 4773 4757 4737 4718 4694 4676 4664 4668 4692 4727 4777 4814 4837 4836 4829 4822 4808 4796 4771 4748 4728 4707 4685 4664 4654 4651 4659 4675 4709 | ||
+ | 4757 4801 4823 4826 4812 4800 4789 4770 4749 4724 4700 4677 4653 4644 4633 4639 4659 4695 4738 4777 4798 4799 4794 4785 4772 4755 4735 4712 4692 4668 4652 4646 | ||
+ | 4641 4648 4674 4709 4753 4793 4817 4818 4808 4797 4780 4764 4748 4724 4699 4674 4656 4639 4627 4633 4644 4677 4716 4765 4794 4804 4801 4791 4778 4763 4744 4721 | ||
+ | </ | ||
+ | |||
+ | Remove the '' | ||
====== More Information ====== | ====== More Information ====== | ||
{{page> | {{page> |