14 #include <linux/module.h>
15 #include <linux/kernel.h>
19 #include <linux/input.h>
22 #include <linux/slab.h>
24 #define DA9034_MANUAL_CTRL 0x50
25 #define DA9034_LDO_ADC_EN (1 << 4)
27 #define DA9034_AUTO_CTRL1 0x51
29 #define DA9034_AUTO_CTRL2 0x52
30 #define DA9034_AUTO_TSI_EN (1 << 3)
31 #define DA9034_PEN_DETECT (1 << 4)
33 #define DA9034_TSI_CTRL1 0x53
34 #define DA9034_TSI_CTRL2 0x54
35 #define DA9034_TSI_X_MSB 0x6c
36 #define DA9034_TSI_Y_MSB 0x6d
37 #define DA9034_TSI_XY_LSB 0x6e
70 static inline int is_pen_down(
struct da9034_touch *touch)
75 static inline int detect_pen_down(
struct da9034_touch *touch,
int on)
102 touch->
last_x = ((_x << 2) & 0x3fc) | (_v & 0x3);
103 touch->
last_y = ((_y << 2) & 0x3fc) | ((_v & 0xc) >> 2);
120 static inline void report_pen_down(
struct da9034_touch *touch)
139 static inline void report_pen_up(
struct da9034_touch *touch)
149 switch (touch->
state) {
157 err = start_tsi(touch);
168 err = read_tsi(touch);
175 err = stop_tsi(touch);
187 da9034_event_handler(touch,
194 report_pen_down(touch);
201 report_pen_up(touch);
210 if (is_pen_down(touch)) {
214 report_pen_up(touch);
224 detect_pen_down(touch, 1);
236 unsigned long event,
void *
data)
276 detect_pen_down(touch, 1);
281 static void da9034_touch_close(
struct input_dev *dev)
292 detect_pen_down(touch, 0);
304 struct input_dev *input_dev;
309 dev_err(&pdev->
dev,
"failed to allocate driver data\n");
324 touch->
notifier.notifier_call = da9034_touch_notifier;
326 input_dev = input_allocate_device();
328 dev_err(&pdev->
dev,
"failed to allocate input device\n");
333 input_dev->name = pdev->
name;
334 input_dev->open = da9034_touch_open;
335 input_dev->close = da9034_touch_close;
336 input_dev->dev.parent = &pdev->
dev;
341 input_set_abs_params(input_dev,
ABS_X, 0, 1023, 0, 0);
342 input_set_abs_params(input_dev,
ABS_Y, 0, 1023, 0, 0);
348 input_set_drvdata(input_dev, touch);
350 ret = input_register_device(input_dev);
354 platform_set_drvdata(pdev, touch);
358 input_free_device(input_dev);
366 struct da9034_touch *touch = platform_get_drvdata(pdev);
368 input_unregister_device(touch->
input_dev);
376 .name =
"da9034-touch",
379 .probe = da9034_touch_probe,