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.
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/cleanup.hlinux/interrupt.hlinux/fs.hlinux/device.hlinux/slab.hlinux/kernel.hlinux/spi/spi.hlinux/sysfs.hlinux/module.hlinux/uaccess.hlinux/iio/iio.hlinux/iio/sysfs.hlinux/iio/events.hlinux/iio/buffer.hlinux/iio/kfifo_buf.h
Detected Declarations
struct sca3000_statestruct sca3000_chip_infofunction sca3000_write_regfunction sca3000_read_data_shortfunction sca3000_reg_lock_onfunction __sca3000_unlock_reg_lockfunction sca3000_write_ctrl_regfunction sca3000_read_ctrl_regfunction sca3000_print_revfunction sca3000_show_available_3db_freqsfunction __sca3000_get_base_freqfunction sca3000_read_raw_samp_freqfunction sca3000_write_raw_samp_freqfunction sca3000_read_3db_freqfunction sca3000_write_3db_freqfunction sca3000_read_rawfunction sca3000_write_rawfunction sca3000_read_av_freqfunction sca3000_read_event_valuefunction sca3000_write_event_valuefunction sca3000_read_datafunction sca3000_ring_int_processfunction sca3000_event_handlerfunction sca3000_read_event_configfunction sca3000_freefall_set_statefunction sca3000_motion_detect_set_statefunction sca3000_write_event_configfunction __sca3000_hw_ring_state_setfunction sca3000_hw_ring_preenablefunction sca3000_hw_ring_postdisablefunction sca3000_clean_setupfunction sca3000_stop_all_interruptsfunction sca3000_probe
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
- Immediate include surface: `linux/cleanup.h`, `linux/interrupt.h`, `linux/fs.h`, `linux/device.h`, `linux/slab.h`, `linux/kernel.h`, `linux/spi/spi.h`, `linux/sysfs.h`.
- Detected declarations: `struct sca3000_state`, `struct sca3000_chip_info`, `function sca3000_write_reg`, `function sca3000_read_data_short`, `function sca3000_reg_lock_on`, `function __sca3000_unlock_reg_lock`, `function sca3000_write_ctrl_reg`, `function sca3000_read_ctrl_reg`, `function sca3000_print_rev`, `function sca3000_show_available_3db_freqs`.
- Atlas domain: Driver Families / drivers/iio.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.