input: touch: raydium: updates for RM31100 chip
Xiaohui Tao [Wed, 17 Oct 2012 18:35:32 +0000 (11:35 -0700)]
Raydium code drop.
Add support for the new Raydium chip;
Working for both the old chip and new one

Bug 1162178

Signed-off-by: Xiaohui Tao <xtao@nvidia.com>
Reviewed-on: http://git-master/r/145319
(cherry picked from commit df26903f2f776b20a4b70eb0a16e9cf65b2a216c)
Signed-off-by: David Jung <djung@nvidia.com>
Change-Id: Ibbb0e8dc92241753799b91fd2f37263a28404dc1
Reviewed-on: http://git-master/r/146047
Reviewed-by: Thomas Cherry <tcherry@nvidia.com>

drivers/input/touchscreen/rm31080a_ctrl.c
drivers/input/touchscreen/rm31080a_ts.c
include/linux/spi/rm31080a_ctrl.h
include/linux/spi/rm31080a_ts.h

index 516d2bd..e1f1f8f 100644 (file)
@@ -24,7 +24,7 @@
 //DEFINITIONS
 //=============================================================================
 #define RM31080_RAW_DATA_LENGTH 2048
-#define MAX_AVERAGE_TIMES        128
+#define MAX_AVERAGE_TIMES              128
 //=============================================================================
 //STRUCTURE DECLARATION
 //=============================================================================
@@ -60,7 +60,7 @@ unsigned char bfSign[60];
 
 //=============================================================================
 // Description:
-//      Control functions for Touch IC
+//       Control functions for Touch IC
 // Input:
 //
 // Output:
@@ -71,7 +71,7 @@ int rm31080_ctrl_clear_int(void)
 {
        u8 flag;
 #if ENABLE_T007B1_SETTING
-       if (g_stCtrl.bICVersion == T007_VERSION_B)
+       if (g_stCtrl.bICVersion != T007A6)
                return rm31080_spi_byte_read(RM31080B1_REG_BANK0_02H, &flag);
        else
 #endif
@@ -101,9 +101,9 @@ void rm31080_ctrl_wait_for_scan_finish(void)
 // Description:
 //
 // Input:
-//      N/A
+//             N/A
 // Output:
-//      N/A
+//             N/A
 //=============================================================================
 //Marty added
 int rm31080_soft_average(signed char *pSource)
@@ -269,7 +269,7 @@ int rm31080_soft_average(signed char *pSource)
                                        bResult1 = (s16Sum / g_bMFCounter[bMaxBlockId]);
                                        //if (g_stCtrl.bfNoiseDetector)
                                        //{
-                                       //    bResult1 = (s16)bResult1 * 4 / 5;
+                                       //      bResult1 = (s16)bResult1 * 4 / 5;
                                        //}
                                }
                        }
@@ -286,7 +286,7 @@ int rm31080_soft_average(signed char *pSource)
                                bResult2 = (bMax + bMin) / 2;
                                //if (g_stCtrl.bfNoiseDetector)
                                //{
-                               //    bResult2 = (s16)bResult2 * 4 / 5;
+                               //      bResult2 = (s16)bResult2 * 4 / 5;
                                //}
 
                        }
@@ -315,7 +315,7 @@ int rm31080_soft_average(signed char *pSource)
                        bResult0 = (s16Sum / g_stCtrl.bNoiseRepeatTimes);       // + 0x80;
                        //if (g_stCtrl.bfNoiseDetector)
                        //{
-                       //    bResult0 = (s16)bResult0 * 4 / 5;
+                       //      bResult0 = (s16)bResult0 * 4 / 5;
                        //}
 
                        if (g_stCtrl.bfMediumFilter & 0x01) {
@@ -378,33 +378,33 @@ int rm31080_soft_average(signed char *pSource)
 // Description:
 //
 // Input:
-//      N/A
+//             N/A
 // Output:
-//      N/A
+//             N/A
 //=============================================================================
 void rm_set_repeat_times(u8 u8Times)
 {
        u8 bReg1_1Fh = 0x00;
        u8 u8Reg = 0x00;
 #if ENABLE_T007B1_SETTING
-       if (g_stCtrl.bICVersion == T007_VERSION_B)
+       if (g_stCtrl.bICVersion != T007A6)
        {
-       u8Reg = g_stCtrl.bSenseNumber - 1;
-       rm31080_spi_byte_write(0x0A, u8Reg&0x0F);
-       rm31080_spi_byte_write(0x0E, u8Times&0x1F);
-       if (g_stCtrl.bfADFC)
-               bReg1_1Fh |= ADFC;
-
-       if (g_stCtrl.bfTHMode)
-               bReg1_1Fh |= FILTER_THRESHOLD_MODE;
-       else
-               bReg1_1Fh &= ~FILTER_NONTHRESHOLD_MODE;
-               //bReg1_1Fh |= FILTER_NONTHRESHOLD_MODE;
+               u8Reg = g_stCtrl.bSenseNumber - 1;
+               rm31080_spi_byte_write(0x0A, u8Reg&0x0F);
+               rm31080_spi_byte_write(0x0E, u8Times&0x1F);
+               if ((g_stCtrl.bfADFC) && (g_stCtrl.bICVersion != T007_VERSION_C))
+                       bReg1_1Fh |= ADFC;
+
+               if (g_stCtrl.bfTHMode)
+                       bReg1_1Fh |= FILTER_THRESHOLD_MODE;
+               else
+                       bReg1_1Fh &= ~FILTER_NONTHRESHOLD_MODE;
+                       //bReg1_1Fh |= FILTER_NONTHRESHOLD_MODE;
 
-       if (u8Times != REPEAT_1)
-               bReg1_1Fh |= 0x44;     //Marty 20120820
+               if (u8Times != REPEAT_1)
+                       bReg1_1Fh |= 0x44;      //Marty 20120820
 
-       rm31080_spi_byte_write(RM31080_REG_1F, bReg1_1Fh);
+               rm31080_spi_byte_write(RM31080_REG_1F, bReg1_1Fh);
        }
        else
 #endif
@@ -432,9 +432,9 @@ void rm_set_repeat_times(u8 u8Times)
 // Description:
 //
 // Input:
-//      N/A
+//             N/A
 // Output:
-//      N/A
+//             N/A
 //=============================================================================
 NOISE_DETECTOR_RET_t rm_noise_detect(signed char *pSource)
 {
@@ -451,7 +451,7 @@ NOISE_DETECTOR_RET_t rm_noise_detect(signed char *pSource)
 
 
 #if ENABLE_T007B1_SETTING
-       if (g_stCtrl.bICVersion == T007_VERSION_B)
+       if (g_stCtrl.bICVersion != T007A6)
        {
                wSENum = 0;
                return ND_DETECTOR_OFF;
@@ -481,9 +481,10 @@ NOISE_DETECTOR_RET_t rm_noise_detect(signed char *pSource)
                        for (i = 0; i < XNum; i++) {
                                if (g_stCtrl.bADCNumber) {
                                        if ((i == g_stCtrl.bDummyChannel[0])
-                                           || (i == g_stCtrl.bDummyChannel[1])
-                                           || (i == g_stCtrl.bDummyChannel[2])
-                                           || (i == g_stCtrl.bDummyChannel[3])) {
+                                               || (i == g_stCtrl.bDummyChannel[1])
+                                               || (i == g_stCtrl.bDummyChannel[2])
+                                               || (i == g_stCtrl.bDummyChannel[3]))
+                                       {
                                                continue;
                                        }
                                } else {
@@ -670,7 +671,7 @@ int rm_noise_main(signed char *pSource)
                iRet = 0;
 
 #if ENABLE_T007B1_SETTING
-       if (g_stCtrl.bICVersion != T007_VERSION_B)
+       if (g_stCtrl.bICVersion == T007A6)
 #endif
        {
 #if ENABLE_NEW_NOISE_MODE
@@ -688,9 +689,9 @@ int rm_noise_main(signed char *pSource)
 // Description:
 //
 // Input:
-//      N/A
+//             N/A
 // Output:
-//      N/A
+//             N/A
 //=============================================================================
 void rm31080_ctrl_set_baseline(void *arg)
 {
@@ -708,9 +709,9 @@ void rm31080_ctrl_set_baseline(void *arg)
 // Description:
 //
 // Input:
-//      N/A
+//             N/A
 // Output:
-//      N/A
+//             N/A
 //=============================================================================
 void rm31080_ctrl_set_analog_baseline(void *arg)
 {
@@ -727,9 +728,9 @@ void rm31080_ctrl_set_analog_baseline(void *arg)
 // Description:
 //
 // Input:
-//      N/A
+//             N/A
 // Output:
-//      N/A
+//             N/A
 //=============================================================================
 void rm31080_ctrl_init(void)
 {
@@ -747,6 +748,7 @@ void rm31080_ctrl_init(void)
        g_stCtrl.bfNoisePreHold = 0;
        g_stCtrl.bfTouched = 0;
        g_stCtrl.bfExitNoiseMode = 0;
+    g_stCtrl.bDummyRunCycle = 1;
 
        g_stCtrl.u16DataLength = RM31080_RAW_DATA_LENGTH;
        g_bfFirstAverage = 0;
@@ -763,9 +765,9 @@ void rm31080_ctrl_init(void)
 // Description:
 //
 // Input:
-//      N/A
+//             N/A
 // Output:
-//      N/A
+//             N/A
 //=============================================================================
 unsigned char rm31080_ctrl_get_noise_mode(u8 * p)
 {
@@ -793,9 +795,9 @@ void rm31080b_sw_reset(void)
 // Description: Set T007B analog filter repeat
 //
 // Input:
-//      Analog average tap number
+//             Analog average tap number
 // Output:
-//      none
+//             none
 //=============================================================================
 void rm31080b_analog_filter_config(unsigned char u8Amount)
 {
@@ -814,9 +816,9 @@ void rm31080b_analog_filter_config(unsigned char u8Amount)
 // Description: Set T007B digital  filter repeat
 //
 // Input:
-//      Digital average tap number
+//             Digital average tap number
 // Output:
-//      none
+//             none
 //=============================================================================
 void rm31080b_digital_filter_config(unsigned char u8Amount)
 {
@@ -835,22 +837,22 @@ void rm31080b_digital_filter_config(unsigned char u8Amount)
 // Description:
 //
 // Input:
-//      N/A
+//             N/A
 // Output:
-//      N/A
+//             N/A
 //=============================================================================
 
 #if ENABLE_FILTER_SWITCH
 void rm31080_analog_filter_config(u8 bRepeatTimes)
 {
 #if ENABLE_T007B1_SETTING
-       if (g_stCtrl.bICVersion != T007_VERSION_B)
+       if (g_stCtrl.bICVersion == T007A6)
 #endif
        {
                //u8 bReg0_1Fh = 0x00;
 
                //InitChargePump();
-               rm31080_spi_byte_write(0x7F, 0x01);     // Switch to 0x01
+               rm31080_spi_byte_write(0x7F, 0x01);             // Switch to 0x01
 
                rm31080_spi_byte_write(0x09, g_stCtrl.bReg1_09h[1]);
                rm31080_spi_byte_write(0x43, g_stCtrl.bReg1_43h[1]);
@@ -859,7 +861,7 @@ void rm31080_analog_filter_config(u8 bRepeatTimes)
                rm31080_spi_byte_write(0x4A, g_stCtrl.bReg1_4Ah[1]);
                rm31080_spi_byte_write(0x4B, g_stCtrl.bReg1_4Bh[1]);
 
-               rm31080_spi_byte_write(0x7F, 0x00);     // Switch to BANK0
+               rm31080_spi_byte_write(0x7F, 0x00);             // Switch to BANK0
 
                #if 0
                rm31080_spi_byte_write(0x0E, ( 0x38 | 0x00)); //bSenseNumber = 8, REPEAT_1
@@ -907,118 +909,118 @@ void rm31080_analog_filter_config(u8 bRepeatTimes)
 void rm31080_digital_filter_config(void)
 {
 #if ENABLE_T007B1_SETTING
-       if (g_stCtrl.bICVersion != T007_VERSION_B)
+       if (g_stCtrl.bICVersion == T007A6)
 #endif
-    {
-       //u8 bReg0_1Fh = 0x00;
+       {
+               //u8 bReg0_1Fh = 0x00;
 
-       //InitChargePump();
-       rm31080_spi_byte_write(0x7F, 0x01);     // Switch to BANK1
+               //InitChargePump();
+               rm31080_spi_byte_write(0x7F, 0x01);     // Switch to BANK1
 
-       rm31080_spi_byte_write(0x09, g_stCtrl.bReg1_09h[0]);
-       rm31080_spi_byte_write(0x43, g_stCtrl.bReg1_43h[0]);
-       rm31080_spi_byte_write(0x48, g_stCtrl.bReg1_48h[0]);
-       rm31080_spi_byte_write(0x49, g_stCtrl.bReg1_49h[0]);
-       rm31080_spi_byte_write(0x4A, g_stCtrl.bReg1_4Ah[0]);
-       rm31080_spi_byte_write(0x4B, g_stCtrl.bReg1_4Bh[0]);
+               rm31080_spi_byte_write(0x09, g_stCtrl.bReg1_09h[0]);
+               rm31080_spi_byte_write(0x43, g_stCtrl.bReg1_43h[0]);
+               rm31080_spi_byte_write(0x48, g_stCtrl.bReg1_48h[0]);
+               rm31080_spi_byte_write(0x49, g_stCtrl.bReg1_49h[0]);
+               rm31080_spi_byte_write(0x4A, g_stCtrl.bReg1_4Ah[0]);
+               rm31080_spi_byte_write(0x4B, g_stCtrl.bReg1_4Bh[0]);
 
-       rm31080_spi_byte_write(0x7F, 0x00);     // Switch to 0x00
+               rm31080_spi_byte_write(0x7F, 0x00);             // Switch to 0x00
 
-       #if 0
-       rm31080_spi_byte_write(0x0E, ( 0x38 | 0x04)); //bSenseNumber = 8, REPEAT_5
+               #if 0
+               rm31080_spi_byte_write(0x0E, ( 0x38 | 0x04)); //bSenseNumber = 8, REPEAT_5
 
-       rm31080_spi_byte_read(0x1F, &bReg0_1Fh);
-       bReg0_1Fh = bReg0_1Fh & 0xF8;
-       bReg0_1Fh = bReg0_1Fh | 0x07;//REPEAT_5
+               rm31080_spi_byte_read(0x1F, &bReg0_1Fh);
+               bReg0_1Fh = bReg0_1Fh & 0xF8;
+               bReg0_1Fh = bReg0_1Fh | 0x07;//REPEAT_5
 
-       rm31080_spi_byte_write(0x1F, bReg0_1Fh);
-       #endif
-       rm_set_repeat_times(g_stCtrl.bRepeatTimes[0]);
+               rm31080_spi_byte_write(0x1F, bReg0_1Fh);
+               #endif
+               rm_set_repeat_times(g_stCtrl.bRepeatTimes[0]);
 
-// -------- Set Driving / Sensing Control Mode --------
-       if(!g_stCtrl.bfAnalogFilter)
-       {
-               rm31080_spi_byte_write(RM31080_REG_10, 0x10 |0x40); //ACC | DDSC
-       }
+       // -------- Set Driving / Sensing Control Mode --------
+               if(!g_stCtrl.bfAnalogFilter)
+               {
+                       rm31080_spi_byte_write(RM31080_REG_10, 0x10 |0x40); //ACC | DDSC
+               }
 
-// -------- Set PGA/DAC --------
-       rm31080_spi_byte_write(0x6B, 0x04); //EN_C0
-
-// -------- Scan Time Setting --------
-       rm31080_spi_byte_write(RM31080_REG_42, g_stCtrl.bReg0_42h[g_stCtrl.bfAnalogFilter]);  //LACTIVE
-       rm31080_spi_byte_write(RM31080_REG_43, g_stCtrl.bReg0_43h[g_stCtrl.bfAnalogFilter]);  //LACTIVE
-
-       rm31080_spi_byte_write(0x20, g_stCtrl.bReg0_20h[g_stCtrl.bfAnalogFilter]);
-       rm31080_spi_byte_write(0x21, g_stCtrl.bReg0_21h[g_stCtrl.bfAnalogFilter]);
-       rm31080_spi_byte_write(0x22, g_stCtrl.bReg0_22h[g_stCtrl.bfAnalogFilter]);
-       rm31080_spi_byte_write(0x23, g_stCtrl.bReg0_23h[g_stCtrl.bfAnalogFilter]);
-       rm31080_spi_byte_write(0x24, g_stCtrl.bReg0_24h[g_stCtrl.bfAnalogFilter]);
-       rm31080_spi_byte_write(0x25, g_stCtrl.bReg0_25h[g_stCtrl.bfAnalogFilter]);
-       rm31080_spi_byte_write(0x26, g_stCtrl.bReg0_26h[g_stCtrl.bfAnalogFilter]);
-       rm31080_spi_byte_write(0x27, g_stCtrl.bReg0_27h[g_stCtrl.bfAnalogFilter]);
-       rm31080_spi_byte_write(0x28, g_stCtrl.bReg0_28h[g_stCtrl.bfAnalogFilter]);
-       rm31080_spi_byte_write(0x29, g_stCtrl.bReg0_29h[g_stCtrl.bfAnalogFilter]);
-       rm31080_spi_byte_write(0x2A, g_stCtrl.bReg0_2Ah[g_stCtrl.bfAnalogFilter]);
-       rm31080_spi_byte_write(0x2B, g_stCtrl.bReg0_2Bh[g_stCtrl.bfAnalogFilter]);
-       rm31080_spi_byte_write(0x2C, g_stCtrl.bReg0_2Ch[g_stCtrl.bfAnalogFilter]);
-       rm31080_spi_byte_write(0x2D, g_stCtrl.bReg0_2Dh[g_stCtrl.bfAnalogFilter]);
-       rm31080_spi_byte_write(0x2E, g_stCtrl.bReg0_2Eh[g_stCtrl.bfAnalogFilter]);
-       rm31080_spi_byte_write(0x2F, g_stCtrl.bReg0_2Fh[g_stCtrl.bfAnalogFilter]);
-       rm31080_spi_byte_write(0x30, g_stCtrl.bReg0_30h[g_stCtrl.bfAnalogFilter]);
-       rm31080_spi_byte_write(0x31, g_stCtrl.bReg0_31h[g_stCtrl.bfAnalogFilter]);
-       rm31080_spi_byte_write(0x32, g_stCtrl.bReg0_32h[g_stCtrl.bfAnalogFilter]);
-       rm31080_spi_byte_write(0x33, g_stCtrl.bReg0_33h[g_stCtrl.bfAnalogFilter]);
-    }
+       // -------- Set PGA/DAC --------
+               rm31080_spi_byte_write(0x6B, 0x04); //EN_C0
+
+       // -------- Scan Time Setting --------
+               rm31080_spi_byte_write(RM31080_REG_42, g_stCtrl.bReg0_42h[g_stCtrl.bfAnalogFilter]);  //LACTIVE
+               rm31080_spi_byte_write(RM31080_REG_43, g_stCtrl.bReg0_43h[g_stCtrl.bfAnalogFilter]);  //LACTIVE
+
+               rm31080_spi_byte_write(0x20, g_stCtrl.bReg0_20h[g_stCtrl.bfAnalogFilter]);
+               rm31080_spi_byte_write(0x21, g_stCtrl.bReg0_21h[g_stCtrl.bfAnalogFilter]);
+               rm31080_spi_byte_write(0x22, g_stCtrl.bReg0_22h[g_stCtrl.bfAnalogFilter]);
+               rm31080_spi_byte_write(0x23, g_stCtrl.bReg0_23h[g_stCtrl.bfAnalogFilter]);
+               rm31080_spi_byte_write(0x24, g_stCtrl.bReg0_24h[g_stCtrl.bfAnalogFilter]);
+               rm31080_spi_byte_write(0x25, g_stCtrl.bReg0_25h[g_stCtrl.bfAnalogFilter]);
+               rm31080_spi_byte_write(0x26, g_stCtrl.bReg0_26h[g_stCtrl.bfAnalogFilter]);
+               rm31080_spi_byte_write(0x27, g_stCtrl.bReg0_27h[g_stCtrl.bfAnalogFilter]);
+               rm31080_spi_byte_write(0x28, g_stCtrl.bReg0_28h[g_stCtrl.bfAnalogFilter]);
+               rm31080_spi_byte_write(0x29, g_stCtrl.bReg0_29h[g_stCtrl.bfAnalogFilter]);
+               rm31080_spi_byte_write(0x2A, g_stCtrl.bReg0_2Ah[g_stCtrl.bfAnalogFilter]);
+               rm31080_spi_byte_write(0x2B, g_stCtrl.bReg0_2Bh[g_stCtrl.bfAnalogFilter]);
+               rm31080_spi_byte_write(0x2C, g_stCtrl.bReg0_2Ch[g_stCtrl.bfAnalogFilter]);
+               rm31080_spi_byte_write(0x2D, g_stCtrl.bReg0_2Dh[g_stCtrl.bfAnalogFilter]);
+               rm31080_spi_byte_write(0x2E, g_stCtrl.bReg0_2Eh[g_stCtrl.bfAnalogFilter]);
+               rm31080_spi_byte_write(0x2F, g_stCtrl.bReg0_2Fh[g_stCtrl.bfAnalogFilter]);
+               rm31080_spi_byte_write(0x30, g_stCtrl.bReg0_30h[g_stCtrl.bfAnalogFilter]);
+               rm31080_spi_byte_write(0x31, g_stCtrl.bReg0_31h[g_stCtrl.bfAnalogFilter]);
+               rm31080_spi_byte_write(0x32, g_stCtrl.bReg0_32h[g_stCtrl.bfAnalogFilter]);
+               rm31080_spi_byte_write(0x33, g_stCtrl.bReg0_33h[g_stCtrl.bfAnalogFilter]);
+       }
 }
 
 void rm31080_filter_config(void)
 {
 #if ENABLE_FILTER_SWITCH
 #if ENABLE_T007B1_SETTING
-       if (g_stCtrl.bICVersion != T007_VERSION_B)
+       if (g_stCtrl.bICVersion == T007A6)
 #endif
-    {
-       if (g_stCtrl.bfAnalogFilter)
        {
-#if ENABLE_NEW_NOISE_MODE
-               if ((g_stCtrl.bfNoiseMode & 0x02) && g_stCtrl.bfNoiseDetector)
+               if (g_stCtrl.bfAnalogFilter)
                {
-                       if (g_stCtrl.bfNoiseModeDetector)
+#if ENABLE_NEW_NOISE_MODE
+                       if ((g_stCtrl.bfNoiseMode & 0x02) && g_stCtrl.bfNoiseDetector)
                        {
-                               rm_set_repeat_times(g_stCtrl.bNewNoiseRepeatTimes);
+                               if (g_stCtrl.bfNoiseModeDetector)
+                               {
+                                       rm_set_repeat_times(g_stCtrl.bNewNoiseRepeatTimes);
+                               }
+                               else
+                               {
+                                       rm_set_repeat_times(g_stCtrl.bRepeatTimes[1]);
+                               }
                        }
                        else
-                       {
                                rm_set_repeat_times(g_stCtrl.bRepeatTimes[1]);
-                       }
-               }
-               else
-                       rm_set_repeat_times(g_stCtrl.bRepeatTimes[1]);
 #else
-               rm31080_analog_filter_config(g_stCtrl.bRepeatTimes[1]);
+                       rm31080_analog_filter_config(g_stCtrl.bRepeatTimes[1]);
 #endif
-               //rm_printk("Analog Setting with %d Repeat Times \n", (g_stCtrl.bRepeatTimes[1] + 1));
-       }
-       else
-       {
-#if ENABLE_NEW_NOISE_MODE
-               if ((g_stCtrl.bfNoiseMode & 0x02) && g_stCtrl.bfNoiseDetector)
+                       //rm_printk("Analog Setting with %d Repeat Times \n", (g_stCtrl.bRepeatTimes[1] + 1));
+               }
+               else
                {
-                       if (g_stCtrl.bfNoiseModeDetector)
+#if ENABLE_NEW_NOISE_MODE
+                       if ((g_stCtrl.bfNoiseMode & 0x02) && g_stCtrl.bfNoiseDetector)
                        {
-                               rm_set_repeat_times(g_stCtrl.bNewNoiseRepeatTimes);
+                               if (g_stCtrl.bfNoiseModeDetector)
+                               {
+                                       rm_set_repeat_times(g_stCtrl.bNewNoiseRepeatTimes);
+                               }
+                               else
+                               {
+                                       rm31080_digital_filter_config();
+                               }
                        }
                        else
-                       {
-                               rm31080_digital_filter_config();
-                       }
-               }
-               else
 #endif
-               rm31080_digital_filter_config();
-               //rm_printk("Digital Setting with %d Repeat Times \n", (g_stCtrl.bRepeatTimes[0]));
-       }
-       //rm_printk("Disable Analog Filter\n");
+                       rm31080_digital_filter_config();
+                       //rm_printk("Digital Setting with %d Repeat Times \n", (g_stCtrl.bRepeatTimes[0]));
+               }
+       }       //rm_printk("Disable Analog Filter\n");
 #endif
 }
 
@@ -1027,9 +1029,9 @@ void rm31080_filter_config(void)
 // Description:
 //
 // Input:
-//      N/A
+//             N/A
 // Output:
-//      N/A
+//             N/A
 //=============================================================================
 void rm31080_ctrl_get_parameter(void *arg)
 {
@@ -1070,7 +1072,7 @@ void rm31080_ctrl_get_parameter(void *arg)
        g_stCtrl.bMFBlockNumber = pPara[PARA_BASIC_LEN + PARA_HARDWARE_LEN + 26];       // Noise_Detector
        g_stCtrl.bRepeatTimes[0] = pPara[PARA_BASIC_LEN + PARA_HARDWARE_LEN + 4];       // Noise_Detector
        g_stCtrl.bRepeatTimes[1] = pPara[PARA_BASIC_LEN + PARA_HARDWARE_LEN + 5];       // Noise_Detector
-    g_stCtrl.bIdleRepeatTimes[0] = pPara[PARA_BASIC_LEN + PARA_HARDWARE_LEN + 6];
+       g_stCtrl.bIdleRepeatTimes[0] = pPara[PARA_BASIC_LEN + PARA_HARDWARE_LEN + 6];
        g_stCtrl.bSenseNumber = pPara[PARA_BASIC_LEN + 11];     // Noise_Detector
        g_stCtrl.bfADFC = pPara[PARA_BASIC_LEN + 4];    // Noise_Detector
        g_stCtrl.bfTHMode = pPara[PARA_BASIC_LEN + PARA_HARDWARE_LEN + 10];     // Noise_Detector
@@ -1086,6 +1088,8 @@ void rm31080_ctrl_get_parameter(void *arg)
        g_stCtrl.bMTTouchThreshold = pPara[192];
        g_stCtrl.bTime2Idle = pPara[194];
        g_stCtrl.bfPowerMode= pPara[195];
+    g_stCtrl.bfIdleMessage = pPara[207];
+    g_stCtrl.bDummyRunCycle = pPara[31];
        //
        // Store dummy channel to skip it, data sequence:
        // Dummy[0](single end) | raw_data | dummy[1](single end) dummy[2](single end) | raw_data | dummy[3](single end)
@@ -1142,8 +1146,8 @@ void rm31080_ctrl_get_parameter(void *arg)
 #if ENABLE_RESOLUTION_SWITCH
        g_stCtrl.u16ResolutionX = ((u16) pPara[PARA_BASIC_LEN + 13]) << 8 | ((u16)pPara[PARA_BASIC_LEN + 12]);
        g_stCtrl.u16ResolutionY = ((u16) pPara[PARA_BASIC_LEN + 15]) << 8 | ((u16)pPara[PARA_BASIC_LEN + 14]);
-//     printk("g_stCtrl.u16ResolutionX=%d", g_stCtrl.u16ResolutionX);
-//     printk("g_stCtrl.u16ResolutionY=%d", g_stCtrl.u16ResolutionY);
+       //printk("===========================================================================================>g_stCtrl.u16ResolutionX=%d\n", g_stCtrl.u16ResolutionX);
+       //printk("===========================================================================================>g_stCtrl.u16ResolutionY=%d\n", g_stCtrl.u16ResolutionY);
        if ((g_stCtrl.u16ResolutionX == 0) || (g_stCtrl.u16ResolutionY == 0)) {
                g_stCtrl.u16ResolutionX = RM_INPUT_RESOLUTION_X;
                g_stCtrl.u16ResolutionY = RM_INPUT_RESOLUTION_Y;
@@ -1152,73 +1156,73 @@ void rm31080_ctrl_get_parameter(void *arg)
 
 #if ENABLE_FILTER_SWITCH
 #if ENABLE_T007B1_SETTING
-       if (g_stCtrl.bICVersion != T007_VERSION_B)
+       if (g_stCtrl.bICVersion == T007A6)
 #endif
-    {
-       g_stCtrl.bReg1_09h[0] = pPara[327];     // Addr. 0327
-       g_stCtrl.bReg1_09h[1] = pPara[328];     // Addr. 0328
-       g_stCtrl.bReg1_43h[0] = pPara[337];     // Addr. 0337
-       g_stCtrl.bReg1_43h[1] = pPara[338];     // Addr. 0338
-       g_stCtrl.bReg1_48h[0] = pPara[339];     // Addr. 0339
-       g_stCtrl.bReg1_48h[1] = pPara[340];     // Addr. 0340
-       g_stCtrl.bReg1_49h[0] = pPara[341];     // Addr. 0341
-       g_stCtrl.bReg1_49h[1] = pPara[342];     // Addr. 0342
-       g_stCtrl.bReg1_4Ah[0] = pPara[343];     // Addr. 0343
-       g_stCtrl.bReg1_4Ah[1] = pPara[344];     // Addr. 0344
-       g_stCtrl.bReg1_4Bh[0] = pPara[345];     // Addr. 0345
-       g_stCtrl.bReg1_4Bh[1] = pPara[346];     // Addr. 0346
-
-       g_stCtrl.bReg0_40h[0] = pPara[258];
-       g_stCtrl.bReg0_40h[1] = pPara[259];
-       g_stCtrl.bReg0_41h[0] = pPara[260];
-       g_stCtrl.bReg0_41h[1] = pPara[261];
-       g_stCtrl.bReg0_42h[0] = pPara[262];     // Addr. 0262
-       g_stCtrl.bReg0_42h[1] = pPara[263];     // Addr. 0263
-       g_stCtrl.bReg0_43h[0] = pPara[264];     // Addr. 0264
-       g_stCtrl.bReg0_43h[1] = pPara[265];     // Addr. 0265
-
-// time chart
-       g_stCtrl.bReg0_20h[0] = pPara[213];     // Addr. 0213
-       g_stCtrl.bReg0_20h[1] = pPara[214];     // Addr. 0214
-       g_stCtrl.bReg0_21h[0] = pPara[215];     // Addr. 0215
-       g_stCtrl.bReg0_21h[1] = pPara[216];     // Addr. 0216
-       g_stCtrl.bReg0_22h[0] = pPara[217];     // Addr. 0217
-       g_stCtrl.bReg0_22h[1] = pPara[218];     // Addr. 0218
-       g_stCtrl.bReg0_23h[0] = pPara[219];     // Addr. 0219
-       g_stCtrl.bReg0_23h[1] = pPara[220];     // Addr. 0220
-       g_stCtrl.bReg0_24h[0] = pPara[221];     // Addr. 0221
-       g_stCtrl.bReg0_24h[1] = pPara[222];     // Addr. 0222
-       g_stCtrl.bReg0_25h[0] = pPara[223];     // Addr. 0223
-       g_stCtrl.bReg0_25h[1] = pPara[224];     // Addr. 0224
-       g_stCtrl.bReg0_26h[0] = pPara[225];     // Addr. 0225
-       g_stCtrl.bReg0_26h[1] = pPara[226];     // Addr. 0226
-       g_stCtrl.bReg0_27h[0] = pPara[227];     // Addr. 0227
-       g_stCtrl.bReg0_27h[1] = pPara[228];     // Addr. 0228
-       g_stCtrl.bReg0_28h[0] = pPara[229];     // Addr. 0229
-       g_stCtrl.bReg0_28h[1] = pPara[230];     // Addr. 0230
-       g_stCtrl.bReg0_29h[0] = pPara[231];     // Addr. 0231
-       g_stCtrl.bReg0_29h[1] = pPara[232];     // Addr. 0232
-       g_stCtrl.bReg0_2Ah[0] = pPara[233];     // Addr. 0233
-       g_stCtrl.bReg0_2Ah[1] = pPara[234];     // Addr. 0234
-       g_stCtrl.bReg0_2Bh[0] = pPara[235];     // Addr. 0235
-       g_stCtrl.bReg0_2Bh[1] = pPara[236];     // Addr. 0236
-       g_stCtrl.bReg0_2Ch[0] = pPara[237];     // Addr. 0237
-       g_stCtrl.bReg0_2Ch[1] = pPara[238];     // Addr. 0238
-       g_stCtrl.bReg0_2Dh[0] = pPara[239];     // Addr. 0239
-       g_stCtrl.bReg0_2Dh[1] = pPara[240];     // Addr. 0240
-       g_stCtrl.bReg0_2Eh[0] = pPara[241];     // Addr. 0241
-       g_stCtrl.bReg0_2Eh[1] = pPara[242];     // Addr. 0242
-       g_stCtrl.bReg0_2Fh[0] = pPara[243];     // Addr. 0243
-       g_stCtrl.bReg0_2Fh[1] = pPara[244];     // Addr. 0244
-       g_stCtrl.bReg0_30h[0] = pPara[245];     // Addr. 0245
-       g_stCtrl.bReg0_30h[1] = pPara[246];     // Addr. 0246
-       g_stCtrl.bReg0_31h[0] = pPara[247];     // Addr. 0247
-       g_stCtrl.bReg0_31h[1] = pPara[248];     // Addr. 0248
-       g_stCtrl.bReg0_32h[0] = pPara[249];     // Addr. 0249
-       g_stCtrl.bReg0_32h[1] = pPara[250];     // Addr. 0250
-       g_stCtrl.bReg0_33h[0] = pPara[251];     // Addr. 0251
-       g_stCtrl.bReg0_33h[1] = pPara[252];     // Addr. 0252
-    }
+       {
+               g_stCtrl.bReg1_09h[0] = pPara[327];     // Addr. 0327
+               g_stCtrl.bReg1_09h[1] = pPara[328];     // Addr. 0328
+               g_stCtrl.bReg1_43h[0] = pPara[337];     // Addr. 0337
+               g_stCtrl.bReg1_43h[1] = pPara[338];     // Addr. 0338
+               g_stCtrl.bReg1_48h[0] = pPara[339];     // Addr. 0339
+               g_stCtrl.bReg1_48h[1] = pPara[340];     // Addr. 0340
+               g_stCtrl.bReg1_49h[0] = pPara[341];     // Addr. 0341
+               g_stCtrl.bReg1_49h[1] = pPara[342];     // Addr. 0342
+               g_stCtrl.bReg1_4Ah[0] = pPara[343];     // Addr. 0343
+               g_stCtrl.bReg1_4Ah[1] = pPara[344];     // Addr. 0344
+               g_stCtrl.bReg1_4Bh[0] = pPara[345];     // Addr. 0345
+               g_stCtrl.bReg1_4Bh[1] = pPara[346];     // Addr. 0346
+
+               g_stCtrl.bReg0_40h[0] = pPara[258];
+               g_stCtrl.bReg0_40h[1] = pPara[259];
+               g_stCtrl.bReg0_41h[0] = pPara[260];
+               g_stCtrl.bReg0_41h[1] = pPara[261];
+               g_stCtrl.bReg0_42h[0] = pPara[262];     // Addr. 0262
+               g_stCtrl.bReg0_42h[1] = pPara[263];     // Addr. 0263
+               g_stCtrl.bReg0_43h[0] = pPara[264];     // Addr. 0264
+               g_stCtrl.bReg0_43h[1] = pPara[265];     // Addr. 0265
+
+       // time chart
+               g_stCtrl.bReg0_20h[0] = pPara[213];     // Addr. 0213
+               g_stCtrl.bReg0_20h[1] = pPara[214];     // Addr. 0214
+               g_stCtrl.bReg0_21h[0] = pPara[215];     // Addr. 0215
+               g_stCtrl.bReg0_21h[1] = pPara[216];     // Addr. 0216
+               g_stCtrl.bReg0_22h[0] = pPara[217];     // Addr. 0217
+               g_stCtrl.bReg0_22h[1] = pPara[218];     // Addr. 0218
+               g_stCtrl.bReg0_23h[0] = pPara[219];     // Addr. 0219
+               g_stCtrl.bReg0_23h[1] = pPara[220];     // Addr. 0220
+               g_stCtrl.bReg0_24h[0] = pPara[221];     // Addr. 0221
+               g_stCtrl.bReg0_24h[1] = pPara[222];     // Addr. 0222
+               g_stCtrl.bReg0_25h[0] = pPara[223];     // Addr. 0223
+               g_stCtrl.bReg0_25h[1] = pPara[224];     // Addr. 0224
+               g_stCtrl.bReg0_26h[0] = pPara[225];     // Addr. 0225
+               g_stCtrl.bReg0_26h[1] = pPara[226];     // Addr. 0226
+               g_stCtrl.bReg0_27h[0] = pPara[227];     // Addr. 0227
+               g_stCtrl.bReg0_27h[1] = pPara[228];     // Addr. 0228
+               g_stCtrl.bReg0_28h[0] = pPara[229];     // Addr. 0229
+               g_stCtrl.bReg0_28h[1] = pPara[230];     // Addr. 0230
+               g_stCtrl.bReg0_29h[0] = pPara[231];     // Addr. 0231
+               g_stCtrl.bReg0_29h[1] = pPara[232];     // Addr. 0232
+               g_stCtrl.bReg0_2Ah[0] = pPara[233];     // Addr. 0233
+               g_stCtrl.bReg0_2Ah[1] = pPara[234];     // Addr. 0234
+               g_stCtrl.bReg0_2Bh[0] = pPara[235];     // Addr. 0235
+               g_stCtrl.bReg0_2Bh[1] = pPara[236];     // Addr. 0236
+               g_stCtrl.bReg0_2Ch[0] = pPara[237];     // Addr. 0237
+               g_stCtrl.bReg0_2Ch[1] = pPara[238];     // Addr. 0238
+               g_stCtrl.bReg0_2Dh[0] = pPara[239];     // Addr. 0239
+               g_stCtrl.bReg0_2Dh[1] = pPara[240];     // Addr. 0240
+               g_stCtrl.bReg0_2Eh[0] = pPara[241];     // Addr. 0241
+               g_stCtrl.bReg0_2Eh[1] = pPara[242];     // Addr. 0242
+               g_stCtrl.bReg0_2Fh[0] = pPara[243];     // Addr. 0243
+               g_stCtrl.bReg0_2Fh[1] = pPara[244];     // Addr. 0244
+               g_stCtrl.bReg0_30h[0] = pPara[245];     // Addr. 0245
+               g_stCtrl.bReg0_30h[1] = pPara[246];     // Addr. 0246
+               g_stCtrl.bReg0_31h[0] = pPara[247];     // Addr. 0247
+               g_stCtrl.bReg0_31h[1] = pPara[248];     // Addr. 0248
+               g_stCtrl.bReg0_32h[0] = pPara[249];     // Addr. 0249
+               g_stCtrl.bReg0_32h[1] = pPara[250];     // Addr. 0250
+               g_stCtrl.bReg0_33h[0] = pPara[251];     // Addr. 0251
+               g_stCtrl.bReg0_33h[1] = pPara[252];     // Addr. 0252
+       }
 #endif
 }
 
index abb495d..72065c3 100755 (executable)
@@ -27,6 +27,9 @@
 #include <linux/kthread.h>     /* kthread_create(),kthread_run() */
 #include <asm/uaccess.h>       /* copy_to_user(), */
 #include <linux/miscdevice.h>
+#if defined(CONFIG_HAS_EARLYSUSPEND)
+#include <linux/earlysuspend.h>
+#endif
 
 #include <linux/spi/rm31080a_ts.h>
 #include <linux/spi/rm31080a_ctrl.h>
@@ -136,6 +139,9 @@ struct rm31080_ts {
        bool suspended;
        char phys[32];
        struct mutex access_mutex;
+#if defined(CONFIG_HAS_EARLYSUSPEND)
+       struct early_suspend early_suspend;
+#endif
 };
 
 struct rm31080_bus_ops {
@@ -166,8 +172,12 @@ struct rm31080_queue_info g_stQ;
 /*========================================================================= */
 /*FUNCTION DECLARATION */
 /*========================================================================= */
+#if defined(CONFIG_HAS_EARLYSUSPEND)
+static void rm31080_early_suspend(struct early_suspend *es);
+static void rm31080_early_resume(struct early_suspend *es);
+#endif
 static int rm31080_spi_checking(bool bInfinite);
-/*========================================================================= 
+/*=========================================================================
  * Description:
  *      Debug function: test speed.
  * Input:
@@ -217,7 +227,7 @@ void my_calc_time(int iStart)
    Description:
         RM31080 spi interface.
    Input:
-  
+
    Output:
         1:succeed
         0:failed
@@ -260,7 +270,7 @@ static int rm31080_spi_read(u8 u8addr, u8 * rxbuf, size_t len)
    Description:
         RM31080 spi interface.
    Input:
-  
+
    Output:
         1:succeed
         0:failed
@@ -286,7 +296,7 @@ static int rm31080_spi_write(u8 * txbuf, size_t len)
    Description:
         RM31080 spi interface.
    Input:
-  
+
    Output:
         1:succeed
         0:failed
@@ -300,7 +310,7 @@ int rm31080_spi_byte_read(unsigned char u8Addr, unsigned char *pu8Value)
    Description:
         RM31080 spi interface.
    Input:
-  
+
    Output:
         1:succeed
         0:failed
@@ -317,7 +327,7 @@ int rm31080_spi_byte_write(unsigned char u8Addr, unsigned char u8Value)
    Description:
         RM31080 spi interface.
    Input:
-  
+
    Output:
         1:succeed
         0:failed
@@ -348,7 +358,7 @@ static int rm31080_spi_burst_read(unsigned char u8Addr, unsigned char *pu8Value,
    Description:
         RM31080 spi interface.
    Input:
-  
+
    Output:
         1:succeed
         0:failed
@@ -392,7 +402,7 @@ void raydium_change_scan_mode(u8 u8TouchCount)
 #endif                         /*ENABLE_AUTO_SCAN*/
 /*=========================================================================
   report touch data for scriber
-  
+
   =========================================================================*/
 #ifdef ENABLE_REPORT_TO_UART
 void raydium_report_to_uart_printf(unsigned char *ucData, unsigned char ucCount)
@@ -535,15 +545,19 @@ void raydium_report_pointer(void *p)
 int rm31080_ctrl_read_raw_data(unsigned char *p)
 {
        int ret;
+#if ENABLE_ST_SCAN
+       char buf[3];
+#endif
+
 #if ENABLE_T007B1_SETTING
-       if (g_stCtrl.bICVersion == T007_VERSION_B)
+       if (g_stCtrl.bICVersion != T007A6)
        {
                ret = rm31080_spi_byte_write(RM31080B1_REG_BANK0_00H, 0x00);
                if (ret)
                        ret = rm31080_spi_byte_write(RM31080B1_REG_BANK0_01H, 0x00);
 
                if (ret)
-                       ret = rm31080_spi_read(RM31080B1_REG_BANK0_03H|0x80, p, g_stCtrl.u16DataLength); /*0x80 for SPI burst read */
+                       ret = rm31080_spi_read(RM31080B1_REG_BANK0_03H|0x80, p, g_stCtrl.u16DataLength); /*0x80 for SPI burst read*/
        }
        else
 #endif
@@ -556,41 +570,70 @@ int rm31080_ctrl_read_raw_data(unsigned char *p)
                        ret = rm31080_spi_read(RM31080_REG_80, p, g_stCtrl.u16DataLength);
        }
 
+#if ENABLE_ST_SCAN
+       if (g_stCtrl.bICVersion == T007A6)
+               return ret;
+
+       if (!ret)
+               return ret;
+
+       if (g_stCtrl.u16DataLength + RM_MAX_CHANNEL_COUNT >
+               RAW_DATA_LENGTH)
+       {
+               rm_printk("Raydium TS:No buffer for ST-Scan\n");
+               return 0;
+       }
+       
+       buf[0] = RM31080B1_REG_BANK0_00H;
+       buf[1] = 0x1C;
+       buf[2] = 0xA0;
+       ret = rm31080_spi_burst_write(buf, sizeof(buf));
+
+       if (ret)
+               ret = rm31080_spi_read(RM31080B1_REG_BANK0_03H|0x80,
+                                       p + g_stCtrl.u16DataLength,
+                                       RM_MAX_CHANNEL_COUNT);
+#endif
+
        return ret;
 }
 
 #ifdef ENABLE_AUTO_SCAN
 void rm_set_idle(u8 OnOff)
 {
-    static u8 reg_46h = 0;
-    switch (OnOff)
-    {
-        case 1:
-            rm31080_spi_read(0x46|0x80, &reg_46h, 1);
-            rm31080_spi_byte_write(0x46, reg_46h|0x30);
-            break;
-        default:
-            rm31080_spi_read(0x46|0x80, &reg_46h, 1);
-            rm31080_spi_byte_write(0x46, reg_46h&0x0F);
-            break;
-    }
+       u8 reg_46h;
+       switch (OnOff)
+       {
+               case 1:
+                       rm31080_spi_read(0x46|0x80, &reg_46h, 1);
+                       rm31080_spi_byte_write(0x46, reg_46h|0x30);
+                       break;
+               default:
+                       rm31080_spi_read(0x46|0x80, &reg_46h, 1);
+                       rm31080_spi_byte_write(0x46, reg_46h&0x0F);
+                       break;
+       }
 }
 void rm31080_ctrl_enter_auto_mode(void)
 {
 #if ENABLE_FILTER_SWITCH
        /*rm_printk("Enable Analog Filter\n"); */
 #if ENABLE_T007B1_SETTING
-       if (g_stCtrl.bICVersion != T007_VERSION_B)
+       if (g_stCtrl.bICVersion == T007A6)
 #endif
-           rm31080_analog_filter_config(REPEAT_1);
+               rm31080_analog_filter_config(REPEAT_1);
 #endif
-       //Enable auto scan
-       //rm_printk("Enter Auto Scan Mode\n");
+       /*Enable auto scan*/
+       if (g_stCtrl.bfIdleMessage)
+       {
+               rm_printk("Enter Auto Scan Mode\n");
+       }
 #if ENABLE_T007B1_SETTING
 #if ENABLE_T007B1_STABLE_IDLE_MODE
-       if (g_stCtrl.bICVersion == T007_VERSION_B)
+       if (g_stCtrl.bICVersion != T007A6)
        {
-               rm_set_idle(1);
+               if (!g_stCtrl.bDummyRunCycle)
+                       rm_set_idle(1);
                rm_set_repeat_times(g_stCtrl.bIdleRepeatTimes[0]);
        }
 #endif
@@ -600,13 +643,17 @@ void rm31080_ctrl_enter_auto_mode(void)
 
 void rm31080_ctrl_leave_auto_mode(void)
 {
-       /*Disable auto scan */
-       /*rm_printk("Leave Auto Scan Mode\n"); */
+       /*Disable auto scan*/
+       if (g_stCtrl.bfIdleMessage)
+       {
+               rm_printk("Leave Auto Scan Mode\n");
+       }
 #if ENABLE_T007B1_SETTING
 #if ENABLE_T007B1_STABLE_IDLE_MODE
-       if (g_stCtrl.bICVersion == T007_VERSION_B)
+       if (g_stCtrl.bICVersion != T007A6)
        {
-               rm_set_idle(0);
+               if (!g_stCtrl.bDummyRunCycle)
+                       rm_set_idle(0);
                rm_set_repeat_times(g_stCtrl.bRepeatTimes[0]);
        }
 #endif
@@ -615,9 +662,9 @@ void rm31080_ctrl_leave_auto_mode(void)
 
 #if ENABLE_FILTER_SWITCH
 #if ENABLE_T007B1_SETTING
-       if (g_stCtrl.bICVersion != T007_VERSION_B)
+       if (g_stCtrl.bICVersion == T007A6)
 #endif
-           rm31080_filter_config();
+               rm31080_filter_config();
 #endif
 }
 
@@ -638,8 +685,8 @@ static u32 rm31080_ctrl_configure(void)
        switch (g_stTs.u8ScanModeState) {
        case RM_SCAN_MODE_MANUAL:
                u32Flag =
-                   RM_NEED_TO_SEND_SCAN | RM_NEED_TO_READ_RAW_DATA |
-                   RM_NEED_TO_SEND_SIGNAL;
+                       RM_NEED_TO_SEND_SCAN | RM_NEED_TO_READ_RAW_DATA |
+                       RM_NEED_TO_SEND_SIGNAL;
 
 #if NOISE_SUM_CHECK
                if(g_stTs.u8Repeat)
@@ -662,7 +709,7 @@ static u32 rm31080_ctrl_configure(void)
                rm31080_ctrl_scan_start();
                g_stTs.u8ScanModeState = RM_SCAN_MODE_MANUAL;
 #if ENABLE_T007B1_SETTING
-               if (g_stCtrl.bICVersion == T007_VERSION_B)
+               if (g_stCtrl.bICVersion != T007A6)
                {
                        u32Flag =
                                RM_NEED_TO_SEND_SCAN | RM_NEED_TO_READ_RAW_DATA |
@@ -688,8 +735,8 @@ static u32 rm31080_ctrl_configure(void)
 #ifdef ENABLE_RM31080_DEEP_SLEEP
 static int rm31080_ctrl_suspend(void)
 {
-       
-  /*Flow designed by Roger 20110930 */
+
+       /*Flow designed by Roger 20110930 */
        /*rm31080_ts_send_signal(g_stTs.ulHalPID,RM_SIGNAL_SUSPEND); */
        g_stTs.bInitFinish = 0;
        mutex_lock(&g_stTs.mutex_scan_mode);
@@ -697,7 +744,7 @@ static int rm31080_ctrl_suspend(void)
        rm31080_ctrl_clear_int();
        /*disable auto scan */
 #if ENABLE_T007B1_SETTING
-       if (g_stCtrl.bICVersion != T007_VERSION_B)
+       if (g_stCtrl.bICVersion == T007A6)
 #endif
        {
                rm31080_spi_byte_write(RM31080_REG_09, 0x00);
@@ -748,24 +795,40 @@ static long rm31080_get_config(u8 * p, u32 u32Len)
        struct rm_spi_ts_platform_data *pdata;
 
 #if ENABLE_T007B1_SETTING
-    u8 var;
-    if (rm31080_spi_byte_read(RM31080_REG_7E, &var))
+       u8 var;
+       if (rm31080_spi_byte_read(RM31080_REG_7E, &var))
                g_stCtrl.bICVersion = var & 0xF0;
        else
                g_stCtrl.bICVersion = T007A6;
 #endif
 
        pdata = g_input_dev->dev.parent->platform_data;
+
+       switch(g_stCtrl.bICVersion)
+       {
+               case T007_VERSION_B:
+                       u32Ret = copy_to_user(p, pdata->config + (PARAMETER_AMOUNT*VERSION_B_PARAMETER_OFFSET), u32Len);
+                       break;
+               case T007_VERSION_C:
+                       u32Ret = copy_to_user(p, pdata->config + (PARAMETER_AMOUNT*VERSION_C_PARAMETER_OFFSET), u32Len);
+                       break;
+               default:
+                       u32Ret = copy_to_user(p, pdata->config, u32Len);
+       }
+
+/*
 #if ENABLE_T007B1_SETTING
-       if (g_stCtrl.bICVersion == T007_VERSION_B)
-               u32Ret = copy_to_user(p, pdata->config + 384, u32Len);
+       if (g_stCtrl.bICVersion != T007A6)
+               u32Ret = copy_to_user(p, pdata->config + PARAMETER_AMOUNT, u32Len);
        else
 #endif
-           u32Ret = copy_to_user(p, pdata->config, u32Len);
+               u32Ret = copy_to_user(p, pdata->config, u32Len);
+*/
        if (u32Ret != 0)
                return 0;
        return 1;
 }
+
 static u32 rm31080_get_platform_id(u8 * p)
 {
        u32 u32Ret;
@@ -776,6 +839,7 @@ static u32 rm31080_get_platform_id(u8 * p)
                return 0;
        return 1;
 }
+
 /*=========================================================================*/
 int rm31080_ts_send_signal(int pid, int iInfo)
 {
@@ -909,7 +973,7 @@ static void *rm31080_enqueue_start(void)
        if (!rm31080_queue_is_full())
                return &g_stQ.pQueue[g_stQ.u16Rear];
 
-       rm_printk("rm31080:touch service is busy,try again.\n");
+       /* rm_printk("rm31080:touch service is busy,try again.\n"); */
        return NULL;
 }
 
@@ -1314,10 +1378,10 @@ static ssize_t rm31080_slowscan_show(struct device *dev,
 {
 #ifdef ENABLE_SLOW_SCAN
        return sprintf(buf, "Slow Scan:%s\nScan Rate:%dHz\n",
-                      g_stTs.bEnableSlowScan ?
-                      "Enabled" : "Disabled",
-                      g_stTs.bEnableSlowScan ?
-                      RM_SLOW_SCAN_LEVEL_20 : g_stTs.u32SlowScanLevel);
+                               g_stTs.bEnableSlowScan ?
+                               "Enabled" : "Disabled",
+                               g_stTs.bEnableSlowScan ?
+                               RM_SLOW_SCAN_LEVEL_20 : g_stTs.u32SlowScanLevel);
 
 #else
        return sprintf(buf, "Not implemented yet\n");
@@ -1325,8 +1389,8 @@ static ssize_t rm31080_slowscan_show(struct device *dev,
 }
 
 static ssize_t rm31080_slowscan_store(struct device *dev,
-                                     struct device_attribute *attr,
-                                     const char *buf, size_t count)
+                                               struct device_attribute *attr,
+                                               const char *buf, size_t count)
 {
 #ifdef ENABLE_SLOW_SCAN
        return rm31080_slowscan_handler(buf, count);
@@ -1452,13 +1516,13 @@ static ssize_t rm31080_version_store(struct device *dev,
 }
 
 static DEVICE_ATTR(slowscan_enable, 0666, rm31080_slowscan_show,
-                  rm31080_slowscan_store);
+                       rm31080_slowscan_store);
 static DEVICE_ATTR(smooth_level, 0666, rm31080_smooth_level_show,
-                  rm31080_smooth_level_store);
+                       rm31080_smooth_level_store);
 static DEVICE_ATTR(self_test, 0666, rm31080_self_test_show,
-                  rm31080_self_test_store);
+                       rm31080_self_test_store);
 static DEVICE_ATTR(version, 0666, rm31080_version_show,
-                  rm31080_version_store);
+                       rm31080_version_store);
 
 static struct attribute *rm_ts_attributes[] = {
        &dev_attr_slowscan_enable.attr,
@@ -1562,15 +1626,17 @@ void rm31080_set_variable(unsigned int index, unsigned int arg)
        }
 
 }
+
 static u32 rm31080_get_variable(unsigned int index, unsigned int arg)
 {
        u32 ret = 0;
-       switch (index) {
-       case RM_VARIABLE_PLATFORM_ID:
-               ret = rm31080_get_platform_id((u8 *) arg);
-               break;
-       default:
-               break;
+       switch (index)
+       {
+               case RM_VARIABLE_PLATFORM_ID:
+                       ret = rm31080_get_platform_id((u8 *) arg);
+                       break;
+               default:
+                       break;
        }
 
        return ret;
@@ -1613,51 +1679,79 @@ static int rm31080_spi_setting(u32 speed)
 /*=========================================================================*/
 static int rm31080_spi_checking(bool bInfinite)
 {
-
        unsigned int i;
        unsigned int iTestCount = 0;
        unsigned char wbuf[] = { 0x50, 0x55, 0xAA, 0x00, 0xFF };
        unsigned char rbuf[sizeof(wbuf)];
        unsigned int iLen;
        int iFail;
+
+#if ENABLE_T007B1_SETTING
+       unsigned char var;
+       if (rm31080_spi_byte_read(RM31080_REG_7E, &var))
+       {
+               if((var & 0xF0) != T007A6)
+               {
+                       wbuf[0] = 0x6E;
+                       var = 0x01;
+                       rm31080_spi_byte_write(RM31080_REG_7F, var);
+               }
+       }
+#endif
+
        rbuf[0] = wbuf[0] | 0x80;       /*address*/
        iLen = sizeof(wbuf) - 1;
-       do {
+       do
+       {
                spi_write(g_spi, wbuf, sizeof(wbuf));
                memset(&rbuf[1], 0, iLen);
                spi_write_then_read(g_spi, &rbuf[0], 1, &rbuf[1], iLen);
 
                /*compare*/
                iFail = 0;
-               for (i = 1; i < iLen + 1; i++) {
-                       if (wbuf[i] != rbuf[i]) {
+               for (i = 1; i < iLen + 1; i++)
+               {
+                       if (wbuf[i] != rbuf[i])
+                       {
                                iFail = 1;
                                break;
                        }
                }
 
-               if (iFail) {
+               if (iFail)
+               {
                        rm_printk("Raydium SPI Checking:Compare fail\n");
                        rm_printk("SPI Speed:%d hz,Mode:%x\n",
-                                 g_spi->max_speed_hz, g_spi->mode);
-                       for (i = 1; i < iLen + 1; i++) {
+                                       g_spi->max_speed_hz, g_spi->mode);
+                       for (i = 1; i < iLen + 1; i++)
+                       {
                                rm_printk
-                                   ("[%02d]Write Data:0x%02x ,Read Data:0x%02x\n",
-                                    i, wbuf[i], rbuf[i]);
+                                       ("[%02d]Write Data:0x%02x ,Read Data:0x%02x\n", i, wbuf[i], rbuf[i]);
                        }
                        msleep(300);
-               } else {
+               }
+               else
+               {
                        iTestCount++;
-                       if ((iTestCount % 10000) == 0) {
+                       if ((iTestCount % 10000) == 0)
+                       {
                                rm_printk
-                                   ("SPI test:%d times ok.(Speed:%d hz,Mode:%x)\n",
-                                    iTestCount, g_spi->max_speed_hz,
-                                    g_spi->mode);
+                                       ("SPI test:%d times ok.(Speed:%d hz,Mode:%x)\n",
+                                       iTestCount, g_spi->max_speed_hz,
+                                       g_spi->mode);
                        }
                }
        } while (bInfinite);
 
-       if (!iFail) {
+       if (!iFail)
+       {
+#if ENABLE_T007B1_SETTING
+               if(wbuf[0] == 0x6E)
+               {
+                       var = 0x00;
+                       rm31080_spi_byte_write(RM31080_REG_7F, var);
+               }
+#endif
                rm_printk("Raydium SPI Checking: ok\n");
        }
 
@@ -1722,11 +1816,38 @@ static int rm31080_resume(struct device *dev)
        rm31080_start(ts);
        return 0;
 }
+#if defined(CONFIG_HAS_EARLYSUSPEND)
+static void rm31080_early_suspend(struct early_suspend *es)
+{
+       struct rm31080_ts *ts;
+       struct device *dev;
+
+       ts = container_of(es, struct rm31080_ts, early_suspend);
+       dev = ts->dev;
+
+       if (rm31080_suspend(dev) != 0) {
+               dev_err(dev, "%s: failed\n", __func__);
+       }
+}
 
+static void rm31080_early_resume(struct early_suspend *es)
+{
+       struct rm31080_ts *ts;
+       struct device *dev;
+
+       ts = container_of(es, struct rm31080_ts, early_suspend);
+       dev = ts->dev;
+
+       if (rm31080_resume(dev) != 0) {
+               dev_err(dev, "%s: failed\n", __func__);
+       }
+}
+#else
 static const struct dev_pm_ops rm31080_pm_ops = {
        .suspend = rm31080_suspend,
        .resume = rm31080_resume,
 };
+#endif                         /*CONFIG_HAS_EARLYSUSPEND */
 #endif                         /*CONFIG_PM */
 
 static void rm31080_set_input_resolution(unsigned int x, unsigned int y)
@@ -1738,7 +1859,7 @@ static void rm31080_set_input_resolution(unsigned int x, unsigned int y)
 }
 
 struct rm31080_ts *rm31080_input_init(struct device *dev, unsigned int irq,
-                                     const struct rm31080_bus_ops *bops)
+                                               const struct rm31080_bus_ops *bops)
 {
 
        struct rm31080_ts *ts;
@@ -1789,20 +1910,27 @@ struct rm31080_ts *rm31080_input_init(struct device *dev, unsigned int irq,
        __set_bit(BTN_TOUCH, input_dev->keybit);
 
        rm31080_set_input_resolution(RM_INPUT_RESOLUTION_X,
-                                    RM_INPUT_RESOLUTION_Y);
+                                               RM_INPUT_RESOLUTION_Y);
        input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, 0xFF, 0, 0);
        input_set_abs_params(input_dev, ABS_MT_WIDTH_MAJOR, 0, 0xFF, 0, 0);
        input_set_abs_params(input_dev, ABS_MT_PRESSURE, 0, 0xFF, 0, 0);
        input_set_abs_params(input_dev, ABS_MT_TRACKING_ID, 0, 32, 0, 0);
 
        err = request_threaded_irq(ts->irq, NULL, rm31080_irq,
-                                  IRQF_TRIGGER_RISING, dev_name(dev), ts);
+                                       IRQF_TRIGGER_RISING, dev_name(dev), ts);
        if (err) {
                dev_err(dev, "irq %d busy?\n", ts->irq);
                goto err_free_mem;
        }
        mutex_init(&ts->access_mutex);
 
+#if defined(CONFIG_HAS_EARLYSUSPEND)
+       ts->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
+       ts->early_suspend.suspend = rm31080_early_suspend;
+       ts->early_suspend.resume = rm31080_early_resume;
+       register_early_suspend(&ts->early_suspend);
+#endif
+
        __rm31080_disable(ts);
 
        err = sysfs_create_group(&dev->kobj, &rm_ts_attr_group);
@@ -1871,7 +1999,7 @@ dev_read(struct file *filp, char __user * buf, size_t count, loff_t * pos)
 
 static ssize_t
 dev_write(struct file *filp, const char __user * buf,
-         size_t count, loff_t * pos)
+               size_t count, loff_t * pos)
 {
        u8 *pMyBuf;
        int ret;
@@ -1953,7 +2081,7 @@ static long dev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 
 #if ENABLE_RESOLUTION_SWITCH
                rm31080_set_input_resolution(g_stCtrl.u16ResolutionX,
-                                            g_stCtrl.u16ResolutionY);
+                                               g_stCtrl.u16ResolutionY);
 #endif
                break;
        case RM_IOCTL_SET_PARAMETER:
@@ -2071,10 +2199,12 @@ static struct spi_driver rm31080_spi_driver = {
                        .name = "rm_ts_spidev",
                        .bus = &spi_bus_type,
                        .owner = THIS_MODULE,
+#if !defined(CONFIG_HAS_EARLYSUSPEND)
 #if defined(CONFIG_PM)
                        .pm = &rm31080_pm_ops,
 #endif
-                  },
+#endif
+                       },
        .probe = rm31080_spi_probe,
        .remove = __devexit_p(rm31080_spi_remove),
 };
index 1a91f27..bb87a14 100644 (file)
@@ -16,6 +16,7 @@
 #define RM31080_REG_80 0x80
 #define RM31080_REG_F2 0xF2
 #define RM31080_REG_7E 0x7E
+#define RM31080_REG_7F 0x7F
 
 #define RM31080B1_REG_BANK0_00H                0x00
 #define RM31080B1_REG_BANK0_01H                0x01
@@ -95,6 +96,9 @@ struct rm31080a_ctrl_para {
        unsigned char bNoisePipelineBase;
        unsigned char bTime2Idle;
        unsigned char bfPowerMode;
+    unsigned char bfIdleMessage;
+    unsigned char bDummyRunCycle;
+
 
 #if ENABLE_FILTER_SWITCH
        unsigned char bReg1_09h[2];     //  0: Digital Filter 1: Analog Filter
index 54b955d..4545e18 100644 (file)
@@ -3,24 +3,31 @@
 
 #define ENABLE_RAW_DATA_QUEUE
 
-#define ENABLE_TOUCH_RESPONSE_TEST    1       //Roger
-#define ENABLE_RESOLUTION_SWITCH      1       //Alex
-#define ENABLE_FILTER_SWITCH          0       //Cage
-#define ENABLE_NEW_NOISE_MODE         0       //Marty
-#define NOISE_SUM_CHECK               0              //Nelson
+#define ENABLE_TOUCH_RESPONSE_TEST     1               //Roger
+#define ENABLE_RESOLUTION_SWITCH       1               //Alex
+#define ENABLE_FILTER_SWITCH           0               //Cage
+#define ENABLE_NEW_NOISE_MODE          0               //Marty
+#define NOISE_SUM_CHECK                                0               //Nelson
 #define ENABLE_CALIBRATTION_BY_FIRMWARE        1
 #define ENABLE_NEW_PARAMETER          1
+#define ENABLE_ST_SCAN                                         0
 
-#define ENABLE_T007B1_SETTING         1
-#define ENABLE_T007B1_STABLE_IDLE_MODE  1
+#define ENABLE_T007B1_SETTING                          1
+#define ENABLE_T007B1_STABLE_IDLE_MODE         1
 
 /* Define for T007 A6/B1 IC version ckeck */
 #define T007A6                         0xD0
 #define T007_VERSION_B         0xB0
-#define T007B1                         0xB0
-#define T007B2                         0xB1
+       #define T007B1                          0xB0
+       #define T007B2                          0xB1
 #define T007_VERSION_C         0xC0
 
+#define VERSION_A_PARAMETER_OFFSET 0x00
+#define VERSION_B_PARAMETER_OFFSET 0x01
+#define VERSION_C_PARAMETER_OFFSET 0x02
+#define PARAMETER_AMOUNT 384
+#define RM_MAX_CHANNEL_COUNT 120
+
 #define RM_IOCTL_REPORT_POINT    0x1001
 #define RM_IOCTL_SET_HAL_PID     0x1002
 #define RM_IOCTL_INIT_START      0x1003
 #define RM_SELF_TEST_RESULT_FAIL    0
 #define RM_SELF_TEST_RESULT_PASS    1
 
+
+#define RM_PLATFORM_KAI_PCB    0x00
+#define RM_PLATFORM_KAI        0x01
+#define RM_PLATFORM_CARDHU     0x02
+#define RM_PLATFORM_DALMORE    0x03
+#define RM_PLATFORM_PLUTO      0x04
+
 #define RM_PLATFORM_K007       0x00
 #define RM_PLATFORM_K107       0x01
 #define RM_PLATFORM_C210       0x02
@@ -84,6 +98,9 @@ struct rm_spi_ts_platform_data {
        int y_size;
        unsigned char *config;
        int platform_id;
+       unsigned char *name_of_clock;
+       unsigned char *name_of_3v3;
+       unsigned char *name_of_1v8;     
 };
 
 int rm31080_spi_byte_write(unsigned char u8Addr, unsigned char u8Value);