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
resources:tools-software:linux-drivers:iio-adc:ad7998 [06 Mar 2015 09:39]
Michael Hennerich [Files]
resources:tools-software:linux-drivers:iio-adc:ad7998 [05 Jan 2021 16:01] (current)
Ioana Chelaru Removed old references
Line 15: Line 15:
 ===== Reference Circuits ===== ===== Reference Circuits =====
  
-  * [[adi>​CN0044]] 
   * [[adi>​CN0288]]   * [[adi>​CN0288]]
   * [[adi>​CN0301]]   * [[adi>​CN0301]]
Line 39: Line 38:
 ===== Status ===== ===== Status =====
  
- Source ​  Mainlined? ​ +^ Source ^ Mainlined? ^ 
-| [[git.linux.org>​drivers/​iio/​adc/​ad799x.c|git]] |  [[git.linux.org>​drivers/​iio/​adc/​ad799x.c|Yes]] ​ |+| [[git.linux.org>​drivers/​iio/​adc/​ad799x.c|git]] | [[git.linux.org>​drivers/​iio/​adc/​ad799x.c|Yes]] |
 ===== Files ===== ===== Files =====
  
Line 51: Line 50:
 {{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>​
  
-<WRAP 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 = { 
-</WRAP>+#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 93: Line 143:
 } }
 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>​
  
resources/tools-software/linux-drivers/iio-adc/ad7998.1425631152.txt.gz · Last modified: 06 Mar 2015 09:39 by Michael Hennerich