summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Collins <rcollins@nvidia.com>2013-04-11 13:54:11 -0700
committerSimone Willett <swillett@nvidia.com>2013-04-22 18:18:31 -0700
commitb656339197ba9d165fad2e347f36f2fa1d2d9728 (patch)
tree9671419b5ca8d892b9ab49a87352d7207fcc3de6
parent83f406d7165a5c8aa9d433b27af84c41944ee497 (diff)
input: touch: raydium: Update to Raydium v55 driver.
Bug 1257642 Bug 1245549 Bug 1245404 Change-Id: I83614e33307cb2545c3a85be4a44c86e2afc1005 Signed-off-by: Robert Collins <rcollins@nvidia.com> Reviewed-on: http://git-master/r/218645 Reviewed-by: Xiaohui Tao <xtao@nvidia.com> Tested-by: Xiaohui Tao <xtao@nvidia.com> GVS: Gerrit_Virtual_Submit Reviewed-by: Matt Wagner <mwagner@nvidia.com>
-rw-r--r--drivers/input/touchscreen/rm31080a_ctrl.c301
-rw-r--r--drivers/input/touchscreen/rm31080a_ts.c2560
-rw-r--r--include/linux/spi/rm31080a_ctrl.h109
-rw-r--r--include/linux/spi/rm31080a_ts.h232
4 files changed, 1515 insertions, 1687 deletions
diff --git a/drivers/input/touchscreen/rm31080a_ctrl.c b/drivers/input/touchscreen/rm31080a_ctrl.c
index 04d13672b0ce..c98ccf348411 100644
--- a/drivers/input/touchscreen/rm31080a_ctrl.c
+++ b/drivers/input/touchscreen/rm31080a_ctrl.c
@@ -1,8 +1,8 @@
/*
* Raydium RM31080 touchscreen driver
*
- * Copyright (C) 2012 - 2013 Raydium Semiconductor Corporation
- * Copyright (C) 2012 NVIDIA Corporation, All Rights Reserved.
+ * Copyright (C) 2012-2013, Raydium Semiconductor Corporation. All Rights Reserved.
+ * Copyright (C) 2012-2013, NVIDIA Corporation. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
@@ -11,168 +11,111 @@
*
*/
/*=============================================================================
- *INCLUDED FILES
- *=============================================================================
- */
+ INCLUDED FILES
+=============================================================================*/
#include <linux/device.h>
-#include <linux/uaccess.h>
+#include <asm/uaccess.h> // copy_to_user(),
#include <linux/delay.h>
-#include <linux/module.h>
+#include <linux/module.h> // Module definition
#include <linux/spi/rm31080a_ts.h>
#include <linux/spi/rm31080a_ctrl.h>
-/*=============================================================================
- *DEFINITIONS
- *=============================================================================
- */
-#define RM31080_RAW_DATA_LENGTH 2048
-
-/*=============================================================================
- *STRUCTURE DECLARATION
- *=============================================================================
- */
/*=============================================================================
- *GLOBAL VARIABLES DECLARATION
- *=============================================================================
- */
+ GLOBAL VARIABLES DECLARATION
+=============================================================================*/
struct rm31080a_ctrl_para g_stCtrl;
/*=============================================================================
- *FUNCTION DECLARATION
- *=============================================================================
- */
+ FUNCTION DECLARATION
+=============================================================================*/
+
/*=============================================================================
- * Description:
- * Control functions for Touch IC
- * Input:
- *
- * Output:
- *=============================================================================
- */
-int rm31080_ctrl_clear_int(void)
+ Description:
+ Control functions for Touch IC
+ Input:
+
+ Output:
+
+=============================================================================*/
+int rm_tch_ctrl_clear_int(void)
{
u8 flag;
-
- if (g_stCtrl.bICVersion != T007A6)
- return rm31080_spi_byte_read(RM31080B1_REG_BANK0_02H, &flag);
+ if (g_stCtrl.bICVersion >= 0xD0)
+ return rm_tch_spi_byte_read(0x72, &flag);
else
- return rm31080_spi_byte_read(RM31080_REG_F2, &flag);
+ return rm_tch_spi_byte_read(RM31080B1_REG_BANK0_02H, &flag);
}
-int rm31080_ctrl_scan_start(void)
+int rm_tch_ctrl_scan_start(void)
{
- return rm31080_spi_byte_write(RM31080_REG_11, 0x17);
+ return rm_tch_spi_byte_write(RM31080_REG_11, 0x17);
}
-void rm31080_ctrl_wait_for_scan_finish(void)
+void rm_tch_ctrl_wait_for_scan_finish(void)
{
u8 u8reg11;
int i;
- /* 50ms = 20Hz */
+ /*50ms = 20Hz*/
for (i = 0; i < 50; i++) {
- rm31080_spi_byte_read(RM31080_REG_11, &u8reg11);
+ rm_tch_spi_byte_read(RM31080_REG_11, &u8reg11);
if (u8reg11 & 0x01)
- usleep_range(1000, 2000);/*msleep(1); */
+ usleep_range(1000, 2000);/* msleep(1); */
else
break;
}
}
-
/*=============================================================================
- * Description:
- *
- * Input:
- * N/A
- * Output:
- * N/A
- *=============================================================================
- */
+ Description:
+
+ Input:
+ N/A
+ Output:
+ N/A
+=============================================================================*/
void rm_set_repeat_times(u8 u8Times)
{
u8 bReg1_1Fh = 0x00;
u8 u8Reg = 0x00;
- if (g_stCtrl.bICVersion != T007A6) {
- rm31080_spi_byte_read(0x0A, &u8Reg);
- u8Reg &= 0xF0;
- u8Reg |= (g_stCtrl.bSenseNumber - 1);
- rm31080_spi_byte_write(0x0A, u8Reg);
-
- rm31080_spi_byte_read(0x0E, &u8Reg);
- u8Reg &= ~0x1F;
- u8Reg |= u8Times;
- rm31080_spi_byte_write(0x0E, u8Reg);
-
- 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;*/
+ u8Reg = g_stCtrl.bSenseNumber - 1;
+ rm_tch_spi_byte_write(0x0A, u8Reg&0x0F);
+ rm_tch_spi_byte_write(0x0E, u8Times&0x1F);
- if (u8Times != REPEAT_1)
- bReg1_1Fh |= 0x44; /*Marty 20120820*/
-
- rm31080_spi_byte_write(RM31080_REG_1F, bReg1_1Fh);
- } else {
- u8Reg = ((g_stCtrl.bSenseNumber - 1) << 3) | u8Times;
-
- rm31080_spi_byte_write(RM31080_REG_0E, u8Reg);
- 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;*/
+ if (g_stCtrl.bfTHMode)
+ bReg1_1Fh |= FILTER_THRESHOLD_MODE;
+ else
+ bReg1_1Fh &= ~FILTER_NONTHRESHOLD_MODE;
- if (u8Times != REPEAT_1)
- bReg1_1Fh |= (u8Times + 3);
+ if (u8Times != REPEAT_1)
+ bReg1_1Fh |= 0x44;
- rm31080_spi_byte_write(RM31080_REG_1F, bReg1_1Fh);
- }
+ rm_tch_spi_byte_write(RM31080_REG_1F, bReg1_1Fh);
}
/*=============================================================================
- * Description:
- *
- * Input:
- * N/A
- * Output:
- * N/A
- *=============================================================================
- */
-void rm31080_ctrl_init(void)
+ Description:
+
+ Input:
+ N/A
+ Output:
+ N/A
+=============================================================================*/
+void rm_tch_ctrl_init(void)
{
- u8 var;
-
memset(&g_stCtrl, 0, sizeof(struct rm31080a_ctrl_para));
-
- g_stCtrl.bDummyRunCycle = 1;
- g_stCtrl.u16DataLength = RM31080_RAW_DATA_LENGTH;
-
- if (rm31080_spi_byte_read(RM31080_REG_7E, &var))
- g_stCtrl.bICVersion = var & 0xF0;
- else
- g_stCtrl.bICVersion = T007A6;
}
/*=============================================================================
- * Description:
- *
- * Input:
- * N/A
- * Output:
- * N/A
- *=============================================================================
- */
-unsigned char rm31080_ctrl_get_noise_mode(u8 *p)
+ Description:
+
+ Input:
+ N/A
+ Output:
+ N/A
+=============================================================================*/
+unsigned char rm_tch_ctrl_get_noise_mode(u8 *p)
{
u32 u32Ret;
u32Ret = copy_to_user(p, &g_stCtrl.bfNoiseModeDetector, 1);
@@ -181,15 +124,16 @@ unsigned char rm31080_ctrl_get_noise_mode(u8 *p)
return 1;
}
+
/*=============================================================================
- * Description: To transfer the value to HAL layer
- *
- * Input:
- * N/A
- * Output:
- * N/A
- *===========================================================================*/
-unsigned char rm31080_ctrl_get_idle_mode(u8 *p)
+ Description: To transfer the value to HAL layer
+
+ Input:
+ N/A
+ Output:
+ N/A
+=============================================================================*/
+unsigned char rm_tch_ctrl_get_idle_mode(u8 *p)
{
u32 u32Ret;
u32Ret = copy_to_user(p, &g_stCtrl.bfIdleModeCheck, 1);
@@ -199,95 +143,64 @@ unsigned char rm31080_ctrl_get_idle_mode(u8 *p)
}
/*=============================================================================
- * Description:
- *
- * Input:
- * N/A
- * Output:
- * N/A
- *=============================================================================
- */
-void rm31080_ctrl_get_parameter(void *arg)
+ Description:
+
+ Input:
+ N/A
+ Output:
+ N/A
+=============================================================================*/
+void rm_tch_ctrl_get_parameter(void *arg)
{
#define PARA_BASIC_LEN 4
#define PARA_HARDWARE_LEN 28
#define PARA_NOISE_LEN 32
#define PARA_ALGORITHM_LEN 128
- /* Marty added*/
u8 Temp;
u8 *pPara;
- u8 idx;
- idx = PARA_BASIC_LEN;
pPara = (u8 *) arg;
- Temp = pPara[idx + PARA_HARDWARE_LEN +
- PARA_NOISE_LEN + PARA_ALGORITHM_LEN + 3];
- rm31080_set_autoscan(Temp);
-
- g_stCtrl.bADCNumber = pPara[idx + 6];
- g_stCtrl.bChannelNumberX = pPara[idx];
- g_stCtrl.bChannelNumberY = pPara[idx + 1];
- g_stCtrl.bfNoiseDetector = pPara[idx + PARA_HARDWARE_LEN + 13];
- g_stCtrl.bChannelDetectorNum = pPara[idx + PARA_HARDWARE_LEN + 19];
- g_stCtrl.bChannelDetectorDummy = pPara[idx + PARA_HARDWARE_LEN + 20];
- g_stCtrl.u16DataLength = (g_stCtrl.bChannelNumberX + 2 +
- g_stCtrl.bADCNumber) *
- (g_stCtrl.bChannelNumberY + g_stCtrl.bfNoiseDetector *
- (g_stCtrl.bChannelDetectorNum +
- g_stCtrl.bChannelDetectorDummy));
- g_stCtrl.bfNoiseMode = pPara[idx + PARA_HARDWARE_LEN + 14];
- g_stCtrl.bNoiseRepeatTimes = pPara[idx + PARA_HARDWARE_LEN + 15];
- /*Marty added*/
- g_stCtrl.bNoiseThresholdMax = pPara[idx + PARA_HARDWARE_LEN + 21];
- g_stCtrl.bNoiseThresholdMin = pPara[idx + PARA_HARDWARE_LEN + 22];
- g_stCtrl.bNoiseThresholdLowMax = pPara[idx + PARA_HARDWARE_LEN + 23];
- g_stCtrl.bNoiseThresholdLowMin = pPara[idx + PARA_HARDWARE_LEN + 24];
- g_stCtrl.bNoiseDetectThd = pPara[idx + PARA_HARDWARE_LEN + 16];
- g_stCtrl.bNoisePipelineBase = pPara[idx + PARA_HARDWARE_LEN + 17];
- g_stCtrl.bNewNoiseRepeatTimes = pPara[idx + PARA_HARDWARE_LEN + 18];
- g_stCtrl.bfMediumFilter = pPara[idx + PARA_HARDWARE_LEN + 25];
- g_stCtrl.bMFBlockNumber = pPara[idx + PARA_HARDWARE_LEN + 26];
- g_stCtrl.bRepeatTimes[0] = pPara[idx + PARA_HARDWARE_LEN + 4];
- g_stCtrl.bRepeatTimes[1] = pPara[idx + PARA_HARDWARE_LEN + 5];
- g_stCtrl.bIdleRepeatTimes[0] = pPara[idx + PARA_HARDWARE_LEN + 6];
- g_stCtrl.bSenseNumber = pPara[idx + 11];
- g_stCtrl.bfADFC = pPara[idx + 4];
- g_stCtrl.bfTHMode = pPara[idx + PARA_HARDWARE_LEN + 10];
- g_stCtrl.bfAnalogFilter = pPara[idx + PARA_HARDWARE_LEN + 8];
- g_stCtrl.bYChannel[0] = pPara[280]; /* Y chan start pin */
- g_stCtrl.bYChannel[1] = pPara[281]; /* Y chan end pin */
- g_stCtrl.bXChannel[0] = pPara[282]; /* X chan ADC1 start pin */
- g_stCtrl.bXChannel[1] = pPara[283]; /* X chan ADC1 end pin */
- g_stCtrl.bXChannel[2] = pPara[284]; /* X chan ADC2 start pin */
- g_stCtrl.bXChannel[3] = pPara[285]; /* X chan ADC2 end pin */
- g_stCtrl.bfSuspendReset = pPara[idx + PARA_HARDWARE_LEN + 27];
- g_stCtrl.bPressureResolution = pPara[105];
- g_stCtrl.bSTScan = pPara[191];
+ Temp = pPara[PARA_BASIC_LEN + PARA_HARDWARE_LEN + PARA_NOISE_LEN + PARA_ALGORITHM_LEN + 3];
+ rm_tch_set_autoscan(Temp);
+
+ g_stCtrl.bICVersion = pPara[PARA_BASIC_LEN - 1];
+ g_stCtrl.bADCNumber = pPara[PARA_BASIC_LEN + 5];
+ g_stCtrl.bChannelNumberX = pPara[PARA_BASIC_LEN];
+ g_stCtrl.bChannelNumberY = pPara[PARA_BASIC_LEN + 1];
+ g_stCtrl.bChannelDetectorNum = pPara[PARA_BASIC_LEN + PARA_HARDWARE_LEN + 19]; /* Noise_Detector */
+ g_stCtrl.bChannelDetectorDummy = pPara[PARA_BASIC_LEN + PARA_HARDWARE_LEN + 20]; /* Noise_Detector */
+ g_stCtrl.u16DataLength = (g_stCtrl.bChannelNumberX + 2 + g_stCtrl.bADCNumber) * (g_stCtrl.bChannelNumberY);
+ g_stCtrl.bfNoiseMode = pPara[PARA_BASIC_LEN + PARA_HARDWARE_LEN + 14];
+ g_stCtrl.bNoiseRepeatTimes = pPara[PARA_BASIC_LEN + PARA_HARDWARE_LEN + 15];
+
+ g_stCtrl.bActiveRepeatTimes[0] = pPara[PARA_BASIC_LEN + PARA_HARDWARE_LEN + 4]; /* Noise_Detector */
+ g_stCtrl.bActiveRepeatTimes[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[1] = pPara[PARA_BASIC_LEN + PARA_HARDWARE_LEN + 7]; /* Noise_Detector */
+ g_stCtrl.bSenseNumber = pPara[PARA_BASIC_LEN + 10]; /* 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 */
+ g_stCtrl.bfAnalogFilter = pPara[PARA_BASIC_LEN + PARA_HARDWARE_LEN + 8]; /* Noise_Detector */
+ g_stCtrl.bfSuspendReset = pPara[PARA_BASIC_LEN + PARA_HARDWARE_LEN + 27];
+ g_stCtrl.bPressureResolution = pPara[95];
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];
+ g_stCtrl.bDebugMessage = pPara[204];
+ g_stCtrl.bTimerTriggerScale = pPara[205];
+ g_stCtrl.bfSelftestData = pPara[207];
- /* 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)*/
-
- 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]);
+ g_stCtrl.u16ResolutionX = ((u16) pPara[PARA_BASIC_LEN + 12]) << 8 | ((u16)pPara[PARA_BASIC_LEN + 11]);
+ g_stCtrl.u16ResolutionY = ((u16) pPara[PARA_BASIC_LEN + 14]) << 8 | ((u16)pPara[PARA_BASIC_LEN + 13]);
if ((g_stCtrl.u16ResolutionX == 0) || (g_stCtrl.u16ResolutionY == 0)) {
g_stCtrl.u16ResolutionX = RM_INPUT_RESOLUTION_X;
g_stCtrl.u16ResolutionY = RM_INPUT_RESOLUTION_Y;
}
-
}
-/*===========================================================================*/
+/*=============================================================================*/
MODULE_AUTHOR("xxxxxxxxxx <xxxxxxxx@rad-ic.com>");
MODULE_DESCRIPTION("Raydium touchscreen control functions");
MODULE_LICENSE("GPL");
diff --git a/drivers/input/touchscreen/rm31080a_ts.c b/drivers/input/touchscreen/rm31080a_ts.c
index 08fb150f9f88..f896d81a347e 100644
--- a/drivers/input/touchscreen/rm31080a_ts.c
+++ b/drivers/input/touchscreen/rm31080a_ts.c
@@ -1,18 +1,18 @@
/*
* Raydium RM31080 touchscreen driver
*
- * Copyright (C) 2012-2013, Raydium Semiconductor Corporation.
+ * Copyright (C) 2012-2013, Raydium Semiconductor Corporation. All Rights Reserved.
* Copyright (C) 2012-2013, NVIDIA Corporation. All Rights Reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
*/
-/*=========================================================================*/
-/*INCLUDED FILES */
-/*=========================================================================*/
+/*=============================================================================
+ INCLUDED FILES
+=============================================================================*/
#include <linux/module.h>
#include <linux/input.h> /* BUS_SPI */
#include <linux/spi/spi.h>
@@ -22,81 +22,98 @@
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/slab.h>
+#include <linux/fb.h>
#include <linux/gpio.h>
#include <linux/sched.h> /* wake_up_process() */
#include <linux/kthread.h> /* kthread_create(),kthread_run() */
-#include <linux/uaccess.h> /* copy_to_user(), */
+#include <asm/uaccess.h> /* copy_to_user() */
#include <linux/miscdevice.h>
-#include <linux/regulator/consumer.h>
-#include <linux/pm_qos.h> /* pm qos for CPU boosting */
-#include <linux/sysfs.h> /* sysfs for pm qos attributes */
-#include <linux/clk.h>
+#include <asm/siginfo.h> /* siginfo */
+#include <linux/rcupdate.h> /* rcu_read_lock */
+#include <linux/sched.h> /* find_task_by_pid_type */
+#include <linux/syscalls.h> /* sys_clock_gettime() */
+#include <linux/random.h> /* random32() */
+#include <linux/suspend.h> /* pm_notifier */
+#include <linux/workqueue.h>
+#include <linux/wakelock.h> /* wakelock */
+#include <linux/regulator/consumer.h> /* regulator & voltage */
+#include <linux/clk.h> /* clock */
+#ifdef CONFIG_HAS_EARLYSUSPEND
+#include <linux/earlysuspend.h>
+#endif
+
+#include <linux/timer.h>
+
#include <linux/spi/rm31080a_ts.h>
#include <linux/spi/rm31080a_ctrl.h>
-#include <../clock.h>
#define CREATE_TRACE_POINTS
#include <trace/events/touchscreen_raydium.h>
-/*=========================================================================*/
-/*DEFINITIONS */
-/*=========================================================================*/
-#define ENABLE_RAW_DATA_QUEUE
-#define ENABLE_WORK_QUEUE
-#define ENABLE_REPORT_TO_UART
-#define ENABLE_RM31080_DEEP_SLEEP
-#define ENABLE_AUTO_SCAN
-/*#define ENABLE_SPEED_TEST_FUNCTION */
-/*#define ENABLE_CALC_QUEUE_COUNT */
-/*#define ENABLE_SPI_BURST_READ_WRITE */
-/*#define ENABLE_SPI_SETTING */
+/*=============================================================================
+ DEFINITIONS
+=============================================================================*/
+/*#define ENABLE_CALC_QUEUE_COUNT*/
+#define ENABLE_SLOW_SCAN
#define ENABLE_SMOOTH_LEVEL
-/*#define ENABLE_SUPPORT_4_7*/ /* for 4.7 inch display */
-#define ENABLE_NEW_INPUT_DEV
-
+#define ENABLE_SPI_SETTING 0
/* undef to disable CPU boost while leaving idle mode */
#define NV_ENABLE_CPU_BOOST
-#define MAX_SPI_FREQ_HZ 50000000
-#define TS_PEN_UP_TIMEOUT msecs_to_jiffies(50)
+#define MAX_SPI_FREQ_HZ 50000000
+#define TS_PEN_UP_TIMEOUT msecs_to_jiffies(50)
-#ifdef ENABLE_RAW_DATA_QUEUE
-#define QUEUE_COUNT 128
-#define RAW_DATA_LENGTH (RM_MAX_MT_COUNT + RM_MAX_CHANNEL_COUNT)
-#endif
+#define QUEUE_COUNT 128
+#define RAW_DATA_LENGTH 2048
-#define RM_SCAN_MODE_MANUAL 0x00
-#define RM_SCAN_MODE_PREPARE_AUTO 0x01
-#define RM_SCAN_MODE_AUTO_SCAN 0x02
+#define RM_SCAN_ACTIVE_MODE 0x00
+#define RM_SCAN_PRE_IDLE_MODE 0x01
+#define RM_SCAN_IDLE_MODE 0x02
-#define RM_NEED_NONE 0x00
-#define RM_NEED_TO_SEND_SCAN 0x01
-#define RM_NEED_TO_READ_RAW_DATA 0x02
-#define RM_NEED_TO_SEND_SIGNAL 0x04
+#define RM_NEED_NONE 0x00
+#define RM_NEED_TO_SEND_SCAN 0x01
+#define RM_NEED_TO_READ_RAW_DATA 0x02
+#define RM_NEED_TO_SEND_SIGNAL 0x04
-#ifdef ENABLE_SMOOTH_LEVEL
-#define RM_SMOOTH_LEVEL_NORMAL 0
-#define RM_SMOOTH_LEVEL_MAX 4
-#endif
+#define TCH_WAKE_LOCK_TIMEOUT (2*HZ)
-#ifdef NV_ENABLE_CPU_BOOST
-/* disable CPU boosting if autoscan mode is disabled */
-#ifndef ENABLE_AUTO_SCAN
-#undef NV_ENABLE_CPU_BOOST
-#endif
+#ifdef ENABLE_SLOW_SCAN
+#define RM_SLOW_SCAN_INTERVAL 20
+#define RM_SLOW_SCAN_CMD_COUNT 0x10
+enum RM_SLOW_SCAN_LEVELS {
+ RM_SLOW_SCAN_LEVEL_NORMAL,
+ RM_SLOW_SCAN_LEVEL_20,
+ RM_SLOW_SCAN_LEVEL_40,
+ RM_SLOW_SCAN_LEVEL_60,
+ RM_SLOW_SCAN_LEVEL_80,
+ RM_SLOW_SCAN_LEVEL_100,
+ RM_SLOW_SCAN_LEVEL_MAX,
+ RM_SLOW_SCAN_LEVEL_COUNT
+};
#endif
-#ifdef ENABLE_WORK_QUEUE
-#include <linux/workqueue.h>
+#ifdef ENABLE_SMOOTH_LEVEL
+#define RM_SMOOTH_LEVEL_NORMAL 0
+#define RM_SMOOTH_LEVEL_MAX 4
#endif
-#define rm_printk(msg...) do { dev_info(&g_spi->dev, msg); } while (0)
-#define rmd_printk(msg...) do { } while (0)
-/*=========================================================================*/
-/*STRUCTURE DECLARATION */
-/*=========================================================================*/
-/*TouchScreen Parameters */
+#define RM_WINTEK_7_CHANNEL_X 30
+
+#define TS_TIMER_PERIOD HZ
+
+#define WDT_INIT_TIME 6000 /* 60 sec */
+#define WDT_NORMAL_TIME 100 /* 1 sec */
+
+struct timer_list ts_timer_triggle;
+static void init_ts_timer(void);
+static void ts_timer_triggle_function(unsigned long option);
+
+#define rm_printk(msg...) printk(msg)
+/*=============================================================================
+ STRUCTURE DECLARATION
+=============================================================================*/
+/*TouchScreen Parameters*/
struct rm31080a_ts_para {
unsigned long ulHalPID;
bool bInitFinish;
@@ -105,19 +122,13 @@ struct rm31080a_ts_para {
bool bEnableAutoScan;
bool bIsSuspended;
- bool bInitStartFlag;
- bool bInitFailFlag;
- bool bReissueSignalFlag;
-
- struct mutex mutex_scan_mode;
-#ifdef ENABLE_WORK_QUEUE
- struct workqueue_struct *rm_workqueue;
- struct work_struct rm_work;
-#endif
+ u32 u32WatchDogCnt;
+ u8 u8WatchDogFlg;
+ u8 u8WatchDogEnable;
+ bool u8WatchDogCheck;
+ u32 u32WatchDogTime;
-#ifdef ENABLE_RAW_DATA_QUEUE
u8 u8ScanModeState;
-#endif
#ifdef ENABLE_SLOW_SCAN
bool bEnableSlowScan;
@@ -131,11 +142,23 @@ struct rm31080a_ts_para {
u8 u8SelfTestStatus;
u8 u8SelfTestResult;
u8 u8Version;
+ u8 u8TestVersion;
u8 u8Repeat;
+
+ struct wake_lock Wakelock_Initialization;
+
+ struct mutex mutex_scan_mode;
+
+ struct workqueue_struct *rm_workqueue;
+ struct work_struct rm_work;
+
+ struct workqueue_struct *rm_timer_workqueue;
+ struct work_struct rm_timer_work;
+
};
-struct rm31080_ts {
- const struct rm31080_bus_ops *bops;
+struct rm_tch_ts {
+ const struct rm_tch_bus_ops *bops;
struct device *dev;
struct input_dev *input;
unsigned int irq;
@@ -143,6 +166,9 @@ struct rm31080_ts {
bool suspended;
char phys[32];
struct mutex access_mutex;
+#ifdef CONFIG_HAS_EARLYSUSPEND
+ struct early_suspend early_suspend;
+#endif
struct regulator *regulator_3v3;
struct regulator *regulator_1v8;
struct notifier_block nb_3v3;
@@ -150,96 +176,67 @@ struct rm31080_ts {
struct clk *clk;
};
-struct rm31080_bus_ops {
+struct rm_tch_bus_ops {
u16 bustype;
int (*read) (struct device *dev, u8 reg);
int (*write) (struct device *dev, u8 reg, u16 val);
};
-#ifdef ENABLE_RAW_DATA_QUEUE
-struct rm31080_queue_info {
+struct rm_tch_queue_info {
u8(*pQueue)[RAW_DATA_LENGTH];
u16 u16Front;
u16 u16Rear;
};
-#endif
-/*=========================================================================*/
-/*GLOBAL VARIABLES DECLARATION */
-/*=========================================================================*/
+/*=============================================================================
+ GLOBAL VARIABLES DECLARATION
+=============================================================================*/
struct input_dev *g_input_dev;
struct spi_device *g_spi;
struct rm31080a_ts_para g_stTs;
+unsigned long g_smooth_level = 1;
-#ifdef ENABLE_RAW_DATA_QUEUE
-struct rm31080_queue_info g_stQ;
-#endif
-
-#ifdef ENABLE_SLOW_SCAN
-struct rm_cmd_slow_scan g_stCmdSlowScan[RM_SLOW_SCAN_LEVEL_COUNT];
-#endif
+struct rm_tch_queue_info g_stQ;
-/*========================================================================= */
-/*FUNCTION DECLARATION */
-/*========================================================================= */
-static int rm31080_spi_checking(bool bInfinite);
-/*=========================================================================
- * Description:
- * Debug function: test speed.
- * Input:
- * N/A
- * Output:
- * 1:succeed
- * 0:failed
- *========================================================================= */
-#ifdef ENABLE_SPEED_TEST_FUNCTION
-void my_calc_time(int iStart)
-{
- static unsigned int u32Max = UINT_MAX;
+unsigned char *g_pu8BurstReadBuf;
- static long iTimebuffer[1000];
- static unsigned long long t1, t2;
- unsigned long nanosec_rem;
- static int iIndex;
+unsigned char g_stCmdSetIdle[KRL_SIZE_SET_IDLE];
+unsigned char g_stCmdPauseAuto[KRL_SIZE_PAUSE_AUTO];
+unsigned char g_stRmStartCmd[KRL_SIZE_RM_START];
+unsigned char g_stRmEndCmd[KRL_SIZE_RM_END];
+unsigned char g_stRmReadImgCmd[KRL_SIZE_RM_READ_IMG];
+unsigned char g_stRmWatchdogCmd[KRL_SIZE_RM_WATCHDOG];
+unsigned char g_stRmTestModeCmd[KRL_SIZE_RM_TESTMODE];
+unsigned char g_stRmSlowScanCmd[KRL_SIZE_RM_SLOWSCAN];
- if (iStart) {
- t1 = cpu_clock(u32Max);
- return;
- } else
- t2 = cpu_clock(u32Max);
+/*=============================================================================
+ FUNCTION DECLARATION
+=============================================================================*/
+static int rm_tch_cmd_process(u8 selCase, u8 *pCmdTbl, struct rm_tch_ts *ts);
+static int rm_tch_read_image_data(unsigned char *p);
+#ifdef CONFIG_HAS_EARLYSUSPEND
+static void rm_tch_early_suspend(struct early_suspend *es);
+static void rm_tch_early_resume(struct early_suspend *es);
+#endif
+static int rm_tch_ts_send_signal(int pid, int iInfo);
- t2 = t2 - t1;
+static void rm_tch_enter_test_mode(u8 flag);
- nanosec_rem = do_div(t2, 1000000000);
+static void rm_ctrl_stop(struct rm_tch_ts *ts);
+static void rm_ctrl_start(struct rm_tch_ts *ts);
- if (t2) { /*more than 1 Second */
- iTimebuffer[iIndex] = 999999;
- } else {
- iTimebuffer[iIndex] = nanosec_rem / 1000; /*micro second */
- }
+static void rm_watchdog_enable(unsigned char u8Enable);
- iIndex++;
- if (iIndex == 1000) {
- for (iIndex = 0; iIndex < 1000; iIndex++) {
- rm_printk(" %04d,%06d\n", iIndex,
- (u32) iTimebuffer[iIndex]);
- }
- iIndex = 0;
- }
+/*=============================================================================
+ Description:
+ RM31080 spi interface.
+ Input:
-}
-#endif /*ENABLE_SPEED_TEST_FUNCTION */
-/*=========================================================================
- * Description:
- * RM31080 spi interface.
- * Input:
- *
- * Output:
- * 1:succeed
- * 0:failed
- *=========================================================================
- */
-static int rm31080_spi_read(u8 u8addr, u8 *rxbuf, size_t len)
+ Output:
+ 1:succeed
+ 0:failed
+=============================================================================*/
+static int rm_tch_spi_read(u8 u8addr, u8 *rxbuf, size_t len)
{
static DEFINE_MUTEX(lock);
@@ -261,90 +258,88 @@ static int rm31080_spi_read(u8 u8addr, u8 *rxbuf, size_t len)
x[1].rx_buf = rxbuf;
spi_message_add_tail(&x[1], &message);
- /* It returns zero on succcess,else a negative error code. */
+ /*It returns zero on succcess,else a negative error code.*/
status = spi_sync(g_spi, &message);
mutex_unlock(&lock);
- if (status)
- return false;
+ if (status) {
+ dev_err(&g_spi->dev, "%s: spi_async failed - error %d\n", __func__, status);
+ return FAIL;
+ }
- return true;
+ return OK;
}
-/*=========================================================================
- * Description:
- * RM31080 spi interface.
- * Input:
- *
- * Output:
- * 1:succeed
- * 0:failed
- *=========================================================================
- */
-static int rm31080_spi_write(u8 *txbuf, size_t len)
+/*=============================================================================
+ Description:
+ RM31080 spi interface.
+ Input:
+
+ Output:
+ 1:succeed
+ 0:failed
+=============================================================================*/
+static int rm_tch_spi_write(u8 *txbuf, size_t len)
{
static DEFINE_MUTEX(lock);
int status;
- /*It returns zero on succcess,else a negative error code. */
+ /*It returns zero on succcess,else a negative error code.*/
mutex_lock(&lock);
status = spi_write(g_spi, txbuf, len);
mutex_unlock(&lock);
- if (status)
- return false;
+ if (status) {
+ dev_err(&g_spi->dev, "%s: spi_write failed - error %d\n", __func__, status);
+ return FAIL;
+ }
- return true;
+ return OK;
}
-/*=========================================================================
- * Description:
- * RM31080 spi interface.
- * Input:
- *
- * Output:
- * 1:succeed
- * 0:failed
- *=========================================================================
- */
-int rm31080_spi_byte_read(unsigned char u8Addr, unsigned char *pu8Value)
+/*=============================================================================
+ Description:
+ RM31080 spi interface.
+ Input:
+
+ Output:
+ 1:succeed
+ 0:failed
+=============================================================================*/
+int rm_tch_spi_byte_read(unsigned char u8Addr, unsigned char *pu8Value)
{
- return rm31080_spi_read(u8Addr, pu8Value, 1);
+ return rm_tch_spi_read(u8Addr, pu8Value, 1);
}
-/*=========================================================================
- * Description:
- * RM31080 spi interface.
- * Input:
- *
- * Output:
- * 1:succeed
- * 0:failed
- *=========================================================================
- */
-int rm31080_spi_byte_write(unsigned char u8Addr, unsigned char u8Value)
+/*=============================================================================
+ Description:
+ RM31080 spi interface.
+ Input:
+
+ Output:
+ 1:succeed
+ 0:failed
+=============================================================================*/
+int rm_tch_spi_byte_write(unsigned char u8Addr, unsigned char u8Value)
{
u8 buf[2];
buf[0] = u8Addr;
buf[1] = u8Value;
- return rm31080_spi_write(buf, 2);
+ return rm_tch_spi_write(buf, 2);
}
-/*=========================================================================
- * Description:
- * RM31080 spi interface.
- * Input:
- *
- * Output:
- * 1:succeed
- * 0:failed
- *=========================================================================
- */
-#ifdef ENABLE_SPI_BURST_READ_WRITE
-static int rm31080_spi_burst_read(unsigned char u8Addr,
- unsigned char *pu8Value,
+/*=============================================================================
+ Description:
+ RM31080 spi interface.
+ Input:
+
+ Output:
+ 1:succeed
+ 0:failed
+=============================================================================*/
+int rm_tch_spi_burst_read(unsigned char u8Addr, unsigned char *pu8Value,
u32 u32len)
{
int ret;
@@ -352,51 +347,49 @@ static int rm31080_spi_burst_read(unsigned char u8Addr,
pMyBuf = kmalloc(u32len, GFP_KERNEL);
if (pMyBuf == NULL)
- return false;
+ return FAIL;
- ret = rm31080_spi_read(u8Addr, pMyBuf, u32len);
+ ret = rm_tch_spi_read(u8Addr, pMyBuf, u32len);
- if (ret)
+ if (ret) {
memcpy(pu8Value, pMyBuf, u32len);
+ }
kfree(pMyBuf);
return ret;
}
-#endif
-/*=========================================================================
- * Description:
- * RM31080 spi interface.
- * Input:
- *
- * Output:
- * 1:succeed
- * 0:failed
- *=========================================================================
- */
-int rm31080_spi_burst_write(unsigned char *pBuf, unsigned int u32Len)
+/*=============================================================================
+ Description:
+ RM31080 spi interface.
+ Input:
+
+ Output:
+ 1:succeed
+ 0:failed
+=============================================================================*/
+int rm_tch_spi_burst_write(unsigned char *pBuf, unsigned int u32Len)
{
u8 *pMyBuf;
int ret;
pMyBuf = kmalloc(u32Len, GFP_KERNEL);
if (pMyBuf == NULL)
- return false;
+ return FAIL;
memcpy(pMyBuf, pBuf, u32Len);
- ret = rm31080_spi_write(pMyBuf, u32Len);
+ ret = rm_tch_spi_write(pMyBuf, u32Len);
kfree(pMyBuf);
return ret;
}
-/*=========================================================================*/
-#ifdef ENABLE_AUTO_SCAN
+/*=============================================================================*/
void raydium_change_scan_mode(u8 u8TouchCount)
{
- static u32 u32NoTouchCount;
+ static u32 u32NoTouchCount = 0;
u16 u16NTCountThd;
- u16NTCountThd = (u16) g_stCtrl.bTime2Idle * 10;
+ u16NTCountThd = (u16)g_stCtrl.bTime2Idle * 100;
if (u8TouchCount) {
u32NoTouchCount = 0;
@@ -404,122 +397,23 @@ void raydium_change_scan_mode(u8 u8TouchCount)
}
if (u32NoTouchCount < u16NTCountThd) {
u32NoTouchCount++;
- } else if (g_stTs.u8ScanModeState == RM_SCAN_MODE_MANUAL) {
+ } else if (g_stTs.u8ScanModeState == RM_SCAN_ACTIVE_MODE) {
if (g_stTs.bEnableAutoScan)
- g_stTs.u8ScanModeState = RM_SCAN_MODE_PREPARE_AUTO;
+ g_stTs.u8ScanModeState = RM_SCAN_PRE_IDLE_MODE;
u32NoTouchCount = 0;
}
}
-#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)
-{
- unsigned char i;
- for (i = 0; i < ucCount; i++)
- rm_printk("%02X", ucData[i]);
-
- rm_printk("\n");
-}
-
-void raydium_report_to_uart(void *p)
-{
- /*1=Tag,1=Touch count,4=(xH xL ,yH yL) ,12=max point,1=Check sum */
- unsigned char ucData[1 + 1 + (4 * 12) + 1];
- struct rm_touch_event *spTP;
- unsigned short usX, usY;
- int i, j;
-
- if (g_stTs.bEnableScriber == 0)
- return;
-
- spTP = (struct rm_touch_event *)p;
-
- ucData[0] = 0x8E;
- ucData[1] = spTP->ucTouchCount;
- j = 2;
- for (i = 0; i < spTP->ucTouchCount; i++) {
- usX = spTP->usX[i] + 1;
- usY = spTP->usY[i] + 1;
- ucData[j++] = ((usX >> 8) & 0xFF) | (spTP->ucID[i] << 4);
- ucData[j++] = ((usX) & 0xFF);
- ucData[j++] = ((usY >> 8) & 0xFF);
- ucData[j++] = ((usY) & 0xFF);
- }
-
- /*check sum */
- ucData[j] = 0;
- for (i = 0; i < j; i++)
- ucData[j] += ucData[i];
-
- ucData[j] = 0x100 - ucData[j];
- j++;
-
- /*print */
- raydium_report_to_uart_printf(ucData, j);
- if (spTP->ucTouchCount == 0) {
- raydium_report_to_uart_printf(ucData, j);
- raydium_report_to_uart_printf(ucData, j);
- }
-}
-#endif /*ENABLE_REPORT_TO_UART */
-#ifdef ENABLE_SUPPORT_4_7 /*for 4.7 inch display */
-#define _RM_SCALE_LEFT (40 + 0)
-#define _RM_SCALE_RIGHT (30 + 0)
-#define _RM_SCALE_TOP (16 + 0)
-#define _RM_SCALE_BOTTOM (30 + 0)
-void raydium_scale_touch_point(struct rm_touch_event *spTP,
- int iMaxX, int iMaxY,
- int left, int right,
- int top, int bottom)
-{
- int i;
- int iNewX, iNewY;
- iNewX = iMaxX - _RM_SCALE_LEFT - _RM_SCALE_RIGHT;
- iNewY = iMaxY - _RM_SCALE_TOP - _RM_SCALE_BOTTOM;
-
- for (i = 0; i < spTP->ucTouchCount; i++) {
- /* cut out */
- if (spTP->usX[i] < _RM_SCALE_LEFT)
- spTP->usX[i] = _RM_SCALE_LEFT;
- else if (spTP->usX[i] > (iMaxX - _RM_SCALE_RIGHT))
- spTP->usX[i] = (iMaxX - _RM_SCALE_RIGHT);
- if (spTP->usY[i] < _RM_SCALE_TOP)
- spTP->usY[i] = _RM_SCALE_TOP;
- else if (spTP->usY[i] > (iMaxY - _RM_SCALE_BOTTOM))
- spTP->usY[i] = (iMaxY - _RM_SCALE_BOTTOM);
- /* shift */
- spTP->usX[i] -= _RM_SCALE_LEFT;
- spTP->usY[i] -= _RM_SCALE_TOP;
- /* scale */
- if (iNewX)
- spTP->usX[i] = (int)spTP->usX[i] * iMaxX / iNewX;
- if (iNewY)
- spTP->usY[i] = (int)spTP->usY[i] * iMaxY / iNewY;
- }
-}
-#endif
void raydium_report_pointer(void *p)
{
- static unsigned char ucLastTouchCount;
+ static unsigned char ucLastTouchCount = 0;
int i;
int iCount;
int iMaxX, iMaxY;
- struct rm_touch_event *spTP;
-#ifdef ENABLE_SUPPORT_4_7
- struct rm_touch_event stTP;
- unsigned long missing;
-#endif
- spTP = (struct rm_touch_event *)p;
-
+ rm_touch_event *spTP;
+ spTP = (rm_touch_event *) p;
- if ((g_stCtrl.u16ResolutionX != 0) &&
- (g_stCtrl.u16ResolutionY != 0)) {
+ if ((g_stCtrl.u16ResolutionX != 0) && (g_stCtrl.u16ResolutionY != 0)) {
iMaxX = g_stCtrl.u16ResolutionX;
iMaxY = g_stCtrl.u16ResolutionY;
} else {
@@ -527,462 +421,543 @@ void raydium_report_pointer(void *p)
iMaxY = RM_INPUT_RESOLUTION_Y;
}
-#ifdef ENABLE_SUPPORT_4_7
- missing = copy_from_user(&stTP, p, sizeof(stTP));
- if (missing == 0) {
- raydium_scale_touch_point(&stTP, iMaxX, iMaxY,
- _RM_SCALE_LEFT,
- _RM_SCALE_RIGHT,
- _RM_SCALE_TOP,
- _RM_SCALE_BOTTOM);
- spTP = &stTP;
- }
-#endif
-
iCount = max(ucLastTouchCount, spTP->ucTouchCount);
if (iCount) {
for (i = 0; i < iCount; i++) {
if (i == 10)
- break;
+ break; /*due to the "touch test" can't support great than 10 points*/
if (i < spTP->ucTouchCount) {
input_report_abs(g_input_dev,
- ABS_MT_TRACKING_ID,
- spTP->ucID[i]);
+ ABS_MT_TRACKING_ID,
+ spTP->ucID[i]);
input_report_abs(g_input_dev,
- ABS_MT_TOUCH_MAJOR,
- spTP->usZ[i]);
+ ABS_MT_TOUCH_MAJOR,
+ spTP->usZ[i]);
input_report_abs(g_input_dev,
- ABS_MT_WIDTH_MAJOR,
- spTP->usZ[i]);
+ ABS_MT_WIDTH_MAJOR,
+ spTP->usZ[i]);
input_report_abs(g_input_dev,
- ABS_MT_PRESSURE,
- spTP->usZ[i]);
+ ABS_MT_PRESSURE,
+ spTP->usZ[i]);
if (spTP->usX[i] >= (iMaxX - 1))
input_report_abs(g_input_dev,
- ABS_MT_POSITION_X,
- (iMaxX - 1));
+ ABS_MT_POSITION_X,
+ (iMaxX - 1));
else
input_report_abs(g_input_dev,
- ABS_MT_POSITION_X,
- spTP->usX[i]);
+ ABS_MT_POSITION_X,
+ spTP->usX[i]);
if (spTP->usY[i] >= (iMaxY - 1))
input_report_abs(g_input_dev,
- ABS_MT_POSITION_Y,
- (iMaxY - 1));
+ ABS_MT_POSITION_Y,
+ (iMaxY - 1));
else
input_report_abs(g_input_dev,
- ABS_MT_POSITION_Y,
- spTP->usY[i]);
+ ABS_MT_POSITION_Y,
+ spTP->usY[i]);
}
input_mt_sync(g_input_dev);
}
ucLastTouchCount = spTP->ucTouchCount;
input_report_key(g_input_dev, BTN_TOUCH,
- spTP->ucTouchCount > 0);
+ spTP->ucTouchCount > 0);
input_sync(g_input_dev);
-#ifdef ENABLE_REPORT_TO_UART
- raydium_report_to_uart(p);
-#endif
-
}
-#ifdef ENABLE_AUTO_SCAN
+
if (g_stCtrl.bfPowerMode)
raydium_change_scan_mode(spTP->ucTouchCount);
-#endif
-}
-/*=========================================================================
- * Description:
- * RM31080 control functions.
- * Input:
- * N/A
- * Output:
- * 1:succeed
- * 0:failed
- *=========================================================================
- */
-#ifdef ENABLE_RAW_DATA_QUEUE
-int rm31080_ctrl_read_raw_data(unsigned char *p)
-{
-#define T007B1_ST_DATA_ADDR 0x1CA0
-#define T007C1_ST_DATA_ADDR 0x0514
-#define T007B1_ST_NO_SWAP 0
-
- int ret;
-
- char buf[3];
-
- 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);
- } else {
- ret = rm31080_spi_byte_write(RM31080_REG_01, 0x10);
- if (ret)
- ret = rm31080_spi_byte_write(RM31080_REG_02, 0x00);
-
- if (ret)
- ret = rm31080_spi_read(RM31080_REG_80, p,
- g_stCtrl.u16DataLength);
- }
-
- if (g_stCtrl.bSTScan) {
- if (g_stCtrl.bICVersion == T007A6)
- return ret;
+}
- if (!ret)
- return ret;
+/*=============================================================================
+ Description:
+ RM31080 control functions.
+ Input:
+ N/A
+ Output:
+ 1:succeed
+ 0:failed
+=============================================================================*/
- buf[0] = RM31080B1_REG_BANK0_00H;
- if (g_stCtrl.bICVersion == T007_VERSION_B) {
- buf[1] = (T007B1_ST_DATA_ADDR >> 8) & 0x1F;
- buf[2] = T007B1_ST_DATA_ADDR & 0xFF;
- } else if (g_stCtrl.bICVersion == T007_VERSION_C) {
- buf[1] = (T007C1_ST_DATA_ADDR >> 8) & 0x1F;
- buf[2] = T007C1_ST_DATA_ADDR & 0xFF;
- }
- ret = rm31080_spi_burst_write(buf, sizeof(buf));
+/*=============================================================================
+ Description: Read Sensor Raw Data
- if (ret)
- ret = rm31080_spi_read(RM31080B1_REG_BANK0_03H |
- 0x80, p + RM_MAX_MT_COUNT,
- RM_MAX_CHANNEL_COUNT);
- }
+ Input:
+ *p : Raw Data Buffer Address
+ Output:
+ none
+=============================================================================*/
+static int rm_tch_read_image_data(unsigned char *p)
+{
+ int ret;
+ g_pu8BurstReadBuf = p;
+ ret = rm_tch_cmd_process(0, g_stRmReadImgCmd, NULL);
return ret;
}
-#ifdef ENABLE_AUTO_SCAN
-void rm_set_idle(u8 OnOff)
+void rm_ctrl_set_idle(u8 OnOff)
{
- u8 reg_46h;
- switch (OnOff) {
- case 1:
- rm31080_spi_read(0x46 | 0x80, &reg_46h, 1);
- rm31080_spi_byte_write(0x46, reg_46h | 0xF0);
- break;
- default:
- rm31080_spi_read(0x46 | 0x80, &reg_46h, 1);
- rm31080_spi_byte_write(0x46, reg_46h & 0x0F);
- break;
- }
+ rm_tch_cmd_process(OnOff, g_stCmdSetIdle, NULL);
}
-void rm_set_auto(u8 OnOff)
-{
- u8 reg_09h = 0;
- u8 reg_0Ah = 0;
- switch (OnOff) {
- case 1:
- rm31080_spi_read(0x09 | 0x80, &reg_09h, 1);
- rm31080_spi_byte_write(0x09, reg_09h | 0x50);
- rm31080_spi_read(0x0A | 0x80, &reg_0Ah, 1);
- rm31080_spi_byte_write(0x0A, reg_0Ah & 0x0F);
- break;
- default:
- rm31080_spi_read(0x09 | 0x80, &reg_09h, 1);
- rm31080_spi_byte_write(0x09, reg_09h & 0x0F);
- rm31080_spi_read(0x0A | 0x80, &reg_0Ah, 1);
- rm31080_spi_byte_write(0x0A, reg_0Ah | 0x40);
- break;
- }
-}
-
-void rm31080_ctrl_enter_auto_mode(void)
+void rm_tch_ctrl_enter_auto_mode(void)
{
- if (g_stCtrl.bICVersion == T007A6)
- rm31080_ts_send_signal(g_stTs.ulHalPID,
- RM_SIGNAL_ENTER_AUTO_SCAN);
+ /*g_stCtrl.bfIdleModeCheck = 0; */
+ g_stCtrl.bfIdleModeCheck &= ~0x01;
- /*Enable auto scan */
- if (g_stCtrl.bfIdleMessage)
+ /*Enable auto scan*/
+ if ((g_stCtrl.bDebugMessage & DEBUG_DRIVER) == DEBUG_DRIVER)
rm_printk("Enter Auto Scan Mode\n");
- /*Set idle*/
- rm_set_idle(1);
- if (g_stCtrl.bSTScan)
- rm_set_auto(1);
- else
- rm31080_spi_byte_write(RM31080_REG_09, 0x10 | 0x40);
+ if (g_stCtrl.bICVersion < 0xD0)
+ rm_set_repeat_times(g_stCtrl.bIdleRepeatTimes[0]);
+
+ rm_ctrl_set_idle(1);
+
+#if ( ENABLE_MANUAL_IDLE_MODE == 1)
+ rm_tch_spi_byte_write(RM31080_REG_09, 0x40);
+#else
+ rm_tch_spi_byte_write(RM31080_REG_09, 0x10 | 0x40);
+#endif
}
-void rm31080_ctrl_leave_auto_mode(void)
+void rm_tch_ctrl_leave_auto_mode(void)
{
- /*Disable auto scan */
- g_stCtrl.bfIdleModeCheck = 1;
+ g_stCtrl.bfIdleModeCheck |= 0x01;
+ /*Disable auto scan*/
- if (g_stCtrl.bfIdleMessage)
- rm_printk("Leave Auto Scan Mode\n");
- /*leave idle*/
- rm_set_idle(0);
+ if (g_stCtrl.bICVersion < 0xD0)
+ rm_set_repeat_times(g_stCtrl.bActiveRepeatTimes[0]);
- if (g_stCtrl.bSTScan)
- rm_set_auto(0);
- else
- rm31080_spi_byte_write(RM31080_REG_09, 0x00);
+ rm_ctrl_set_idle(0);
- if (g_stCtrl.bICVersion == T007A6)
- rm31080_ts_send_signal(g_stTs.ulHalPID,
- RM_SIGNAL_LEAVE_AUTO_SCAN);
+ rm_tch_spi_byte_write(RM31080_REG_09, 0x00);
+ if ((g_stCtrl.bDebugMessage & DEBUG_DRIVER) == DEBUG_DRIVER)
+ rm_printk("Leave Auto Scan Mode\n");
}
-void rm31080_ctrl_pause_auto_mode(void)
+void rm_ctrl_pause_auto_mode(void)
{
- u8 u8reg11;
- rm31080_spi_byte_write(RM31080_REG_09, 0x40); /*disable auto scan */
- rm31080_spi_byte_read(RM31080_REG_11, &u8reg11);
- u8reg11 &= ~0x01;
- /*set scan start=0 */
- rm31080_spi_byte_write(RM31080_REG_11, u8reg11);
+ rm_tch_cmd_process(0, g_stCmdPauseAuto, NULL);
}
-#endif /*ENABLE_AUTO_SCAN */
-static u32 rm31080_ctrl_configure(void)
+static u32 rm_tch_ctrl_configure(void)
{
u32 u32Flag;
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;
-
- break;
-#ifdef ENABLE_AUTO_SCAN
- case RM_SCAN_MODE_PREPARE_AUTO:
- rm31080_ctrl_enter_auto_mode();
- g_stTs.u8ScanModeState = RM_SCAN_MODE_AUTO_SCAN;
- u32Flag = RM_NEED_NONE;
- break;
- case RM_SCAN_MODE_AUTO_SCAN:
- rm31080_ctrl_leave_auto_mode();
- rm31080_ctrl_scan_start();
- g_stTs.u8ScanModeState = RM_SCAN_MODE_MANUAL;
-
- if (g_stCtrl.bICVersion != T007A6) {
+ case RM_SCAN_ACTIVE_MODE:
u32Flag =
- RM_NEED_TO_SEND_SCAN |
- RM_NEED_TO_READ_RAW_DATA |
+ RM_NEED_TO_SEND_SCAN | RM_NEED_TO_READ_RAW_DATA |
RM_NEED_TO_SEND_SIGNAL;
- } else
- u32Flag = RM_NEED_TO_SEND_SCAN;
- break;
-#endif /*ENABLE_AUTO_SCAN */
- default:
- u32Flag = RM_NEED_NONE;
- break;
+ break;
+
+ case RM_SCAN_PRE_IDLE_MODE:
+ rm_tch_ctrl_enter_auto_mode();
+ g_stTs.u8ScanModeState = RM_SCAN_IDLE_MODE;
+ u32Flag = RM_NEED_NONE;
+ break;
+
+ case RM_SCAN_IDLE_MODE:
+ rm_tch_ctrl_leave_auto_mode();
+ rm_tch_ctrl_scan_start();
+ g_stTs.u8ScanModeState = RM_SCAN_ACTIVE_MODE;
+ if (g_stCtrl.bICVersion >= 0xD0)
+ u32Flag = RM_NEED_TO_SEND_SCAN;
+ else
+ u32Flag =
+ RM_NEED_TO_SEND_SCAN | RM_NEED_TO_READ_RAW_DATA |
+ RM_NEED_TO_SEND_SIGNAL;
+ break;
+
+ default:
+ u32Flag = RM_NEED_NONE;
+ break;
}
return u32Flag;
}
-#endif /*ENABLE_RAW_DATA_QUEUE */
-/*========================================================================= */
-#ifdef ENABLE_RM31080_DEEP_SLEEP
-
-static int rm31080_ctrl_suspend(struct rm31080_ts *ts)
+static int rm_tch_cmd_process(u8 selCase, u8 *pCmdTbl, struct rm_tch_ts *ts)
{
- /* handle touch suspend */
- int error;
- /*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);
- usleep_range(8000, 9000);/*msleep(8); */
- rm31080_ctrl_clear_int();
- /*disable auto scan */
-
- if (g_stCtrl.bICVersion == T007A6) {
- rm31080_spi_byte_write(RM31080_REG_09, 0x00);
- rm31080_spi_byte_write(RM31080_REG_10, 0x14);
- rm31080_ctrl_scan_start();
- rm31080_ctrl_scan_start();
- usleep_range(15000, 20000); /*msleep(15); */
- }
+#define _CMD u16j
+#define _ADDR u16j+1
+#define _SUB_CMD u16j+1
+#define _DATA u16j+2
- rm31080_spi_byte_write(RM31080_REG_11, 0x06);
+ static DEFINE_MUTEX(lock);
+ u16 u16j = 0, u16strIdx, u16TblLenth, u16Tmp;
+ u8 u8i, u8reg = 0;
+ int ret = FAIL;
+ struct rm_spi_ts_platform_data *pdata;
- msleep(100);
- /* 1) disable (3.3v) */
- if (ts->regulator_3v3) {
- error = regulator_disable(ts->regulator_3v3);
- if (error < 0)
- dev_err(&g_spi->dev,
- "raydium regulator 3.3V disable failed: %d\n",
- error);
+ mutex_lock(&lock);
+
+
+ pdata = g_input_dev->dev.parent->platform_data;
+
+ u16TblLenth = pCmdTbl[KRL_TBL_FIELD_POS_LEN_H];
+ u16TblLenth <<= 8;
+ u16TblLenth |= pCmdTbl[KRL_TBL_FIELD_POS_LEN_L];
+ if (u16TblLenth < 3) {
+ dev_err(&g_spi->dev, "Null CMD %s: [0x%x] cmd failed\n", __func__, (u32)pCmdTbl);
+ mutex_unlock(&lock);
+ return ret;
}
- /* handle platforms w/ and w/out regulator switches */
- /* 2) delay for platforms w/ regulator switches */
- usleep_range(15000, 20000); /*msleep(15); */
- /* 3) disable clock */
- if (ts->clk)
- clk_disable(ts->clk);
- /* 4) disable 1.8 */
- if (ts->regulator_1v8 && ts->regulator_3v3) {
- error = regulator_disable(ts->regulator_1v8);
- if (error < 0)
- dev_err(&g_spi->dev,
- "raydium regulator 1.8V disable failed: %d\n",
- error);
+
+ u16strIdx = pCmdTbl[KRL_TBL_FIELD_POS_CASE_NUM] + KRL_TBL_FIELD_POS_CASE_NUM + 1;
+ for (u8i = 0; u8i < selCase; u8i++) {
+ u16strIdx += (pCmdTbl[u8i + KRL_TBL_FIELD_POS_CMD_NUM] * KRL_TBL_CMD_LEN);
}
- printk(KERN_ALERT "Raydium Sending SUSPEND done\n");
- if (g_stTs.bInitStartFlag)
- g_stTs.bInitFailFlag = 1;
- mutex_unlock(&g_stTs.mutex_scan_mode);
- return 1;
+
+ for (u8i = 0; u8i < pCmdTbl[selCase + KRL_TBL_FIELD_POS_CMD_NUM]; u8i++) {
+ u16j = u16strIdx + (KRL_TBL_CMD_LEN * u8i);
+ ret = FAIL;
+ switch (pCmdTbl[_CMD]) {
+ case KRL_CMD_READ:
+ ret = rm_tch_spi_read(pCmdTbl[_ADDR],&u8reg,1);
+ /*rm_printk("KRL_CMD_READ : 0x%x:0x%x \n",pCmdTbl[_ADDR],u8reg);*/
+ break;
+ case KRL_CMD_WRITE_W_DATA:
+ /*rm_printk("KRL_CMD_WRITE_W_DATA : 0x%x:0x%x \n",pCmdTbl[_ADDR],pCmdTbl[_DATA]);*/
+ ret = rm_tch_spi_byte_write(pCmdTbl[_ADDR],pCmdTbl[_DATA]);
+ break;
+ case KRL_CMD_WRITE_WO_DATA:
+ /*rm_printk("KRL_CMD_WRITE_WO_DATA : 0x%x:0x%x \n",pCmdTbl[_ADDR],u8reg);*/
+ ret = rm_tch_spi_byte_write(pCmdTbl[_ADDR],u8reg);
+ break;
+ case KRL_CMD_AND:
+ u8reg &= pCmdTbl[_DATA];
+ ret = OK;
+ break;
+ case KRL_CMD_OR:
+ u8reg |= pCmdTbl[_DATA];
+ ret = OK;
+ break;
+ case KRL_CMD_NOT:
+ u8reg = ~u8reg;
+ ret = OK;
+ break;
+ case KRL_CMD_XOR:
+ u8reg ^= pCmdTbl[_DATA];
+ ret = OK;
+ break;
+ case KRL_CMD_SEND_SIGNAL:
+ u16Tmp = pCmdTbl[_DATA];
+ /*rm_printk("KRL_SEND_SIGNAL_CM : %d\n",u16Tmp);*/
+ ret = rm_tch_ts_send_signal(g_stTs.ulHalPID, (int)u16Tmp);
+ break;
+ case KRL_CMD_CONFIG_RST:
+ /*rm_printk("KRL_CMD_CONFIG_RST : %d - %d\n",pCmdTbl[_SUB_CMD],pCmdTbl[_DATA]);*/
+ switch (pCmdTbl[_SUB_CMD]) {
+ case KRL_SUB_CMD_SET_RST_GPIO:
+ gpio_direction_output(pdata->gpio_reset, pCmdTbl[_DATA]);
+ break;
+ case KRL_SUB_CMD_SET_RST_VALUE:
+ gpio_set_value(pdata->gpio_reset, pCmdTbl[_DATA]);
+ break;
+ }
+ ret = OK;
+ break;
+ case KRL_CMD_CONFIG_3V3:/*Need to check qpio setting*/
+ /*rm_printk("KRL_CMD_CONFIG_3V3 : %d - %d\n",pCmdTbl[_SUB_CMD],pCmdTbl[_DATA]);*/
+ if (pCmdTbl[_SUB_CMD] == KRL_SUB_CMD_SET_3V3_REGULATOR) {
+ if (ts) {
+ if (pCmdTbl[_DATA]) {
+ if (ts->regulator_3v3) {
+ ret = regulator_enable(ts->regulator_3v3);
+ if (ret < 0) {
+ dev_err(&g_spi->dev,
+ "raydium regulator 3.3V enable failed: %d\n",
+ ret);
+ ret = FAIL;
+ } else
+ ret = OK;
+ }
+ } else {
+ if (ts->regulator_3v3) {
+ ret = regulator_disable(ts->regulator_3v3);
+ if (ret < 0) {
+ dev_err(&g_spi->dev,
+ "raydium regulator 3.3V disable failed: %d\n",
+ ret);
+ ret = FAIL;
+ } else
+ ret = OK;
+ }
+ }
+ } else {
+ ret = FAIL;
+ }
+ /*gpio_set_value(pdata->gpio_3v3, pCmdTbl[_DATA]);*/
+ } else if (pCmdTbl[_SUB_CMD] == KRL_SUB_CMD_SET_3V3_GPIO) {
+ gpio_direction_output(pdata->gpio_3v3, pCmdTbl[_DATA]);
+ ret = OK;
+ } else {
+ ret = FAIL;
+ }
+ break;
+ case KRL_CMD_CONFIG_1V8:/*Need to check qpio setting*/
+ /*rm_printk("KRL_CMD_CONFIG_1V8 : %d - %d\n",pCmdTbl[_SUB_CMD],pCmdTbl[_DATA]);*/
+ if (pCmdTbl[_SUB_CMD] == KRL_SUB_CMD_SET_1V8_REGULATOR) {
+ if (ts) {
+ if (pCmdTbl[_DATA]) {
+ if (ts->regulator_1v8) {
+ ret = regulator_enable(ts->regulator_1v8);
+ if (ret < 0) {
+ dev_err(&g_spi->dev,
+ "raydium regulator 1.8V enable failed: %d\n",
+ ret);
+ ret = FAIL;
+ } else
+ ret = OK;
+ }
+ } else {
+ if (ts->regulator_1v8 && ts->regulator_3v3) {
+ ret = regulator_disable(ts->regulator_1v8);
+ if (ret < 0) {
+ dev_err(&g_spi->dev,
+ "raydium regulator 1.8V disable failed: %d\n",
+ ret);
+ ret = FAIL;
+ } else
+ ret = OK;
+ }
+ }
+ } else {
+ ret = FAIL;
+ }
+ /*gpio_set_value(pdata->gpio_1v8, pCmdTbl[_DATA]);*/
+ } else if (pCmdTbl[_SUB_CMD] == KRL_SUB_CMD_SET_1V8_GPIO) {
+ gpio_direction_output(pdata->gpio_1v8, pCmdTbl[_DATA]);
+ ret = OK;
+ } else {
+ ret = FAIL;
+ }
+ break;
+ case KRL_CMD_CONFIG_CLK:
+ /*rm_printk("KRL_CMD_CONFIG_CLK : %d - %d\n",pCmdTbl[_SUB_CMD],pCmdTbl[_DATA]);*/
+ ret = OK;
+ if (ts && ts->clk) {
+ if (pCmdTbl[_SUB_CMD] == KRL_SUB_CMD_SET_CLK) {
+ if (pCmdTbl[_DATA])
+ clk_enable(ts->clk);
+ else
+ clk_disable(ts->clk);
+ } else
+ ret = FAIL;
+ } else {
+ ret = FAIL;
+ }
+ break;
+ case KRL_CMD_SET_TIMER:
+ /*rm_printk("KRL_CMD_SET_TIMER : %d\n",pCmdTbl[_SUB_CMD]);*/
+ ret = OK;
+ if (pCmdTbl[_SUB_CMD] == KRL_SUB_CMD_INIT_TIMER) {
+ init_ts_timer();
+ } else if (pCmdTbl[_SUB_CMD] == KRL_SUB_CMD_ADD_TIMER) {
+ add_timer(&ts_timer_triggle);
+ } else if (pCmdTbl[_SUB_CMD] == KRL_SUB_CMD_DEL_TIMER) {
+ del_timer(&ts_timer_triggle);
+ } else
+ ret = FAIL;
+ break;
+ case KRL_CMD_USLEEP:
+ /*rm_printk("KRL_CMD_USLEEP : %d ms\n",pCmdTbl[_DATA]);*/
+ u16Tmp = pCmdTbl[_DATA];
+ u16Tmp *= 1000;
+ usleep_range(u16Tmp,u16Tmp+200);
+ ret = OK;
+ break;
+ case KRL_CMD_MSLEEP:
+ /*rm_printk("KRL_CMD_MSLEEP : %d ms\n",pCmdTbl[_DATA]);*/
+ msleep(pCmdTbl[_DATA]);
+ ret = OK;
+ break;
+ case KRL_CMD_FLUSH_QU:
+ /*rm_printk("KRL_CMD_FLUSH_QU : %d\n",pCmdTbl[_SUB_CMD]);*/
+ ret = OK;
+ if (pCmdTbl[_SUB_CMD] == KRL_SUB_CMD_SENSOR_QU) {
+ flush_workqueue(g_stTs.rm_workqueue);
+ } else if (pCmdTbl[_SUB_CMD] == KRL_SUB_CMD_TIMER_QU) {
+ flush_workqueue(g_stTs.rm_timer_workqueue);
+ } else
+ ret = FAIL;
+ break;
+ case KRL_CMD_READ_IMG:
+ /*rm_printk("KRL_CMD_READ_IMG : 0x%x:0x%x:%d \n",pCmdTbl[_ADDR],g_pu8BurstReadBuf,g_stCtrl.u16DataLength);*/
+ if (g_pu8BurstReadBuf)
+ ret = rm_tch_spi_read(pCmdTbl[_ADDR] | 0x80, g_pu8BurstReadBuf, g_stCtrl.u16DataLength);
+ g_pu8BurstReadBuf = NULL;
+ break;
+ default:
+ break;
+ }
+
+
+ if (ret == FAIL) {
+ dev_err(&g_spi->dev, "%s: [0x%x] cmd failed - cmd:0x%x, addr:0x%x, data:0x%x\n", __func__, (u32)pCmdTbl,
+ pCmdTbl[_CMD], pCmdTbl[_ADDR], pCmdTbl[_DATA]);
+ break;
+ }
+ }
+
+ mutex_unlock(&lock);
+ return ret;
}
-#endif
-/*========================================================================= */
-static void rm31080_enter_manual_mode(void)
+int rm_set_kernel_tbl(int iFuncIdx, u8 *u8pSrc)
{
- flush_workqueue(g_stTs.rm_workqueue);
-
- if (g_stTs.u8ScanModeState == RM_SCAN_MODE_MANUAL)
- return;
+ ssize_t missing;
+ u16 u16len;
+ u8 *u8pDst;
- if (g_stTs.u8ScanModeState == RM_SCAN_MODE_PREPARE_AUTO) {
- g_stTs.u8ScanModeState = RM_SCAN_MODE_MANUAL;
- return;
+ switch (iFuncIdx) {
+ case KRL_INDEX_FUNC_SET_IDLE:
+ u8pDst = g_stCmdSetIdle;
+ break;
+ case KRL_INDEX_FUNC_PAUSE_AUTO:
+ u8pDst = g_stCmdPauseAuto;
+ break;
+ case KRL_INDEX_RM_START:
+ u8pDst = g_stRmStartCmd;
+ break;
+ case KRL_INDEX_RM_END:
+ u8pDst = g_stRmEndCmd;
+ break;
+ case KRL_INDEX_RM_READ_IMG:
+ u8pDst = g_stRmReadImgCmd;
+ break;
+ case KRL_INDEX_RM_WATCHDOG:
+ u8pDst = g_stRmWatchdogCmd;
+ break;
+ case KRL_INDEX_RM_TESTMODE:
+ u8pDst = g_stRmTestModeCmd;
+ break;
+ case KRL_INDEX_RM_SLOWSCAN:
+ u8pDst = g_stRmSlowScanCmd;
+ break;
+ default:
+ dev_err(&g_spi->dev, "%s: no kernel table - err:%d\n", __func__, iFuncIdx);
+ return FAIL;
}
- if (g_stTs.u8ScanModeState == RM_SCAN_MODE_AUTO_SCAN) {
- rm31080_ctrl_leave_auto_mode();
- g_stTs.u8ScanModeState = RM_SCAN_MODE_MANUAL;
- usleep_range(10000, 12000); /*msleep(10); */
+ u16len = u8pSrc[KRL_TBL_FIELD_POS_LEN_H];
+ u16len <<= 8;
+ u16len |= u8pSrc[KRL_TBL_FIELD_POS_LEN_L];
+
+ missing = copy_from_user(u8pDst, u8pSrc, u16len);
+ if (missing) {
+ dev_err(&g_spi->dev, "%s: copy failed - len:%d, miss:%d\n", __func__, u16len, missing);
+ return FAIL;
}
+ return OK;
}
-
/*=============================================================================
- * Description:
- * Copy Config(Parameters) to HAL's Buffer
- * Input:
- * p: HAL's buffer
- * u32Len : buffer size
- * Output:
- * 1: succeed
- * 0: failed
- *=============================================================================
- */
-static long rm31080_get_config(u8 *p, u32 u32Len)
-{
- u32 u32Ret;
- struct rm_spi_ts_platform_data *pdata;
- u8 var;
- if (rm31080_spi_byte_read(RM31080_REG_7E, &var))
- g_stCtrl.bICVersion = var & 0xF0;
- else
- g_stCtrl.bICVersion = T007A6;
+=============================================================================*/
+static void rm_tch_enter_manual_mode(void)
+{
+ flush_workqueue(g_stTs.rm_workqueue);
- pdata = g_input_dev->dev.parent->platform_data;
+ if (g_stTs.u8ScanModeState == RM_SCAN_ACTIVE_MODE)
+ return;
- 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 (g_stTs.u8ScanModeState == RM_SCAN_PRE_IDLE_MODE) {
+ g_stTs.u8ScanModeState = RM_SCAN_ACTIVE_MODE;
+ return;
}
- if (u32Ret != 0)
- return 0;
- return 1;
+ if (g_stTs.u8ScanModeState == RM_SCAN_IDLE_MODE) {
+ rm_tch_ctrl_leave_auto_mode();
+ g_stTs.u8ScanModeState = RM_SCAN_ACTIVE_MODE;
+ usleep_range(10000, 10050);/*msleep(10);*/
+ }
}
-static u32 rm31080_get_platform_id(u8 *p)
+static u32 rm_tch_get_platform_id(u8 *p)
{
u32 u32Ret;
struct rm_spi_ts_platform_data *pdata;
pdata = g_input_dev->dev.parent->platform_data;
- u32Ret = copy_to_user(p, &pdata->platform_id,
- sizeof(pdata->platform_id));
+ u32Ret = copy_to_user(p, &pdata->platform_id, sizeof(pdata->platform_id));
if (u32Ret != 0)
return 0;
return 1;
}
-/*=========================================================================*/
-int rm31080_ts_send_signal(int pid, int iInfo)
+/*=============================================================================*/
+static int rm_tch_ts_send_signal(int pid, int iInfo)
{
struct siginfo info;
struct task_struct *t;
- int ret = 0;
+ int ret = OK;
static DEFINE_MUTEX(lock);
- if (!pid)
- return ret;
+ if (!pid) {
+ dev_err(&g_spi->dev, "%s: pid failed\n", __func__);
+ return FAIL;
+ }
mutex_lock(&lock);
/* send the signal */
memset(&info, 0, sizeof(struct siginfo));
info.si_signo = RM_TS_SIGNAL;
info.si_code = SI_QUEUE;
- /* this is bit of a trickery: SI_QUEUE is normally
- * used by sigqueue from user space, and kernel space
- * should use SI_KERNEL. But if SI_KERNEL is used the real_time data
- * is not delivered to the user space signal handler function.
- */
- info.si_int = iInfo;/*real time signals may have 32 bits of data. */
+ /*
+ this is bit of a trickery: SI_QUEUE is normally used by sigqueue from user space,
+ and kernel space should use SI_KERNEL. But if SI_KERNEL is used the real_time data
+ is not delivered to the user space signal handler function.
+ */
+ info.si_int = iInfo; /*real time signals may have 32 bits of data.*/
rcu_read_lock();
t = find_task_by_vpid(pid);
rcu_read_unlock();
if (t == NULL) {
- rmd_printk("no such pid\n");
- ret = -ENODEV;
+ dev_err(&g_spi->dev, "%s: no such pid\n", __func__);
+ return FAIL;
} else
- ret = send_sig_info(RM_TS_SIGNAL, &info, t);
-
- if (ret < 0)
- rmd_printk("error sending signal\n");
+ ret = send_sig_info(RM_TS_SIGNAL, &info, t); /*send the signal*/
+ if (ret < 0) {
+ dev_err(&g_spi->dev, "%s: send sig failed err:%d \n", __func__, ret);
+ return FAIL;
+ }
mutex_unlock(&lock);
- return ret;
+ return OK;
}
/*=============================================================================
- * Description:
- * Queuing functions.
- * Input:
- * N/A
- * Output:
- * 0:succeed
- * others:error code
- *=============================================================================
- */
-#ifdef ENABLE_RAW_DATA_QUEUE
-static void rm31080_queue_reset(void)
+ Description:
+ Queuing functions.
+ Input:
+ N/A
+ Output:
+ 0:succeed
+ others:error code
+=============================================================================*/
+static void rm_tch_queue_reset(void)
{
g_stQ.u16Rear = 0;
g_stQ.u16Front = 0;
}
-static int rm31080_queue_init(void)
+static int rm_tch_queue_init(void)
{
- rm31080_queue_reset();
+ rm_tch_queue_reset();
g_stQ.pQueue = kmalloc(QUEUE_COUNT * RAW_DATA_LENGTH, GFP_KERNEL);
- if (g_stQ.pQueue == NULL)
+ if (g_stQ.pQueue == NULL) {
return -ENOMEM;
+ }
return 0;
}
-static void rm31080_queue_free(void)
+static void rm_tch_queue_free(void)
{
if (!g_stQ.pQueue)
return;
@@ -991,7 +966,7 @@ static void rm31080_queue_free(void)
}
#ifdef ENABLE_CALC_QUEUE_COUNT
-static int rm31080_queue_get_current_count(void)
+static int rm_tch_queue_get_current_count(void)
{
if (g_stQ.u16Rear >= g_stQ.u16Front)
return g_stQ.u16Rear - g_stQ.u16Front;
@@ -1001,23 +976,22 @@ static int rm31080_queue_get_current_count(void)
#endif
/*=============================================================================
- * Description:
- * About full/empty buffer distinction,
- * There are a number of solutions like:
- * 1.Always keep one slot open.
- * 2.Use a fill count to distinguish the two cases.
- * 3.Use read and write counts to get the fill count from.
- * 4.Use absolute indices.
- * we chose "keep one slot open" to make it simple and robust
- * and also avoid race condition.
- * Input:
- * N/A
- * Output:
- * 1:empty
- * 0:not empty
- *=============================================================================
- */
-static int rm31080_queue_is_empty(void)
+ Description:
+ About full/empty buffer distinction,
+ There are a number of solutions like:
+ 1.Always keep one slot open.
+ 2.Use a fill count to distinguish the two cases.
+ 3.Use read and write counts to get the fill count from.
+ 4.Use absolute indices.
+ we chose "keep one slot open" to make it simple and robust
+ and also avoid race condition.
+ Input:
+ N/A
+ Output:
+ 1:empty
+ 0:not empty
+=============================================================================*/
+static int rm_tch_queue_is_empty(void)
{
if (g_stQ.u16Rear == g_stQ.u16Front)
return 1;
@@ -1025,16 +999,15 @@ static int rm31080_queue_is_empty(void)
}
/*=============================================================================
- * Description:
- * check queue full.
- * Input:
- * N/A
- * Output:
- * 1:full
- * 0:not full
- *=============================================================================
- */
-static int rm31080_queue_is_full(void)
+ Description:
+ check queue full.
+ Input:
+ N/A
+ Output:
+ 1:full
+ 0:not full
+=============================================================================*/
+static int rm_tch_queue_is_full(void)
{
u16 u16Front = g_stQ.u16Front;
if (g_stQ.u16Rear + 1 == u16Front)
@@ -1046,19 +1019,19 @@ static int rm31080_queue_is_full(void)
return 0;
}
-static void *rm31080_enqueue_start(void)
+static void *rm_tch_enqueue_start(void)
{
- if (!g_stQ.pQueue) /*error handling for no memory */
+ if (!g_stQ.pQueue) /*error handling for no memory*/
return NULL;
- if (!rm31080_queue_is_full())
+ if (!rm_tch_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;
}
-static void rm31080_enqueue_finish(void)
+static void rm_tch_enqueue_finish(void)
{
if (g_stQ.u16Rear == (QUEUE_COUNT - 1))
g_stQ.u16Rear = 0;
@@ -1066,15 +1039,15 @@ static void rm31080_enqueue_finish(void)
g_stQ.u16Rear++;
}
-static void *rm31080_dequeue_start(void)
+static void *rm_tch_dequeue_start(void)
{
- if (!rm31080_queue_is_empty())
+ if (!rm_tch_queue_is_empty())
return &g_stQ.pQueue[g_stQ.u16Front];
return NULL;
}
-static void rm31080_dequeue_finish(void)
+static void rm_tch_dequeue_finish(void)
{
if (g_stQ.u16Front == (QUEUE_COUNT - 1))
g_stQ.u16Front = 0;
@@ -1082,11 +1055,11 @@ static void rm31080_dequeue_finish(void)
g_stQ.u16Front++;
}
-static long rm31080_queue_read_raw_data(u8 *p, u32 u32Len)
+static long rm_tch_queue_read_raw_data(u8 *p, u32 u32Len)
{
u8 *pQueue;
u32 u32Ret;
- pQueue = rm31080_dequeue_start();
+ pQueue = rm_tch_dequeue_start();
if (!pQueue)
return 0;
@@ -1094,37 +1067,36 @@ static long rm31080_queue_read_raw_data(u8 *p, u32 u32Len)
if (u32Ret != 0)
return 0;
- rm31080_dequeue_finish();
+ rm_tch_dequeue_finish();
return 1;
}
-#endif /*ENABLE_RAW_DATA_QUEUE */
-/*=====================================================================*/
-#ifdef ENABLE_WORK_QUEUE
+/*=============================================================================*/
static void rm_work_handler(struct work_struct *work)
{
void *pKernelBuffer;
u32 u32Flag;
int iRet;
- if (g_stTs.bIsSuspended)
+ if (g_stTs.bInitFinish == false || g_stTs.bIsSuspended)
return;
mutex_lock(&g_stTs.mutex_scan_mode);
- iRet = rm31080_ctrl_clear_int();
+ iRet = rm_tch_ctrl_clear_int();
- u32Flag = rm31080_ctrl_configure();
+ u32Flag = rm_tch_ctrl_configure();
- if (u32Flag & RM_NEED_TO_SEND_SCAN)
- rm31080_ctrl_scan_start();
+ if (u32Flag & RM_NEED_TO_SEND_SCAN) {
+ rm_tch_ctrl_scan_start();
+ }
if (u32Flag & RM_NEED_TO_READ_RAW_DATA) {
- pKernelBuffer = rm31080_enqueue_start();
+ pKernelBuffer = rm_tch_enqueue_start();
if (pKernelBuffer) {
- iRet = rm31080_ctrl_read_raw_data((u8 *) pKernelBuffer);
-
- if (iRet)
- rm31080_enqueue_finish();
+ iRet = rm_tch_read_image_data((u8 *) pKernelBuffer);
+ if (iRet) {
+ rm_tch_enqueue_finish();
+ }
}
}
mutex_unlock(&g_stTs.mutex_scan_mode);
@@ -1132,98 +1104,163 @@ static void rm_work_handler(struct work_struct *work)
if (u32Flag & RM_NEED_TO_SEND_SIGNAL) {
if (g_stTs.bCalcFinish) {
g_stTs.bCalcFinish = 0;
- rm31080_ts_send_signal(g_stTs.ulHalPID, RM_SIGNAL_INTR);
+ rm_tch_ts_send_signal(g_stTs.ulHalPID, RM_SIGNAL_INTR);
}
}
}
-#endif /*ENABLE_WORK_QUEUE */
-/*========================================================================= */
-static void __rm31080_enable(struct rm31080_ts *ts)
+
+static void rm_tch_init_ts_structure_part(void)
{
- enable_irq(ts->irq);
-}
+ g_stTs.bInitFinish = 0;
+ g_stTs.bCalcFinish = 0;
+ g_stTs.bEnableScriber = 0;
+ g_stTs.bIsSuspended = 0;
+ g_stTs.bEnableAutoScan = 1;
+#ifdef ENABLE_SLOW_SCAN
+ g_stTs.bEnableSlowScan = false;
+#endif
+ g_stTs.u8ScanModeState = RM_SCAN_ACTIVE_MODE;
+
+ g_pu8BurstReadBuf = NULL;
-static void __rm31080_disable(struct rm31080_ts *ts)
+ rm_watchdog_enable(0);
+ rm_tch_ctrl_init();
+}
+/*==============================================================================*/
+static void rm_watchdog_enable(unsigned char u8Enable)
{
- disable_irq(ts->irq);
+
+ g_stTs.u8WatchDogFlg = 0;
+ g_stTs.u32WatchDogCnt = 0;
+ g_stTs.u8WatchDogCheck=0;
+
+ if (u8Enable) {
+ g_stTs.u8WatchDogEnable = 1;
+ g_stTs.u32WatchDogTime = WDT_INIT_TIME; /*60sec*/
+ } else {
+ g_stTs.u8WatchDogEnable = 0;
+ g_stTs.u32WatchDogTime = 0xFFFFFFFF;
+ }
+ if ((g_stCtrl.bDebugMessage & DEBUG_DRIVER) == DEBUG_DRIVER)
+ rm_printk("Raydium TS: WatchDogEnable=%d\n",g_stTs.u8WatchDogEnable);
+
}
-void rm31080_send_command(struct rm_cmd_list *rm_cmd_list)
+static void rm_watchdog_work_function(unsigned char scan_mode)
{
- unsigned char i;
- unsigned char addr;
- unsigned char value;
- for (i = 0; i < rm_cmd_list->count; i++) {
- addr = rm_cmd_list->cmd[i].addr;
- value = rm_cmd_list->cmd[i].value;
- rmd_printk("No:[%d]addr:0x%x,value:0x%x\n", i, addr, value);
- rm31080_spi_byte_write(addr, value);
+ if ((g_stTs.u8WatchDogEnable==0)||(g_stTs.bInitFinish==0)) {
+ return;
+ }
+ if (g_stTs.u32WatchDogCnt++ > g_stTs.u32WatchDogTime) {
+ if ((g_stCtrl.bDebugMessage & DEBUG_DRIVER) == DEBUG_DRIVER)
+ rm_printk("##watchdog work: Time:%dsec Cnt:%d,Flg:%d(%x)\n",g_stTs.u32WatchDogTime/100,g_stTs.u32WatchDogCnt,g_stTs.u8WatchDogFlg,g_stTs.u8ScanModeState);
+
+ switch (scan_mode) {
+ case RM_SCAN_ACTIVE_MODE:
+ g_stTs.u32WatchDogCnt = 0;
+ g_stTs.u8WatchDogFlg = 1;
+ break;
+ case RM_SCAN_IDLE_MODE:
+ g_stTs.u32WatchDogCnt = 0;
+ g_stTs.u8WatchDogCheck = 1;
+ break;
+ }
}
+
+
+ if (g_stTs.u8WatchDogFlg) {
+ /*WATCH DOG RESET*/
+ rm_printk("##WatchDog Resume\n");
+ rm_tch_init_ts_structure_part();
+ g_stTs.bIsSuspended = true;
+ del_timer(&ts_timer_triggle);
+ rm_tch_cmd_process(0, g_stRmWatchdogCmd, NULL);
+ g_stTs.bIsSuspended = false;
+ g_stTs.u8ScanModeState = RM_SCAN_ACTIVE_MODE;
+ add_timer(&ts_timer_triggle);
+ rm_tch_ctrl_scan_start();
+ return;
+ }
+
}
-#ifdef ENABLE_SLOW_SCAN
-void rm31080_set_command(struct rm_cmd_list *cmd_list, char *buf, int count)
+static u8 rm_timer_trigger_function(void)
{
- int i;
- if (count > RM_SLOW_SCAN_CMD_COUNT)
- count = RM_SLOW_SCAN_CMD_COUNT;
- cmd_list->count = count;
- for (i = 0; i < count; i++) {
- cmd_list->cmd[i].addr = buf[(i << 1) + 0];
- cmd_list->cmd[i].value = buf[(i << 1) + 1];
+ static u32 u32TimerCnt=0;
+
+ if (u32TimerCnt++ < g_stCtrl.bTimerTriggerScale) {
+ return 0;
+ } else {
+ /*rm_printk("##rm_timer_work_handler:%x,%x \n", g_stCtrl.bTimerTriggerScale, u32TimerCnt);*/
+ u32TimerCnt=0;
+ return 1;
}
+
}
-static void rm31080_set_slowscan_para(u8 *p, int index)
+static void rm_timer_work_handler(struct work_struct *work)
{
- ssize_t missing;
- u8 buf[256];
- u8 size = p[0];
- missing = copy_from_user(buf, p, size);
- if (missing != 0)
- return;
- if (index > RM_SLOW_SCAN_LEVEL_MAX)
+ if (g_stTs.bIsSuspended)
return;
- rm31080_set_command((struct rm_cmd_list *)
- &g_stCmdSlowScan[index],
- &buf[1],
- (size - 1) >> 1);
+
+ mutex_lock(&g_stTs.mutex_scan_mode);
+ if (rm_timer_trigger_function()) {
+ if (g_stTs.u8ScanModeState != RM_SCAN_ACTIVE_MODE) {
+ rm_watchdog_work_function(RM_SCAN_IDLE_MODE);
+#if( ENABLE_MANUAL_IDLE_MODE == 1)
+ //rm_tch_spi_byte_write(RM31080_REG_11, 0x37);
+ rm_tch_spi_byte_write(RM31080_REG_11, 0x17);
+#endif
+ } else {
+ rm_watchdog_work_function(RM_SCAN_ACTIVE_MODE);
+ }
+ }
+ mutex_unlock(&g_stTs.mutex_scan_mode);
+ if (g_stTs.u8WatchDogCheck==1) {
+ rm_tch_ts_send_signal(g_stTs.ulHalPID, RM_SIGNAL_WATCH_DOG_CHECK);
+ g_stTs.u8WatchDogCheck=0;
+ }
+
}
-void rm31080_slow_scan_init(void)
+/*========================================================================= */
+static void rm_tch_enable_irq(struct rm_tch_ts *ts)
{
- int i;
- for (i = 0; i < RM_SLOW_SCAN_LEVEL_COUNT; i++)
- g_stCmdSlowScan[i].count = 0;
+ enable_irq(ts->irq);
}
+static void rm_tch_disable_irq(struct rm_tch_ts *ts)
+{
+ disable_irq(ts->irq);
+}
+
+#ifdef ENABLE_SLOW_SCAN
/*=============================================================================
* Description:
- * Context dependent touch system.
- * Change scan speed for slowscan function.
- * Change scan speed flow: (by CY,20120305)
- * 1.Disable auto scan ([0x09]bit4=0,[0x09]bit6=1)
- * 2.Clear Scan start bit ([0x11]bit0=0)
- * 3.Read Scan start bit until it equals 0
- * 4.Set LACTIVE and YACTIVE configuration
- * 5.Enable autoscan ([0x09]bit4=1,[0x09]bit6=1)
- * 6.Sleep 1 minisecond.
- * 7.Set Scan start bit ([0x11]bit0=1)
+ * Context dependent touch system.
+ * Change scan speed for slowscan function.
+ * Change scan speed flow: (by CY,20120305)
+ * 1.Disable auto scan ([0x09]bit4=0,[0x09]bit6=1)
+ * 2.Clear Scan start bit ([0x11]bit0=0)
+ * 3.Read Scan start bit until it equals 0
+ * 4.Set LACTIVE and YACTIVE configuration
+ * 5.Enable autoscan ([0x09]bit4=1,[0x09]bit6=1)
+ * 6.Sleep 1 minisecond.
+ * 7.Set Scan start bit ([0x11]bit0=1)
* Input:
- * N/A
+ * N/A
* Output:
- * N/A
+ * N/A
*=============================================================================
- */
-static void rm31080_ctrl_slowscan(u32 level)
+*/
+static void rm_tch_ctrl_slowscan(u32 level)
{
- if (g_stTs.u8ScanModeState == RM_SCAN_MODE_AUTO_SCAN)
- rm31080_ctrl_pause_auto_mode();
-
- rm31080_ctrl_wait_for_scan_finish();
+ if (g_stTs.u8ScanModeState == RM_SCAN_IDLE_MODE) {
+ rm_ctrl_pause_auto_mode();
+ }
- rmd_printk("P005:change level:%d\n", level);
+ rm_tch_ctrl_wait_for_scan_finish();
if (level == RM_SLOW_SCAN_LEVEL_NORMAL)
level = RM_SLOW_SCAN_LEVEL_20;
@@ -1231,17 +1268,19 @@ static void rm31080_ctrl_slowscan(u32 level)
if (level > RM_SLOW_SCAN_LEVEL_100)
level = RM_SLOW_SCAN_LEVEL_MAX;
- rm31080_send_command((struct rm_cmd_list *)
- &g_stCmdSlowScan[level]);
+ rm_tch_cmd_process((u8)level, g_stRmSlowScanCmd, NULL);
+
+ rm_printk("##rm_tch_ctrl_slowscan:%x,%x,%x \n",level,g_stRmSlowScanCmd[0],g_stRmSlowScanCmd[1]);
+
- if (g_stTs.u8ScanModeState == RM_SCAN_MODE_AUTO_SCAN) {
- rm31080_ctrl_enter_auto_mode();
- usleep_range(1000, 2000); /*msleep(1); */
- rm31080_ctrl_scan_start();
+ if (g_stTs.u8ScanModeState == RM_SCAN_IDLE_MODE) {
+ rm_tch_ctrl_enter_auto_mode();
+ usleep_range(1000, 1200);
+ rm_tch_ctrl_scan_start();
}
}
-static u32 rm31080_slowscan_round(u32 val)
+static u32 rm_tch_slowscan_round(u32 val)
{
u32 i;
for (i = 0; i < RM_SLOW_SCAN_LEVEL_COUNT; i++) {
@@ -1249,10 +1288,9 @@ static u32 rm31080_slowscan_round(u32 val)
break;
}
return i;
-
}
-static ssize_t rm31080_slowscan_handler(const char *buf, size_t count)
+static ssize_t rm_tch_slowscan_handler(const char *buf, size_t count)
{
unsigned long val;
ssize_t error;
@@ -1267,10 +1305,10 @@ static ssize_t rm31080_slowscan_handler(const char *buf, size_t count)
if (count == 2) {
if (buf[0] == '0') {
g_stTs.bEnableSlowScan = false;
- rm31080_ctrl_slowscan(RM_SLOW_SCAN_LEVEL_MAX);
+ rm_tch_ctrl_slowscan(RM_SLOW_SCAN_LEVEL_MAX);
} else if (buf[0] == '1') {
g_stTs.bEnableSlowScan = true;
- rm31080_ctrl_slowscan(RM_SLOW_SCAN_LEVEL_60);
+ rm_tch_ctrl_slowscan(RM_SLOW_SCAN_LEVEL_60);
g_stTs.u32SlowScanLevel = RM_SLOW_SCAN_LEVEL_60;
}
} else if ((buf[0] == '2') && (buf[1] == ' ')) {
@@ -1279,8 +1317,8 @@ static ssize_t rm31080_slowscan_handler(const char *buf, size_t count)
ret = error;
} else {
g_stTs.bEnableSlowScan = true;
- g_stTs.u32SlowScanLevel = rm31080_slowscan_round(val);
- rm31080_ctrl_slowscan(g_stTs.u32SlowScanLevel);
+ g_stTs.u32SlowScanLevel = rm_tch_slowscan_round(val);
+ rm_tch_ctrl_slowscan(g_stTs.u32SlowScanLevel);
}
}
@@ -1289,32 +1327,31 @@ static ssize_t rm31080_slowscan_handler(const char *buf, size_t count)
}
#endif
-static ssize_t rm31080_slowscan_show(struct device *dev,
- struct device_attribute *attr, char *buf)
+static ssize_t rm_tch_slowscan_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
{
#ifdef ENABLE_SLOW_SCAN
return sprintf(buf, "Slow Scan:%s\nScan Rate:%dHz\n",
g_stTs.bEnableSlowScan ?
"Enabled" : "Disabled",
g_stTs.u32SlowScanLevel * RM_SLOW_SCAN_INTERVAL);
-
#else
- return sprintf(buf, "0\n");
+ return sprintf(buf, "Not implemented yet\n");
#endif
}
-static ssize_t rm31080_slowscan_store(struct device *dev,
+static ssize_t rm_tch_slowscan_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
#ifdef ENABLE_SLOW_SCAN
- return rm31080_slowscan_handler(buf, count);
+ return rm_tch_slowscan_handler(buf, count);
#else
return count;
#endif
}
-static void rm31080_smooth_level_change(unsigned long val)
+static void rm_tch_smooth_level_change(unsigned long val)
{
int iInfo;
@@ -1327,10 +1364,10 @@ static void rm31080_smooth_level_change(unsigned long val)
(val << 16) |
RM_SIGNAL_CHANGE_PARA;
- rm31080_ts_send_signal(g_stTs.ulHalPID, iInfo);
+ rm_tch_ts_send_signal(g_stTs.ulHalPID, iInfo);
}
-static ssize_t rm31080_smooth_level_handler(const char *buf, size_t count)
+static ssize_t rm_tch_smooth_level_handler(const char *buf, size_t count)
{
unsigned long val;
ssize_t error;
@@ -1340,16 +1377,19 @@ static ssize_t rm31080_smooth_level_handler(const char *buf, size_t count)
return count;
ret = (ssize_t) count;
+
error = kstrtoul(buf, 10, &val);
- if (error)
+ if (error) {
ret = error;
- else
- rm31080_smooth_level_change(val);
+ } else {
+ rm_tch_smooth_level_change(val);
+ }
return ret;
}
-static ssize_t rm31080_self_test_handler(const char *buf, size_t count)
+
+static ssize_t rm_tch_self_test_handler(struct rm_tch_ts *ts, const char *buf, size_t count)
{
unsigned long val;
ssize_t error;
@@ -1363,42 +1403,43 @@ static ssize_t rm31080_self_test_handler(const char *buf, size_t count)
if (g_stTs.u8SelfTestStatus == RM_SELF_TEST_STATUS_TESTING)
return ret;
+
+ rm_tch_enter_test_mode(1);
+
g_stTs.u8SelfTestResult = RM_SELF_TEST_RESULT_PASS;
error = kstrtoul(buf, 10, &val);
if (error) {
ret = error;
+ rm_tch_enter_test_mode(0);
} else if (val == 0) {
- g_stTs.bInitFinish = 0;
- msleep(1000);
- rm31080_spi_checking(1);
+ rm_tch_enter_test_mode(0);
} else if ((val >= 0x01) && (val <= 0xFF)) {
- g_stTs.u8SelfTestStatus = RM_SELF_TEST_STATUS_TESTING;
iInfo = (RM_SIGNAL_PARA_SELF_TEST << 24) |
(val << 16) |
RM_SIGNAL_CHANGE_PARA;
- rm31080_ts_send_signal(g_stTs.ulHalPID, iInfo);
+ rm_tch_ts_send_signal(g_stTs.ulHalPID, iInfo);
}
return ret;
}
-static ssize_t rm31080_smooth_level_show(struct device *dev,
- struct device_attribute *attr,
- char *buf)
+static ssize_t rm_tch_smooth_level_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
{
return sprintf(buf, "Smooth level:%d\n", g_stTs.u32SmoothLevel);
}
-static ssize_t rm31080_smooth_level_store(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t count)
+static ssize_t rm_tch_smooth_level_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
{
- rm31080_smooth_level_handler(buf, count);
+ rm_tch_smooth_level_handler(buf, count);
return count;
}
-static ssize_t rm31080_self_test_show(struct device *dev,
+static ssize_t rm_tch_self_test_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
@@ -1407,90 +1448,60 @@ static ssize_t rm31080_self_test_show(struct device *dev,
g_stTs.u8SelfTestResult);
}
-static ssize_t rm31080_self_test_store(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t count)
+static ssize_t rm_tch_self_test_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
{
- rm31080_self_test_handler(buf, count);
+ struct rm_tch_ts *ts = dev_get_drvdata(dev);
+ rm_tch_self_test_handler(ts, buf, count);
return count;
}
-static ssize_t rm31080_version_show(struct device *dev,
- struct device_attribute *attr,
- char *buf)
+static ssize_t rm_tch_version_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
{
- return sprintf(buf, "0x%02X\n", g_stTs.u8Version);
+ return sprintf(buf, "Release V 0x%02X, Test V 0x%02X\n", g_stTs.u8Version, g_stTs.u8TestVersion);
}
-static ssize_t rm31080_version_store(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t count)
+static ssize_t rm_tch_version_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
{
return count;
}
-static void rm31080_ctrl_registry(void)
+static ssize_t rm_tch_module_detect_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
{
- int i;
- unsigned char buf;
- if (g_stTs.u8ScanModeState == RM_SCAN_MODE_AUTO_SCAN)
- rm31080_ctrl_pause_auto_mode();
-
- for (i = 4; i < 128; i++) {
- rm31080_spi_byte_read(i, &buf);
- rm_printk("BANK0 %2xh = 0x%2x\n", i, buf);
- }
- rm31080_spi_byte_write(0x7F, 0x01);
- for (i = 0; i < 128; i++) {
- rm31080_spi_byte_read(i, &buf);
- rm_printk("BANK1 %2xh = 0x%2x\n", i, buf);
- }
- rm31080_spi_byte_write(0x7F, 0x00);
-
- if (g_stTs.u8ScanModeState == RM_SCAN_MODE_AUTO_SCAN) {
- rm31080_ctrl_enter_auto_mode();
- usleep_range(1000, 2000); /*msleep(1); */
- rm31080_ctrl_scan_start();
- }
+ return sprintf(buf, "%s\n", "Raydium Touch Module");
}
-static ssize_t rm31080_registry_show(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- mutex_lock(&g_stTs.mutex_scan_mode);
-
- rm31080_ctrl_registry();
-
- mutex_unlock(&g_stTs.mutex_scan_mode);
-
- return sprintf(buf, "Finish!\n");
-}
-
-static ssize_t rm31080_registry_store(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t count)
+static ssize_t rm_tch_module_detect_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
{
return count;
}
-static DEVICE_ATTR(slowscan_enable, 0640, rm31080_slowscan_show,
- rm31080_slowscan_store);
-static DEVICE_ATTR(smooth_level, 0640, rm31080_smooth_level_show,
- rm31080_smooth_level_store);
-static DEVICE_ATTR(self_test, 0640, rm31080_self_test_show,
- rm31080_self_test_store);
-static DEVICE_ATTR(version, 0640, rm31080_version_show,
- rm31080_version_store);
-static DEVICE_ATTR(registry, 0640, rm31080_registry_show,
- rm31080_registry_store);
+static DEVICE_ATTR(slowscan_enable, 0640, rm_tch_slowscan_show,
+ rm_tch_slowscan_store);
+static DEVICE_ATTR(smooth_level, 0640, rm_tch_smooth_level_show,
+ rm_tch_smooth_level_store);
+static DEVICE_ATTR(self_test, 0640, rm_tch_self_test_show,
+ rm_tch_self_test_store);
+static DEVICE_ATTR(version, 0640, rm_tch_version_show,
+ rm_tch_version_store);
+static DEVICE_ATTR(module_detect, 0640, rm_tch_module_detect_show,
+ rm_tch_module_detect_store);
static struct attribute *rm_ts_attributes[] = {
&dev_attr_slowscan_enable.attr,
&dev_attr_smooth_level.attr,
&dev_attr_self_test.attr,
&dev_attr_version.attr,
- &dev_attr_registry.attr,
+ &dev_attr_module_detect.attr,
NULL
};
@@ -1498,237 +1509,146 @@ static const struct attribute_group rm_ts_attr_group = {
.attrs = rm_ts_attributes,
};
-static int rm31080_input_open(struct input_dev *input)
+static int rm_tch_input_open(struct input_dev *input)
{
- struct rm31080_ts *ts = input_get_drvdata(input);
+ struct rm_tch_ts *ts = input_get_drvdata(input);
if (!ts->disabled && !ts->suspended)
- __rm31080_enable(ts);
+ rm_tch_enable_irq(ts);
return 0;
}
-static void rm31080_input_close(struct input_dev *input)
+static void rm_tch_input_close(struct input_dev *input)
{
- struct rm31080_ts *ts = input_get_drvdata(input);
+ struct rm_tch_ts *ts = input_get_drvdata(input);
if (!ts->disabled && !ts->suspended)
- __rm31080_disable(ts);
+ rm_tch_disable_irq(ts);
}
-/*=========================================================================*/
-static irqreturn_t rm31080_irq(int irq, void *handle)
+static irqreturn_t rm_tch_irq(int irq, void *handle)
{
- /*struct rm31080_ts *ts = handle; */
- if (!g_stTs.bInitFinish)
- return IRQ_HANDLED;
+ if (g_stTs.u32WatchDogTime == WDT_INIT_TIME)
+ g_stTs.u32WatchDogTime = WDT_NORMAL_TIME;
- trace_touchscreen_raydium_irq("Raydium_interrupt");
+ g_stTs.u32WatchDogCnt=0;
+ trace_touchscreen_raydium_irq("Raydium_interrupt");
#ifdef NV_ENABLE_CPU_BOOST
if (g_stCtrl.bfPowerMode &&
- (g_stTs.u8ScanModeState == RM_SCAN_MODE_AUTO_SCAN))
+ (g_stTs.u8ScanModeState == RM_SCAN_IDLE_MODE))
input_event(g_input_dev, EV_MSC, MSC_ACTIVITY, 1);
#endif
-#ifdef ENABLE_WORK_QUEUE
- queue_work(g_stTs.rm_workqueue, &g_stTs.rm_work);
-#endif
+ if (g_stTs.bInitFinish && g_stTs.bIsSuspended == false) {
+ queue_work(g_stTs.rm_workqueue, &g_stTs.rm_work);
+ } else {
+ rm_watchdog_enable(0);
+ }
return IRQ_HANDLED;
}
-/*==========================================================================*/
-static void rm31080_init_ts_structure_part(void)
+void rm_tch_set_autoscan(unsigned char val)
{
- g_stTs.bInitFinish = 0;
- g_stTs.bCalcFinish = 0;
- g_stTs.bEnableScriber = 0;
- g_stTs.bIsSuspended = 0;
- g_stTs.bEnableAutoScan = 1;
-
- g_stTs.bEnableSlowScan = false;
-
-#ifdef ENABLE_RAW_DATA_QUEUE
- g_stTs.u8ScanModeState = RM_SCAN_MODE_MANUAL;
-#endif
- rm31080_ctrl_init();
+ g_stTs.bEnableAutoScan = val;
}
-void rm31080_disable_touch(void)
+static void rm_tch_enter_test_mode(u8 flag)
{
- g_stTs.bInitFinish = 0;
-}
+ if (flag) { /*enter test mode*/
+ g_stTs.u8SelfTestStatus = RM_SELF_TEST_STATUS_TESTING;
+ g_stTs.bIsSuspended = true;
+ flush_workqueue(g_stTs.rm_workqueue);
+ flush_workqueue(g_stTs.rm_timer_workqueue);
+ } else {/*leave test mode*/
+ g_stTs.bIsSuspended = false;
+ rm_tch_init_ts_structure_part();
+ }
-void rm31080_enable_touch(void)
-{
- g_stTs.bInitFinish = 1;
-}
+ rm_tch_cmd_process(flag, g_stRmTestModeCmd, NULL);
+
+ if (!flag)
+ g_stTs.u8SelfTestStatus = RM_SELF_TEST_STATUS_FINISH;
-void rm31080_set_autoscan(unsigned char val)
-{
- g_stTs.bEnableAutoScan = val;
}
-void rm31080_set_variable(unsigned int index, unsigned int arg)
+void rm_tch_set_variable(unsigned int index, unsigned int arg)
{
switch (index) {
- case RM_VARIABLE_SELF_TEST_RESULT:
- g_stTs.u8SelfTestResult = (u8) arg;
- g_stTs.u8SelfTestStatus = RM_SELF_TEST_STATUS_FINISH;
- break;
- case RM_VARIABLE_SCRIBER_FLAG:
- g_stTs.bEnableScriber = (bool) arg;
- break;
- case RM_VARIABLE_AUTOSCAN_FLAG:
- g_stTs.bEnableAutoScan = (bool) arg;
- break;
- case RM_VARIABLE_VERSION:
- g_stTs.u8Version = (u8) arg;
- dev_info(&g_spi->dev, "Raydium TS:Firmware v%d\n",
- g_stTs.u8Version);
- break;
- case RM_VARIABLE_IDLEMODECHECK:
- g_stCtrl.bfIdleModeCheck = (u8) arg;
- if (g_stCtrl.bfIdleMessage)
- rm_printk(
- "## Raydium debug: bfIdleModeCheck %2x\n", arg);
- break;
- case RM_VARIABLE_REPEAT:
- rm_printk("Repeat %d\n", arg);
- g_stTs.u8Repeat = (u8) arg;
- break;
- default:
- break;
+ case RM_VARIABLE_SELF_TEST_RESULT:
+ g_stTs.u8SelfTestResult = (u8) arg;
+ rm_tch_enter_test_mode(0);
+ break;
+ case RM_VARIABLE_SCRIBER_FLAG:
+ g_stTs.bEnableScriber = (bool) arg;
+ break;
+ case RM_VARIABLE_AUTOSCAN_FLAG:
+ g_stTs.bEnableAutoScan = (bool) arg;
+ break;
+ case RM_VARIABLE_TEST_VERSION:
+ g_stTs.u8TestVersion = (u8) arg;
+ break;
+ case RM_VARIABLE_VERSION:
+ g_stTs.u8Version = (u8) arg;
+ dev_info(&g_spi->dev,"Raydium TS:Firmware v%d.%d\n",
+ g_stTs.u8Version, g_stTs.u8TestVersion);
+ break;
+ case RM_VARIABLE_IDLEMODECHECK:
+ g_stCtrl.bfIdleModeCheck = (u8) arg;
+ if ((g_stCtrl.bDebugMessage & DEBUG_DRIVER) == DEBUG_DRIVER)
+ rm_printk("Raydium debug: bfIdleModeCheck %2x\n", arg);
+ break;
+ case RM_VARIABLE_REPEAT:
+ /*rm_printk("Repeat %d\n", arg);*/
+ g_stTs.u8Repeat = (u8) arg;
+ case RM_VARIABLE_WATCHDOG_FLAG:
+ rm_watchdog_enable((u8) arg);
+ break;
+ default:
+ break;
}
}
-
-static u32 rm31080_get_variable(unsigned int index, unsigned int arg)
+static u32 rm_tch_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;
+ case RM_VARIABLE_PLATFORM_ID:
+ ret = rm_tch_get_platform_id((u8 *) arg);
+ break;
+ default:
+ break;
}
-
return ret;
}
-static void rm31080_init_ts_structure(void)
+static void rm_tch_init_ts_structure(void)
{
g_stTs.ulHalPID = 0;
memset(&g_stTs, 0, sizeof(struct rm31080a_ts_para));
#ifdef ENABLE_SLOW_SCAN
- rm31080_slow_scan_init();
- g_stTs.u32SlowScanLevel = RM_SLOW_SCAN_LEVEL_140;
+ g_stTs.u32SlowScanLevel = RM_SLOW_SCAN_LEVEL_MAX;
#endif
-#ifdef ENABLE_WORK_QUEUE
g_stTs.rm_workqueue = create_singlethread_workqueue("rm_work");
INIT_WORK(&g_stTs.rm_work, rm_work_handler);
-#endif
-
- g_stTs.bInitStartFlag = 0;
- g_stTs.bInitFailFlag = 0;
- g_stTs.bReissueSignalFlag = 0;
-
- mutex_init(&g_stTs.mutex_scan_mode);
-}
-
-/*=========================================================================*/
-#ifdef ENABLE_SPI_SETTING
-static int rm31080_spi_setting(u32 speed)
-{
- int err;
- if ((speed == 0) || (speed > 18))
- return false;
-
- g_spi->max_speed_hz = speed * 1000 * 1000;
- err = spi_setup(g_spi);
- if (err) {
- dev_dbg(&g_spi->dev, "Change SPI setting failed\n");
- return false;
- }
- return true;
-}
-#endif
-/*=========================================================================*/
-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;
- 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);
- }
- }
- rbuf[0] = wbuf[0] | 0x80; /*address */
- iLen = sizeof(wbuf) - 1;
- 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); */
- rm31080_spi_read(rbuf[0], &rbuf[1], iLen);
-
- /*compare */
- iFail = 0;
- for (i = 1; i < iLen + 1; i++) {
- if (wbuf[i] != rbuf[i]) {
- iFail = 1;
- break;
- }
- }
+ g_stTs.rm_timer_workqueue = create_singlethread_workqueue("rm_idle_work");
+ INIT_WORK(&g_stTs.rm_timer_work, rm_timer_work_handler);
- 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++) {
- rm_printk("[%02d]Write Data:0x%02x,", i,
- wbuf[i]);
- rm_printk("Read Data:0x%02x\n", rbuf[i]);
- }
- msleep(300);
- } else {
- iTestCount++;
- if ((iTestCount % 10000) == 0) {
- rm_printk("SPI test:%d times ok.", iTestCount);
- rm_printk("(Speed:%d hz,Mode:%x)\n",
- g_spi->max_speed_hz, g_spi->mode);
- }
- }
- } while (bInfinite);
+ wake_lock_init(&g_stTs.Wakelock_Initialization,
+ WAKE_LOCK_SUSPEND, "TouchInitialLock");
- if (!iFail) {
- if (wbuf[0] == 0x6E) {
- var = 0x00;
- rm31080_spi_byte_write(RM31080_REG_7F, var);
- }
- rm_printk("Raydium SPI Checking: ok\n");
- }
-
- return !iFail;
+ mutex_init(&g_stTs.mutex_scan_mode);
}
-
static int rm31080_voltage_notifier_1v8(struct notifier_block *nb,
unsigned long event, void *ignored)
{
int error;
- struct rm31080_ts *ts = input_get_drvdata(g_input_dev);
+ struct rm_tch_ts *ts = input_get_drvdata(g_input_dev);
rm_printk("rm31080 REGULATOR EVENT:0x%x\n", (unsigned int)event);
@@ -1752,7 +1672,7 @@ static int rm31080_voltage_notifier_1v8(struct notifier_block *nb,
static int rm31080_voltage_notifier_3v3(struct notifier_block *nb,
unsigned long event, void *ignored)
{
- struct rm31080_ts *ts;
+ struct rm_tch_ts *ts;
ts = input_get_drvdata(g_input_dev);
@@ -1760,138 +1680,90 @@ static int rm31080_voltage_notifier_3v3(struct notifier_block *nb,
return NOTIFY_OK;
}
-
-/*=========================================================================*/
-static void rm31080_start(struct rm31080_ts *ts)
-{ /* handle touch resume */
- int error;
- struct rm_spi_ts_platform_data *pdata;
- if (!g_stTs.bIsSuspended)
+/*=============================================================================*/
+static void rm_ctrl_start(struct rm_tch_ts *ts)
+{
+ if (g_stTs.bIsSuspended == false)
return;
g_stTs.bIsSuspended = false;
mutex_lock(&g_stTs.mutex_scan_mode);
-#ifdef ENABLE_RM31080_DEEP_SLEEP
- /* 1. enable (1.8v) */
- if (ts->regulator_1v8) {
- error = regulator_enable(ts->regulator_1v8);
- if (error < 0)
- dev_err(&g_spi->dev,
- "raydium regulator 1.8V enable failed: %d\n",
- error);
- }
- /* handle all platforms w/ and w/out regulator switches */
- /* 4. delay for platforms with load switches */
- usleep_range(15000, 20000);
- /* 5. enable clock */
- if (ts->clk)
- clk_enable(ts->clk);
- /* 6. reset */
- pdata = g_input_dev->dev.parent->platform_data;
- if (pdata->platform_id == RM_PLATFORM_P005) {
- gpio_set_value(pdata->gpio_reset, 0);
- usleep_range(200, 300);
- gpio_set_value(pdata->gpio_reset, 1);
- } else { /* sw reset */
- usleep_range(15000, 20000);
- rm31080_spi_byte_write(RM31080_REG_11, 0x04);
- usleep_range(200, 300);
- rm31080_spi_byte_write(RM31080_REG_11, 0x00);
- }
- /* 7. delay */
- msleep(20);
+ rm_tch_init_ts_structure_part();
- rm31080_init_ts_structure_part();
+ rm_tch_cmd_process(0, g_stRmStartCmd, ts);
- if (g_stTs.bInitStartFlag) {
- if (!g_stTs.bReissueSignalFlag) {
- printk(KERN_ALERT "Raydium Re-Sending RESUME done\n");
- rm31080_ts_send_signal(g_stTs.ulHalPID,
- RM_SIGNAL_RESUME);
- g_stTs.bReissueSignalFlag = 1;
- }
- } else {
- printk(KERN_ALERT "Raydium Sending RESUME done\n");
- rm31080_ts_send_signal(g_stTs.ulHalPID, RM_SIGNAL_RESUME);
- }
-#elif defined(ENABLE_AUTO_SCAN)
- rm31080_ctrl_clear_int();
- rm31080_ctrl_scan_start();
-#endif
mutex_unlock(&g_stTs.mutex_scan_mode);
}
-static void rm31080_stop(struct rm31080_ts *ts)
+static void rm_ctrl_stop(struct rm_tch_ts *ts)
{
- if (g_stTs.bIsSuspended)
+ if (g_stTs.bIsSuspended == true)
return;
g_stTs.bIsSuspended = true;
+ g_stTs.bInitFinish = 0;
- flush_workqueue(g_stTs.rm_workqueue);
+ mutex_lock(&g_stTs.mutex_scan_mode);
-#ifdef ENABLE_RM31080_DEEP_SLEEP
- rm31080_ctrl_suspend(ts);
-#endif
+ rm_tch_cmd_process(0, g_stRmEndCmd, ts);
+
+ printk(KERN_ALERT "Raydium Sending SUSPEND done\n");
+
+ mutex_unlock(&g_stTs.mutex_scan_mode);
}
#ifdef CONFIG_PM
-static int rm31080_suspend(struct device *dev)
+static int rm_tch_suspend(struct device *dev)
{
- struct rm31080_ts *ts = dev_get_drvdata(dev);
- rm31080_stop(ts);
+ struct rm_tch_ts *ts = dev_get_drvdata(dev);
+ rm_ctrl_stop(ts);
return 0;
}
-static int rm31080_resume(struct device *dev)
+static int rm_tch_resume(struct device *dev)
{
- struct rm31080_ts *ts = dev_get_drvdata(dev);
- rm31080_start(ts);
+ struct rm_tch_ts *ts = dev_get_drvdata(dev);
+ wake_lock_timeout(&g_stTs.Wakelock_Initialization,
+ TCH_WAKE_LOCK_TIMEOUT);
+ rm_ctrl_start(ts);
return 0;
}
-
-static const struct dev_pm_ops rm31080_pm_ops = {
- .suspend = rm31080_suspend,
- .resume = rm31080_resume,
-};
-
-#endif /*CONFIG_PM */
-
-/* NVIDIA 20121026*/
-#ifdef ENABLE_NEW_INPUT_DEV
-static int rm31080_input_enable(struct input_dev *in_dev)
+#if defined(CONFIG_HAS_EARLYSUSPEND)
+static void rm_tch_early_suspend(struct early_suspend *es)
{
- int error = 0;
+ struct rm_tch_ts *ts;
+ struct device *dev;
-#ifdef CONFIG_PM
- struct rm31080_ts *ts = input_get_drvdata(in_dev);
+ ts = container_of(es, struct rm_tch_ts, early_suspend);
+ dev = ts->dev;
- error = rm31080_resume(ts->dev);
- if (error)
- dev_err(ts->dev, "%s: failed\n", __func__);
-#endif
-
- return error;
+ if (rm_tch_suspend(dev) != 0) {
+ dev_err(dev, "%s: failed\n", __func__);
+ }
}
-static int rm31080_input_disable(struct input_dev *in_dev)
+static void rm_tch_early_resume(struct early_suspend *es)
{
- int error = 0;
+ struct rm_tch_ts *ts;
+ struct device *dev;
-#ifdef CONFIG_PM
- struct rm31080_ts *ts = input_get_drvdata(in_dev);
+ ts = container_of(es, struct rm_tch_ts, early_suspend);
+ dev = ts->dev;
- error = rm31080_suspend(ts->dev);
- if (error)
- dev_err(ts->dev, "%s: failed\n", __func__);
-#endif
-
- return error;
+ if (rm_tch_resume(dev) != 0) {
+ dev_err(dev, "%s: failed\n", __func__);
+ }
}
-#endif /*ENABLE_NEW_INPUT_DEV */
+#else
+static const struct dev_pm_ops rm_tch_pm_ops = {
+ .suspend = rm_tch_suspend,
+ .resume = rm_tch_resume,
+};
+#endif /*CONFIG_HAS_EARLYSUSPEND*/
+#endif /*CONFIG_PM*/
-static void rm31080_set_input_resolution(unsigned int x, unsigned int y)
+static void rm_tch_set_input_resolution(unsigned int x, unsigned int y)
{
input_set_abs_params(g_input_dev, ABS_X, 0, x - 1, 0, 0);
input_set_abs_params(g_input_dev, ABS_Y, 0, y - 1, 0, 0);
@@ -1899,11 +1771,10 @@ static void rm31080_set_input_resolution(unsigned int x, unsigned int y)
input_set_abs_params(g_input_dev, ABS_MT_POSITION_Y, 0, y - 1, 0, 0);
}
-struct rm31080_ts *rm31080_input_init(struct device *dev, unsigned int irq,
- const struct rm31080_bus_ops *bops)
-{
+struct rm_tch_ts *rm_tch_input_init(struct device *dev, unsigned int irq,
+ const struct rm_tch_bus_ops *bops) {
- struct rm31080_ts *ts;
+ struct rm_tch_ts *ts;
struct input_dev *input_dev;
struct rm_spi_ts_platform_data *pdata;
int err;
@@ -1951,13 +1822,8 @@ struct rm31080_ts *rm31080_input_init(struct device *dev, unsigned int irq,
input_dev->dev.parent = dev;
input_dev->id.bustype = bops->bustype;
- input_dev->open = rm31080_input_open;
- input_dev->close = rm31080_input_close;
-#ifdef ENABLE_NEW_INPUT_DEV
- input_dev->enable = rm31080_input_enable;
- input_dev->disable = rm31080_input_disable;
- input_dev->enabled = true;
-#endif
+ input_dev->open = rm_tch_input_open;
+ input_dev->close = rm_tch_input_close;
input_dev->hint_events_per_packet = 256U;
input_set_drvdata(input_dev, ts);
@@ -1970,22 +1836,28 @@ struct rm31080_ts *rm31080_input_init(struct device *dev, unsigned int irq,
__set_bit(EV_KEY, input_dev->evbit);
__set_bit(BTN_TOUCH, input_dev->keybit);
- rm31080_set_input_resolution(RM_INPUT_RESOLUTION_X,
- RM_INPUT_RESOLUTION_Y);
+ rm_tch_set_input_resolution(RM_INPUT_RESOLUTION_X,
+ 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);
+ err = request_threaded_irq(ts->irq, NULL, rm_tch_irq,
+ 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 = rm_tch_early_suspend;
+ ts->early_suspend.resume = rm_tch_early_resume;
+ register_early_suspend(&ts->early_suspend);
+#endif
- __rm31080_disable(ts);
+ rm_tch_disable_irq(ts);
err = sysfs_create_group(&dev->kobj, &rm_ts_attr_group);
if (err)
@@ -2016,7 +1888,7 @@ static int dev_open(struct inode *inode, struct file *filp)
static int dev_release(struct inode *inode, struct file *filp)
{
g_stTs.bInitFinish = 0;
- rm31080_enter_manual_mode();
+ rm_tch_enter_manual_mode();
return 0;
}
@@ -2032,7 +1904,7 @@ dev_read(struct file *filp, char __user *buf, size_t count, loff_t *pos)
return -ENOMEM;
pMyBuf[0] = buf[0];
- ret = rm31080_spi_read(pMyBuf[0], pMyBuf, count);
+ ret = rm_tch_spi_read(pMyBuf[0], pMyBuf, count);
if (ret) {
status = count;
@@ -2044,7 +1916,7 @@ dev_read(struct file *filp, char __user *buf, size_t count, loff_t *pos)
status = status - missing;
} else {
status = -EFAULT;
- rmd_printk("rm31080_spi_read() fail\n");
+ rm_printk("rm_tch_spi_read() fail\n");
}
kfree(pMyBuf);
@@ -2053,7 +1925,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;
@@ -2066,7 +1938,7 @@ dev_write(struct file *filp, const char __user *buf,
missing = copy_from_user(pMyBuf, buf, count);
if (missing == 0) {
- ret = rm31080_spi_write(pMyBuf, count);
+ ret = rm_tch_spi_write(pMyBuf, count);
if (ret)
status = count;
else
@@ -2078,105 +1950,85 @@ dev_write(struct file *filp, const char __user *buf,
return status;
}
-/*==============================================================================
- * Description:
- * I/O Control routine.
- * Input:
- * file:
- * cmd :
- * arg :
- * Output:
- * 1: succeed
- * 0: failed
- * Note: To avoid context switch,
- * please don't add debug message in this function.
- *==============================================================================
- */
+/*=============================================================================
+ Description:
+ I/O Control routin.
+ Input:
+ file:
+ cmd :
+ arg :
+ Output:
+ 1: succeed
+ 0: failed
+ Note: To avoid context switch,please don't add debug message in this function.
+=============================================================================*/
static long dev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
long ret = true;
unsigned int index;
index = (cmd >> 16) & 0xFFFF;
switch (cmd & 0xFFFF) {
- case RM_IOCTL_REPORT_POINT:
- raydium_report_pointer((void *)arg);
- break;
- case RM_IOCTL_SET_HAL_PID:
- g_stTs.ulHalPID = arg;
- break;
- case RM_IOCTL_INIT_START:
- g_stTs.bInitFinish = 0;
- g_stTs.bInitStartFlag = 1;
- printk(KERN_ALERT "Raydium Received RM_IOCTL_INIT_START.");
- printk(KERN_ALERT " Touch not ready, ScanModeState = 0x%x\n",
- g_stTs.u8ScanModeState);
- rm31080_enter_manual_mode();
- break;
- case RM_IOCTL_INIT_END:
- printk(KERN_ALERT "Raydium Received RM_IOCTL_INIT_END");
- printk(KERN_ALERT " Touch ready.\n");
- g_stTs.bInitFinish = 1;
- g_stTs.bCalcFinish = 1;
- g_stTs.bInitStartFlag = 0;
- g_stTs.bReissueSignalFlag = 0;
-#ifdef ENABLE_RAW_DATA_QUEUE
- ret = rm31080_ctrl_scan_start();
-#endif
- break;
- case RM_IOCTL_FINISH_CALC:
- g_stTs.bCalcFinish = 1;
- break;
- case RM_IOCTL_SCRIBER_CTRL:
- g_stTs.bEnableScriber = (bool) arg;
- break;
- case RM_IOCTL_AUTOSCAN_CTRL:
- g_stTs.bEnableAutoScan = (bool) arg;
- break;
-#ifdef ENABLE_RAW_DATA_QUEUE
- case RM_IOCTL_READ_RAW_DATA:
- ret = rm31080_queue_read_raw_data((u8 *) arg, index);
- break;
-#endif
- case RM_IOCTL_NOISE_CHECK:
- ret = rm31080_ctrl_get_noise_mode((u8 *) arg);
- break;
- case RM_IOCTL_GET_PARAMETER:
- rm31080_ctrl_get_parameter((void *)arg);
- rm31080_set_input_resolution(g_stCtrl.u16ResolutionX,
- g_stCtrl.u16ResolutionY);
- break;
- case RM_IOCTL_SET_PARAMETER:
- ret = rm31080_get_config((u8 *) arg, index);
- break;
- case RM_IOCTL_SEND_BASELINE: /* Noise_Detector */
- break;
- case RM_IOCTL_SET_VARIABLE:
- rm31080_set_variable(index, arg);
- break;
-
- case RM_IOCTL_GET_VARIABLE:
- ret = rm31080_get_variable(index, arg);
- break;
-#ifdef ENABLE_SLOW_SCAN
- case RM_IOCTL_SET_SLOWSCAN_PARA:
- rm31080_set_slowscan_para((u8 *) arg, index);
- break;
-#endif
- case RM_IOCTL_GET_SACN_MODE:
- rm31080_ctrl_get_idle_mode((u8 *) arg);
- break;
- case RM_IOCTL_CHECK_INIT_STATUS:
- ret = g_stTs.bInitFailFlag;
- g_stTs.bInitFailFlag = 0;
- break;
-
- default:
- break;
+ case RM_IOCTL_REPORT_POINT:
+ raydium_report_pointer((void *)arg);
+ break;
+ case RM_IOCTL_SET_HAL_PID:
+ g_stTs.ulHalPID = arg;
+ break;
+ case RM_IOCTL_INIT_START:
+ g_stTs.bInitFinish = 0;
+ rm_tch_enter_manual_mode();
+ break;
+ case RM_IOCTL_INIT_END:
+ g_stTs.bInitFinish = 1;
+ g_stTs.bCalcFinish = 1;
+ if (wake_lock_active(&g_stTs.Wakelock_Initialization))
+ wake_unlock(&g_stTs.Wakelock_Initialization);
+ ret = rm_tch_ctrl_scan_start();
+ break;
+ case RM_IOCTL_FINISH_CALC:
+ g_stTs.bCalcFinish = 1;
+ break;
+ case RM_IOCTL_SCRIBER_CTRL:
+ g_stTs.bEnableScriber = (bool) arg;
+ break;
+ case RM_IOCTL_AUTOSCAN_CTRL:
+ g_stTs.bEnableAutoScan = (bool) arg;
+ break;
+ case RM_IOCTL_READ_RAW_DATA:
+ ret = rm_tch_queue_read_raw_data((u8 *) arg, index);
+ break;
+ case RM_IOCTL_NOISE_CHECK:
+ ret = rm_tch_ctrl_get_noise_mode((u8 *) arg);
+ break;
+ case RM_IOCTL_GET_PARAMETER:
+ rm_tch_ctrl_get_parameter((void *)arg);
+
+ rm_tch_set_input_resolution(g_stCtrl.u16ResolutionX,
+ g_stCtrl.u16ResolutionY);
+ break;
+ case RM_IOCTL_SET_VARIABLE:
+ rm_tch_set_variable(index, arg);
+ break;
+ case RM_IOCTL_GET_SACN_MODE:
+ rm_tch_ctrl_get_idle_mode((u8 *) arg);
+ break;
+ case RM_IOCTL_GET_VARIABLE:
+ ret = rm_tch_get_variable(index, arg);
+ break;
+ case RM_IOCTL_SET_KRL_TBL:
+ rm_set_kernel_tbl(index, (u8 *)arg);
+ break;
+ case RM_IOCTL_WATCH_DOG:
+ g_stTs.u8WatchDogFlg = 1;
+ g_stTs.u8WatchDogCheck=0;
+ break;
+ default:
+ break;
}
return ret;
}
-static const struct file_operations dev_fops = {
+static struct file_operations dev_fops = {
.owner = THIS_MODULE,
.open = dev_open,
.release = dev_release,
@@ -2191,21 +2043,80 @@ static struct miscdevice raydium_ts_miscdev = {
.fops = &dev_fops,
};
-static const struct rm31080_bus_ops rm31080_spi_bus_ops = {
+static const struct rm_tch_bus_ops rm_tch_spi_bus_ops = {
.bustype = BUS_SPI,
};
-static int rm31080_misc_init(void)
+static void init_ts_timer(void)
+{
+ init_timer(&ts_timer_triggle);
+ ts_timer_triggle.function = ts_timer_triggle_function;
+ ts_timer_triggle.data = ((unsigned long) 0);
+ ts_timer_triggle.expires = jiffies + TS_TIMER_PERIOD;
+}
+static void ts_timer_triggle_function(unsigned long option)
+{
+ queue_work(g_stTs.rm_timer_workqueue, &g_stTs.rm_timer_work);
+ ts_timer_triggle.expires = jiffies + TS_TIMER_PERIOD;
+ add_timer(&ts_timer_triggle);
+}
+
+/*=============================================================================*/
+#if ENABLE_SPI_SETTING
+static int rm_tch_spi_setting(u32 speed)
{
int err;
- err = sysfs_create_group(&raydium_ts_miscdev.this_device->kobj,
- &rm_ts_attr_group);
- if (err)
- return false;
- return true;
+ if ((speed == 0) || (speed > 18))
+ return FAIL;
+
+ g_spi->max_speed_hz = speed * 1000 * 1000;
+ err = spi_setup(g_spi);
+ if (err) {
+ dev_dbg(&g_spi->dev, "Change SPI setting failed\n");
+ return FAIL;
+ }
+ return OK;
+}
+#endif
+
+static int __devexit rm_tch_spi_remove(struct spi_device *spi)
+{
+ struct rm_tch_ts *ts = spi_get_drvdata(spi);
+ del_timer(&ts_timer_triggle);
+ if (g_stTs.rm_timer_workqueue)
+ destroy_workqueue(g_stTs.rm_timer_workqueue);
+
+ rm_tch_queue_free();
+
+ if (g_stTs.rm_workqueue)
+ destroy_workqueue(g_stTs.rm_workqueue);
+
+ if (&g_stTs.Wakelock_Initialization)
+ wake_lock_destroy(&g_stTs.Wakelock_Initialization);
+
+ sysfs_remove_group(&raydium_ts_miscdev.this_device->kobj,
+ &rm_ts_attr_group);
+ misc_deregister(&raydium_ts_miscdev);
+ sysfs_remove_group(&ts->dev->kobj, &rm_ts_attr_group);
+ free_irq(ts->irq, ts);
+ input_unregister_device(ts->input);
+
+ if (ts->regulator_3v3 && ts->regulator_1v8) {
+ regulator_unregister_notifier(ts->regulator_3v3, &ts->nb_3v3);
+ regulator_unregister_notifier(ts->regulator_1v8, &ts->nb_1v8);
+ regulator_disable(ts->regulator_3v3);
+ regulator_disable(ts->regulator_1v8);
+ }
+
+ if (ts->clk)
+ clk_disable(ts->clk);
+
+ kfree(ts);
+ spi_set_drvdata(spi, NULL);
+ return 0;
}
-static void rm31080_init_regulator(struct rm31080_ts *ts)
+static int rm_tch_regulator_init(struct rm_tch_ts *ts)
{
int error;
@@ -2252,7 +2163,7 @@ static void rm31080_init_regulator(struct rm31080_ts *ts)
goto err_unregister_notifier;
}
- return;
+ return 0;
err_unregister_notifier:
regulator_unregister_notifier(ts->regulator_1v8, &ts->nb_1v8);
@@ -2262,54 +2173,39 @@ err_disable_regulator:
err_null_regulator:
ts->regulator_3v3 = NULL;
ts->regulator_1v8 = NULL;
+ return 1;
}
-static int __devexit rm31080_spi_remove(struct spi_device *spi)
-{
- struct rm31080_ts *ts = spi_get_drvdata(spi);
-
-#ifdef ENABLE_RAW_DATA_QUEUE
- rm31080_queue_free();
-#endif
-
-#ifdef ENABLE_WORK_QUEUE
- if (g_stTs.rm_workqueue)
- destroy_workqueue(g_stTs.rm_workqueue);
-#endif
- sysfs_remove_group(&raydium_ts_miscdev.this_device->kobj,
- &rm_ts_attr_group);
- misc_deregister(&raydium_ts_miscdev);
- sysfs_remove_group(&ts->dev->kobj, &rm_ts_attr_group);
- free_irq(ts->irq, ts);
- input_unregister_device(ts->input);
- if (ts->regulator_3v3 && ts->regulator_1v8) {
- regulator_unregister_notifier(ts->regulator_3v3, &ts->nb_3v3);
- regulator_unregister_notifier(ts->regulator_1v8, &ts->nb_1v8);
- regulator_disable(ts->regulator_3v3);
- regulator_disable(ts->regulator_1v8);
- }
- if (ts->clk)
- clk_disable(ts->clk);
- kfree(ts);
- spi_set_drvdata(spi, NULL);
- return 0;
-}
-
-static int __devinit rm31080_spi_probe(struct spi_device *spi)
+static int __devinit rm_tch_spi_probe(struct spi_device *spi)
{
- struct rm31080_ts *ts;
+ struct rm_tch_ts *ts;
struct rm_spi_ts_platform_data *pdata;
+ int ret;
g_spi = spi;
- rm31080_init_ts_structure();
+ rm_tch_init_ts_structure();
+ rm_tch_init_ts_structure_part();
+
+ if (spi->max_speed_hz > MAX_SPI_FREQ_HZ) {
+ dev_err(&spi->dev, "SPI CLK %d Hz?\n", spi->max_speed_hz);
+ ret = -EINVAL;
+ goto err_spi_speed;
+ }
+ ts = rm_tch_input_init(&spi->dev, spi->irq, &rm_tch_spi_bus_ops);
+ if (IS_ERR(ts)) {
+ dev_err(&spi->dev, "Raydium TS: Input Device Initialization Fail!\n");
+ ret = PTR_ERR(ts);
+ goto err_spi_speed;
+ }
- ts = rm31080_input_init(&spi->dev, spi->irq, &rm31080_spi_bus_ops);
- if (IS_ERR(ts))
- return PTR_ERR(ts);
spi_set_drvdata(spi, ts);
- rm31080_init_regulator(ts);
+ if (rm_tch_regulator_init(ts)) {
+ dev_err(&spi->dev, "Raydium TS: regulator Initialization Fail!\n");
+ ret = -EINVAL;
+ goto err_regulator_init;
+ }
pdata = g_input_dev->dev.parent->platform_data;
usleep_range(5000, 6000);
@@ -2321,36 +2217,36 @@ static int __devinit rm31080_spi_probe(struct spi_device *spi)
gpio_set_value(pdata->gpio_reset, 1);
msleep(20);
- if (spi->max_speed_hz > MAX_SPI_FREQ_HZ) {
- dev_err(&spi->dev, "SPI CLK %d Hz?\n", spi->max_speed_hz);
- goto err_free;
+ ret = misc_register(&raydium_ts_miscdev);
+ if ( ret != 0) {
+ dev_err(&spi->dev, "Raydium TS: cannot register miscdev: %d \n", ret);
+ goto err_misc_reg;
}
-
- rm31080_init_ts_structure_part();
-
- if (!rm31080_spi_checking(0))
- goto err_free;
-
- if (misc_register(&raydium_ts_miscdev) != 0) {
- dev_err(&spi->dev, "Raydium TS: cannot register miscdev\n");
- kfree(ts);
- return 0;
+ ret = sysfs_create_group(&raydium_ts_miscdev.this_device->kobj,
+ &rm_ts_attr_group);
+ if ( ret != 0) {
+ dev_err(&spi->dev, "Raydium TS: cannot create group: %d \n", ret );
+ goto err_create_sysfs;
}
- rm31080_misc_init();
-#ifdef ENABLE_RAW_DATA_QUEUE
- rm31080_queue_init();
-#endif
+ ret = rm_tch_queue_init();
+ if ( ret != 0) {
+ dev_err(&spi->dev, "Raydium TS: could not init queue: %d \n", ret );
+ goto err_queue_init;
+ }
- /* Enable async suspend/resume to reduce LP0 latency */
- device_enable_async_suspend(&spi->dev);
+ init_ts_timer();
+ add_timer(&ts_timer_triggle);
+ rm_printk("Raydium Spi Probe Done!!\n");
return 0;
-err_free:
- sysfs_remove_group(&ts->dev->kobj, &rm_ts_attr_group);
- free_irq(ts->irq, ts);
- input_unregister_device(ts->input);
+err_queue_init:
+ sysfs_remove_group(&raydium_ts_miscdev.this_device->kobj,
+ &rm_ts_attr_group);
+err_create_sysfs:
+ misc_deregister(&raydium_ts_miscdev);
+err_misc_reg:
if (ts->regulator_3v3 && ts->regulator_1v8) {
regulator_unregister_notifier(ts->regulator_3v3, &ts->nb_3v3);
regulator_unregister_notifier(ts->regulator_1v8, &ts->nb_1v8);
@@ -2359,37 +2255,53 @@ err_free:
}
if (ts->clk)
clk_disable(ts->clk);
- kfree(ts);
+err_regulator_init:
spi_set_drvdata(spi, NULL);
- return -EINVAL;
+ input_unregister_device(ts->input);
+ sysfs_remove_group(&ts->dev->kobj, &rm_ts_attr_group);
+#if defined(CONFIG_HAS_EARLYSUSPEND)
+ unregister_early_suspend(&ts->early_suspend);
+#endif
+ mutex_destroy(&ts->access_mutex);
+ free_irq(ts->irq, ts);
+ input_free_device(g_input_dev);
+ kfree(ts);
+err_spi_speed:
+ if (g_stTs.rm_timer_workqueue)
+ destroy_workqueue(g_stTs.rm_timer_workqueue);
+ if (g_stTs.rm_workqueue)
+ destroy_workqueue(g_stTs.rm_workqueue);
+ mutex_destroy(&g_stTs.mutex_scan_mode);
+ return ret;
}
-static struct spi_driver rm31080_spi_driver = {
+static struct spi_driver rm_tch_spi_driver = {
.driver = {
- .name = "rm_ts_spidev",
- .bus = &spi_bus_type,
- .owner = THIS_MODULE,
-
+ .name = "rm_ts_spidev",
+ .bus = &spi_bus_type,
+ .owner = THIS_MODULE,
+#if !defined(CONFIG_HAS_EARLYSUSPEND)
#if defined(CONFIG_PM)
- .pm = &rm31080_pm_ops,
+ .pm = &rm_tch_pm_ops,
+#endif
#endif
- },
- .probe = rm31080_spi_probe,
- .remove = __devexit_p(rm31080_spi_remove),
+ },
+ .probe = rm_tch_spi_probe,
+ .remove = __devexit_p(rm_tch_spi_remove),
};
-static int __init rm31080_spi_init(void)
+static int __init rm_tch_spi_init(void)
{
- return spi_register_driver(&rm31080_spi_driver);
+ return spi_register_driver(&rm_tch_spi_driver);
}
-static void __exit rm31080_spi_exit(void)
+static void __exit rm_tch_spi_exit(void)
{
- spi_unregister_driver(&rm31080_spi_driver);
+ spi_unregister_driver(&rm_tch_spi_driver);
}
-module_init(rm31080_spi_init);
-module_exit(rm31080_spi_exit);
+module_init(rm_tch_spi_init);
+module_exit(rm_tch_spi_exit);
MODULE_AUTHOR("Valentine Hsu <valentine.hsu@rad-ic.com>");
MODULE_DESCRIPTION("Raydium touchscreen SPI bus driver");
diff --git a/include/linux/spi/rm31080a_ctrl.h b/include/linux/spi/rm31080a_ctrl.h
index 61987aabf8af..2f47cfd04f2a 100644
--- a/include/linux/spi/rm31080a_ctrl.h
+++ b/include/linux/spi/rm31080a_ctrl.h
@@ -1,22 +1,22 @@
#ifndef _RM31080A_CTRL_H_
#define _RM31080A_CTRL_H_
-#define RM31080_REG_01 0x01
-#define RM31080_REG_02 0x02
-#define RM31080_REG_09 0x09
-#define RM31080_REG_0E 0x0E
-#define RM31080_REG_10 0x10
-#define RM31080_REG_11 0x11
-#define RM31080_REG_1F 0x1F
-#define RM31080_REG_2F 0x2F
-#define RM31080_REG_40 0x40
-#define RM31080_REG_41 0x41
-#define RM31080_REG_42 0x42
-#define RM31080_REG_43 0x43
-#define RM31080_REG_80 0x80
-#define RM31080_REG_F2 0xF2
-#define RM31080_REG_7E 0x7E
-#define RM31080_REG_7F 0x7F
+#define RM31080_REG_01 0x01
+#define RM31080_REG_02 0x02
+#define RM31080_REG_09 0x09
+#define RM31080_REG_0E 0x0E
+#define RM31080_REG_10 0x10
+#define RM31080_REG_11 0x11
+#define RM31080_REG_1F 0x1F
+#define RM31080_REG_2F 0x2F
+#define RM31080_REG_40 0x40
+#define RM31080_REG_41 0x41
+#define RM31080_REG_42 0x42
+#define RM31080_REG_43 0x43
+#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
@@ -26,87 +26,72 @@
#define RM31080B1_REG_BANK0_0EH 0x0E
#define RM31080B1_REG_BANK0_11H 0x11
+typedef enum {
+ ND_NORMAL = 0,
+ ND_DETECTOR_OFF,
+ ND_BASELINE_NOT_READY,
+ ND_NOISE_DETECTED,
+ ND_LEAVE_NOISE_MODE
+} NOISE_DETECTOR_RET_t;
-/* Tchreg.h */
-/* Adaptive digital filter */
-#define ADFC 0x10
-#define FILTER_THRESHOLD_MODE 0x08
-#define FILTER_NONTHRESHOLD_MODE 0x00
+/*Tchreg.h*/
+#define ADFC 0x10 /* Adaptive digital filter*/
+#define FILTER_THRESHOLD_MODE 0x08
+#define FILTER_NONTHRESHOLD_MODE 0x00
-#define REPEAT_5 0x04
-#define REPEAT_4 0x03
-#define REPEAT_3 0x02
-#define REPEAT_2 0x01
-#define REPEAT_1 0x00
+#define REPEAT_5 0x04
+#define REPEAT_4 0x03
+#define REPEAT_3 0x02
+#define REPEAT_2 0x01
+#define REPEAT_1 0x00
struct rm31080a_ctrl_para {
unsigned short u16DataLength;
+ unsigned short bICVersion;
unsigned short bChannelNumberX;
unsigned short bChannelNumberY;
unsigned short bADCNumber;
unsigned char bfNoiseMode;
unsigned char bNoiseRepeatTimes;
- unsigned char bfNoiseDetector;
unsigned short u16ResolutionX;
unsigned short u16ResolutionY;
- unsigned char bICVersion;
- /* Marty added */
- unsigned char bChannelDetectorNum; /* Noise_Detector */
- unsigned char bChannelDetectorDummy; /* Noise_Detector */
- signed char bNoiseThresholdMax; /* Noise_Detector */
- signed char bNoiseThresholdMin; /* Noise_Detector */
- signed char bNoiseThresholdLowMax; /* Noise_Detector */
- signed char bNoiseThresholdLowMin; /* Noise_Detector */
- unsigned char bBaselineReady; /* Noise_Detector */
- unsigned char bNoiseDetectThd; /* Noise_Detector */
- unsigned char bNewNoiseRepeatTimes;
- unsigned char bRepeatTimes[2]; /* Noise_Detector */
+ unsigned char bChannelDetectorNum;
+ unsigned char bChannelDetectorDummy;
+ unsigned char bActiveRepeatTimes[2]; /* Noise_Detector */
unsigned char bIdleRepeatTimes[2];
unsigned char bSenseNumber; /* Noise_Detector */
unsigned char bfADFC; /* Noise_Detector */
unsigned char bfTHMode; /* Noise_Detector */
unsigned char bfAnalogFilter; /* Noise_Detector */
- unsigned char bXChannel[4];
- unsigned char bYChannel[2];
- unsigned char bDummyChannel[4];
unsigned char bfNoiseModeDetector;
- unsigned char bfMediumFilter;
- unsigned char bMFBlockNumber;
unsigned char bfSuspendReset;
unsigned char bPressureResolution;
unsigned char bfNoisePreHold;
unsigned char bfTouched;
- unsigned char bSTScan;
signed char bMTTouchThreshold;
- unsigned char bfExitNoiseMode;
- unsigned char bNoisePipelineBase;
unsigned char bTime2Idle;
unsigned char bfPowerMode;
- unsigned char bfIdleMessage;
+ unsigned char bDebugMessage;
+ unsigned char bTimerTriggerScale;
unsigned char bDummyRunCycle;
unsigned char bfIdleModeCheck;
-
+ unsigned char bfSelftestData;
};
extern struct rm31080a_ctrl_para g_stCtrl;
-int rm31080_ctrl_clear_int(void);
-int rm31080_ctrl_scan_start(void);
-int rm31080_ctrl_read_raw_data(unsigned char *p);
-void rm31080_ctrl_wait_for_scan_finish(void);
+int rm_tch_ctrl_clear_int(void);
+int rm_tch_ctrl_scan_start(void);
+void rm_tch_ctrl_wait_for_scan_finish(void);
-void rm31080_ctrl_init(void);
-void rm31080_ctrl_set_baseline(void *arg);
-unsigned char rm31080_ctrl_get_noise_mode(unsigned char *p);
-unsigned char rm31080_ctrl_get_idle_mode(unsigned char *p);
-void rm31080_ctrl_get_parameter(void *arg);
-int rm31080_soft_average(signed char *pSource);
-int rm_noise_detect(signed char *pSource);
-int rm_noise_main(signed char *pSource);
+void rm_tch_ctrl_init(void);
+unsigned char rm_tch_ctrl_get_noise_mode(unsigned char *p);
+unsigned char rm_tch_ctrl_get_idle_mode (unsigned char *p);
+void rm_tch_ctrl_get_parameter(void *arg);
void rm_set_repeat_times(u8 u8Times);
-#endif /* _RM31080A_CTRL_H_ */
+#endif /*_RM31080A_CTRL_H_*/
diff --git a/include/linux/spi/rm31080a_ts.h b/include/linux/spi/rm31080a_ts.h
index 9a1364ec8240..3cbd589ecc7a 100644
--- a/include/linux/spi/rm31080a_ts.h
+++ b/include/linux/spi/rm31080a_ts.h
@@ -1,80 +1,64 @@
-/*
- * Raydium RM31080 touchscreen header
- *
- * Copyright (C) 2012-2013, Raydium Semiconductor Corporation.
- * Copyright (C) 2012-2013, NVIDIA Corporation. All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- */
#ifndef _RM31080A_TS_H_
#define _RM31080A_TS_H_
-#define ENABLE_SLOW_SCAN
+#define ENABLE_MANUAL_IDLE_MODE 0
-#define RM_MAX_CHANNEL_COUNT 128
-#define RM_MAX_MT_COUNT 2048
+#define PARAMETER_AMOUNT 384
-/* Define for T007 A6/B1 IC version ckeck */
-#define T007A6 0xD0
-#define T007_VERSION_B 0xB0
-#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
+/***************************************************************************
+ * Kernel CTRL Define
+ * DO NOT MODIFY
+ * NOTE: Need to sync with HAL
+ ***************************************************************************/
+#define OK 1
+#define FAIL 0
+#define DEBUG_DRIVER 0x01
-#define RM_IOCTL_REPORT_POINT 0x1001
-#define RM_IOCTL_SET_HAL_PID 0x1002
+#define RM_IOCTL_REPORT_POINT 0x1001
+#define RM_IOCTL_SET_HAL_PID 0x1002
#define RM_IOCTL_INIT_START 0x1003
-#define RM_IOCTL_INIT_END 0x1004
-#define RM_IOCTL_FINISH_CALC 0x1005
-#define RM_IOCTL_SCRIBER_CTRL 0x1006
+#define RM_IOCTL_INIT_END 0x1004
+#define RM_IOCTL_FINISH_CALC 0x1005
+#define RM_IOCTL_SCRIBER_CTRL 0x1006
#define RM_IOCTL_READ_RAW_DATA 0x1007
#define RM_IOCTL_AUTOSCAN_CTRL 0x1008
-#define RM_IOCTL_NOISE_CHECK 0x1009
+#define RM_IOCTL_NOISE_CHECK 0x1009
#define RM_IOCTL_GET_PARAMETER 0x100A
-#define RM_IOCTL_SET_PARAMETER 0x100B
-#define RM_IOCTL_SEND_BASELINE 0x100C
-#define RM_IOCTL_SEND_ANALOG_BASELINE 0x100D
-#define RM_IOCTL_SET_VARIABLE 0x1010
- #define RM_VARIABLE_SELF_TEST_RESULT 0x01
- #define RM_VARIABLE_SCRIBER_FLAG 0x02
- #define RM_VARIABLE_AUTOSCAN_FLAG 0x03
- #define RM_VARIABLE_VERSION 0x04
- #define RM_VARIABLE_IDLEMODECHECK 0x05
- #define RM_VARIABLE_REPEAT 0x06
-#define RM_IOCTL_GET_VARIABLE 0x1011
- #define RM_VARIABLE_PLATFORM_ID 0x01
-#define RM_IOCTL_SET_SLOWSCAN_PARA 0x1012
-#define RM_IOCTL_GET_SACN_MODE 0x1013
-#define RM_IOCTL_CHECK_INIT_STATUS 0x1014
-
-#define RM_INPUT_RESOLUTION_X 4096
-#define RM_INPUT_RESOLUTION_Y 4096
-
-#define RM_TS_SIGNAL 44
-#define RM_TS_MAX_POINTS 16
+#define RM_IOCTL_SET_VARIABLE 0x1010
+#define RM_VARIABLE_SELF_TEST_RESULT 0x01
+#define RM_VARIABLE_SCRIBER_FLAG 0x02
+#define RM_VARIABLE_AUTOSCAN_FLAG 0x03
+#define RM_VARIABLE_VERSION 0x04
+#define RM_VARIABLE_IDLEMODECHECK 0x05
+#define RM_VARIABLE_REPEAT 0x06
+#define RM_VARIABLE_WATCHDOG_FLAG 0x07
+#define RM_VARIABLE_TEST_VERSION 0x08
+#define RM_IOCTL_GET_VARIABLE 0x1011
+#define RM_VARIABLE_PLATFORM_ID 0x01
+#define RM_IOCTL_GET_SACN_MODE 0x1012
+#define RM_IOCTL_SET_KRL_TBL 0x1013
+#define RM_IOCTL_WATCH_DOG 0x1014
+
+#define RM_INPUT_RESOLUTION_X 4096
+#define RM_INPUT_RESOLUTION_Y 4096
+
+#define RM_TS_SIGNAL 44
+#define RM_TS_MAX_POINTS 16
#define RM_SIGNAL_INTR 0x00000001
#define RM_SIGNAL_SUSPEND 0x00000002
#define RM_SIGNAL_RESUME 0x00000003
#define RM_SIGNAL_CHANGE_PARA 0x00000004
- #define RM_SIGNAL_PARA_SMOOTH 0x00
- #define RM_SIGNAL_PARA_SELF_TEST 0x01
-#define RM_SIGNAL_ENTER_AUTO_SCAN 0x00000005
-#define RM_SIGNAL_LEAVE_AUTO_SCAN 0x00000006
+#define RM_SIGNAL_WATCH_DOG_CHECK 0x00000005
+#define RM_SIGNAL_PARA_SMOOTH 0x00
+#define RM_SIGNAL_PARA_SELF_TEST 0x01
+
#define RM_SELF_TEST_STATUS_FINISH 0
#define RM_SELF_TEST_STATUS_TESTING 1
-#define RM_SELF_TEST_RESULT_FAIL 0
-#define RM_SELF_TEST_RESULT_PASS 1
+#define RM_SELF_TEST_RESULT_FAIL 0
+#define RM_SELF_TEST_RESULT_PASS 1
+
/****************************************************************************
* Platform define
@@ -85,59 +69,96 @@
#define RM_PLATFORM_D010 0x03
#define RM_PLATFORM_P005 0x04
#define RM_PLATFORM_R005 0x05
-#define RM_PLATFORM_A110 0x10
-#define RM_PLATFORM_A10L 0x11
-
-#ifdef ENABLE_SLOW_SCAN
-#define RM_SLOW_SCAN_INTERVAL 20
-#define RM_SLOW_SCAN_CMD_COUNT 0x10
-enum RM_SLOW_SCAN_LEVELS {
- RM_SLOW_SCAN_LEVEL_NORMAL,
- RM_SLOW_SCAN_LEVEL_20,
- RM_SLOW_SCAN_LEVEL_40,
- RM_SLOW_SCAN_LEVEL_60,
- RM_SLOW_SCAN_LEVEL_80,
- RM_SLOW_SCAN_LEVEL_100,
- RM_SLOW_SCAN_LEVEL_120,
- RM_SLOW_SCAN_LEVEL_140,
- RM_SLOW_SCAN_LEVEL_160,
- RM_SLOW_SCAN_LEVEL_180,
- RM_SLOW_SCAN_LEVEL_200,
- RM_SLOW_SCAN_LEVEL_220,
- RM_SLOW_SCAN_LEVEL_240,
- RM_SLOW_SCAN_LEVEL_260,
- RM_SLOW_SCAN_LEVEL_280,
- RM_SLOW_SCAN_LEVEL_MAX,
- RM_SLOW_SCAN_LEVEL_COUNT
-};
-#endif
+#define RM_PLATFORM_RAYPRJ 0x80
+/***************************************************************************
+ * DO NOT MODIFY - Kernel CTRL Define
+ * NOTE: Need to sync with HAL
+ ***************************************************************************/
-struct rm_cmd_element {
- unsigned char addr;
- unsigned char value;
-};
-struct rm_cmd_list {
- unsigned char count;
- struct rm_cmd_element cmd[0];
-};
-struct rm_cmd_slow_scan {
- unsigned char count;
- struct rm_cmd_element cmd[RM_SLOW_SCAN_CMD_COUNT];
-};
+/***************************************************************************
+ * Kernel Command Set
+ * DO NOT MODIFY
+ * NOTE: Need to sync with HAL
+ ***************************************************************************/
+#define KRL_TBL_CMD_LEN 3
+
+#define KRL_INDEX_FUNC_SET_IDLE 0
+#define KRL_INDEX_FUNC_PAUSE_AUTO 1
+#define KRL_INDEX_RM_START 2
+#define KRL_INDEX_RM_END 3
+#define KRL_INDEX_RM_READ_IMG 4
+#define KRL_INDEX_RM_WATCHDOG 5
+#define KRL_INDEX_RM_TESTMODE 6
+#define KRL_INDEX_RM_SLOWSCAN 7
+
+#define KRL_SIZE_SET_IDLE 128
+#define KRL_SIZE_PAUSE_AUTO 64
+#define KRL_SIZE_RM_START 64
+#define KRL_SIZE_RM_END 64
+#define KRL_SIZE_RM_READ_IMG 64
+#define KRL_SIZE_RM_WATCHDOG 96
+#define KRL_SIZE_RM_TESTMODE 96
+#define KRL_SIZE_RM_SLOWSCAN 128
+
+#define KRL_TBL_FIELD_POS_LEN_H 0
+#define KRL_TBL_FIELD_POS_LEN_L 1
+#define KRL_TBL_FIELD_POS_CASE_NUM 2
+#define KRL_TBL_FIELD_POS_CMD_NUM 3
+
+#define KRL_CMD_READ 0x11
+#define KRL_CMD_WRITE_W_DATA 0x12
+#define KRL_CMD_WRITE_WO_DATA 0x13
+#define KRL_CMD_AND 0x18
+#define KRL_CMD_OR 0x19
+#define KRL_CMD_NOT 0x1A
+#define KRL_CMD_XOR 0x1B
+
+#define KRL_CMD_SEND_SIGNAL 0x20
+#define KRL_CMD_CONFIG_RST 0x21
+#define KRL_SUB_CMD_SET_RST_GPIO 0x00
+#define KRL_SUB_CMD_SET_RST_VALUE 0x01
+#define KRL_CMD_SET_TIMER 0x22
+#define KRL_SUB_CMD_INIT_TIMER 0x00
+#define KRL_SUB_CMD_ADD_TIMER 0x01
+#define KRL_SUB_CMD_DEL_TIMER 0x02
+#define KRL_CMD_CONFIG_3V3 0x23
+#define KRL_SUB_CMD_SET_3V3_GPIO 0x00
+#define KRL_SUB_CMD_SET_3V3_REGULATOR 0x01
+#define KRL_CMD_CONFIG_1V8 0x24
+#define KRL_SUB_CMD_SET_1V8_GPIO 0x00
+#define KRL_SUB_CMD_SET_1V8_REGULATOR 0x01
+#define KRL_CMD_CONFIG_CLK 0x25
+#define KRL_SUB_CMD_SET_CLK 0x00
+
+#define KRL_CMD_USLEEP 0x40
+#define KRL_CMD_MSLEEP 0x41
+
+#define KRL_CMD_FLUSH_QU 0x52
+#define KRL_SUB_CMD_SENSOR_QU 0x00
+#define KRL_SUB_CMD_TIMER_QU 0x01
+
+#define KRL_CMD_READ_IMG 0x60
+
+/***************************************************************************
+ * DO NOT MODIFY - Kernel Command Set
+ * NOTE: Need to sync with HAL
+ ***************************************************************************/
-struct rm_touch_event {
+typedef struct {
unsigned char ucTouchCount;
unsigned char ucID[RM_TS_MAX_POINTS];
unsigned short usX[RM_TS_MAX_POINTS];
unsigned short usY[RM_TS_MAX_POINTS];
unsigned short usZ[RM_TS_MAX_POINTS];
-};
+} rm_touch_event;
struct rm_spi_ts_platform_data {
int gpio_reset;
+ int gpio_1v8;
+ int gpio_3v3;
int x_size;
int y_size;
unsigned char *config;
@@ -146,12 +167,9 @@ struct rm_spi_ts_platform_data {
unsigned char *name_of_clock_con;
};
-int rm31080_spi_byte_write(unsigned char u8Addr, unsigned char u8Value);
-int rm31080_spi_byte_read(unsigned char u8Addr, unsigned char *pu8Value);
-int rm31080_spi_burst_write(unsigned char *pBuf, unsigned int u32Len);
-void rm31080_disable_touch(void);
-void rm31080_enable_touch(void);
-void rm31080_set_autoscan(unsigned char val);
-int rm31080_ts_send_signal(int pid, int iInfo);
+int rm_tch_spi_byte_write(unsigned char u8Addr, unsigned char u8Value);
+int rm_tch_spi_byte_read(unsigned char u8Addr, unsigned char *pu8Value);
+int rm_tch_spi_burst_write(unsigned char *pBuf, unsigned int u32Len);
+void rm_tch_set_autoscan(unsigned char val);
-#endif /*_RM31080A_TS_H_*/
+#endif /*_RM31080A_TS_H_*/