drivers/iio/adc/ad7173.c

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

File Facts

System
Linux kernel
Corpus path
drivers/iio/adc/ad7173.c
Extension
.c
Size
60947 bytes
Lines
2101
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 ad7173_device_info {
	const unsigned int *sinc5_data_rates;
	unsigned int num_sinc5_data_rates;
	unsigned int odr_start_value;
	/*
	 * AD4116 has both inputs with a voltage divider and without.
	 * These inputs cannot be mixed in the channel configuration.
	 * Does not include the VINCOM input.
	 */
	unsigned int num_voltage_in_div;
	unsigned int num_channels;
	unsigned int num_configs;
	unsigned int num_voltage_in;
	unsigned int clock;
	unsigned int id;
	char *name;
	const struct ad_sigma_delta_info *sd_info;
	bool has_current_inputs;
	bool has_vincom_input;
	bool has_temp;
	/* ((AVDD1 − AVSS)/5) */
	bool has_pow_supply_monitoring;
	bool data_reg_only_16bit;
	bool has_input_buf;
	bool has_int_ref;
	bool has_ref2;
	bool has_internal_fs_calibration;
	bool has_openwire_det;
	bool higher_gpio_bits;
	u8 num_gpios;
};

enum ad7173_filter_type {
	AD7173_FILTER_SINC3,
	AD7173_FILTER_SINC5_SINC1,
	AD7173_FILTER_SINC5_SINC1_PF1,
	AD7173_FILTER_SINC5_SINC1_PF2,
	AD7173_FILTER_SINC5_SINC1_PF3,
	AD7173_FILTER_SINC5_SINC1_PF4,
};

struct ad7173_channel_config {
	/* Openwire detection threshold */
	unsigned int openwire_thrsh_raw;
	int openwire_comp_chan;
	u8 cfg_slot;
	bool live;

	/*
	 * Following fields are used to compare equality. If you
	 * make adaptations in it, you most likely also have to adapt
	 * ad7173_is_setup_equal(), too.
	 */
	struct_group(config_props,
		bool bipolar;
		bool input_buf;
		u16 sinc3_odr_div;
		u8 sinc5_odr_index;
		u8 ref_sel;
		enum ad7173_filter_type filter_type;
	);
};

struct ad7173_channel {
	unsigned int ain;
	struct ad7173_channel_config cfg;
	u8 syscalib_mode;
	bool openwire_det_en;
};

struct ad7173_state {
	struct ad_sigma_delta sd;
	const struct ad7173_device_info *info;
	struct ad7173_channel *channels;
	struct regulator_bulk_data regulators[3];
	unsigned int adc_mode;
	unsigned int interface_mode;
	unsigned int num_channels;
	struct ida cfg_slots_status;
	unsigned long long config_usage_counter;
	unsigned long long *config_cnts;
	struct clk_hw int_clk_hw;
	struct regmap *reg_gpiocon_regmap;
	struct gpio_regmap *gpio_regmap;
};

static unsigned int ad4115_sinc5_data_rates[] = {
	24845000, 24845000, 20725000, 20725000,	/*  0-3  */
	15564000, 13841000, 10390000, 10390000,	/*  4-7  */
	4994000,  2499000,  1000000,  500000,	/*  8-11 */

Annotation

Implementation Notes