11 #include <linux/kernel.h>
12 #include <linux/module.h>
15 #include <linux/i2c.h>
16 #include <linux/input.h>
18 #include <linux/slab.h>
21 #define ACCURATE_BIT (12)
24 #define MEAS_EN3 (0x52)
26 #define MEAS_TSIX_1 (0x8D)
27 #define MEAS_TSIX_2 (0x8E)
28 #define MEAS_TSIY_1 (0x8F)
29 #define MEAS_TSIY_2 (0x90)
30 #define MEAS_TSIZ1_1 (0x91)
31 #define MEAS_TSIZ1_2 (0x92)
32 #define MEAS_TSIZ2_1 (0x93)
33 #define MEAS_TSIZ2_2 (0x94)
36 #define MEAS_PD_EN (1 << 3)
37 #define MEAS_TSIX_EN (1 << 4)
38 #define MEAS_TSIY_EN (1 << 5)
39 #define MEAS_TSIZ1_EN (1 << 6)
40 #define MEAS_TSIZ2_EN (1 << 7)
63 pen_down = buf[1] & (1 << 6);
64 x = ((buf[0] & 0xFF) << 4) | (buf[1] & 0x0F);
65 y = ((buf[2] & 0xFF) << 4) | (buf[3] & 0x0F);
66 z1 = ((buf[4] & 0xFF) << 4) | (buf[5] & 0x0F);
67 z2 = ((buf[6] & 0xFF) << 4) | (buf[7] & 0x0F);
70 if ((x != 0) && (z1 != 0) && (touch->
res_x != 0)) {
80 dev_dbg(chip->
dev,
"pen down at [%d, %d].\n", x, y);
86 input_sync(touch->
idev);
92 static int pm860x_touch_open(
struct input_dev *
dev)
107 static void pm860x_touch_close(
struct input_dev *dev)
130 dev_err(&pdev->
dev,
"Can't find touch node\n");
135 if (!of_property_read_u32(np,
"marvell,88pm860x-gpadc-prebias", &
n))
137 if (!of_property_read_u32(np,
"marvell,88pm860x-gpadc-slot-cycle", &
n))
139 if (!of_property_read_u32(np,
"marvell,88pm860x-gpadc-off-scale", &
n))
141 if (!of_property_read_u32(np,
"marvell,88pm860x-gpadc-sw-cal", &
n))
149 if (!of_property_read_u32(np,
"marvell,88pm860x-tsi-prebias", &data)) {
156 if (!of_property_read_u32(np,
"marvell,88pm860x-pen-prebias", &
n))
158 if (!of_property_read_u32(np,
"marvell,88pm860x-pen-prechg", &
n))
165 of_property_read_u32(np,
"marvell,88pm860x-resistor-X", res_x);
169 #define pm860x_touch_dt_init(x, y, z) (-1)
179 int irq, ret, res_x = 0, data = 0;
197 data |= (pdata->
sw_cal << 7)
218 & PM8607_PD_PRECHG_MASK;
225 res_x = pdata->
res_x;
227 dev_err(&pdev->
dev,
"failed to get platform data\n");
242 touch->
idev = input_allocate_device();
244 dev_err(&pdev->
dev,
"Failed to allocate input device!\n");
249 touch->
idev->name =
"88pm860x-touch";
250 touch->
idev->phys =
"88pm860x/input0";
252 touch->
idev->dev.parent = &pdev->
dev;
253 touch->
idev->open = pm860x_touch_open;
254 touch->
idev->close = pm860x_touch_close;
258 touch->
res_x = res_x;
259 input_set_drvdata(touch->
idev, touch);
279 ret = input_register_device(touch->
idev);
281 dev_err(chip->
dev,
"Failed to register touch!\n");
285 platform_set_drvdata(pdev, touch);
290 input_free_device(touch->
idev);
298 struct pm860x_touch *touch = platform_get_drvdata(pdev);
300 input_unregister_device(touch->
idev);
302 platform_set_drvdata(pdev,
NULL);
309 .name =
"88pm860x-touch",
312 .probe = pm860x_touch_probe,