16 #include <linux/module.h>
17 #include <linux/kernel.h>
19 #include <linux/errno.h>
20 #include <linux/input.h>
23 #include <linux/slab.h>
25 #include <linux/ctype.h>
31 #define TSC_PENUP_POLL (HZ / 5)
32 #define IDLE_TIMEOUT 100
39 #define TSC_HEAD_SKIP 1
40 #define TSC_TAIL_SKIP 1
41 #define TSC_SKIP (TSC_HEAD_SKIP + TSC_TAIL_SKIP + 1)
42 #define TSC_SAMPLES (TSC_SKIP + 1)
58 #define ZMEASURE_EN BIT(2)
62 #define ONE_SHOT BIT(6)
65 #define AVGNUM(x) (((x) & 0x03) << 9)
66 #define PVSTC(x) (((x) & 0x07) << 11)
69 #define AFERST BIT(16)
72 #define DATA_VALID BIT(16)
75 #define tsc_read(ts, reg) __raw_readl(&(ts)->regs->reg)
76 #define tsc_write(ts, reg, val) __raw_writel(val, &(ts)->regs->reg);
77 #define tsc_set_bits(ts, reg, val) \
78 tsc_write(ts, reg, tsc_read(ts, reg) | (val))
79 #define tsc_clr_bits(ts, reg, val) \
80 tsc_write(ts, reg, tsc_read(ts, reg) & ~(val))
101 int x,
y, z1, z2,
t,
p = 0;
110 y =
tsc_read(ts, chval[1]) & 0xffff;
111 z1 =
tsc_read(ts, chval[2]) & 0xffff;
112 z2 =
tsc_read(ts, chval[3]) & 0xffff;
115 t = ((600 *
x) * (z2 - z1));
116 p = t / (
u32) (z1 << 12);
128 static void tsc_poll(
unsigned long data)
166 spin_unlock_irqrestore(&ts->
lock, flags);
175 spin_lock(&ts->
lock);
179 if (tsc_read_sample(ts, sample) < 0)
195 spin_unlock(&ts->
lock);
199 static int tsc_start(
struct input_dev *
dev)
201 struct tsc_data *ts = input_get_drvdata(dev);
236 static void tsc_stop(
struct input_dev *dev)
238 struct tsc_data *ts = input_get_drvdata(dev);
255 dev_err(dev,
"cannot allocate device info\n");
262 platform_set_drvdata(pdev, ts);
266 dev_err(dev,
"cannot determine device interrupt\n");
273 dev_err(dev,
"cannot determine register area\n");
280 dev_err(dev,
"cannot claim register memory\n");
288 dev_err(dev,
"cannot map register memory\n");
294 if (IS_ERR(ts->
clk)) {
295 dev_err(dev,
"cannot claim device clock\n");
296 error = PTR_ERR(ts->
clk);
303 dev_err(ts->
dev,
"Could not allocate ts irq\n");
309 dev_err(dev,
"cannot allocate input device\n");
323 ts->
input_dev->id.product = ((rev >> 8) & 0x07);
324 ts->
input_dev->id.version = ((rev >> 16) & 0xfff);
335 error = input_register_device(ts->
input_dev);
337 dev_err(dev,
"failed input device registration\n");
354 platform_set_drvdata(pdev,
NULL);
362 struct tsc_data *ts = platform_get_drvdata(pdev);
369 platform_set_drvdata(pdev,
NULL);
378 .driver.name =
"tnetv107x-ts",