2 * wm97xx-core.c -- Touch screen driver core for Wolfson WM9705, WM9712
3 * and WM9713 AC97 Codecs.
5 * Copyright 2003, 2004, 2005, 2006, 2007, 2008 Wolfson Microelectronics PLC.
6 * Author: Liam Girdwood <lrg@slimlogic.co.uk>
7 * Parts Copyright : Ian Molton <spyro@f2s.com>
8 * Andrew Zabolotny <zap@homelink.ru>
9 * Russell King <rmk@arm.linux.org.uk>
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
19 * - supports WM9705, WM9712, WM9713
21 * - continuous mode (arch-dependent)
22 * - adjustable rpu/dpp settings
23 * - adjustable pressure current
24 * - adjustable sample settle delay
25 * - 4 and 5 wire touchscreens (5 wire is WM9712 only)
26 * - pen down detection
31 * - codec event notification
33 * - Support for async sampling control for noisy LCDs.
37 #include <linux/module.h>
38 #include <linux/moduleparam.h>
39 #include <linux/kernel.h>
40 #include <linux/init.h>
41 #include <linux/delay.h>
42 #include <linux/string.h>
43 #include <linux/proc_fs.h>
45 #include <linux/interrupt.h>
46 #include <linux/bitops.h>
47 #include <linux/workqueue.h>
48 #include <linux/wm97xx.h>
49 #include <linux/uaccess.h>
51 #include <linux/slab.h>
53 #define TS_NAME "wm97xx"
54 #define WM_CORE_VERSION "1.00"
55 #define DEFAULT_PRESSURE 0xb0c0
59 * Touchscreen absolute values
61 * These parameters are used to help the input layer discard out of
62 * range readings and reduce jitter etc.
64 * o min, max:- indicate the min and max values your touch screen returns
65 * o fuzz:- use a higher number to reduce jitter
67 * The default values correspond to Mainstone II in QVGA mode
70 * Documentation/input/input-programming.txt for more details.
73 static int abs_x
[3] = {350, 3900, 5};
74 module_param_array(abs_x
, int, NULL
, 0);
75 MODULE_PARM_DESC(abs_x
, "Touchscreen absolute X min, max, fuzz");
77 static int abs_y
[3] = {320, 3750, 40};
78 module_param_array(abs_y
, int, NULL
, 0);
79 MODULE_PARM_DESC(abs_y
, "Touchscreen absolute Y min, max, fuzz");
81 static int abs_p
[3] = {0, 150, 4};
82 module_param_array(abs_p
, int, NULL
, 0);
83 MODULE_PARM_DESC(abs_p
, "Touchscreen absolute Pressure min, max, fuzz");
86 * wm97xx IO access, all IO locking done by AC97 layer
88 int wm97xx_reg_read(struct wm97xx
*wm
, u16 reg
)
91 return wm
->ac97
->bus
->ops
->read(wm
->ac97
, reg
);
95 EXPORT_SYMBOL_GPL(wm97xx_reg_read
);
97 void wm97xx_reg_write(struct wm97xx
*wm
, u16 reg
, u16 val
)
99 /* cache digitiser registers */
100 if (reg
>= AC97_WM9713_DIG1
&& reg
<= AC97_WM9713_DIG3
)
101 wm
->dig
[(reg
- AC97_WM9713_DIG1
) >> 1] = val
;
103 /* cache gpio regs */
104 if (reg
>= AC97_GPIO_CFG
&& reg
<= AC97_MISC_AFE
)
105 wm
->gpio
[(reg
- AC97_GPIO_CFG
) >> 1] = val
;
112 wm
->ac97
->bus
->ops
->write(wm
->ac97
, reg
, val
);
114 EXPORT_SYMBOL_GPL(wm97xx_reg_write
);
117 * wm97xx_read_aux_adc - Read the aux adc.
118 * @wm: wm97xx device.
119 * @adcsel: codec ADC to be read
121 * Reads the selected AUX ADC.
124 int wm97xx_read_aux_adc(struct wm97xx
*wm
, u16 adcsel
)
126 int power_adc
= 0, auxval
;
132 mutex_lock(&wm
->codec_mutex
);
134 /* When the touchscreen is not in use, we may have to power up
135 * the AUX ADC before we can use sample the AUX inputs->
137 if (wm
->id
== WM9713_ID2
&&
138 (power
= wm97xx_reg_read(wm
, AC97_EXTENDED_MID
)) & 0x8000) {
140 wm97xx_reg_write(wm
, AC97_EXTENDED_MID
, power
& 0x7fff);
143 /* Prepare the codec for AUX reading */
144 wm
->codec
->aux_prepare(wm
);
146 /* Turn polling mode on to read AUX ADC */
147 wm
->pen_probably_down
= 1;
149 while (rc
!= RC_VALID
&& timeout
++ < 5)
150 rc
= wm
->codec
->poll_sample(wm
, adcsel
, &auxval
);
153 wm97xx_reg_write(wm
, AC97_EXTENDED_MID
, power
| 0x8000);
155 wm
->codec
->dig_restore(wm
);
157 wm
->pen_probably_down
= 0;
161 "timeout reading auxadc %d, disabling digitiser\n",
163 wm
->codec
->dig_enable(wm
, false);
166 mutex_unlock(&wm
->codec_mutex
);
167 return (rc
== RC_VALID
? auxval
& 0xfff : -EBUSY
);
169 EXPORT_SYMBOL_GPL(wm97xx_read_aux_adc
);
172 * wm97xx_get_gpio - Get the status of a codec GPIO.
173 * @wm: wm97xx device.
176 * Get the status of a codec GPIO pin
179 enum wm97xx_gpio_status
wm97xx_get_gpio(struct wm97xx
*wm
, u32 gpio
)
182 enum wm97xx_gpio_status ret
;
184 mutex_lock(&wm
->codec_mutex
);
185 status
= wm97xx_reg_read(wm
, AC97_GPIO_STATUS
);
188 ret
= WM97XX_GPIO_HIGH
;
190 ret
= WM97XX_GPIO_LOW
;
192 mutex_unlock(&wm
->codec_mutex
);
195 EXPORT_SYMBOL_GPL(wm97xx_get_gpio
);
198 * wm97xx_set_gpio - Set the status of a codec GPIO.
199 * @wm: wm97xx device.
203 * Set the status of a codec GPIO pin
206 void wm97xx_set_gpio(struct wm97xx
*wm
, u32 gpio
,
207 enum wm97xx_gpio_status status
)
211 mutex_lock(&wm
->codec_mutex
);
212 reg
= wm97xx_reg_read(wm
, AC97_GPIO_STATUS
);
214 if (status
== WM97XX_GPIO_HIGH
)
219 if (wm
->id
== WM9712_ID2
&& wm
->variant
!= WM97xx_WM1613
)
220 wm97xx_reg_write(wm
, AC97_GPIO_STATUS
, reg
<< 1);
222 wm97xx_reg_write(wm
, AC97_GPIO_STATUS
, reg
);
223 mutex_unlock(&wm
->codec_mutex
);
225 EXPORT_SYMBOL_GPL(wm97xx_set_gpio
);
228 * Codec GPIO pin configuration, this sets pin direction, polarity,
229 * stickyness and wake up.
231 void wm97xx_config_gpio(struct wm97xx
*wm
, u32 gpio
, enum wm97xx_gpio_dir dir
,
232 enum wm97xx_gpio_pol pol
, enum wm97xx_gpio_sticky sticky
,
233 enum wm97xx_gpio_wake wake
)
237 mutex_lock(&wm
->codec_mutex
);
238 reg
= wm97xx_reg_read(wm
, AC97_GPIO_POLARITY
);
240 if (pol
== WM97XX_GPIO_POL_HIGH
)
245 wm97xx_reg_write(wm
, AC97_GPIO_POLARITY
, reg
);
246 reg
= wm97xx_reg_read(wm
, AC97_GPIO_STICKY
);
248 if (sticky
== WM97XX_GPIO_STICKY
)
253 wm97xx_reg_write(wm
, AC97_GPIO_STICKY
, reg
);
254 reg
= wm97xx_reg_read(wm
, AC97_GPIO_WAKEUP
);
256 if (wake
== WM97XX_GPIO_WAKE
)
261 wm97xx_reg_write(wm
, AC97_GPIO_WAKEUP
, reg
);
262 reg
= wm97xx_reg_read(wm
, AC97_GPIO_CFG
);
264 if (dir
== WM97XX_GPIO_IN
)
269 wm97xx_reg_write(wm
, AC97_GPIO_CFG
, reg
);
270 mutex_unlock(&wm
->codec_mutex
);
272 EXPORT_SYMBOL_GPL(wm97xx_config_gpio
);
275 * Configure the WM97XX_PRP value to use while system is suspended.
276 * If a value other than 0 is set then WM97xx pen detection will be
277 * left enabled in the configured mode while the system is in suspend,
278 * the device has users and suspend has not been disabled via the
279 * wakeup sysfs entries.
281 * @wm: WM97xx device to configure
282 * @mode: WM97XX_PRP value to configure while suspended
284 void wm97xx_set_suspend_mode(struct wm97xx
*wm
, u16 mode
)
286 wm
->suspend_mode
= mode
;
287 device_init_wakeup(&wm
->input_dev
->dev
, mode
!= 0);
289 EXPORT_SYMBOL_GPL(wm97xx_set_suspend_mode
);
292 * Handle a pen down interrupt.
294 static void wm97xx_pen_irq_worker(struct work_struct
*work
)
296 struct wm97xx
*wm
= container_of(work
, struct wm97xx
, pen_event_work
);
297 int pen_was_down
= wm
->pen_is_down
;
299 /* do we need to enable the touch panel reader */
300 if (wm
->id
== WM9705_ID2
) {
301 if (wm97xx_reg_read(wm
, AC97_WM97XX_DIGITISER_RD
) &
308 mutex_lock(&wm
->codec_mutex
);
309 status
= wm97xx_reg_read(wm
, AC97_GPIO_STATUS
);
310 pol
= wm97xx_reg_read(wm
, AC97_GPIO_POLARITY
);
312 if (WM97XX_GPIO_13
& pol
& status
) {
314 wm97xx_reg_write(wm
, AC97_GPIO_POLARITY
, pol
&
318 wm97xx_reg_write(wm
, AC97_GPIO_POLARITY
, pol
|
322 if (wm
->id
== WM9712_ID2
&& wm
->variant
!= WM97xx_WM1613
)
323 wm97xx_reg_write(wm
, AC97_GPIO_STATUS
, (status
&
324 ~WM97XX_GPIO_13
) << 1);
326 wm97xx_reg_write(wm
, AC97_GPIO_STATUS
, status
&
328 mutex_unlock(&wm
->codec_mutex
);
331 /* If the system is not using continuous mode or it provides a
332 * pen down operation then we need to schedule polls while the
333 * pen is down. Otherwise the machine driver is responsible
334 * for scheduling reads.
336 if (!wm
->mach_ops
->acc_enabled
|| wm
->mach_ops
->acc_pen_down
) {
337 if (wm
->pen_is_down
&& !pen_was_down
) {
338 /* Data is not available immediately on pen down */
339 queue_delayed_work(wm
->ts_workq
, &wm
->ts_reader
, 1);
342 /* Let ts_reader report the pen up for debounce. */
343 if (!wm
->pen_is_down
&& pen_was_down
)
347 if (!wm
->pen_is_down
&& wm
->mach_ops
->acc_enabled
)
348 wm
->mach_ops
->acc_pen_up(wm
);
350 wm
->mach_ops
->irq_enable(wm
, 1);
354 * Codec PENDOWN irq handler
356 * We have to disable the codec interrupt in the handler because it
357 * can take up to 1ms to clear the interrupt source. We schedule a task
358 * in a work queue to do the actual interaction with the chip. The
359 * interrupt is then enabled again in the slow handler when the source
362 static irqreturn_t
wm97xx_pen_interrupt(int irq
, void *dev_id
)
364 struct wm97xx
*wm
= dev_id
;
366 if (!work_pending(&wm
->pen_event_work
)) {
367 wm
->mach_ops
->irq_enable(wm
, 0);
368 queue_work(wm
->ts_workq
, &wm
->pen_event_work
);
375 * initialise pen IRQ handler and workqueue
377 static int wm97xx_init_pen_irq(struct wm97xx
*wm
)
381 /* If an interrupt is supplied an IRQ enable operation must also be
383 BUG_ON(!wm
->mach_ops
->irq_enable
);
385 if (request_irq(wm
->pen_irq
, wm97xx_pen_interrupt
, IRQF_SHARED
,
388 "Failed to register pen down interrupt, polling");
393 /* Configure GPIO as interrupt source on WM971x */
394 if (wm
->id
!= WM9705_ID2
) {
395 BUG_ON(!wm
->mach_ops
->irq_gpio
);
396 reg
= wm97xx_reg_read(wm
, AC97_MISC_AFE
);
397 wm97xx_reg_write(wm
, AC97_MISC_AFE
,
398 reg
& ~(wm
->mach_ops
->irq_gpio
));
399 reg
= wm97xx_reg_read(wm
, 0x5a);
400 wm97xx_reg_write(wm
, 0x5a, reg
& ~0x0001);
406 static int wm97xx_read_samples(struct wm97xx
*wm
)
408 struct wm97xx_data data
;
411 mutex_lock(&wm
->codec_mutex
);
413 if (wm
->mach_ops
&& wm
->mach_ops
->acc_enabled
)
414 rc
= wm
->mach_ops
->acc_pen_down(wm
);
416 rc
= wm
->codec
->poll_touch(wm
, &data
);
419 if (wm
->pen_is_down
) {
421 dev_dbg(wm
->dev
, "pen up\n");
422 input_report_abs(wm
->input_dev
, ABS_PRESSURE
, 0);
423 input_report_key(wm
->input_dev
, BTN_TOUCH
, 0);
424 input_sync(wm
->input_dev
);
425 } else if (!(rc
& RC_AGAIN
)) {
426 /* We need high frequency updates only while
427 * pen is down, the user never will be able to
428 * touch screen faster than a few times per
429 * second... On the other hand, when the user
430 * is actively working with the touchscreen we
431 * don't want to lose the quick response. So we
432 * will slowly increase sleep time after the
433 * pen is up and quicky restore it to ~one task
434 * switch when pen is down again.
436 if (wm
->ts_reader_interval
< HZ
/ 10)
437 wm
->ts_reader_interval
++;
440 } else if (rc
& RC_VALID
) {
442 "pen down: x=%x:%d, y=%x:%d, pressure=%x:%d\n",
443 data
.x
>> 12, data
.x
& 0xfff, data
.y
>> 12,
444 data
.y
& 0xfff, data
.p
>> 12, data
.p
& 0xfff);
445 input_report_abs(wm
->input_dev
, ABS_X
, data
.x
& 0xfff);
446 input_report_abs(wm
->input_dev
, ABS_Y
, data
.y
& 0xfff);
447 input_report_abs(wm
->input_dev
, ABS_PRESSURE
, data
.p
& 0xfff);
448 input_report_key(wm
->input_dev
, BTN_TOUCH
, 1);
449 input_sync(wm
->input_dev
);
451 wm
->ts_reader_interval
= wm
->ts_reader_min_interval
;
452 } else if (rc
& RC_PENDOWN
) {
453 dev_dbg(wm
->dev
, "pen down\n");
455 wm
->ts_reader_interval
= wm
->ts_reader_min_interval
;
458 mutex_unlock(&wm
->codec_mutex
);
463 * The touchscreen sample reader.
465 static void wm97xx_ts_reader(struct work_struct
*work
)
468 struct wm97xx
*wm
= container_of(work
, struct wm97xx
, ts_reader
.work
);
473 rc
= wm97xx_read_samples(wm
);
474 } while (rc
& RC_AGAIN
);
476 if (wm
->pen_is_down
|| !wm
->pen_irq
)
477 queue_delayed_work(wm
->ts_workq
, &wm
->ts_reader
,
478 wm
->ts_reader_interval
);
482 * wm97xx_ts_input_open - Open the touch screen input device.
483 * @idev: Input device to be opened.
485 * Called by the input sub system to open a wm97xx touchscreen device.
486 * Starts the touchscreen thread and touch digitiser.
488 static int wm97xx_ts_input_open(struct input_dev
*idev
)
490 struct wm97xx
*wm
= input_get_drvdata(idev
);
492 wm
->ts_workq
= create_singlethread_workqueue("kwm97xx");
493 if (wm
->ts_workq
== NULL
) {
495 "Failed to create workqueue\n");
499 /* start digitiser */
500 if (wm
->mach_ops
&& wm
->mach_ops
->acc_enabled
)
501 wm
->codec
->acc_enable(wm
, 1);
502 wm
->codec
->dig_enable(wm
, 1);
504 INIT_DELAYED_WORK(&wm
->ts_reader
, wm97xx_ts_reader
);
505 INIT_WORK(&wm
->pen_event_work
, wm97xx_pen_irq_worker
);
507 wm
->ts_reader_min_interval
= HZ
>= 100 ? HZ
/ 100 : 1;
508 if (wm
->ts_reader_min_interval
< 1)
509 wm
->ts_reader_min_interval
= 1;
510 wm
->ts_reader_interval
= wm
->ts_reader_min_interval
;
514 wm97xx_init_pen_irq(wm
);
516 dev_err(wm
->dev
, "No IRQ specified\n");
518 /* If we either don't have an interrupt for pen down events or
519 * failed to acquire it then we need to poll.
521 if (wm
->pen_irq
== 0)
522 queue_delayed_work(wm
->ts_workq
, &wm
->ts_reader
,
523 wm
->ts_reader_interval
);
529 * wm97xx_ts_input_close - Close the touch screen input device.
530 * @idev: Input device to be closed.
532 * Called by the input sub system to close a wm97xx touchscreen
533 * device. Kills the touchscreen thread and stops the touch
537 static void wm97xx_ts_input_close(struct input_dev
*idev
)
539 struct wm97xx
*wm
= input_get_drvdata(idev
);
543 /* Return the interrupt to GPIO usage (disabling it) */
544 if (wm
->id
!= WM9705_ID2
) {
545 BUG_ON(!wm
->mach_ops
->irq_gpio
);
546 reg
= wm97xx_reg_read(wm
, AC97_MISC_AFE
);
547 wm97xx_reg_write(wm
, AC97_MISC_AFE
,
548 reg
| wm
->mach_ops
->irq_gpio
);
551 free_irq(wm
->pen_irq
, wm
);
556 /* Balance out interrupt disables/enables */
557 if (cancel_work_sync(&wm
->pen_event_work
))
558 wm
->mach_ops
->irq_enable(wm
, 1);
560 /* ts_reader rearms itself so we need to explicitly stop it
561 * before we destroy the workqueue.
563 cancel_delayed_work_sync(&wm
->ts_reader
);
565 destroy_workqueue(wm
->ts_workq
);
568 wm
->codec
->dig_enable(wm
, 0);
569 if (wm
->mach_ops
&& wm
->mach_ops
->acc_enabled
)
570 wm
->codec
->acc_enable(wm
, 0);
573 static int wm97xx_probe(struct device
*dev
)
576 struct wm97xx_pdata
*pdata
= dev
->platform_data
;
579 wm
= kzalloc(sizeof(struct wm97xx
), GFP_KERNEL
);
582 mutex_init(&wm
->codec_mutex
);
585 dev_set_drvdata(dev
, wm
);
586 wm
->ac97
= to_ac97_t(dev
);
588 /* check that we have a supported codec */
589 id
= wm97xx_reg_read(wm
, AC97_VENDOR_ID1
);
590 if (id
!= WM97XX_ID1
) {
591 dev_err(dev
, "Device with vendor %04x is not a wm97xx\n", id
);
596 wm
->id
= wm97xx_reg_read(wm
, AC97_VENDOR_ID2
);
598 wm
->variant
= WM97xx_GENERIC
;
600 dev_info(wm
->dev
, "detected a wm97%02x codec\n", wm
->id
& 0xff);
602 switch (wm
->id
& 0xff) {
603 #ifdef CONFIG_TOUCHSCREEN_WM9705
605 wm
->codec
= &wm9705_codec
;
608 #ifdef CONFIG_TOUCHSCREEN_WM9712
610 wm
->codec
= &wm9712_codec
;
613 #ifdef CONFIG_TOUCHSCREEN_WM9713
615 wm
->codec
= &wm9713_codec
;
619 dev_err(wm
->dev
, "Support for wm97%02x not compiled in.\n",
625 /* set up physical characteristics */
626 wm
->codec
->phy_init(wm
);
628 /* load gpio cache */
629 wm
->gpio
[0] = wm97xx_reg_read(wm
, AC97_GPIO_CFG
);
630 wm
->gpio
[1] = wm97xx_reg_read(wm
, AC97_GPIO_POLARITY
);
631 wm
->gpio
[2] = wm97xx_reg_read(wm
, AC97_GPIO_STICKY
);
632 wm
->gpio
[3] = wm97xx_reg_read(wm
, AC97_GPIO_WAKEUP
);
633 wm
->gpio
[4] = wm97xx_reg_read(wm
, AC97_GPIO_STATUS
);
634 wm
->gpio
[5] = wm97xx_reg_read(wm
, AC97_MISC_AFE
);
636 wm
->input_dev
= input_allocate_device();
637 if (wm
->input_dev
== NULL
) {
642 /* set up touch configuration */
643 wm
->input_dev
->name
= "wm97xx touchscreen";
644 wm
->input_dev
->phys
= "wm97xx";
645 wm
->input_dev
->open
= wm97xx_ts_input_open
;
646 wm
->input_dev
->close
= wm97xx_ts_input_close
;
648 __set_bit(EV_ABS
, wm
->input_dev
->evbit
);
649 __set_bit(EV_KEY
, wm
->input_dev
->evbit
);
650 __set_bit(BTN_TOUCH
, wm
->input_dev
->keybit
);
652 input_set_abs_params(wm
->input_dev
, ABS_X
, abs_x
[0], abs_x
[1],
654 input_set_abs_params(wm
->input_dev
, ABS_Y
, abs_y
[0], abs_y
[1],
656 input_set_abs_params(wm
->input_dev
, ABS_PRESSURE
, abs_p
[0], abs_p
[1],
659 input_set_drvdata(wm
->input_dev
, wm
);
660 wm
->input_dev
->dev
.parent
= dev
;
662 ret
= input_register_device(wm
->input_dev
);
666 /* register our battery device */
667 wm
->battery_dev
= platform_device_alloc("wm97xx-battery", -1);
668 if (!wm
->battery_dev
) {
672 platform_set_drvdata(wm
->battery_dev
, wm
);
673 wm
->battery_dev
->dev
.parent
= dev
;
674 wm
->battery_dev
->dev
.platform_data
= pdata
;
675 ret
= platform_device_add(wm
->battery_dev
);
679 /* register our extended touch device (for machine specific
681 wm
->touch_dev
= platform_device_alloc("wm97xx-touch", -1);
682 if (!wm
->touch_dev
) {
686 platform_set_drvdata(wm
->touch_dev
, wm
);
687 wm
->touch_dev
->dev
.parent
= dev
;
688 wm
->touch_dev
->dev
.platform_data
= pdata
;
689 ret
= platform_device_add(wm
->touch_dev
);
696 platform_device_put(wm
->touch_dev
);
698 platform_device_del(wm
->battery_dev
);
700 platform_device_put(wm
->battery_dev
);
702 input_unregister_device(wm
->input_dev
);
703 wm
->input_dev
= NULL
;
705 input_free_device(wm
->input_dev
);
712 static int wm97xx_remove(struct device
*dev
)
714 struct wm97xx
*wm
= dev_get_drvdata(dev
);
716 platform_device_unregister(wm
->battery_dev
);
717 platform_device_unregister(wm
->touch_dev
);
718 input_unregister_device(wm
->input_dev
);
725 static int wm97xx_suspend(struct device
*dev
, pm_message_t state
)
727 struct wm97xx
*wm
= dev_get_drvdata(dev
);
731 if (device_may_wakeup(&wm
->input_dev
->dev
))
732 suspend_mode
= wm
->suspend_mode
;
736 if (wm
->input_dev
->users
)
737 cancel_delayed_work_sync(&wm
->ts_reader
);
739 /* Power down the digitiser (bypassing the cache for resume) */
740 reg
= wm97xx_reg_read(wm
, AC97_WM97XX_DIGITISER2
);
741 reg
&= ~WM97XX_PRP_DET_DIG
;
742 if (wm
->input_dev
->users
)
744 wm
->ac97
->bus
->ops
->write(wm
->ac97
, AC97_WM97XX_DIGITISER2
, reg
);
746 /* WM9713 has an additional power bit - turn it off if there
747 * are no users or if suspend mode is zero. */
748 if (wm
->id
== WM9713_ID2
&&
749 (!wm
->input_dev
->users
|| !suspend_mode
)) {
750 reg
= wm97xx_reg_read(wm
, AC97_EXTENDED_MID
) | 0x8000;
751 wm97xx_reg_write(wm
, AC97_EXTENDED_MID
, reg
);
757 static int wm97xx_resume(struct device
*dev
)
759 struct wm97xx
*wm
= dev_get_drvdata(dev
);
761 /* restore digitiser and gpios */
762 if (wm
->id
== WM9713_ID2
) {
763 wm97xx_reg_write(wm
, AC97_WM9713_DIG1
, wm
->dig
[0]);
764 wm97xx_reg_write(wm
, 0x5a, wm
->misc
);
765 if (wm
->input_dev
->users
) {
767 reg
= wm97xx_reg_read(wm
, AC97_EXTENDED_MID
) & 0x7fff;
768 wm97xx_reg_write(wm
, AC97_EXTENDED_MID
, reg
);
772 wm97xx_reg_write(wm
, AC97_WM9713_DIG2
, wm
->dig
[1]);
773 wm97xx_reg_write(wm
, AC97_WM9713_DIG3
, wm
->dig
[2]);
775 wm97xx_reg_write(wm
, AC97_GPIO_CFG
, wm
->gpio
[0]);
776 wm97xx_reg_write(wm
, AC97_GPIO_POLARITY
, wm
->gpio
[1]);
777 wm97xx_reg_write(wm
, AC97_GPIO_STICKY
, wm
->gpio
[2]);
778 wm97xx_reg_write(wm
, AC97_GPIO_WAKEUP
, wm
->gpio
[3]);
779 wm97xx_reg_write(wm
, AC97_GPIO_STATUS
, wm
->gpio
[4]);
780 wm97xx_reg_write(wm
, AC97_MISC_AFE
, wm
->gpio
[5]);
782 if (wm
->input_dev
->users
&& !wm
->pen_irq
) {
783 wm
->ts_reader_interval
= wm
->ts_reader_min_interval
;
784 queue_delayed_work(wm
->ts_workq
, &wm
->ts_reader
,
785 wm
->ts_reader_interval
);
792 #define wm97xx_suspend NULL
793 #define wm97xx_resume NULL
797 * Machine specific operations
799 int wm97xx_register_mach_ops(struct wm97xx
*wm
,
800 struct wm97xx_mach_ops
*mach_ops
)
802 mutex_lock(&wm
->codec_mutex
);
804 mutex_unlock(&wm
->codec_mutex
);
807 wm
->mach_ops
= mach_ops
;
808 mutex_unlock(&wm
->codec_mutex
);
812 EXPORT_SYMBOL_GPL(wm97xx_register_mach_ops
);
814 void wm97xx_unregister_mach_ops(struct wm97xx
*wm
)
816 mutex_lock(&wm
->codec_mutex
);
818 mutex_unlock(&wm
->codec_mutex
);
820 EXPORT_SYMBOL_GPL(wm97xx_unregister_mach_ops
);
822 static struct device_driver wm97xx_driver
= {
824 .bus
= &ac97_bus_type
,
825 .owner
= THIS_MODULE
,
826 .probe
= wm97xx_probe
,
827 .remove
= wm97xx_remove
,
828 .suspend
= wm97xx_suspend
,
829 .resume
= wm97xx_resume
,
832 static int __init
wm97xx_init(void)
834 return driver_register(&wm97xx_driver
);
837 static void __exit
wm97xx_exit(void)
839 driver_unregister(&wm97xx_driver
);
842 module_init(wm97xx_init
);
843 module_exit(wm97xx_exit
);
845 /* Module information */
846 MODULE_AUTHOR("Liam Girdwood <lrg@slimlogic.co.uk>");
847 MODULE_DESCRIPTION("WM97xx Core - Touch Screen / AUX ADC / GPIO Driver");
848 MODULE_LICENSE("GPL");