26 #include <linux/errno.h>
27 #include <linux/kernel.h>
28 #include <linux/module.h>
30 #include <linux/input.h>
42 #define TSC_SLEEP (S3C2410_ADCTSC_PULL_UP_DISABLE | S3C2410_ADCTSC_XY_PST(0))
45 #define INT_UP (1 << 8)
47 #define WAIT4INT (S3C2410_ADCTSC_YM_SEN | \
48 S3C2410_ADCTSC_YP_SEN | \
49 S3C2410_ADCTSC_XP_SEN | \
50 S3C2410_ADCTSC_XY_PST(3))
52 #define AUTOPST (S3C2410_ADCTSC_YM_SEN | \
53 S3C2410_ADCTSC_YP_SEN | \
54 S3C2410_ADCTSC_XP_SEN | \
55 S3C2410_ADCTSC_AUTO_PST | \
56 S3C2410_ADCTSC_XY_PST(0))
58 #define FEAT_PEN_IRQ (1 << 0)
99 static inline bool get_down(
unsigned long data0,
unsigned long data1)
103 !(data1 & S3C2410_ADCDAT0_UPDOWN));
106 static void touch_timer_fire(
unsigned long data)
115 down = get_down(data0, data1);
118 if (
ts.count == (1 <<
ts.shift)) {
122 dev_dbg(
ts.dev,
"%s: X=%lu, Y=%lu, count=%d\n",
123 __func__,
ts.xp,
ts.yp,
ts.count);
125 input_report_abs(
ts.input,
ABS_X,
ts.xp);
126 input_report_abs(
ts.input,
ABS_Y,
ts.yp);
129 input_sync(
ts.input);
143 input_sync(
ts.input);
149 static DEFINE_TIMER(touch_timer, touch_timer_fire, 0, 0);
167 down = get_down(data0, data1);
176 dev_dbg(
ts.dev,
"%s: count=%d\n", __func__,
ts.count);
196 unsigned data0,
unsigned data1,
199 dev_dbg(
ts.dev,
"%s: %d,%d\n", __func__, data0, data1);
245 struct input_dev *input_dev;
254 info = pdev->
dev.platform_data;
256 dev_err(dev,
"no platform data, cannot attach\n");
260 dev_dbg(dev,
"initialising touchscreen\n");
263 if (IS_ERR(
ts.clock)) {
264 dev_err(dev,
"cannot get adc clock source\n");
269 dev_dbg(dev,
"got and enabled clocks\n");
273 dev_err(dev,
"no resource for interrupt\n");
279 dev_err(dev,
"no resource for registers\n");
286 dev_err(dev,
"cannot map registers\n");
296 s3c24xx_ts_conversion, 1);
297 if (IS_ERR(
ts.client)) {
298 dev_err(dev,
"failed to register adc client\n");
299 ret = PTR_ERR(
ts.client);
304 if ((info->
delay & 0xffff) > 0)
309 input_dev = input_allocate_device();
311 dev_err(dev,
"Unable to allocate the input device !!\n");
316 ts.input = input_dev;
319 input_set_abs_params(
ts.input,
ABS_X, 0, 0x3FF, 0, 0);
320 input_set_abs_params(
ts.input,
ABS_Y, 0, 0x3FF, 0, 0);
322 ts.input->name =
"S3C24XX TouchScreen";
324 ts.input->id.vendor = 0xDEAD;
325 ts.input->id.product = 0xBEEF;
326 ts.input->id.version = 0x0102;
332 "s3c2410_ts_pen",
ts.input);
334 dev_err(dev,
"cannot get TC interrupt\n");
338 dev_info(dev,
"driver attached, registering input device\n");
341 ret = input_register_device(
ts.input);
343 dev_err(dev,
"failed to register input device\n");
353 input_free_device(
ts.input);
376 input_unregister_device(
ts.input);
383 static int s3c2410ts_suspend(
struct device *dev)
392 static int s3c2410ts_resume(
struct device *dev)
401 if ((info->
delay & 0xffff) > 0)
409 static const struct dev_pm_ops s3c_ts_pmops = {
411 .resume = s3c2410ts_resume,
425 .name =
"samsung-ts",
431 .id_table = s3cts_driver_ids,
432 .probe = s3c2410ts_probe,