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()
201 struct device *dev = &pdev->dev; in lpc32xx_ts_probe()
213 return -ENOMEM; in lpc32xx_ts_probe()
215 tsc->irq = irq; in lpc32xx_ts_probe()
217 tsc->tsc_base = devm_platform_ioremap_resource(pdev, 0); in lpc32xx_ts_probe()
218 if (IS_ERR(tsc->tsc_base)) in lpc32xx_ts_probe()
219 return PTR_ERR(tsc->tsc_base); in lpc32xx_ts_probe()
221 tsc->clk = devm_clk_get(dev, NULL); in lpc32xx_ts_probe()
222 if (IS_ERR(tsc->clk)) { in lpc32xx_ts_probe()
223 dev_err(&pdev->dev, "failed getting clock\n"); in lpc32xx_ts_probe()
224 return PTR_ERR(tsc->clk); in lpc32xx_ts_probe()
229 dev_err(&pdev->dev, "failed allocating input device\n"); in lpc32xx_ts_probe()
230 return -ENOMEM; in lpc32xx_ts_probe()
233 input->name = MOD_NAME; in lpc32xx_ts_probe()
234 input->phys = "lpc32xx/input0"; in lpc32xx_ts_probe()
235 input->id.bustype = BUS_HOST; in lpc32xx_ts_probe()
236 input->id.vendor = 0x0001; in lpc32xx_ts_probe()
237 input->id.product = 0x0002; in lpc32xx_ts_probe()
238 input->id.version = 0x0100; in lpc32xx_ts_probe()
239 input->open = lpc32xx_ts_open; in lpc32xx_ts_probe()
240 input->close = lpc32xx_ts_close; in lpc32xx_ts_probe()
249 tsc->dev = input; in lpc32xx_ts_probe()
251 error = devm_request_irq(dev, tsc->irq, lpc32xx_ts_interrupt, in lpc32xx_ts_probe()
252 0, pdev->name, tsc); in lpc32xx_ts_probe()
254 dev_err(&pdev->dev, "failed requesting interrupt\n"); in lpc32xx_ts_probe()
260 dev_err(&pdev->dev, "failed registering input device\n"); in lpc32xx_ts_probe()
265 device_init_wakeup(&pdev->dev, true); in lpc32xx_ts_probe()
274 struct input_dev *input = tsc->dev; in lpc32xx_ts_suspend()
282 mutex_lock(&input->mutex); in lpc32xx_ts_suspend()
286 enable_irq_wake(tsc->irq); in lpc32xx_ts_suspend()
291 mutex_unlock(&input->mutex); in lpc32xx_ts_suspend()
299 struct input_dev *input = tsc->dev; in lpc32xx_ts_resume()
301 mutex_lock(&input->mutex); in lpc32xx_ts_resume()
305 disable_irq_wake(tsc->irq); in lpc32xx_ts_resume()
310 mutex_unlock(&input->mutex); in lpc32xx_ts_resume()
326 { .compatible = "nxp,lpc3220-tsc", },