diff options
author | Vincent Chen <zochen@nvidia.com> | 2014-04-01 20:13:20 -0700 |
---|---|---|
committer | Riham Haidar <rhaidar@nvidia.com> | 2014-05-05 11:05:33 -0700 |
commit | 37d7fa65b3f8471e65cbe3ea8ed05419bcdf2342 (patch) | |
tree | d63a0de4ca7774e91bd39e3c6e30c3a6ad4689a9 /drivers/input | |
parent | 7e2ffe6c059b6fbae01480605e5aef8093e5fb4c (diff) |
input: touchscreen: raydium: update driver to 62.3
62.2 changes:
[1] fix error/warning from checkpatch
[2] add keybit
[3] Device tree support
[4] All the sysfs nodes are moved to 'sys/devices/virtual/misc/touch'
and also rename the device as 'touch'
[5] Using default path to loading all libraries instead of absolute path
[6] Remove PM suspend/resume operations to prevent from LP0 resume
failure due to race condition
[7] Touch performance refine (palm, stylus, ......)
[8] fix slowscan issue
[9] Add TLK support
[10] Add TN8 support
62.3 changes:
[1] fix checkpatch error.
[2] improve TN8 stylus performance.
[3] improve TN8 finger performance.
[4] add error code in selftest function.
[5] add TN8 noise hopping function.
[6] add codes for x64 system."
bug 1446493
bug 1482112
bug 1469135
bug 1468629
bug 1465587
bug 1453371
bug 1437076
bug 1405258
Change-Id: I633cddb8b65a9c7fe741f6a782d4a4f5fd792c58
Signed-off-by: Vincent Chen <zochen@nvidia.com>
Signed-off-by: Robert Collins <rcollins@nvidia.com>
Reviewed-on: http://git-master/r/401082
Tested-by: Hridya Valsaraju <hvalsaraju@nvidia.com>
Reviewed-by: Mitch Luban <mluban@nvidia.com>
Diffstat (limited to 'drivers/input')
-rw-r--r-- | drivers/input/touchscreen/rm31080a_ctrl.c | 14 | ||||
-rw-r--r-- | drivers/input/touchscreen/rm31080a_ts.c | 2063 |
2 files changed, 1173 insertions, 904 deletions
diff --git a/drivers/input/touchscreen/rm31080a_ctrl.c b/drivers/input/touchscreen/rm31080a_ctrl.c index 7b6dd6a5a10b..d11c169ea708 100644 --- a/drivers/input/touchscreen/rm31080a_ctrl.c +++ b/drivers/input/touchscreen/rm31080a_ctrl.c @@ -1,9 +1,9 @@ /* * Raydium RM31080 touchscreen driver * - * Copyright (C) 2012-2013, Raydium Semiconductor Corporation. + * Copyright (C) 2012-2014, Raydium Semiconductor Corporation. * All Rights Reserved. - * Copyright (C) 2012-2013, NVIDIA Corporation. All Rights Reserved. + * Copyright (C) 2012-2014, 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 @@ -25,7 +25,7 @@ /*============================================================================= GLOBAL VARIABLES DECLARATION =============================================================================*/ -struct rm_tch_ctrl_para g_stCtrl; +struct rm_tch_ctrl_para g_st_ctrl; /*============================================================================= FUNCTION DECLARATION @@ -40,7 +40,7 @@ struct rm_tch_ctrl_para g_stCtrl; =============================================================================*/ void rm_tch_ctrl_init(void) { - memset(&g_stCtrl, 0, sizeof(struct rm_tch_ctrl_para)); + memset(&g_st_ctrl, 0, sizeof(struct rm_tch_ctrl_para)); } /*============================================================================= @@ -54,7 +54,8 @@ void rm_tch_ctrl_init(void) unsigned char rm_tch_ctrl_get_idle_mode(u8 *p) { u32 u32Ret; - u32Ret = copy_to_user(p, &g_stCtrl.bfIdleModeCheck, 1); + u32Ret = copy_to_user(p, + &g_st_ctrl.u8_idle_mode_check, 1); if (u32Ret) return RETURN_FAIL; return RETURN_OK; @@ -71,7 +72,8 @@ unsigned char rm_tch_ctrl_get_idle_mode(u8 *p) void rm_tch_ctrl_set_parameter(void *arg) { ssize_t missing; - missing = copy_from_user(&g_stCtrl, arg, sizeof(struct rm_tch_ctrl_para)); + missing = copy_from_user(&g_st_ctrl, + arg, sizeof(struct rm_tch_ctrl_para)); if (missing) return; } diff --git a/drivers/input/touchscreen/rm31080a_ts.c b/drivers/input/touchscreen/rm31080a_ts.c index 283d1c12ea3f..49971ecd34ae 100644 --- a/drivers/input/touchscreen/rm31080a_ts.c +++ b/drivers/input/touchscreen/rm31080a_ts.c @@ -1,7 +1,7 @@ /* * Raydium RM31080 touchscreen driver * - * Copyright (C) 2012-2013, Raydium Semiconductor Corporation. + * Copyright (C) 2012-2014, Raydium Semiconductor Corporation. * All Rights Reserved. * Copyright (C) 2012-2014, NVIDIA Corporation. All Rights Reserved. * @@ -25,6 +25,9 @@ #include <linux/slab.h> #include <linux/fb.h> #include <linux/gpio.h> +#include <linux/of.h> +#include <linux/of_device.h> +#include <linux/of_gpio.h> #include <linux/sched.h> /* wake_up_process() */ #include <linux/kthread.h> /* kthread_create(),kthread_run() */ #include <linux/uaccess.h> /* copy_to_user() */ @@ -58,28 +61,35 @@ #define ENABLE_SLOW_SCAN #define ENABLE_SMOOTH_LEVEL #define ENABLE_SPI_SETTING 0 +#define ENABLE_FREQ_HOPPING 1 #define MAX_SPI_FREQ_HZ 50000000 #define TS_PEN_UP_TIMEOUT msecs_to_jiffies(50) -#define QUEUE_COUNT 128 +#define QUEUE_COUNT 128 #define RM_RAW_DATA_LENGTH 6144 #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 #define TCH_WAKE_LOCK_TIMEOUT (HZ/2) #ifdef ENABLE_SLOW_SCAN -#define RM_SLOW_SCAN_INTERVAL 20 -#define RM_SLOW_SCAN_CMD_COUNT 0x10 +#define RM_SLOW_SCAN_INTERVAL 20 +#define RM_SLOW_SCAN_CMD_COUNT 0x10 +#if ENABLE_FREQ_HOPPING /*ENABLE_SCAN_DATA_HEADER*/ +#define QUEUE_HEADER_NUM 8 +#define SCAN_TYPE_MT 1 +#else +#define QUEUE_HEADER_NUM 0 +#endif enum RM_SLOW_SCAN_LEVELS { RM_SLOW_SCAN_LEVEL_NORMAL, RM_SLOW_SCAN_LEVEL_20, @@ -99,14 +109,17 @@ enum RM_SLOW_SCAN_LEVELS { #define TS_TIMER_PERIOD HZ -#define INPUT_DEVICE_MULTIPLE_INSTANCES +/*#define INPUT_DEVICE_MULTIPLE_INSTANCES*/ #ifdef INPUT_DEVICE_MULTIPLE_INSTANCES -#define INPUT_DEVICE_AMOUNT 2 - +#define INPUT_DEVICE_AMOUNT 2 #define INPUT_DEVICE_FOR_FINGER 0 #define INPUT_DEVICE_FOR_STYLUS 1 #endif +/*#define CS_SUPPORT*/ +/*#define CONFIG_TRUSTED_LITTLE_KERNEL*/ +#define MASK_USER_SPACE_POINTER 0x00000000FFFFFFFF /* 64-bit support */ + /* do not use printk in kernel files */ #define rm_printk(msg...) dev_info(&g_spi->dev, msg) @@ -115,46 +128,44 @@ enum RM_SLOW_SCAN_LEVELS { =============================================================================*/ /*TouchScreen Parameters*/ struct rm31080a_ts_para { - unsigned long ulHalPID; - bool bInitFinish; - bool bCalcFinish; - bool bEnableScriber; - bool bIsSuspended; - - u32 u32WatchDogCnt; - u8 u8WatchDogFlg; - u8 u8WatchDogEnable; - bool u8WatchDogCheck; - u32 u32WatchDogTime; + u32 u32_hal_pid; + bool b_init_finish; + bool b_calc_finish; + bool b_enable_scriber; + bool b_is_suspended; - u8 u8ScanModeState; - u8 u8ReportMode; + u32 u32_watch_dog_cnt; + u8 u8_watch_dog_flg; + u8 u8_watch_dog_enable; + bool b_watch_dog_check; + u32 u32_watch_dog_time; - u8 u8ResumeCnt; + u8 u8_scan_mode_state; + u8 u8_resume_cnt; #ifdef ENABLE_SLOW_SCAN - bool bEnableSlowScan; - u32 u32SlowScanLevel; + bool b_enable_slow_scan; + u32 u32_slow_scan_level; #endif #ifdef ENABLE_SMOOTH_LEVEL - u32 u32SmoothLevel; + u32 u32_smooth_level; #endif - - u8 u8SelfTestStatus; - u8 u8SelfTestResult; - u8 u8Version; - u8 u8TestVersion; - u8 u8Repeat; - u16 u16ReadPara; - u8 u8SPILocked; - u8 bSWCPW[3]; - u8 bDP[3]; - u8 bSWC[3]; - u8 bNsMode; - u8 bNsSel; - u8 bNsRpt; - struct wake_lock Wakelock_Initialization; + bool b_selftest_enable; + u8 u8_selftest_status; + u8 u8_selftest_result; + u8 u8_version; + u8 u8_test_version; + u8 u8_repeat; + u16 u16_read_para; + u8 u8_spi_locked; +#if ENABLE_FREQ_HOPPING + u8 u8_ns_para[9]; + u8 u8_ns_mode; + u8 u8_ns_sel; + u8 u8_ns_rpt; +#endif + struct wake_lock wakelock_initialization; struct mutex mutex_scan_mode; struct mutex mutex_spi_rw; @@ -165,7 +176,6 @@ struct rm31080a_ts_para { struct workqueue_struct *rm_timer_workqueue; struct work_struct rm_timer_work; - }; struct rm_tch_ts { @@ -187,7 +197,7 @@ struct rm_tch_ts { struct notifier_block nb_3v3; struct notifier_block nb_1v8; struct clk *clk; - unsigned char bRepeatCounter; + unsigned char u8_repeat_counter; }; struct rm_tch_bus_ops { @@ -197,9 +207,9 @@ struct rm_tch_bus_ops { }; struct rm_tch_queue_info { - u8(*pQueue)[RM_RAW_DATA_LENGTH]; - u16 u16Front; - u16 u16Rear; + u8(*p_u8_queue)[RM_RAW_DATA_LENGTH]; + u16 u16_front; + u16 u16_rear; }; /*============================================================================= @@ -211,54 +221,53 @@ struct input_dev *g_input_dev; struct input_dev *g_input_dev[INPUT_DEVICE_AMOUNT]; #endif struct spi_device *g_spi; -struct rm31080a_ts_para g_stTs; +struct rm31080a_ts_para g_st_ts; +struct rm_tch_queue_info g_st_q; + bool g_timer_queue_is_flush; bool g_worker_queue_is_flush; - -struct rm_tch_queue_info g_stQ; - -unsigned char *g_pu8BurstReadBuf; - -unsigned char g_stCmdSetIdle[KRL_SIZE_SET_IDLE]; -unsigned char g_stCmdPauseAuto[KRL_SIZE_PAUSE_AUTO]; -unsigned char g_stRmResumeCmd[KRL_SIZE_RM_RESUME]; -unsigned char g_stRmSuspendCmd[KRL_SIZE_RM_SUSPEND]; -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]; -unsigned char g_stRmClearIntCmd[KRL_SIZE_RM_CLEARINT]; -unsigned char g_stRmScanStartCmd[KRL_SIZE_RM_SCANSTART]; -unsigned char g_stRmWaitScanOKCmd[KRL_SIZE_RM_WAITSCANOK]; -unsigned char g_stRmSetRepTimeCmd[KRL_SIZE_RM_SETREPTIME]; -unsigned char g_stRmNsParaCmd[KRL_SIZE_RM_NS_PARA]; -unsigned char g_stRmSlowScanBCmd[KRL_SIZE_RM_SLOWSCANB]; -unsigned char g_stRmWriteImgCmd[KRL_SIZE_RM_WRITE_IMAGE]; +unsigned char *g_pu8_burstread_buf; + +unsigned char g_st_cmd_set_idle[KRL_SIZE_SET_IDLE]; +unsigned char g_st_cmd_pause_auto[KRL_SIZE_PAUSE_AUTO]; +unsigned char g_st_rm_resume_cmd[KRL_SIZE_RM_RESUME]; +unsigned char g_st_rm_suspend_cmd[KRL_SIZE_RM_SUSPEND]; +unsigned char g_st_rm_readimg_cmd[KRL_SIZE_RM_READ_IMG]; +unsigned char g_st_rm_watchdog_cmd[KRL_SIZE_RM_WATCHDOG]; +unsigned char g_st_rm_testmode_cmd[KRL_SIZE_RM_TESTMODE]; +unsigned char g_st_rm_slow_scan_cmd[KRL_SIZE_RM_SLOWSCAN]; +unsigned char g_st_rm_clear_int_cmd[KRL_SIZE_RM_CLEARINT]; +unsigned char g_st_rm_scan_start_cmd[KRL_SIZE_RM_SCANSTART]; +unsigned char g_st_rm_wait_scan_ok_cmd[KRL_SIZE_RM_WAITSCANOK]; +unsigned char g_st_rm_set_rep_time_cmd[KRL_SIZE_RM_SETREPTIME]; +unsigned char g_st_rm_ns_para_cmd[KRL_SIZE_RM_NS_PARA]; +unsigned char g_st_rm_writeimg_cmd[KRL_SIZE_RM_WRITE_IMAGE]; +unsigned char g_st_rm_tlk_cmd[KRL_SIZE_RM_TLK]; int g_service_busy_report_count; struct timer_list ts_timer_triggle; -static unsigned char spi_buf[4096]; -static unsigned int bufsize; /*= 0; remove by checkpatch*/ -bool fgBLUpdated; -u8 g_u8UpdateBaseline[RM_RAW_DATA_LENGTH]; +static unsigned char g_spi_buf[8192]; +static unsigned int g_spi_bufsize; /*= 0; remove by checkpatch*/ +static unsigned char g_spi_addr; +bool b_bl_updated; +u8 g_u8_update_baseline[RM_RAW_DATA_LENGTH]; /*============================================================================= FUNCTION DECLARATION =============================================================================*/ -static int rm_tch_cmd_process(u8 selCase, u8 *pCmdTbl, struct rm_tch_ts *ts); +static int rm_tch_cmd_process(u8 u8_sel_case, u8 *p_cmd_tbl, + 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); - +static int rm_tch_ts_send_signal(int pid, int i_info); static void rm_tch_enter_test_mode(u8 flag); static void rm_ctrl_suspend(struct rm_tch_ts *ts); static void rm_ctrl_resume(struct rm_tch_ts *ts); -static void rm_ctrl_watchdog_func(unsigned int u32Enable); - +static void rm_ctrl_watchdog_func(unsigned int u32_enable); static void init_ts_timer(void); static void ts_timer_triggle_function(unsigned long option); @@ -277,16 +286,16 @@ static int rm_tch_spi_read(u8 u8addr, u8 *rxbuf, size_t len) struct spi_message message; struct spi_transfer x[2]; - if (g_stTs.u8SPILocked) { + if (g_st_ts.u8_spi_locked) { memset(rxbuf, 0, len); - if (g_stCtrl.bKernelMsg & DEBUG_DRIVER_REGISTER) + if (g_st_ctrl.u8_kernel_msg & DEBUG_DRIVER_REGISTER) rm_printk("Raydium - SPI Read Locked!! 0x%x:%d\n", u8addr, len); - //return RETURN_FAIL; + /*return RETURN_FAIL;*/ return RETURN_OK; } - mutex_lock(&g_stTs.mutex_spi_rw); + mutex_lock(&g_st_ts.mutex_spi_rw); spi_message_init(&message); memset(x, 0, sizeof(x)); @@ -303,10 +312,10 @@ static int rm_tch_spi_read(u8 u8addr, u8 *rxbuf, size_t len) /*It returns zero on succcess,else a negative error code.*/ status = spi_sync(g_spi, &message); - mutex_unlock(&g_stTs.mutex_spi_rw); + mutex_unlock(&g_st_ts.mutex_spi_rw); - if (g_stCtrl.bKernelMsg & DEBUG_DRIVER_REGISTER) - if (g_stTs.bInitFinish == 0) + if (g_st_ctrl.u8_kernel_msg & DEBUG_DRIVER_REGISTER) + if (g_st_ts.b_init_finish == 0) rm_printk("Raydium - READ: addr=0x%2x, value=0x%2x", (u8addr&0x7F), rxbuf[0]); @@ -333,22 +342,22 @@ static int rm_tch_spi_write(u8 *txbuf, size_t len) int status; /*It returns zero on succcess,else a negative error code.*/ - if (g_stTs.u8SPILocked) { - if (g_stCtrl.bKernelMsg & DEBUG_DRIVER_REGISTER) + if (g_st_ts.u8_spi_locked) { + if (g_st_ctrl.u8_kernel_msg & DEBUG_DRIVER_REGISTER) rm_printk("Raydium - SPI write Locked!! 0x%x:0x%x\n", txbuf[0], txbuf[1]); - //return RETURN_FAIL; + /*return RETURN_FAIL;*/ return RETURN_OK; } - mutex_lock(&g_stTs.mutex_spi_rw); + mutex_lock(&g_st_ts.mutex_spi_rw); status = spi_write(g_spi, txbuf, len); - mutex_unlock(&g_stTs.mutex_spi_rw); + mutex_unlock(&g_st_ts.mutex_spi_rw); - if (g_stCtrl.bKernelMsg & DEBUG_DRIVER_REGISTER) - if (g_stTs.bInitFinish == 0) + if (g_st_ctrl.u8_kernel_msg & DEBUG_DRIVER_REGISTER) + if (g_st_ts.b_init_finish == 0) rm_printk("Raydium - WRITE: addr=0x%2x, value=0x%2x", txbuf[0], txbuf[1]); @@ -370,9 +379,9 @@ static int rm_tch_spi_write(u8 *txbuf, size_t len) 1:succeed 0:failed =============================================================================*/ -int rm_tch_spi_byte_read(unsigned char u8Addr, unsigned char *pu8Value) +int rm_tch_spi_byte_read(unsigned char u8_addr, unsigned char *p_u8_value) { - return rm_tch_spi_read(u8Addr, pu8Value, 1); + return rm_tch_spi_read(u8_addr, p_u8_value, 1); } /*============================================================================= @@ -384,160 +393,94 @@ int rm_tch_spi_byte_read(unsigned char u8Addr, unsigned char *pu8Value) 1:succeed 0:failed =============================================================================*/ -int rm_tch_spi_byte_write(unsigned char u8Addr, unsigned char u8Value) +int rm_tch_spi_byte_write(unsigned char u8_addr, unsigned char u8_value) { u8 buf[2]; - buf[0] = u8Addr; - buf[1] = u8Value; + buf[0] = u8_addr; + buf[1] = u8_value; return rm_tch_spi_write(buf, 2); } -/*============================================================================= - Description: - RM31080 spi interface. - Input: - - Output: - 1:succeed - 0:failed -=============================================================================*/ -int rm_tch_spi_burst_read(unsigned char u8Addr, unsigned char *pu8Value, - unsigned int u32Len) -{ - int ret; - u8 *pMyBuf; - ssize_t missing; - - pMyBuf = kmalloc(u32Len, GFP_KERNEL); - if (pMyBuf == NULL) - return -ENOMEM; - - ret = rm_tch_spi_read(u8Addr, pMyBuf, u32Len); - - if (ret) { - missing = copy_to_user(pu8Value, pMyBuf, u32Len); - if (missing) { - dev_err(&g_spi->dev, "Raydium - %s : copy failed - len:%d, miss:%d\n", - __func__, u32Len, missing); - kfree(pMyBuf); - return RETURN_FAIL; - } - } - - kfree(pMyBuf); - - return ret; -} -/*============================================================================= - 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; - ssize_t missing; - - pMyBuf = kmalloc(u32Len, GFP_KERNEL); - if (pMyBuf == NULL) - return -ENOMEM; - - missing = copy_from_user(pMyBuf, pBuf, u32Len); - if (missing) { - dev_err(&g_spi->dev, "Raydium - %s : copy failed - len:%d, miss:%d\n", - __func__, u32Len, missing); - kfree(pMyBuf); - return RETURN_FAIL; - } - - ret = rm_tch_spi_write(pMyBuf, u32Len); - kfree(pMyBuf); - return ret; -} - /*===========================================================================*/ -void raydium_change_scan_mode(u8 u8TouchCount) +void raydium_change_scan_mode(u8 u8_touch_count) { - static u32 u32NoTouchCount; /*= 0; remove by checkpatch*/ - u16 u16NTCountThd; + static u32 u32_no_touch_count; /*= 0; remove by checkpatch*/ + u16 u16_nt_count_thd; - u16NTCountThd = (u16)g_stCtrl.bTime2Idle * 100; + u16_nt_count_thd = (u16)g_st_ctrl.u8_time2idle * 100; - if (u8TouchCount) { - u32NoTouchCount = 0; + if (u8_touch_count) { + u32_no_touch_count = 0; return; } - mutex_lock(&g_stTs.mutex_scan_mode); - if (u32NoTouchCount < u16NTCountThd) { - u32NoTouchCount++; - } else if (g_stTs.u8ScanModeState == RM_SCAN_ACTIVE_MODE) { - g_stTs.u8ScanModeState = RM_SCAN_PRE_IDLE_MODE; - u32NoTouchCount = 0; + mutex_lock(&g_st_ts.mutex_scan_mode); + if (u32_no_touch_count < u16_nt_count_thd) { + u32_no_touch_count++; + } else if (g_st_ts.u8_scan_mode_state == RM_SCAN_ACTIVE_MODE) { + g_st_ts.u8_scan_mode_state = RM_SCAN_PRE_IDLE_MODE; + u32_no_touch_count = 0; } - mutex_unlock(&g_stTs.mutex_scan_mode); + mutex_unlock(&g_st_ts.mutex_scan_mode); } void raydium_report_pointer(void *p) { - static unsigned char ucLastTouchCount; /*= 0; remove by checkpatch*/ + static unsigned char u8_last_touch_count; /*= 0; remove by checkpatch*/ #ifdef INPUT_DEVICE_MULTIPLE_INSTANCES u8 target_device = INPUT_DEVICE_FOR_FINGER; #endif int i; - int iCount; - int iMaxX, iMaxY; - struct rm_touch_event *spTP; + int i_count; + int i_max_x, i_max_y; + struct rm_touch_event *sp_tp; ssize_t missing; - spTP = kmalloc(sizeof(struct rm_touch_event), GFP_KERNEL); - if (spTP == NULL) + sp_tp = kmalloc(sizeof(struct rm_touch_event), GFP_KERNEL); + if (sp_tp == NULL) return; - missing = copy_from_user(spTP, p, sizeof(struct rm_touch_event)); + missing = copy_from_user(sp_tp, p, sizeof(struct rm_touch_event)); if (missing) { dev_err(&g_spi->dev, "Raydium - %s : copy failed - len:%d, miss:%d\n", __func__, sizeof(struct rm_touch_event), missing); - kfree(spTP); + kfree(sp_tp); return; } - if ((g_stCtrl.u16ResolutionX != 0) && (g_stCtrl.u16ResolutionY != 0)) { - iMaxX = g_stCtrl.u16ResolutionX; - iMaxY = g_stCtrl.u16ResolutionY; + if ((g_st_ctrl.u16_resolution_x != 0) && + (g_st_ctrl.u16_resolution_y != 0)) { + i_max_x = g_st_ctrl.u16_resolution_x; + i_max_y = g_st_ctrl.u16_resolution_y; } else { - iMaxX = RM_INPUT_RESOLUTION_X; - iMaxY = RM_INPUT_RESOLUTION_Y; + i_max_x = RM_INPUT_RESOLUTION_X; + i_max_y = RM_INPUT_RESOLUTION_Y; } - iCount = max(ucLastTouchCount, spTP->ucTouchCount); + i_count = max(u8_last_touch_count, sp_tp->uc_touch_count); + #ifndef INPUT_DEVICE_MULTIPLE_INSTANCES - if (iCount && !spTP->ucTouchCount) { - ucLastTouchCount = 0; + if (i_count && !sp_tp->uc_touch_count) { + u8_last_touch_count = 0; input_report_key(g_input_dev, BTN_TOOL_RUBBER, 0); input_mt_sync(g_input_dev); input_sync(g_input_dev); - } else if (iCount) { - for (i = 0; i < iCount; i++) { + } else if (i_count) { + for (i = 0; i < i_count; i++) { if (i == MAX_REPORT_TOUCHED_POINTS) break; - if ((spTP->ucToolType[i] == POINT_TYPE_ERASER) - && (spTP->ucSlot[i] & INPUT_POINT_RESET)) { + if ((sp_tp->uc_tool_type[i] == POINT_TYPE_ERASER) && + (sp_tp->uc_slot[i] & INPUT_POINT_RESET)) { input_report_key(g_input_dev, BTN_TOOL_RUBBER, 0); input_mt_sync(g_input_dev); continue; } - if (i < spTP->ucTouchCount) { - switch (spTP->ucToolType[i]) { + if (i < sp_tp->uc_touch_count) { + switch (sp_tp->uc_tool_type[i]) { case POINT_TYPE_FINGER: input_report_abs(g_input_dev, ABS_MT_TOOL_TYPE, @@ -555,45 +498,45 @@ void raydium_report_pointer(void *p) default: dev_err(&g_spi->dev, "Raydium - point %d is invalid input tool type: %d\n", - i, spTP->ucToolType[i]); + i, sp_tp->uc_tool_type[i]); break; } input_report_abs(g_input_dev, ABS_MT_TRACKING_ID, - spTP->ucID[i]); + sp_tp->uc_id[i]); - if (spTP->usX[i] >= (iMaxX - 1)) + if (sp_tp->us_x[i] >= (i_max_x - 1)) input_report_abs(g_input_dev, ABS_MT_POSITION_X, - (iMaxX - 1)); + (i_max_x - 1)); else input_report_abs(g_input_dev, ABS_MT_POSITION_X, - spTP->usX[i]); + sp_tp->us_x[i]); - if (spTP->usY[i] >= (iMaxY - 1)) + if (sp_tp->us_y[i] >= (i_max_y - 1)) input_report_abs(g_input_dev, ABS_MT_POSITION_Y, - (iMaxY - 1)); + (i_max_y - 1)); else input_report_abs(g_input_dev, ABS_MT_POSITION_Y, - spTP->usY[i]); + sp_tp->us_y[i]); input_report_abs(g_input_dev, ABS_MT_PRESSURE, - spTP->usZ[i]); + sp_tp->us_z[i]); } input_mt_sync(g_input_dev); } input_sync(g_input_dev); - ucLastTouchCount = spTP->ucTouchCount; + u8_last_touch_count = sp_tp->uc_touch_count; } #else - if (iCount && !spTP->ucTouchCount) { - ucLastTouchCount = 0; + if (i_count && !sp_tp->uc_touch_count) { + u8_last_touch_count = 0; for (i = 0; i < INPUT_DEVICE_AMOUNT; i++) { if (i == INPUT_DEVICE_FOR_STYLUS) input_report_key(g_input_dev[i], @@ -601,13 +544,13 @@ void raydium_report_pointer(void *p) input_mt_sync(g_input_dev[i]); input_sync(g_input_dev[i]); } - } else if (iCount) { - for (i = 0; i < iCount; i++) { + } else if (i_count) { + for (i = 0; i < i_count; i++) { if (i == MAX_REPORT_TOUCHED_POINTS) break; - if ((spTP->ucToolType[i] == POINT_TYPE_ERASER) - && (spTP->ucSlot[i] & INPUT_POINT_RESET)) { + if ((sp_tp->uc_tool_type[i] == POINT_TYPE_ERASER) && + (sp_tp->uc_slot[i] & INPUT_POINT_RESET)) { input_report_key( g_input_dev[INPUT_DEVICE_FOR_STYLUS], BTN_TOOL_RUBBER, 0); @@ -616,8 +559,8 @@ void raydium_report_pointer(void *p) continue; } - if (i < spTP->ucTouchCount) { - switch (spTP->ucToolType[i]) { + if (i < sp_tp->uc_touch_count) { + switch (sp_tp->uc_tool_type[i]) { case POINT_TYPE_FINGER: target_device = INPUT_DEVICE_FOR_FINGER; input_report_abs( @@ -641,48 +584,52 @@ void raydium_report_pointer(void *p) default: dev_err(&g_spi->dev, "Raydium - point %d is invalid input tool type: %d\n", - i, spTP->ucToolType[i]); + i, sp_tp->uc_tool_type[i]); break; } input_report_abs(g_input_dev[target_device], ABS_MT_TRACKING_ID, - spTP->ucID[i]); + sp_tp->uc_id[i]); - if (spTP->usX[i] >= (iMaxX - 1)) - input_report_abs(g_input_dev[target_device], - ABS_MT_POSITION_X, - (iMaxX - 1)); + if (sp_tp->us_x[i] >= (i_max_x - 1)) + input_report_abs( + g_input_dev[target_device], + ABS_MT_POSITION_X, + i_max_x - 1); else - input_report_abs(g_input_dev[target_device], - ABS_MT_POSITION_X, - spTP->usX[i]); + input_report_abs( + g_input_dev[target_device], + ABS_MT_POSITION_X, + sp_tp->us_x[i]); - if (spTP->usY[i] >= (iMaxY - 1)) - input_report_abs(g_input_dev[target_device], - ABS_MT_POSITION_Y, - (iMaxY - 1)); + if (sp_tp->us_y[i] >= (i_max_y - 1)) + input_report_abs( + g_input_dev[target_device], + ABS_MT_POSITION_Y, + (i_max_y - 1)); else - input_report_abs(g_input_dev[target_device], - ABS_MT_POSITION_Y, - spTP->usY[i]); + input_report_abs( + g_input_dev[target_device], + ABS_MT_POSITION_Y, + sp_tp->us_y[i]); input_report_abs(g_input_dev[target_device], - ABS_MT_PRESSURE, - spTP->usZ[i]); + ABS_MT_PRESSURE, + sp_tp->us_z[i]); } input_mt_sync(g_input_dev[target_device]); } for (i = 0; i < INPUT_DEVICE_AMOUNT; i++) input_sync(g_input_dev[i]); - ucLastTouchCount = spTP->ucTouchCount; + u8_last_touch_count = sp_tp->uc_touch_count; } #endif - if (g_stCtrl.bfPowerMode) - raydium_change_scan_mode(spTP->ucTouchCount); + if (g_st_ctrl.u8_power_mode) + raydium_change_scan_mode(sp_tp->uc_touch_count); - kfree(spTP); + kfree(sp_tp); } /*============================================================================= @@ -696,8 +643,20 @@ void raydium_report_pointer(void *p) static int rm_tch_read_image_data(unsigned char *p) { int ret; - g_pu8BurstReadBuf = p; - ret = rm_tch_cmd_process(0, g_stRmReadImgCmd, NULL); + g_pu8_burstread_buf = p; + +#if ENABLE_FREQ_HOPPING /*ENABLE_SCAN_DATA_HEADER*/ + g_pu8_burstread_buf[0] = SCAN_TYPE_MT; + g_pu8_burstread_buf[1] = (u8)(g_st_ctrl.u16_data_length >> 8); + g_pu8_burstread_buf[2] = (u8)(g_st_ctrl.u16_data_length); + g_pu8_burstread_buf[3] = g_st_ts.u8_ns_sel; + /*g_pu8_burstread_buf[4] = 0x00;*/ + /*g_pu8_burstread_buf[5] = 0x00;*/ + /*g_pu8_burstread_buf[6] = 0x00;*/ + /*g_pu8_burstread_buf[7] = 0x00;*/ +#endif + + ret = rm_tch_cmd_process(0, g_st_rm_readimg_cmd, NULL); return ret; } @@ -705,113 +664,125 @@ void rm_tch_ctrl_set_baseline(u8 *arg, u16 u16Len) { ssize_t missing; - fgBLUpdated = FALSE; - missing = copy_from_user(g_u8UpdateBaseline, arg, u16Len); + b_bl_updated = FALSE; + missing = copy_from_user(g_u8_update_baseline, arg, u16Len); if (missing) return; - fgBLUpdated = TRUE; + b_bl_updated = TRUE; } static int rm_tch_write_image_data(void) { int ret = RETURN_OK; - ret = rm_tch_cmd_process(0, g_stRmWriteImgCmd, NULL); + ret = rm_tch_cmd_process(0, g_st_rm_writeimg_cmd, NULL); return ret; } +#if ENABLE_FREQ_HOPPING +void rm_set_ns_para(u8 u8Idx, u8 *u8Para) +{ + int ii; +#ifndef INPUT_DEVICE_MULTIPLE_INSTANCES + struct rm_tch_ts *ts = input_get_drvdata(g_input_dev); +#else + struct rm_tch_ts *ts = input_get_drvdata(g_input_dev[0]); +#endif + for (ii = 0; ii < g_st_rm_ns_para_cmd[2]; ii++) { + ts->u8_repeat_counter = u8Para[ii*3+u8Idx]; + rm_tch_cmd_process(ii, g_st_rm_ns_para_cmd, ts); + } +} +#endif + void rm_tch_ctrl_enter_auto_mode(void) { - g_stCtrl.bfIdleModeCheck &= ~0x01; + g_st_ctrl.u8_idle_mode_check &= ~0x01; - if (g_stCtrl.bKernelMsg & DEBUG_DRIVER) - rm_printk("Raydium - Enter Auto Scan Mode\n"); + if (g_st_ctrl.u8_kernel_msg & DEBUG_DRIVER) + rm_printk("Raydium - Enter Auto Scan Mode, bl_update=%d\n", + b_bl_updated); - if (fgBLUpdated) { + if (b_bl_updated) { rm_tch_write_image_data(); - fgBLUpdated = FALSE; + b_bl_updated = FALSE; } - rm_set_repeat_times(g_stCtrl.bIdleDigitalRepeatTimes); - rm_tch_cmd_process(1, g_stCmdSetIdle, NULL); + rm_set_repeat_times(g_st_ctrl.u8_idle_digital_repeat_times); + rm_tch_cmd_process(1, g_st_cmd_set_idle, NULL); } void rm_tch_ctrl_leave_auto_mode(void) { - g_stCtrl.bfIdleModeCheck |= 0x01; + g_st_ctrl.u8_idle_mode_check |= 0x01; - rm_tch_cmd_process(0, g_stCmdSetIdle, NULL); - rm_set_repeat_times(g_stCtrl.bActiveDigitalRepeatTimes); +#if ENABLE_FREQ_HOPPING + if (g_st_ctrl.u8_ns_func_enable&0x01) + rm_set_ns_para(0, (u8 *)&g_st_ts.u8_ns_para[0]); +#endif + rm_tch_cmd_process(0, g_st_cmd_set_idle, NULL); + rm_set_repeat_times(g_st_ctrl.u8_active_digital_repeat_times); - if (g_stCtrl.bKernelMsg & DEBUG_DRIVER) + if (g_st_ctrl.u8_kernel_msg & DEBUG_DRIVER) rm_printk("Raydium - Leave Auto Scan Mode\n"); } void rm_ctrl_pause_auto_mode(void) { - rm_tch_cmd_process(0, g_stCmdPauseAuto, NULL); + rm_tch_cmd_process(0, g_st_cmd_pause_auto, NULL); } int rm_tch_ctrl_clear_int(void) { - return rm_tch_cmd_process(0, g_stRmClearIntCmd, NULL); + return rm_tch_cmd_process(0, g_st_rm_clear_int_cmd, NULL); } -void rm_set_ns_para(u8 u8Idx, u8 u8Para) + +int rm_tch_ctrl_wait_for_scan_finish(u8 u8Idx) { -#ifndef INPUT_DEVICE_MULTIPLE_INSTANCES - struct rm_tch_ts *ts = input_get_drvdata(g_input_dev); -#else - struct rm_tch_ts *ts = input_get_drvdata(g_input_dev[0]); -#endif + int i; - ts->bRepeatCounter = u8Para; + for (i = 0; i < 50; i++) { /*50ms = 20Hz*/ + rm_tch_cmd_process(0, g_st_rm_wait_scan_ok_cmd, NULL); - rm_tch_cmd_process(u8Idx, g_stRmNsParaCmd, ts); + if (g_st_ts.u16_read_para & 0x01) { + if (u8Idx) + return 1; + else + usleep_range(1000, 2000); /* msleep(1); */ + } else + break; + } + return 0; } int rm_tch_ctrl_scan_start(void) { +#if ENABLE_FREQ_HOPPING static u8 u8NsSel = 0, u8Rpt = 1; + if (g_st_ctrl.u8_ns_func_enable&0x01) { + if (rm_tch_ctrl_wait_for_scan_finish(1)) + return rm_tch_cmd_process(0, g_st_rm_scan_start_cmd, + NULL); - if (g_stCtrl.bNsFucnEnable) { - rm_tch_ctrl_wait_for_scan_finish(); + mutex_lock(&g_st_ts.mutex_ns_mode); + g_st_ts.u8_ns_sel = g_st_ts.u8_ns_para[u8NsSel]; - mutex_lock(&g_stTs.mutex_ns_mode); - - g_stTs.bNsSel = g_stTs.bSWCPW[u8NsSel]; - - if (u8NsSel < g_stTs.bNsMode) + if (u8NsSel < g_st_ts.u8_ns_mode) u8NsSel++; else u8NsSel = 0; - if (u8Rpt != g_stTs.bNsRpt) { - u8Rpt = g_stTs.bNsRpt; + if (u8Rpt != g_st_ts.u8_ns_rpt) { + u8Rpt = g_st_ts.u8_ns_rpt; rm_set_repeat_times(u8Rpt); } - rm_set_ns_para(0, g_stTs.bDP[u8NsSel]); - rm_set_ns_para(1, g_stTs.bSWC[u8NsSel]); - rm_set_ns_para(2, g_stTs.bSWCPW[u8NsSel]); + rm_set_ns_para(u8NsSel, (u8 *)&g_st_ts.u8_ns_para[0]); - mutex_unlock(&g_stTs.mutex_ns_mode); - } - - return rm_tch_cmd_process(0, g_stRmScanStartCmd, NULL); -} - -void rm_tch_ctrl_wait_for_scan_finish(void) -{ - int i; - /*50ms = 20Hz*/ - - for (i = 0; i < 50; i++) { - rm_tch_cmd_process(0, g_stRmWaitScanOKCmd, NULL); - if (g_stTs.u16ReadPara & 0x01) - usleep_range(1000, 2000); /* msleep(1); */ - else - break; + mutex_unlock(&g_st_ts.mutex_ns_mode); } +#endif + return rm_tch_cmd_process(0, g_st_rm_scan_start_cmd, NULL); } void rm_set_repeat_times(u8 u8Times) @@ -827,23 +798,24 @@ void rm_set_repeat_times(u8 u8Times) else u8Times = u8Times - 1; - if (u8Times > 31) - u8Times = 31; + if (u8Times > 127) + u8Times = 127; - ts->bRepeatCounter = (u8Times & 0x1F); + /*ts->u8_repeat_counter = (u8Times & 0x1F);*/ + ts->u8_repeat_counter = (u8Times & 0x7F); if (u8Times == 0) - rm_tch_cmd_process(0, g_stRmSetRepTimeCmd, ts); + rm_tch_cmd_process(0, g_st_rm_set_rep_time_cmd, ts); else - rm_tch_cmd_process(1, g_stRmSetRepTimeCmd, ts); + rm_tch_cmd_process(1, g_st_rm_set_rep_time_cmd, ts); } static u32 rm_tch_ctrl_configure(void) { - u32 u32Flag; + u32 u32_flag; - switch (g_stTs.u8ScanModeState) { + switch (g_st_ts.u8_scan_mode_state) { case RM_SCAN_ACTIVE_MODE: - u32Flag = + u32_flag = RM_NEED_TO_SEND_SCAN | RM_NEED_TO_READ_RAW_DATA | RM_NEED_TO_SEND_SIGNAL; @@ -851,25 +823,25 @@ static u32 rm_tch_ctrl_configure(void) case RM_SCAN_PRE_IDLE_MODE: rm_tch_ctrl_enter_auto_mode(); - g_stTs.u8ScanModeState = RM_SCAN_IDLE_MODE; - u32Flag = RM_NEED_NONE; + g_st_ts.u8_scan_mode_state = RM_SCAN_IDLE_MODE; + u32_flag = RM_NEED_NONE; break; case RM_SCAN_IDLE_MODE: rm_tch_ctrl_leave_auto_mode(); - g_stTs.u8ScanModeState = RM_SCAN_ACTIVE_MODE; - u32Flag = RM_NEED_TO_SEND_SCAN; + g_st_ts.u8_scan_mode_state = RM_SCAN_ACTIVE_MODE; + u32_flag = RM_NEED_TO_SEND_SCAN; break; default: - u32Flag = RM_NEED_NONE; + u32_flag = RM_NEED_NONE; break; } - return u32Flag; + return u32_flag; } -int KRL_CMD_CONFIG_1V8_Handler(u8 CMD, u8 OnOff, struct rm_tch_ts *ts) +int KRL_CMD_CONFIG_1V8_Handler(u8 u8_cmd, u8 u8_on_off, struct rm_tch_ts *ts) { int ret = RETURN_FAIL; struct rm_spi_ts_platform_data *pdata; @@ -880,25 +852,19 @@ int KRL_CMD_CONFIG_1V8_Handler(u8 CMD, u8 OnOff, struct rm_tch_ts *ts) pdata = g_input_dev[0]->dev.parent->platform_data; #endif - if (CMD == KRL_SUB_CMD_SET_1V8_REGULATOR) { + if (u8_cmd == KRL_SUB_CMD_SET_1V8_REGULATOR) { if (ts) { if (ts->regulator_1v8) { - if (OnOff) { - if (regulator_is_enabled(ts->regulator_1v8)) - ret = RETURN_OK; - else - ret = regulator_enable( - ts->regulator_1v8); + if (u8_on_off) { + ret = regulator_enable( + ts->regulator_1v8); if (ret) dev_err(&g_spi->dev, "Raydium - regulator 1.8V enable failed: %d\n", ret); } else { - if (!regulator_is_enabled(ts->regulator_1v8)) - ret = RETURN_OK; - else - ret = regulator_disable( - ts->regulator_1v8); + ret = regulator_disable( + ts->regulator_1v8); if (ret) dev_err(&g_spi->dev, "Raydium - regulator 1.8V disable failed: %d\n", @@ -912,13 +878,13 @@ int KRL_CMD_CONFIG_1V8_Handler(u8 CMD, u8 OnOff, struct rm_tch_ts *ts) dev_err(&g_spi->dev, "Raydium - regulator 1.8V ts fail: %d\n", ret); - } else if (CMD == KRL_SUB_CMD_SET_1V8_GPIO) - ret = gpio_direction_output(pdata->gpio_1v8, OnOff); + } else if (u8_cmd == KRL_SUB_CMD_SET_1V8_GPIO) + ret = gpio_direction_output(pdata->gpio_1v8, u8_on_off); return ret; } -int KRL_CMD_CONFIG_3V3_Handler(u8 CMD, u8 OnOff, struct rm_tch_ts *ts) +int KRL_CMD_CONFIG_3V3_Handler(u8 u8_cmd, u8 u8_on_off, struct rm_tch_ts *ts) { int ret = RETURN_FAIL; struct rm_spi_ts_platform_data *pdata; @@ -929,25 +895,19 @@ int KRL_CMD_CONFIG_3V3_Handler(u8 CMD, u8 OnOff, struct rm_tch_ts *ts) pdata = g_input_dev[0]->dev.parent->platform_data; #endif - if (CMD == KRL_SUB_CMD_SET_3V3_REGULATOR) { + if (u8_cmd == KRL_SUB_CMD_SET_3V3_REGULATOR) { if (ts) { if (ts->regulator_3v3) { - if (OnOff) { - if (regulator_is_enabled(ts->regulator_3v3)) - ret = RETURN_OK; - else - ret = regulator_enable( - ts->regulator_3v3); + if (u8_on_off) { + ret = regulator_enable( + ts->regulator_3v3); if (ret) dev_err(&g_spi->dev, "Raydium - regulator 3.3V enable failed: %d\n", ret); } else { - if (!regulator_is_enabled(ts->regulator_3v3)) - ret = RETURN_OK; - else - ret = regulator_disable( - ts->regulator_3v3); + ret = regulator_disable( + ts->regulator_3v3); if (ret) dev_err(&g_spi->dev, "Raydium - regulator 3.3V disable failed: %d\n", @@ -961,13 +921,73 @@ int KRL_CMD_CONFIG_3V3_Handler(u8 CMD, u8 OnOff, struct rm_tch_ts *ts) dev_err(&g_spi->dev, "Raydium - regulator 3.3V ts fail: %d\n", ret); - } else if (CMD == KRL_SUB_CMD_SET_3V3_GPIO) - ret = gpio_direction_output(pdata->gpio_3v3, OnOff); + } else if (u8_cmd == KRL_SUB_CMD_SET_3V3_GPIO) + ret = gpio_direction_output(pdata->gpio_3v3, u8_on_off); return ret; } -static int rm_tch_cmd_process(u8 selCase, u8 *pCmdTbl, struct rm_tch_ts *ts) +void rm_show_kernel_tbl_name(u8 *p_cmd_tbl) +{ + char target_table_name[32]; + + memset(target_table_name, 0, + sizeof(target_table_name)); + + if (p_cmd_tbl == g_st_cmd_set_idle) + snprintf(target_table_name, + sizeof(target_table_name), "Set Idle"); + else if (p_cmd_tbl == g_st_cmd_pause_auto) + snprintf(target_table_name, + sizeof(target_table_name), "Pause Auto"); + else if (p_cmd_tbl == g_st_rm_resume_cmd) + snprintf(target_table_name, + sizeof(target_table_name), "Resume"); + else if (p_cmd_tbl == g_st_rm_suspend_cmd) + snprintf(target_table_name, + sizeof(target_table_name), "Suspend"); + else if (p_cmd_tbl == g_st_rm_readimg_cmd) + snprintf(target_table_name, + sizeof(target_table_name), "Read Image"); + else if (p_cmd_tbl == g_st_rm_watchdog_cmd) + snprintf(target_table_name, + sizeof(target_table_name), "WatchDog"); + else if (p_cmd_tbl == g_st_rm_testmode_cmd) + snprintf(target_table_name, + sizeof(target_table_name), "Test Mode"); + else if (p_cmd_tbl == g_st_rm_slow_scan_cmd) + snprintf(target_table_name, + sizeof(target_table_name), "Slowscan"); + else if (p_cmd_tbl == g_st_rm_clear_int_cmd) + snprintf(target_table_name, + sizeof(target_table_name), "Clear Intterupt"); + else if (p_cmd_tbl == g_st_rm_scan_start_cmd) + snprintf(target_table_name, + sizeof(target_table_name), "Scan Start"); + else if (p_cmd_tbl == g_st_rm_wait_scan_ok_cmd) + snprintf(target_table_name, + sizeof(target_table_name), "Wait Scan Okay"); + else if (p_cmd_tbl == g_st_rm_set_rep_time_cmd) + snprintf(target_table_name, + sizeof(target_table_name), "Set Repeat Time"); + else if (p_cmd_tbl == g_st_rm_ns_para_cmd) + snprintf(target_table_name, + sizeof(target_table_name), "Ns Parameter"); + else if (p_cmd_tbl == g_st_rm_writeimg_cmd) + snprintf(target_table_name, + sizeof(target_table_name), "Write Image"); + else if (p_cmd_tbl == g_st_rm_tlk_cmd) + snprintf(target_table_name, + sizeof(target_table_name), "TLK"); + else { + dev_err(&g_spi->dev, "Raydium - %s : no such kernel table - err:%p\n", + __func__, p_cmd_tbl); + } + dev_err(&g_spi->dev, "Raydium - Table %s cmd failed\n", + target_table_name); +} +static int rm_tch_cmd_process(u8 u8_sel_case, + u8 *p_cmd_tbl, struct rm_tch_ts *ts) { #define _CMD u16j #define _ADDR (u16j+1) @@ -988,118 +1008,143 @@ static int rm_tch_cmd_process(u8 selCase, u8 *pCmdTbl, struct rm_tch_ts *ts) #else pdata = g_input_dev[0]->dev.parent->platform_data; #endif - u16TblLenth = pCmdTbl[KRL_TBL_FIELD_POS_LEN_H]; - u16TblLenth <<= 8; - u16TblLenth |= pCmdTbl[KRL_TBL_FIELD_POS_LEN_L]; + + if (p_cmd_tbl[KRL_TBL_FIELD_POS_LEN_H]) { + u16TblLenth = p_cmd_tbl[KRL_TBL_FIELD_POS_LEN_H]; + u16TblLenth <<= 8; + u16TblLenth |= p_cmd_tbl[KRL_TBL_FIELD_POS_LEN_L]; + } else + u16TblLenth = p_cmd_tbl[KRL_TBL_FIELD_POS_LEN_L]; if (u16TblLenth < 3) { - if (g_stCtrl.bKernelMsg & DEBUG_DRIVER) - dev_info(&g_spi->dev, "Raydium - Null CMD %s : [%p]\n", - __func__, pCmdTbl); + if (g_st_ctrl.u8_kernel_msg & DEBUG_DRIVER) + dev_info(&g_spi->dev, "Raydium - Null u8_cmd %s : [%p]\n", + __func__, p_cmd_tbl); mutex_unlock(&lock); return ret; } u16strIdx = KRL_TBL_FIELD_POS_CASE_NUM - + pCmdTbl[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); + + p_cmd_tbl[KRL_TBL_FIELD_POS_CASE_NUM] + 1; - for (u8i = 0; u8i < pCmdTbl[selCase + KRL_TBL_FIELD_POS_CMD_NUM]; + if (u8_sel_case) { + for (u8i = 0; u8i < u8_sel_case; u8i++) + u16strIdx += (p_cmd_tbl[u8i + KRL_TBL_FIELD_POS_CMD_NUM] + * KRL_TBL_CMD_LEN); + } + + for (u8i = 0; u8i < p_cmd_tbl[u8_sel_case + KRL_TBL_FIELD_POS_CMD_NUM]; u8i++) { u16j = u16strIdx + (KRL_TBL_CMD_LEN * u8i); ret = RETURN_FAIL; - switch (pCmdTbl[_CMD]) { + switch (p_cmd_tbl[_CMD]) { case KRL_CMD_READ: - ret = rm_tch_spi_read(pCmdTbl[_ADDR], &u8reg, 1); - g_stTs.u16ReadPara = u8reg; + ret = rm_tch_spi_read(p_cmd_tbl[_ADDR], &u8reg, 1); + g_st_ts.u16_read_para = u8reg; /*rm_printk("Raydium - KRL_CMD_READ " - "- 0x%x:0x%x\n", pCmdTbl[_ADDR], u8reg);*/ - break; - case KRL_CMD_WRITE_W_DATA: - /*rm_printk("Raydium - KRL_CMD_WRITE_W_DATA " - "- 0x%x:0x%x\n", pCmdTbl[_ADDR], pCmdTbl[_DATA]);*/ - ret = rm_tch_spi_byte_write(pCmdTbl[_ADDR], - pCmdTbl[_DATA]); + "- 0x%x:0x%x\n", p_cmd_tbl[_ADDR], u8reg);*/ break; case KRL_CMD_WRITE_WO_DATA: /*rm_printk("Raydium - KRL_CMD_WRITE_WO_DATA " - "- 0x%x:0x%x\n", pCmdTbl[_ADDR], u8reg);*/ - ret = rm_tch_spi_byte_write(pCmdTbl[_ADDR], u8reg); + "- 0x%x:0x%x\n", p_cmd_tbl[_ADDR], u8reg);*/ + ret = rm_tch_spi_byte_write(p_cmd_tbl[_ADDR], u8reg); break; case KRL_CMD_IF_AND_OR: - if (u8reg & pCmdTbl[_ADDR]) - u8reg |= pCmdTbl[_DATA]; + if (u8reg & p_cmd_tbl[_ADDR]) + u8reg |= p_cmd_tbl[_DATA]; ret = RETURN_OK; break; case KRL_CMD_AND: - u8reg &= pCmdTbl[_DATA]; + u8reg &= p_cmd_tbl[_DATA]; ret = RETURN_OK; break; case KRL_CMD_OR: - u8reg |= pCmdTbl[_DATA]; + u8reg |= p_cmd_tbl[_DATA]; ret = RETURN_OK; break; + case KRL_CMD_DRAM_INIT: + ret = rm_tch_spi_byte_write(0x01, 0x00); + ret = rm_tch_spi_byte_write(0x02, 0x00); + break; + case KRL_CMD_READ_IMG: + /*rm_printk("Raydium - KRL_CMD_READ_IMG " + "- 0x%x:%p:%d\n", + p_cmd_tbl[_ADDR], + g_pu8_burstread_buf, + g_st_ctrl.u16_data_length);*/ + if (g_pu8_burstread_buf != NULL) { + ret = rm_tch_spi_read(p_cmd_tbl[_ADDR], + g_pu8_burstread_buf + QUEUE_HEADER_NUM, + g_st_ctrl.u16_data_length - QUEUE_HEADER_NUM); + } + g_pu8_burstread_buf = NULL; + break; + case KRL_CMD_WRITE_W_DATA: + /*rm_printk("Raydium - KRL_CMD_WRITE_W_DATA " + "- 0x%x:0x%x\n", p_cmd_tbl[_ADDR], p_cmd_tbl[_DATA]);*/ + ret = rm_tch_spi_byte_write(p_cmd_tbl[_ADDR], + p_cmd_tbl[_DATA]); + break; case KRL_CMD_NOT: u8reg = ~u8reg; - //g_stTs.u16ReadPara = u8reg; + /*g_st_ts.u16_read_para = u8reg;*/ ret = RETURN_OK; break; case KRL_CMD_XOR: - u8reg ^= pCmdTbl[_DATA]; + u8reg ^= p_cmd_tbl[_DATA]; ret = RETURN_OK; break; case KRL_CMD_SEND_SIGNAL: - u16Tmp = pCmdTbl[_DATA]; + u16Tmp = p_cmd_tbl[_DATA]; /*rm_printk("Raydium - KRL_CMD_SEND_SIGNAL " "- %d\n", u16Tmp);*/ - ret = rm_tch_ts_send_signal(g_stTs.ulHalPID, + ret = rm_tch_ts_send_signal(g_st_ts.u32_hal_pid, (int)u16Tmp); if (u16Tmp == RM_SIGNAL_RESUME) - g_stTs.u8ResumeCnt++; + g_st_ts.u8_resume_cnt++; break; case KRL_CMD_CONFIG_RST: /*rm_printk("Raydium - KRL_CMD_CONFIG_RST " - "- %d - %d\n", pCmdTbl[_SUB_CMD], pCmdTbl[_DATA]);*/ - switch (pCmdTbl[_SUB_CMD]) { + "- %d - %d\n", p_cmd_tbl[_SUB_CMD], p_cmd_tbl[_DATA]);*/ + switch (p_cmd_tbl[_SUB_CMD]) { case KRL_SUB_CMD_SET_RST_GPIO: ret = gpio_direction_output(pdata->gpio_reset, - pCmdTbl[_DATA]); + p_cmd_tbl[_DATA]); break; case KRL_SUB_CMD_SET_RST_VALUE: gpio_set_value(pdata->gpio_reset, - pCmdTbl[_DATA]); + p_cmd_tbl[_DATA]); ret = RETURN_OK; break; } break; case KRL_CMD_CONFIG_3V3:/*Need to check qpio setting*/ /*rm_printk("Raydium - KRL_CMD_CONFIG_3V3 " - "- %d - %d\n", pCmdTbl[_SUB_CMD], pCmdTbl[_DATA]); + "- %d - %d\n", p_cmd_tbl[_SUB_CMD], p_cmd_tbl[_DATA]); rm_printk("Raydium - 3.3V regulator is %d\n", regulator_is_enabled(ts->regulator_3v3));*/ - ret = KRL_CMD_CONFIG_3V3_Handler(pCmdTbl[_SUB_CMD], - pCmdTbl[_DATA], ts); + ret = KRL_CMD_CONFIG_3V3_Handler(p_cmd_tbl[_SUB_CMD], + p_cmd_tbl[_DATA], ts); /*rm_printk("Raydium - 3.3V regulator is %d\n", regulator_is_enabled(ts->regulator_3v3));*/ break; case KRL_CMD_CONFIG_1V8:/*Need to check qpio setting*/ /*rm_printk("Raydium - KRL_CMD_CONFIG_1V8 " - "- %d - %d\n", pCmdTbl[_SUB_CMD], pCmdTbl[_DATA]); + "- %d - %d\n", p_cmd_tbl[_SUB_CMD], p_cmd_tbl[_DATA]); rm_printk("Raydium - 1.8V regulator is %d\n", regulator_is_enabled(ts->regulator_1v8));*/ - ret = KRL_CMD_CONFIG_1V8_Handler(pCmdTbl[_SUB_CMD], - pCmdTbl[_DATA], ts); + ret = KRL_CMD_CONFIG_1V8_Handler(p_cmd_tbl[_SUB_CMD], + p_cmd_tbl[_DATA], ts); /*rm_printk("Raydium - 1.8V regulator is %d\n", regulator_is_enabled(ts->regulator_1v8));*/ break; case KRL_CMD_CONFIG_CLK: /*rm_printk("Raydium - KRL_CMD_CONFIG_CLK" - " - %d - %d\n", pCmdTbl[_SUB_CMD], pCmdTbl[_DATA]);*/ - if (pCmdTbl[_SUB_CMD] == KRL_SUB_CMD_SET_CLK) { + " - %d - %d\n", p_cmd_tbl[_SUB_CMD], + p_cmd_tbl[_DATA]);*/ + if (p_cmd_tbl[_SUB_CMD] == KRL_SUB_CMD_SET_CLK) { if (ts && ts->clk) { - if (pCmdTbl[_DATA]) + if (p_cmd_tbl[_DATA]) ret = clk_enable(ts->clk); else { clk_disable(ts->clk); @@ -1115,33 +1160,50 @@ static int rm_tch_cmd_process(u8 selCase, u8 *pCmdTbl, struct rm_tch_ts *ts) break; case KRL_CMD_CONFIG_CS: /*rm_printk("Raydium - KRL_CMD_CONFIG_CS " - "- %d - %d\n", pCmdTbl[_SUB_CMD], pCmdTbl[_DATA]);*/ - switch (pCmdTbl[_SUB_CMD]) { + "- %d - %d\n", p_cmd_tbl[_SUB_CMD], p_cmd_tbl[_DATA]);*/ + switch (p_cmd_tbl[_SUB_CMD]) { case KRL_SUB_CMD_SET_CS_LOW: - ret = spi_cs_low(g_spi, (bool)!!pCmdTbl[_DATA]); +#ifdef CS_SUPPORT + /* + * spi_cs_low - set chip select pin state + * @spi: device for which chip select pin state to be set + * state: if true chip select pin will be kept low else + * high + * The return value is zero for success, else + * errno status code. + * + * int spi_cs_low(struct spi_device *spi, bool state) + */ + ret = spi_cs_low(g_spi, + (bool)!!p_cmd_tbl[_DATA]); +#else + ret = RETURN_OK; +#endif break; } break; case KRL_CMD_SET_TIMER: /*rm_printk("Raydium - KRL_CMD_SET_TIMER " - "- %d\n", pCmdTbl[_SUB_CMD]);*/ + "- %d\n", p_cmd_tbl[_SUB_CMD]);*/ ret = RETURN_OK; - if (pCmdTbl[_SUB_CMD] == KRL_SUB_CMD_INIT_TIMER) + if (p_cmd_tbl[_SUB_CMD] == KRL_SUB_CMD_INIT_TIMER) init_ts_timer(); - else if (pCmdTbl[_SUB_CMD] == KRL_SUB_CMD_ADD_TIMER) { + else if (p_cmd_tbl[_SUB_CMD] == KRL_SUB_CMD_ADD_TIMER) { if (!timer_pending(&ts_timer_triggle)) add_timer(&ts_timer_triggle); - } else if (pCmdTbl[_SUB_CMD] == KRL_SUB_CMD_DEL_TIMER) + } else if (p_cmd_tbl[_SUB_CMD] == KRL_SUB_CMD_DEL_TIMER) + /*del_timer of an inactive timer returns 0, + del_timer of an active timer returns 1*/ del_timer(&ts_timer_triggle); else ret = RETURN_FAIL; break; case KRL_CMD_MSLEEP: /*rm_printk("Raydium - KRL_CMD_MSLEEP " - "- %d ms\n", pCmdTbl[_DATA] | - (pCmdTbl[_SUB_CMD] << 8));*/ - u32Tmp = (u16)(pCmdTbl[_DATA] | - (pCmdTbl[_SUB_CMD] << 8)); + "- %d ms\n", p_cmd_tbl[_DATA] | + (p_cmd_tbl[_SUB_CMD] << 8));*/ + u32Tmp = (u16)(p_cmd_tbl[_DATA] | + (p_cmd_tbl[_SUB_CMD] << 8)); u32Tmp *= 1000; usleep_range(u32Tmp, u32Tmp + 200); @@ -1149,75 +1211,76 @@ static int rm_tch_cmd_process(u8 selCase, u8 *pCmdTbl, struct rm_tch_ts *ts) break; case KRL_CMD_FLUSH_QU: /*rm_printk("Raydium - KRL_CMD_FLUSH_QU " - "- %d\n", pCmdTbl[_SUB_CMD]);*/ + "- %d\n", p_cmd_tbl[_SUB_CMD]);*/ ret = RETURN_OK; - if (pCmdTbl[_SUB_CMD] == KRL_SUB_CMD_SENSOR_QU) { - flush_workqueue(g_stTs.rm_workqueue); + if (p_cmd_tbl[_SUB_CMD] == KRL_SUB_CMD_SENSOR_QU) { + flush_workqueue(g_st_ts.rm_workqueue); g_worker_queue_is_flush = true; - } else if (pCmdTbl[_SUB_CMD] == KRL_SUB_CMD_TIMER_QU) { - flush_workqueue(g_stTs.rm_timer_workqueue); + } else if (p_cmd_tbl[_SUB_CMD] == + KRL_SUB_CMD_TIMER_QU) { + flush_workqueue(g_st_ts.rm_timer_workqueue); g_timer_queue_is_flush = true; } else ret = RETURN_FAIL; break; - case KRL_CMD_READ_IMG: - /*rm_printk("Raydium - KRL_CMD_READ_IMG " - "- 0x%x:%p:%d\n", - pCmdTbl[_ADDR], - g_pu8BurstReadBuf, - g_stCtrl.u16DataLength);*/ - if (g_pu8BurstReadBuf != NULL) { - ret = rm_tch_spi_read(pCmdTbl[_ADDR], - g_pu8BurstReadBuf, - g_stCtrl.u16DataLength); - if(g_stCtrl.bNsFucnEnable){ - g_pu8BurstReadBuf[g_stCtrl.u16DataLength] = g_stTs.bNsSel; - /*rm_printk("Raydium -Ns mode:%d,%x,%x\n", - g_stCtrl.u16DataLength,g_pu8BurstReadBuf[g_stCtrl.u16DataLength],g_stTs.bNsSel);*/ - } - } - g_pu8BurstReadBuf = NULL; - break; case KRL_CMD_WRITE_W_COUNT: /*rm_printk("Raydium - KRL_CMD_WRITE_W_COUNT " - "- 0x%x: 0x%x..0x%x\n", pCmdTbl[_ADDR], u8reg, - ts->bRepeatCounter);*/ + "- 0x%x: 0x%x..0x%x\n", p_cmd_tbl[_ADDR], u8reg, + ts->u8_repeat_counter);*/ if (ts) - ret = rm_tch_spi_byte_write(pCmdTbl[_ADDR], - u8reg | (ts->bRepeatCounter)); + ret = rm_tch_spi_byte_write(p_cmd_tbl[_ADDR], + u8reg | (ts->u8_repeat_counter)); else ret = RETURN_FAIL; break; case KRL_CMD_RETURN_RESULT: - g_stTs.u16ReadPara = u8reg; + g_st_ts.u16_read_para = u8reg; ret = RETURN_OK; break; case KRL_CMD_RETURN_VALUE: - g_stTs.u16ReadPara = (pCmdTbl[_ADDR] << 8) + (pCmdTbl[_DATA]); + g_st_ts.u16_read_para = (p_cmd_tbl[_ADDR] << 8) + + (p_cmd_tbl[_DATA]); ret = RETURN_OK; - /*rm_printk("Raydium - KRL_CMD_RETURN_VALUE, value=%d", ret);*/ + /*rm_printk("Raydium - KRL_CMD_RETURN_VALUE, + value=%d", ret);*/ break; case KRL_CMD_WRITE_IMG: - /*rm_printk("Raydium - KRL_CMD_WRITE_IMG - 0x%x:0x%x:%d\n", - pCmdTbl[_ADDR], g_pu8BurstReadBuf, g_stCtrl.u16DataLength);*/ - ret = rm_tch_spi_byte_write(pCmdTbl[_ADDR], g_u8UpdateBaseline[0]); - ret = rm_tch_spi_write(&g_u8UpdateBaseline[1], g_stCtrl.u16DataLength - 1); + /*rm_printk("Raydium - KRL_CMD_WRITE_IMG - + 0x%x:0x%x:%d\n", p_cmd_tbl[_ADDR], g_pu8_burstread_buf, + g_st_ctrl.u16_data_length);*/ + ret = rm_tch_spi_byte_write(p_cmd_tbl[_ADDR], + g_u8_update_baseline[0]); + ret = rm_tch_spi_write(&g_u8_update_baseline[1], + g_st_ctrl.u16_data_length - 1); + break; + case KRL_CMD_CONFIG_IRQ: + if (ts && (p_cmd_tbl[_SUB_CMD] + == KRL_SUB_CMD_SET_IRQ)) { + if (ts->irq) { + if (p_cmd_tbl[_DATA]) + enable_irq(ts->irq); + else + disable_irq(ts->irq); + } else { + dev_err(&g_spi->dev, + "Raydium - %s : No irq handler!\n", + __func__); + } + ret = RETURN_OK; + } else + ret = RETURN_FAIL; break; default: break; } - //if ( (pCmdTbl[_CMD] == KRL_CMD_RETURN_RESULT) || (pCmdTbl[_CMD] == KRL_CMD_RETURN_VALUE)) - // break; - if (ret) { - dev_err(&g_spi->dev, "Raydium - %s : [%p] cmd failed\n", - __func__, - pCmdTbl); - dev_err(&g_spi->dev, "Raydium - cmd:0x%x, addr:0x%x, data:0x%x\n", - pCmdTbl[_CMD], - pCmdTbl[_ADDR], - pCmdTbl[_DATA]); + rm_show_kernel_tbl_name(p_cmd_tbl); + + dev_err(&g_spi->dev, "Raydium - u8_cmd:0x%x, addr:0x%x, data:0x%x\n", + p_cmd_tbl[_CMD], + p_cmd_tbl[_ADDR], + p_cmd_tbl[_DATA]); break; } } @@ -1227,94 +1290,91 @@ static int rm_tch_cmd_process(u8 selCase, u8 *pCmdTbl, struct rm_tch_ts *ts) return ret; } -int rm_set_kernel_tbl(int iFuncIdx, u8 *u8pSrc) +int rm_set_kernel_tbl(int i_func_idx, u8 *p_u8_src) { ssize_t missing; - u16 u16len = 0; - u8 *u8pLen; - u8 *u8pDst; + u16 u16_len = 0; + u8 *p_u8_len; + u8 *p_u8_dst; - switch (iFuncIdx) { + switch (i_func_idx) { case KRL_INDEX_FUNC_SET_IDLE: - u8pDst = g_stCmdSetIdle; + p_u8_dst = g_st_cmd_set_idle; break; case KRL_INDEX_FUNC_PAUSE_AUTO: - u8pDst = g_stCmdPauseAuto; + p_u8_dst = g_st_cmd_pause_auto; break; case KRL_INDEX_RM_RESUME: - u8pDst = g_stRmResumeCmd; + p_u8_dst = g_st_rm_resume_cmd; break; case KRL_INDEX_RM_SUSPEND: - u8pDst = g_stRmSuspendCmd; + p_u8_dst = g_st_rm_suspend_cmd; break; case KRL_INDEX_RM_READ_IMG: - u8pDst = g_stRmReadImgCmd; + p_u8_dst = g_st_rm_readimg_cmd; break; case KRL_INDEX_RM_WATCHDOG: - u8pDst = g_stRmWatchdogCmd; + p_u8_dst = g_st_rm_watchdog_cmd; break; case KRL_INDEX_RM_TESTMODE: - u8pDst = g_stRmTestModeCmd; + p_u8_dst = g_st_rm_testmode_cmd; break; case KRL_INDEX_RM_SLOWSCAN: - u8pDst = g_stRmSlowScanCmd; - break; - case KRL_INDEX_RM_SLOWSCANB: - u8pDst = g_stRmSlowScanBCmd; + p_u8_dst = g_st_rm_slow_scan_cmd; break; case KRL_INDEX_RM_CLEARINT: - u8pDst = g_stRmClearIntCmd; + p_u8_dst = g_st_rm_clear_int_cmd; break; case KRL_INDEX_RM_SCANSTART: - u8pDst = g_stRmScanStartCmd; + p_u8_dst = g_st_rm_scan_start_cmd; break; case KRL_INDEX_RM_WAITSCANOK: - u8pDst = g_stRmWaitScanOKCmd; + p_u8_dst = g_st_rm_wait_scan_ok_cmd; break; case KRL_INDEX_RM_SETREPTIME: - u8pDst = g_stRmSetRepTimeCmd; + p_u8_dst = g_st_rm_set_rep_time_cmd; break; case KRL_INDEX_RM_NSPARA: - u8pDst = g_stRmNsParaCmd; + p_u8_dst = g_st_rm_ns_para_cmd; break; case KRL_INDEX_RM_WRITE_IMG: - u8pDst = g_stRmWriteImgCmd; + p_u8_dst = g_st_rm_writeimg_cmd; + break; + case KRL_INDEX_RM_TLK: + p_u8_dst = g_st_rm_tlk_cmd; break; - default: dev_err(&g_spi->dev, "Raydium - %s : no such kernel table - err:%d\n", - __func__, iFuncIdx); + __func__, i_func_idx); return RETURN_FAIL; } - u8pLen = kmalloc(KRL_TBL_FIELD_POS_CASE_NUM, GFP_KERNEL); - if (u8pLen == NULL) + p_u8_len = kmalloc(KRL_TBL_FIELD_POS_CASE_NUM, GFP_KERNEL); + if (p_u8_len == NULL) return RETURN_FAIL; - missing = copy_from_user(u8pLen, u8pSrc, KRL_TBL_FIELD_POS_CASE_NUM); + missing = copy_from_user(p_u8_len, p_u8_src, + KRL_TBL_FIELD_POS_CASE_NUM); if (missing) { dev_err(&g_spi->dev, "Raydium - %s : copy failed - len:%d, miss:%d\n", __func__, KRL_TBL_FIELD_POS_CASE_NUM, missing); - kfree(u8pLen); + kfree(p_u8_len); return missing; } - u16len = u8pLen[KRL_TBL_FIELD_POS_LEN_H]; - u16len <<= 8; - u16len |= u8pLen[KRL_TBL_FIELD_POS_LEN_L]; + u16_len = p_u8_len[KRL_TBL_FIELD_POS_LEN_H]; + u16_len <<= 8; + u16_len |= p_u8_len[KRL_TBL_FIELD_POS_LEN_L]; - missing = copy_from_user(u8pDst, u8pSrc, u16len); + missing = copy_from_user(p_u8_dst, p_u8_src, u16_len); if (missing) { dev_err(&g_spi->dev, "Raydium - %s : copy failed - len:%d, miss:%d\n", - __func__, u16len, missing); - kfree(u8pLen); + __func__, u16_len, missing); + kfree(p_u8_len); return missing; } - /*dev_info(&g_spi->dev, "Raydium - %s : CMD_TAB_%d[%p]\n", - __func__, iFuncIdx, u8pDst);*/ - - kfree(u8pLen); + kfree(p_u8_len); return RETURN_OK; } /*============================================================================= @@ -1322,29 +1382,29 @@ int rm_set_kernel_tbl(int iFuncIdx, u8 *u8pSrc) =============================================================================*/ static void rm_tch_enter_manual_mode(void) { - flush_workqueue(g_stTs.rm_workqueue); + flush_workqueue(g_st_ts.rm_workqueue); - mutex_lock(&g_stTs.mutex_scan_mode); - if (g_stTs.u8ScanModeState == RM_SCAN_ACTIVE_MODE) { - mutex_unlock(&g_stTs.mutex_scan_mode); + mutex_lock(&g_st_ts.mutex_scan_mode); + if (g_st_ts.u8_scan_mode_state == RM_SCAN_ACTIVE_MODE) { + mutex_unlock(&g_st_ts.mutex_scan_mode); return; } - if (g_stTs.u8ScanModeState == RM_SCAN_PRE_IDLE_MODE) { - g_stTs.u8ScanModeState = RM_SCAN_ACTIVE_MODE; - mutex_unlock(&g_stTs.mutex_scan_mode); + if (g_st_ts.u8_scan_mode_state == RM_SCAN_PRE_IDLE_MODE) { + g_st_ts.u8_scan_mode_state = RM_SCAN_ACTIVE_MODE; + mutex_unlock(&g_st_ts.mutex_scan_mode); return; } - if (g_stTs.u8ScanModeState == RM_SCAN_IDLE_MODE) { + if (g_st_ts.u8_scan_mode_state == RM_SCAN_IDLE_MODE) { rm_tch_ctrl_leave_auto_mode(); - g_stTs.u8ScanModeState = RM_SCAN_ACTIVE_MODE; + g_st_ts.u8_scan_mode_state = RM_SCAN_ACTIVE_MODE; usleep_range(10000, 10050);/*msleep(10);*/ } - mutex_unlock(&g_stTs.mutex_scan_mode); + mutex_unlock(&g_st_ts.mutex_scan_mode); } -static u32 rm_tch_get_platform_id(u32 *p) +static u32 rm_tch_get_platform_id(u8 *p) { u32 u32Ret; struct rm_spi_ts_platform_data *pdata; @@ -1362,23 +1422,24 @@ static u32 rm_tch_get_platform_id(u32 *p) static u32 rm_tch_get_gpio_sensor_select(u8 *p) { u32 u32Ret = 0; - struct rm_spi_ts_platform_data *pdata; + struct rm_spi_ts_platform_data *pdata; #ifndef INPUT_DEVICE_MULTIPLE_INSTANCES - pdata = g_input_dev->dev.parent->platform_data; + pdata = g_input_dev->dev.parent->platform_data; #else - pdata = g_input_dev[0]->dev.parent->platform_data; + pdata = g_input_dev[0]->dev.parent->platform_data; #endif /* Read from GPIO - u32Ret = gpio_set_value(pdata->gpio_sensor_select0) - | (1 << gpio_set_value(pdata->gpio_sensor_select1)); + u32Ret = gpio_set_value(pdata->gpio_sensor_select0) + | (1 << gpio_set_value(pdata->gpio_sensor_select1)); */ -/* Read from data struct */ + + /* Read from data struct */ if (pdata->gpio_sensor_select0) u32Ret |= 0x01; if (pdata->gpio_sensor_select1) u32Ret |= 0x02; - if (g_stCtrl.bKernelMsg & DEBUG_DRIVER) + if (g_st_ctrl.u8_kernel_msg & DEBUG_DRIVER) rm_printk("Raydium - %s : %d\n", __func__, u32Ret); @@ -1391,33 +1452,20 @@ static u32 rm_tch_get_spi_lock_status(u8 *p) { u32 u32Ret; - if (g_stCtrl.bKernelMsg & DEBUG_DRIVER) - rm_printk("Raydium - SPI_LOCK = %d\n", g_stTs.u8SPILocked); + if (g_st_ctrl.u8_kernel_msg & DEBUG_DRIVER) + rm_printk("Raydium - SPI_LOCK = %d\n", g_st_ts.u8_spi_locked); - u32Ret = copy_to_user(p, &g_stTs.u8SPILocked, - sizeof(g_stTs.u8SPILocked)); + u32Ret = copy_to_user(p, &g_st_ts.u8_spi_locked, + sizeof(g_st_ts.u8_spi_locked)); - if (g_stTs.u8SPILocked && g_stTs.u8ResumeCnt) - g_stTs.u8ResumeCnt--; - - return u32Ret; -} - -static u32 rm_tch_get_report_mode(u8 *p) -{ - u32 u32Ret; - - if (g_stCtrl.bKernelMsg & DEBUG_DRIVER) - rm_printk("Raydium - REPORT_MODE = %d\n", g_stTs.u8ReportMode); - - u32Ret = copy_to_user(p, &g_stTs.u8ReportMode, - sizeof(g_stTs.u8ReportMode)); + if (g_st_ts.u8_spi_locked && g_st_ts.u8_resume_cnt) + g_st_ts.u8_resume_cnt--; return u32Ret; } /*===========================================================================*/ -static int rm_tch_ts_send_signal(int pid, int iInfo) +static int rm_tch_ts_send_signal(int pid, int i_info) { struct siginfo info; struct task_struct *t; @@ -1442,7 +1490,7 @@ static int rm_tch_ts_send_signal(int pid, int iInfo) 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.*/ + info.si_int = i_info; /*real time signals may have 32 bits of data.*/ rcu_read_lock(); t = find_task_by_vpid(pid); @@ -1451,8 +1499,7 @@ static int rm_tch_ts_send_signal(int pid, int iInfo) dev_err(&g_spi->dev, "Raydium - %s : no such pid\n", __func__); mutex_unlock(&lock); return RETURN_FAIL; - } else - /*send the signal*/ + } else /*send the signal*/ ret = send_sig_info(RM_TS_SIGNAL, &info, t); if (ret) @@ -1474,15 +1521,16 @@ static int rm_tch_ts_send_signal(int pid, int iInfo) =============================================================================*/ static void rm_tch_queue_reset(void) { - g_stQ.u16Rear = 0; - g_stQ.u16Front = 0; + g_st_q.u16_rear = 0; + g_st_q.u16_front = 0; } static int rm_tch_queue_init(void) { rm_tch_queue_reset(); - g_stQ.pQueue = kmalloc(QUEUE_COUNT * RM_RAW_DATA_LENGTH, GFP_KERNEL); - if (g_stQ.pQueue == NULL) + g_st_q.p_u8_queue = kmalloc(QUEUE_COUNT * RM_RAW_DATA_LENGTH, + GFP_KERNEL); + if (g_st_q.p_u8_queue == NULL) return -ENOMEM; return RETURN_OK; @@ -1490,19 +1538,19 @@ static int rm_tch_queue_init(void) static void rm_tch_queue_free(void) { - if (!g_stQ.pQueue) + if (!g_st_q.p_u8_queue) return; - kfree(g_stQ.pQueue); - g_stQ.pQueue = NULL; + kfree(g_st_q.p_u8_queue); + g_st_q.p_u8_queue = NULL; } #ifdef ENABLE_CALC_QUEUE_COUNT static int rm_tch_queue_get_current_count(void) { - if (g_stQ.u16Rear >= g_stQ.u16Front) - return g_stQ.u16Rear - g_stQ.u16Front; + if (g_st_q.u16_rear >= g_st_q.u16_front) + return g_st_q.u16_rear - g_st_q.u16_front; - return (QUEUE_COUNT - g_stQ.u16Front) + g_stQ.u16Rear; + return (QUEUE_COUNT - g_st_q.u16_front) + g_st_q.u16_rear; } #endif @@ -1524,7 +1572,7 @@ static int rm_tch_queue_get_current_count(void) =============================================================================*/ static int rm_tch_queue_is_empty(void) { - if (g_stQ.u16Rear == g_stQ.u16Front) + if (g_st_q.u16_rear == g_st_q.u16_front) return TRUE; return FALSE; } @@ -1540,12 +1588,12 @@ static int rm_tch_queue_is_empty(void) =============================================================================*/ static int rm_tch_queue_is_full(void) { - u16 u16Front = g_stQ.u16Front; + u16 u16_front = g_st_q.u16_front; - if (g_stQ.u16Rear + 1 == u16Front) + if (g_st_q.u16_rear + 1 == u16_front) return TRUE; - if ((g_stQ.u16Rear == (QUEUE_COUNT - 1)) && (u16Front == 0)) + if ((g_st_q.u16_rear == (QUEUE_COUNT - 1)) && (u16_front == 0)) return TRUE; return FALSE; @@ -1553,12 +1601,12 @@ static int rm_tch_queue_is_full(void) static void *rm_tch_enqueue_start(void) { - if (!g_stQ.pQueue) /*error handling for no memory*/ + if (!g_st_q.p_u8_queue) /*error handling for no memory*/ return NULL; if (!rm_tch_queue_is_full()) { - g_service_busy_report_count = 100 ; - return &g_stQ.pQueue[g_stQ.u16Rear]; + g_service_busy_report_count = 100; + return &g_st_q.p_u8_queue[g_st_q.u16_rear]; } if (g_service_busy_report_count < 0) { @@ -1572,37 +1620,37 @@ static void *rm_tch_enqueue_start(void) static void rm_tch_enqueue_finish(void) { - if (g_stQ.u16Rear == (QUEUE_COUNT - 1)) - g_stQ.u16Rear = 0; + if (g_st_q.u16_rear == (QUEUE_COUNT - 1)) + g_st_q.u16_rear = 0; else - g_stQ.u16Rear++; + g_st_q.u16_rear++; } static void *rm_tch_dequeue_start(void) { if (!rm_tch_queue_is_empty()) - return &g_stQ.pQueue[g_stQ.u16Front]; + return &g_st_q.p_u8_queue[g_st_q.u16_front]; return NULL; } static void rm_tch_dequeue_finish(void) { - if (g_stQ.u16Front == (QUEUE_COUNT - 1)) - g_stQ.u16Front = 0; + if (g_st_q.u16_front == (QUEUE_COUNT - 1)) + g_st_q.u16_front = 0; else - g_stQ.u16Front++; + g_st_q.u16_front++; } static long rm_tch_queue_read_raw_data(u8 *p, u32 u32Len) { - u8 *pQueue; + u8 *p_u8_queue; u32 u32Ret; - pQueue = rm_tch_dequeue_start(); - if (!pQueue) + p_u8_queue = rm_tch_dequeue_start(); + if (!p_u8_queue) return RETURN_FAIL; - u32Ret = copy_to_user(p, pQueue, u32Len); + u32Ret = copy_to_user(p, p_u8_queue, u32Len); if (u32Ret) return RETURN_FAIL; @@ -1612,130 +1660,123 @@ static long rm_tch_queue_read_raw_data(u8 *p, u32 u32Len) /*===========================================================================*/ static void rm_work_handler(struct work_struct *work) { - void *pKernelBuffer; - u32 u32Flag; - int iRet; + void *p_kernel_buffer; + u32 u32_flag; + int i_ret; - if (g_stTs.bInitFinish == false || g_stTs.bIsSuspended) + if (!g_st_ts.b_init_finish + || g_st_ts.b_is_suspended + || g_worker_queue_is_flush) return; - if (g_worker_queue_is_flush == true) - return; + mutex_lock(&g_st_ts.mutex_scan_mode); - mutex_lock(&g_stTs.mutex_scan_mode); + i_ret = rm_tch_ctrl_clear_int(); - iRet = rm_tch_ctrl_clear_int(); + u32_flag = rm_tch_ctrl_configure(); - u32Flag = rm_tch_ctrl_configure(); - - if (u32Flag & RM_NEED_TO_SEND_SCAN) { -#ifdef ENABLE_SLOW_SCAN - if (g_stTs.bEnableSlowScan == true) { - rm_tch_cmd_process((u8)(g_stTs.u32SlowScanLevel - 1), - g_stRmSlowScanBCmd, NULL); - //rm_printk("##Raydium - ENABLE_SLOW_SCAN, value = %d", g_stTs.u16ReadPara); - usleep_range(g_stTs.u16ReadPara, g_stTs.u16ReadPara + 30); - } -#endif + if (u32_flag & RM_NEED_TO_SEND_SCAN) rm_tch_ctrl_scan_start(); - } - if (u32Flag & RM_NEED_TO_READ_RAW_DATA) { - pKernelBuffer = rm_tch_enqueue_start(); - if (pKernelBuffer) { - iRet = rm_tch_read_image_data((u8 *) pKernelBuffer); - if (!iRet) + if (u32_flag & RM_NEED_TO_READ_RAW_DATA) { + p_kernel_buffer = rm_tch_enqueue_start(); + if (p_kernel_buffer) { + i_ret = rm_tch_read_image_data((u8 *) p_kernel_buffer); + if (!i_ret) rm_tch_enqueue_finish(); } } - mutex_unlock(&g_stTs.mutex_scan_mode); + mutex_unlock(&g_st_ts.mutex_scan_mode); - if (u32Flag & RM_NEED_TO_SEND_SIGNAL) { - if (g_stTs.bCalcFinish) { - g_stTs.bCalcFinish = 0; - rm_tch_ts_send_signal(g_stTs.ulHalPID, RM_SIGNAL_INTR); + if (u32_flag & RM_NEED_TO_SEND_SIGNAL) { + if (g_st_ts.b_calc_finish) { + g_st_ts.b_calc_finish = 0; + rm_tch_ts_send_signal(g_st_ts.u32_hal_pid, + RM_SIGNAL_INTR); } } } static void rm_tch_init_ts_structure_part(void) { - g_stTs.bInitFinish = 0; - g_stTs.bCalcFinish = 0; - g_stTs.bEnableScriber = 0; - g_stTs.bIsSuspended = 0; + g_st_ts.b_init_finish = 0; + g_st_ts.b_calc_finish = 0; + g_st_ts.b_enable_scriber = 0; + g_st_ts.b_is_suspended = 0; #ifdef ENABLE_SLOW_SCAN - g_stTs.bEnableSlowScan = false; + g_st_ts.b_enable_slow_scan = false; #endif - g_stTs.u8ScanModeState = RM_SCAN_ACTIVE_MODE; - g_stTs.u8ReportMode = EVENT_REPORT_MODE_STYLUS_ERASER_FINGER; + g_st_ts.u8_scan_mode_state = RM_SCAN_ACTIVE_MODE; + g_st_ctrl.u8_event_report_mode = EVENT_REPORT_MODE_STYLUS_ERASER_FINGER; - g_pu8BurstReadBuf = NULL; + g_pu8_burstread_buf = NULL; g_worker_queue_is_flush = false; g_timer_queue_is_flush = false; - g_stTs.u16ReadPara = 0; + g_st_ts.u16_read_para = 0; rm_ctrl_watchdog_func(0); rm_tch_ctrl_init(); - fgBLUpdated = false; + b_bl_updated = false; } + /*===========================================================================*/ -static void rm_ctrl_watchdog_func(unsigned int u32Enable) +static void rm_ctrl_watchdog_func(unsigned int u32_enable) { - g_stTs.u8WatchDogFlg = 0; - g_stTs.u32WatchDogCnt = 0; - g_stTs.u8WatchDogCheck = 0; + g_st_ts.u8_watch_dog_flg = 0; + g_st_ts.u32_watch_dog_cnt = 0; + g_st_ts.b_watch_dog_check = 0; - g_stTs.u8WatchDogEnable = u32Enable & 0x01; - g_stTs.u32WatchDogTime = u32Enable >> 16; + g_st_ts.u8_watch_dog_enable = u32_enable & 0x01; + g_st_ts.u32_watch_dog_time = u32_enable >> 16; - if (u32Enable&0x01) { - g_stTs.u8WatchDogEnable = 1; - g_stTs.u32WatchDogTime = u32Enable >> 16; + if (u32_enable&0x01) { + g_st_ts.u8_watch_dog_enable = 1; + g_st_ts.u32_watch_dog_time = u32_enable >> 16; } else { - g_stTs.u8WatchDogEnable = 0; - g_stTs.u32WatchDogTime = 0xFFFFFFFF; + g_st_ts.u8_watch_dog_enable = 0; + g_st_ts.u32_watch_dog_time = 0xFFFFFFFF; } - if (g_stCtrl.bKernelMsg & DEBUG_DRIVER) + if (g_st_ctrl.u8_kernel_msg & DEBUG_DRIVER) rm_printk("Raydium - WatchDogEnable=%d, WatchDogTime=%d\n", - g_stTs.u8WatchDogEnable, g_stTs.u32WatchDogTime); - + g_st_ts.u8_watch_dog_enable, + g_st_ts.u32_watch_dog_time); } static void rm_watchdog_work_function(unsigned char scan_mode) { - if ((g_stTs.u8WatchDogEnable == 0) || (g_stTs.bInitFinish == 0)) + if ((g_st_ts.u8_watch_dog_enable == 0) || + (g_st_ts.b_init_finish == 0)) return; - if (g_stTs.u32WatchDogCnt++ >= g_stTs.u32WatchDogTime) { - if (g_stCtrl.bKernelMsg & DEBUG_DRIVER) + if (g_st_ts.u32_watch_dog_cnt++ >= g_st_ts.u32_watch_dog_time) { + if (g_st_ctrl.u8_kernel_msg & DEBUG_DRIVER) rm_printk("Raydium - watchdog work: Time:%dsec Cnt:%d,Flg:%d(%x)\n", - g_stTs.u32WatchDogTime, - g_stTs.u32WatchDogCnt, - g_stTs.u8WatchDogFlg, - g_stTs.u8ScanModeState); + g_st_ts.u32_watch_dog_time, + g_st_ts.u32_watch_dog_cnt, + g_st_ts.u8_watch_dog_flg, + g_st_ts.u8_scan_mode_state); switch (scan_mode) { case RM_SCAN_ACTIVE_MODE: - g_stTs.u32WatchDogCnt = 0; - g_stTs.u8WatchDogFlg = 1; + g_st_ts.u32_watch_dog_cnt = 0; + g_st_ts.u8_watch_dog_flg = 1; break; case RM_SCAN_IDLE_MODE: - g_stTs.u32WatchDogCnt = 0; - g_stTs.u8WatchDogCheck = 1; + g_st_ts.u32_watch_dog_cnt = 0; + g_st_ts.b_watch_dog_check = 1; break; } } - if (g_stTs.u8WatchDogFlg) { + if (g_st_ts.u8_watch_dog_flg) { /*WATCH DOG RESET*/ rm_printk("Raydium - WatchDog Resume\n"); rm_tch_init_ts_structure_part(); - g_stTs.bIsSuspended = true; - rm_tch_cmd_process(0, g_stRmWatchdogCmd, NULL); - g_stTs.bIsSuspended = false; + g_st_ts.b_is_suspended = true; + rm_tch_cmd_process(0, g_st_rm_watchdog_cmd, NULL); + g_st_ts.b_is_suspended = false; return; } @@ -1745,47 +1786,48 @@ static u8 rm_timer_trigger_function(void) { static u32 u32TimerCnt; /*= 0; remove by checkpatch*/ - if (u32TimerCnt++ < g_stCtrl.bTimerTriggerScale) { + if (u32TimerCnt++ < g_st_ctrl.u8_timer_trigger_scale) { return FALSE; } else { /*rm_printk("Raydium - rm_timer_work_handler:%x,%x\n", - g_stCtrl.bTimerTriggerScale, u32TimerCnt);*/ + g_st_ctrl.u8_timer_trigger_scale, u32TimerCnt);*/ u32TimerCnt = 0; return TRUE; } - } static void rm_timer_work_handler(struct work_struct *work) { static u16 u32TimerCnt; /*= 0; remove by checkpatch*/ - if (g_stTs.bIsSuspended) + if (g_st_ts.b_is_suspended) return; if (g_timer_queue_is_flush == true) return; - mutex_lock(&g_stTs.mutex_scan_mode); + mutex_lock(&g_st_ts.mutex_scan_mode); if (rm_timer_trigger_function()) { - if (g_stTs.u8ScanModeState != RM_SCAN_ACTIVE_MODE) + if (g_st_ts.u8_scan_mode_state != RM_SCAN_ACTIVE_MODE) rm_watchdog_work_function(RM_SCAN_IDLE_MODE); else rm_watchdog_work_function(RM_SCAN_ACTIVE_MODE); } - mutex_unlock(&g_stTs.mutex_scan_mode); + mutex_unlock(&g_st_ts.mutex_scan_mode); - if (g_stTs.u8WatchDogCheck == 1) { - rm_tch_ts_send_signal(g_stTs.ulHalPID, + if (g_st_ts.b_watch_dog_check == 1) { + rm_tch_ts_send_signal(g_st_ts.u32_hal_pid, RM_SIGNAL_WATCH_DOG_CHECK); - g_stTs.u8WatchDogCheck = 0; + g_st_ts.b_watch_dog_check = 0; } - if (g_stTs.u8WatchDogEnable) { + if (g_st_ts.u8_watch_dog_enable) { u32TimerCnt++; - if (u32TimerCnt > g_stTs.u32WatchDogTime && - g_stTs.u32WatchDogTime != g_stCtrl.bWatchDogNormalCnt) { - g_stTs.u32WatchDogTime = g_stCtrl.bWatchDogNormalCnt; - if (g_stCtrl.bKernelMsg & DEBUG_DRIVER) + if (u32TimerCnt > g_st_ts.u32_watch_dog_time && + g_st_ts.u32_watch_dog_time != + g_st_ctrl.u8_watch_dog_normal_cnt) { + g_st_ts.u32_watch_dog_time = + g_st_ctrl.u8_watch_dog_normal_cnt; + if (g_st_ctrl.u8_kernel_msg & DEBUG_DRIVER) rm_printk("Raydium - WDT:Normal mode\n"); u32TimerCnt = 0; } @@ -1822,47 +1864,40 @@ static void rm_tch_disable_irq(struct rm_tch_ts *ts) * N/A * Output: * N/A - *============================================================================= -*/ + *===========================================================================*/ static void rm_tch_ctrl_slowscan(u32 level) { - if (g_stTs.u8ScanModeState == RM_SCAN_IDLE_MODE) { + if (g_st_ts.u8_scan_mode_state == RM_SCAN_IDLE_MODE) rm_tch_ctrl_leave_auto_mode(); - rm_ctrl_pause_auto_mode(); - } - rm_tch_ctrl_wait_for_scan_finish(); + rm_tch_ctrl_wait_for_scan_finish(0); if (level == RM_SLOW_SCAN_LEVEL_NORMAL) level = RM_SLOW_SCAN_LEVEL_20; - if (level > RM_SLOW_SCAN_LEVEL_100) level = RM_SLOW_SCAN_LEVEL_MAX; - rm_tch_cmd_process((u8)(level - 1), g_stRmSlowScanCmd, NULL); + rm_tch_cmd_process((u8)(level - 1), + g_st_rm_slow_scan_cmd, NULL); - rm_printk("Raydium - rm_tch_ctrl_slowscan:%x,%x,%x\n", - (level - 1), - g_stRmSlowScanCmd[0], - g_stRmSlowScanCmd[1]); + rm_printk("Raydium - rm_tch_ctrl_slowscan:%x\n", (level - 1)); - if (g_stTs.u8ScanModeState == RM_SCAN_IDLE_MODE) { + if (g_st_ts.u8_scan_mode_state == RM_SCAN_IDLE_MODE) rm_tch_ctrl_enter_auto_mode(); - usleep_range(1000, 1200); - rm_tch_ctrl_scan_start(); - } } static u32 rm_tch_slowscan_round(u32 val) { u32 i; + for (i = 0; i < RM_SLOW_SCAN_LEVEL_COUNT; i++) { if ((i * RM_SLOW_SCAN_INTERVAL) >= val) break; } - if(i > RM_SLOW_SCAN_LEVEL_MAX) + + if (i > RM_SLOW_SCAN_LEVEL_MAX) i = RM_SLOW_SCAN_LEVEL_MAX; - + return i; } @@ -1877,16 +1912,16 @@ static ssize_t rm_tch_slowscan_handler(const char *buf, size_t count) ret = (ssize_t) count; - mutex_lock(&g_stTs.mutex_scan_mode); + mutex_lock(&g_st_ts.mutex_scan_mode); if (count == 2) { if (buf[0] == '0') { - g_stTs.bEnableSlowScan = false; + g_st_ts.b_enable_slow_scan = false; rm_tch_ctrl_slowscan(RM_SLOW_SCAN_LEVEL_MAX); } else if (buf[0] == '1') { - g_stTs.bEnableSlowScan = true; + g_st_ts.b_enable_slow_scan = true; rm_tch_ctrl_slowscan(RM_SLOW_SCAN_LEVEL_60); - g_stTs.u32SlowScanLevel = RM_SLOW_SCAN_LEVEL_60; + g_st_ts.u32_slow_scan_level = RM_SLOW_SCAN_LEVEL_60; } } else if ((buf[0] == '2') && (buf[1] == ' ')) { error = kstrtoul(&buf[2], 10, &val); @@ -1894,13 +1929,14 @@ static ssize_t rm_tch_slowscan_handler(const char *buf, size_t count) if (error) { ret = error; } else { - g_stTs.bEnableSlowScan = true; - g_stTs.u32SlowScanLevel = rm_tch_slowscan_round((u32)val); - rm_tch_ctrl_slowscan(g_stTs.u32SlowScanLevel); + g_st_ts.b_enable_slow_scan = true; + g_st_ts.u32_slow_scan_level = + rm_tch_slowscan_round((u32)val); + rm_tch_ctrl_slowscan(g_st_ts.u32_slow_scan_level); } } - mutex_unlock(&g_stTs.mutex_scan_mode); + mutex_unlock(&g_st_ts.mutex_scan_mode); return ret; } #endif @@ -1910,9 +1946,9 @@ static ssize_t rm_tch_slowscan_show(struct device *dev, { #ifdef ENABLE_SLOW_SCAN return sprintf(buf, "Slow Scan:%s\nScan Rate:%dHz\n", - g_stTs.bEnableSlowScan ? + g_st_ts.b_enable_slow_scan ? "Enabled" : "Disabled", - g_stTs.u32SlowScanLevel * RM_SLOW_SCAN_INTERVAL); + g_st_ts.u32_slow_scan_level * RM_SLOW_SCAN_INTERVAL); #else return sprintf(buf, "Not implemented yet\n"); #endif @@ -1931,18 +1967,18 @@ static ssize_t rm_tch_slowscan_store(struct device *dev, static void rm_tch_smooth_level_change(unsigned long val) { - int iInfo; + int i_info; if (val > RM_SMOOTH_LEVEL_MAX) return; - g_stTs.u32SmoothLevel = val; + g_st_ts.u32_smooth_level = val; - iInfo = (RM_SIGNAL_PARA_SMOOTH << 24) | + i_info = (RM_SIGNAL_PARA_SMOOTH << 24) | (val << 16) | RM_SIGNAL_CHANGE_PARA; - rm_tch_ts_send_signal(g_stTs.ulHalPID, iInfo); + rm_tch_ts_send_signal(g_st_ts.u32_hal_pid, i_info); } static ssize_t rm_tch_smooth_level_handler(const char *buf, size_t count) @@ -1969,7 +2005,7 @@ 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); + return sprintf(buf, "Smooth level:%d\n", g_st_ts.u32_smooth_level); } static ssize_t rm_tch_smooth_level_store(struct device *dev, @@ -1986,19 +2022,19 @@ static ssize_t rm_tch_self_test_handler(struct rm_tch_ts *ts, unsigned long val; ssize_t error; ssize_t ret; - int iInfo; + int i_info; ret = (ssize_t) count; if (count != 2) return -EINVAL; - if (g_stTs.u8SelfTestStatus == RM_SELF_TEST_STATUS_TESTING) + if (g_st_ts.u8_selftest_status == RM_SELF_TEST_STATUS_TESTING) return ret; rm_tch_enter_test_mode(1); - g_stTs.u8SelfTestResult = RM_SELF_TEST_RESULT_PASS; + g_st_ts.u8_selftest_result = RM_SELF_TEST_RESULT_PASS; error = kstrtoul(buf, 10, &val); @@ -2008,20 +2044,46 @@ static ssize_t rm_tch_self_test_handler(struct rm_tch_ts *ts, } else if (val == 0) { rm_tch_enter_test_mode(0); } else if ((val >= 0x01) && (val <= 0xFF)) { - iInfo = (RM_SIGNAL_PARA_SELF_TEST << 24) | + i_info = (RM_SIGNAL_PARA_SELF_TEST << 24) | (val << 16) | RM_SIGNAL_CHANGE_PARA; - rm_tch_ts_send_signal(g_stTs.ulHalPID, iInfo); + rm_tch_ts_send_signal(g_st_ts.u32_hal_pid, i_info); } return ret; } +static ssize_t selftest_platform_id_gpio_set(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + return count; +} +static ssize_t selftest_platform_id_gpio_get(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct rm_spi_ts_platform_data *pdata; + +#ifndef INPUT_DEVICE_MULTIPLE_INSTANCES + pdata = g_input_dev->dev.parent->platform_data; +#else + pdata = g_input_dev[0]->dev.parent->platform_data; +#endif + buf[0] = (char)pdata->platform_id; + + /* Read from data struct */ + if (pdata->gpio_sensor_select0) + buf[1] = 0; + if (pdata->gpio_sensor_select1) + buf[1] = 1; + return 2; +} static ssize_t selftest_enable_set(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - //rm_printk("enter test mode buf[0] = %d", buf[0]); + rm_printk("enter test mode buf[0] = %d\n", buf[0]); rm_tch_enter_test_mode(buf[0]); return count; } @@ -2038,8 +2100,8 @@ static ssize_t rm_tch_self_test_show(struct device *dev, char *buf) { return sprintf(buf, "Self_Test:Status:%d ,Result:%d\n", - g_stTs.u8SelfTestStatus, - g_stTs.u8SelfTestResult); + g_st_ts.u8_selftest_status, + g_st_ts.u8_selftest_result); } static ssize_t rm_tch_self_test_store(struct device *dev, @@ -2056,8 +2118,8 @@ static ssize_t rm_tch_version_show(struct device *dev, char *buf) { return sprintf(buf, "Release V 0x%02X, Test V 0x%02X\n", - g_stTs.u8Version, - g_stTs.u8TestVersion); + g_st_ts.u8_version, + g_st_ts.u8_test_version); } static ssize_t rm_tch_version_store(struct device *dev, @@ -2083,15 +2145,15 @@ static ssize_t rm_tch_module_detect_store(struct device *dev, static void rm_tch_report_mode_change(unsigned long val) { - int iInfo; + int i_info; - g_stTs.u8ReportMode = (u8)val; + g_st_ctrl.u8_event_report_mode = (u8)val; - iInfo = (RM_SIGNAL_PARA_REPORT_MODE_CHANGE << 24) | - (g_stTs.u8ReportMode << 16) | + i_info = (RM_SIGNAL_PARA_REPORT_MODE_CHANGE << 24) | + (g_st_ctrl.u8_event_report_mode << 16) | RM_SIGNAL_REPORT_MODE_CHANGE; - rm_tch_ts_send_signal(g_stTs.ulHalPID, iInfo); + rm_tch_ts_send_signal(g_st_ts.u32_hal_pid, i_info); } static ssize_t rm_tch_report_mode_handler(const char *buf, size_t count) @@ -2109,7 +2171,8 @@ static ssize_t rm_tch_report_mode_handler(const char *buf, size_t count) if (error) ret = error; else { - if ((val >= EVENT_REPORT_MODE_STYLUS_ERASER_FINGER) && (val < EVENT_REPORT_MODE_TYPE_NUM)) + if ((val >= EVENT_REPORT_MODE_STYLUS_ERASER_FINGER) && + (val < EVENT_REPORT_MODE_TYPE_NUM)) rm_tch_report_mode_change(val); else ret = RETURN_FAIL; @@ -2122,7 +2185,8 @@ static ssize_t rm_tch_report_mode_show(struct device *dev, struct device_attribute *attr, char *buf) { - return sprintf(buf, "Raydium Touch Report Mode : %d\n", g_stTs.u8ReportMode); + return sprintf(buf, "Raydium Touch Report Mode : %d\n", + g_st_ctrl.u8_event_report_mode); } static ssize_t rm_tch_report_mode_store(struct device *dev, @@ -2133,92 +2197,120 @@ static ssize_t rm_tch_report_mode_store(struct device *dev, return count; } -static ssize_t selftest_SPI_byte_read_get(struct device *dev, +static ssize_t selftest_spi_byte_read_get(struct device *dev, struct device_attribute *attr, char *buf) { - buf[0] = spi_buf[0]; + buf[0] = g_spi_buf[0]; return 2; } -static ssize_t selftest_SPI_byte_read_set(struct device *dev, +static ssize_t selftest_spi_byte_read_set(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - return rm_tch_spi_byte_read(buf[0], &spi_buf[0]); + return rm_tch_spi_byte_read(buf[0], &g_spi_buf[0]); } -static ssize_t selftest_SPI_byte_write_get(struct device *dev, +static ssize_t selftest_spi_byte_write_get(struct device *dev, struct device_attribute *attr, char *buf) { return 1; } -static ssize_t selftest_SPI_byte_write_set(struct device *dev, +static ssize_t selftest_spi_byte_write_set(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { return rm_tch_spi_byte_write(buf[0], buf[1]); } -static ssize_t selftest_SPI_burst_read_get(struct device *dev, +static ssize_t selftest_spi_burst_read_get(struct device *dev, struct device_attribute *attr, char *buf) { - memcpy(buf, spi_buf, bufsize); - return bufsize; + int ret; + + /*rm_printk("selftest_spi_burst_read_get %d", g_spi_bufsize);*/ + ret = rm_tch_spi_read(g_spi_addr, buf, g_spi_bufsize); + if (ret == RETURN_OK) + return g_spi_bufsize; + + return 0; } -static ssize_t selftest_SPI_burst_read_set(struct device *dev, +static ssize_t selftest_spi_burst_read_set(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - bufsize = count; - return rm_tch_spi_burst_read(buf[0], spi_buf, bufsize); + /*rm_printk("selftest_spi_burst_read_set %d",count);*/ + g_spi_addr = 0; + g_spi_bufsize = 0; + g_spi_addr = buf[0]; + g_spi_bufsize = buf[1]; + g_spi_bufsize <<= 8; + g_spi_bufsize |= buf[2]; + + return 0; } -static ssize_t selftest_SPI_burst_write_get(struct device *dev, +static ssize_t selftest_spi_burst_write_get(struct device *dev, struct device_attribute *attr, char *buf) { return 1; } -static ssize_t selftest_SPI_burst_write_set(struct device *dev, +static ssize_t selftest_spi_burst_write_set(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - memcpy(spi_buf, buf, count); - return rm_tch_spi_burst_write(spi_buf, count); + return rm_tch_spi_write((u8 *)buf, count); } -static DEVICE_ATTR(selftest_enable, 0640, selftest_enable_get, +static DEVICE_ATTR(get_platform_id_gpio, 0640, + selftest_platform_id_gpio_get, + selftest_platform_id_gpio_set); + +static DEVICE_ATTR(selftest_enable, 0640, + selftest_enable_get, selftest_enable_set); -static DEVICE_ATTR(selftest_spi_byte_read, 0640, selftest_SPI_byte_read_get, - selftest_SPI_byte_read_set); +static DEVICE_ATTR(selftest_spi_byte_read, 0640, + selftest_spi_byte_read_get, + selftest_spi_byte_read_set); -static DEVICE_ATTR(selftest_spi_byte_write, 0640, selftest_SPI_byte_write_get, - selftest_SPI_byte_write_set); +static DEVICE_ATTR(selftest_spi_byte_write, 0640, + selftest_spi_byte_write_get, + selftest_spi_byte_write_set); -static DEVICE_ATTR(selftest_spi_burst_read, 0640, selftest_SPI_burst_read_get, - selftest_SPI_burst_read_set); +static DEVICE_ATTR(selftest_spi_burst_read, 0640, + selftest_spi_burst_read_get, + selftest_spi_burst_read_set); -static DEVICE_ATTR(selftest_spi_burst_write, 0640, selftest_SPI_burst_write_get, - selftest_SPI_burst_write_set); +static DEVICE_ATTR(selftest_spi_burst_write, 0640, + selftest_spi_burst_write_get, + selftest_spi_burst_write_set); -static DEVICE_ATTR(slowscan_enable, 0640, rm_tch_slowscan_show, +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, +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, +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, +static DEVICE_ATTR(version, 0640, + rm_tch_version_show, rm_tch_version_store); -static DEVICE_ATTR(module_detect, 0640, rm_tch_module_detect_show, +static DEVICE_ATTR(module_detect, 0640, + rm_tch_module_detect_show, rm_tch_module_detect_store); -static DEVICE_ATTR(report_mode, 0640, rm_tch_report_mode_show, +static DEVICE_ATTR(report_mode, 0640, + rm_tch_report_mode_show, rm_tch_report_mode_store); static struct attribute *rm_ts_attributes[] = { + &dev_attr_get_platform_id_gpio.attr, &dev_attr_slowscan_enable.attr, &dev_attr_selftest_enable.attr, &dev_attr_selftest_spi_byte_read.attr, @@ -2255,23 +2347,23 @@ static void rm_tch_input_close(struct input_dev *input) static irqreturn_t rm_tch_irq(int irq, void *handle) { - g_stTs.u32WatchDogCnt = 0; + g_st_ts.u32_watch_dog_cnt = 0; trace_touchscreen_raydium_irq("Raydium_interrupt"); - mutex_lock(&g_stTs.mutex_scan_mode); + mutex_lock(&g_st_ts.mutex_scan_mode); - if (g_stCtrl.bfPowerMode && - (g_stTs.u8ScanModeState == RM_SCAN_IDLE_MODE)) + if (g_st_ctrl.u8_power_mode && + (g_st_ts.u8_scan_mode_state == RM_SCAN_IDLE_MODE)) #ifndef INPUT_DEVICE_MULTIPLE_INSTANCES input_event(g_input_dev, EV_MSC, MSC_ACTIVITY, 1); #else input_event(g_input_dev[0], EV_MSC, MSC_ACTIVITY, 1); #endif - mutex_unlock(&g_stTs.mutex_scan_mode); + mutex_unlock(&g_st_ts.mutex_scan_mode); - if (g_stTs.bInitFinish && g_stTs.bIsSuspended == false) - queue_work(g_stTs.rm_workqueue, &g_stTs.rm_work); + if (g_st_ts.b_init_finish && g_st_ts.b_is_suspended == false) + queue_work(g_st_ts.rm_workqueue, &g_st_ts.rm_work); return IRQ_HANDLED; } @@ -2279,111 +2371,135 @@ static irqreturn_t rm_tch_irq(int irq, void *handle) static void rm_tch_enter_test_mode(u8 flag) { 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; + g_st_ts.b_selftest_enable = 1; + g_st_ts.u8_selftest_status = RM_SELF_TEST_STATUS_TESTING; + g_st_ts.b_is_suspended = true; + flush_workqueue(g_st_ts.rm_workqueue); + flush_workqueue(g_st_ts.rm_timer_workqueue); + } else { /*leave test mode*/ + g_st_ts.b_selftest_enable = 0; + g_st_ts.b_is_suspended = false; rm_tch_init_ts_structure_part(); } - rm_tch_cmd_process(flag, g_stRmTestModeCmd, NULL); + rm_tch_cmd_process(flag, g_st_rm_testmode_cmd, NULL); if (!flag) - g_stTs.u8SelfTestStatus = RM_SELF_TEST_STATUS_FINISH; + g_st_ts.u8_selftest_status = RM_SELF_TEST_STATUS_FINISH; } void rm_tch_set_variable(unsigned int index, unsigned int arg) { +#if ENABLE_FREQ_HOPPING ssize_t missing; +#endif switch (index) { case RM_VARIABLE_SELF_TEST_RESULT: - g_stTs.u8SelfTestResult = (u8) arg; + g_st_ts.u8_selftest_result = (u8) arg; rm_tch_enter_test_mode(0); break; case RM_VARIABLE_SCRIBER_FLAG: - g_stTs.bEnableScriber = (bool) arg; + g_st_ts.b_enable_scriber = (bool) arg; break; case RM_VARIABLE_AUTOSCAN_FLAG: - g_stCtrl.bfPowerMode = (bool) arg; + g_st_ctrl.u8_power_mode = (bool) arg; break; case RM_VARIABLE_TEST_VERSION: - g_stTs.u8TestVersion = (u8) arg; + g_st_ts.u8_test_version = (u8) arg; break; case RM_VARIABLE_VERSION: - g_stTs.u8Version = (u8) arg; + g_st_ts.u8_version = (u8) arg; dev_info(&g_spi->dev, "Raydium - Firmware v%d.%d\n", - g_stTs.u8Version, g_stTs.u8TestVersion); + g_st_ts.u8_version, g_st_ts.u8_test_version); break; case RM_VARIABLE_IDLEMODECHECK: - g_stCtrl.bfIdleModeCheck = (u8) arg; - if (g_stCtrl.bKernelMsg & DEBUG_DRIVER) - rm_printk("Raydium - bfIdleModeCheck %2x\n", + g_st_ctrl.u8_idle_mode_check = (u8) arg; + if (g_st_ctrl.u8_kernel_msg & DEBUG_DRIVER) + rm_printk("Raydium - u8_idle_mode_check %2x\n", arg); break; case RM_VARIABLE_REPEAT: /*rm_printk("Raydium - Repeat %d\n", arg);*/ - g_stTs.u8Repeat = (u8) arg; - if(g_stCtrl.bNsFucnEnable) { - g_stTs.bNsRpt = (u8) arg; - if(g_stCtrl.bKernelMsg & DEBUG_DRIVER) - rm_printk("g_stCtrl.bNsRpt %d\n", - g_stTs.bNsRpt); + g_st_ts.u8_repeat = (u8) arg; +#if ENABLE_FREQ_HOPPING + if (g_st_ctrl.u8_ns_func_enable) { + g_st_ts.u8_ns_rpt = (u8) arg; + if (g_st_ctrl.u8_kernel_msg & DEBUG_DRIVER) + rm_printk("g_st_ctrl.u8_ns_rpt %d\n", + g_st_ts.u8_ns_rpt); } +#endif break; case RM_VARIABLE_WATCHDOG_FLAG: rm_ctrl_watchdog_func(arg); - g_stCtrl.bNsFucnEnable = ((u8)arg >> 7) & 0x01; - if(g_stCtrl.bKernelMsg & DEBUG_DRIVER) - rm_printk("g_stCtrl.bKernelMsg %d\n", - g_stCtrl.bNsFucnEnable); + g_st_ctrl.u8_ns_func_enable = ((u8)arg >> 6); + if (g_st_ctrl.u8_kernel_msg & DEBUG_DRIVER) + rm_printk("g_st_ctrl.u8_ns_func_enable %d\n", + g_st_ctrl.u8_ns_func_enable); break; case RM_VARIABLE_SET_SPI_UNLOCK: - if (g_stTs.u8ResumeCnt > 1) + if (g_st_ts.u8_resume_cnt > 1) break; - g_stTs.u8SPILocked = 0; - if (g_stCtrl.bKernelMsg & DEBUG_DRIVER) + g_st_ts.u8_spi_locked = 0; + if (g_st_ctrl.u8_kernel_msg & DEBUG_DRIVER) rm_printk("Raydium - SET_SPI_UNLOCK\n"); break; case RM_VARIABLE_SET_WAKE_UNLOCK: - if (wake_lock_active(&g_stTs.Wakelock_Initialization)) - wake_unlock(&g_stTs.Wakelock_Initialization); + if (wake_lock_active(&g_st_ts.wakelock_initialization)) + wake_unlock(&g_st_ts.wakelock_initialization); break; +#if ENABLE_FREQ_HOPPING case RM_VARIABLE_DPW: - mutex_lock(&g_stTs.mutex_ns_mode); - missing = copy_from_user(&g_stTs.bDP[0], ((u8 *)arg), 3); - missing += copy_from_user(&g_stTs.bSWCPW[0], (((u8 *)arg) + 3), 3); - missing += copy_from_user(&g_stTs.bSWC[0], (((u8 *)arg) + 6), 3); + mutex_lock(&g_st_ts.mutex_ns_mode); + missing = copy_from_user(&g_st_ts.u8_ns_para[0], + ((u8 *)arg), 9); + /*missing = copy_from_user(&g_st_ts.bDP[0], + ((u8 *)arg), 3);*/ + /*missing += copy_from_user(&g_st_ts.bSWCPW[0], + (((u8 *)arg) + 3), 3);*/ + /*missing += copy_from_user(&g_st_ts.bSWC[0], + (((u8 *)arg) + 6), 3);*/ if (missing) dev_err(&g_spi->dev, "Raydium - %s RM_VARIABLE_DPW : copy failed - miss:%d\n", __func__, missing); - mutex_unlock(&g_stTs.mutex_ns_mode); - if (g_stCtrl.bKernelMsg & DEBUG_DRIVER) - rm_printk("g_stCtrl.DPW 0x%x:0x%x:0x%x # 0x%x:0x%x:0x%x\n", - g_stTs.bDP[0], g_stTs.bDP[1], - g_stTs.bDP[2], g_stTs.bSWCPW[0], - g_stTs.bSWCPW[1], g_stTs.bSWCPW[2]); + /*memcpy(&g_st_ts.bDP[0], ((u8 *)arg), 3);*/ + /*memcpy(&g_st_ts.bSWCPW[0], (((u8 *)arg) + 3), 3);*/ + /*memcpy(&g_st_ts.bSWC[0], (((u8 *)arg) + 6), 3);*/ + mutex_unlock(&g_st_ts.mutex_ns_mode); + if (g_st_ctrl.u8_kernel_msg & DEBUG_DRIVER) + rm_printk("g_st_ctrl.DPW 0x%x:0x%x:0x%x # 0x%x:0x%x:0x%x,# 0x%x:0x%x:0x%x\n", + /*g_st_ts.bDP[0], g_st_ts.bDP[1], + g_st_ts.bDP[2], g_st_ts.bSWCPW[0], + g_st_ts.bSWCPW[1], g_st_ts.bSWCPW[2], + g_st_ts.bSWC[0], g_st_ts.bSWC[1], + g_st_ts.bSWC[2]);*/ + g_st_ts.u8_ns_para[0], g_st_ts.u8_ns_para[1], + g_st_ts.u8_ns_para[2], g_st_ts.u8_ns_para[3], + g_st_ts.u8_ns_para[4], g_st_ts.u8_ns_para[5], + g_st_ts.u8_ns_para[6], g_st_ts.u8_ns_para[7], + g_st_ts.u8_ns_para[8]); break; case RM_VARIABLE_NS_MODE: - mutex_lock(&g_stTs.mutex_ns_mode); - g_stTs.bNsMode = (u8)arg; - mutex_unlock(&g_stTs.mutex_ns_mode); - if (g_stCtrl.bKernelMsg & DEBUG_DRIVER) - rm_printk("g_stCtrl.bNsMode=%d\n", g_stTs.bNsMode); + mutex_lock(&g_st_ts.mutex_ns_mode); + g_st_ts.u8_ns_mode = (u8)arg; + mutex_unlock(&g_st_ts.mutex_ns_mode); + if (g_st_ctrl.u8_kernel_msg & DEBUG_DRIVER) + rm_printk("g_st_ctrl.u8_ns_mode=%d\n", + g_st_ts.u8_ns_mode); break; +#endif default: break; } } -static u32 rm_tch_get_variable(unsigned int index, unsigned int arg) +static u32 rm_tch_get_variable(unsigned int index, u8 *arg) { u32 ret = RETURN_OK; switch (index) { case RM_VARIABLE_PLATFORM_ID: - ret = rm_tch_get_platform_id((u32 *) arg); + ret = rm_tch_get_platform_id((u8 *) arg); break; case RM_VARIABLE_GPIO_SELECT: ret = rm_tch_get_gpio_sensor_select((u8 *) arg); @@ -2391,9 +2507,6 @@ static u32 rm_tch_get_variable(unsigned int index, unsigned int arg) case RM_VARIABLE_CHECK_SPI_LOCK: ret = rm_tch_get_spi_lock_status((u8 *) arg); break; - case RM_VARIABLE_REPORT_MODE: - ret = rm_tch_get_report_mode((u8 *) arg); - break; default: ret = -EINVAL; break; @@ -2403,34 +2516,34 @@ static u32 rm_tch_get_variable(unsigned int index, unsigned int arg) static void rm_tch_init_ts_structure(void) { - g_stTs.ulHalPID = 0; - memset(&g_stTs, 0, sizeof(struct rm31080a_ts_para)); + g_st_ts.u32_hal_pid = 0; + memset(&g_st_ts, 0, sizeof(struct rm31080a_ts_para)); #ifdef ENABLE_SLOW_SCAN - g_stTs.u32SlowScanLevel = RM_SLOW_SCAN_LEVEL_MAX; + g_st_ts.u32_slow_scan_level = RM_SLOW_SCAN_LEVEL_MAX; #endif - g_stTs.rm_workqueue = create_singlethread_workqueue("rm_work"); - INIT_WORK(&g_stTs.rm_work, rm_work_handler); + g_st_ts.rm_workqueue = create_singlethread_workqueue("rm_work"); + INIT_WORK(&g_st_ts.rm_work, rm_work_handler); - g_stTs.rm_timer_workqueue = + g_st_ts.rm_timer_workqueue = create_singlethread_workqueue("rm_idle_work"); - INIT_WORK(&g_stTs.rm_timer_work, rm_timer_work_handler); + INIT_WORK(&g_st_ts.rm_timer_work, rm_timer_work_handler); - wake_lock_init(&g_stTs.Wakelock_Initialization, + wake_lock_init(&g_st_ts.wakelock_initialization, WAKE_LOCK_SUSPEND, "TouchInitialLock"); - mutex_init(&g_stTs.mutex_scan_mode); - mutex_init(&g_stTs.mutex_spi_rw); - mutex_init(&g_stTs.mutex_ns_mode); + mutex_init(&g_st_ts.mutex_scan_mode); + mutex_init(&g_st_ts.mutex_spi_rw); + mutex_init(&g_st_ts.mutex_ns_mode); - g_stTs.u8ResumeCnt = 0; + g_st_ts.u8_resume_cnt = 0; } static int rm31080_voltage_notifier_1v8(struct notifier_block *nb, unsigned long event, void *ignored) { - if (g_stCtrl.bKernelMsg & DEBUG_DRIVER) + if (g_st_ctrl.u8_kernel_msg & DEBUG_DRIVER) rm_printk("Raydium - REGULATOR EVENT 1.8V:0x%x\n", (unsigned int)event); @@ -2440,7 +2553,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) { - if (g_stCtrl.bKernelMsg & DEBUG_DRIVER) + if (g_st_ctrl.u8_kernel_msg & DEBUG_DRIVER) rm_printk("Raydium - REGULATOR EVENT 3.3V:0x%x\n", (unsigned int)event); @@ -2450,40 +2563,40 @@ static int rm31080_voltage_notifier_3v3(struct notifier_block *nb, /*===========================================================================*/ static void rm_ctrl_resume(struct rm_tch_ts *ts) { - if (g_stTs.bInitFinish) + if (g_st_ts.b_init_finish) return; - mutex_lock(&g_stTs.mutex_scan_mode); + mutex_lock(&g_st_ts.mutex_scan_mode); rm_tch_init_ts_structure_part(); - rm_tch_cmd_process(0, g_stRmResumeCmd, ts); + rm_tch_cmd_process(0, g_st_rm_resume_cmd, ts); - mutex_unlock(&g_stTs.mutex_scan_mode); + mutex_unlock(&g_st_ts.mutex_scan_mode); } static void rm_ctrl_suspend(struct rm_tch_ts *ts) { - if (g_stTs.bIsSuspended == true) + if (g_st_ts.b_is_suspended == true) return; - g_stTs.bIsSuspended = true; - g_stTs.bInitFinish = 0; + g_st_ts.b_is_suspended = true; + g_st_ts.b_init_finish = 0; - if (g_stTs.u8ScanModeState == RM_SCAN_IDLE_MODE) + if (g_st_ts.u8_scan_mode_state == RM_SCAN_IDLE_MODE) rm_ctrl_pause_auto_mode(); - rm_tch_ctrl_wait_for_scan_finish(); + rm_tch_ctrl_wait_for_scan_finish(0); - mutex_lock(&g_stTs.mutex_scan_mode); + mutex_lock(&g_st_ts.mutex_scan_mode); - rm_tch_cmd_process(0, g_stRmSuspendCmd, ts); + rm_tch_cmd_process(0, g_st_rm_suspend_cmd, ts); - rm_tch_ctrl_wait_for_scan_finish(); + rm_tch_ctrl_wait_for_scan_finish(0); - rm_tch_cmd_process(1, g_stRmSuspendCmd, ts); + rm_tch_cmd_process(1, g_st_rm_suspend_cmd, ts); - mutex_unlock(&g_stTs.mutex_scan_mode); + mutex_unlock(&g_st_ts.mutex_scan_mode); } #ifdef CONFIG_PM @@ -2493,8 +2606,8 @@ static int rm_tch_suspend(struct device *dev) rm_ctrl_suspend(ts); - g_stTs.u8SPILocked = 1; - if (g_stCtrl.bKernelMsg & DEBUG_DRIVER) + g_st_ts.u8_spi_locked = 1; + if (g_st_ctrl.u8_kernel_msg & DEBUG_DRIVER) rm_printk("Raydium - SPI_LOCKED by suspend!!\n"); return RETURN_OK; @@ -2504,14 +2617,14 @@ static int rm_tch_resume(struct device *dev) { struct rm_tch_ts *ts = dev_get_drvdata(dev); - if (wake_lock_active(&g_stTs.Wakelock_Initialization)) - wake_unlock(&g_stTs.Wakelock_Initialization); + if (wake_lock_active(&g_st_ts.wakelock_initialization)) + wake_unlock(&g_st_ts.wakelock_initialization); - g_stTs.u8SPILocked = 1; - if (g_stCtrl.bKernelMsg & DEBUG_DRIVER) + g_st_ts.u8_spi_locked = 1; + if (g_st_ctrl.u8_kernel_msg & DEBUG_DRIVER) rm_printk("Raydium - SPI_LOCKED by resume!!\n"); - wake_lock_timeout(&g_stTs.Wakelock_Initialization, + wake_lock_timeout(&g_st_ts.wakelock_initialization, TCH_WAKE_LOCK_TIMEOUT); rm_ctrl_resume(ts); @@ -2584,6 +2697,46 @@ static int rm_tch_input_disable(struct input_dev *in_dev) return error; } +#if defined(CONFIG_TRUSTED_LITTLE_KERNEL) +/*===========================================================================*/ +void raydium_tlk_ns_touch_suspend(void) +{ +#ifndef INPUT_DEVICE_MULTIPLE_INSTANCES + struct rm_tch_ts *ts = input_get_drvdata(g_input_dev); +#else + struct rm_tch_ts *ts = input_get_drvdata(g_input_dev[0]); +#endif + + rm_printk("tlk_ns_touch_suspend\n"); + + rm_tch_enter_manual_mode(); + mutex_lock(&g_st_ts.mutex_scan_mode); + mutex_lock(&g_st_ts.mutex_spi_rw); + rm_tch_cmd_process(0, g_st_rm_tlk_cmd, ts); +} +EXPORT_SYMBOL(raydium_tlk_ns_touch_suspend); + +/*===========================================================================*/ +void raydium_tlk_ns_touch_resume(void) +{ +#ifndef INPUT_DEVICE_MULTIPLE_INSTANCES + struct rm_tch_ts *ts = input_get_drvdata(g_input_dev); +#else + struct rm_tch_ts *ts = input_get_drvdata(g_input_dev[0]); +#endif + + rm_printk("tlk_ns_touch_resume\n"); + + rm_tch_ts_send_signal(g_st_ts.u32_hal_pid, 0x03); + rm_tch_cmd_process(1, g_st_rm_tlk_cmd, ts); + + mutex_unlock(&g_st_ts.mutex_scan_mode); + mutex_unlock(&g_st_ts.mutex_spi_rw); +} +EXPORT_SYMBOL(raydium_tlk_ns_touch_resume); +/*===========================================================================*/ +#endif /*CONFIG_TRUSTED_LITTLE_KERNEL*/ + static void rm_tch_set_input_resolution(unsigned int x, unsigned int y) { #ifndef INPUT_DEVICE_MULTIPLE_INSTANCES @@ -2591,7 +2744,7 @@ static void rm_tch_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); #else u8 i; - for (i = 0 ; i < INPUT_DEVICE_AMOUNT ; i++) { + for (i = 0; i < INPUT_DEVICE_AMOUNT; i++) { input_set_abs_params(g_input_dev[i], ABS_MT_POSITION_X, 0, x - 1, 0, 0); input_set_abs_params(g_input_dev[i], ABS_MT_POSITION_Y, @@ -2600,6 +2753,73 @@ static void rm_tch_set_input_resolution(unsigned int x, unsigned int y) #endif } +static struct rm_spi_ts_platform_data *rm_ts_parse_dt(struct device *dev, + int irq) +{ + struct rm_spi_ts_platform_data *pdata; + struct device_node *np = dev->of_node; + const char *str; + int ret, val, irq_gpio; + + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) + return ERR_PTR(-ENOMEM); + + pdata->gpio_reset = of_get_named_gpio_flags(np, "reset-gpio", 0, NULL); + if (!gpio_is_valid(pdata->gpio_reset)) { + dev_err(dev, "Invalid reset-gpio\n"); + return ERR_PTR(-EINVAL); + } + ret = gpio_request(pdata->gpio_reset, "reset-gpio"); + if (ret < 0) { + dev_err(dev, "gpio_request fail\n"); + return ERR_PTR(-EINVAL); + } + gpio_direction_output(pdata->gpio_reset, 0); + + ret = of_property_read_u32(np, "interrupts", &irq_gpio); + if (!gpio_is_valid(irq_gpio)) { + dev_err(dev, "Invalid irq-gpio\n"); + ret = -EINVAL; + goto exit_release_reset_gpio; + } + + ret = gpio_request(irq_gpio, "irq-gpio"); + if (ret < 0) { + dev_err(dev, "irq_request fail\n"); + ret = -EINVAL; + goto exit_release_reset_gpio; + } + gpio_direction_input(irq_gpio); + + ret = of_property_read_u32(np, "config", &val); + if (ret < 0) + goto exit_release_all_gpio; + pdata->config = (unsigned char *)val; + ret = of_property_read_u32(np, "platform-id", &val); + if (ret < 0) + goto exit_release_all_gpio; + pdata->platform_id = val; + ret = of_property_read_string(np, "name-of-clock", &str); + if (ret < 0) + goto exit_release_all_gpio; + pdata->name_of_clock = (char *)str; + + ret = of_property_read_string(np, "name-of-clock-con", &str); + if (ret < 0) + goto exit_release_all_gpio; + pdata->name_of_clock_con = (char *)str; + + return pdata; + +exit_release_all_gpio: + gpio_free(irq_gpio); + +exit_release_reset_gpio: + gpio_free(pdata->gpio_reset); + return ERR_PTR(ret); +} + #ifndef INPUT_DEVICE_MULTIPLE_INSTANCES struct rm_tch_ts *rm_tch_input_init(struct device *dev, unsigned int irq, const struct rm_tch_bus_ops *bops) @@ -2632,6 +2852,18 @@ struct rm_tch_ts *rm_tch_input_init(struct device *dev, unsigned int irq, ts->input = input_dev; ts->irq = irq; + + if (dev->of_node) { + pr_info("Load platform data from DT.\n"); + pdata = rm_ts_parse_dt(dev, irq); + if (IS_ERR(pdata)) { + dev_err(&g_spi->dev, "Raydium - failed to parse dt\n"); + err = -EINVAL; + goto err_free_mem; + } + dev->platform_data = pdata; + } + pdata = dev->platform_data; if (pdata->name_of_clock || pdata->name_of_clock_con) { @@ -2647,7 +2879,7 @@ struct rm_tch_ts *rm_tch_input_init(struct device *dev, unsigned int irq, snprintf(ts->phys, sizeof(ts->phys), "%s/input0", dev_name(dev)); - input_dev->name = "raydium_ts"; + input_dev->name = "touch"; input_dev->phys = ts->phys; input_dev->dev.parent = dev; input_dev->id.bustype = bops->bustype; @@ -2714,7 +2946,6 @@ err_out: #else /*#ifdef INPUT_DEVICE_MULTIPLE_INSTANCES*/ struct rm_tch_ts *rm_tch_input_init(struct device *dev, unsigned int irq, const struct rm_tch_bus_ops *bops) { - struct rm_tch_ts *ts; struct rm_spi_ts_platform_data *pdata; u8 index; @@ -2737,12 +2968,24 @@ struct rm_tch_ts *rm_tch_input_init(struct device *dev, unsigned int irq, ts->dev = dev; ts->irq = irq; + if (dev->of_node) { + pr_info("Load platform data from DT.\n"); + pdata = rm_ts_parse_dt(dev, irq); + if (IS_ERR(pdata)) { + dev_err(&g_spi->dev, "Raydium - failed to parse dt\n"); + err = -EINVAL; + goto err_free_mem; + } + dev->platform_data = pdata; + } + pdata = dev->platform_data; if (pdata->name_of_clock || pdata->name_of_clock_con) { ts->clk = clk_get_sys(pdata->name_of_clock, pdata->name_of_clock_con); if (IS_ERR(ts->clk)) { - dev_err(&g_spi->dev, "Raydium - failed to get touch_clk: (%s, %s)\n", + dev_err(&g_spi->dev, + "Raydium - failed to get touch_clk: (%s, %s)\n", pdata->name_of_clock, pdata->name_of_clock_con); err = -EINVAL; goto err_free_ts_mem; @@ -2751,11 +2994,11 @@ struct rm_tch_ts *rm_tch_input_init(struct device *dev, unsigned int irq, mutex_init(&ts->access_mutex); - for (index = 0 ; index < INPUT_DEVICE_AMOUNT ; index++) + for (index = 0; index < INPUT_DEVICE_AMOUNT; index++) if (ts->input[index] != NULL) goto err_free_mem; - for (index = 0 ; index < INPUT_DEVICE_AMOUNT ; index++) { + for (index = 0; index < INPUT_DEVICE_AMOUNT; index++) { ts->input[index] = input_allocate_device(); if (!ts->input[index]) { dev_err(dev, @@ -2770,7 +3013,7 @@ struct rm_tch_ts *rm_tch_input_init(struct device *dev, unsigned int irq, snprintf(ts->phys, sizeof(ts->phys), "%s/input%d", dev_name(dev), index); - ts->input[index]->name = "raydium_ts"; + ts->input[index]->name = "touch"; ts->input[index]->phys = ts->phys; ts->input[index]->dev.parent = dev; ts->input[index]->id.bustype = bops->bustype; @@ -2787,14 +3030,18 @@ struct rm_tch_ts *rm_tch_input_init(struct device *dev, unsigned int irq, EV_MSC, MSC_ACTIVITY); } - __set_bit(EV_SYN, ts->input[index]->evbit); - __set_bit(EV_ABS, ts->input[index]->evbit); - input_set_abs_params(ts->input[index], ABS_MT_PRESSURE, 0, 0xFF, 0, 0); - input_set_abs_params(ts->input[index], ABS_MT_TRACKING_ID, 0, 32, 0, 0); - if (index != INPUT_DEVICE_FOR_FINGER) { + input_set_abs_params(ts->input[index], + ABS_MT_PRESSURE, 0, 0xFF, 0, 0); + input_set_abs_params(ts->input[index], + ABS_MT_TRACKING_ID, 0, 32, 0, 0); + + if (index == INPUT_DEVICE_FOR_FINGER) { + __set_bit(EV_KEY, ts->input[index]->evbit); + __set_bit(BTN_TOOL_FINGER, ts->input[index]->keybit); + } else { __set_bit(EV_KEY, ts->input[index]->evbit); __set_bit(BTN_TOOL_RUBBER, ts->input[index]->keybit); } @@ -2814,10 +3061,11 @@ struct rm_tch_ts *rm_tch_input_init(struct device *dev, unsigned int irq, } rm_tch_set_input_resolution(RM_INPUT_RESOLUTION_X, - RM_INPUT_RESOLUTION_Y); + RM_INPUT_RESOLUTION_Y); err = request_threaded_irq(ts->irq, NULL, rm_tch_irq, IRQF_TRIGGER_RISING | IRQF_ONESHOT, dev_name(dev), ts); + if (err) { dev_err(dev, "Raydium - irq %d busy?\n", ts->irq); goto err_free_mem; @@ -2837,19 +3085,21 @@ struct rm_tch_ts *rm_tch_input_init(struct device *dev, unsigned int irq, return ts; -/* -err_remove_attr: - sysfs_remove_group(&dev->kobj, &rm_ts_attr_group); -*/ +/*err_remove_attr: + sysfs_remove_group(&dev->kobj, &rm_ts_attr_group);*/ + err_free_irq: free_irq(ts->irq, ts); + err_free_mem: - for (index = 0 ; index < INPUT_DEVICE_AMOUNT ; index++) { + for (index = 0; index < INPUT_DEVICE_AMOUNT; index++) { input_free_device(ts->input[index]); ts->input[index] = NULL; } + err_free_ts_mem: kfree(ts); + err_out: return ERR_PTR(err); } @@ -2862,7 +3112,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; + g_st_ts.b_init_finish = 0; rm_tch_enter_manual_mode(); return RETURN_OK; @@ -2873,21 +3123,21 @@ dev_read(struct file *filp, char __user *buf, size_t count, loff_t *pos) { ssize_t missing, status; int ret; - u8 *pMyBuf; + u8 *p_u8_my_buf; - pMyBuf = kmalloc(count, GFP_KERNEL); - if (pMyBuf == NULL) + p_u8_my_buf = kmalloc(count, GFP_KERNEL); + if (p_u8_my_buf == NULL) return -ENOMEM; - pMyBuf[0] = buf[0]; - ret = rm_tch_spi_read(pMyBuf[0], pMyBuf, count); + p_u8_my_buf[0] = buf[0]; + ret = rm_tch_spi_read(p_u8_my_buf[0], p_u8_my_buf, count); if (ret) { status = -EFAULT; rm_printk("Raydium - rm_tch_spi_read() fail\n"); } else { status = count; - missing = copy_to_user(buf, pMyBuf, count); + missing = copy_to_user(buf, p_u8_my_buf, count); if (missing) { if (missing == status) @@ -2897,35 +3147,34 @@ dev_read(struct file *filp, char __user *buf, size_t count, loff_t *pos) } } - kfree(pMyBuf); + kfree(p_u8_my_buf); return status; } -static ssize_t -dev_write(struct file *filp, const 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) { - u8 *pMyBuf; + u8 *p_u8_my_buf; int ret; unsigned long missing; ssize_t status = 0; - pMyBuf = kmalloc(count, GFP_KERNEL); - if (pMyBuf == NULL) + p_u8_my_buf = kmalloc(count, GFP_KERNEL); + if (p_u8_my_buf == NULL) return -ENOMEM; - missing = copy_from_user(pMyBuf, buf, count); + missing = copy_from_user(p_u8_my_buf, buf, count); if (missing) status = -EFAULT; else { - ret = rm_tch_spi_write(pMyBuf, count); + ret = rm_tch_spi_write(p_u8_my_buf, count); if (ret) status = -EFAULT; else status = count; } - kfree(pMyBuf); + kfree(p_u8_my_buf); return status; } @@ -2934,7 +3183,7 @@ dev_write(struct file *filp, const char __user *buf, I/O Control routin. Input: file: - cmd : + u8_cmd : arg : Output: 1: succeed @@ -2942,69 +3191,74 @@ dev_write(struct file *filp, const char __user *buf, 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) +static long dev_ioctl(struct file *file, + unsigned int u8_cmd, unsigned long arg) { long ret = RETURN_OK; unsigned int index; - index = (cmd >> 16) & 0xFFFF; - switch (cmd & 0xFFFF) { + + index = (u8_cmd >> 16) & 0xFFFF; + + switch (u8_cmd & 0xFFFF) { case RM_IOCTL_REPORT_POINT: - raydium_report_pointer((void *)arg); + raydium_report_pointer((void *)(arg & MASK_USER_SPACE_POINTER)); + break; + case RM_IOCTL_FINISH_CALC: + g_st_ts.b_calc_finish = 1; + break; + case RM_IOCTL_READ_RAW_DATA: + ret = rm_tch_queue_read_raw_data((u8 *)(arg & MASK_USER_SPACE_POINTER), index); + break; + case RM_IOCTL_GET_SACN_MODE: + ret = rm_tch_ctrl_get_idle_mode((u8 *)(arg & MASK_USER_SPACE_POINTER)); break; case RM_IOCTL_SET_HAL_PID: - g_stTs.ulHalPID = arg; + g_st_ts.u32_hal_pid = (u32)arg; + break; + case RM_IOCTL_WATCH_DOG: + g_st_ts.u8_watch_dog_flg = 1; + g_st_ts.b_watch_dog_check = 0; + break; + case RM_IOCTL_GET_VARIABLE: + ret = rm_tch_get_variable(index, ((u8 *)(arg & MASK_USER_SPACE_POINTER))); break; case RM_IOCTL_INIT_START: - g_stTs.bInitFinish = 0; + g_st_ts.b_init_finish = 0; rm_tch_enter_manual_mode(); break; case RM_IOCTL_INIT_END: - g_stTs.bInitFinish = 1; - g_stTs.bCalcFinish = 1; - g_stTs.bIsSuspended = false; - if (g_stTs.u8ResumeCnt) /* In case issued by boot-up*/ - g_stTs.u8ResumeCnt--; - if (wake_lock_active(&g_stTs.Wakelock_Initialization)) - wake_unlock(&g_stTs.Wakelock_Initialization); + g_st_ts.b_init_finish = 1; + g_st_ts.b_calc_finish = 1; + g_st_ts.b_is_suspended = false; + if (g_st_ts.u8_resume_cnt) /* In case issued by boot-up*/ + g_st_ts.u8_resume_cnt--; + if (wake_lock_active(&g_st_ts.wakelock_initialization)) + wake_unlock(&g_st_ts.wakelock_initialization); rm_printk("Raydium - Enable input device done\n"); 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_READ_RAW_DATA: - ret = rm_tch_queue_read_raw_data((u8 *) arg, index); + g_st_ts.b_enable_scriber = (bool) arg; break; case RM_IOCTL_SET_PARAMETER: - rm_tch_ctrl_set_parameter((void *)arg); - rm_tch_set_input_resolution(g_stCtrl.u16ResolutionX, - g_stCtrl.u16ResolutionY); + rm_tch_ctrl_set_parameter((void *)(arg & MASK_USER_SPACE_POINTER)); + rm_tch_set_input_resolution(g_st_ctrl.u16_resolution_x, + g_st_ctrl.u16_resolution_y); break; case RM_IOCTL_SET_BASELINE: - rm_tch_ctrl_set_baseline((u8 *)arg, g_stCtrl.u16DataLength); + rm_tch_ctrl_set_baseline((u8 *)(arg & MASK_USER_SPACE_POINTER), + g_st_ctrl.u16_data_length); break; case RM_IOCTL_SET_VARIABLE: rm_tch_set_variable(index, arg); break; - case RM_IOCTL_GET_SACN_MODE: - ret = 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: - ret = rm_set_kernel_tbl(index, (u8 *)arg); - break; - case RM_IOCTL_WATCH_DOG: - g_stTs.u8WatchDogFlg = 1; - g_stTs.u8WatchDogCheck = 0; + ret = rm_set_kernel_tbl(index, ((u8 *)(arg & MASK_USER_SPACE_POINTER))); break; default: return -EINVAL; break; } + return !ret; } @@ -3020,7 +3274,7 @@ static const struct file_operations dev_fops = { static struct miscdevice raydium_ts_miscdev = { .minor = MISC_DYNAMIC_MINOR, - .name = "raydium_ts", + .name = "touch", .fops = &dev_fops, }; @@ -3030,14 +3284,15 @@ static const struct rm_tch_bus_ops rm_tch_spi_bus_ops = { static void init_ts_timer(void) { - init_timer_deferrable(&ts_timer_triggle); + 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); + queue_work(g_st_ts.rm_timer_workqueue, &g_st_ts.rm_timer_work); ts_timer_triggle.expires = jiffies + TS_TIMER_PERIOD; add_timer(&ts_timer_triggle); } @@ -3066,20 +3321,21 @@ static int rm_tch_spi_remove(struct spi_device *spi) #ifdef INPUT_DEVICE_MULTIPLE_INSTANCES u8 i; #endif + del_timer(&ts_timer_triggle); - if (g_stTs.rm_timer_workqueue) - destroy_workqueue(g_stTs.rm_timer_workqueue); + if (g_st_ts.rm_timer_workqueue) + destroy_workqueue(g_st_ts.rm_timer_workqueue); rm_tch_queue_free(); - if (g_stTs.rm_workqueue) - destroy_workqueue(g_stTs.rm_workqueue); + if (g_st_ts.rm_workqueue) + destroy_workqueue(g_st_ts.rm_workqueue); - if (&g_stTs.Wakelock_Initialization) - wake_lock_destroy(&g_stTs.Wakelock_Initialization); + if (&g_st_ts.wakelock_initialization) + wake_lock_destroy(&g_st_ts.wakelock_initialization); - mutex_destroy(&g_stTs.mutex_scan_mode); - mutex_destroy(&g_stTs.mutex_spi_rw); + mutex_destroy(&g_st_ts.mutex_scan_mode); + mutex_destroy(&g_st_ts.mutex_spi_rw); sysfs_remove_group(&raydium_ts_miscdev.this_device->kobj, &rm_ts_attr_group); @@ -3089,7 +3345,7 @@ static int rm_tch_spi_remove(struct spi_device *spi) #ifndef INPUT_DEVICE_MULTIPLE_INSTANCES input_unregister_device(ts->input); #else - for (i = 0 ; i < INPUT_DEVICE_AMOUNT ; i++) + for (i = 0; i < INPUT_DEVICE_AMOUNT; i++) input_unregister_device(ts->input[i]); #endif @@ -3105,6 +3361,7 @@ static int rm_tch_spi_remove(struct spi_device *spi) kfree(ts); spi_set_drvdata(spi, NULL); + return RETURN_OK; } @@ -3272,12 +3529,13 @@ err_misc_reg: if (ts->clk) clk_disable(ts->clk); + err_regulator_init: spi_set_drvdata(spi, NULL); #ifndef INPUT_DEVICE_MULTIPLE_INSTANCES input_unregister_device(ts->input); #else - for (i = 0 ; i < INPUT_DEVICE_AMOUNT ; i++) + for (i = 0; i < INPUT_DEVICE_AMOUNT; i++) input_unregister_device(ts->input[i]); #endif sysfs_remove_group(&ts->dev->kobj, &rm_ts_attr_group); @@ -3289,25 +3547,34 @@ err_regulator_init: #ifndef INPUT_DEVICE_MULTIPLE_INSTANCES input_free_device(g_input_dev); #else - for (i = 0 ; i < INPUT_DEVICE_AMOUNT ; i++) + for (i = 0; i < INPUT_DEVICE_AMOUNT; i++) input_free_device(g_input_dev[i]); #endif 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); - mutex_destroy(&g_stTs.mutex_spi_rw); + if (g_st_ts.rm_timer_workqueue) + destroy_workqueue(g_st_ts.rm_timer_workqueue); + if (g_st_ts.rm_workqueue) + destroy_workqueue(g_st_ts.rm_workqueue); + mutex_destroy(&g_st_ts.mutex_scan_mode); + mutex_destroy(&g_st_ts.mutex_spi_rw); return ret; } +static const struct of_device_id rm_ts_dt_match[] = { + { .compatible = "raydium,rm_ts_spidev" }, + { }, +}; +MODULE_DEVICE_TABLE(of, rm_ts_dt_match); + static struct spi_driver rm_tch_spi_driver = { .driver = { .name = "rm_ts_spidev", .bus = &spi_bus_type, .owner = THIS_MODULE, +#ifdef CONFIG_OF + .of_match_table = rm_ts_dt_match, +#endif }, .probe = rm_tch_spi_probe, .remove = rm_tch_spi_remove, |