drivers/iio/accel/sca3000.c

Source file repositories/reference/linux-study-clean/drivers/iio/accel/sca3000.c

File Facts

System
Linux kernel
Corpus path
drivers/iio/accel/sca3000.c
Extension
.c
Size
42207 bytes
Lines
1527
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 sca3000_state {
	struct spi_device		*us;
	const struct sca3000_chip_info	*info;
	int				mo_det_use_count;
	struct mutex			lock;
	/* Can these share a cacheline ? */
	u8				rx[384] __aligned(IIO_DMA_MINALIGN);
	u8				tx[6] __aligned(IIO_DMA_MINALIGN);
};

/**
 * struct sca3000_chip_info - model dependent parameters
 * @name:			name of the chip
 * @scale:			scale * 10^-6
 * @temp_output:		some devices have temperature sensors.
 * @measurement_mode_freq:	normal mode sampling frequency
 * @measurement_mode_3db_freq:	3db cutoff frequency of the low pass filter for
 * the normal measurement mode.
 * @option_mode_1:		first optional mode. Not all models have one
 * @option_mode_1_freq:		option mode 1 sampling frequency
 * @option_mode_1_3db_freq:	3db cutoff frequency of the low pass filter for
 * the first option mode.
 * @option_mode_2:		second optional mode. Not all chips have one
 * @option_mode_2_freq:		option mode 2 sampling frequency
 * @option_mode_2_3db_freq:	3db cutoff frequency of the low pass filter for
 * the second option mode.
 * @mot_det_mult_xz:		Bit wise multipliers to calculate the threshold
 * for motion detection in the x and z axis.
 * @mot_det_mult_y:		Bit wise multipliers to calculate the threshold
 * for motion detection in the y axis.
 *
 * This structure is used to hold information about the functionality of a given
 * sca3000 variant.
 **/
struct sca3000_chip_info {
	const char		*name;
	unsigned int		scale;
	bool			temp_output;
	int			measurement_mode_freq;
	int			measurement_mode_3db_freq;
	int			option_mode_1;
	int			option_mode_1_freq;
	int			option_mode_1_3db_freq;
	int			option_mode_2;
	int			option_mode_2_freq;
	int			option_mode_2_3db_freq;
	int			mot_det_mult_xz[6];
	int			mot_det_mult_y[7];
};

static const struct sca3000_chip_info sca3000_chip_info_d01 = {
	.name = "sca3000_d01",
	.scale = 7357,
	.temp_output = true,
	.measurement_mode_freq = 250,
	.measurement_mode_3db_freq = 45,
	.option_mode_1 = SCA3000_OP_MODE_BYPASS,
	.option_mode_1_freq = 250,
	.option_mode_1_3db_freq = 70,
	.mot_det_mult_xz = { 50, 100, 200, 350, 650, 1300 },
	.mot_det_mult_y = { 50, 100, 150, 250, 450, 850, 1750 },
};

static const struct sca3000_chip_info sca3000_chip_info_e02 = {
	.name = "sca3000_e02",
	.scale = 9810,
	.measurement_mode_freq = 125,
	.measurement_mode_3db_freq = 40,
	.option_mode_1 = SCA3000_OP_MODE_NARROW,
	.option_mode_1_freq = 63,
	.option_mode_1_3db_freq = 11,
	.mot_det_mult_xz = { 100, 150, 300, 550, 1050, 2050 },
	.mot_det_mult_y = { 50, 100, 200, 350, 700, 1350, 2700 },
};

static const struct sca3000_chip_info sca3000_chip_info_e04 = {
	.name = "sca3000_e04",
	.scale = 19620,
	.measurement_mode_freq = 100,
	.measurement_mode_3db_freq = 38,
	.option_mode_1 = SCA3000_OP_MODE_NARROW,
	.option_mode_1_freq = 50,
	.option_mode_1_3db_freq = 9,
	.option_mode_2 = SCA3000_OP_MODE_WIDE,
	.option_mode_2_freq = 400,
	.option_mode_2_3db_freq = 70,
	.mot_det_mult_xz = { 200, 300, 600, 1100, 2100, 4100 },
	.mot_det_mult_y = { 100, 200, 400, 7000, 1400, 2700, 54000 },
};

Annotation

Implementation Notes