drivers/iio/adc/ti-tsc2046.c
Source file repositories/reference/linux-study-clean/drivers/iio/adc/ti-tsc2046.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/adc/ti-tsc2046.c- Extension
.c- Size
- 23006 bytes
- Lines
- 856
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitfield.hlinux/cleanup.hlinux/delay.hlinux/module.hlinux/regulator/consumer.hlinux/spi/spi.hlinux/units.hlinux/unaligned.hlinux/iio/buffer.hlinux/iio/trigger_consumer.hlinux/iio/triggered_buffer.hlinux/iio/trigger.h
Detected Declarations
struct tsc2046_adc_atomstruct tsc2046_adc_group_layoutstruct tsc2046_adc_dcfgstruct tsc2046_adc_ch_cfgstruct tsc2046_adc_privenum tsc2046_statefunction tsc2046_adc_time_to_countfunction tsc2046_adc_get_cmdfunction tsc2046_adc_get_valuefunction tsc2046_adc_read_onefunction tsc2046_adc_group_set_layoutfunction tsc2046_adc_group_set_cmdfunction tsc2046_adc_get_valfunction tsc2046_adc_scanfunction tsc2046_adc_trigger_handlerfunction tsc2046_adc_read_rawfunction tsc2046_adc_update_scan_modefunction tsc2046_adc_timerfunction tsc2046_adc_irqfunction tsc2046_adc_reenable_triggerfunction tsc2046_adc_set_trigger_statefunction tsc2046_adc_setup_spi_msgfunction tsc2046_adc_parse_fwnodefunction device_for_each_child_nodefunction tsc2046_adc_probe
Annotated Snippet
struct tsc2046_adc_atom {
/*
* Command transmitted to the controller. This field is empty on the RX
* buffer.
*/
u8 cmd;
/*
* Data received from the controller. This field is empty for the TX
* buffer
*/
__be16 data;
} __packed;
/* Layout of atomic buffers within big buffer */
struct tsc2046_adc_group_layout {
/* Group offset within the SPI RX buffer */
unsigned int offset;
/*
* Amount of tsc2046_adc_atom structs within the same command gathered
* within same group.
*/
unsigned int count;
/*
* Settling samples (tsc2046_adc_atom structs) which should be skipped
* before good samples will start.
*/
unsigned int skip;
};
struct tsc2046_adc_dcfg {
const struct iio_chan_spec *channels;
unsigned int num_channels;
};
struct tsc2046_adc_ch_cfg {
unsigned int settling_time_us;
unsigned int oversampling_ratio;
};
enum tsc2046_state {
TSC2046_STATE_SHUTDOWN,
TSC2046_STATE_STANDBY,
TSC2046_STATE_POLL,
TSC2046_STATE_POLL_IRQ_DISABLE,
TSC2046_STATE_ENABLE_IRQ,
};
struct tsc2046_adc_priv {
struct spi_device *spi;
const struct tsc2046_adc_dcfg *dcfg;
bool internal_vref;
struct iio_trigger *trig;
struct hrtimer trig_timer;
enum tsc2046_state state;
int poll_cnt;
spinlock_t state_lock;
struct spi_transfer xfer;
struct spi_message msg;
struct {
/* Scan data for each channel */
u16 data[TI_TSC2046_MAX_CHAN];
/* Timestamp */
aligned_s64 ts;
} scan_buf;
/*
* Lock to protect the layout and the SPI transfer buffer.
* tsc2046_adc_group_layout can be changed within update_scan_mode(),
* in this case the l[] and tx/rx buffer will be out of sync to each
* other.
*/
struct mutex slock;
struct tsc2046_adc_group_layout l[TI_TSC2046_MAX_CHAN];
struct tsc2046_adc_atom *rx;
struct tsc2046_adc_atom *tx;
unsigned int count;
unsigned int groups;
u32 effective_speed_hz;
u32 scan_interval_us;
u32 time_per_scan_us;
u32 time_per_bit_ns;
unsigned int vref_mv;
struct tsc2046_adc_ch_cfg ch_cfg[TI_TSC2046_MAX_CHAN];
};
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/cleanup.h`, `linux/delay.h`, `linux/module.h`, `linux/regulator/consumer.h`, `linux/spi/spi.h`, `linux/units.h`, `linux/unaligned.h`.
- Detected declarations: `struct tsc2046_adc_atom`, `struct tsc2046_adc_group_layout`, `struct tsc2046_adc_dcfg`, `struct tsc2046_adc_ch_cfg`, `struct tsc2046_adc_priv`, `enum tsc2046_state`, `function tsc2046_adc_time_to_count`, `function tsc2046_adc_get_cmd`, `function tsc2046_adc_get_value`, `function tsc2046_adc_read_one`.
- 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.