drivers/iio/dac/ad5360.c
Source file repositories/reference/linux-study-clean/drivers/iio/dac/ad5360.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/dac/ad5360.c- Extension
.c- Size
- 13488 bytes
- Lines
- 551
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/device.hlinux/err.hlinux/module.hlinux/kernel.hlinux/spi/spi.hlinux/slab.hlinux/sysfs.hlinux/regulator/consumer.hlinux/iio/iio.hlinux/iio/sysfs.h
Detected Declarations
struct ad5360_chip_infostruct ad5360_stateenum ad5360_typefunction ad5360_get_channel_vref_indexfunction ad5360_get_channel_vreffunction ad5360_write_unlockedfunction ad5360_writefunction ad5360_readfunction ad5360_read_dac_powerdownfunction ad5360_update_ctrlfunction ad5360_write_dac_powerdownfunction ad5360_write_rawfunction ad5360_read_rawfunction ad5360_alloc_channelsfunction ad5360_probefunction ad5360_remove
Annotated Snippet
struct ad5360_chip_info {
struct iio_chan_spec channel_template;
unsigned int num_channels;
unsigned int channels_per_group;
unsigned int num_vrefs;
};
/**
* struct ad5360_state - driver instance specific data
* @spi: spi_device
* @chip_info: chip model specific constants, available modes etc
* @vref_reg: vref supply regulators
* @ctrl: control register cache
* @lock: lock to protect the data buffer during SPI ops
* @data: spi transfer buffers
*/
struct ad5360_state {
struct spi_device *spi;
const struct ad5360_chip_info *chip_info;
struct regulator_bulk_data vref_reg[3];
unsigned int ctrl;
struct mutex lock;
/*
* DMA (thus cache coherency maintenance) may require the
* transfer buffers to live in their own cache lines.
*/
union {
__be32 d32;
u8 d8[4];
} data[2] __aligned(IIO_DMA_MINALIGN);
};
enum ad5360_type {
ID_AD5360,
ID_AD5361,
ID_AD5362,
ID_AD5363,
ID_AD5370,
ID_AD5371,
ID_AD5372,
ID_AD5373,
};
#define AD5360_CHANNEL(bits) { \
.type = IIO_VOLTAGE, \
.indexed = 1, \
.output = 1, \
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \
BIT(IIO_CHAN_INFO_SCALE) | \
BIT(IIO_CHAN_INFO_OFFSET) | \
BIT(IIO_CHAN_INFO_CALIBSCALE) | \
BIT(IIO_CHAN_INFO_CALIBBIAS), \
.scan_type = { \
.sign = 'u', \
.realbits = (bits), \
.storagebits = 16, \
.shift = 16 - (bits), \
}, \
}
static const struct ad5360_chip_info ad5360_chip_info_tbl[] = {
[ID_AD5360] = {
.channel_template = AD5360_CHANNEL(16),
.num_channels = 16,
.channels_per_group = 8,
.num_vrefs = 2,
},
[ID_AD5361] = {
.channel_template = AD5360_CHANNEL(14),
.num_channels = 16,
.channels_per_group = 8,
.num_vrefs = 2,
},
[ID_AD5362] = {
.channel_template = AD5360_CHANNEL(16),
.num_channels = 8,
.channels_per_group = 4,
.num_vrefs = 2,
},
[ID_AD5363] = {
.channel_template = AD5360_CHANNEL(14),
.num_channels = 8,
.channels_per_group = 4,
.num_vrefs = 2,
},
[ID_AD5370] = {
.channel_template = AD5360_CHANNEL(16),
.num_channels = 40,
Annotation
- Immediate include surface: `linux/device.h`, `linux/err.h`, `linux/module.h`, `linux/kernel.h`, `linux/spi/spi.h`, `linux/slab.h`, `linux/sysfs.h`, `linux/regulator/consumer.h`.
- Detected declarations: `struct ad5360_chip_info`, `struct ad5360_state`, `enum ad5360_type`, `function ad5360_get_channel_vref_index`, `function ad5360_get_channel_vref`, `function ad5360_write_unlocked`, `function ad5360_write`, `function ad5360_read`, `function ad5360_read_dac_powerdown`, `function ad5360_update_ctrl`.
- 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.