drivers/iio/adc/ltc2309.c

Source file repositories/reference/linux-study-clean/drivers/iio/adc/ltc2309.c

File Facts

System
Linux kernel
Corpus path
drivers/iio/adc/ltc2309.c
Extension
.c
Size
6743 bytes
Lines
255
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 ltc2309 {
	struct device		*dev;
	struct i2c_client	*client;
	struct mutex		lock; /* serialize data access */
	int			vref_mv;
};

/* Order matches expected channel address, See datasheet Table 1. */
enum ltc2305_channels {
	LTC2305_CH0_CH1 = 0x0,
	LTC2305_CH1_CH0 = 0x4,
	LTC2305_CH0     = 0x8,
	LTC2305_CH1     = 0xc,
};

enum ltc2309_channels {
	LTC2309_CH0_CH1 = 0x0,
	LTC2309_CH2_CH3 = 0x1,
	LTC2309_CH4_CH5 = 0x2,
	LTC2309_CH6_CH7 = 0x3,
	LTC2309_CH1_CH0 = 0x4,
	LTC2309_CH3_CH2 = 0x5,
	LTC2309_CH5_CH4 = 0x6,
	LTC2309_CH7_CH6 = 0x7,
	LTC2309_CH0     = 0x8,
	LTC2309_CH2     = 0x9,
	LTC2309_CH4     = 0xa,
	LTC2309_CH6     = 0xb,
	LTC2309_CH1     = 0xc,
	LTC2309_CH3     = 0xd,
	LTC2309_CH5     = 0xe,
	LTC2309_CH7     = 0xf,
};

#define LTC2309_CHAN(_chan, _addr) {				\
	.type = IIO_VOLTAGE,					\
	.indexed = 1,						\
	.address = _addr,					\
	.channel = _chan,					\
	.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),		\
	.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),	\
}

#define LTC2309_DIFF_CHAN(_chan, _chan2, _addr) {		\
	.type = IIO_VOLTAGE,					\
	.differential = 1,					\
	.indexed = 1,						\
	.address = _addr,					\
	.channel = _chan,					\
	.channel2 = _chan2,					\
	.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),		\
	.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),	\
}

static const struct iio_chan_spec ltc2305_channels[] = {
	LTC2309_CHAN(0, LTC2305_CH0),
	LTC2309_CHAN(1, LTC2305_CH1),
	LTC2309_DIFF_CHAN(0, 1, LTC2305_CH0_CH1),
	LTC2309_DIFF_CHAN(1, 0, LTC2305_CH1_CH0),
};

static const struct iio_chan_spec ltc2309_channels[] = {
	LTC2309_CHAN(0, LTC2309_CH0),
	LTC2309_CHAN(1, LTC2309_CH1),
	LTC2309_CHAN(2, LTC2309_CH2),
	LTC2309_CHAN(3, LTC2309_CH3),
	LTC2309_CHAN(4, LTC2309_CH4),
	LTC2309_CHAN(5, LTC2309_CH5),
	LTC2309_CHAN(6, LTC2309_CH6),
	LTC2309_CHAN(7, LTC2309_CH7),
	LTC2309_DIFF_CHAN(0, 1, LTC2309_CH0_CH1),
	LTC2309_DIFF_CHAN(2, 3, LTC2309_CH2_CH3),
	LTC2309_DIFF_CHAN(4, 5, LTC2309_CH4_CH5),
	LTC2309_DIFF_CHAN(6, 7, LTC2309_CH6_CH7),
	LTC2309_DIFF_CHAN(1, 0, LTC2309_CH1_CH0),
	LTC2309_DIFF_CHAN(3, 2, LTC2309_CH3_CH2),
	LTC2309_DIFF_CHAN(5, 4, LTC2309_CH5_CH4),
	LTC2309_DIFF_CHAN(7, 6, LTC2309_CH7_CH6),
};

struct ltc2309_chip_info {
	const char *name;
	const struct iio_chan_spec *channels;
	int num_channels;
};

static const struct ltc2309_chip_info ltc2305_chip_info = {
	.name = "ltc2305",
	.channels = ltc2305_channels,
	.num_channels = ARRAY_SIZE(ltc2305_channels),

Annotation

Implementation Notes