drivers/iio/imu/bmi323/bmi323_core.c
Source file repositories/reference/linux-study-clean/drivers/iio/imu/bmi323/bmi323_core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/imu/bmi323/bmi323_core.c- Extension
.c- Size
- 59072 bytes
- Lines
- 2304
- 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/cleanup.hlinux/device.hlinux/interrupt.hlinux/minmax.hlinux/module.hlinux/mutex.hlinux/property.hlinux/regmap.hlinux/regulator/consumer.hlinux/units.hlinux/unaligned.hlinux/iio/buffer.hlinux/iio/events.hlinux/iio/iio.hlinux/iio/sysfs.hlinux/iio/trigger.hlinux/iio/trigger_consumer.hlinux/iio/triggered_buffer.hbmi323.h
Detected Declarations
struct bmi323_hwstruct bmi323_regs_runtime_pmstruct bmi323_dataenum bmi323_sensor_typeenum bmi323_opr_modeenum bmi323_stateenum bmi323_irq_pinenum bmi323_3db_bwenum bmi323_scanfunction bmi323_get_mount_matrixfunction BITfunction bmi323_iio_to_sensorfunction bmi323_set_modefunction bmi323_write_ext_regfunction bmi323_read_ext_regfunction bmi323_update_ext_regfunction bmi323_get_error_statusfunction bmi323_feature_engine_eventsfunction bmi323_step_wtrmrk_enfunction bmi323_motion_config_regfunction bmi323_motion_event_enfunction bmi323_tap_event_enfunction in_accel_gesture_tap_wait_dur_showfunction scoped_guardfunction in_accel_gesture_tap_wait_dur_storefunction in_accel_gesture_tap_wait_timeout_showfunction scoped_guardfunction in_accel_gesture_tap_wait_timeout_storefunction bmi323_write_event_configfunction bmi323_read_event_configfunction bmi323_write_event_valuefunction bmi323_read_event_valuefunction __bmi323_fifo_flushfunction bmi323_set_watermarkfunction bmi323_fifo_disablefunction bmi323_buffer_predisablefunction bmi323_update_watermarkfunction bmi323_fifo_enablefunction bmi323_buffer_preenablefunction bmi323_buffer_postenablefunction hwfifo_watermark_showfunction hwfifo_enabled_showfunction bmi323_irq_thread_handlerfunction scoped_guardfunction bmi323_set_drdy_irqfunction bmi323_data_rdy_trigger_set_statefunction bmi323_trigger_handlerfunction for_each_set_bit
Annotated Snippet
struct bmi323_hw {
u8 data;
u8 config;
const int (*scale_table)[2];
int scale_table_len;
};
/*
* The accelerometer supports +-2G/4G/8G/16G ranges, and the resolution of
* each sample is 16 bits, signed.
* At +-8G the scale can calculated by
* ((8 + 8) * 9.80665 / (2^16 - 1)) * 10^6 = 2394.23819 scale in micro
*
*/
static const int bmi323_accel_scale[][2] = {
{ 0, 598 },
{ 0, 1197 },
{ 0, 2394 },
{ 0, 4788 },
};
static const int bmi323_gyro_scale[][2] = {
{ 0, 66 },
{ 0, 133 },
{ 0, 266 },
{ 0, 532 },
{ 0, 1065 },
};
static const int bmi323_accel_gyro_avrg[] = {0, 2, 4, 8, 16, 32, 64};
static const struct bmi323_hw bmi323_hw[2] = {
[BMI323_ACCEL] = {
.data = BMI323_ACCEL_X_REG,
.config = BMI323_ACC_CONF_REG,
.scale_table = bmi323_accel_scale,
.scale_table_len = ARRAY_SIZE(bmi323_accel_scale),
},
[BMI323_GYRO] = {
.data = BMI323_GYRO_X_REG,
.config = BMI323_GYRO_CONF_REG,
.scale_table = bmi323_gyro_scale,
.scale_table_len = ARRAY_SIZE(bmi323_gyro_scale),
},
};
static const unsigned int bmi323_reg_savestate[] = {
BMI323_INT_MAP1_REG,
BMI323_INT_MAP2_REG,
BMI323_IO_INT_CTR_REG,
BMI323_IO_INT_CONF_REG,
BMI323_ACC_CONF_REG,
BMI323_GYRO_CONF_REG,
BMI323_FEAT_IO0_REG,
BMI323_FIFO_WTRMRK_REG,
BMI323_FIFO_CONF_REG
};
static const unsigned int bmi323_ext_reg_savestate[] = {
BMI323_GEN_SET1_REG,
BMI323_TAP1_REG,
BMI323_TAP2_REG,
BMI323_TAP3_REG,
BMI323_FEAT_IO0_S_TAP_MSK,
BMI323_STEP_SC1_REG,
BMI323_ANYMO1_REG,
BMI323_NOMO1_REG,
BMI323_ANYMO1_REG + BMI323_MO2_OFFSET,
BMI323_NOMO1_REG + BMI323_MO2_OFFSET,
BMI323_ANYMO1_REG + BMI323_MO3_OFFSET,
BMI323_NOMO1_REG + BMI323_MO3_OFFSET
};
struct bmi323_regs_runtime_pm {
unsigned int reg_settings[ARRAY_SIZE(bmi323_reg_savestate)];
unsigned int ext_reg_settings[ARRAY_SIZE(bmi323_ext_reg_savestate)];
};
struct bmi323_data {
struct device *dev;
struct regmap *regmap;
struct iio_mount_matrix orientation;
enum bmi323_irq_pin irq_pin;
struct iio_trigger *trig;
enum bmi323_state state;
s64 fifo_tstamp, old_fifo_tstamp;
u32 odrns[BMI323_SENSORS_CNT];
u32 odrhz[BMI323_SENSORS_CNT];
unsigned int feature_events;
struct bmi323_regs_runtime_pm runtime_pm_status;
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/cleanup.h`, `linux/device.h`, `linux/interrupt.h`, `linux/minmax.h`, `linux/module.h`, `linux/mutex.h`, `linux/property.h`.
- Detected declarations: `struct bmi323_hw`, `struct bmi323_regs_runtime_pm`, `struct bmi323_data`, `enum bmi323_sensor_type`, `enum bmi323_opr_mode`, `enum bmi323_state`, `enum bmi323_irq_pin`, `enum bmi323_3db_bw`, `enum bmi323_scan`, `function bmi323_get_mount_matrix`.
- 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.