Lines Matching +full:pen +full:- +full:up
1 // SPDX-License-Identifier: GPL-2.0-or-later
25 * R16424 (0x4028) - Touch Control 1
33 #define WM831X_TCH_DELAY_MASK 0x00E0 /* TCH_DELAY - [7:5] */
34 #define WM831X_TCH_DELAY_SHIFT 5 /* TCH_DELAY - [7:5] */
35 #define WM831X_TCH_DELAY_WIDTH 3 /* TCH_DELAY - [7:5] */
36 #define WM831X_TCH_RATE_MASK 0x001F /* TCH_RATE - [4:0] */
37 #define WM831X_TCH_RATE_SHIFT 0 /* TCH_RATE - [4:0] */
38 #define WM831X_TCH_RATE_WIDTH 5 /* TCH_RATE - [4:0] */
41 * R16425 (0x4029) - Touch Control 2
47 #define WM831X_TCH_RPU_MASK 0x000F /* TCH_RPU - [3:0] */
48 #define WM831X_TCH_RPU_SHIFT 0 /* TCH_RPU - [3:0] */
49 #define WM831X_TCH_RPU_WIDTH 4 /* TCH_RPU - [3:0] */
52 * R16426-8 (0x402A-C) - Touch Data X/Y/X
55 #define WM831X_TCH_DATA_MASK 0x0FFF /* TCH_DATA - [11:0] */
56 #define WM831X_TCH_DATA_SHIFT 0 /* TCH_DATA - [11:0] */
57 #define WM831X_TCH_DATA_WIDTH 12 /* TCH_DATA - [11:0] */
74 if (wm831x_ts->pen_down) { in wm831x_pd_data_work()
75 enable_irq(wm831x_ts->data_irq); in wm831x_pd_data_work()
76 dev_dbg(wm831x_ts->wm831x->dev, "IRQ PD->DATA done\n"); in wm831x_pd_data_work()
78 enable_irq(wm831x_ts->pd_irq); in wm831x_pd_data_work()
79 dev_dbg(wm831x_ts->wm831x->dev, "IRQ DATA->PD done\n"); in wm831x_pd_data_work()
86 struct wm831x *wm831x = wm831x_ts->wm831x; in wm831x_ts_data_irq()
92 if (wm831x_ts->pressure) in wm831x_ts_data_irq()
103 dev_err(wm831x->dev, "Failed to read touch data: %d\n", in wm831x_ts_data_irq()
109 * We get a pen down reading on every reading, report pen up if any in wm831x_ts_data_irq()
112 wm831x_ts->pen_down = true; in wm831x_ts_data_irq()
115 wm831x_ts->pen_down = false; in wm831x_ts_data_irq()
118 input_report_abs(wm831x_ts->input_dev, data_types[i], in wm831x_ts_data_irq()
122 if (!wm831x_ts->pen_down) { in wm831x_ts_data_irq()
123 /* Switch from data to pen down */ in wm831x_ts_data_irq()
124 dev_dbg(wm831x->dev, "IRQ DATA->PD\n"); in wm831x_ts_data_irq()
126 disable_irq_nosync(wm831x_ts->data_irq); in wm831x_ts_data_irq()
139 if (wm831x_ts->pressure) in wm831x_ts_data_irq()
140 input_report_abs(wm831x_ts->input_dev, in wm831x_ts_data_irq()
143 input_report_key(wm831x_ts->input_dev, BTN_TOUCH, 0); in wm831x_ts_data_irq()
145 schedule_work(&wm831x_ts->pd_data_work); in wm831x_ts_data_irq()
147 input_report_key(wm831x_ts->input_dev, BTN_TOUCH, 1); in wm831x_ts_data_irq()
150 input_sync(wm831x_ts->input_dev); in wm831x_ts_data_irq()
158 struct wm831x *wm831x = wm831x_ts->wm831x; in wm831x_ts_pen_down_irq()
161 if (wm831x_ts->pen_down) in wm831x_ts_pen_down_irq()
164 disable_irq_nosync(wm831x_ts->pd_irq); in wm831x_ts_pen_down_irq()
167 if (wm831x_ts->pressure) in wm831x_ts_pen_down_irq()
177 wm831x_ts->pen_down = true; in wm831x_ts_pen_down_irq()
179 /* Switch from pen down to data */ in wm831x_ts_pen_down_irq()
180 dev_dbg(wm831x->dev, "IRQ PD->DATA\n"); in wm831x_ts_pen_down_irq()
181 schedule_work(&wm831x_ts->pd_data_work); in wm831x_ts_pen_down_irq()
189 struct wm831x *wm831x = wm831x_ts->wm831x; in wm831x_ts_input_open()
205 struct wm831x *wm831x = wm831x_ts->wm831x; in wm831x_ts_input_close()
215 synchronize_irq(wm831x_ts->data_irq); in wm831x_ts_input_close()
216 synchronize_irq(wm831x_ts->pd_irq); in wm831x_ts_input_close()
219 flush_work(&wm831x_ts->pd_data_work); in wm831x_ts_input_close()
221 /* If we ended up with the pen down then make sure we revert back in wm831x_ts_input_close()
222 * to pen detection state for the next time we start up. in wm831x_ts_input_close()
224 if (wm831x_ts->pen_down) { in wm831x_ts_input_close()
225 disable_irq(wm831x_ts->data_irq); in wm831x_ts_input_close()
226 enable_irq(wm831x_ts->pd_irq); in wm831x_ts_input_close()
227 wm831x_ts->pen_down = false; in wm831x_ts_input_close()
234 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent); in wm831x_ts_probe()
235 struct wm831x_pdata *core_pdata = dev_get_platdata(pdev->dev.parent); in wm831x_ts_probe()
241 pdata = core_pdata->touch; in wm831x_ts_probe()
243 wm831x_ts = devm_kzalloc(&pdev->dev, sizeof(struct wm831x_ts), in wm831x_ts_probe()
245 input_dev = devm_input_allocate_device(&pdev->dev); in wm831x_ts_probe()
247 error = -ENOMEM; in wm831x_ts_probe()
251 wm831x_ts->wm831x = wm831x; in wm831x_ts_probe()
252 wm831x_ts->input_dev = input_dev; in wm831x_ts_probe()
253 INIT_WORK(&wm831x_ts->pd_data_work, wm831x_pd_data_work); in wm831x_ts_probe()
259 wm831x_ts->data_irq = wm831x_irq(wm831x, in wm831x_ts_probe()
262 if (pdata && pdata->data_irq) in wm831x_ts_probe()
263 wm831x_ts->data_irq = pdata->data_irq; in wm831x_ts_probe()
265 wm831x_ts->pd_irq = wm831x_irq(wm831x, in wm831x_ts_probe()
267 if (pdata && pdata->pd_irq) in wm831x_ts_probe()
268 wm831x_ts->pd_irq = pdata->pd_irq; in wm831x_ts_probe()
271 wm831x_ts->pressure = pdata->pressure; in wm831x_ts_probe()
273 wm831x_ts->pressure = true; in wm831x_ts_probe()
276 if (pdata && pdata->fivewire) { in wm831x_ts_probe()
281 WARN_ON(pdata->pressure && pdata->fivewire); in wm831x_ts_probe()
282 wm831x_ts->pressure = false; in wm831x_ts_probe()
289 switch (pdata->isel) { in wm831x_ts_probe()
291 dev_err(&pdev->dev, "Unsupported ISEL setting: %d\n", in wm831x_ts_probe()
292 pdata->isel); in wm831x_ts_probe()
313 if (pdata && pdata->data_irqf) in wm831x_ts_probe()
314 irqf = pdata->data_irqf; in wm831x_ts_probe()
318 error = request_threaded_irq(wm831x_ts->data_irq, in wm831x_ts_probe()
323 dev_err(&pdev->dev, "Failed to request data IRQ %d: %d\n", in wm831x_ts_probe()
324 wm831x_ts->data_irq, error); in wm831x_ts_probe()
328 if (pdata && pdata->pd_irqf) in wm831x_ts_probe()
329 irqf = pdata->pd_irqf; in wm831x_ts_probe()
333 error = request_threaded_irq(wm831x_ts->pd_irq, in wm831x_ts_probe()
336 "Touchscreen pen down", wm831x_ts); in wm831x_ts_probe()
338 dev_err(&pdev->dev, "Failed to request pen down IRQ %d: %d\n", in wm831x_ts_probe()
339 wm831x_ts->pd_irq, error); in wm831x_ts_probe()
343 /* set up touch configuration */ in wm831x_ts_probe()
344 input_dev->name = "WM831x touchscreen"; in wm831x_ts_probe()
345 input_dev->phys = "wm831x"; in wm831x_ts_probe()
346 input_dev->open = wm831x_ts_input_open; in wm831x_ts_probe()
347 input_dev->close = wm831x_ts_input_close; in wm831x_ts_probe()
349 __set_bit(EV_ABS, input_dev->evbit); in wm831x_ts_probe()
350 __set_bit(EV_KEY, input_dev->evbit); in wm831x_ts_probe()
351 __set_bit(BTN_TOUCH, input_dev->keybit); in wm831x_ts_probe()
355 if (wm831x_ts->pressure) in wm831x_ts_probe()
359 input_dev->dev.parent = &pdev->dev; in wm831x_ts_probe()
369 free_irq(wm831x_ts->pd_irq, wm831x_ts); in wm831x_ts_probe()
371 free_irq(wm831x_ts->data_irq, wm831x_ts); in wm831x_ts_probe()
381 free_irq(wm831x_ts->pd_irq, wm831x_ts); in wm831x_ts_remove()
382 free_irq(wm831x_ts->data_irq, wm831x_ts); in wm831x_ts_remove()
387 .name = "wm831x-touch",
398 MODULE_ALIAS("platform:wm831x-touch");