drivers/iio/frequency/admv1014.c
Source file repositories/reference/linux-study-clean/drivers/iio/frequency/admv1014.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/frequency/admv1014.c- Extension
.c- Size
- 21950 bytes
- Lines
- 809
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitfield.hlinux/bits.hlinux/clk.hlinux/clkdev.hlinux/device.hlinux/iio/iio.hlinux/module.hlinux/mod_devicetable.hlinux/notifier.hlinux/property.hlinux/regulator/consumer.hlinux/spi/spi.hlinux/units.hlinux/unaligned.h
Detected Declarations
struct admv1014_statefunction __admv1014_spi_readfunction admv1014_spi_readfunction __admv1014_spi_writefunction admv1014_spi_writefunction __admv1014_spi_update_bitsfunction admv1014_spi_update_bitsfunction admv1014_update_quad_filtersfunction admv1014_update_vcm_settingsfunction admv1014_read_rawfunction admv1014_write_rawfunction admv1014_readfunction admv1014_writefunction admv1014_read_availfunction admv1014_reg_accessfunction admv1014_freq_changefunction BITfunction admv1014_clk_disablefunction admv1014_reg_disablefunction admv1014_powerdownfunction admv1014_initfunction admv1014_properties_parsefunction admv1014_probe
Annotated Snippet
struct admv1014_state {
struct spi_device *spi;
struct clk *clkin;
struct notifier_block nb;
/* Protect against concurrent accesses to the device and to data*/
struct mutex lock;
struct regulator_bulk_data regulators[ADMV1014_NUM_REGULATORS];
unsigned int input_mode;
unsigned int quad_se_mode;
unsigned int p1db_comp;
bool det_en;
u8 data[3] __aligned(IIO_DMA_MINALIGN);
};
static const int mixer_vgate_table[] = {106, 107, 108, 110, 111, 112, 113, 114,
117, 118, 119, 120, 122, 123, 44, 45};
static int __admv1014_spi_read(struct admv1014_state *st, unsigned int reg,
unsigned int *val)
{
struct spi_transfer t = {};
int ret;
st->data[0] = ADMV1014_READ | FIELD_PREP(ADMV1014_REG_ADDR_READ_MSK, reg);
st->data[1] = 0;
st->data[2] = 0;
t.rx_buf = &st->data[0];
t.tx_buf = &st->data[0];
t.len = sizeof(st->data);
ret = spi_sync_transfer(st->spi, &t, 1);
if (ret)
return ret;
*val = FIELD_GET(ADMV1014_REG_DATA_MSK, get_unaligned_be24(&st->data[0]));
return ret;
}
static int admv1014_spi_read(struct admv1014_state *st, unsigned int reg,
unsigned int *val)
{
int ret;
mutex_lock(&st->lock);
ret = __admv1014_spi_read(st, reg, val);
mutex_unlock(&st->lock);
return ret;
}
static int __admv1014_spi_write(struct admv1014_state *st,
unsigned int reg,
unsigned int val)
{
put_unaligned_be24(FIELD_PREP(ADMV1014_REG_DATA_MSK, val) |
FIELD_PREP(ADMV1014_REG_ADDR_WRITE_MSK, reg), &st->data[0]);
return spi_write(st->spi, &st->data[0], 3);
}
static int admv1014_spi_write(struct admv1014_state *st, unsigned int reg,
unsigned int val)
{
int ret;
mutex_lock(&st->lock);
ret = __admv1014_spi_write(st, reg, val);
mutex_unlock(&st->lock);
return ret;
}
static int __admv1014_spi_update_bits(struct admv1014_state *st, unsigned int reg,
unsigned int mask, unsigned int val)
{
unsigned int data, temp;
int ret;
ret = __admv1014_spi_read(st, reg, &data);
if (ret)
return ret;
temp = (data & ~mask) | (val & mask);
return __admv1014_spi_write(st, reg, temp);
}
static int admv1014_spi_update_bits(struct admv1014_state *st, unsigned int reg,
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/bits.h`, `linux/clk.h`, `linux/clkdev.h`, `linux/device.h`, `linux/iio/iio.h`, `linux/module.h`, `linux/mod_devicetable.h`.
- Detected declarations: `struct admv1014_state`, `function __admv1014_spi_read`, `function admv1014_spi_read`, `function __admv1014_spi_write`, `function admv1014_spi_write`, `function __admv1014_spi_update_bits`, `function admv1014_spi_update_bits`, `function admv1014_update_quad_filters`, `function admv1014_update_vcm_settings`, `function admv1014_read_raw`.
- Atlas domain: Driver Families / drivers/iio.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.