drivers/iio/adc/ti-ads131e08.c
Source file repositories/reference/linux-study-clean/drivers/iio/adc/ti-ads131e08.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/adc/ti-ads131e08.c- Extension
.c- Size
- 23069 bytes
- Lines
- 940
- 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.
- 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/clk.hlinux/delay.hlinux/module.hlinux/iio/buffer.hlinux/iio/iio.hlinux/iio/sysfs.hlinux/iio/trigger.hlinux/iio/trigger_consumer.hlinux/iio/triggered_buffer.hlinux/regulator/consumer.hlinux/spi/spi.hlinux/unaligned.h
Detected Declarations
struct ads131e08_infostruct ads131e08_channel_configstruct ads131e08_statestruct ads131e08_data_rate_descstruct ads131e08_pga_gain_descenum ads131e08_idsfunction ads131e08_exec_cmdfunction ads131e08_read_regfunction ads131e08_write_regfunction ads131e08_read_datafunction ads131e08_set_data_ratefunction ads131e08_pga_gain_to_field_valuefunction ads131e08_set_pga_gainfunction ads131e08_validate_channel_muxfunction ads131e08_set_channel_muxfunction ads131e08_power_down_channelfunction ads131e08_config_reference_voltagefunction ads131e08_initial_configfunction ads131e08_pool_datafunction ads131e08_read_directfunction ads131e08_read_rawfunction ads131e08_write_rawfunction ads131e08_debugfs_reg_accessfunction ads131e08_set_trigger_statefunction ads131e08_trigger_handlerfunction iio_for_each_active_channelfunction ads131e08_interruptfunction ads131e08_alloc_channelsfunction ads131e08_regulator_disablefunction ads131e08_probe
Annotated Snippet
struct ads131e08_info {
unsigned int max_channels;
const char *name;
};
struct ads131e08_channel_config {
unsigned int pga_gain;
unsigned int mux;
};
struct ads131e08_state {
const struct ads131e08_info *info;
struct spi_device *spi;
struct iio_trigger *trig;
struct clk *adc_clk;
struct regulator *vref_reg;
struct ads131e08_channel_config *channel_config;
unsigned int data_rate;
unsigned int vref_mv;
unsigned int sdecode_delay_us;
unsigned int reset_delay_us;
unsigned int readback_len;
struct completion completion;
struct {
u8 data[ADS131E08_NUM_DATA_BYTES_MAX];
aligned_s64 ts;
} tmp_buf;
u8 tx_buf[3] __aligned(IIO_DMA_MINALIGN);
/*
* Add extra one padding byte to be able to access the last channel
* value using u32 pointer
*/
u8 rx_buf[ADS131E08_NUM_STATUS_BYTES +
ADS131E08_NUM_DATA_BYTES_MAX + 1];
};
static const struct ads131e08_info ads131e08_info_tbl[] = {
[ads131e04] = {
.max_channels = 4,
.name = "ads131e04",
},
[ads131e06] = {
.max_channels = 6,
.name = "ads131e06",
},
[ads131e08] = {
.max_channels = 8,
.name = "ads131e08",
},
};
struct ads131e08_data_rate_desc {
unsigned int rate; /* data rate in kSPS */
u8 reg; /* reg value */
};
static const struct ads131e08_data_rate_desc ads131e08_data_rate_tbl[] = {
{ .rate = 64, .reg = 0x00 },
{ .rate = 32, .reg = 0x01 },
{ .rate = 16, .reg = 0x02 },
{ .rate = 8, .reg = 0x03 },
{ .rate = 4, .reg = 0x04 },
{ .rate = 2, .reg = 0x05 },
{ .rate = 1, .reg = 0x06 },
};
struct ads131e08_pga_gain_desc {
unsigned int gain; /* PGA gain value */
u8 reg; /* field value */
};
static const struct ads131e08_pga_gain_desc ads131e08_pga_gain_tbl[] = {
{ .gain = 1, .reg = 0x01 },
{ .gain = 2, .reg = 0x02 },
{ .gain = 4, .reg = 0x04 },
{ .gain = 8, .reg = 0x05 },
{ .gain = 12, .reg = 0x06 },
};
static const u8 ads131e08_valid_channel_mux_values[] = { 0, 1, 3, 4 };
static int ads131e08_exec_cmd(struct ads131e08_state *st, u8 cmd)
{
int ret;
ret = spi_write_then_read(st->spi, &cmd, 1, NULL, 0);
if (ret)
dev_err(&st->spi->dev, "Exec cmd(%02x) failed\n", cmd);
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/clk.h`, `linux/delay.h`, `linux/module.h`, `linux/iio/buffer.h`, `linux/iio/iio.h`, `linux/iio/sysfs.h`, `linux/iio/trigger.h`.
- Detected declarations: `struct ads131e08_info`, `struct ads131e08_channel_config`, `struct ads131e08_state`, `struct ads131e08_data_rate_desc`, `struct ads131e08_pga_gain_desc`, `enum ads131e08_ids`, `function ads131e08_exec_cmd`, `function ads131e08_read_reg`, `function ads131e08_write_reg`, `function ads131e08_read_data`.
- Atlas domain: Driver Families / drivers/iio.
- Implementation status: source 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.