drivers/iio/dac/ad5770r.c
Source file repositories/reference/linux-study-clean/drivers/iio/dac/ad5770r.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/dac/ad5770r.c- Extension
.c- Size
- 16909 bytes
- Lines
- 664
- Domain
- Driver Families
- Bucket
- drivers/iio
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bits.hlinux/delay.hlinux/device.hlinux/gpio/consumer.hlinux/iio/iio.hlinux/iio/sysfs.hlinux/kernel.hlinux/module.hlinux/property.hlinux/regmap.hlinux/regulator/consumer.hlinux/spi/spi.hlinux/unaligned.h
Detected Declarations
struct ad5770r_out_rangestruct ad5770r_statestruct ad5770r_output_modesenum ad5770r_ch0_modesenum ad5770r_ch1_modesenum ad5770r_ch2_5_modesenum ad5770r_ref_venum ad5770r_output_filter_resistorfunction ad5770r_set_output_modefunction ad5770r_set_referencefunction ad5770r_soft_resetfunction ad5770r_resetfunction ad5770r_get_rangefunction ad5770r_get_filter_freqfunction ad5770r_set_filter_freqfunction ad5770r_read_rawfunction ad5770r_write_rawfunction ad5770r_read_freq_availfunction ad5770r_reg_accessfunction ad5770r_store_output_rangefunction ad5770r_read_dac_powerdownfunction ad5770r_write_dac_powerdownfunction ad5770r_channel_configfunction device_for_each_child_node_scopedfunction ad5770r_initfunction ad5770r_probe
Annotated Snippet
struct ad5770r_out_range {
u8 out_scale;
u8 out_range_mode;
};
/**
* struct ad5770r_state - driver instance specific data
* @spi: spi_device
* @regmap: regmap
* @gpio_reset: gpio descriptor
* @output_mode: array contains channels output ranges
* @vref: reference value
* @ch_pwr_down: powerdown flags
* @internal_ref: internal reference flag
* @external_res: external 2.5k resistor flag
* @transf_buf: cache aligned buffer for spi read/write
*/
struct ad5770r_state {
struct spi_device *spi;
struct regmap *regmap;
struct gpio_desc *gpio_reset;
struct ad5770r_out_range output_mode[AD5770R_MAX_CHANNELS];
int vref;
bool ch_pwr_down[AD5770R_MAX_CHANNELS];
bool internal_ref;
bool external_res;
u8 transf_buf[2] __aligned(IIO_DMA_MINALIGN);
};
static const struct regmap_config ad5770r_spi_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
.read_flag_mask = BIT(7),
};
struct ad5770r_output_modes {
unsigned int ch;
u8 mode;
int min;
int max;
};
static const struct ad5770r_output_modes ad5770r_rng_tbl[] = {
{ 0, AD5770R_CH0_0_300, 0, 300 },
{ 0, AD5770R_CH0_NEG_60_0, -60, 0 },
{ 0, AD5770R_CH0_NEG_60_300, -60, 300 },
{ 1, AD5770R_CH1_0_140_LOW_HEAD, 0, 140 },
{ 1, AD5770R_CH1_0_140_LOW_NOISE, 0, 140 },
{ 1, AD5770R_CH1_0_250, 0, 250 },
{ 2, AD5770R_CH_LOW_RANGE, 0, 55 },
{ 2, AD5770R_CH_HIGH_RANGE, 0, 150 },
{ 3, AD5770R_CH_LOW_RANGE, 0, 45 },
{ 3, AD5770R_CH_HIGH_RANGE, 0, 100 },
{ 4, AD5770R_CH_LOW_RANGE, 0, 45 },
{ 4, AD5770R_CH_HIGH_RANGE, 0, 100 },
{ 5, AD5770R_CH_LOW_RANGE, 0, 45 },
{ 5, AD5770R_CH_HIGH_RANGE, 0, 100 },
};
static const unsigned int ad5770r_filter_freqs[] = {
153, 357, 715, 1400, 2800, 262000,
};
static const unsigned int ad5770r_filter_reg_vals[] = {
AD5770R_FILTER_104_KOHM,
AD5770R_FILTER_44_4_KOHM,
AD5770R_FILTER_22_2_KOHM,
AD5770R_FILTER_11_2_KOHM,
AD5770R_FILTER_5_6_KOHM,
AD5770R_FILTER_60_OHM
};
static int ad5770r_set_output_mode(struct ad5770r_state *st,
const struct ad5770r_out_range *out_mode,
int channel)
{
unsigned int regval;
regval = AD5770R_RANGE_OUTPUT_SCALING(out_mode->out_scale) |
AD5770R_RANGE_MODE(out_mode->out_range_mode);
return regmap_write(st->regmap,
AD5770R_OUTPUT_RANGE(channel), regval);
}
static int ad5770r_set_reference(struct ad5770r_state *st)
{
unsigned int regval;
regval = AD5770R_REF_RESISTOR_SEL(st->external_res);
Annotation
- Immediate include surface: `linux/bits.h`, `linux/delay.h`, `linux/device.h`, `linux/gpio/consumer.h`, `linux/iio/iio.h`, `linux/iio/sysfs.h`, `linux/kernel.h`, `linux/module.h`.
- Detected declarations: `struct ad5770r_out_range`, `struct ad5770r_state`, `struct ad5770r_output_modes`, `enum ad5770r_ch0_modes`, `enum ad5770r_ch1_modes`, `enum ad5770r_ch2_5_modes`, `enum ad5770r_ref_v`, `enum ad5770r_output_filter_resistor`, `function ad5770r_set_output_mode`, `function ad5770r_set_reference`.
- Atlas domain: Driver Families / drivers/iio.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.