drivers/iio/adc/at91_adc.c
Source file repositories/reference/linux-study-clean/drivers/iio/adc/at91_adc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/adc/at91_adc.c- Extension
.c- Size
- 39183 bytes
- Lines
- 1355
- 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/bitmap.hlinux/bitops.hlinux/cleanup.hlinux/clk.hlinux/err.hlinux/io.hlinux/input.hlinux/interrupt.hlinux/jiffies.hlinux/kernel.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/sched.hlinux/slab.hlinux/wait.hlinux/iio/iio.hlinux/iio/buffer.hlinux/iio/trigger.hlinux/iio/trigger_consumer.hlinux/iio/triggered_buffer.hlinux/pinctrl/consumer.h
Detected Declarations
struct at91_adc_triggerstruct at91_adc_reg_descstruct at91_adc_capsstruct at91_adc_stateenum atmel_adc_ts_typefunction at91_adc_trigger_handlerfunction iio_for_each_active_channelfunction handle_adc_eoc_triggerfunction at91_ts_samplefunction at91_adc_rl_interruptfunction at91_adc_9x5_interruptfunction at91_adc_channel_initfunction for_each_set_bitfunction at91_adc_get_trigger_value_by_namefunction at91_adc_configure_triggerfunction for_each_set_bitfunction for_each_set_bitfunction at91_adc_trigger_initfunction at91_adc_trigger_removefunction at91_adc_buffer_initfunction at91_adc_buffer_removefunction at91_adc_read_rawfunction calc_startup_ticks_9260function calc_startup_ticks_9x5function at91_adc_probe_dt_tsfunction atmel_ts_openfunction atmel_ts_closefunction at91_ts_hw_initfunction at91_ts_registerfunction at91_ts_unregisterfunction at91_adc_probefunction at91_adc_removefunction at91_adc_suspendfunction at91_adc_resume
Annotated Snippet
struct at91_adc_trigger {
const char *name;
u8 value;
bool is_external;
};
/**
* struct at91_adc_reg_desc - Various information relative to registers
* @channel_base: Base offset for the channel data registers
* @drdy_mask: Mask of the DRDY field in the relevant registers
* (Interruptions registers mostly)
* @status_register: Offset of the Interrupt Status Register
* @trigger_register: Offset of the Trigger setup register
* @mr_prescal_mask: Mask of the PRESCAL field in the adc MR register
* @mr_startup_mask: Mask of the STARTUP field in the adc MR register
*/
struct at91_adc_reg_desc {
u8 channel_base;
u32 drdy_mask;
u8 status_register;
u8 trigger_register;
u32 mr_prescal_mask;
u32 mr_startup_mask;
};
struct at91_adc_caps {
bool has_ts; /* Support touch screen */
bool has_tsmr; /* only at91sam9x5, sama5d3 have TSMR reg */
/*
* Numbers of sampling data will be averaged. Can be 0~3.
* Hardware can average (2 ^ ts_filter_average) sample data.
*/
u8 ts_filter_average;
/* Pen Detection input pull-up resistor, can be 0~3 */
u8 ts_pen_detect_sensitivity;
/* startup time calculate function */
u32 (*calc_startup_ticks)(u32 startup_time, u32 adc_clk_khz);
u8 num_channels;
u8 low_res_bits;
u8 high_res_bits;
u32 trigger_number;
const struct at91_adc_trigger *triggers;
struct at91_adc_reg_desc registers;
};
struct at91_adc_state {
struct clk *adc_clk;
u16 *buffer;
unsigned long channels_mask;
struct clk *clk;
bool done;
int irq;
u16 last_value;
int chnb;
struct mutex lock;
u8 num_channels;
void __iomem *reg_base;
const struct at91_adc_reg_desc *registers;
u32 startup_time;
u8 sample_hold_time;
bool sleep_mode;
struct iio_trigger **trig;
bool use_external;
u32 vref_mv;
u32 res; /* resolution used for conversions */
wait_queue_head_t wq_data_avail;
const struct at91_adc_caps *caps;
/*
* Following ADC channels are shared by touchscreen:
*
* CH0 -- Touch screen XP/UL
* CH1 -- Touch screen XM/UR
* CH2 -- Touch screen YP/LL
* CH3 -- Touch screen YM/Sense
* CH4 -- Touch screen LR(5-wire only)
*
* The bitfields below represents the reserved channel in the
* touchscreen mode.
*/
#define CHAN_MASK_TOUCHSCREEN_4WIRE (0xf << 0)
#define CHAN_MASK_TOUCHSCREEN_5WIRE (0x1f << 0)
enum atmel_adc_ts_type touchscreen_type;
struct input_dev *ts_input;
u16 ts_sample_period_val;
u32 ts_pressure_threshold;
Annotation
- Immediate include surface: `linux/bitmap.h`, `linux/bitops.h`, `linux/cleanup.h`, `linux/clk.h`, `linux/err.h`, `linux/io.h`, `linux/input.h`, `linux/interrupt.h`.
- Detected declarations: `struct at91_adc_trigger`, `struct at91_adc_reg_desc`, `struct at91_adc_caps`, `struct at91_adc_state`, `enum atmel_adc_ts_type`, `function at91_adc_trigger_handler`, `function iio_for_each_active_channel`, `function handle_adc_eoc_trigger`, `function at91_ts_sample`, `function at91_adc_rl_interrupt`.
- 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.