23a0c8f613f4f361ed79c7f0927c256f391a0b7c
[glsdk/meta-ti-glsdk.git] / recipes-kernel / linux / linux-ti33x-psp-3.1 / adc / 0001-AM335x-Add-support-for-TSC-on-Beta-GP-EVM.patch
1 From de1ae4c44093c7f62af58caf3bdba83bb9531295 Mon Sep 17 00:00:00 2001
2 From: Patil, Rachna <rachna@ti.com>
3 Date: Fri, 11 Nov 2011 18:03:27 +0530
4 Subject: [PATCH 1/9] AM335x: Add support for TSC on Beta GP EVM.
6 AN1 and AN2(analog inputs to analog front end) were swapped
7 on alpha EVM's. This change is IP dependent, hence changes are
8 made in the driver to support the beta EVM.
10 Signed-off-by: Patil, Rachna <rachna@ti.com>
11 ---
12 arch/arm/mach-omap2/board-am335xevm.c | 8 +++
13 drivers/input/touchscreen/ti_tscadc.c | 83 ++++++++++++++++++++++-----------
14 include/linux/input/ti_tscadc.h | 10 ++++
15 3 files changed, 73 insertions(+), 28 deletions(-)
17 diff --git a/arch/arm/mach-omap2/board-am335xevm.c b/arch/arm/mach-omap2/board-am335xevm.c
18 index b27fb97..7f52de1 100644
19 --- a/arch/arm/mach-omap2/board-am335xevm.c
20 +++ b/arch/arm/mach-omap2/board-am335xevm.c
21 @@ -920,6 +920,14 @@ static void dvi_init(int evm_id, int profile)
22 static void tsc_init(int evm_id, int profile)
23 {
24 int err;
25 +
26 + if (gp_evm_revision == GP_EVM_REV_IS_1_1A) {
27 + am335x_touchscreen_data.analog_input = 1;
28 + pr_info("TSC connected to beta GP EVM\n");
29 + } else {
30 + am335x_touchscreen_data.analog_input = 0;
31 + pr_info("TSC connected to alpha GP EVM\n");
32 + }
33 setup_pin_mux(tsc_pin_mux);
34 err = platform_device_register(&tsc_device);
35 if (err)
36 diff --git a/drivers/input/touchscreen/ti_tscadc.c b/drivers/input/touchscreen/ti_tscadc.c
37 index 1f4db8d..021db7f 100644
38 --- a/drivers/input/touchscreen/ti_tscadc.c
39 +++ b/drivers/input/touchscreen/ti_tscadc.c
40 @@ -65,13 +65,16 @@
41 #define TSCADC_STEPCONFIG_RFP (1 << 12)
42 #define TSCADC_STEPCONFIG_INM (1 << 18)
43 #define TSCADC_STEPCONFIG_INP_4 (1 << 19)
44 +#define TSCADC_STEPCONFIG_INP (1 << 20)
45 #define TSCADC_STEPCONFIG_INP_5 (1 << 21)
46 #define TSCADC_STEPCONFIG_FIFO1 (1 << 26)
47 #define TSCADC_STEPCONFIG_IDLE_INP (1 << 22)
48 #define TSCADC_STEPCONFIG_OPENDLY 0x018
49 #define TSCADC_STEPCONFIG_SAMPLEDLY 0x88
50 -#define TSCADC_STEPCHARGE_INM BIT(16)
51 -#define TSCADC_STEPCHARGE_INP BIT(20)
52 +#define TSCADC_STEPCHARGE_INM_SWAP BIT(16)
53 +#define TSCADC_STEPCHARGE_INM BIT(15)
54 +#define TSCADC_STEPCHARGE_INP_SWAP BIT(20)
55 +#define TSCADC_STEPCHARGE_INP BIT(19)
56 #define TSCADC_STEPCHARGE_RFM (1 << 23)
57 #define TSCADC_STEPCHARGE_DELAY 0x1
58 #define TSCADC_CNTRLREG_TSCSSENB BIT(0)
59 @@ -94,6 +97,7 @@ unsigned int bckup_x = 0, bckup_y = 0;
60 struct tscadc {
61 struct input_dev *input;
62 int wires;
63 + int analog_input;
64 struct clk *clk;
65 int irq;
66 void __iomem *tsc_base;
67 @@ -121,21 +125,37 @@ static void tsc_step_config(struct tscadc *ts_dev)
68 delay = TSCADC_STEPCONFIG_SAMPLEDLY | TSCADC_STEPCONFIG_OPENDLY;
70 stepconfigx = TSCADC_STEPCONFIG_MODE_HWSYNC |
71 - TSCADC_STEPCONFIG_2SAMPLES_AVG | TSCADC_STEPCONFIG_XPP |
72 - TSCADC_STEPCONFIG_YPN;
73 + TSCADC_STEPCONFIG_2SAMPLES_AVG | TSCADC_STEPCONFIG_XPP;
74 +
75 switch (ts_dev->wires) {
76 case 4:
77 - stepconfigx |= TSCADC_STEPCONFIG_INP_4;
78 + if (ts_dev->analog_input == 0)
79 + stepconfigx |= TSCADC_STEPCONFIG_INP_4 |
80 + TSCADC_STEPCONFIG_YPN;
81 + else
82 + stepconfigx |= TSCADC_STEPCONFIG_INP |
83 + TSCADC_STEPCONFIG_XNN;
84 break;
85 case 5:
86 - stepconfigx |= TSCADC_STEPCONFIG_YPP |
87 - TSCADC_STEPCONFIG_YNN |
88 + stepconfigx |= TSCADC_STEPCONFIG_YNN |
89 TSCADC_STEPCONFIG_INP_5;
90 + if (ts_dev->analog_input == 0)
91 + stepconfigx |= TSCADC_STEPCONFIG_XNP |
92 + TSCADC_STEPCONFIG_YPN;
93 + else
94 + stepconfigx |= TSCADC_STEPCONFIG_XNN |
95 + TSCADC_STEPCONFIG_YPP;
96 break;
97 case 8:
98 - stepconfigx |= TSCADC_STEPCONFIG_INP_4;
99 + if (ts_dev->analog_input == 0)
100 + stepconfigx |= TSCADC_STEPCONFIG_INP_4 |
101 + TSCADC_STEPCONFIG_YPN;
102 + else
103 + stepconfigx |= TSCADC_STEPCONFIG_INP |
104 + TSCADC_STEPCONFIG_XNN;
105 break;
106 }
107 +
108 for (i = 1; i < 7; i++) {
109 tscadc_writel(ts_dev, TSCADC_REG_STEPCONFIG(i), stepconfigx);
110 tscadc_writel(ts_dev, TSCADC_REG_STEPDELAY(i), delay);
111 @@ -146,18 +166,28 @@ static void tsc_step_config(struct tscadc *ts_dev)
112 TSCADC_STEPCONFIG_INM | TSCADC_STEPCONFIG_FIFO1;
113 switch (ts_dev->wires) {
114 case 4:
115 - stepconfigy |= TSCADC_STEPCONFIG_XNP;
116 + if (ts_dev->analog_input == 0)
117 + stepconfigy |= TSCADC_STEPCONFIG_XNP;
118 + else
119 + stepconfigy |= TSCADC_STEPCONFIG_YPP;
120 break;
121 case 5:
122 - stepconfigy |= TSCADC_STEPCONFIG_XPP |
123 - TSCADC_STEPCONFIG_XNP |
124 - TSCADC_STEPCONFIG_YPN |
125 - TSCADC_STEPCONFIG_INP_5;
126 + stepconfigy |= TSCADC_STEPCONFIG_XPP | TSCADC_STEPCONFIG_INP_5;
127 + if (ts_dev->analog_input == 0)
128 + stepconfigy |= TSCADC_STEPCONFIG_XNN |
129 + TSCADC_STEPCONFIG_YPP;
130 + else
131 + stepconfigy |= TSCADC_STEPCONFIG_XNP |
132 + TSCADC_STEPCONFIG_YPN;
133 break;
134 case 8:
135 - stepconfigy |= TSCADC_STEPCONFIG_XNP;
136 + if (ts_dev->analog_input == 0)
137 + stepconfigy |= TSCADC_STEPCONFIG_XNP;
138 + else
139 + stepconfigy |= TSCADC_STEPCONFIG_YPP;
140 break;
141 }
142 +
143 for (i = 7; i < 13; i++) {
144 tscadc_writel(ts_dev, TSCADC_REG_STEPCONFIG(i), stepconfigy);
145 tscadc_writel(ts_dev, TSCADC_REG_STEPDELAY(i), delay);
146 @@ -166,8 +196,12 @@ static void tsc_step_config(struct tscadc *ts_dev)
147 chargeconfig = TSCADC_STEPCONFIG_XPP |
148 TSCADC_STEPCONFIG_YNN |
149 TSCADC_STEPCONFIG_RFP |
150 - TSCADC_STEPCHARGE_INM | TSCADC_STEPCHARGE_INP |
151 TSCADC_STEPCHARGE_RFM;
152 + if (ts_dev->analog_input == 0)
153 + chargeconfig |= TSCADC_STEPCHARGE_INM_SWAP |
154 + TSCADC_STEPCHARGE_INP_SWAP;
155 + else
156 + chargeconfig |= TSCADC_STEPCHARGE_INM | TSCADC_STEPCHARGE_INP;
157 tscadc_writel(ts_dev, TSCADC_REG_CHARGECONFIG, chargeconfig);
158 tscadc_writel(ts_dev, TSCADC_REG_CHARGEDELAY, TSCADC_STEPCHARGE_DELAY);
160 @@ -180,20 +214,12 @@ static void tsc_idle_config(struct tscadc *ts_config)
161 unsigned int idleconfig;
163 idleconfig = TSCADC_STEPCONFIG_YNN |
164 - TSCADC_STEPCONFIG_XNN |
165 - TSCADC_STEPCONFIG_INM;
166 + TSCADC_STEPCONFIG_INM | TSCADC_STEPCONFIG_IDLE_INP;
167 + if (ts_config->analog_input == 0)
168 + idleconfig |= TSCADC_STEPCONFIG_XNN;
169 + else
170 + idleconfig |= TSCADC_STEPCONFIG_YPN;
172 - switch (ts_config->wires) {
173 - case 4:
174 - idleconfig |= TSCADC_STEPCONFIG_IDLE_INP;
175 - break;
176 - case 5:
177 - idleconfig |= TSCADC_STEPCONFIG_INP_5;
178 - break;
179 - case 8:
180 - idleconfig |= TSCADC_STEPCONFIG_INP_4;
181 - break;
182 - }
183 tscadc_writel(ts_config, TSCADC_REG_IDLECONFIG, idleconfig);
184 }
186 @@ -376,6 +402,7 @@ static int __devinit tscadc_probe(struct platform_device *pdev)
187 tscadc_writel(ts_dev, TSCADC_REG_IRQWAKEUP, TSCADC_IRQWKUP_ENB);
189 ts_dev->wires = pdata->wires;
190 + ts_dev->analog_input = pdata->analog_input;
192 /* Set the control register bits */
193 ctrl = TSCADC_CNTRLREG_STEPCONFIGWRT |
194 diff --git a/include/linux/input/ti_tscadc.h b/include/linux/input/ti_tscadc.h
195 index 29f87db..b9d9a46 100644
196 --- a/include/linux/input/ti_tscadc.h
197 +++ b/include/linux/input/ti_tscadc.h
198 @@ -3,8 +3,18 @@
199 * @wires: Wires refer to application modes
200 * i.e. 4/5/8 wire touchscreen support
201 * on the platform
202 + * @analog_input: Analog inputs refer to the order in which the
203 + * connections are made to the AFE. If the connections
204 + * are as : XPUL = AN0,XNUR = AN1,YPLL = AN2,
205 + * YNLR = AN3, then this variable is set to 1.
206 + * Else if the connections are as :
207 + * XPUL = AN0,YPLL = AN1,XNUR = AN2,
208 + * YNLR = AN3, then set this variable to
209 + * 0.
210 */
212 struct tsc_data {
213 int wires;
214 + int analog_input;
215 +
216 };
217 --
218 1.7.2.5