drivers/iio/accel/bmi088-accel-core.c
Source file repositories/reference/linux-study-clean/drivers/iio/accel/bmi088-accel-core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/accel/bmi088-accel-core.c- Extension
.c- Size
- 15907 bytes
- Lines
- 628
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitfield.hlinux/delay.hlinux/iio/iio.hlinux/iio/sysfs.hlinux/interrupt.hlinux/module.hlinux/pm.hlinux/pm_runtime.hlinux/regmap.hlinux/slab.hlinux/unaligned.hbmi088-accel.h
Detected Declarations
struct bmi088_accel_chip_infostruct bmi088_accel_dataenum bmi088_accel_axisenum bmi088_osr_modesenum bmi088_odr_modesfunction bmi088_accel_power_upfunction bmi088_accel_power_downfunction bmi088_accel_get_sample_freqfunction bmi088_accel_set_sample_freqfunction bmi088_accel_set_scalefunction bmi088_accel_get_tempfunction bmi088_accel_get_axisfunction bmi088_accel_read_rawfunction bmi088_accel_read_availfunction bmi088_accel_write_rawfunction bmi088_accel_chip_initfunction bmi088_accel_core_probefunction bmi088_accel_core_removefunction bmi088_accel_runtime_suspendfunction bmi088_accel_runtime_resume
Annotated Snippet
struct bmi088_accel_chip_info {
const char *name;
u8 chip_id;
const struct iio_chan_spec *channels;
int num_channels;
const int scale_table[4][2];
};
struct bmi088_accel_data {
struct regmap *regmap;
const struct bmi088_accel_chip_info *chip_info;
u8 buffer[2] __aligned(IIO_DMA_MINALIGN); /* shared DMA safe buffer */
};
static const struct regmap_range bmi088_volatile_ranges[] = {
/* All registers below 0x40 are volatile, except the CHIP ID. */
regmap_reg_range(BMI088_ACCEL_REG_ERROR, 0x3f),
/* Mark the RESET as volatile too, it is self-clearing */
regmap_reg_range(BMI088_ACCEL_REG_RESET, BMI088_ACCEL_REG_RESET),
};
static const struct regmap_access_table bmi088_volatile_table = {
.yes_ranges = bmi088_volatile_ranges,
.n_yes_ranges = ARRAY_SIZE(bmi088_volatile_ranges),
};
const struct regmap_config bmi088_regmap_conf = {
.reg_bits = 8,
.val_bits = 8,
.max_register = 0x7E,
.volatile_table = &bmi088_volatile_table,
.cache_type = REGCACHE_MAPLE,
};
EXPORT_SYMBOL_NS_GPL(bmi088_regmap_conf, "IIO_BMI088");
static int bmi088_accel_power_up(struct bmi088_accel_data *data)
{
int ret;
/* Enable accelerometer and temperature sensor */
ret = regmap_write(data->regmap, BMI088_ACCEL_REG_PWR_CTRL, 0x4);
if (ret)
return ret;
/* Datasheet recommends to wait at least 5ms before communication */
usleep_range(5000, 6000);
/* Disable suspend mode */
ret = regmap_write(data->regmap, BMI088_ACCEL_REG_PWR_CONF, 0x0);
if (ret)
return ret;
/* Recommended at least 1ms before further communication */
usleep_range(1000, 1200);
return 0;
}
static int bmi088_accel_power_down(struct bmi088_accel_data *data)
{
int ret;
/* Enable suspend mode */
ret = regmap_write(data->regmap, BMI088_ACCEL_REG_PWR_CONF, 0x3);
if (ret)
return ret;
/* Recommended at least 1ms before further communication */
usleep_range(1000, 1200);
/* Disable accelerometer and temperature sensor */
ret = regmap_write(data->regmap, BMI088_ACCEL_REG_PWR_CTRL, 0x0);
if (ret)
return ret;
/* Datasheet recommends to wait at least 5ms before communication */
usleep_range(5000, 6000);
return 0;
}
static int bmi088_accel_get_sample_freq(struct bmi088_accel_data *data,
int *val, int *val2)
{
unsigned int value;
int ret;
ret = regmap_read(data->regmap, BMI088_ACCEL_REG_ACC_CONF,
&value);
if (ret)
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/delay.h`, `linux/iio/iio.h`, `linux/iio/sysfs.h`, `linux/interrupt.h`, `linux/module.h`, `linux/pm.h`, `linux/pm_runtime.h`.
- Detected declarations: `struct bmi088_accel_chip_info`, `struct bmi088_accel_data`, `enum bmi088_accel_axis`, `enum bmi088_osr_modes`, `enum bmi088_odr_modes`, `function bmi088_accel_power_up`, `function bmi088_accel_power_down`, `function bmi088_accel_get_sample_freq`, `function bmi088_accel_set_sample_freq`, `function bmi088_accel_set_scale`.
- Atlas domain: Driver Families / drivers/iio.
- Implementation status: integration implementation candidate.
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.