drivers/iio/imu/bmi160/bmi160_core.c
Source file repositories/reference/linux-study-clean/drivers/iio/imu/bmi160/bmi160_core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/imu/bmi160/bmi160_core.c- Extension
.c- Size
- 22613 bytes
- Lines
- 910
- 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/module.hlinux/regmap.hlinux/delay.hlinux/irq.hlinux/property.hlinux/regulator/consumer.hlinux/iio/iio.hlinux/iio/triggered_buffer.hlinux/iio/trigger_consumer.hlinux/iio/buffer.hlinux/iio/sysfs.hlinux/iio/trigger.hbmi160.h
Detected Declarations
struct bmi160_regsstruct bmi160_scalestruct bmi160_odrstruct bmi160_scale_itemstruct bmi160_odr_itemenum bmi160_scan_axisenum bmi160_sensor_typeenum bmi160_int_pinfunction Copyrightfunction bmi160_get_mount_matrixfunction bmi160_to_sensorfunction bmi160_set_modefunction bmi160_set_scalefunction bmi160_get_scalefunction bmi160_get_datafunction bmi160_set_odrfunction bmi160_get_odrfunction bmi160_trigger_handlerfunction iio_for_each_active_channelfunction bmi160_read_rawfunction bmi160_write_rawfunction bmi160_write_conf_regfunction bmi160_config_pinfunction bmi160_enable_irqfunction bmi160_get_irqfunction bmi160_config_device_irqfunction bmi160_setup_irqfunction bmi160_check_chip_idfunction bmi160_chip_initfunction bmi160_data_rdy_trigger_set_statefunction bmi160_probe_triggerfunction bmi160_chip_uninitfunction bmi160_core_probefunction bmi160_core_runtime_suspendfunction bmi160_core_runtime_resume
Annotated Snippet
struct bmi160_regs {
u8 data; /* LSB byte register for X-axis */
u8 config;
u8 config_odr_mask;
u8 config_bwp_mask;
u8 range;
u8 pmu_cmd_normal;
u8 pmu_cmd_suspend;
};
static const struct bmi160_regs bmi160_regs[] = {
[BMI160_ACCEL] = {
.data = BMI160_REG_DATA_ACCEL_XOUT_L,
.config = BMI160_REG_ACCEL_CONFIG,
.config_odr_mask = BMI160_ACCEL_CONFIG_ODR_MASK,
.config_bwp_mask = BMI160_ACCEL_CONFIG_BWP_MASK,
.range = BMI160_REG_ACCEL_RANGE,
.pmu_cmd_normal = BMI160_CMD_ACCEL_PM_NORMAL,
.pmu_cmd_suspend = BMI160_CMD_ACCEL_PM_SUSPEND,
},
[BMI160_GYRO] = {
.data = BMI160_REG_DATA_GYRO_XOUT_L,
.config = BMI160_REG_GYRO_CONFIG,
.config_odr_mask = BMI160_GYRO_CONFIG_ODR_MASK,
.config_bwp_mask = BMI160_GYRO_CONFIG_BWP_MASK,
.range = BMI160_REG_GYRO_RANGE,
.pmu_cmd_normal = BMI160_CMD_GYRO_PM_NORMAL,
.pmu_cmd_suspend = BMI160_CMD_GYRO_PM_SUSPEND,
},
};
static unsigned long bmi160_pmu_time[] = {
[BMI160_ACCEL] = BMI160_ACCEL_PMU_MIN_USLEEP,
[BMI160_GYRO] = BMI160_GYRO_PMU_MIN_USLEEP,
};
struct bmi160_scale {
u8 bits;
int uscale;
};
struct bmi160_odr {
u8 bits;
int odr;
int uodr;
};
static const struct bmi160_scale bmi160_accel_scale[] = {
{ BMI160_ACCEL_RANGE_2G, 598},
{ BMI160_ACCEL_RANGE_4G, 1197},
{ BMI160_ACCEL_RANGE_8G, 2394},
{ BMI160_ACCEL_RANGE_16G, 4788},
};
static const struct bmi160_scale bmi160_gyro_scale[] = {
{ BMI160_GYRO_RANGE_2000DPS, 1065},
{ BMI160_GYRO_RANGE_1000DPS, 532},
{ BMI160_GYRO_RANGE_500DPS, 266},
{ BMI160_GYRO_RANGE_250DPS, 133},
{ BMI160_GYRO_RANGE_125DPS, 66},
};
struct bmi160_scale_item {
const struct bmi160_scale *tbl;
int num;
};
static const struct bmi160_scale_item bmi160_scale_table[] = {
[BMI160_ACCEL] = {
.tbl = bmi160_accel_scale,
.num = ARRAY_SIZE(bmi160_accel_scale),
},
[BMI160_GYRO] = {
.tbl = bmi160_gyro_scale,
.num = ARRAY_SIZE(bmi160_gyro_scale),
},
};
static const struct bmi160_odr bmi160_accel_odr[] = {
{0x01, 0, 781250},
{0x02, 1, 562500},
{0x03, 3, 125000},
{0x04, 6, 250000},
{0x05, 12, 500000},
{0x06, 25, 0},
{0x07, 50, 0},
{0x08, 100, 0},
{0x09, 200, 0},
{0x0A, 400, 0},
{0x0B, 800, 0},
Annotation
- Immediate include surface: `linux/module.h`, `linux/regmap.h`, `linux/delay.h`, `linux/irq.h`, `linux/property.h`, `linux/regulator/consumer.h`, `linux/iio/iio.h`, `linux/iio/triggered_buffer.h`.
- Detected declarations: `struct bmi160_regs`, `struct bmi160_scale`, `struct bmi160_odr`, `struct bmi160_scale_item`, `struct bmi160_odr_item`, `enum bmi160_scan_axis`, `enum bmi160_sensor_type`, `enum bmi160_int_pin`, `function Copyright`, `function bmi160_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.