drivers/iio/imu/inv_icm45600/inv_icm45600_core.c
Source file repositories/reference/linux-study-clean/drivers/iio/imu/inv_icm45600/inv_icm45600_core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/imu/inv_icm45600/inv_icm45600_core.c- Extension
.c- Size
- 28031 bytes
- Lines
- 995
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitfield.hlinux/delay.hlinux/device.hlinux/err.hlinux/interrupt.hlinux/irq.hlinux/limits.hlinux/minmax.hlinux/module.hlinux/mutex.hlinux/pm_runtime.hlinux/property.hlinux/regmap.hlinux/regulator/consumer.hlinux/time.hlinux/types.hasm/byteorder.hlinux/iio/iio.hinv_icm45600_buffer.hinv_icm45600.h
Detected Declarations
function inv_icm45600_ireg_readfunction inv_icm45600_ireg_writefunction inv_icm45600_readfunction inv_icm45600_writefunction inv_icm45600_get_mount_matrixfunction inv_icm45600_odr_to_periodfunction inv_icm45600_set_pwr_mgmt0function inv_icm45600_set_default_conffunction inv_icm45600_set_accel_conffunction inv_icm45600_set_gyro_conffunction inv_icm45600_debugfs_regfunction inv_icm45600_set_conffunction inv_icm45600_setupfunction inv_icm45600_irq_timestampfunction inv_icm45600_irq_handlerfunction inv_icm45600_irq_initfunction inv_icm45600_timestamp_setupfunction inv_icm45600_enable_regulator_vddiofunction inv_icm45600_disable_vddio_regfunction inv_icm45600_core_probefunction inv_icm45600_suspendfunction scoped_guardfunction inv_icm45600_resumefunction scoped_guardfunction inv_icm45600_runtime_suspendfunction inv_icm45600_runtime_resumefunction _inv_icm45600_temp_readfunction inv_icm45600_temp_readfunction inv_icm45600_temp_read_raw
Annotated Snippet
if (conf->odr <= INV_ICM45600_ODR_800HZ_LN) {
conf->mode = INV_ICM45600_SENSOR_MODE_LOW_NOISE;
} else {
conf->mode = INV_ICM45600_SENSOR_MODE_LOW_POWER;
/* sanitize averaging value depending on ODR for low-power mode */
/* maximum 1x @400Hz */
if (conf->odr == INV_ICM45600_ODR_400HZ)
conf->filter = INV_ICM45600_ACCEL_LP_AVG_SEL_1X;
else
conf->filter = INV_ICM45600_ACCEL_LP_AVG_SEL_4X;
}
}
/* Set accel fullscale & odr. */
if (conf->fs != oldconf->fs || conf->odr != oldconf->odr) {
val = FIELD_PREP(INV_ICM45600_ACCEL_CONFIG0_FS_MASK, conf->fs) |
FIELD_PREP(INV_ICM45600_ACCEL_CONFIG0_ODR_MASK, conf->odr);
ret = regmap_write(st->map, INV_ICM45600_REG_ACCEL_CONFIG0, val);
if (ret)
return ret;
oldconf->fs = conf->fs;
oldconf->odr = conf->odr;
}
/* Set accel low-power average filter. */
if (conf->filter != oldconf->filter) {
ret = regmap_write(st->map, INV_ICM45600_IPREG_SYS2_REG_129,
conf->filter);
if (ret)
return ret;
oldconf->filter = conf->filter;
}
/* Update the sensor accel mode. */
return inv_icm45600_set_pwr_mgmt0(st, st->conf.gyro.mode, conf->mode,
sleep_ms);
}
int inv_icm45600_set_gyro_conf(struct inv_icm45600_state *st,
struct inv_icm45600_sensor_conf *conf,
unsigned int *sleep_ms)
{
struct inv_icm45600_sensor_conf *oldconf = &st->conf.gyro;
unsigned int val;
int ret;
inv_icm45600_set_default_conf(conf, oldconf);
/* Force the power mode against ODR when sensor is on. */
if (conf->mode > INV_ICM45600_SENSOR_MODE_STANDBY) {
if (conf->odr >= INV_ICM45600_ODR_6_25HZ_LP) {
conf->mode = INV_ICM45600_SENSOR_MODE_LOW_POWER;
conf->filter = INV_ICM45600_GYRO_LP_AVG_SEL_8X;
} else {
conf->mode = INV_ICM45600_SENSOR_MODE_LOW_NOISE;
}
}
/* Set gyro fullscale & odr. */
if (conf->fs != oldconf->fs || conf->odr != oldconf->odr) {
val = FIELD_PREP(INV_ICM45600_GYRO_CONFIG0_FS_MASK, conf->fs) |
FIELD_PREP(INV_ICM45600_GYRO_CONFIG0_ODR_MASK, conf->odr);
ret = regmap_write(st->map, INV_ICM45600_REG_GYRO_CONFIG0, val);
if (ret)
return ret;
oldconf->fs = conf->fs;
oldconf->odr = conf->odr;
}
/* Set gyro low-power average filter. */
if (conf->filter != oldconf->filter) {
val = FIELD_PREP(INV_ICM45600_IPREG_SYS1_170_GYRO_LP_AVG_MASK, conf->filter);
ret = regmap_update_bits(st->map, INV_ICM45600_IPREG_SYS1_REG_170,
INV_ICM45600_IPREG_SYS1_170_GYRO_LP_AVG_MASK, val);
if (ret)
return ret;
oldconf->filter = conf->filter;
}
/* Update the sensor gyro mode. */
return inv_icm45600_set_pwr_mgmt0(st, conf->mode, st->conf.accel.mode,
sleep_ms);
}
int inv_icm45600_debugfs_reg(struct iio_dev *indio_dev, unsigned int reg,
unsigned int writeval, unsigned int *readval)
{
struct inv_icm45600_state *st = iio_device_get_drvdata(indio_dev);
guard(mutex)(&st->lock);
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/delay.h`, `linux/device.h`, `linux/err.h`, `linux/interrupt.h`, `linux/irq.h`, `linux/limits.h`, `linux/minmax.h`.
- Detected declarations: `function inv_icm45600_ireg_read`, `function inv_icm45600_ireg_write`, `function inv_icm45600_read`, `function inv_icm45600_write`, `function inv_icm45600_get_mount_matrix`, `function inv_icm45600_odr_to_period`, `function inv_icm45600_set_pwr_mgmt0`, `function inv_icm45600_set_default_conf`, `function inv_icm45600_set_accel_conf`, `function inv_icm45600_set_gyro_conf`.
- 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.