drivers/iio/cdc/ad7746.c

Source file repositories/reference/linux-study-clean/drivers/iio/cdc/ad7746.c

File Facts

System
Linux kernel
Corpus path
drivers/iio/cdc/ad7746.c
Extension
.c
Size
21235 bytes
Lines
820
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 ad7746_chip_info {
	struct i2c_client *client;
	struct mutex lock; /* protect sensor state */
	/*
	 * Capacitive channel digital filter setup;
	 * conversion time/update rate setup per channel
	 */
	u8	config;
	u8	cap_setup;
	u8	vt_setup;
	u8	capdac[2][2];
	s8	capdac_set;
};

enum ad7746_chan {
	VIN,
	VIN_VDD,
	TEMP_INT,
	TEMP_EXT,
	CIN1,
	CIN1_DIFF,
	CIN2,
	CIN2_DIFF,
};

struct ad7746_chan_info {
	u8 addr;
	union {
		u8 vtmd;
		struct { /* CAP SETUP fields */
			unsigned int cin2 : 1;
			unsigned int capdiff : 1;
		};
	};
};

static const struct ad7746_chan_info ad7746_chan_info[] = {
	[VIN] = {
		.addr = AD7746_REG_VT_DATA_HIGH,
		.vtmd = AD7746_VTSETUP_VTMD_EXT_VIN,
	},
	[VIN_VDD] = {
		.addr = AD7746_REG_VT_DATA_HIGH,
		.vtmd = AD7746_VTSETUP_VTMD_VDD_MON,
	},
	[TEMP_INT] = {
		.addr = AD7746_REG_VT_DATA_HIGH,
		.vtmd = AD7746_VTSETUP_VTMD_INT_TEMP,
	},
	[TEMP_EXT] = {
		.addr = AD7746_REG_VT_DATA_HIGH,
		.vtmd = AD7746_VTSETUP_VTMD_EXT_TEMP,
	},
	[CIN1] = {
		.addr = AD7746_REG_CAP_DATA_HIGH,
	},
	[CIN1_DIFF] = {
		.addr =  AD7746_REG_CAP_DATA_HIGH,
		.capdiff = 1,
	},
	[CIN2] = {
		.addr = AD7746_REG_CAP_DATA_HIGH,
		.cin2 = 1,
	},
	[CIN2_DIFF] = {
		.addr = AD7746_REG_CAP_DATA_HIGH,
		.cin2 = 1,
		.capdiff = 1,
	},
};

static const struct iio_chan_spec ad7746_channels[] = {
	[VIN] = {
		.type = IIO_VOLTAGE,
		.indexed = 1,
		.channel = 0,
		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
		.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SAMP_FREQ),
		.info_mask_shared_by_type_available = BIT(IIO_CHAN_INFO_SAMP_FREQ),
		.address = VIN,
	},
	[VIN_VDD] = {
		.type = IIO_VOLTAGE,
		.indexed = 1,
		.channel = 1,
		.extend_name = "supply",
		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
		.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SAMP_FREQ),
		.info_mask_shared_by_type_available = BIT(IIO_CHAN_INFO_SAMP_FREQ),
		.address = VIN_VDD,

Annotation

Implementation Notes