drivers/iio/pressure/zpa2326.c
Source file repositories/reference/linux-study-clean/drivers/iio/pressure/zpa2326.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/pressure/zpa2326.c- Extension
.c- Size
- 48527 bytes
- Lines
- 1712
- 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/kernel.hlinux/delay.hlinux/interrupt.hlinux/regulator/consumer.hlinux/pm_runtime.hlinux/regmap.hlinux/iio/iio.hlinux/iio/sysfs.hlinux/iio/buffer.hlinux/iio/trigger.hlinux/iio/trigger_consumer.hlinux/iio/triggered_buffer.hlinux/unaligned.hzpa2326.h
Detected Declarations
struct zpa2326_frequencystruct zpa2326_privatefunction zpa2326_isreg_writeablefunction zpa2326_isreg_readablefunction zpa2326_isreg_preciousfunction zpa2326_enable_devicefunction zpa2326_sleepfunction zpa2326_reset_devicefunction zpa2326_start_oneshotfunction zpa2326_power_onfunction zpa2326_power_offfunction zpa2326_config_oneshotfunction zpa2326_clear_fifofunction zpa2326_dequeue_pressurefunction zpa2326_fill_sample_bufferfunction zpa2326_runtime_suspendfunction zpa2326_runtime_resumefunction zpa2326_resumefunction zpa2326_suspendfunction zpa2326_init_runtimefunction zpa2326_fini_runtimefunction zpa2326_resumefunction zpa2326_suspendfunction zpa2326_handle_irqfunction zpa2326_handle_threaded_irqfunction zpa2326_wait_oneshot_completionfunction zpa2326_init_managed_irqfunction zpa2326_poll_oneshot_completionfunction zpa2326_fetch_raw_samplefunction zpa2326_sample_oneshotfunction zpa2326_trigger_handlerfunction zpa2326_preenable_bufferfunction zpa2326_postenable_bufferfunction zpa2326_postdisable_bufferfunction zpa2326_set_trigger_statefunction zpa2326_init_managed_triggerfunction zpa2326_get_frequencyfunction zpa2326_set_frequencyfunction zpa2326_read_rawfunction zpa2326_write_rawfunction zpa2326_probefunction zpa2326_remove
Annotated Snippet
struct zpa2326_frequency {
int hz;
u16 odr;
};
/*
* Keep these in strict ascending order: last array entry is expected to
* correspond to the highest sampling frequency.
*/
static const struct zpa2326_frequency zpa2326_sampling_frequencies[] = {
{ .hz = 1, .odr = 1 << ZPA2326_CTRL_REG3_ODR_SHIFT },
{ .hz = 5, .odr = 5 << ZPA2326_CTRL_REG3_ODR_SHIFT },
{ .hz = 11, .odr = 6 << ZPA2326_CTRL_REG3_ODR_SHIFT },
{ .hz = 23, .odr = 7 << ZPA2326_CTRL_REG3_ODR_SHIFT },
};
/* Return the highest hardware sampling frequency available. */
static const struct zpa2326_frequency *zpa2326_highest_frequency(void)
{
return &zpa2326_sampling_frequencies[
ARRAY_SIZE(zpa2326_sampling_frequencies) - 1];
}
/**
* struct zpa2326_private - Per-device internal private state
* @timestamp: Buffered samples ready datum.
* @regmap: Underlying I2C / SPI bus adapter used to abstract slave register
* accesses.
* @result: Allows sampling logic to get completion status of operations
* that interrupt handlers perform asynchronously.
* @data_ready: Interrupt handler uses this to wake user context up at sampling
* operation completion.
* @trigger: Optional hardware / interrupt driven trigger used to notify
* external devices a new sample is ready.
* @waken: Flag indicating whether or not device has just been powered on.
* @irq: Optional interrupt line: negative or zero if not declared into
* DT, in which case sampling logic keeps polling status register
* to detect completion.
* @frequency: Current hardware sampling frequency.
* @vref: Power / voltage reference.
* @vdd: Power supply.
*/
struct zpa2326_private {
s64 timestamp;
struct regmap *regmap;
int result;
struct completion data_ready;
struct iio_trigger *trigger;
bool waken;
int irq;
const struct zpa2326_frequency *frequency;
struct regulator *vref;
struct regulator *vdd;
};
#define zpa2326_err(idev, fmt, ...) \
dev_err(idev->dev.parent, fmt "\n", ##__VA_ARGS__)
#define zpa2326_warn(idev, fmt, ...) \
dev_warn(idev->dev.parent, fmt "\n", ##__VA_ARGS__)
#define zpa2326_dbg(idev, fmt, ...) \
dev_dbg(idev->dev.parent, fmt "\n", ##__VA_ARGS__)
bool zpa2326_isreg_writeable(struct device *dev, unsigned int reg)
{
switch (reg) {
case ZPA2326_REF_P_XL_REG:
case ZPA2326_REF_P_L_REG:
case ZPA2326_REF_P_H_REG:
case ZPA2326_RES_CONF_REG:
case ZPA2326_CTRL_REG0_REG:
case ZPA2326_CTRL_REG1_REG:
case ZPA2326_CTRL_REG2_REG:
case ZPA2326_CTRL_REG3_REG:
case ZPA2326_THS_P_LOW_REG:
case ZPA2326_THS_P_HIGH_REG:
return true;
default:
return false;
}
}
EXPORT_SYMBOL_NS_GPL(zpa2326_isreg_writeable, "IIO_ZPA2326");
bool zpa2326_isreg_readable(struct device *dev, unsigned int reg)
{
switch (reg) {
case ZPA2326_REF_P_XL_REG:
case ZPA2326_REF_P_L_REG:
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/delay.h`, `linux/interrupt.h`, `linux/regulator/consumer.h`, `linux/pm_runtime.h`, `linux/regmap.h`, `linux/iio/iio.h`.
- Detected declarations: `struct zpa2326_frequency`, `struct zpa2326_private`, `function zpa2326_isreg_writeable`, `function zpa2326_isreg_readable`, `function zpa2326_isreg_precious`, `function zpa2326_enable_device`, `function zpa2326_sleep`, `function zpa2326_reset_device`, `function zpa2326_start_oneshot`, `function zpa2326_power_on`.
- 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.