import PULS_20160108
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / input / touchscreen / mediatek / synaptics_2200 / RefCode_F54_TxToGndReport.c
1 /*
2 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 Copyright (c) 2011 Synaptics, Inc.
4
5 Permission is hereby granted, free of charge, to any person obtaining a copy of
6 this software and associated documentation files (the "Software"), to deal in
7 the Software without restriction, including without limitation the rights to use,
8 copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
9 Software, and to permit persons to whom the Software is furnished to do so,
10 subject to the following conditions:
11
12 The above copyright notice and this permission notice shall be included in all
13 copies or substantial portions of the Software.
14
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 SOFTWARE.
22
23 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
24 */
25
26 #include "RefCode.h"
27 #include "RefCode_PDTScan.h"
28
29 #ifdef _F54_TEST_
30 // The following #defines are just needed to define an Image Report BUffer in memory
31 unsigned char F54_TxToGndReport(void)
32 {
33 unsigned char ImageBuffer[CFG_F54_TXCOUNT];
34 unsigned char ImageArray[CFG_F54_TXCOUNT];
35 //unsigned char Result[CFG_F54_TXCOUNT];
36 unsigned char Result=0;
37
38 int i, k;
39 int shift;
40
41 unsigned char command;
42
43 #ifdef F54_Porting
44 char buf[256] = {0};
45 int ret = 0;
46
47 ret = sprintf(buf, "\nBin #: 10 Name: Transmitter To Ground Short Test\n");
48 #else
49 printk("\nBin #: 10 Name: Transmitter To Ground Short Test\n");
50 #endif
51 for (i = 0; i < CFG_F54_TXCOUNT; i++)
52 ImageArray[i] = 0;
53
54 // Set report mode to run Tx-to-GND
55 command = 0x10;
56 writeRMI(F54_Data_Base, &command, 1);
57
58 command = 0x00;
59 writeRMI(F54_Data_LowIndex, &command, 1);
60 writeRMI(F54_Data_HighIndex, &command, 1);
61
62 // Set the GetReport bit to run Tx-to-Tx
63 command = 0x01;
64 writeRMI(F54_Command_Base, &command, 1);
65
66 // Wait until the command is completed
67 do {
68 delayMS(1); //wait 1ms
69 readRMI(F54_Command_Base, &command, 1);
70 } while (command != 0x00);
71
72 readRMI(F54_Data_Buffer, &ImageBuffer[0], 4);
73
74 // One bit per transmitter channel
75 k = 0;
76 for (i = 0; i < CFG_F54_TXCOUNT; i++)
77 {
78 k = i / 8;
79 shift = i % 8;
80 if(ImageBuffer[k] & (1 << shift)) ImageArray[i] = 1;
81 }
82
83 #ifdef F54_Porting
84 ret += sprintf(buf+ret, "Column:\t");
85 #else
86 printk("Column:\t");
87 #endif
88 for (i = 0; i < numberOfTx; i++)
89 {
90 #ifdef F54_Porting
91 ret += sprintf(buf+ret, "Tx%d,\t", TxChannelUsed[i]);
92 #else
93 printk("Tx%d,\t", TxChannelUsed[i]);
94 #endif
95 }
96 #ifdef F54_Porting
97 ret += sprintf(buf+ret, "\n");
98 ret += sprintf(buf+ret, "0:\t");
99 #else
100 printk("\n");
101
102 printk("0:\t");
103 #endif
104 for (i = 0; i < numberOfTx; i++)
105 {
106 if(ImageArray[TxChannelUsed[i]])
107 {
108 Result++;
109 #ifdef F54_Porting
110 ret += sprintf(buf+ret, "%d,\t", ImageArray[TxChannelUsed[i]]);
111 #else
112 printk("%d,\t", ImageArray[TxChannelUsed[i]]);
113 #endif
114 }
115 else
116 {
117 #ifdef F54_Porting
118 ret += sprintf(buf+ret, "%d(*),\t", ImageArray[TxChannelUsed[i]]);
119 #else
120 printk("%d(*),\t", ImageArray[TxChannelUsed[i]]);
121 #endif
122 }
123 }
124 #ifdef F54_Porting
125 ret += sprintf(buf+ret, "\n");
126 #else
127 printk("\n");
128 #endif
129
130 /*
131 // Check against test limits
132 printk("TxToGND Result\n");
133 for (i = 0; i < numberOfTx; i++)
134 {
135 if(ImageArray[TxChannelUsed[i]] == TxGNDLimit)
136 Result[i] = 'P'; //Pass
137 else
138 Result[i] = 'F'; //Fail
139 printk("Tx%d = %c\n", TxChannelUsed[i], Result[i]);
140 }
141 */
142
143 //enable all the interrupts
144 // SetPage(0x00);
145 //Reset
146 command= 0x01;
147 writeRMI(F01_Cmd_Base, &command, 1);
148 delayMS(200);
149 readRMI(F01_Data_Base+1, &command, 1); //Read Interrupt status register to Interrupt line goes to high
150
151 if(Result == numberOfTx)
152 {
153 #ifdef F54_Porting
154 ret += sprintf(buf+ret, "Test Result: Pass\n");
155 write_log(buf);
156 #else
157 printk("Test Result: Pass\n");
158 #endif
159 return 1; //Pass
160 }
161 else
162 {
163 #ifdef F54_Porting
164 ret += sprintf(buf+ret, "Test Result: Fail\n");
165 write_log(buf);
166 #else
167 printk("Test Result: Fail\n");
168 #endif
169 return 0; //Fail
170 }
171 }
172
173 int F54_GetTxToGndReport(char *buf)
174 {
175 unsigned char ImageBuffer[CFG_F54_TXCOUNT];
176 unsigned char ImageArray[CFG_F54_TXCOUNT];
177 unsigned char Result=0;
178
179 int i, k;
180 int shift;
181
182 unsigned char command;
183 int ret = 0;
184
185 int waitcount;
186
187 for (i = 0; i < CFG_F54_TXCOUNT; i++)
188 ImageArray[i] = 0;
189
190 // Set report mode to run Tx-to-GND
191 command = 0x10;
192 writeRMI(F54_Data_Base, &command, 1);
193
194 command = 0x00;
195 writeRMI(F54_Data_LowIndex, &command, 1);
196 writeRMI(F54_Data_HighIndex, &command, 1);
197
198 // Set the GetReport bit to run Tx-to-Tx
199 command = 0x01;
200 writeRMI(F54_Command_Base, &command, 1);
201
202 // Wait until the command is completed
203 waitcount = 0;
204 do {
205 if(++waitcount > 100)
206 {
207 pr_info("%s[%d], command = %d\n", __func__, __LINE__, command);
208 return ret;
209 }
210 delayMS(1); //wait 1ms
211 readRMI(F54_Command_Base, &command, 1);
212 } while (command != 0x00);
213
214 readRMI(F54_Data_Buffer, &ImageBuffer[0], 4);
215
216 // One bit per transmitter channel
217 k = 0;
218 for (i = 0; i < CFG_F54_TXCOUNT; i++)
219 {
220 k = i / 8;
221 shift = i % 8;
222 if(ImageBuffer[k] & (1 << shift)) ImageArray[i] = 1;
223 }
224
225 ret += sprintf(buf+ret, "Info: Tx=%d\n", numberOfTx);
226 ret += sprintf(buf+ret, "UsedTx: ");
227 for (i = 0; i < numberOfTx; i++)
228 {
229 ret += sprintf(buf+ret, "%d", TxChannelUsed[i]);
230
231 if(i < (numberOfTx-1))
232 ret += sprintf(buf+ret, " ");
233 }
234 ret += sprintf(buf+ret, "\n");
235 ret += sprintf(buf+ret, " ");
236 for (i = 0; i < numberOfTx; i++)
237 {
238 if(!ImageArray[TxChannelUsed[i]])
239 {
240 Result++;
241 ret += sprintf(buf+ret, "%d", ImageArray[TxChannelUsed[i]]);
242 }
243 else
244 {
245 ret += sprintf(buf+ret, "%d(*)", ImageArray[TxChannelUsed[i]]);
246 }
247
248 if(i < (numberOfTx-1))
249 ret += sprintf(buf+ret, " ");
250 }
251
252 ret += sprintf(buf+ret, "\n");
253
254 /*
255 // Check against test limits
256 printk("TxToGND Result\n");
257 for (i = 0; i < numberOfTx; i++)
258 {
259 if(ImageArray[TxChannelUsed[i]] == TxGNDLimit)
260 Result[i] = 'P'; //Pass
261 else
262 Result[i] = 'F'; //Fail
263 printk("Tx%d = %c\n", TxChannelUsed[i], Result[i]);
264 }
265 */
266
267 if (Result == numberOfTx)
268 {
269 ret += sprintf(buf+ret, "RESULT: Pass\n");
270 }
271 else
272 {
273 ret += sprintf(buf+ret, "RESULT: Fail\n");
274 }
275
276 //enable all the interrupts
277 // SetPage(0x00);
278 //Reset
279 command= 0x01;
280 writeRMI(F01_Cmd_Base, &command, 1);
281 delayMS(200);
282 readRMI(F01_Data_Base+1, &command, 1); //Read Interrupt status register to Interrupt line goes to high
283
284
285 return ret;
286
287 }
288 #endif
289