drivers/iio/dac/ad3530r.c
Source file repositories/reference/linux-study-clean/drivers/iio/dac/ad3530r.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/dac/ad3530r.c- Extension
.c- Size
- 14635 bytes
- Lines
- 543
- 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/array_size.hlinux/bitfield.hlinux/bits.hlinux/cleanup.hlinux/delay.hlinux/dev_printk.hlinux/err.hlinux/gpio/consumer.hlinux/iio/iio.hlinux/kstrtox.hlinux/mod_devicetable.hlinux/module.hlinux/mutex.hlinux/property.hlinux/regmap.hlinux/regulator/consumer.hlinux/spi/spi.hlinux/sysfs.hlinux/types.hlinux/units.h
Detected Declarations
struct ad3530r_chanstruct ad3530r_chip_infostruct ad3530r_stateenum ad3530r_modefunction ad3530r_input_ch_regfunction ad3531r_input_ch_regfunction ad3530r_get_powerdown_modefunction ad3530r_set_powerdown_modefunction ad3530r_get_dac_powerdownfunction ad3530r_set_dac_powerdownfunction ad3530r_trigger_hw_ldacfunction ad3530r_dac_writefunction ad3530r_read_rawfunction ad3530r_write_rawfunction ad3530r_reg_accessfunction ad3530r_setupfunction ad3530r_probe
Annotated Snippet
struct ad3530r_chan {
enum ad3530r_mode powerdown_mode;
bool powerdown;
};
struct ad3530r_chip_info {
const char *name;
const struct iio_chan_spec *channels;
int (*input_ch_reg)(unsigned int channel);
unsigned int num_channels;
unsigned int sw_ldac_trig_reg;
bool internal_ref_support;
};
struct ad3530r_state {
struct regmap *regmap;
/* lock to protect against multiple access to the device and shared data */
struct mutex lock;
struct ad3530r_chan chan[AD3530R_MAX_CHANNELS];
const struct ad3530r_chip_info *chip_info;
struct gpio_desc *ldac_gpio;
int vref_mV;
/*
* DMA (thus cache coherency maintenance) may require the transfer
* buffers to live in their own cache lines.
*/
__be16 buf __aligned(IIO_DMA_MINALIGN);
};
static int ad3530r_input_ch_reg(unsigned int channel)
{
return 2 * channel + AD3530R_INPUT_CH;
}
static int ad3531r_input_ch_reg(unsigned int channel)
{
return 2 * channel + AD3531R_INPUT_CH;
}
static const char * const ad3530r_powerdown_modes[] = {
"1kohm_to_gnd",
"7.7kohm_to_gnd",
"32kohm_to_gnd",
};
static const char * const ad3531r_powerdown_modes[] = {
"500ohm_to_gnd",
"3.85kohm_to_gnd",
"16kohm_to_gnd",
};
static int ad3530r_get_powerdown_mode(struct iio_dev *indio_dev,
const struct iio_chan_spec *chan)
{
struct ad3530r_state *st = iio_priv(indio_dev);
guard(mutex)(&st->lock);
return st->chan[chan->channel].powerdown_mode - 1;
}
static int ad3530r_set_powerdown_mode(struct iio_dev *indio_dev,
const struct iio_chan_spec *chan,
unsigned int mode)
{
struct ad3530r_state *st = iio_priv(indio_dev);
guard(mutex)(&st->lock);
st->chan[chan->channel].powerdown_mode = mode + 1;
return 0;
}
static const struct iio_enum ad3530r_powerdown_mode_enum = {
.items = ad3530r_powerdown_modes,
.num_items = ARRAY_SIZE(ad3530r_powerdown_modes),
.get = ad3530r_get_powerdown_mode,
.set = ad3530r_set_powerdown_mode,
};
static const struct iio_enum ad3531r_powerdown_mode_enum = {
.items = ad3531r_powerdown_modes,
.num_items = ARRAY_SIZE(ad3531r_powerdown_modes),
.get = ad3530r_get_powerdown_mode,
.set = ad3530r_set_powerdown_mode,
};
static ssize_t ad3530r_get_dac_powerdown(struct iio_dev *indio_dev,
uintptr_t private,
const struct iio_chan_spec *chan,
char *buf)
Annotation
- Immediate include surface: `linux/array_size.h`, `linux/bitfield.h`, `linux/bits.h`, `linux/cleanup.h`, `linux/delay.h`, `linux/dev_printk.h`, `linux/err.h`, `linux/gpio/consumer.h`.
- Detected declarations: `struct ad3530r_chan`, `struct ad3530r_chip_info`, `struct ad3530r_state`, `enum ad3530r_mode`, `function ad3530r_input_ch_reg`, `function ad3531r_input_ch_reg`, `function ad3530r_get_powerdown_mode`, `function ad3530r_set_powerdown_mode`, `function ad3530r_get_dac_powerdown`, `function ad3530r_set_dac_powerdown`.
- 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.