Wiki

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
resources:tools-software:linux-drivers:iio-adc:ad7998 [16 Nov 2012 13:29] – [Reference Circuit Notes] fix heading Lars-Peter Clausenresources:tools-software:linux-drivers:iio-adc:ad7998 [06 Mar 2015 10:27] – update Michael Hennerich
Line 15: Line 15:
 ===== Reference Circuits ===== ===== Reference Circuits =====
  
-  * [[adi>CN0043]] 
   * [[adi>CN0044]]   * [[adi>CN0044]]
-  * [[adi>CN0045]]+  * [[adi>CN0288]] 
 +  * [[adi>CN0301]]
  
 ===== Evaluation Boards ===== ===== Evaluation Boards =====
Line 40: Line 40:
  
 ^  Source  ^  Mainlined?  ^ ^  Source  ^  Mainlined?  ^
-| [[git.linux.org>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 52: 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 voltage 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 96: Line 146:
 </code> </code>
  
-====== Adding Linux drive +===== Devicetree ===== 
-support ======+ 
 +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> 
 + 
 +====== Adding Linux driver support ======
  
 Configure kernel with "make menuconfig" (alternatively use "make xconfig" or Configure kernel with "make menuconfig" (alternatively use "make xconfig" or
 "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 133: 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/**
Line 158: Line 244:
 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/iio: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 ===
Line 173: Line 259:
 scale to be applied to in_voltage0_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/iio:device0> **cat in_voltage_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 184: 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/iio:device0> **cat in_voltage0_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** = //in_voltage0_raw * in_voltage_scale// = 1491 * 1.000 = **1491,00 //mV//** **U** = //in_voltage0_raw * in_voltage_scale// = 1491 * 1.000 = **1491,00 //mV//**
Line 202: 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/iio:device0/buffer> **ls** root:/sys/devices/platform/i2c-bfin-twi.0/i2c-0/0-0024/iio:device0/buffer> **ls**
 **enable**  **length** **enable**  **length**
 root:/sys/devices/platform/i2c-bfin-twi.0/i2c-0/0-0024/iio:device0/buffer> root:/sys/devices/platform/i2c-bfin-twi.0/i2c-0/0-0024/iio:device0/buffer>
-</xterm></box>+</xterm></WRAP>
  
 {{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/iio:device0/scan_elements> **ls** root:/sys/devices/platform/i2c-bfin-twi.0/i2c-0/0-0024/iio:device0/scan_elements> **ls**
Line 220: Line 306:
 in_voltage2_en           in_voltage4_index        in_voltage7_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/iio:device0/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