drivers/iio/accel/msa311.c
Source file repositories/reference/linux-study-clean/drivers/iio/accel/msa311.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/accel/msa311.c- Extension
.c- Size
- 36300 bytes
- Lines
- 1297
- 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/i2c.hlinux/mod_devicetable.hlinux/module.hlinux/pm.hlinux/pm_runtime.hlinux/regmap.hlinux/string_choices.hlinux/types.hlinux/units.hlinux/iio/buffer.hlinux/iio/iio.hlinux/iio/sysfs.hlinux/iio/trigger.hlinux/iio/trigger_consumer.hlinux/iio/triggered_buffer.h
Detected Declarations
struct iio_decimal_fractstruct msa311_privenum msa311_fieldsenum msa311_sifunction msa311_get_odrfunction msa311_set_odrfunction msa311_wait_for_next_datafunction msa311_set_pwr_modefunction msa311_get_axisfunction msa311_read_raw_datafunction msa311_read_scalefunction msa311_read_samp_freqfunction msa311_read_rawfunction msa311_read_availfunction msa311_write_scalefunction msa311_write_samp_freqfunction msa311_write_rawfunction msa311_debugfs_reg_accessfunction msa311_buffer_preenablefunction msa311_buffer_postdisablefunction msa311_set_new_data_trig_statefunction msa311_validate_devicefunction msa311_buffer_threadfunction iio_for_each_active_channelfunction msa311_irq_threadfunction msa311_check_partidfunction msa311_soft_resetfunction msa311_chip_initfunction msa311_setup_interruptsfunction msa311_regmap_initfunction msa311_powerdownfunction msa311_probefunction msa311_runtime_suspendfunction msa311_runtime_resume
Annotated Snippet
struct iio_decimal_fract {
int integral;
int microfract;
};
static const struct iio_decimal_fract msa311_fs_table[] = {
{0, 9580}, {0, 19160}, {0, 38320}, {0, 76641},
};
/* Possible Output Data Rate values */
enum {
MSA311_ODR_1_HZ,
MSA311_ODR_1_95_HZ,
MSA311_ODR_3_9_HZ,
MSA311_ODR_7_81_HZ,
MSA311_ODR_15_63_HZ,
MSA311_ODR_31_25_HZ,
MSA311_ODR_62_5_HZ,
MSA311_ODR_125_HZ,
MSA311_ODR_250_HZ,
MSA311_ODR_500_HZ,
MSA311_ODR_1000_HZ,
};
static const struct iio_decimal_fract msa311_odr_table[] = {
{1, 0}, {1, 950000}, {3, 900000}, {7, 810000}, {15, 630000},
{31, 250000}, {62, 500000}, {125, 0}, {250, 0}, {500, 0}, {1000, 0},
};
/* All supported power modes */
#define MSA311_PWR_MODE_NORMAL 0b00
#define MSA311_PWR_MODE_LOW 0b01
#define MSA311_PWR_MODE_UNKNOWN 0b10
#define MSA311_PWR_MODE_SUSPEND 0b11
static const char * const msa311_pwr_modes[] = {
[MSA311_PWR_MODE_NORMAL] = "normal",
[MSA311_PWR_MODE_LOW] = "low",
[MSA311_PWR_MODE_UNKNOWN] = "unknown",
[MSA311_PWR_MODE_SUSPEND] = "suspend",
};
/* Autosuspend delay */
#define MSA311_PWR_SLEEP_DELAY_MS 2000
/* Possible INT1 types and levels */
enum {
MSA311_INT1_OD_PUSH_PULL,
MSA311_INT1_OD_OPEN_DRAIN,
};
enum {
MSA311_INT1_LVL_LOW,
MSA311_INT1_LVL_HIGH,
};
/* Latch INT modes */
#define MSA311_LATCH_INT_NOT_LATCHED 0b0000
#define MSA311_LATCH_INT_250MS 0b0001
#define MSA311_LATCH_INT_500MS 0b0010
#define MSA311_LATCH_INT_1S 0b0011
#define MSA311_LATCH_INT_2S 0b0100
#define MSA311_LATCH_INT_4S 0b0101
#define MSA311_LATCH_INT_8S 0b0110
#define MSA311_LATCH_INT_1MS 0b1010
#define MSA311_LATCH_INT_2MS 0b1011
#define MSA311_LATCH_INT_25MS 0b1100
#define MSA311_LATCH_INT_50MS 0b1101
#define MSA311_LATCH_INT_100MS 0b1110
#define MSA311_LATCH_INT_LATCHED 0b0111
static const struct regmap_range msa311_readonly_registers[] = {
regmap_reg_range(MSA311_PARTID_REG, MSA311_ORIENT_STS_REG),
};
static const struct regmap_access_table msa311_writeable_table = {
.no_ranges = msa311_readonly_registers,
.n_no_ranges = ARRAY_SIZE(msa311_readonly_registers),
};
static const struct regmap_range msa311_writeonly_registers[] = {
regmap_reg_range(MSA311_SOFT_RESET_REG, MSA311_SOFT_RESET_REG),
};
static const struct regmap_access_table msa311_readable_table = {
.no_ranges = msa311_writeonly_registers,
.n_no_ranges = ARRAY_SIZE(msa311_writeonly_registers),
};
static const struct regmap_range msa311_volatile_registers[] = {
regmap_reg_range(MSA311_ACC_X_REG, MSA311_ORIENT_STS_REG),
Annotation
- Immediate include surface: `linux/i2c.h`, `linux/mod_devicetable.h`, `linux/module.h`, `linux/pm.h`, `linux/pm_runtime.h`, `linux/regmap.h`, `linux/string_choices.h`, `linux/types.h`.
- Detected declarations: `struct iio_decimal_fract`, `struct msa311_priv`, `enum msa311_fields`, `enum msa311_si`, `function msa311_get_odr`, `function msa311_set_odr`, `function msa311_wait_for_next_data`, `function msa311_set_pwr_mode`, `function msa311_get_axis`, `function msa311_read_raw_data`.
- 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.