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:ad7998 [05 Mar 2015 19:31] – [Files] driver moved out of staging and separate ring driver file no longer exists. Header file also removed but I do not know what to point to instead... Nils Grundback | resources:tools-software:linux-drivers:iio-adc:ad7998 [05 Jan 2021 16:01] (current) – Removed old references Ioana Chelaru | ||
---|---|---|---|
Line 15: | Line 15: | ||
===== Reference Circuits ===== | ===== Reference Circuits ===== | ||
- | * [[adi> | ||
* [[adi> | * [[adi> | ||
* [[adi> | * [[adi> | ||
Line 39: | Line 38: | ||
===== Status ===== | ===== Status ===== | ||
- | ^ Source | + | ^ Source ^ Mainlined? ^ |
- | | [[git.linux.org> | + | | [[git.linux.org> |
===== Files ===== | ===== Files ===== | ||
^ Function ^ File ^ | ^ Function ^ File ^ | ||
| driver | | driver | ||
- | | include | [[git.linux.org> | + | |
====== Example platform device initialization ====== | ====== Example platform device initialization ====== | ||
Line 51: | Line 50: | ||
{{page> | {{page> | ||
- | The reference voltage may vary between boards and models. The platform_data for the device' | ||
- | <source trunk/drivers/ | + | ===== 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 | + | #if defined(CONFIG_REGULATOR_FIXED_VOLTAGE) || defined(CONFIG_REGULATOR_FIXED_VOLTAGE_MODULE) |
- | .vref_mv = 2500, | + | static struct |
+ | REGULATOR_SUPPLY(" | ||
}; | }; | ||
+ | |||
+ | static struct regulator_init_data board_avdd_reg_init_data = { | ||
+ | .constraints = { | ||
+ | .name = " | ||
+ | .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 = " | ||
+ | .microvolts = 2500000, | ||
+ | .gpio = -EINVAL, | ||
+ | .enabled_at_boot = 0, | ||
+ | .init_data = & | ||
+ | }; | ||
+ | static struct platform_device brd_voltage_regulator = { | ||
+ | .name = " | ||
+ | .id = -1, | ||
+ | .num_resources = 0, | ||
+ | .dev = { | ||
+ | .platform_data = & | ||
+ | }, | ||
+ | }; | ||
+ | #endif | ||
</ | </ | ||
- | <WRAP tip> | + | <code c> |
- | In case platform_data is not present or set to NULL, the 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) |
+ | & | ||
+ | #endif | ||
+ | }; | ||
+ | </ | ||
+ | |||
+ | <code c> | ||
+ | static int __init board_init(void) | ||
+ | { | ||
+ | [--snip--] | ||
+ | |||
+ | platform_add_devices(board_devices, ARRAY_SIZE(board_devices)); | ||
+ | |||
+ | [--snip--] | ||
+ | |||
+ | return 0; | ||
+ | } | ||
+ | arch_initcall(board_init); | ||
+ | </code> | ||
{{page> | {{page> | ||
Line 93: | Line 143: | ||
} | } | ||
arch_initcall(board_init); | arch_initcall(board_init); | ||
+ | </ | ||
+ | |||
+ | ===== Devicetree ===== | ||
+ | |||
+ | Required devicetree properties: | ||
+ | * compatible: Needs to be " | ||
+ | * reg: The slave address used for the device | ||
+ | * vcc-supply: Phandle to the supply regulator | ||
+ | |||
+ | < | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | }; | ||
+ | |||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | }; | ||
+ | |||
+ | i2c: i2c@e0007000 { | ||
+ | # | ||
+ | # | ||
+ | | ||
+ | ... | ||
+ | |||
+ | | ||
+ | | ||
+ | reg = < | ||
+ | | ||
+ | | ||
+ | }; | ||
+ | }; | ||
</ | </ | ||