Wiki

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
resources:tools-software:linux-drivers:iio-adc:ad7998 [03 Mar 2011 21:58]
Michael Hennerich [Buffer management]
resources:tools-software:linux-drivers:iio-adc:ad7998 [11 Feb 2016 20:47]
Lars-Peter Clausen [Status]
Line 1: Line 1:
-====== AD7998 ​driver ​======+====== AD7998 ​IIO ADC Linux Driver ​======
  
 ===== Supported Devices ===== ===== Supported Devices =====
  
-This driver supports the +  * [[adi>​AD7991]] 
-[[:​analog-to-digital-converters:​ad-converters:​ad7991]] +  ​* ​[[adi>​AD7992]] 
-[[:​analog-to-digital-converters:​ad-converters:​ad7992]] +  ​* ​[[adi>​AD7993]] 
-[[:​analog-to-digital-converters:​ad-converters:​ad7993]] +  ​* ​[[adi>​AD7994]] 
-[[:analog-to-digital-converters:​ad-converters:​ad7994]] +  * [[adi>​AD7995]] 
-[[:analog-to-digital-converters:​ad-converters:​ad7995]] +  * [[adi>​AD7997]] 
-[[:analog-to-digital-converters:​ad-converters:​ad7997]] +  * [[adi>​AD7998]] 
-[[:analog-to-digital-converters:​ad-converters:​ad7998]] +  * [[adi>​AD7999]] 
-[[:analog-to-digital-converters:​ad-converters:​ad7999]]+ 
 + 
 +===== Reference Circuits ===== 
 + 
 +  * [[adi>​CN0044]] 
 +  * [[adi>​CN0288]] 
 +  * [[adi>​CN0301]] 
 + 
 +===== Evaluation Boards ===== 
 + 
 +  * [[adi>​EVAL-AD7991EBZ]] 
 +  ​* ​[[adi>EVAL-AD7992EBZ]] 
 +  ​* ​[[adi>EVAL-AD7993EBZ]] 
 +  ​* ​[[adi>EVAL-AD7994EBZ]] 
 +  ​* ​[[adi>EVAL-AD7995EBZ]] 
 +  ​* ​[[adi>EVAL-AD7997EBZ]] 
 +  * [[adi>​EVAL-AD7998EBZ]]
  
 ===== Description ===== ===== Description =====
Line 23: Line 39:
 ===== Status ===== ===== Status =====
  
- Source ​  Mainlined? ​ +^ Source ^ Mainlined? ^ 
- [[bfsvn>linux-kernel?​drivers/​staging/​iio/​adc/​ad799x_core.c|svn]] ​  ​[[bfgit>linux-kernel?​drivers/staging/iio/adc/ad799x_core.c|git]] |  [[git.linux.org>​drivers/staging/iio/adc/ad799x_core.c|Yes]] ​ |+| [[git.linux.org>​drivers/​iio/​adc/​ad799x.c|git]] | [[git.linux.org>​drivers/​iio/​adc/​ad799x.c|Yes]] |
 ===== Files ===== ===== Files =====
  
 ^ Function ^ File ^ ^ Function ^ File ^
-| driver ​ | [[git.linux.org>​drivers/staging/iio/adc/ad799x_core.c]] | +| driver ​ | [[git.linux.org>​drivers/​iio/​adc/​ad799x.c]] | 
-| driver ​ | [[git.linux.org>​drivers/​staging/​iio/​adc/​ad799x_ring.c]] | +
-| include | [[git.linux.org>​drivers/​staging/​iio/​adc/​ad799x.h]] |+
  
 ====== Example platform device initialization ====== ====== Example platform device initialization ======
Line 36: Line 51:
 {{page>​software/​linux/​docs/​platform_and_bus_model#​Platform Data&​noheader&​firstseconly&​noeditbtn}} {{page>​software/​linux/​docs/​platform_and_bus_model#​Platform Data&​noheader&​firstseconly&​noeditbtn}}
  
-The reference volatage may vary between boards and models. The platform_data for the device'​s "​struct device"​ holds this information. 
  
-<source trunk/drivers/​staging/​iio/​adc/​ad799x.h:​ad799x_platform_data{} c linux-kernel>+===== Specifying reference voltage via the regulator framework ===== 
 + 
 +<WRAP tip> 
 +In case the AD799x on-chip reference is not used,  
 +this driver requires specifying the reference voltage, by using the Linux regulator framework. 
 +</WRAP> 
 + 
 +Below example specifies a 2.5 Volt reference for the I2C device 0-0024 on I2C-Bus 0. (**0-0024**)
  
 <code c> <code c>
-static struct ​ad799x_platform_data ad7998_pdata ​= { +#if defined(CONFIG_REGULATOR_FIXED_VOLTAGE) || defined(CONFIG_REGULATOR_FIXED_VOLTAGE_MODULE) 
- .vref_mv = 2500,+static struct ​regulator_consumer_supply ad7998_consumer_supplies[] ​= { 
 + REGULATOR_SUPPLY("​vref",​ "​0-0024"​),
 }; };
 +
 +static struct regulator_init_data board_avdd_reg_init_data = {
 + .constraints = {
 + .name = "​2V5",​
 + .valid_ops_mask = REGULATOR_CHANGE_STATUS,​
 + },
 + .consumer_supplies = ad7998_consumer_supplies,​
 + .num_consumer_supplies = ARRAY_SIZE(ad7998_consumer_supplies),​
 +};
 +
 +static struct fixed_voltage_config board_vref_pdata = {
 + .supply_name = "​board-2V5",​
 + .microvolts = 2500000,
 + .gpio = -EINVAL,
 + .enabled_at_boot = 0,
 + .init_data = &​board_avdd_reg_init_data,​
 +};
 +static struct platform_device brd_voltage_regulator = {
 + .name = "​reg-fixed-voltage",​
 + .id = -1,
 + .num_resources = 0,
 + .dev = {
 + .platform_data = &​board_vref_pdata,​
 + },
 +};
 +#endif
 </​code>​ </​code>​
  
-<note tip+<code c
-In case platform_data is not present or set to NULLthe driver will use the AD7998 internal reference. +static struct platform_device *board_devices[] __initdata = { 
-</note>+#if defined(CONFIG_REGULATOR_FIXED_VOLTAGE) || defined(CONFIG_REGULATOR_FIXED_VOLTAGE_MODULE) 
 + &​brd_voltage_regulator 
 +#endif 
 +}; 
 +</​code>​ 
 + 
 +<code c> 
 +static int __init board_init(void) 
 +
 + [--snip--] 
 + 
 + platform_add_devices(board_devicesARRAY_SIZE(board_devices));​ 
 + 
 + [--snip--] 
 + 
 + return 0; 
 +
 +arch_initcall(board_init);​ 
 +</code>
  
 {{page>​software/​linux/​docs/​platform_and_bus_model#​Declaring I2C devices&​firstseconly&​noeditbtn}} {{page>​software/​linux/​docs/​platform_and_bus_model#​Declaring I2C devices&​firstseconly&​noeditbtn}}
Line 59: Line 125:
  {  {
  I2C_BOARD_INFO("​ad7998",​ 0x24),  I2C_BOARD_INFO("​ad7998",​ 0x24),
- .platform_data = (void *)&​ad799x_pdata,​+ .platform_data = &​ad799x_pdata,​
  .irq = IRQ_PG0,  .irq = IRQ_PG0,
  },  },
Line 78: Line 144:
 } }
 arch_initcall(board_init);​ arch_initcall(board_init);​
 +</​code>​
 +
 +===== Devicetree =====
 +
 +Required devicetree properties:
 +  * compatible: Needs to be "​adi,"​ followed by the name of the device. E.g. "​adi,​ad7798"​
 +  * reg: The slave address used for the device
 +  * vcc-supply: Phandle to the supply regulator
 +
 +<​code>​
 +       ​adc_supply:​ fixedregulator {
 +               ​compatible = "​regulator-fixed";​
 +               ​regulator-name = "​fixed-supply";​
 +               ​regulator-min-microvolt = <​3300000>;​
 +               ​regulator-max-microvolt = <​3300000>;​
 +       };
 +
 +       ​adc_vref:​ fixedregulator {
 +               ​compatible = "​regulator-fixed";​
 +               ​regulator-name = "​fixed-supply";​
 +               ​regulator-min-microvolt = <​2500000>;​
 +               ​regulator-max-microvolt = <​2500000>;​
 +       };
 +       
 +       i2c: i2c@e0007000 {
 +               #​address-cells = <1>;
 +               #​size-cells = <0>;
 +               ​compatible = "​xlnx,​xps-iic-2.00.a";​
 +               ...
 +
 +               ​ad7798@24 {
 +                       ​compatible = "​adi,​ad7798";​
 +                       reg = <​0x24>;​
 +                       ​vcc-supply = <&​adc_supply>;​
 +                       ​vref-supply = <&​adc_vref>;​
 +               };
 +        };
 </​code>​ </​code>​
  
Line 85: Line 188:
 "make qconfig"​) "make qconfig"​)
  
-<note>+<WRAP round help>
 The AD7998 Driver depends on **CONFIG_I2C** The AD7998 Driver depends on **CONFIG_I2C**
-</note>+</WRAP>
  
 <​code>​ <​code>​
Line 116: Line 219:
 {{page>​software:​linux:​docs:​iio:​iio_snippets#​iio device files&​noheader&​firstseconly&​noeditbtn}} {{page>​software:​linux:​docs:​iio:​iio_snippets#​iio device files&​noheader&​firstseconly&​noeditbtn}}
  
-<​box ​100% green|shell prompt running on the target>+<WRAP box bggreen><​wrap info>​This specifies any shell prompt running on the target</wrap>
 <​xterm>​ <​xterm>​
 root:/> **cd /​sys/​bus/​iio/​devices/​** root:/> **cd /​sys/​bus/​iio/​devices/​**
 root:/​sys/​bus/​iio/​devices>​ ls root:/​sys/​bus/​iio/​devices>​ ls
-device0 ​                 ​device0:​buffer0:​access0  ​trigger0 +iio:device0 ​                 trigger0 
-device0:​buffer0 ​         device0:​buffer0:​event0+
  
 root:/​sys/​bus/​iio/​devices>​ **cd device0** root:/​sys/​bus/​iio/​devices>​ **cd device0**
  
-root:/​sys/​devices/​platform/​i2c-bfin-twi.0/​i2c-0/​0-0024/​device0>​ **ls -l** +root:/​sys/​devices/​platform/​i2c-bfin-twi.0/​i2c-0/​0-0024/​iio:device0> **ls -l** 
-drwxr-xr-x ​   5 root     ​root ​            0 Jan  1 00:00 device0:​buffer0 +drwxr-xr-x ​   5 root     ​root ​            0 Jan  1 00:00 buffer 
-drwxr-xr-x ​   2 root     ​root ​            0 Jan  1 00:00 device0:​event0 +drwxr-xr-x ​   2 root     ​root ​            0 Jan  1 00:00 events 
--r--r--r-- ​   1 root     ​root ​         4096 Jan  1 00:00 in0_raw +-r--r--r-- ​   1 root     ​root ​         4096 Jan  1 00:00 in_voltage0_raw 
--r--r--r-- ​   1 root     ​root ​         4096 Jan  1 00:00 in1_raw +-r--r--r-- ​   1 root     ​root ​         4096 Jan  1 00:00 in_voltage1_raw 
--r--r--r-- ​   1 root     ​root ​         4096 Jan  1 00:00 in2_raw +-r--r--r-- ​   1 root     ​root ​         4096 Jan  1 00:00 in_voltage2_raw 
--r--r--r-- ​   1 root     ​root ​         4096 Jan  1 00:00 in3_raw +-r--r--r-- ​   1 root     ​root ​         4096 Jan  1 00:00 in_voltage3_raw 
--r--r--r-- ​   1 root     ​root ​         4096 Jan  1 00:00 in4_raw +-r--r--r-- ​   1 root     ​root ​         4096 Jan  1 00:00 in_voltage4_raw 
--r--r--r-- ​   1 root     ​root ​         4096 Jan  1 00:00 in5_raw +-r--r--r-- ​   1 root     ​root ​         4096 Jan  1 00:00 in_voltage5_raw 
--r--r--r-- ​   1 root     ​root ​         4096 Jan  1 00:00 in6_raw +-r--r--r-- ​   1 root     ​root ​         4096 Jan  1 00:00 in_voltage6_raw 
--r--r--r-- ​   1 root     ​root ​         4096 Jan  1 00:00 in7_raw +-r--r--r-- ​   1 root     ​root ​         4096 Jan  1 00:00 in_voltage7_raw 
--r--r--r-- ​   1 root     ​root ​         4096 Jan  1 00:00 in_scale+-r--r--r-- ​   1 root     ​root ​         4096 Jan  1 00:00 in_voltage_scale
 -r--r--r-- ​   1 root     ​root ​         4096 Jan  1 00:00 name -r--r--r-- ​   1 root     ​root ​         4096 Jan  1 00:00 name
 lrwxrwxrwx ​   1 root     ​root ​            0 Jan  1 00:00 subsystem -> ../​../​../​../​../​../​bus/​iio lrwxrwxrwx ​   1 root     ​root ​            0 Jan  1 00:00 subsystem -> ../​../​../​../​../​../​bus/​iio
 drwxr-xr-x ​   2 root     ​root ​            0 Jan  1 00:00 trigger drwxr-xr-x ​   2 root     ​root ​            0 Jan  1 00:00 trigger
 -rw-r--r-- ​   1 root     ​root ​         4096 Jan  1 00:00 uevent -rw-r--r-- ​   1 root     ​root ​         4096 Jan  1 00:00 uevent
-</​xterm></​box>+</​xterm></​WRAP>
  
 === Show device name === === Show device name ===
  
-<​box ​100% green|shell prompt running on the target>+<WRAP box bggreen><​wrap info>​This specifies any shell prompt running on the target</wrap>
 <​xterm>​ <​xterm>​
-root:/​sys/​devices/​platform/​i2c-bfin-twi.0/​i2c-0/​0-0024/​device0>​ **cat name**+root:/​sys/​devices/​platform/​i2c-bfin-twi.0/​i2c-0/​0-0024/​iio:device0> **cat name**
 ad7998 ad7998
-</​xterm></​box>+</​xterm></​WRAP>
  
 === Show scale === === Show scale ===
  
 **Description:​**\\ **Description:​**\\
-scale to be applied to in0_raw ​in order to obtain the measured voltage in millivolts.+scale to be applied to in_voltage0_raw ​in order to obtain the measured voltage in millivolts.
  
-<​box ​100% green|shell prompt running on the target>+<WRAP box bggreen><​wrap info>​This specifies any shell prompt running on the target</wrap>
 <​xterm>​ <​xterm>​
-root:/​sys/​devices/​platform/​i2c-bfin-twi.0/​i2c-0/​0-0024/​device0>​ **cat in_scale**+root:/​sys/​devices/​platform/​i2c-bfin-twi.0/​i2c-0/​0-0024/​iio:device0> **cat in_voltage_scale**
 1.000 1.000
-</​xterm></​box>+</​xterm></​WRAP>
  
 === Show channel 0 measurement === === Show channel 0 measurement ===
Line 167: Line 270:
 Raw unscaled voltage measurement on channel 0 Raw unscaled voltage measurement on channel 0
  
-<​box ​100% green|shell prompt running on the target>+<WRAP box bggreen><​wrap info>​This specifies any shell prompt running on the target</wrap>
 <​xterm>​ <​xterm>​
-root:/​sys/​devices/​platform/​i2c-bfin-twi.0/​i2c-0/​0-0024/​device0>​ **cat in0_raw**+root:/​sys/​devices/​platform/​i2c-bfin-twi.0/​i2c-0/​0-0024/​iio:device0> **cat in_voltage0_raw**
 1491 1491
-</​xterm></​box>+</​xterm></​WRAP>
  
-**U** = //in0_raw ​in_scale// = 1491 * 1.000 = **1491,00 //mV//**+**U** = //in_voltage0_raw ​in_voltage_scale// = 1491 * 1.000 = **1491,00 //mV//**
  
 ===== Trigger management ===== ===== Trigger management =====
Line 185: Line 288:
 ===== Buffer management ===== ===== Buffer management =====
  
-<​box ​100% green|shell prompt running on the target>+<WRAP box bggreen><​wrap info>​This specifies any shell prompt running on the target</wrap>
 <​xterm>​ <​xterm>​
-root:/​sys/​devices/​platform/​i2c-bfin-twi.0/​i2c-0/​0-0024/​device0/​device0:​buffer0> **ls** +root:/​sys/​devices/​platform/​i2c-bfin-twi.0/​i2c-0/​0-0024/​iio:device0/buffer> **ls** 
-**bytes_per_datum** ​         ​**enable** ​                  subsystem +**enable** ​ **length** 
-device0:​buffer0:​access0 ​ ​**length**                   ​uevent +root:/​sys/​devices/​platform/​i2c-bfin-twi.0/​i2c-0/​0-0024/​iio:device0/buffer
-device0:​buffer0:​event0 ​  ​**scan_elements** +</​xterm></​WRAP>
-root:/​sys/​devices/​platform/​i2c-bfin-twi.0/​i2c-0/​0-0024/​device0/​device0:​buffer0+
-</​xterm></​box>+
  
 {{page>​software:​linux:​docs:​iio:​iio_snippets#​Buffer management&​noheader&​firstseconly&​noeditbtn}} {{page>​software:​linux:​docs:​iio:​iio_snippets#​Buffer management&​noheader&​firstseconly&​noeditbtn}}
  
-<​box ​100% green|shell prompt running on the target>+<WRAP box bggreen><​wrap info>​This specifies any shell prompt running on the target</wrap>
 <​xterm>​ <​xterm>​
-root:/​sys/​devices/​platform/​i2c-bfin-twi.0/​i2c-0/​0-0024/​device0/​device0:​buffer0/​scan_elements>​ **ls** +root:/​sys/​devices/​platform/​i2c-bfin-twi.0/​i2c-0/​0-0024/​iio:device0/​scan_elements>​ **ls** 
-in0_en ​          ​in2_index ​       in5_en ​          ​in7_index +in_voltage0_en ​          ​in_voltage2_index ​       in_voltage5_en ​          ​in_voltage7_index 
-in0_index ​       in3_en ​          ​in5_index ​       in_type +in_voltage0_index ​       in_voltage3_en ​          ​in_voltage5_index ​       in_voltage_type 
-in1_en ​          ​in3_index ​       in6_en ​          timestamp_en +in_voltage1_en ​          ​in_voltage3_index ​       in_voltage6_en ​          timestamp_en 
-in1_index ​       in4_en ​          ​in6_index ​       ​timestamp_index +in_voltage1_index ​       in_voltage4_en ​          ​in_voltage6_index ​       ​timestamp_index 
-in2_en ​          ​in4_index ​       in7_en ​          timestamp_type +in_voltage2_en ​          ​in_voltage4_index ​       in_voltage7_en ​          timestamp_type 
-root:/​sys/​devices/​platform/​i2c-bfin-twi.0/​i2c-0/​0-0024/​device0/​device0:​buffer0/​scan_elements>​ +root:/​sys/​devices/​platform/​i2c-bfin-twi.0/​i2c-0/​0-0024/​iio:device0/​scan_elements>​ 
-</​xterm></​box>+</​xterm></​WRAP>
  
  
resources/tools-software/linux-drivers/iio-adc/ad7998.txt · Last modified: 05 Jan 2021 16:01 by Ioana Chelaru