drivers/input/touchscreen/sun4i-ts.c
Source file repositories/reference/linux-study-clean/drivers/input/touchscreen/sun4i-ts.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/touchscreen/sun4i-ts.c- Extension
.c- Size
- 11784 bytes
- Lines
- 412
- 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.
- 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/err.hlinux/hwmon.hlinux/thermal.hlinux/init.hlinux/input.hlinux/interrupt.hlinux/io.hlinux/module.hlinux/of_platform.hlinux/platform_device.hlinux/slab.h
Detected Declarations
struct sun4i_ts_datafunction sun4i_ts_irq_handle_inputfunction sun4i_ts_irqfunction sun4i_ts_openfunction sun4i_ts_closefunction sun4i_get_tempfunction sun4i_get_tz_tempfunction show_tempfunction show_temp_labelfunction sun4i_ts_probefunction sun4i_ts_remove
Annotated Snippet
struct sun4i_ts_data {
struct device *dev;
struct input_dev *input;
void __iomem *base;
unsigned int irq;
bool ignore_fifo_data;
int temp_data;
int temp_offset;
int temp_step;
};
static void sun4i_ts_irq_handle_input(struct sun4i_ts_data *ts, u32 reg_val)
{
u32 x, y;
if (reg_val & FIFO_DATA_PENDING) {
x = readl(ts->base + TP_DATA);
y = readl(ts->base + TP_DATA);
/* The 1st location reported after an up event is unreliable */
if (!ts->ignore_fifo_data) {
input_report_abs(ts->input, ABS_X, x);
input_report_abs(ts->input, ABS_Y, y);
/*
* The hardware has a separate down status bit, but
* that gets set before we get the first location,
* resulting in reporting a click on the old location.
*/
input_report_key(ts->input, BTN_TOUCH, 1);
input_sync(ts->input);
} else {
ts->ignore_fifo_data = false;
}
}
if (reg_val & TP_UP_PENDING) {
ts->ignore_fifo_data = true;
input_report_key(ts->input, BTN_TOUCH, 0);
input_sync(ts->input);
}
}
static irqreturn_t sun4i_ts_irq(int irq, void *dev_id)
{
struct sun4i_ts_data *ts = dev_id;
u32 reg_val;
reg_val = readl(ts->base + TP_INT_FIFOS);
if (reg_val & TEMP_DATA_PENDING)
ts->temp_data = readl(ts->base + TEMP_DATA);
if (ts->input)
sun4i_ts_irq_handle_input(ts, reg_val);
writel(reg_val, ts->base + TP_INT_FIFOS);
return IRQ_HANDLED;
}
static int sun4i_ts_open(struct input_dev *dev)
{
struct sun4i_ts_data *ts = input_get_drvdata(dev);
/* Flush, set trig level to 1, enable temp, data and up irqs */
writel(TEMP_IRQ_EN(1) | DATA_IRQ_EN(1) | FIFO_TRIG(1) | FIFO_FLUSH(1) |
TP_UP_IRQ_EN(1), ts->base + TP_INT_FIFOC);
return 0;
}
static void sun4i_ts_close(struct input_dev *dev)
{
struct sun4i_ts_data *ts = input_get_drvdata(dev);
/* Deactivate all input IRQs */
writel(TEMP_IRQ_EN(1), ts->base + TP_INT_FIFOC);
}
static int sun4i_get_temp(const struct sun4i_ts_data *ts, int *temp)
{
/* No temp_data until the first irq */
if (ts->temp_data == -1)
return -EAGAIN;
*temp = ts->temp_data * ts->temp_step - ts->temp_offset;
return 0;
}
static int sun4i_get_tz_temp(struct thermal_zone_device *tz, int *temp)
Annotation
- Immediate include surface: `linux/err.h`, `linux/hwmon.h`, `linux/thermal.h`, `linux/init.h`, `linux/input.h`, `linux/interrupt.h`, `linux/io.h`, `linux/module.h`.
- Detected declarations: `struct sun4i_ts_data`, `function sun4i_ts_irq_handle_input`, `function sun4i_ts_irq`, `function sun4i_ts_open`, `function sun4i_ts_close`, `function sun4i_get_temp`, `function sun4i_get_tz_temp`, `function show_temp`, `function show_temp_label`, `function sun4i_ts_probe`.
- Atlas domain: Driver Families / drivers/input.
- 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.