drivers/iio/adc/ti-ads1015.c
Source file repositories/reference/linux-study-clean/drivers/iio/adc/ti-ads1015.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/adc/ti-ads1015.c- Extension
.c- Size
- 31502 bytes
- Lines
- 1162
- Domain
- Driver Families
- Bucket
- drivers/iio
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/cleanup.hlinux/init.hlinux/irq.hlinux/i2c.hlinux/property.hlinux/regmap.hlinux/pm_runtime.hlinux/mutex.hlinux/delay.hlinux/iio/iio.hlinux/iio/types.hlinux/iio/sysfs.hlinux/iio/events.hlinux/iio/buffer.hlinux/iio/triggered_buffer.hlinux/iio/trigger_consumer.h
Detected Declarations
struct ads1015_chip_datastruct ads1015_channel_datastruct ads1015_thresh_datastruct ads1015_dataenum ads1015_channelsfunction BITfunction ads1015_event_channel_enabledfunction ads1015_event_channel_enablefunction ads1015_event_channel_disablefunction ads1015_set_power_statefunction ads1015_set_power_statefunction ads1015_get_adc_resultfunction ads1015_trigger_handlerfunction ads1015_set_scalefunction ads1015_set_data_ratefunction ads1015_read_availfunction __ads1015_read_info_rawfunction ads1015_read_rawfunction ads1015_write_rawfunction ads1015_read_eventfunction ads1015_write_eventfunction ads1015_read_event_configfunction ads1015_enable_event_configfunction ads1015_disable_event_configfunction ads1015_write_event_configfunction ads1015_event_handlerfunction ads1015_buffer_preenablefunction ads1015_buffer_postdisablefunction ads1015_client_get_channels_configfunction device_for_each_child_node_scopedfunction ads1015_get_channels_configfunction ads1015_set_conv_modefunction ads1015_probefunction ads1015_removefunction ads1015_runtime_suspendfunction ads1015_runtime_resume
Annotated Snippet
struct ads1015_chip_data {
struct iio_chan_spec const *channels;
int num_channels;
const struct iio_info *info;
const int *data_rate;
const int data_rate_len;
const int *scale;
const int scale_len;
bool has_comparator;
};
enum ads1015_channels {
ADS1015_AIN0_AIN1 = 0,
ADS1015_AIN0_AIN3,
ADS1015_AIN1_AIN3,
ADS1015_AIN2_AIN3,
ADS1015_AIN0,
ADS1015_AIN1,
ADS1015_AIN2,
ADS1015_AIN3,
ADS1015_TIMESTAMP,
};
static const int ads1015_data_rate[] = {
128, 250, 490, 920, 1600, 2400, 3300, 3300
};
static const int ads1115_data_rate[] = {
8, 16, 32, 64, 128, 250, 475, 860
};
/*
* Translation from PGA bits to full-scale positive and negative input voltage
* range in mV
*/
static const int ads1015_fullscale_range[] = {
6144, 4096, 2048, 1024, 512, 256, 256, 256
};
static const int ads1015_scale[] = { /* 12bit ADC */
256, 11,
512, 11,
1024, 11,
2048, 11,
4096, 11,
6144, 11
};
static const int ads1115_scale[] = { /* 16bit ADC */
256, 15,
512, 15,
1024, 15,
2048, 15,
4096, 15,
6144, 15
};
/*
* Translation from COMP_QUE field value to the number of successive readings
* exceed the threshold values before an interrupt is generated
*/
static const int ads1015_comp_queue[] = { 1, 2, 4 };
static const struct iio_event_spec ads1015_events[] = {
{
.type = IIO_EV_TYPE_THRESH,
.dir = IIO_EV_DIR_RISING,
.mask_separate = BIT(IIO_EV_INFO_VALUE) |
BIT(IIO_EV_INFO_ENABLE),
}, {
.type = IIO_EV_TYPE_THRESH,
.dir = IIO_EV_DIR_FALLING,
.mask_separate = BIT(IIO_EV_INFO_VALUE),
}, {
.type = IIO_EV_TYPE_THRESH,
.dir = IIO_EV_DIR_EITHER,
.mask_separate = BIT(IIO_EV_INFO_ENABLE) |
BIT(IIO_EV_INFO_PERIOD),
},
};
/*
* Compile-time check whether _fitbits can accommodate up to _testbits
* bits. Returns _fitbits on success, fails to compile otherwise.
*
* The test works such that it multiplies constant _fitbits by constant
* double-negation of size of a non-empty structure, i.e. it multiplies
* constant _fitbits by constant 1 in each successful compilation case.
* The non-empty structure may contain C11 _Static_assert(), make use of
* this and place the kernel variant of static assert in there, so that
Annotation
- Immediate include surface: `linux/module.h`, `linux/cleanup.h`, `linux/init.h`, `linux/irq.h`, `linux/i2c.h`, `linux/property.h`, `linux/regmap.h`, `linux/pm_runtime.h`.
- Detected declarations: `struct ads1015_chip_data`, `struct ads1015_channel_data`, `struct ads1015_thresh_data`, `struct ads1015_data`, `enum ads1015_channels`, `function BIT`, `function ads1015_event_channel_enabled`, `function ads1015_event_channel_enable`, `function ads1015_event_channel_disable`, `function ads1015_set_power_state`.
- Atlas domain: Driver Families / drivers/iio.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- 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.