Lines Matching +full:ts +full:- +full:attached
1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Copyright 2004 Arnaud Patard <arnaud.patard@rtp-net.org>
6 * Copyright 2008 Ben Dooks <ben-linux@fluff.org>
23 #include <linux/soc/samsung/s3c-adc.h>
24 #include <linux/platform_data/touchscreen-s3c2410.h>
78 /* Per-touchscreen data. */
81 * struct s3c2410ts - driver touchscreen state.
108 static struct s3c2410ts ts; variable
111 * get_down - return the down state of the pen
115 * Return non-zero if both readings show that the pen is down.
130 data0 = readl(ts.io + S3C2410_ADCDAT0); in touch_timer_fire()
131 data1 = readl(ts.io + S3C2410_ADCDAT1); in touch_timer_fire()
136 if (ts.count == (1 << ts.shift)) { in touch_timer_fire()
137 ts.xp >>= ts.shift; in touch_timer_fire()
138 ts.yp >>= ts.shift; in touch_timer_fire()
140 dev_dbg(ts.dev, "%s: X=%lu, Y=%lu, count=%d\n", in touch_timer_fire()
141 __func__, ts.xp, ts.yp, ts.count); in touch_timer_fire()
143 input_report_abs(ts.input, ABS_X, ts.xp); in touch_timer_fire()
144 input_report_abs(ts.input, ABS_Y, ts.yp); in touch_timer_fire()
146 input_report_key(ts.input, BTN_TOUCH, 1); in touch_timer_fire()
147 input_sync(ts.input); in touch_timer_fire()
149 ts.xp = 0; in touch_timer_fire()
150 ts.yp = 0; in touch_timer_fire()
151 ts.count = 0; in touch_timer_fire()
154 s3c_adc_start(ts.client, 0, 1 << ts.shift); in touch_timer_fire()
156 ts.xp = 0; in touch_timer_fire()
157 ts.yp = 0; in touch_timer_fire()
158 ts.count = 0; in touch_timer_fire()
160 input_report_key(ts.input, BTN_TOUCH, 0); in touch_timer_fire()
161 input_sync(ts.input); in touch_timer_fire()
163 writel(WAIT4INT | INT_DOWN, ts.io + S3C2410_ADCTSC); in touch_timer_fire()
170 * stylus_irq - touchscreen stylus event interrupt
182 data0 = readl(ts.io + S3C2410_ADCDAT0); in stylus_irq()
183 data1 = readl(ts.io + S3C2410_ADCDAT1); in stylus_irq()
192 s3c_adc_start(ts.client, 0, 1 << ts.shift); in stylus_irq()
194 dev_dbg(ts.dev, "%s: count=%d\n", __func__, ts.count); in stylus_irq()
196 if (ts.features & FEAT_PEN_IRQ) { in stylus_irq()
198 writel(0x0, ts.io + S3C64XX_ADCCLRINTPNDNUP); in stylus_irq()
205 * s3c24xx_ts_conversion - ADC conversion callback
217 dev_dbg(ts.dev, "%s: %d,%d\n", __func__, data0, data1); in s3c24xx_ts_conversion()
219 ts.xp += data0; in s3c24xx_ts_conversion()
220 ts.yp += data1; in s3c24xx_ts_conversion()
222 ts.count++; in s3c24xx_ts_conversion()
224 /* From tests, it seems that it is unlikely to get a pen-up in s3c24xx_ts_conversion()
226 * ignore any pen-up events with less than the requisite in s3c24xx_ts_conversion()
229 * In several thousand conversions, no pen-ups where detected in s3c24xx_ts_conversion()
235 * s3c24xx_ts_select - ADC selection callback.
245 ts.io + S3C2410_ADCTSC); in s3c24xx_ts_select()
248 writel(WAIT4INT | INT_UP, ts.io + S3C2410_ADCTSC); in s3c24xx_ts_select()
253 * s3c2410ts_probe - device core probe entry point
262 struct device *dev = &pdev->dev; in s3c2410ts_probe()
265 int ret = -EINVAL; in s3c2410ts_probe()
268 memset(&ts, 0, sizeof(struct s3c2410ts)); in s3c2410ts_probe()
270 ts.dev = dev; in s3c2410ts_probe()
275 return -EINVAL; in s3c2410ts_probe()
280 ts.clock = clk_get(dev, "adc"); in s3c2410ts_probe()
281 if (IS_ERR(ts.clock)) { in s3c2410ts_probe()
283 return -ENOENT; in s3c2410ts_probe()
286 ret = clk_prepare_enable(ts.clock); in s3c2410ts_probe()
293 ts.irq_tc = ret = platform_get_irq(pdev, 0); in s3c2410ts_probe()
302 ret = -ENOENT; in s3c2410ts_probe()
306 ts.io = ioremap(res->start, resource_size(res)); in s3c2410ts_probe()
307 if (ts.io == NULL) { in s3c2410ts_probe()
309 ret = -ENOMEM; in s3c2410ts_probe()
314 if (info->cfg_gpio) in s3c2410ts_probe()
315 info->cfg_gpio(to_platform_device(ts.dev)); in s3c2410ts_probe()
317 ts.client = s3c_adc_register(pdev, s3c24xx_ts_select, in s3c2410ts_probe()
319 if (IS_ERR(ts.client)) { in s3c2410ts_probe()
321 ret = PTR_ERR(ts.client); in s3c2410ts_probe()
326 if ((info->delay & 0xffff) > 0) in s3c2410ts_probe()
327 writel(info->delay & 0xffff, ts.io + S3C2410_ADCDLY); in s3c2410ts_probe()
329 writel(WAIT4INT | INT_DOWN, ts.io + S3C2410_ADCTSC); in s3c2410ts_probe()
334 ret = -ENOMEM; in s3c2410ts_probe()
338 ts.input = input_dev; in s3c2410ts_probe()
339 ts.input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); in s3c2410ts_probe()
340 ts.input->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); in s3c2410ts_probe()
341 input_set_abs_params(ts.input, ABS_X, 0, 0x3FF, 0, 0); in s3c2410ts_probe()
342 input_set_abs_params(ts.input, ABS_Y, 0, 0x3FF, 0, 0); in s3c2410ts_probe()
344 ts.input->name = "S3C24XX TouchScreen"; in s3c2410ts_probe()
345 ts.input->id.bustype = BUS_HOST; in s3c2410ts_probe()
346 ts.input->id.vendor = 0xDEAD; in s3c2410ts_probe()
347 ts.input->id.product = 0xBEEF; in s3c2410ts_probe()
348 ts.input->id.version = 0x0102; in s3c2410ts_probe()
350 ts.shift = info->oversampling_shift; in s3c2410ts_probe()
351 ts.features = platform_get_device_id(pdev)->driver_data; in s3c2410ts_probe()
353 ret = request_irq(ts.irq_tc, stylus_irq, 0, in s3c2410ts_probe()
354 "s3c2410_ts_pen", ts.input); in s3c2410ts_probe()
360 dev_info(dev, "driver attached, registering input device\n"); in s3c2410ts_probe()
363 ret = input_register_device(ts.input); in s3c2410ts_probe()
366 ret = -EIO; in s3c2410ts_probe()
373 free_irq(ts.irq_tc, ts.input); in s3c2410ts_probe()
375 input_free_device(ts.input); in s3c2410ts_probe()
377 iounmap(ts.io); in s3c2410ts_probe()
379 clk_disable_unprepare(ts.clock); in s3c2410ts_probe()
382 clk_put(ts.clock); in s3c2410ts_probe()
387 * s3c2410ts_remove - device core removal entry point
394 free_irq(ts.irq_tc, ts.input); in s3c2410ts_remove()
397 clk_disable_unprepare(ts.clock); in s3c2410ts_remove()
398 clk_put(ts.clock); in s3c2410ts_remove()
400 input_unregister_device(ts.input); in s3c2410ts_remove()
401 iounmap(ts.io); in s3c2410ts_remove()
409 writel(TSC_SLEEP, ts.io + S3C2410_ADCTSC); in s3c2410ts_suspend()
410 disable_irq(ts.irq_tc); in s3c2410ts_suspend()
411 clk_disable(ts.clock); in s3c2410ts_suspend()
419 struct s3c2410_ts_mach_info *info = dev_get_platdata(&pdev->dev); in s3c2410ts_resume()
421 clk_enable(ts.clock); in s3c2410ts_resume()
422 enable_irq(ts.irq_tc); in s3c2410ts_resume()
425 if ((info->delay & 0xffff) > 0) in s3c2410ts_resume()
426 writel(info->delay & 0xffff, ts.io + S3C2410_ADCDLY); in s3c2410ts_resume()
428 writel(WAIT4INT | INT_DOWN, ts.io + S3C2410_ADCTSC); in s3c2410ts_resume()
440 { "s3c2410-ts", 0 },
441 { "s3c2440-ts", 0 },
442 { "s3c64xx-ts", FEAT_PEN_IRQ },
449 .name = "samsung-ts",
460 MODULE_AUTHOR("Arnaud Patard <arnaud.patard@rtp-net.org>, "