drivers/iio/imu/smi330/smi330_core.c
Source file repositories/reference/linux-study-clean/drivers/iio/imu/smi330/smi330_core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/imu/smi330/smi330_core.c- Extension
.c- Size
- 23110 bytes
- Lines
- 914
- Domain
- Driver Families
- Bucket
- drivers/iio
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/bitfield.hlinux/delay.hlinux/interrupt.hlinux/irq.hlinux/module.hlinux/property.hlinux/regmap.hlinux/string.hlinux/units.hlinux/iio/buffer.hlinux/iio/iio.hlinux/iio/trigger.hlinux/iio/trigger_consumer.hlinux/iio/triggered_buffer.hsmi330.h
Detected Declarations
struct smi330_attributesstruct smi330_cfgstruct smi330_dataenum smi330_accel_rangeenum smi330_gyro_rangeenum smi330_odrenum smi330_avg_numenum smi330_modeenum smi330_bwenum smi330_operation_modeenum smi330_sensorenum smi330_sensor_conf_selectenum smi330_int_outfunction Copyrightfunction smi330_get_attributesfunction smi330_get_config_regfunction smi330_get_sensor_configfunction smi330_set_sensor_configfunction smi330_get_datafunction smi330_read_availfunction smi330_read_rawfunction smi330_write_rawfunction smi330_write_raw_get_fmtfunction smi330_soft_resetfunction smi330_trigger_handlerfunction smi330_irq_thread_handlerfunction smi330_set_int_pin_configfunction smi330_setup_irqfunction smi330_register_irqfunction smi330_set_drdy_trigger_statefunction smi330_dev_initfunction smi330_core_probe
Annotated Snippet
struct smi330_attributes {
int *reg_vals;
int *vals;
int len;
int type;
int mask;
};
struct smi330_cfg {
enum smi330_operation_mode op_mode;
enum smi330_int_out data_irq;
};
struct smi330_data {
struct regmap *regmap;
struct smi330_cfg cfg;
struct iio_trigger *trig;
IIO_DECLARE_BUFFER_WITH_TS(__le16, buf, SMI330_SCAN_LEN);
};
const struct regmap_config smi330_regmap_config = {
.reg_bits = 8,
.val_bits = 16,
.val_format_endian = REGMAP_ENDIAN_LITTLE,
};
EXPORT_SYMBOL_NS_GPL(smi330_regmap_config, "IIO_SMI330");
static const struct iio_chan_spec smi330_channels[] = {
SMI330_ACCEL_CHANNEL(X),
SMI330_ACCEL_CHANNEL(Y),
SMI330_ACCEL_CHANNEL(Z),
SMI330_GYRO_CHANNEL(X),
SMI330_GYRO_CHANNEL(Y),
SMI330_GYRO_CHANNEL(Z),
SMI330_TEMP_CHANNEL(-1), /* No buffer support */
IIO_CHAN_SOFT_TIMESTAMP(SMI330_SCAN_TIMESTAMP),
};
static const unsigned long smi330_avail_scan_masks[] = {
(BIT(SMI330_SCAN_ACCEL_X) | BIT(SMI330_SCAN_ACCEL_Y) |
BIT(SMI330_SCAN_ACCEL_Z) | BIT(SMI330_SCAN_GYRO_X) |
BIT(SMI330_SCAN_GYRO_Y) | BIT(SMI330_SCAN_GYRO_Z)),
0
};
static const struct smi330_attributes smi330_accel_scale_attr = {
.reg_vals = (int[]){ SMI330_ACCEL_RANGE_2G, SMI330_ACCEL_RANGE_4G,
SMI330_ACCEL_RANGE_8G, SMI330_ACCEL_RANGE_16G },
.vals = (int[]){ 0, 61035, 0, 122070, 0, 244140, 0, 488281 },
.len = 8,
.type = IIO_VAL_INT_PLUS_NANO,
.mask = SMI330_CFG_RANGE_MASK
};
static const struct smi330_attributes smi330_gyro_scale_attr = {
.reg_vals = (int[]){ SMI330_GYRO_RANGE_125, SMI330_GYRO_RANGE_250,
SMI330_GYRO_RANGE_500 },
.vals = (int[]){ 0, 3814697, 0, 7629395, 0, 15258789 },
.len = 6,
.type = IIO_VAL_INT_PLUS_NANO,
.mask = SMI330_CFG_RANGE_MASK
};
static const struct smi330_attributes smi330_average_attr = {
.reg_vals = (int[]){ SMI330_AVG_NUM_1, SMI330_AVG_NUM_2,
SMI330_AVG_NUM_4, SMI330_AVG_NUM_8,
SMI330_AVG_NUM_16, SMI330_AVG_NUM_32,
SMI330_AVG_NUM_64 },
.vals = (int[]){ 1, 2, 4, 8, 16, 32, 64 },
.len = 7,
.type = IIO_VAL_INT,
.mask = SMI330_CFG_AVG_NUM_MASK
};
static const struct smi330_attributes smi330_bandwidth_attr = {
.reg_vals = (int[]){ SMI330_BW_2, SMI330_BW_4 },
.vals = (int[]){ 2, 4 },
.len = 2,
.type = IIO_VAL_INT,
.mask = SMI330_CFG_BW_MASK
};
static const struct smi330_attributes smi330_odr_attr = {
.reg_vals = (int[]){ SMI330_ODR_12_5_HZ, SMI330_ODR_25_HZ,
SMI330_ODR_50_HZ, SMI330_ODR_100_HZ,
SMI330_ODR_200_HZ, SMI330_ODR_400_HZ,
SMI330_ODR_800_HZ, SMI330_ODR_1600_HZ,
SMI330_ODR_3200_HZ, SMI330_ODR_6400_HZ },
.vals = (int[]){ 12, 25, 50, 100, 200, 400, 800, 1600, 3200, 6400 },
.len = 10,
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/delay.h`, `linux/interrupt.h`, `linux/irq.h`, `linux/module.h`, `linux/property.h`, `linux/regmap.h`, `linux/string.h`.
- Detected declarations: `struct smi330_attributes`, `struct smi330_cfg`, `struct smi330_data`, `enum smi330_accel_range`, `enum smi330_gyro_range`, `enum smi330_odr`, `enum smi330_avg_num`, `enum smi330_mode`, `enum smi330_bw`, `enum smi330_operation_mode`.
- Atlas domain: Driver Families / drivers/iio.
- Implementation status: integration implementation candidate.
- 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.