drivers/iio/dac/ds4424.c

Source file repositories/reference/linux-study-clean/drivers/iio/dac/ds4424.c

File Facts

System
Linux kernel
Corpus path
drivers/iio/dac/ds4424.c
Extension
.c
Size
11165 bytes
Lines
440
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.

Dependency Surface

Detected Declarations

Annotated Snippet

struct ds4424_chip_info {
	const char *name;
	int vref_mV;
	int scale_denom;
	u8 result_mask;
	u8 num_channels;
};

static const struct ds4424_chip_info ds4402_info = {
	.name = "ds4402",
	.vref_mV = 1230,
	.scale_denom = 4,
	.result_mask = DS4404_DAC_MASK,
	.num_channels = DS4422_MAX_DAC_CHANNELS,
};

static const struct ds4424_chip_info ds4404_info = {
	.name = "ds4404",
	.vref_mV = 1230,
	.scale_denom = 4,
	.result_mask = DS4404_DAC_MASK,
	.num_channels = DS4424_MAX_DAC_CHANNELS,
};

static const struct ds4424_chip_info ds4422_info = {
	.name = "ds4422",
	.vref_mV = 976,
	.scale_denom = 16,
	.result_mask = DS4424_DAC_MASK,
	.num_channels = DS4422_MAX_DAC_CHANNELS,
};

static const struct ds4424_chip_info ds4424_info = {
	.name = "ds4424",
	.vref_mV = 976,
	.scale_denom = 16,
	.result_mask = DS4424_DAC_MASK,
	.num_channels = DS4424_MAX_DAC_CHANNELS,
};

struct ds4424_data {
	struct regmap *regmap;
	struct regulator *vcc_reg;
	const struct ds4424_chip_info *chip_info;
	u32 rfs_ohms[DS4424_MAX_DAC_CHANNELS];
	bool has_rfs;
};

static const struct iio_chan_spec ds4424_channels[] = {
	DS4424_CHANNEL(0),
	DS4424_CHANNEL(1),
	DS4424_CHANNEL(2),
	DS4424_CHANNEL(3),
};

static const struct iio_chan_spec ds4424_channels_with_scale[] = {
	DS4424_CHANNEL_WITH_SCALE(0),
	DS4424_CHANNEL_WITH_SCALE(1),
	DS4424_CHANNEL_WITH_SCALE(2),
	DS4424_CHANNEL_WITH_SCALE(3),
};

static const struct regmap_range ds44x2_ranges[] = {
	regmap_reg_range(DS4424_DAC_ADDR(0), DS4424_DAC_ADDR(1)),
};

static const struct regmap_range ds44x4_ranges[] = {
	regmap_reg_range(DS4424_DAC_ADDR(0), DS4424_DAC_ADDR(3)),
};

static const struct regmap_access_table ds44x2_table = {
	.yes_ranges = ds44x2_ranges,
	.n_yes_ranges = ARRAY_SIZE(ds44x2_ranges),
};

static const struct regmap_access_table ds44x4_table = {
	.yes_ranges = ds44x4_ranges,
	.n_yes_ranges = ARRAY_SIZE(ds44x4_ranges),
};

static const struct regmap_config ds44x2_regmap_config = {
	.reg_bits = 8,
	.val_bits = 8,
	.cache_type = REGCACHE_MAPLE,
	.max_register = DS4424_DAC_ADDR(1),
	.rd_table = &ds44x2_table,
	.wr_table = &ds44x2_table,
};

static const struct regmap_config ds44x4_regmap_config = {

Annotation

Implementation Notes