drivers/input/touchscreen/mxs-lradc-ts.c
Source file repositories/reference/linux-study-clean/drivers/input/touchscreen/mxs-lradc-ts.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/touchscreen/mxs-lradc-ts.c- Extension
.c- Size
- 19479 bytes
- Lines
- 703
- Domain
- Driver Families
- Bucket
- drivers/input
- 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/device.hlinux/err.hlinux/input.hlinux/interrupt.hlinux/module.hlinux/mfd/core.hlinux/mfd/mxs-lradc.hlinux/of.hlinux/of_irq.hlinux/platform_device.h
Detected Declarations
struct mxs_lradc_tsstruct state_infoenum mxs_lradc_ts_platefunction mxs_lradc_check_touch_eventfunction mxs_lradc_map_ts_channelfunction mxs_lradc_setup_ts_channelfunction mxs_lradc_setup_ts_pressurefunction mxs_lradc_ts_read_raw_channelfunction mxs_lradc_read_ts_pressurefunction YPfunction YPfunction YPfunction YPfunction mxs_lradc_enable_touch_detectionfunction mxs_lradc_start_touch_eventfunction mxs_lradc_report_ts_eventfunction mxs_lradc_complete_touch_eventfunction mxs_lradc_finish_touch_eventfunction mxs_lradc_handle_touchfunction mxs_lradc_ts_handle_irqfunction mxs_lradc_ts_openfunction mxs_lradc_ts_stopfunction mxs_lradc_ts_closefunction mxs_lradc_ts_hw_initfunction mxs_lradc_ts_registerfunction mxs_lradc_ts_probe
Annotated Snippet
struct mxs_lradc_ts {
struct mxs_lradc *lradc;
struct device *dev;
void __iomem *base;
/*
* When the touchscreen is enabled, we give it two private virtual
* channels: #6 and #7. This means that only 6 virtual channels (instead
* of 8) will be available for buffered capture.
*/
#define TOUCHSCREEN_VCHANNEL1 7
#define TOUCHSCREEN_VCHANNEL2 6
struct input_dev *ts_input;
enum mxs_lradc_ts_plate cur_plate; /* state machine */
bool ts_valid;
unsigned int ts_x_pos;
unsigned int ts_y_pos;
unsigned int ts_pressure;
/* handle touchscreen's physical behaviour */
/* samples per coordinate */
unsigned int over_sample_cnt;
/* time clocks between samples */
unsigned int over_sample_delay;
/* time in clocks to wait after the plates where switched */
unsigned int settling_delay;
spinlock_t lock;
};
struct state_info {
u32 mask;
u32 bit;
u32 x_plate;
u32 y_plate;
u32 pressure;
};
static struct state_info info[] = {
{LRADC_CTRL0_MX23_PLATE_MASK, LRADC_CTRL0_MX23_TOUCH_DETECT_ENABLE,
LRADC_CTRL0_MX23_XP | LRADC_CTRL0_MX23_XM,
LRADC_CTRL0_MX23_YP | LRADC_CTRL0_MX23_YM,
LRADC_CTRL0_MX23_YP | LRADC_CTRL0_MX23_XM},
{LRADC_CTRL0_MX28_PLATE_MASK, LRADC_CTRL0_MX28_TOUCH_DETECT_ENABLE,
LRADC_CTRL0_MX28_XPPSW | LRADC_CTRL0_MX28_XNNSW,
LRADC_CTRL0_MX28_YPPSW | LRADC_CTRL0_MX28_YNNSW,
LRADC_CTRL0_MX28_YPPSW | LRADC_CTRL0_MX28_XNNSW}
};
static bool mxs_lradc_check_touch_event(struct mxs_lradc_ts *ts)
{
return !!(readl(ts->base + LRADC_STATUS) &
LRADC_STATUS_TOUCH_DETECT_RAW);
}
static void mxs_lradc_map_ts_channel(struct mxs_lradc_ts *ts, unsigned int vch,
unsigned int ch)
{
writel(LRADC_CTRL4_LRADCSELECT_MASK(vch),
ts->base + LRADC_CTRL4 + STMP_OFFSET_REG_CLR);
writel(LRADC_CTRL4_LRADCSELECT(vch, ch),
ts->base + LRADC_CTRL4 + STMP_OFFSET_REG_SET);
}
static void mxs_lradc_setup_ts_channel(struct mxs_lradc_ts *ts, unsigned int ch)
{
/*
* prepare for oversampling conversion
*
* from the datasheet:
* "The ACCUMULATE bit in the appropriate channel register
* HW_LRADC_CHn must be set to 1 if NUM_SAMPLES is greater then 0;
* otherwise, the IRQs will not fire."
*/
writel(LRADC_CH_ACCUMULATE |
LRADC_CH_NUM_SAMPLES(ts->over_sample_cnt - 1),
ts->base + LRADC_CH(ch));
/* from the datasheet:
* "Software must clear this register in preparation for a
* multi-cycle accumulation.
*/
writel(LRADC_CH_VALUE_MASK,
ts->base + LRADC_CH(ch) + STMP_OFFSET_REG_CLR);
/*
* prepare the delay/loop unit according to the oversampling count
*
* from the datasheet:
Annotation
- Immediate include surface: `linux/device.h`, `linux/err.h`, `linux/input.h`, `linux/interrupt.h`, `linux/module.h`, `linux/mfd/core.h`, `linux/mfd/mxs-lradc.h`, `linux/of.h`.
- Detected declarations: `struct mxs_lradc_ts`, `struct state_info`, `enum mxs_lradc_ts_plate`, `function mxs_lradc_check_touch_event`, `function mxs_lradc_map_ts_channel`, `function mxs_lradc_setup_ts_channel`, `function mxs_lradc_setup_ts_pressure`, `function mxs_lradc_ts_read_raw_channel`, `function mxs_lradc_read_ts_pressure`, `function YP`.
- Atlas domain: Driver Families / drivers/input.
- 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.