drivers/iio/frequency/admv4420.c
Source file repositories/reference/linux-study-clean/drivers/iio/frequency/admv4420.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/frequency/admv4420.c- Extension
.c- Size
- 10253 bytes
- Lines
- 396
- 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/bitfield.hlinux/iio/iio.hlinux/iio/sysfs.hlinux/module.hlinux/regmap.hlinux/spi/spi.hlinux/units.hlinux/unaligned.h
Detected Declarations
struct admv4420_reference_blockstruct admv4420_n_counterstruct admv4420_stateenum admv4420_mux_selfunction admv4420_reg_accessfunction admv4420_set_n_counterfunction admv4420_read_rawfunction admv4420_fw_parsefunction admv4420_calc_pfd_vcofunction admv4420_calc_pfd_reffunction admv4420_calc_parametersfunction admv4420_setupfunction admv4420_probe
Annotated Snippet
struct admv4420_reference_block {
bool doubler_en;
bool divide_by_2_en;
bool ref_single_ended;
u32 divider;
};
struct admv4420_n_counter {
u32 int_val;
u32 frac_val;
u32 mod_val;
u32 n_counter;
};
struct admv4420_state {
struct spi_device *spi;
struct regmap *regmap;
u64 vco_freq_hz;
u64 lo_freq_hz;
struct admv4420_reference_block ref_block;
struct admv4420_n_counter n_counter;
enum admv4420_mux_sel mux_sel;
struct mutex lock;
u8 transf_buf[4] __aligned(IIO_DMA_MINALIGN);
};
static const struct regmap_config admv4420_regmap_config = {
.reg_bits = 16,
.val_bits = 8,
.read_flag_mask = BIT(7),
};
static int admv4420_reg_access(struct iio_dev *indio_dev,
u32 reg, u32 writeval,
u32 *readval)
{
struct admv4420_state *st = iio_priv(indio_dev);
if (readval)
return regmap_read(st->regmap, reg, readval);
else
return regmap_write(st->regmap, reg, writeval);
}
static int admv4420_set_n_counter(struct admv4420_state *st, u32 int_val,
u32 frac_val, u32 mod_val)
{
int ret;
put_unaligned_le32(frac_val, st->transf_buf);
ret = regmap_bulk_write(st->regmap, ADMV4420_FRAC_L, st->transf_buf, 3);
if (ret)
return ret;
put_unaligned_le32(mod_val, st->transf_buf);
ret = regmap_bulk_write(st->regmap, ADMV4420_MOD_L, st->transf_buf, 3);
if (ret)
return ret;
put_unaligned_le32(int_val, st->transf_buf);
return regmap_bulk_write(st->regmap, ADMV4420_INT_L, st->transf_buf, 2);
}
static int admv4420_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int *val, int *val2, long info)
{
struct admv4420_state *st = iio_priv(indio_dev);
switch (info) {
case IIO_CHAN_INFO_FREQUENCY:
*val = div_u64_rem(st->lo_freq_hz, MICRO, val2);
return IIO_VAL_INT_PLUS_MICRO;
default:
return -EINVAL;
}
}
static const struct iio_info admv4420_info = {
.read_raw = admv4420_read_raw,
.debugfs_reg_access = &admv4420_reg_access,
};
static const struct iio_chan_spec admv4420_channels[] = {
{
.type = IIO_ALTVOLTAGE,
.output = 0,
.indexed = 1,
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/iio/iio.h`, `linux/iio/sysfs.h`, `linux/module.h`, `linux/regmap.h`, `linux/spi/spi.h`, `linux/units.h`, `linux/unaligned.h`.
- Detected declarations: `struct admv4420_reference_block`, `struct admv4420_n_counter`, `struct admv4420_state`, `enum admv4420_mux_sel`, `function admv4420_reg_access`, `function admv4420_set_n_counter`, `function admv4420_read_raw`, `function admv4420_fw_parse`, `function admv4420_calc_pfd_vco`, `function admv4420_calc_pfd_ref`.
- 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.