summaryrefslogtreecommitdiffstats
path: root/recipes-kernel/linux/linux-ti33x-psp-3.1/adc/0001-AM335x-Add-support-for-TSC-on-Beta-GP-EVM.patch
blob: 23a0c8f613f4f361ed79c7f0927c256f391a0b7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
From de1ae4c44093c7f62af58caf3bdba83bb9531295 Mon Sep 17 00:00:00 2001
From: Patil, Rachna <rachna@ti.com>
Date: Fri, 11 Nov 2011 18:03:27 +0530
Subject: [PATCH 1/9] AM335x: Add support for TSC on Beta GP EVM.

AN1 and AN2(analog inputs to analog front end) were swapped
on alpha EVM's. This change is IP dependent, hence changes are
made in the driver to support the beta EVM.

Signed-off-by: Patil, Rachna <rachna@ti.com>
---
 arch/arm/mach-omap2/board-am335xevm.c |    8 +++
 drivers/input/touchscreen/ti_tscadc.c |   83 ++++++++++++++++++++++-----------
 include/linux/input/ti_tscadc.h       |   10 ++++
 3 files changed, 73 insertions(+), 28 deletions(-)

diff --git a/arch/arm/mach-omap2/board-am335xevm.c b/arch/arm/mach-omap2/board-am335xevm.c
index b27fb97..7f52de1 100644
--- a/arch/arm/mach-omap2/board-am335xevm.c
+++ b/arch/arm/mach-omap2/board-am335xevm.c
@@ -920,6 +920,14 @@ static void dvi_init(int evm_id, int profile)
 static void tsc_init(int evm_id, int profile)
 {
 	int err;
+
+	if (gp_evm_revision == GP_EVM_REV_IS_1_1A) {
+		am335x_touchscreen_data.analog_input = 1;
+		pr_info("TSC connected to beta GP EVM\n");
+	} else {
+		am335x_touchscreen_data.analog_input = 0;
+		pr_info("TSC connected to alpha GP EVM\n");
+	}
 	setup_pin_mux(tsc_pin_mux);
 	err = platform_device_register(&tsc_device);
 	if (err)
diff --git a/drivers/input/touchscreen/ti_tscadc.c b/drivers/input/touchscreen/ti_tscadc.c
index 1f4db8d..021db7f 100644
--- a/drivers/input/touchscreen/ti_tscadc.c
+++ b/drivers/input/touchscreen/ti_tscadc.c
@@ -65,13 +65,16 @@
 #define TSCADC_STEPCONFIG_RFP		(1 << 12)
 #define TSCADC_STEPCONFIG_INM		(1 << 18)
 #define TSCADC_STEPCONFIG_INP_4		(1 << 19)
+#define TSCADC_STEPCONFIG_INP		(1 << 20)
 #define TSCADC_STEPCONFIG_INP_5		(1 << 21)
 #define TSCADC_STEPCONFIG_FIFO1		(1 << 26)
 #define TSCADC_STEPCONFIG_IDLE_INP	(1 << 22)
 #define TSCADC_STEPCONFIG_OPENDLY	0x018
 #define TSCADC_STEPCONFIG_SAMPLEDLY	0x88
-#define TSCADC_STEPCHARGE_INM		BIT(16)
-#define TSCADC_STEPCHARGE_INP		BIT(20)
+#define TSCADC_STEPCHARGE_INM_SWAP     BIT(16)
+#define TSCADC_STEPCHARGE_INM          BIT(15)
+#define TSCADC_STEPCHARGE_INP_SWAP     BIT(20)
+#define TSCADC_STEPCHARGE_INP          BIT(19)
 #define TSCADC_STEPCHARGE_RFM		(1 << 23)
 #define TSCADC_STEPCHARGE_DELAY		0x1
 #define TSCADC_CNTRLREG_TSCSSENB	BIT(0)
@@ -94,6 +97,7 @@ unsigned int bckup_x = 0, bckup_y = 0;
 struct tscadc {
 	struct input_dev	*input;
 	int			wires;
+	int			analog_input;
 	struct clk		*clk;
 	int			irq;
 	void __iomem		*tsc_base;
@@ -121,21 +125,37 @@ static void tsc_step_config(struct tscadc *ts_dev)
 	delay = TSCADC_STEPCONFIG_SAMPLEDLY | TSCADC_STEPCONFIG_OPENDLY;
 
 	stepconfigx = TSCADC_STEPCONFIG_MODE_HWSYNC |
-			TSCADC_STEPCONFIG_2SAMPLES_AVG | TSCADC_STEPCONFIG_XPP |
-			TSCADC_STEPCONFIG_YPN;
+			TSCADC_STEPCONFIG_2SAMPLES_AVG | TSCADC_STEPCONFIG_XPP;
+
 	switch (ts_dev->wires) {
 	case 4:
-		stepconfigx |= TSCADC_STEPCONFIG_INP_4;
+		if (ts_dev->analog_input == 0)
+			stepconfigx |= TSCADC_STEPCONFIG_INP_4 |
+				TSCADC_STEPCONFIG_YPN;
+		else
+			stepconfigx |= TSCADC_STEPCONFIG_INP |
+				TSCADC_STEPCONFIG_XNN;
 		break;
 	case 5:
-		stepconfigx |= TSCADC_STEPCONFIG_YPP |
-				TSCADC_STEPCONFIG_YNN |
+		stepconfigx |= TSCADC_STEPCONFIG_YNN |
 				TSCADC_STEPCONFIG_INP_5;
+		if (ts_dev->analog_input == 0)
+			stepconfigx |= TSCADC_STEPCONFIG_XNP |
+				TSCADC_STEPCONFIG_YPN;
+		else
+			stepconfigx |= TSCADC_STEPCONFIG_XNN |
+				TSCADC_STEPCONFIG_YPP;
 		break;
 	case 8:
-		stepconfigx |= TSCADC_STEPCONFIG_INP_4;
+		if (ts_dev->analog_input == 0)
+			stepconfigx |= TSCADC_STEPCONFIG_INP_4 |
+				TSCADC_STEPCONFIG_YPN;
+		else
+			stepconfigx |= TSCADC_STEPCONFIG_INP |
+				TSCADC_STEPCONFIG_XNN;
 		break;
 	}
+
 	for (i = 1; i < 7; i++) {
 		tscadc_writel(ts_dev, TSCADC_REG_STEPCONFIG(i), stepconfigx);
 		tscadc_writel(ts_dev, TSCADC_REG_STEPDELAY(i), delay);
@@ -146,18 +166,28 @@ static void tsc_step_config(struct tscadc *ts_dev)
 			TSCADC_STEPCONFIG_INM | TSCADC_STEPCONFIG_FIFO1;
 	switch (ts_dev->wires) {
 	case 4:
-		stepconfigy |= TSCADC_STEPCONFIG_XNP;
+		if (ts_dev->analog_input == 0)
+			stepconfigy |= TSCADC_STEPCONFIG_XNP;
+		else
+			stepconfigy |= TSCADC_STEPCONFIG_YPP;
 		break;
 	case 5:
-		stepconfigy |= TSCADC_STEPCONFIG_XPP |
-				TSCADC_STEPCONFIG_XNP |
-				TSCADC_STEPCONFIG_YPN |
-				TSCADC_STEPCONFIG_INP_5;
+		stepconfigy |= TSCADC_STEPCONFIG_XPP | TSCADC_STEPCONFIG_INP_5;
+		if (ts_dev->analog_input == 0)
+			stepconfigy |= TSCADC_STEPCONFIG_XNN |
+				TSCADC_STEPCONFIG_YPP;
+		else
+			stepconfigy |= TSCADC_STEPCONFIG_XNP |
+				TSCADC_STEPCONFIG_YPN;
 		break;
 	case 8:
-		stepconfigy |= TSCADC_STEPCONFIG_XNP;
+		if (ts_dev->analog_input == 0)
+			stepconfigy |= TSCADC_STEPCONFIG_XNP;
+		else
+			stepconfigy |= TSCADC_STEPCONFIG_YPP;
 		break;
 	}
+
 	for (i = 7; i < 13; i++) {
 		tscadc_writel(ts_dev, TSCADC_REG_STEPCONFIG(i), stepconfigy);
 		tscadc_writel(ts_dev, TSCADC_REG_STEPDELAY(i), delay);
@@ -166,8 +196,12 @@ static void tsc_step_config(struct tscadc *ts_dev)
 	chargeconfig = TSCADC_STEPCONFIG_XPP |
 			TSCADC_STEPCONFIG_YNN |
 			TSCADC_STEPCONFIG_RFP |
-			TSCADC_STEPCHARGE_INM | TSCADC_STEPCHARGE_INP |
 			TSCADC_STEPCHARGE_RFM;
+	if (ts_dev->analog_input == 0)
+		chargeconfig |= TSCADC_STEPCHARGE_INM_SWAP |
+			TSCADC_STEPCHARGE_INP_SWAP;
+	else
+		chargeconfig |= TSCADC_STEPCHARGE_INM | TSCADC_STEPCHARGE_INP;
 	tscadc_writel(ts_dev, TSCADC_REG_CHARGECONFIG, chargeconfig);
 	tscadc_writel(ts_dev, TSCADC_REG_CHARGEDELAY, TSCADC_STEPCHARGE_DELAY);
 
@@ -180,20 +214,12 @@ static void tsc_idle_config(struct tscadc *ts_config)
 	unsigned int	 idleconfig;
 
 	idleconfig = TSCADC_STEPCONFIG_YNN |
-				TSCADC_STEPCONFIG_XNN |
-				TSCADC_STEPCONFIG_INM;
+			TSCADC_STEPCONFIG_INM | TSCADC_STEPCONFIG_IDLE_INP;
+	if (ts_config->analog_input == 0)
+		idleconfig |= TSCADC_STEPCONFIG_XNN;
+	else
+		idleconfig |= TSCADC_STEPCONFIG_YPN;
 
-	switch (ts_config->wires) {
-	case 4:
-		idleconfig |= TSCADC_STEPCONFIG_IDLE_INP;
-		break;
-	case 5:
-		idleconfig |= TSCADC_STEPCONFIG_INP_5;
-		break;
-	case 8:
-		idleconfig |= TSCADC_STEPCONFIG_INP_4;
-		break;
-	}
 	tscadc_writel(ts_config, TSCADC_REG_IDLECONFIG, idleconfig);
 }
 
@@ -376,6 +402,7 @@ static	int __devinit tscadc_probe(struct platform_device *pdev)
 	tscadc_writel(ts_dev, TSCADC_REG_IRQWAKEUP, TSCADC_IRQWKUP_ENB);
 
 	ts_dev->wires = pdata->wires;
+	ts_dev->analog_input = pdata->analog_input;
 
 	/* Set the control register bits */
 	ctrl = TSCADC_CNTRLREG_STEPCONFIGWRT |
diff --git a/include/linux/input/ti_tscadc.h b/include/linux/input/ti_tscadc.h
index 29f87db..b9d9a46 100644
--- a/include/linux/input/ti_tscadc.h
+++ b/include/linux/input/ti_tscadc.h
@@ -3,8 +3,18 @@
  * @wires:		Wires refer to application modes
  *			i.e. 4/5/8 wire touchscreen support
  *			on the platform
+ * @analog_input:	Analog inputs refer to the order in which the
+ *			connections are made to the AFE. If the connections
+ *			are as : XPUL = AN0,XNUR = AN1,YPLL = AN2,
+ *			YNLR = AN3, then this variable is set to 1.
+ *			Else if the connections are as :
+ *			XPUL = AN0,YPLL = AN1,XNUR = AN2,
+ *			YNLR = AN3, then set this variable to
+ *			0.
  */
 
 struct tsc_data {
 	int wires;
+	int analog_input;
+
 };
-- 
1.7.2.5