aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2008-04-02 00:51:21 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2008-04-02 00:51:21 -0400
commit9448cefc6689aa51f1cd1cfe8b701dc94789c7ee (patch)
treed6257aad45a5aae857622122dcc9fe8cb1c0380a
parentfebf1dff119ef27ee22a54d40f284d2454f00d8d (diff)
Input: WM97xx - add chip driver for WM9705 touchscreen
Signed-off-by: Liam Girdwood <liam.girdwood@wolfsonmicro.com> Signed-off-by: Graeme Gregory <gg@opensource.wolfsonmicro.com> Signed-off-by: Mike Arthur <mike.arthur@wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
-rw-r--r--drivers/input/touchscreen/Kconfig9
-rw-r--r--drivers/input/touchscreen/Makefile1
-rw-r--r--drivers/input/touchscreen/wm9705.c353
3 files changed, 363 insertions, 0 deletions
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index a95a87cd1d59..4939a96d12b9 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -199,6 +199,15 @@ config TOUCHSCREEN_WM97XX
199 To compile this driver as a module, choose M here: the 199 To compile this driver as a module, choose M here: the
200 module will be called wm97xx-ts. 200 module will be called wm97xx-ts.
201 201
202config TOUCHSCREEN_WM9705
203 bool "WM9705 Touchscreen interface support"
204 depends on TOUCHSCREEN_WM97XX
205 help
206 Say Y here if you have a Wolfson Microelectronics WM9705
207 touchscreen controller connected to your system.
208
209 If unsure, say N.
210
202config TOUCHSCREEN_USB_COMPOSITE 211config TOUCHSCREEN_USB_COMPOSITE
203 tristate "USB Touchscreen Driver" 212 tristate "USB Touchscreen Driver"
204 depends on USB_ARCH_HAS_HCD 213 depends on USB_ARCH_HAS_HCD
diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile
index b4e7b5dbf649..5829a435efd1 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -22,3 +22,4 @@ obj-$(CONFIG_TOUCHSCREEN_TOUCHRIGHT) += touchright.o
22obj-$(CONFIG_TOUCHSCREEN_TOUCHWIN) += touchwin.o 22obj-$(CONFIG_TOUCHSCREEN_TOUCHWIN) += touchwin.o
23obj-$(CONFIG_TOUCHSCREEN_UCB1400) += ucb1400_ts.o 23obj-$(CONFIG_TOUCHSCREEN_UCB1400) += ucb1400_ts.o
24obj-$(CONFIG_TOUCHSCREEN_WM97XX) += wm97xx-ts.o 24obj-$(CONFIG_TOUCHSCREEN_WM97XX) += wm97xx-ts.o
25wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9705) += wm9705.o
diff --git a/drivers/input/touchscreen/wm9705.c b/drivers/input/touchscreen/wm9705.c
new file mode 100644
index 000000000000..978e1a13ffc7
--- /dev/null
+++ b/drivers/input/touchscreen/wm9705.c
@@ -0,0 +1,353 @@
1/*
2 * wm9705.c -- Codec driver for Wolfson WM9705 AC97 Codec.
3 *
4 * Copyright 2003, 2004, 2005, 2006, 2007 Wolfson Microelectronics PLC.
5 * Author: Liam Girdwood
6 * liam.girdwood@wolfsonmicro.com or linux@wolfsonmicro.com
7 * Parts Copyright : Ian Molton <spyro@f2s.com>
8 * Andrew Zabolotny <zap@homelink.ru>
9 * Russell King <rmk@arm.linux.org.uk>
10 *
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.
15 *
16 */
17
18#include <linux/module.h>
19#include <linux/moduleparam.h>
20#include <linux/version.h>
21#include <linux/kernel.h>
22#include <linux/input.h>
23#include <linux/delay.h>
24#include <linux/bitops.h>
25#include <linux/wm97xx.h>
26
27#define TS_NAME "wm97xx"
28#define WM9705_VERSION "1.00"
29#define DEFAULT_PRESSURE 0xb0c0
30
31/*
32 * Module parameters
33 */
34
35/*
36 * Set current used for pressure measurement.
37 *
38 * Set pil = 2 to use 400uA
39 * pil = 1 to use 200uA and
40 * pil = 0 to disable pressure measurement.
41 *
42 * This is used to increase the range of values returned by the adc
43 * when measureing touchpanel pressure.
44 */
45static int pil;
46module_param(pil, int, 0);
47MODULE_PARM_DESC(pil, "Set current used for pressure measurement.");
48
49/*
50 * Set threshold for pressure measurement.
51 *
52 * Pen down pressure below threshold is ignored.
53 */
54static int pressure = DEFAULT_PRESSURE & 0xfff;
55module_param(pressure, int, 0);
56MODULE_PARM_DESC(pressure, "Set threshold for pressure measurement.");
57
58/*
59 * Set adc sample delay.
60 *
61 * For accurate touchpanel measurements, some settling time may be
62 * required between the switch matrix applying a voltage across the
63 * touchpanel plate and the ADC sampling the signal.
64 *
65 * This delay can be set by setting delay = n, where n is the array
66 * position of the delay in the array delay_table below.
67 * Long delays > 1ms are supported for completeness, but are not
68 * recommended.
69 */
70static int delay = 4;
71module_param(delay, int, 0);
72MODULE_PARM_DESC(delay, "Set adc sample delay.");
73
74/*
75 * Pen detect comparator threshold.
76 *
77 * 0 to Vmid in 15 steps, 0 = use zero power comparator with Vmid threshold
78 * i.e. 1 = Vmid/15 threshold
79 * 15 = Vmid/1 threshold
80 *
81 * Adjust this value if you are having problems with pen detect not
82 * detecting any down events.
83 */
84static int pdd = 8;
85module_param(pdd, int, 0);
86MODULE_PARM_DESC(pdd, "Set pen detect comparator threshold");
87
88/*
89 * Set adc mask function.
90 *
91 * Sources of glitch noise, such as signals driving an LCD display, may feed
92 * through to the touch screen plates and affect measurement accuracy. In
93 * order to minimise this, a signal may be applied to the MASK pin to delay or
94 * synchronise the sampling.
95 *
96 * 0 = No delay or sync
97 * 1 = High on pin stops conversions
98 * 2 = Edge triggered, edge on pin delays conversion by delay param (above)
99 * 3 = Edge triggered, edge on pin starts conversion after delay param
100 */
101static int mask;
102module_param(mask, int, 0);
103MODULE_PARM_DESC(mask, "Set adc mask function.");
104
105/*
106 * ADC sample delay times in uS
107 */
108static const int delay_table[] = {
109 21, /* 1 AC97 Link frames */
110 42, /* 2 */
111 84, /* 4 */
112 167, /* 8 */
113 333, /* 16 */
114 667, /* 32 */
115 1000, /* 48 */
116 1333, /* 64 */
117 2000, /* 96 */
118 2667, /* 128 */
119 3333, /* 160 */
120 4000, /* 192 */
121 4667, /* 224 */
122 5333, /* 256 */
123 6000, /* 288 */
124 0 /* No delay, switch matrix always on */
125};
126
127/*
128 * Delay after issuing a POLL command.
129 *
130 * The delay is 3 AC97 link frames + the touchpanel settling delay
131 */
132static inline void poll_delay(int d)
133{
134 udelay(3 * AC97_LINK_FRAME + delay_table[d]);
135}
136
137/*
138 * set up the physical settings of the WM9705
139 */
140static void wm9705_phy_init(struct wm97xx *wm)
141{
142 u16 dig1 = 0, dig2 = WM97XX_RPR;
143
144 /*
145 * mute VIDEO and AUX as they share X and Y touchscreen
146 * inputs on the WM9705
147 */
148 wm97xx_reg_write(wm, AC97_AUX, 0x8000);
149 wm97xx_reg_write(wm, AC97_VIDEO, 0x8000);
150
151 /* touchpanel pressure current*/
152 if (pil == 2) {
153 dig2 |= WM9705_PIL;
154 dev_dbg(wm->dev,
155 "setting pressure measurement current to 400uA.");
156 } else if (pil)
157 dev_dbg(wm->dev,
158 "setting pressure measurement current to 200uA.");
159 if (!pil)
160 pressure = 0;