drivers/iio/adc/ti-ads1119.c
Source file repositories/reference/linux-study-clean/drivers/iio/adc/ti-ads1119.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/adc/ti-ads1119.c- Extension
.c- Size
- 20059 bytes
- Lines
- 826
- 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/bits.hlinux/bitfield.hlinux/completion.hlinux/delay.hlinux/dev_printk.hlinux/err.hlinux/gpio/consumer.hlinux/interrupt.hlinux/iopoll.hlinux/i2c.hlinux/kernel.hlinux/math.hlinux/module.hlinux/pm_runtime.hlinux/regulator/consumer.hlinux/units.hlinux/iio/iio.hlinux/iio/buffer.hlinux/iio/trigger.hlinux/iio/triggered_buffer.hlinux/iio/trigger_consumer.h
Detected Declarations
struct ads1119_channel_configstruct ads1119_statefunction ads1119_upd_cfg_regfunction ads1119_data_readyfunction ads1119_resetfunction ads1119_set_conv_modefunction ads1119_get_hw_gainfunction ads1119_get_hw_dataratefunction ads1119_configure_channelfunction ads1119_poll_data_readyfunction ads1119_read_datafunction ads1119_single_conversionfunction ads1119_validate_dataratefunction ads1119_read_availfunction ads1119_read_rawfunction ads1119_write_rawfunction ads1119_debugfs_reg_accessfunction ads1119_triggered_buffer_preenablefunction ads1119_triggered_buffer_postdisablefunction ads1119_irq_handlerfunction ads1119_trigger_handlerfunction ads1119_initfunction ads1119_map_analog_inputs_muxfunction ads1119_alloc_and_config_channelsfunction device_for_each_child_node_scopedfunction ads1119_powerdownfunction ads1119_probefunction ads1119_runtime_suspend
Annotated Snippet
struct ads1119_channel_config {
int gain;
int datarate;
int mux;
};
struct ads1119_state {
struct completion completion;
struct i2c_client *client;
struct gpio_desc *reset_gpio;
struct iio_trigger *trig;
struct ads1119_channel_config *channels_cfg;
unsigned int num_channels_cfg;
unsigned int cached_config;
int vref_uV;
};
static const char * const ads1119_power_supplies[] = {
"avdd", "dvdd"
};
static const int ads1119_available_datarates[] = {
20, 90, 330, 1000,
};
static const int ads1119_available_gains[] = {
1, 1,
1, 4,
};
static int ads1119_upd_cfg_reg(struct ads1119_state *st, unsigned int fields,
unsigned int val)
{
unsigned int config = st->cached_config;
int ret;
config &= ~fields;
config |= val;
ret = i2c_smbus_write_byte_data(st->client, ADS1119_CMD_WREG, config);
if (ret)
return ret;
st->cached_config = config;
return 0;
}
static bool ads1119_data_ready(struct ads1119_state *st)
{
int status;
status = i2c_smbus_read_byte_data(st->client, ADS1119_CMD_RREG_STATUS);
if (status < 0)
return false;
return FIELD_GET(ADS1119_STATUS_DRDY_FIELD, status);
}
static int ads1119_reset(struct ads1119_state *st)
{
st->cached_config = 0;
if (!st->reset_gpio)
return i2c_smbus_write_byte(st->client, ADS1119_CMD_RESET);
gpiod_set_value_cansleep(st->reset_gpio, 1);
udelay(1);
gpiod_set_value_cansleep(st->reset_gpio, 0);
udelay(1);
return 0;
}
static int ads1119_set_conv_mode(struct ads1119_state *st, bool continuous)
{
unsigned int mode;
if (continuous)
mode = ADS1119_CM_CONTINUOUS;
else
mode = ADS1119_CM_SINGLE;
return ads1119_upd_cfg_reg(st, ADS1119_CONFIG_CM_FIELD,
FIELD_PREP(ADS1119_CONFIG_CM_FIELD, mode));
}
static int ads1119_get_hw_gain(int gain)
{
if (gain == 4)
Annotation
- Immediate include surface: `linux/bits.h`, `linux/bitfield.h`, `linux/completion.h`, `linux/delay.h`, `linux/dev_printk.h`, `linux/err.h`, `linux/gpio/consumer.h`, `linux/interrupt.h`.
- Detected declarations: `struct ads1119_channel_config`, `struct ads1119_state`, `function ads1119_upd_cfg_reg`, `function ads1119_data_ready`, `function ads1119_reset`, `function ads1119_set_conv_mode`, `function ads1119_get_hw_gain`, `function ads1119_get_hw_datarate`, `function ads1119_configure_channel`, `function ads1119_poll_data_ready`.
- 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.