37 #include <linux/module.h>
39 #include <linux/kernel.h>
42 #include <linux/string.h>
46 #include <linux/bitops.h>
51 #include <linux/slab.h>
53 #define TS_NAME "wm97xx"
54 #define WM_CORE_VERSION "1.00"
55 #define DEFAULT_PRESSURE 0xb0c0
73 static int abs_x[3] = {350, 3900, 5};
77 static int abs_y[3] = {320, 3750, 40};
81 static int abs_p[3] = {0, 150, 4};
91 return wm->
ac97->bus->ops->read(wm->
ac97, reg);
112 wm->
ac97->bus->ops->write(wm->
ac97, reg, val);
126 int power_adc = 0, auxval;
144 wm->
codec->aux_prepare(wm);
149 while (rc !=
RC_VALID && timeout++ < 5)
150 rc = wm->
codec->poll_sample(wm, adcsel, &auxval);
155 wm->
codec->dig_restore(wm);
161 "timeout reading auxadc %d, disabling digitiser\n",
163 wm->
codec->dig_enable(wm,
false);
377 static int wm97xx_init_pen_irq(
struct wm97xx *wm)
388 "Failed to register pen down interrupt, polling");
406 static int wm97xx_read_samples(
struct wm97xx *wm)
414 rc = wm->
mach_ops->acc_pen_down(wm);
442 "pen down: x=%x:%d, y=%x:%d, pressure=%x:%d\n",
465 static void wm97xx_ts_reader(
struct work_struct *work)
473 rc = wm97xx_read_samples(wm);
474 }
while (rc & RC_AGAIN);
490 struct wm97xx *wm = input_get_drvdata(idev);
495 "Failed to create workqueue\n");
501 wm->
codec->acc_enable(wm, 1);
502 wm->
codec->dig_enable(wm, 1);
514 wm97xx_init_pen_irq(wm);
537 static void wm97xx_ts_input_close(
struct input_dev *idev)
539 struct wm97xx *wm = input_get_drvdata(idev);
568 wm->
codec->dig_enable(wm, 0);
570 wm->
codec->acc_enable(wm, 0);
573 static int wm97xx_probe(
struct device *
dev)
591 dev_err(dev,
"Device with vendor %04x is not a wm97xx\n",
id);
600 dev_info(wm->
dev,
"detected a wm97%02x codec\n", wm->
id & 0xff);
602 switch (wm->
id & 0xff) {
603 #ifdef CONFIG_TOUCHSCREEN_WM9705
608 #ifdef CONFIG_TOUCHSCREEN_WM9712
613 #ifdef CONFIG_TOUCHSCREEN_WM9713
619 dev_err(wm->
dev,
"Support for wm97%02x not compiled in.\n",
626 wm->
codec->phy_init(wm);
643 wm->
input_dev->name =
"wm97xx touchscreen";
645 wm->
input_dev->open = wm97xx_ts_input_open;
646 wm->
input_dev->close = wm97xx_ts_input_close;
662 ret = input_register_device(wm->
input_dev);
712 static int wm97xx_remove(
struct device *dev)
731 if (device_may_wakeup(&wm->
input_dev->dev))
749 (!wm->
input_dev->users || !suspend_mode)) {
792 #define wm97xx_suspend NULL
793 #define wm97xx_resume NULL
826 .probe = wm97xx_probe,
827 .remove = wm97xx_remove,
832 static int __init wm97xx_init(
void)
837 static void __exit wm97xx_exit(
void)