1 Index: linux-tosa/drivers/input/touchscreen/wm9712.c
2 ===================================================================
3 --- linux-tosa.orig/drivers/input/touchscreen/wm9712.c 2006-08-29 16:52:36.008543280 +0100
4 +++ linux-tosa/drivers/input/touchscreen/wm9712.c 2006-08-29 16:52:50.923275896 +0100
7 * wm9712.c -- Codec driver for Wolfson WM9712 AC97 Codecs.
9 - * Copyright 2003, 2004, 2005 Wolfson Microelectronics PLC.
10 + * Copyright 2003, 2004, 2005, 2006 Wolfson Microelectronics PLC.
11 * Author: Liam Girdwood
12 * liam.girdwood@wolfsonmicro.com or linux@wolfsonmicro.com
13 * Parts Copyright : Ian Molton <spyro@f2s.com>
15 * Free Software Foundation; either version 2 of the License, or (at your
16 * option) any later version.
19 + * 4th Jul 2005 Initial version.
20 + * 29th Aug 2006 Mike Arthur <mike@mikearthur.co.uk>
21 + * Added fixes for Sharp SL-6000 (Tosa) LCD noise causing
22 + * touchscreen interference.
26 #include <linux/module.h>
28 #define WM9705_VERSION "0.60"
29 #define DEFAULT_PRESSURE 0xb0c0
31 +#define CCNT(a) asm volatile ("mrc p14, 0, %0, C1, C1, 0" : "=r"(a))
32 +#define CCNT_ON() asm("mcr p14, 0, %0, C0, C0, 0" : : "r"(1))
33 +#define CCNT_OFF() asm("mcr p14, 0, %0, C0, C0, 0" : : "r"(1))
39 return wm->dig[2] & WM9712_PDEN;
43 +#ifdef CONFIG_MACH_TOSA
44 +/* On the Sharp SL-6000 (Tosa), due to a noisy LCD, we need to perform a wait
45 + * before sampling the Y axis of the touchscreen */
46 +static inline void wm9712_lcd_sync_on(struct wm97xx* wm, int adcsel) {
47 + unsigned long timer1 = 0, timer2 = 0, wait_time = 0;
48 + if (adcsel == WM97XX_ADCSEL_Y) {
49 + wait_time = wm97xx_calc_lcd_waittime(wm);
54 + /* wait for LCD rising edge */
55 + wm_machinfo->wait_hsync();
60 + while ((timer2 - timer1) < wait_time) {
67 +static inline void wm9712_lcd_sync_off(void) {
73 * Read a sample from the WM9712 adc in polling mode.
76 /* set up digitiser */
78 adcsel = ((adcsel & 0x7fff) + 3) << 12;
79 + #ifdef CONFIG_MACH_TOSA
80 + wm9712_lcd_sync_on(wm, adcsel);
82 wm97xx_reg_write(wm, AC97_WM97XX_DIGITISER1, adcsel | WM97XX_POLL | WM97XX_DELAY(delay));
84 /* wait 3 AC97 time slots + delay for conversion */
87 *sample = wm97xx_reg_read(wm, AC97_WM97XX_DIGITISER_RD);
89 + #ifdef CONFIG_MACH_TOSA
90 + wm9712_lcd_sync_off();
93 /* check we have correct sample */
94 if ((*sample & WM97XX_ADCSEL_MASK) != adcsel) {
95 dbg ("adc wrong sample, read %x got %x", adcsel,
97 static int wm9712_poll_touch(struct wm97xx* wm, struct wm97xx_data *data)
101 if ((rc = wm9712_poll_sample(wm, WM97XX_ADCSEL_X, &data->x)) != RC_VALID)
104 if ((rc = wm9712_poll_sample(wm, WM97XX_ADCSEL_Y, &data->y)) != RC_VALID)
107 if (pil && !five_wire) {
108 if ((rc = wm9712_poll_sample(wm, WM97XX_ADCSEL_PRES, &data->p)) != RC_VALID)
110 Index: linux-tosa/drivers/input/touchscreen/wm97xx-core.c
111 ===================================================================
112 --- linux-tosa.orig/drivers/input/touchscreen/wm97xx-core.c 2006-08-29 16:52:36.008543280 +0100
113 +++ linux-tosa/drivers/input/touchscreen/wm97xx-core.c 2006-08-29 16:52:50.924275744 +0100
115 * wm97xx-core.c -- Touch screen driver core for Wolfson WM9705, WM9712
116 * and WM9713 AC97 Codecs.
118 - * Copyright 2003, 2004, 2005 Wolfson Microelectronics PLC.
119 + * Copyright 2003, 2004, 2005, 2006 Wolfson Microelectronics PLC.
120 * Author: Liam Girdwood
121 * liam.girdwood@wolfsonmicro.com or linux@wolfsonmicro.com
122 * Parts Copyright : Ian Molton <spyro@f2s.com>
124 * GPIOs) and 2.6 power management.
125 * 29th Nov 2004 Added WM9713 support.
126 * 4th Jul 2005 Moved codec specific code out to seperate files.
127 + * 29th Aug 2006 Mike Arthur <mike@mikearthur.co.uk>
128 + * Added fixes for Sharp SL-6000 (Tosa) LCD noise causing
129 + * touchscreen interference.
132 #include <linux/module.h>
134 static DECLARE_MUTEX(gpio_sem);
135 static LIST_HEAD(wm97xx_misc_list);
136 static struct wm97xx* wm_codec = NULL;
137 +struct wm97xx_machinfo *wm_machinfo;
140 * WM97xx - enable/disable AUX ADC sysfs
142 mdev->remove(wm_codec);
145 +#ifdef CONFIG_MACH_TOSA
146 +/* On the Sharp SL-6000 (Tosa), due to a noisy LCD, we need to perform a wait
147 + * before sampling the Y axis of the touchscreen */
148 +unsigned long wm97xx_calc_lcd_waittime(struct wm97xx *wm) {
149 + unsigned long hsync_time = wm_machinfo->get_hsync_time();
153 +void wm97xx_set_machinfo(struct wm97xx_machinfo *machinfo) {
154 + wm_machinfo = machinfo;
157 +void wm97xx_unset_machinfo() {
158 + wm_machinfo = NULL;
162 static struct device_driver wm97xx_driver = {
164 .bus = &ac97_bus_type,
166 EXPORT_SYMBOL_GPL(wm97xx_reg_write);
167 EXPORT_SYMBOL_GPL(wm97xx_register_misc_dev);
168 EXPORT_SYMBOL_GPL(wm97xx_unregister_misc_dev);
169 +EXPORT_SYMBOL_GPL(wm97xx_calc_lcd_waittime);
170 +EXPORT_SYMBOL_GPL(wm97xx_set_machinfo);
171 +EXPORT_SYMBOL_GPL(wm97xx_unset_machinfo);
173 module_init(wm97xx_init);
174 module_exit(wm97xx_exit);
175 Index: linux-tosa/include/linux/wm97xx.h
176 ===================================================================
177 --- linux-tosa.orig/include/linux/wm97xx.h 2006-08-29 16:52:36.008543280 +0100
178 +++ linux-tosa/include/linux/wm97xx.h 2006-08-29 16:52:50.924275744 +0100
182 extern struct wm97xx_codec_drv wm97xx_codec;
183 +extern struct wm97xx_machinfo *wm_machinfo;
186 * Codec driver interface - allows mapping to WM9705/12/13 and newer codecs
188 struct list_head list;
191 +struct wm97xx_machinfo {
192 + unsigned long (*get_hsync_time)(void);
193 + void (*wait_hsync)(void);
196 int wm97xx_register_misc_dev(struct wm97xx_misc_dev* mdev);
197 void wm97xx_unregister_misc_dev(struct wm97xx_misc_dev* mdev);
200 int wm97xx_acc_startup(struct wm97xx* wm);
201 void wm97xx_acc_shutdown(struct wm97xx* wm);
204 +unsigned long wm97xx_calc_lcd_waittime(struct wm97xx *wm);
205 +void wm97xx_set_machinfo(struct wm97xx_machinfo *machinfo);
206 +void wm97xx_unset_machinfo(void);