summaryrefslogtreecommitdiffstats
path: root/drivers/input/touchscreen/rm31080a_ctrl.c
diff options
context:
space:
mode:
authorXiaohui Tao <xtao@nvidia.com>2013-05-30 14:30:13 -0400
committerDavid Pu <dpu@nvidia.com>2017-07-27 19:09:19 -0400
commit817dd2fd4f085d0ab96ff7fd8b8515ea4826df34 (patch)
treed37feab56c2850dd5086b51016d6f9fe6dfdaf8d /drivers/input/touchscreen/rm31080a_ctrl.c
parent96b1cd57542c6db1ff583a187f097d962fca46a6 (diff)
Input: touch: raydium: Update to Raydium v56.1 driver
Raydium code drop Jump directly from v51 to v56.1 V52 Changes (Beta) (Roth only): [1] Add Kernel control architecturee (SlowScan/SetIdle/Start/End..) [2] New parameter loading architecture [3] Refine ESD solution for MP [4] Re-fine self-test procedure for MP [5] Load calibration file from environment variable path [6] Fix the LP0 2 sec delay issue [7] Fix finger on the screen during boot up issue [8] This version only support Roth platform [9] Refine coding style (4/16) [10] Newer parameter modifier apk (4/16) [11] Newer architecture for idle mode power saving has some problem, please ignore the idle mode verification on this trial version (4/16) V53 Changes (Beta) (Roth only): [1] Save calibration file from environment variable path [2] Refine selftest threshold V54 Changes (Beta) (Roth only): [1] Fix the hard code file path to environment variable path [2] Remove the redundancy message in kernel layer V54.1 Changes (Beta) (Roth only): [1] Refine environment variable path mechanism [2] Add test version field for debugging [3] Enable environment variable path debug msgs V54.2 Changes (Beta) (Roth only): [1] Refine coding style [2] Add kernel command entries [3] Using kernel command instead of hard-coded in suspend/resume routine [4] Using lower report rate during idle mode to fix CPU ain't got into idle mode (5 Hz) V55.0 Changes (Beta) (Roth only): [1] Fix idle mode issue & increase report rate [2] Add error handling block for kernel table loading [3] Refine coding style V55.1 Changes (Beta) (Roth only): [1] Refine parameter for factory test [2] Add copy file from TOUCH_CONF_DIR in parameter loading [3] Turn on loading file logcat msgs V55.2 Changes (Beta) (Roth only): [1] Remove unnecessary code [2] Add GPIO interface for future sensor select [3] Refine selftest procedure [4] Refine calibration procedure V55.3 Changes (Beta) (Roth only): [1] Add support to disable power and clock when display is off [2] Parameter fine-tune V55.4 Changes (Beta) (Roth only): [1] Fix CTS test failure in service transaction return [2] Fix stub command error return V55.5 Changes (Beta): [1] Suppor roth/pluto/dalmore V55.6 Changes (Beta): [1] Refine coding style [2] Parameter fine tune for pluto/dalmore V55.7 Changes (Beta): [1] Parameter fine tune for pluto/dalmore V55.8 Changes (Beta): [1] Parameter fine tune for pluto(Orientation setting for RM31081) V55.9 Changes (Beta): [1] Refine resume control flow [2] Modify touch WDT function [3] Touch start/stop control flow modification V55.10 Changes (Beta): [1] Set REST as the following Suspend 1. Pull RESET low 2. Disable clk and power 3. Pull RESET high Resume 1. Pull RESET low 2. Enable power ,clk 3. Pull RESET high V56 Changes: [1] Fix CTS fail error V56.1 Changes: [1] Fix CTS fail error [2] Shorten suspend/resume duration Bug 1278869 Bug 1283619 Bug 1297187 Bug 1280093 Bug 1257642 Bug 1245549 Bug 1245404 Change-Id: I04acd5001e6ec675c3a4ddf2db892e0886d36303 Signed-off-by: Xiaohui Tao <xtao@nvidia.com> Reviewed-on: http://git-master/r/234223 Reviewed-by: Robert Collins <rcollins@nvidia.com> Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Diffstat (limited to 'drivers/input/touchscreen/rm31080a_ctrl.c')
-rw-r--r--drivers/input/touchscreen/rm31080a_ctrl.c293
1 files changed, 89 insertions, 204 deletions
diff --git a/drivers/input/touchscreen/rm31080a_ctrl.c b/drivers/input/touchscreen/rm31080a_ctrl.c
index 04d13672b..04f9f70e9 100644
--- a/drivers/input/touchscreen/rm31080a_ctrl.c
+++ b/drivers/input/touchscreen/rm31080a_ctrl.c
@@ -1,8 +1,8 @@
1/* 1/*
2 * Raydium RM31080 touchscreen driver 2 * Raydium RM31080 touchscreen driver
3 * 3 *
4 * Copyright (C) 2012 - 2013 Raydium Semiconductor Corporation 4 * Copyright (C) 2012-2013, Raydium Semiconductor Corporation. All Rights Reserved.
5 * Copyright (C) 2012 NVIDIA Corporation, All Rights Reserved. 5 * Copyright (C) 2012-2013, NVIDIA Corporation. All Rights Reserved.
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify it 7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the 8 * under the terms of the GNU General Public License as published by the
@@ -11,185 +11,111 @@
11 * 11 *
12 */ 12 */
13/*============================================================================= 13/*=============================================================================
14 *INCLUDED FILES 14 INCLUDED FILES
15 *============================================================================= 15=============================================================================*/
16 */
17#include <linux/device.h> 16#include <linux/device.h>
18#include <linux/uaccess.h> 17#include <asm/uaccess.h> // copy_to_user(),
19#include <linux/delay.h> 18#include <linux/delay.h>
20#include <linux/module.h> 19#include <linux/module.h> // Module definition
21 20
22#include <linux/spi/rm31080a_ts.h> 21#include <linux/spi/rm31080a_ts.h>
23#include <linux/spi/rm31080a_ctrl.h> 22#include <linux/spi/rm31080a_ctrl.h>
24/*=============================================================================
25 *DEFINITIONS
26 *=============================================================================
27 */
28#define RM31080_RAW_DATA_LENGTH 2048
29 23
30/*============================================================================= 24/*=============================================================================
31 *STRUCTURE DECLARATION 25 GLOBAL VARIABLES DECLARATION
32 *============================================================================= 26=============================================================================*/
33 */
34
35/*=============================================================================
36 *GLOBAL VARIABLES DECLARATION
37 *=============================================================================
38 */
39struct rm31080a_ctrl_para g_stCtrl; 27struct rm31080a_ctrl_para g_stCtrl;
40 28
41/*============================================================================= 29/*=============================================================================
42 *FUNCTION DECLARATION 30 FUNCTION DECLARATION
43 *============================================================================= 31=============================================================================*/
44 */ 32
45/*============================================================================= 33/*=============================================================================
46 * Description: 34 Description:
47 * Control functions for Touch IC 35 Control functions for Touch IC
48 * Input: 36 Input:
49 * 37
50 * Output: 38 Output:
51 *============================================================================= 39
52 */ 40=============================================================================*/
53int rm31080_ctrl_clear_int(void) 41int rm_tch_ctrl_clear_int(void)
54{ 42{
55 u8 flag; 43 u8 flag;
56 44 if (g_stCtrl.bICVersion >= 0xD0)
57 if (g_stCtrl.bICVersion != T007A6) 45 return rm_tch_spi_byte_read(0x72, &flag);
58 return rm31080_spi_byte_read(RM31080B1_REG_BANK0_02H, &flag);
59 else 46 else
60 return rm31080_spi_byte_read(RM31080_REG_F2, &flag); 47 return rm_tch_spi_byte_read(0x02, &flag);
61} 48}
62 49
63int rm31080_ctrl_scan_start(void) 50int rm_tch_ctrl_scan_start(void)
64{ 51{
65 return rm31080_spi_byte_write(RM31080_REG_11, 0x17); 52 return rm_tch_spi_byte_write(RM31080_REG_11, 0x17);
66} 53}
67 54
68void rm31080_ctrl_wait_for_scan_finish(void) 55void rm_tch_ctrl_wait_for_scan_finish(void)
69{ 56{
70 u8 u8reg11; 57 u8 u8reg11;
71 int i; 58 int i;
72 /* 50ms = 20Hz */ 59 /*50ms = 20Hz*/
73 for (i = 0; i < 50; i++) { 60 for (i = 0; i < 50; i++) {
74 rm31080_spi_byte_read(RM31080_REG_11, &u8reg11); 61 rm_tch_spi_byte_read(RM31080_REG_11, &u8reg11);
75 if (u8reg11 & 0x01) 62 if (u8reg11 & 0x01)
76 usleep_range(1000, 2000);/*msleep(1); */ 63 usleep_range(1000, 2000);/* msleep(1); */
77 else 64 else
78 break; 65 break;
79 } 66 }
80} 67}
81 68
82
83/*============================================================================= 69/*=============================================================================
84 * Description: 70 Description:
85 * 71
86 * Input: 72 Input:
87 * N/A 73 N/A
88 * Output: 74 Output:
89 * N/A 75 N/A
90 *============================================================================= 76=============================================================================*/
91 */
92void rm_set_repeat_times(u8 u8Times) 77void rm_set_repeat_times(u8 u8Times)
93{ 78{
94 u8 bReg1_1Fh = 0x00; 79 u8 bReg1_1Fh = 0x00;
95 u8 u8Reg = 0x00; 80 u8 u8Reg = 0x00;
96 81
97 if (g_stCtrl.bICVersion != T007A6) { 82 u8Reg = g_stCtrl.bSenseNumber - 1;
98 rm31080_spi_byte_read(0x0A, &u8Reg); 83 rm_tch_spi_byte_write(0x0A, u8Reg&0x0F);
99 u8Reg &= 0xF0; 84 rm_tch_spi_byte_write(0x0E, u8Times&0x1F);
100 u8Reg |= (g_stCtrl.bSenseNumber - 1);
101 rm31080_spi_byte_write(0x0A, u8Reg);
102
103 rm31080_spi_byte_read(0x0E, &u8Reg);
104 u8Reg &= ~0x1F;
105 u8Reg |= u8Times;
106 rm31080_spi_byte_write(0x0E, u8Reg);
107
108 if ((g_stCtrl.bfADFC) &&
109 (g_stCtrl.bICVersion != T007_VERSION_C))
110 bReg1_1Fh |= ADFC;
111
112 if (g_stCtrl.bfTHMode)
113 bReg1_1Fh |= FILTER_THRESHOLD_MODE;
114 else
115 bReg1_1Fh &= ~FILTER_NONTHRESHOLD_MODE;
116 /*bReg1_1Fh |= FILTER_NONTHRESHOLD_MODE;*/
117
118 if (u8Times != REPEAT_1)
119 bReg1_1Fh |= 0x44; /*Marty 20120820*/
120
121 rm31080_spi_byte_write(RM31080_REG_1F, bReg1_1Fh);
122 } else {
123 u8Reg = ((g_stCtrl.bSenseNumber - 1) << 3) | u8Times;
124
125 rm31080_spi_byte_write(RM31080_REG_0E, u8Reg);
126 if (g_stCtrl.bfADFC)
127 bReg1_1Fh |= ADFC;
128 85
129 if (g_stCtrl.bfTHMode) 86 if (g_stCtrl.bfTHMode)
130 bReg1_1Fh |= FILTER_THRESHOLD_MODE; 87 bReg1_1Fh |= FILTER_THRESHOLD_MODE;
131 else 88 else
132 bReg1_1Fh &= ~FILTER_NONTHRESHOLD_MODE; 89 bReg1_1Fh &= ~FILTER_NONTHRESHOLD_MODE;
133 /*bReg1_1Fh |= FILTER_NONTHRESHOLD_MODE;*/
134 90
135 if (u8Times != REPEAT_1) 91 if (u8Times != REPEAT_1)
136 bReg1_1Fh |= (u8Times + 3); 92 bReg1_1Fh |= 0x44;
137 93
138 rm31080_spi_byte_write(RM31080_REG_1F, bReg1_1Fh); 94 rm_tch_spi_byte_write(RM31080_REG_1F, bReg1_1Fh);
139 }
140} 95}
141 96
142/*============================================================================= 97/*=============================================================================
143 * Description: 98 Description:
144 * 99
145 * Input: 100 Input:
146 * N/A 101 N/A
147 * Output: 102 Output:
148 * N/A 103 N/A
149 *============================================================================= 104=============================================================================*/
150 */ 105void rm_tch_ctrl_init(void)
151void rm31080_ctrl_init(void)
152{ 106{
153 u8 var;
154
155 memset(&g_stCtrl, 0, sizeof(struct rm31080a_ctrl_para)); 107 memset(&g_stCtrl, 0, sizeof(struct rm31080a_ctrl_para));
156
157 g_stCtrl.bDummyRunCycle = 1;
158 g_stCtrl.u16DataLength = RM31080_RAW_DATA_LENGTH;
159
160 if (rm31080_spi_byte_read(RM31080_REG_7E, &var))
161 g_stCtrl.bICVersion = var & 0xF0;
162 else
163 g_stCtrl.bICVersion = T007A6;
164} 108}
165 109
166/*============================================================================= 110/*=============================================================================
167 * Description: 111 Description: To transfer the value to HAL layer
168 * 112
169 * Input: 113 Input:
170 * N/A 114 N/A
171 * Output: 115 Output:
172 * N/A 116 N/A
173 *============================================================================= 117=============================================================================*/
174 */ 118unsigned char rm_tch_ctrl_get_idle_mode(u8 *p)
175unsigned char rm31080_ctrl_get_noise_mode(u8 *p)
176{
177 u32 u32Ret;
178 u32Ret = copy_to_user(p, &g_stCtrl.bfNoiseModeDetector, 1);
179 if (u32Ret != 0)
180 return 0;
181 return 1;
182}
183
184/*=============================================================================
185 * Description: To transfer the value to HAL layer
186 *
187 * Input:
188 * N/A
189 * Output:
190 * N/A
191 *===========================================================================*/
192unsigned char rm31080_ctrl_get_idle_mode(u8 *p)
193{ 119{
194 u32 u32Ret; 120 u32 u32Ret;
195 u32Ret = copy_to_user(p, &g_stCtrl.bfIdleModeCheck, 1); 121 u32Ret = copy_to_user(p, &g_stCtrl.bfIdleModeCheck, 1);
@@ -199,95 +125,54 @@ unsigned char rm31080_ctrl_get_idle_mode(u8 *p)
199} 125}
200 126
201/*============================================================================= 127/*=============================================================================
202 * Description: 128 Description:
203 * 129
204 * Input: 130 Input:
205 * N/A 131 N/A
206 * Output: 132 Output:
207 * N/A 133 N/A
208 *============================================================================= 134=============================================================================*/
209 */ 135void rm_tch_ctrl_get_parameter(void *arg)
210void rm31080_ctrl_get_parameter(void *arg)
211{ 136{
212#define PARA_BASIC_LEN 4 137#define PARA_BASIC_LEN 4
213#define PARA_HARDWARE_LEN 28 138#define PARA_HARDWARE_LEN 28
214#define PARA_NOISE_LEN 32 139#define PARA_NOISE_LEN 32
215#define PARA_ALGORITHM_LEN 128 140#define PARA_ALGORITHM_LEN 128
216 141
217 /* Marty added*/
218 u8 Temp; 142 u8 Temp;
219 u8 *pPara; 143 u8 *pPara;
220 u8 idx;
221 idx = PARA_BASIC_LEN;
222 144
223 pPara = (u8 *) arg; 145 pPara = (u8 *) arg;
224 Temp = pPara[idx + PARA_HARDWARE_LEN + 146 Temp = pPara[PARA_BASIC_LEN + PARA_HARDWARE_LEN + PARA_NOISE_LEN + PARA_ALGORITHM_LEN + 3];
225 PARA_NOISE_LEN + PARA_ALGORITHM_LEN + 3]; 147 rm_tch_set_autoscan(Temp);
226 rm31080_set_autoscan(Temp); 148
227 149 g_stCtrl.bICVersion = pPara[PARA_BASIC_LEN - 1];
228 g_stCtrl.bADCNumber = pPara[idx + 6]; 150 g_stCtrl.bADCNumber = pPara[PARA_BASIC_LEN + 5];
229 g_stCtrl.bChannelNumberX = pPara[idx]; 151 g_stCtrl.bChannelNumberX = pPara[PARA_BASIC_LEN];
230 g_stCtrl.bChannelNumberY = pPara[idx + 1]; 152 g_stCtrl.bChannelNumberY = pPara[PARA_BASIC_LEN + 1];
231 g_stCtrl.bfNoiseDetector = pPara[idx + PARA_HARDWARE_LEN + 13]; 153 g_stCtrl.u16DataLength = (g_stCtrl.bChannelNumberX + 2 + g_stCtrl.bADCNumber) * (g_stCtrl.bChannelNumberY);
232 g_stCtrl.bChannelDetectorNum = pPara[idx + PARA_HARDWARE_LEN + 19]; 154
233 g_stCtrl.bChannelDetectorDummy = pPara[idx + PARA_HARDWARE_LEN + 20]; 155 g_stCtrl.bActiveRepeatTimes[0] = pPara[PARA_BASIC_LEN + PARA_HARDWARE_LEN + 4];
234 g_stCtrl.u16DataLength = (g_stCtrl.bChannelNumberX + 2 + 156 g_stCtrl.bActiveRepeatTimes[1] = pPara[PARA_BASIC_LEN + PARA_HARDWARE_LEN + 5];
235 g_stCtrl.bADCNumber) * 157 g_stCtrl.bIdleRepeatTimes[0] = pPara[PARA_BASIC_LEN + PARA_HARDWARE_LEN + 6];
236 (g_stCtrl.bChannelNumberY + g_stCtrl.bfNoiseDetector * 158 g_stCtrl.bIdleRepeatTimes[1] = pPara[PARA_BASIC_LEN + PARA_HARDWARE_LEN + 7];
237 (g_stCtrl.bChannelDetectorNum + 159 g_stCtrl.bSenseNumber = pPara[PARA_BASIC_LEN + 10];
238 g_stCtrl.bChannelDetectorDummy)); 160 g_stCtrl.bfTHMode = pPara[PARA_BASIC_LEN + PARA_HARDWARE_LEN + 10];
239 g_stCtrl.bfNoiseMode = pPara[idx + PARA_HARDWARE_LEN + 14];
240 g_stCtrl.bNoiseRepeatTimes = pPara[idx + PARA_HARDWARE_LEN + 15];
241 /*Marty added*/
242 g_stCtrl.bNoiseThresholdMax = pPara[idx + PARA_HARDWARE_LEN + 21];
243 g_stCtrl.bNoiseThresholdMin = pPara[idx + PARA_HARDWARE_LEN + 22];
244 g_stCtrl.bNoiseThresholdLowMax = pPara[idx + PARA_HARDWARE_LEN + 23];
245 g_stCtrl.bNoiseThresholdLowMin = pPara[idx + PARA_HARDWARE_LEN + 24];
246 g_stCtrl.bNoiseDetectThd = pPara[idx + PARA_HARDWARE_LEN + 16];
247 g_stCtrl.bNoisePipelineBase = pPara[idx + PARA_HARDWARE_LEN + 17];
248 g_stCtrl.bNewNoiseRepeatTimes = pPara[idx + PARA_HARDWARE_LEN + 18];
249 g_stCtrl.bfMediumFilter = pPara[idx + PARA_HARDWARE_LEN + 25];
250 g_stCtrl.bMFBlockNumber = pPara[idx + PARA_HARDWARE_LEN + 26];
251 g_stCtrl.bRepeatTimes[0] = pPara[idx + PARA_HARDWARE_LEN + 4];
252 g_stCtrl.bRepeatTimes[1] = pPara[idx + PARA_HARDWARE_LEN + 5];
253 g_stCtrl.bIdleRepeatTimes[0] = pPara[idx + PARA_HARDWARE_LEN + 6];
254 g_stCtrl.bSenseNumber = pPara[idx + 11];
255 g_stCtrl.bfADFC = pPara[idx + 4];
256 g_stCtrl.bfTHMode = pPara[idx + PARA_HARDWARE_LEN + 10];
257 g_stCtrl.bfAnalogFilter = pPara[idx + PARA_HARDWARE_LEN + 8];
258 g_stCtrl.bYChannel[0] = pPara[280]; /* Y chan start pin */
259 g_stCtrl.bYChannel[1] = pPara[281]; /* Y chan end pin */
260 g_stCtrl.bXChannel[0] = pPara[282]; /* X chan ADC1 start pin */
261 g_stCtrl.bXChannel[1] = pPara[283]; /* X chan ADC1 end pin */
262 g_stCtrl.bXChannel[2] = pPara[284]; /* X chan ADC2 start pin */
263 g_stCtrl.bXChannel[3] = pPara[285]; /* X chan ADC2 end pin */
264 g_stCtrl.bfSuspendReset = pPara[idx + PARA_HARDWARE_LEN + 27];
265 g_stCtrl.bPressureResolution = pPara[105];
266 g_stCtrl.bSTScan = pPara[191];
267 g_stCtrl.bMTTouchThreshold = pPara[192];
268 g_stCtrl.bTime2Idle = pPara[194]; 161 g_stCtrl.bTime2Idle = pPara[194];
269 g_stCtrl.bfPowerMode = pPara[195]; 162 g_stCtrl.bfPowerMode = pPara[195];
270 g_stCtrl.bfIdleMessage = pPara[207]; 163 g_stCtrl.bDebugMessage = pPara[204];
271 g_stCtrl.bDummyRunCycle = pPara[31]; 164 g_stCtrl.bTimerTriggerScale = pPara[205];
272
273 /* Store dummy channel to skip it, data sequence:*/
274 /* Dummy[0](single end) | raw_data |
275 dummy[1](single end) dummy[2](single end) | raw_data |
276 dummy[3](single end)*/
277 165
278 g_stCtrl.u16ResolutionX = ((u16) pPara[PARA_BASIC_LEN + 13]) << 8 | 166 g_stCtrl.u16ResolutionX = ((u16) pPara[PARA_BASIC_LEN + 12]) << 8 | ((u16)pPara[PARA_BASIC_LEN + 11]);
279 ((u16)pPara[PARA_BASIC_LEN + 12]); 167 g_stCtrl.u16ResolutionY = ((u16) pPara[PARA_BASIC_LEN + 14]) << 8 | ((u16)pPara[PARA_BASIC_LEN + 13]);
280 g_stCtrl.u16ResolutionY = ((u16) pPara[PARA_BASIC_LEN + 15]) << 8 |
281 ((u16)pPara[PARA_BASIC_LEN + 14]);
282 168
283 if ((g_stCtrl.u16ResolutionX == 0) || (g_stCtrl.u16ResolutionY == 0)) { 169 if ((g_stCtrl.u16ResolutionX == 0) || (g_stCtrl.u16ResolutionY == 0)) {
284 g_stCtrl.u16ResolutionX = RM_INPUT_RESOLUTION_X; 170 g_stCtrl.u16ResolutionX = RM_INPUT_RESOLUTION_X;
285 g_stCtrl.u16ResolutionY = RM_INPUT_RESOLUTION_Y; 171 g_stCtrl.u16ResolutionY = RM_INPUT_RESOLUTION_Y;
286 } 172 }
287
288} 173}
289 174
290/*===========================================================================*/ 175/*=============================================================================*/
291MODULE_AUTHOR("xxxxxxxxxx <xxxxxxxx@rad-ic.com>"); 176MODULE_AUTHOR("xxxxxxxxxx <xxxxxxxx@rad-ic.com>");
292MODULE_DESCRIPTION("Raydium touchscreen control functions"); 177MODULE_DESCRIPTION("Raydium touchscreen control functions");
293MODULE_LICENSE("GPL"); 178MODULE_LICENSE("GPL");