drivers/iio/accel/bma220_core.c
Source file repositories/reference/linux-study-clean/drivers/iio/accel/bma220_core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/accel/bma220_core.c- Extension
.c- Size
- 15471 bytes
- Lines
- 586
- 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/bits.hlinux/bitfield.hlinux/cleanup.hlinux/device.hlinux/errno.hlinux/mod_devicetable.hlinux/module.hlinux/mutex.hlinux/pm.hlinux/regmap.hlinux/regulator/consumer.hlinux/types.hlinux/iio/buffer.hlinux/iio/iio.hlinux/iio/sysfs.hlinux/iio/trigger.hlinux/iio/trigger_consumer.hlinux/iio/triggered_buffer.hbma220.h
Detected Declarations
struct bma220_dataenum bma220_axisfunction Copyrightfunction bma220_is_writable_regfunction bma220_data_rdy_trigger_set_statefunction bma220_trigger_handlerfunction bma220_read_rawfunction bma220_find_match_2dtfunction bma220_find_matchfunction bma220_write_rawfunction bma220_read_availfunction bma220_reg_accessfunction bma220_resetfunction bma220_powerfunction bma220_initfunction bma220_deinitfunction bma220_irq_handlerfunction bma220_common_probefunction bma220_suspendfunction bma220_resume
Annotated Snippet
struct bma220_data {
struct regmap *regmap;
struct mutex lock;
u8 lpf_3dB_freq_idx;
u8 range_idx;
struct iio_trigger *trig;
struct {
s8 chans[3];
/* Ensure timestamp is naturally aligned. */
aligned_s64 timestamp;
} scan __aligned(IIO_DMA_MINALIGN);
};
static const struct iio_chan_spec bma220_channels[] = {
BMA220_ACCEL_CHANNEL(0, BMA220_REG_ACCEL_X, X),
BMA220_ACCEL_CHANNEL(1, BMA220_REG_ACCEL_Y, Y),
BMA220_ACCEL_CHANNEL(2, BMA220_REG_ACCEL_Z, Z),
IIO_CHAN_SOFT_TIMESTAMP(3),
};
/* Available cut-off frequencies of the low pass filter in Hz. */
static const int bma220_lpf_3dB_freq_Hz_table[] = {
[BMA220_COF_1000Hz] = 1000,
[BMA220_COF_500Hz] = 500,
[BMA220_COF_250Hz] = 250,
[BMA220_COF_125Hz] = 125,
[BMA220_COF_64Hz] = 64,
[BMA220_COF_32Hz] = 32,
};
static const unsigned long bma220_accel_scan_masks[] = {
BIT(AXIS_X) | BIT(AXIS_Y) | BIT(AXIS_Z),
0
};
static bool bma220_is_writable_reg(struct device *dev, unsigned int reg)
{
switch (reg) {
case BMA220_REG_CONF0:
case BMA220_REG_CONF1:
case BMA220_REG_CONF2:
case BMA220_REG_CONF3:
case BMA220_REG_CONF4:
case BMA220_REG_CONF5:
case BMA220_REG_IE0:
case BMA220_REG_IE1:
case BMA220_REG_IE2:
case BMA220_REG_FILTER:
case BMA220_REG_RANGE:
case BMA220_REG_WDT:
return true;
default:
return false;
}
}
const struct regmap_config bma220_spi_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
.read_flag_mask = BIT(7),
.max_register = BMA220_REG_SOFTRESET,
.cache_type = REGCACHE_NONE,
.writeable_reg = bma220_is_writable_reg,
};
EXPORT_SYMBOL_NS_GPL(bma220_spi_regmap_config, "IIO_BOSCH_BMA220");
/*
* Based on the datasheet the memory map differs between the SPI and the I2C
* implementations. I2C register addresses are simply shifted to the left
* by 1 bit yet the register size remains unchanged.
* This driver employs the SPI memory map to correlate register names to
* addresses regardless of the bus type.
*/
const struct regmap_config bma220_i2c_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
.reg_shift = -1,
.max_register = BMA220_REG_SOFTRESET,
.cache_type = REGCACHE_NONE,
.writeable_reg = bma220_is_writable_reg,
};
EXPORT_SYMBOL_NS_GPL(bma220_i2c_regmap_config, "IIO_BOSCH_BMA220");
static int bma220_data_rdy_trigger_set_state(struct iio_trigger *trig,
bool state)
{
struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig);
struct bma220_data *data = iio_priv(indio_dev);
Annotation
- Immediate include surface: `linux/bits.h`, `linux/bitfield.h`, `linux/cleanup.h`, `linux/device.h`, `linux/errno.h`, `linux/mod_devicetable.h`, `linux/module.h`, `linux/mutex.h`.
- Detected declarations: `struct bma220_data`, `enum bma220_axis`, `function Copyright`, `function bma220_is_writable_reg`, `function bma220_data_rdy_trigger_set_state`, `function bma220_trigger_handler`, `function bma220_read_raw`, `function bma220_find_match_2dt`, `function bma220_find_match`, `function bma220_write_raw`.
- 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.