Lines Matching +full:touchscreen +full:- +full:average +full:- +full:samples

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * LPC32xx built-in touchscreen driver
18 * Touchscreen controller register offsets
43 #define LPC32XX_TSC_ADCCON_X_SAMPLE_SIZE(s) ((10 - (s)) << 7)
44 #define LPC32XX_TSC_ADCCON_Y_SAMPLE_SIZE(s) ((10 - (s)) << 4)
57 #define MOD_NAME "ts-lpc32xx"
60 __raw_readl((dev)->tsc_base + (reg))
62 __raw_writel((val), (dev)->tsc_base + (reg))
83 struct input_dev *input = tsc->dev; in lpc32xx_ts_interrupt()
88 /* FIFO overflow - throw away samples */ in lpc32xx_ts_interrupt()
94 * Gather and normalize 4 samples. Pen-up events may have less in lpc32xx_ts_interrupt()
95 * than 4 samples, but its ok to pop 4 and let the last sample in lpc32xx_ts_interrupt()
96 * pen status check drop the samples. in lpc32xx_ts_interrupt()
103 xs[idx] = LPC32XX_TSC_ADCDAT_VALUE_MASK - in lpc32xx_ts_interrupt()
105 ys[idx] = LPC32XX_TSC_ADCDAT_VALUE_MASK - in lpc32xx_ts_interrupt()
113 /* Use average of 2nd and 3rd sample for position */ in lpc32xx_ts_interrupt()
133 clk_disable_unprepare(tsc->clk); in lpc32xx_stop_tsc()
141 err = clk_prepare_enable(tsc->clk); in lpc32xx_setup_tsc()
147 /* Set the TSC FIFO depth to 4 samples @ 10-bits per sample (max) */ in lpc32xx_setup_tsc()
210 dev_err(&pdev->dev, "Can't get memory resource\n"); in lpc32xx_ts_probe()
211 return -ENOENT; in lpc32xx_ts_probe()
221 dev_err(&pdev->dev, "failed allocating memory\n"); in lpc32xx_ts_probe()
222 error = -ENOMEM; in lpc32xx_ts_probe()
226 tsc->dev = input; in lpc32xx_ts_probe()
227 tsc->irq = irq; in lpc32xx_ts_probe()
231 if (!request_mem_region(res->start, size, pdev->name)) { in lpc32xx_ts_probe()
232 dev_err(&pdev->dev, "TSC registers are not free\n"); in lpc32xx_ts_probe()
233 error = -EBUSY; in lpc32xx_ts_probe()
237 tsc->tsc_base = ioremap(res->start, size); in lpc32xx_ts_probe()
238 if (!tsc->tsc_base) { in lpc32xx_ts_probe()
239 dev_err(&pdev->dev, "Can't map memory\n"); in lpc32xx_ts_probe()
240 error = -ENOMEM; in lpc32xx_ts_probe()
244 tsc->clk = clk_get(&pdev->dev, NULL); in lpc32xx_ts_probe()
245 if (IS_ERR(tsc->clk)) { in lpc32xx_ts_probe()
246 dev_err(&pdev->dev, "failed getting clock\n"); in lpc32xx_ts_probe()
247 error = PTR_ERR(tsc->clk); in lpc32xx_ts_probe()
251 input->name = MOD_NAME; in lpc32xx_ts_probe()
252 input->phys = "lpc32xx/input0"; in lpc32xx_ts_probe()
253 input->id.bustype = BUS_HOST; in lpc32xx_ts_probe()
254 input->id.vendor = 0x0001; in lpc32xx_ts_probe()
255 input->id.product = 0x0002; in lpc32xx_ts_probe()
256 input->id.version = 0x0100; in lpc32xx_ts_probe()
257 input->dev.parent = &pdev->dev; in lpc32xx_ts_probe()
258 input->open = lpc32xx_ts_open; in lpc32xx_ts_probe()
259 input->close = lpc32xx_ts_close; in lpc32xx_ts_probe()
261 input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); in lpc32xx_ts_probe()
262 input->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); in lpc32xx_ts_probe()
270 error = request_irq(tsc->irq, lpc32xx_ts_interrupt, in lpc32xx_ts_probe()
271 0, pdev->name, tsc); in lpc32xx_ts_probe()
273 dev_err(&pdev->dev, "failed requesting interrupt\n"); in lpc32xx_ts_probe()
279 dev_err(&pdev->dev, "failed registering input device\n"); in lpc32xx_ts_probe()
284 device_init_wakeup(&pdev->dev, 1); in lpc32xx_ts_probe()
289 free_irq(tsc->irq, tsc); in lpc32xx_ts_probe()
291 clk_put(tsc->clk); in lpc32xx_ts_probe()
293 iounmap(tsc->tsc_base); in lpc32xx_ts_probe()
295 release_mem_region(res->start, size); in lpc32xx_ts_probe()
308 free_irq(tsc->irq, tsc); in lpc32xx_ts_remove()
310 input_unregister_device(tsc->dev); in lpc32xx_ts_remove()
312 clk_put(tsc->clk); in lpc32xx_ts_remove()
314 iounmap(tsc->tsc_base); in lpc32xx_ts_remove()
316 release_mem_region(res->start, resource_size(res)); in lpc32xx_ts_remove()
327 struct input_dev *input = tsc->dev; in lpc32xx_ts_suspend()
335 mutex_lock(&input->mutex); in lpc32xx_ts_suspend()
337 if (input->users) { in lpc32xx_ts_suspend()
339 enable_irq_wake(tsc->irq); in lpc32xx_ts_suspend()
344 mutex_unlock(&input->mutex); in lpc32xx_ts_suspend()
352 struct input_dev *input = tsc->dev; in lpc32xx_ts_resume()
354 mutex_lock(&input->mutex); in lpc32xx_ts_resume()
356 if (input->users) { in lpc32xx_ts_resume()
358 disable_irq_wake(tsc->irq); in lpc32xx_ts_resume()
363 mutex_unlock(&input->mutex); in lpc32xx_ts_resume()
379 { .compatible = "nxp,lpc3220-tsc", },