drivers/iio/accel/adxl380.c
Source file repositories/reference/linux-study-clean/drivers/iio/accel/adxl380.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/accel/adxl380.c- Extension
.c- Size
- 49468 bytes
- Lines
- 2006
- 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/interrupt.hlinux/irq.hlinux/module.hlinux/property.hlinux/regmap.hlinux/units.hlinux/unaligned.hlinux/iio/buffer.hlinux/iio/events.hlinux/iio/iio.hlinux/iio/kfifo_buf.hlinux/iio/sysfs.hlinux/regulator/consumer.hadxl380.h
Detected Declarations
struct adxl380_stateenum adxl380_channelsenum adxl380_axisenum adxl380_activity_typeenum adxl380_tap_typeenum adxl380_tap_time_typefunction adxl380_readable_noinc_regfunction adxl380_act_inact_enabledfunction adxl380_set_measure_enfunction adxl380_scale_act_inact_thresholdsfunction adxl380_write_act_inact_thresholdfunction adxl380_set_act_inact_thresholdfunction adxl380_set_tap_threshold_valuefunction _adxl380_write_tap_time_usfunction adxl380_write_tap_time_usfunction adxl380_write_tap_dur_usfunction adxl380_read_chnfunction adxl380_get_odrfunction adxl380_fill_lpf_tblfunction adxl380_fill_hpf_tblfunction adxl380_set_odrfunction adxl380_find_match_1d_tblfunction adxl380_find_match_2d_tblfunction adxl380_get_lpffunction adxl380_set_lpffunction adxl380_get_hpffunction adxl380_set_hpffunction _adxl380_set_act_inact_time_msfunction adxl380_set_act_inact_time_msfunction adxl380_set_rangefunction adxl380_write_act_inact_enfunction adxl380_read_act_inact_intfunction adxl380_write_act_inact_intfunction adxl380_act_inact_configfunction adxl380_write_tap_axisfunction adxl380_read_tap_intfunction adxl380_write_tap_intfunction adxl380_tap_configfunction adxl380_set_fifo_samplesfunction adxl380_get_statusfunction adxl380_get_fifo_entriesfunction adxl380_push_eventfunction adxl380_irq_handlerfunction adxl380_write_calibbias_valuefunction adxl380_read_calibbias_valuefunction hwfifo_watermark_min_showfunction hwfifo_watermark_max_showfunction adxl380_get_fifo_watermark
Annotated Snippet
struct adxl380_state {
struct regmap *regmap;
struct device *dev;
const struct adxl380_chip_info *chip_info;
/*
* Synchronize access to members of driver state, and ensure atomicity
* of consecutive regmap operations.
*/
struct mutex lock;
enum adxl380_axis tap_axis_en;
u8 range;
u8 odr;
u8 fifo_set_size;
u8 transf_buf[3];
u16 watermark;
u32 act_time_ms;
u32 act_threshold;
u32 inact_time_ms;
u32 inact_threshold;
u32 tap_latent_us;
u32 tap_window_us;
u32 tap_duration_us;
u32 tap_threshold;
int irq;
int int_map[2];
int lpf_tbl[4];
int hpf_tbl[7][2];
__be16 fifo_buf[ADXL380_FIFO_SAMPLES] __aligned(IIO_DMA_MINALIGN);
};
bool adxl380_readable_noinc_reg(struct device *dev, unsigned int reg)
{
return reg == ADXL380_FIFO_DATA;
}
EXPORT_SYMBOL_NS_GPL(adxl380_readable_noinc_reg, "IIO_ADXL380");
static int adxl380_act_inact_enabled(struct adxl380_state *st, bool *enabled)
{
unsigned int act_inact_ctl;
int ret;
if (!st->chip_info->has_low_power) {
*enabled = false;
return 0;
}
ret = regmap_read(st->regmap, ADXL380_ACT_INACT_CTL_REG, &act_inact_ctl);
if (ret)
return ret;
*enabled = FIELD_GET(ADXL380_ACT_EN_MSK, act_inact_ctl) ||
FIELD_GET(ADXL380_INACT_EN_MSK, act_inact_ctl);
return 0;
}
static int adxl380_set_measure_en(struct adxl380_state *st, bool en)
{
int ret;
u8 op_mode = ADXL380_OP_MODE_STANDBY;
if (en) {
bool act_inact_enabled;
ret = adxl380_act_inact_enabled(st, &act_inact_enabled);
if (ret)
return ret;
/*
* Activity/Inactivity detection available only in VLP/ULP
* mode and for devices that support low power modes.
*/
if (act_inact_enabled)
st->odr = ADXL380_ODR_VLP;
if (st->odr == ADXL380_ODR_VLP)
op_mode = ADXL380_OP_MODE_VLP;
else
op_mode = ADXL380_OP_MODE_HP;
}
return regmap_update_bits(st->regmap, ADXL380_OP_MODE_REG,
ADXL380_OP_MODE_MSK,
FIELD_PREP(ADXL380_OP_MODE_MSK, op_mode));
}
static void adxl380_scale_act_inact_thresholds(struct adxl380_state *st,
u8 old_range,
u8 new_range)
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/interrupt.h`, `linux/irq.h`, `linux/module.h`, `linux/property.h`, `linux/regmap.h`, `linux/units.h`, `linux/unaligned.h`.
- Detected declarations: `struct adxl380_state`, `enum adxl380_channels`, `enum adxl380_axis`, `enum adxl380_activity_type`, `enum adxl380_tap_type`, `enum adxl380_tap_time_type`, `function adxl380_readable_noinc_reg`, `function adxl380_act_inact_enabled`, `function adxl380_set_measure_en`, `function adxl380_scale_act_inact_thresholds`.
- 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.