13 #include <linux/module.h>
15 #include <linux/kernel.h>
17 #include <linux/string.h>
19 #include <linux/input.h>
26 #include <linux/slab.h>
27 #include <linux/types.h>
32 #define WM831X_TCH_ENA 0x8000
33 #define WM831X_TCH_CVT_ENA 0x4000
34 #define WM831X_TCH_SLPENA 0x1000
35 #define WM831X_TCH_Z_ENA 0x0400
36 #define WM831X_TCH_Y_ENA 0x0200
37 #define WM831X_TCH_X_ENA 0x0100
38 #define WM831X_TCH_DELAY_MASK 0x00E0
39 #define WM831X_TCH_DELAY_SHIFT 5
40 #define WM831X_TCH_DELAY_WIDTH 3
41 #define WM831X_TCH_RATE_MASK 0x001F
42 #define WM831X_TCH_RATE_SHIFT 0
43 #define WM831X_TCH_RATE_WIDTH 5
48 #define WM831X_TCH_PD_WK 0x2000
49 #define WM831X_TCH_5WIRE 0x1000
50 #define WM831X_TCH_PDONLY 0x0800
51 #define WM831X_TCH_ISEL 0x0100
52 #define WM831X_TCH_RPU_MASK 0x000F
53 #define WM831X_TCH_RPU_SHIFT 0
54 #define WM831X_TCH_RPU_WIDTH 4
59 #define WM831X_TCH_PD 0x8000
60 #define WM831X_TCH_DATA_MASK 0x0FFF
61 #define WM831X_TCH_DATA_SHIFT 0
62 #define WM831X_TCH_DATA_WIDTH 12
90 struct wm831x_ts *wm831x_ts = irq_data;
108 dev_err(wm831x->
dev,
"Failed to read touch data: %d\n",
118 for (i = 0; i <
count; i++) {
123 input_report_abs(wm831x_ts->
input_dev, data_types[i],
160 static irqreturn_t wm831x_ts_pen_down_irq(
int irq,
void *irq_data)
162 struct wm831x_ts *wm831x_ts = irq_data;
163 struct wm831x *wm831x = wm831x_ts->
wm831x;
191 static int wm831x_ts_input_open(
struct input_dev *
idev)
193 struct wm831x_ts *wm831x_ts = input_get_drvdata(idev);
194 struct wm831x *wm831x = wm831x_ts->
wm831x;
207 static void wm831x_ts_input_close(
struct input_dev *
idev)
209 struct wm831x_ts *wm831x_ts = input_get_drvdata(idev);
210 struct wm831x *wm831x = wm831x_ts->
wm831x;
238 struct wm831x_ts *wm831x_ts;
242 struct input_dev *input_dev;
246 pdata = core_pdata->
touch;
248 wm831x_ts = kzalloc(
sizeof(
struct wm831x_ts),
GFP_KERNEL);
249 input_dev = input_allocate_device();
250 if (!wm831x_ts || !input_dev) {
255 wm831x_ts->
wm831x = wm831x;
263 wm831x_ts->
data_irq = wm831x_irq(wm831x,
269 wm831x_ts->
pd_irq = wm831x_irq(wm831x,
271 if (pdata && pdata->
pd_irq)
293 switch (pdata->
isel) {
295 dev_err(&pdev->
dev,
"Unsupported ISEL setting: %d\n",
323 NULL, wm831x_ts_data_irq,
325 "Touchscreen data", wm831x_ts);
327 dev_err(&pdev->
dev,
"Failed to request data IRQ %d: %d\n",
339 NULL, wm831x_ts_pen_down_irq,
341 "Touchscreen pen down", wm831x_ts);
343 dev_err(&pdev->
dev,
"Failed to request pen down IRQ %d: %d\n",
344 wm831x_ts->
pd_irq, error);
349 input_dev->name =
"WM831x touchscreen";
350 input_dev->phys =
"wm831x";
351 input_dev->open = wm831x_ts_input_open;
352 input_dev->close = wm831x_ts_input_close;
358 input_set_abs_params(input_dev,
ABS_X, 0, 4095, 5, 0);
359 input_set_abs_params(input_dev,
ABS_Y, 0, 4095, 5, 0);
361 input_set_abs_params(input_dev,
ABS_PRESSURE, 0, 4095, 5, 0);
363 input_set_drvdata(input_dev, wm831x_ts);
364 input_dev->dev.parent = &pdev->
dev;
366 error = input_register_device(input_dev);
370 platform_set_drvdata(pdev, wm831x_ts);
378 input_free_device(input_dev);
386 struct wm831x_ts *wm831x_ts = platform_get_drvdata(pdev);
390 input_unregister_device(wm831x_ts->
input_dev);
393 platform_set_drvdata(pdev,
NULL);
399 .name =
"wm831x-touch",
402 .probe = wm831x_ts_probe,