Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    2)  * drivers/input/touchscreen/gslX680.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    4)  * Copyright (c) 2012 Shanghai Basewin
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    5)  *	Guan Yuwei<guanyuwei@basewin.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    7)  *  This program is free software; you can redistribute it and/or modify
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    8)  *  it under the terms of the GNU General Public License version 2 as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    9)  *  published by the Free Software Foundation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   10)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   12) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   13) #include <linux/delay.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   14) #include <linux/device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   15) #include <linux/hrtimer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   16) #include <linux/i2c.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   17) #include <linux/input.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   18) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   19) #include <linux/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   20) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   21) #include <linux/async.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   22) #include <linux/irq.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   23) #include <linux/workqueue.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   24) #include <linux/proc_fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   25) #include <linux/input/mt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   26) #include <linux/version.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   27) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   28) #include <linux/of_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   29) #include <linux/of_gpio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   31) #include "tp_suspend.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   32) #include "tp_gslx680_board.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   34) #ifdef OLD_VERSION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   35) #if defined(CONFIG_TOUCHSCREEN_GSL1680_7INCH_800x480_LEHENG_NEW)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   36) #include "rockchip_gsl1680_7inch_800x480_LeHeng.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   37) #elif defined(CONFIG_TOUCHSCREEN_GSL1680_7INCH_800x480_SHENGHEXIANG_NEW)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   38) #include "rockchip_gsl1680_7inch_800x480_ShengHeXiang.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   39) #elif defined(CONFIG_TOUCHSCREEN_GSL1680_7INCH_800x480_SHENGHEXIANG_QLT_NEW)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   40) #include "rockchip_gsl1680_7inch_800x480_ShengHeXiang_QLT.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   41) #elif defined(CONFIG_TOUCHSCREEN_GSL1680_7INCH_1024x600_SHENGHEXIANG_NEW)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   42) #include "rockchip_gsl1680_7inch_1024x600_ShengHeXiang.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   43) #elif defined(CONFIG_TOUCHSCREEN_GSL1680_7INCH_800x480_YOUCHU_NEW)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   44) #include "rockchip_gsl1680_7inch_800x480_YouChu_dc.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   45) #elif defined(CONFIG_TOUCHSCREEN_GSL1680_7INCH_800x480_GANGXINDA_NEW)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   46) #include "rockchip_gsl1680_7inch_800x480_YouChu_NEW_GangXinDa.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   47) #elif defined(CONFIG_TOUCHSCREEN_GSL1680_7INCH_1024x600_GANGXINDA_NEW)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   48) #include "rockchip_gsl1680_7inch_1024x600_YouChu_NEW_GangXinDa.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   49) #elif defined(CONFIG_TOUCHSCREEN_GSL1680_7INCH_800x480_DEYI_NEW)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   50) #include "rockchip_gsl1680_7inch_800x480_DeYi.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   51) #elif defined(CONFIG_TOUCHSCREEN_GSL1680_7INCH_800x480_YOUCHU_YISENG_NEW)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   52) #include "rockchip_gsl1680_7inch_800x480_YouChu_YiSeng.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   53) #elif defined(CONFIG_TOUCHSCREEN_GSL1680_7INCH_800x480_HAOYUAN_NEW)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   54) #include "rockchip_gsl1680_7inch_800x480_HaoYuan_NEW.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   55) #elif defined(CONFIG_TOUCHSCREEN_GSL1680_7INCH_800x480_XINAGRUIDE_NEW)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   56) #include "rockchip_gsl1680_7inch_800x480_XiangRuiDe_NEW.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   57) #elif defined(CONFIG_TOUCHSCREEN_GSL1680_7INCH_1024x600_YOUCHU_NEW)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   58) #include "rockchip_gsl1680_7inch_1024x600_YouChu.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   59) #elif defined(CONFIG_TOUCHSCREEN_GSL1680_7INCH_1024x600_HAOYUAN_NEW)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   60) #include "rockchip_gsl1680_7inch_1024x600_HaoYuan.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   61) #elif defined(CONFIG_TOUCHSCREEN_GSL1680_7INCH_1024x600_DEYI_NEW)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   62) #include "rockchip_gsl1680_7inch_1024x600_DeYi_NEW.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   63) #elif defined(CONFIG_TOUCHSCREEN_GSL1680_7INCH_1024x600_FEICHU_NEW)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   64) #include "rockchip_gsl1680_7inch_1024x600_FeiChu_NEW.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   65) #elif defined(CONFIG_TOUCHSCREEN_GSL1680_7INCH_1024x600_K71_NEW)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   66) #include "rockchip_gsl1680_7inch_1024x600_K71_NEW.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   67) #elif defined(CONFIG_GSLX680_9INCH_800X480_NEW)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   68) #include "rockchip_gslX680_9inch_800x480.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   69) #elif defined(CONFIG_GSLX680_9INCH_800X480_TENGYAO_NEW)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   70) #include "rockchip_gslX680_9inch_800x480_TengYao.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   71) #elif defined(CONFIG_GSLX680_9INCH_1024X600_NEW)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   72) #include "rockchip_gslX680_9inch_1024x600.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   73) #elif defined(CONFIG_GSLX680_8INCH_800X600_NEW)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   74) #include "rockchip_gslX680_8inch_800x600.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   75) #elif defined(CONFIG_GSLX680_8INCH_1024X600_NEW)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   76) #include "rockchip_gslX680_8inch_1024x600.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   77) #elif defined(CONFIG_TOUCHSCREEN_GSL1680_43INCH_480x272_HAOYUAN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   78) #include "rockchip_gsl1680_43inch_480x272_YouChu.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   79) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   80) #include "rockchip_gslX680.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   81) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   82) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   83) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   85) #define REPORT_DATA_ANDROID_4_0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   86) #define SLEEP_CLEAR_POINT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   87) #ifdef FILTER_POINT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   88) #define FILTER_MAX	9
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   89) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   91) #define GSLX680_I2C_NAME	"gslX680a"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   92) #define GSLX680_I2C_ADDR	0x40
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   94) #ifdef OLD_VERSION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   95) #ifdef CONFIG_MACH_RK3028A_86V
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   96) 	#define IRQ_PORT			RK30_PIN3_PC7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   97) 	#if defined(CONFIG_INCAR_PNLVCOM_ADJUST)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   98) 		#define WAKE_PORT			RK30_PIN3_PC3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   99) 	#else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  100) 		#define WAKE_PORT			RK30_PIN3_PC3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  101) 	#endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  102) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  103) 	#if defined(CONFIG_MACH_RK3026_AT8931_NMC1000) || defined(CONFIG_MACH_RK3026_PMU_ACT9831)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  104) 		#define IRQ_PORT			RK30_PIN1_PA1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  105) 		#ifdef CONFIG_MACH_RK3026_YK_k71_ACT8931
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  106) 			#define WAKE_PORT			INVALID_GPIO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  107) 		#else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  108) 			#define WAKE_PORT			RK30_PIN2_PB2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  109) 		#endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  110) 	#elif defined(CONFIG_MACH_RK3026_86V_NOPMU) && defined(CONFIG_MACH_RK3026_86V_WIFI_ESP8089)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  111) 		#define IRQ_PORT			RK30_PIN1_PA1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  112) 		#define WAKE_PORT			RK30_PIN2_PB2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  113) 	#elif defined(CONFIG_PMIC_AXP192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  114) 		#define IRQ_PORT			RK30_PIN2_PB2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  115) 		#define WAKE_PORT			INVALID_GPIO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  116) 	#elif defined(CONFIG_INCAR_PNLVCOM_ADJUST)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  117) 		#define IRQ_PORT			RK30_PIN1_PB0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  118) 		#define WAKE_PORT			RK30_PIN2_PB2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  119) 	#elif defined(CONFIG_MACH_RK3026_86V_NOPMU)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  120) 		#define IRQ_PORT			RK30_PIN1_PA1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  121) 		#define WAKE_PORT			INVALID_GPIO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  122) 	#else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  123) 		#define IRQ_PORT			RK30_PIN1_PB0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  124) 		#define WAKE_PORT			RK30_PIN0_PD3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  125) 	#endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  126) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  127) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  128) static int g_wake_pin;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  129) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  130) #define GSL_DATA_REG		0x80
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  131) #define GSL_STATUS_REG		0xe0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  132) #define GSL_PAGE_REG		0xf0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  134) #define TPD_PROC_DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  135) #ifdef TPD_PROC_DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  136) #include <linux/proc_fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  137) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  138) #include <linux/seq_file.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  139) #define GSL_CONFIG_PROC_FILE "gsl_config"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  140) #define CONFIG_LEN 31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  141) static char gsl_read[CONFIG_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  142) static u8 gsl_data_proc[8] = {0};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  143) static u8 gsl_proc_flag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  144) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  145) #if defined(CONFIG_TOUCHSCREEN_GSL1680_7INCH_1024x600_K71_NEW)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  146) static int revert_xy = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  147) static int revert_x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  148) static int revert_y;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  149) #elif defined(CONFIG_GSLX680_9INCH_800X480_NEW)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  150) static int revert_xy = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  151) static int revert_x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  152) static int revert_y;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  153) #elif defined(CONFIG_TOUCHSCREEN_GSL1680_7INCH_800x480_YOUCHU_NEW)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  154) static int revert_xy = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  155) static int revert_x = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  156) static int revert_y = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  157) #elif defined(CONFIG_BOARD_TH71_3128_V1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  158) static int revert_xy = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  159) static int revert_x = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  160) static int revert_y = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  161) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  162) static int revert_xy = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  163) static int revert_x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  164) static int revert_y = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  165) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  166) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  167) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  168) #define PRESS_MAX			255
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  169) #define MAX_FINGERS			5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  170) #define MAX_CONTACTS		10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  171) #define DMA_TRANS_LEN		0x20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  172) #ifdef GSL_MONITOR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  173) static struct delayed_work gsl_monitor_work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  174) static struct workqueue_struct *gsl_monitor_workqueue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  175) static char int_1st[4] = {0};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  176) static char int_2nd[4] = {0};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  177) static char dac_counter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  178) static char b0_counter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  179) static char i2c_lock_flag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  180) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  182) static struct i2c_client *gsl_client;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  183) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  184) #ifdef HAVE_TOUCH_KEY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  185) static u16 key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  186) static int key_state_flag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  187) struct key_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  188) 	u16 key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  189) 	u16 x_min;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  190) 	u16 x_max;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  191) 	u16 y_min;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  192) 	u16 y_max;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  193) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  194) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  195) const u16 key_array[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  196) 			KEY_BACK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  197) 			KEY_HOME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  198) 			KEY_MENU,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  199) 			KEY_SEARCH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  200) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  201) #define MAX_KEY_NUM (sizeof(key_array) / sizeof(key_array[0]))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  202) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  203) struct key_data gsl_key_data[MAX_KEY_NUM] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  204) 	{KEY_BACK, 2048, 2048, 2048, 2048},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  205) 	{KEY_HOME, 2048, 2048, 2048, 2048},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  206) 	{KEY_MENU, 2048, 2048, 2048, 2048},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  207) 	{KEY_SEARCH, 2048, 2048, 2048, 2048},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  208) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  209) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  210) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  211) struct gsl_ts_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  212) 	u8 x_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  213) 	u8 y_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  214) 	u8 z_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  215) 	u8 id_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  216) 	u8 touch_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  217) 	u8 data_reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  218) 	u8 status_reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  219) 	u8 data_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  220) 	u8 touch_bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  221) 	u8 update_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  222) 	u8 touch_meta_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  223) 	u8 finger_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  224) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  225) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  226) static struct gsl_ts_data devices[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  227) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  228) 		.x_index = 6,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  229) 		.y_index = 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  230) 		.z_index = 5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  231) 		.id_index = 7,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  232) 		.data_reg = GSL_DATA_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  233) 		.status_reg = GSL_STATUS_REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  234) 		.update_data = 0x4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  235) 		.touch_bytes = 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  236) 		.touch_meta_data = 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  237) 		.finger_size = 70,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  238) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  239) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  240) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  241) struct gsl_ts {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  242) 	struct i2c_client *client;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  243) 	struct input_dev *input;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  244) 	struct work_struct work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  245) 	struct workqueue_struct *wq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  246) 	struct gsl_ts_data *dd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  247) 	u8 *touch_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  248) 	u8 device_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  249) 	int irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  250) 	int irq_pin;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  251) 	int wake_pin;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  252) 	struct  tp_device  tp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  253) #if defined(CONFIG_HAS_EARLYSUSPEND)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  254) 	struct early_suspend early_suspend;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  255) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  256) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  257) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  258) #ifdef GSL_DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  259) #define print_info(fmt, args...)   \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  260) 	do {                              \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  261) 		pr_info(fmt, ##args);     \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  262) 	} while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  263) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  264) #define print_info(fmt, args...)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  265) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  266) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  267) static u32 id_sign[MAX_CONTACTS + 1] = {0};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  268) static u8 id_state_flag[MAX_CONTACTS + 1] = {0};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  269) static u8 id_state_old_flag[MAX_CONTACTS + 1] = {0};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  270) static u16 x_old[MAX_CONTACTS + 1] = {0};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  271) static u16 y_old[MAX_CONTACTS + 1] = {0};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  272) static u16 x_new;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  273) static u16 y_new;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  274) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  275) static int gslX680_shutdown_low(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  276) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  277) 	if (g_wake_pin != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  278) 		gpio_direction_output(g_wake_pin, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  279) 		gpio_set_value(g_wake_pin, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  280) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  281) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  282) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  283) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  284) static int gslX680_shutdown_high(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  285) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  286) 	if (g_wake_pin != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  287) 		gpio_direction_output(g_wake_pin, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  288) 		gpio_set_value(g_wake_pin, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  289) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  290) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  291) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  292) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  293) static inline u16 join_bytes(u8 a, u8 b)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  294) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  295) 	u16 ab = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  296) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  297) 	ab = ab | a;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  298) 	ab = ab << 8 | b;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  299) 	return ab;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  300) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  301) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  302) static u32 gsl_write_interface(struct i2c_client *client, const u8 reg, u8 *buf, u32 num)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  303) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  304) 	struct i2c_msg xfer_msg[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  305) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  306) 	buf[0] = reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  307) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  308) 	xfer_msg[0].addr = client->addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  309) 	xfer_msg[0].len = num + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  310) 	xfer_msg[0].flags = client->flags & I2C_M_TEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  311) 	xfer_msg[0].buf = buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  312) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  313) 	return i2c_transfer(client->adapter, xfer_msg, 1) == 1 ? 0 : -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  314) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  315) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  316) static int gsl_ts_write(struct i2c_client *client, u8 addr, u8 *pdata, int datalen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  317) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  318) 	int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  319) 	u8 tmp_buf[128];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  320) 	unsigned int bytelen = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  321) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  322) 	if (datalen > 125) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  323) 		pr_info("%s too big datalen = %d!\n", __func__, datalen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  324) 		return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  325) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  326) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  327) 	tmp_buf[0] = addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  328) 	bytelen++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  329) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  330) 	if (datalen != 0 && pdata != NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  331) 		memcpy(&tmp_buf[bytelen], pdata, datalen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  332) 		bytelen += datalen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  333) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  334) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  335) 	ret = i2c_master_send(client, tmp_buf, bytelen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  336) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  337) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  338) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  339) static int gsl_ts_read(struct i2c_client *client, u8 addr, u8 *pdata, unsigned int datalen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  340) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  341) 	int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  342) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  343) 	if (datalen > 126) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  344) 		pr_info("%s too big datalen = %d!\n", __func__, datalen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  345) 		return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  346) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  347) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  348) 	ret = gsl_ts_write(client, addr, NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  349) 	if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  350) 		pr_info("%s set data address fail!\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  351) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  352) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  353) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  354) 	return i2c_master_recv(client, pdata, datalen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  355) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  356) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  357) static __inline__ void fw2buf(u8 *buf, const u32 *fw)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  358) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  359) 	u32 *u32_buf = (int *)buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  360) 	*u32_buf = *fw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  361) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  362) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  363) static void gsl_load_fw(struct i2c_client *client)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  364) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  365) 	u8 buf[DMA_TRANS_LEN * 4 + 1] = {0};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  366) 	u8 send_flag = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  367) 	u8 *cur = buf + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  368) 	u32 source_line = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  369) 	u32 source_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  370) 	struct fw_data *ptr_fw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  371) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  372) 	pr_info("=============gsl_load_fw start==============\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  373) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  374) 	ptr_fw = GSLX680_FW;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  375) 	source_len = ARRAY_SIZE(GSLX680_FW);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  376) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  377) 	for (source_line = 0; source_line < source_len; source_line++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  378) 		/* init page trans, set the page val */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  379) 		if (ptr_fw[source_line].offset == GSL_PAGE_REG) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  380) 			fw2buf(cur, &ptr_fw[source_line].val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  381) 			gsl_write_interface(client, GSL_PAGE_REG, buf, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  382) 			send_flag = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  383) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  384) 			if (send_flag % (DMA_TRANS_LEN < 0x20 ? DMA_TRANS_LEN : 0x20) == 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  385) 				buf[0] = (u8)ptr_fw[source_line].offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  386) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  387) 			fw2buf(cur, &ptr_fw[source_line].val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  388) 			cur += 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  389) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  390) 			if (send_flag % (DMA_TRANS_LEN < 0x20 ? DMA_TRANS_LEN : 0x20) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  391) 				gsl_write_interface(client, buf[0], buf, cur - buf - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  392) 				cur = buf + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  393) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  394) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  395) 			send_flag++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  396) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  397) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  398) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  399) 	pr_info("=============gsl_load_fw end==============\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  400) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  401) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  402) static int test_i2c(struct i2c_client *client)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  403) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  404) 	u8 read_buf = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  405) 	u8 write_buf = 0x12;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  406) 	int ret, rc = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  407) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  408) 	ret = gsl_ts_read(client, 0xf0, &read_buf, sizeof(read_buf));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  409) 	if (ret  < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  410) 		rc--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  411) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  412) 		pr_info("I read reg 0xf0 is %x\n", read_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  413) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  414) 	msleep(2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  415) 	ret = gsl_ts_write(client, 0xf0, &write_buf, sizeof(write_buf));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  416) 	if (ret  >=  0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  417) 		pr_info("I write reg 0xf0 0x12\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  418) 	msleep(2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  419) 	ret = gsl_ts_read(client, 0xf0, &read_buf, sizeof(read_buf));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  420) 	if (ret <  0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  421) 		rc--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  422) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  423) 		pr_info("I read reg 0xf0 is 0x%x\n", read_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  424) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  425) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  426) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  427) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  428) static void startup_chip(struct i2c_client *client)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  429) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  430) 	u8 tmp = 0x00;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  431) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  432) #ifdef GSL_NOID_VERSION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  433) 	gsl_DataInit(gsl_config_data_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  434) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  435) 	gsl_ts_write(client, 0xe0, &tmp, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  436) 	msleep(10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  437) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  438) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  439) static void reset_chip(struct i2c_client *client)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  440) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  441) 	u8 tmp = 0x88;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  442) 	u8 buf[4] = {0x00};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  443) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  444) 	gsl_ts_write(client, 0xe0, &tmp, sizeof(tmp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  445) 	msleep(20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  446) 	tmp = 0x04;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  447) 	gsl_ts_write(client, 0xe4, &tmp, sizeof(tmp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  448) 	msleep(10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  449) 	gsl_ts_write(client, 0xbc, buf, sizeof(buf));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  450) 	msleep(10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  451) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  452) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  453) static void clr_reg(struct i2c_client *client)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  454) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  455) 	u8 write_buf[4] = {0};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  456) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  457) 	write_buf[0] = 0x88;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  458) 	gsl_ts_write(client, 0xe0, &write_buf[0], 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  459) 	msleep(20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  460) 	write_buf[0] = 0x03;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  461) 	gsl_ts_write(client, 0x80, &write_buf[0], 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  462) 	msleep(5);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  463) 	write_buf[0] = 0x04;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  464) 	gsl_ts_write(client, 0xe4, &write_buf[0], 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  465) 	msleep(5);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  466) 	write_buf[0] = 0x00;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  467) 	gsl_ts_write(client, 0xe0, &write_buf[0], 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  468) 	msleep(20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  469) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  470) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  471) static void init_chip(struct i2c_client *client)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  472) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  473) 	int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  474) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  475) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  476) 	gslX680_shutdown_low();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  477) 	msleep(20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  478) 	gslX680_shutdown_high();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  479) 	msleep(20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  480) 	for (i = 0; i < 10; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  481) 	rc = test_i2c(client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  482) 		if (rc >= 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  483) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  484) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  485) 	if (rc < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  486) 		pr_info("------gslX680 test_i2c error------\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  487) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  488) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  489) 	clr_reg(client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  490) 	reset_chip(client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  491) 	gsl_load_fw(client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  492) 	startup_chip(client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  493) 	reset_chip(client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  494) 	startup_chip(client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  495) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  496) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  497) static void check_mem_data(struct i2c_client *client)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  498) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  499) 	u8 read_buf[4]  = {0};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  500) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  501) 	msleep(30);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  502) 	gsl_ts_read(client, 0xb0, read_buf, sizeof(read_buf));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  503) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  504) 	if (read_buf[3] != 0x5a || read_buf[2] != 0x5a || read_buf[1] != 0x5a || read_buf[0] != 0x5a) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  505) 		pr_info("#########check mem read 0xb0 = %x %x %x %x #########\n", read_buf[3], read_buf[2], read_buf[1], read_buf[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  506) 		init_chip(client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  507) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  508) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  509) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  510) #ifdef TPD_PROC_DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  511) static int char_to_int(char ch)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  512) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  513) 	if (ch >= '0' && ch <= '9')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  514) 		return (ch - '0');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  515) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  516) 		return (ch - 'a' + 10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  517) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  518) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  519) static int gsl_config_read_proc(struct seq_file *m, void *v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  520) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  521) 	char temp_data[5] = {0};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  522) 	unsigned int tmp = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  523) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  524) 	if ('v' == gsl_read[0] && 's' == gsl_read[1]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  525) #ifdef GSL_NOID_VERSION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  526) 		tmp = gsl_version_id();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  527) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  528) 		tmp = 0x20121215;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  529) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  530) 		seq_printf(m, "version:%x\n", tmp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  531) 	} else if ('r' == gsl_read[0] && 'e' == gsl_read[1]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  532) 		if ('i' == gsl_read[3]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  533) #ifdef GSL_NOID_VERSION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  534) 			tmp = (gsl_data_proc[5] << 8) | gsl_data_proc[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  535) 			seq_printf(m, "gsl_config_data_id[%d] = ", tmp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  536) 			if (tmp >= 0 && tmp < ARRAY_SIZE(gsl_config_data_id))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  537) 					seq_printf(m, "%d\n", gsl_config_data_id[tmp]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  538) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  539) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  540) 			gsl_ts_write(gsl_client, 0Xf0, &gsl_data_proc[4], 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  541) 			if (gsl_data_proc[0] < 0x80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  542) 				gsl_ts_read(gsl_client, gsl_data_proc[0], temp_data, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  543) 			gsl_ts_read(gsl_client, gsl_data_proc[0], temp_data, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  544) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  545) 			seq_printf(m, "offset : {0x%02x,0x", gsl_data_proc[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  546) 			seq_printf(m, "%02x", temp_data[3]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  547) 			seq_printf(m, "%02x", temp_data[2]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  548) 			seq_printf(m, "%02x", temp_data[1]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  549) 			seq_printf(m, "%02x};\n", temp_data[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  550) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  551) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  552) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  553) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  554) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  555) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  556) static ssize_t gsl_config_write_proc(struct file *file, const char __user *buffer, size_t count, loff_t *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  557) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  558) 	u8 buf[8] = {0};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  559) 	char temp_buf[CONFIG_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  560) 	char *path_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  561) 	int tmp = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  562) 	int tmp1 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  563) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  564) 	print_info("[tp-gsl][%s] \n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  565) 	if (count > 512) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  566) 		print_info("size not match [%d:%ld]\n", CONFIG_LEN, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  567) 		return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  568) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  569) 	path_buf = kzalloc(count, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  570) 	if (!path_buf) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  571) 		pr_info("alloc path_buf memory error \n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  572) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  573) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  574) 	if (copy_from_user(path_buf, buffer, count)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  575) 		print_info("copy from user fail\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  576) 		goto exit_write_proc_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  577) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  578) 	memcpy(temp_buf, path_buf, (count < CONFIG_LEN ? count : CONFIG_LEN));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  579) 	print_info("[tp-gsl][%s][%s]\n", __func__, temp_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  580) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  581) 	buf[3] = char_to_int(temp_buf[14]) << 4 | char_to_int(temp_buf[15]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  582) 	buf[2] = char_to_int(temp_buf[16]) << 4 | char_to_int(temp_buf[17]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  583) 	buf[1] = char_to_int(temp_buf[18]) << 4 | char_to_int(temp_buf[19]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  584) 	buf[0] = char_to_int(temp_buf[20]) << 4 | char_to_int(temp_buf[21]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  585) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  586) 	buf[7] = char_to_int(temp_buf[5]) << 4 | char_to_int(temp_buf[6]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  587) 	buf[6] = char_to_int(temp_buf[7]) << 4 | char_to_int(temp_buf[8]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  588) 	buf[5] = char_to_int(temp_buf[9]) << 4 | char_to_int(temp_buf[10]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  589) 	buf[4] = char_to_int(temp_buf[11]) << 4 | char_to_int(temp_buf[12]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  590) 	if ('v' == temp_buf[0] && 's' == temp_buf[1]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  591) 		memcpy(gsl_read, temp_buf, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  592) 		pr_info("gsl version\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  593) 	} else if ('s' == temp_buf[0] && 't' == temp_buf[1]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  594) 	#ifdef GSL_MONITOR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  595) 		cancel_delayed_work_sync(&gsl_monitor_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  596) 	#endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  597) 		gsl_proc_flag = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  598) 		reset_chip(gsl_client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  599) 	} else if ('e' == temp_buf[0] && 'n' == temp_buf[1])	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  600) 		msleep(20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  601) 		reset_chip(gsl_client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  602) 		startup_chip(gsl_client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  603) 		gsl_proc_flag = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  604) 	} else if ('r' == temp_buf[0] && 'e' == temp_buf[1]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  605) 		memcpy(gsl_read, temp_buf, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  606) 		memcpy(gsl_data_proc, buf, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  607) 	} else if ('w' == temp_buf[0] && 'r' == temp_buf[1]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  608) 		gsl_ts_write(gsl_client, buf[4], buf, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  609) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  610) #ifdef GSL_NOID_VERSION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  611) 	else if ('i' == temp_buf[0] && 'd' == temp_buf[1]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  612) 		tmp1 = (buf[7] << 24) | (buf[6] << 16) | (buf[5] << 8) | buf[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  613) 		tmp = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  614) 		if (tmp1 >= 0 && tmp1 < ARRAY_SIZE(gsl_config_data_id))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  615) 			gsl_config_data_id[tmp1] = tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  616) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  617) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  618) exit_write_proc_out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  619) 	kfree(path_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  620) 	return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  621) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  622) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  623) static int gsl_server_list_open(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  624) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  625) 	return single_open(file, gsl_config_read_proc, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  626) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  627) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  628) static const struct file_operations gsl_seq_fops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  629) 	.open = gsl_server_list_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  630) 	.read = seq_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  631) 	.release = single_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  632) 	.write = gsl_config_write_proc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  633) 	.owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  634) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  635) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  636) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  637) #ifdef FILTER_POINT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  638) static void filter_point(u16 x, u16 y, u8 id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  639) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  640) 	u16 x_err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  641) 	u16 y_err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  642) 	u16 filter_step_x = 0, filter_step_y = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  643) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  644) 	id_sign[id] = id_sign[id] + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  645) 	if (id_sign[id] == 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  646) 		x_old[id] = x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  647) 		y_old[id] = y;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  648) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  649) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  650) 	x_err = x > x_old[id] ? (x - x_old[id]) : (x_old[id] - x);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  651) 	y_err = y > y_old[id] ? (y - y_old[id]) : (y_old[id] - y);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  652) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  653) 	if ((x_err > FILTER_MAX && y_err > FILTER_MAX / 3) || (x_err > FILTER_MAX / 3 && y_err > FILTER_MAX)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  654) 		filter_step_x = x_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  655) 		filter_step_y = y_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  656) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  657) 		if (x_err > FILTER_MAX)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  658) 			filter_step_x = x_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  659) 		if (y_err > FILTER_MAX)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  660) 			filter_step_y = y_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  661) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  662) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  663) 	if (x_err <= 2 * FILTER_MAX && y_err <= 2 * FILTER_MAX) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  664) 		filter_step_x >>= 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  665) 		filter_step_y >>= 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  666) 	} else if (x_err <= 3 * FILTER_MAX && y_err <= 3 * FILTER_MAX) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  667) 		filter_step_x >>= 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  668) 		filter_step_y >>= 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  669) 	} else if (x_err <= 4 * FILTER_MAX && y_err <= 4 * FILTER_MAX) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  670) 		filter_step_x = filter_step_x * 3 / 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  671) 		filter_step_y = filter_step_y * 3 / 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  672) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  673) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  674) 	x_new = x > x_old[id] ? (x_old[id] + filter_step_x) : (x_old[id] - filter_step_x);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  675) 	y_new = y > y_old[id] ? (y_old[id] + filter_step_y) : (y_old[id] - filter_step_y);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  676) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  677) 	x_old[id] = x_new;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  678) 	y_old[id] = y_new;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  679) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  680) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  681) static void record_point(u16 x, u16 y, u8 id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  682) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  683) 	u16 x_err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  684) 	u16 y_err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  685) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  686) 	id_sign[id] = id_sign[id] + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  687) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  688) 	if (id_sign[id] == 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  689) 		x_old[id] = x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  690) 		y_old[id] = y;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  691) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  692) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  693) 	x = (x_old[id] + x) / 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  694) 	y = (y_old[id] + y) / 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  695) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  696) 	if (x > x_old[id])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  697) 		x_err = x - x_old[id];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  698) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  699) 		x_err = x_old[id] - x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  700) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  701) 	if (y > y_old[id])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  702) 		y_err = y - y_old[id];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  703) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  704) 		y_err = y_old[id] - y;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  705) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  706) 	if ((x_err > 3 && y_err > 1) || (x_err > 1 && y_err > 3)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  707) 		x_new = x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  708) 		x_old[id] = x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  709) 		y_new = y;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  710) 		y_old[id] = y;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  711) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  712) 		if (x_err > 3) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  713) 			x_new = x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  714) 			x_old[id] = x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  715) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  716) 			x_new = x_old[id];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  717) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  718) 		if (y_err > 3) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  719) 			y_new = y;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  720) 			y_old[id] = y;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  721) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  722) 			y_new = y_old[id];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  723) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  724) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  725) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  726) 	if (id_sign[id] == 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  727) 		x_new = x_old[id];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  728) 		y_new = y_old[id];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  729) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  730) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  731) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  732) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  733) #ifdef HAVE_TOUCH_KEY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  734) static void report_key(struct gsl_ts *ts, u16 x, u16 y)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  735) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  736) 	u16 i = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  737) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  738) 	for (i = 0; i < MAX_KEY_NUM; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  739) 		if ((gsl_key_data[i].x_min < x) && (x < gsl_key_data[i].x_max) && (gsl_key_data[i].y_min < y) && (y < gsl_key_data[i].y_max)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  740) 			key = gsl_key_data[i].key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  741) 			input_report_key(ts->input, key, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  742) 			input_sync(ts->input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  743) 			key_state_flag = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  744) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  745) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  746) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  747) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  748) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  749) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  750) static void report_data(struct gsl_ts *ts, u16 x, u16 y, u8 pressure, u8 id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  751) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  752) 	if (revert_xy)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  753) 		swap(x, y);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  754) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  755) 	print_info("#####id=%d,x=%d,y=%d######\n", id, x, y);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  756) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  757) 	if (x > SCREEN_MAX_X || y > SCREEN_MAX_Y) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  758) 	#ifdef HAVE_TOUCH_KEY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  759) 		report_key(ts, x, y);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  760) 	#endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  761) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  762) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  763) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  764) 	if (revert_x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  765) 		x = SCREEN_MAX_X - x - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  766) 	if (revert_y)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  767) 		y = SCREEN_MAX_Y - y - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  768) #ifdef REPORT_DATA_ANDROID_4_0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  769) 	input_mt_slot(ts->input, id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  770) 	input_report_abs(ts->input, ABS_MT_TRACKING_ID, id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  771) 	input_report_abs(ts->input, ABS_MT_TOUCH_MAJOR, pressure);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  772) 	input_report_abs(ts->input, ABS_MT_POSITION_X, x);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  773) 	input_report_abs(ts->input, ABS_MT_POSITION_Y, y);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  774) 	input_report_abs(ts->input, ABS_MT_WIDTH_MAJOR, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  775) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  776) 	input_report_abs(ts->input, ABS_MT_TRACKING_ID, id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  777) 	input_report_abs(ts->input, ABS_MT_TOUCH_MAJOR, pressure);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  778) 	input_report_abs(ts->input, ABS_MT_POSITION_X, x);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  779) 	input_report_abs(ts->input, ABS_MT_POSITION_Y, y);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  780) 	input_report_abs(ts->input, ABS_MT_WIDTH_MAJOR, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  781) 	input_mt_sync(ts->input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  782) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  783) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  784) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  785) static void gslX680_ts_worker(struct work_struct *work)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  786) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  787) 	int rc, i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  788) 	u8 id, touches;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  789) 	u16 x, y;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  790) #ifdef GSL_NOID_VERSION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  791) 	unsigned int tmp1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  792) 	u8 buf[4] = {0};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  793) 	struct gsl_touch_info cinfo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  794) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  795) 	struct gsl_ts *ts = container_of(work, struct gsl_ts, work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  796) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  797) 	print_info("=====gslX680_ts_worker=====\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  798) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  799) #ifdef TPD_PROC_DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  800) 	if (gsl_proc_flag == 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  801) 		goto schedule;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  802) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  803) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  804) #ifdef GSL_MONITOR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  805) 	if (i2c_lock_flag != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  806) 		goto i2c_lock_schedule;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  807) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  808) 		i2c_lock_flag = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  809) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  810) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  811) 	rc = gsl_ts_read(ts->client, 0x80, ts->touch_data, ts->dd->data_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  812) 	if (rc < 0)  {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  813) 		dev_err(&ts->client->dev, "read failed\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  814) 		reset_chip(ts->client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  815) 		startup_chip(ts->client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  816) 		goto schedule;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  817) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  818) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  819) 	touches = ts->touch_data[ts->dd->touch_index];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  820) 	print_info("-----touches: %d -----\n", touches);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  821) #ifdef GSL_NOID_VERSION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  822) 	cinfo.finger_num = touches;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  823) 	print_info("tp-gsl  finger_num = %d\n", cinfo.finger_num);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  824) 	for (i = 0; i < (touches < MAX_CONTACTS ? touches : MAX_CONTACTS); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  825) 		cinfo.x[i] = join_bytes((ts->touch_data[ts->dd->x_index  + 4 * i + 1] & 0xf),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  826) 				ts->touch_data[ts->dd->x_index + 4 * i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  827) 		cinfo.y[i] = join_bytes(ts->touch_data[ts->dd->y_index + 4 * i + 1],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  828) 							ts->touch_data[ts->dd->y_index + 4 * i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  829) 		print_info("tp-gsl  x = %d y = %d \n", cinfo.x[i], cinfo.y[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  830) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  831) 	cinfo.finger_num = (ts->touch_data[3] << 24) | (ts->touch_data[2] << 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  832) 		| (ts->touch_data[1] << 8) | (ts->touch_data[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  833) 	gsl_alg_id_main(&cinfo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  834) 	tmp1 = gsl_mask_tiaoping();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  835) 	print_info("[tp-gsl] tmp1=%x\n", tmp1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  836) 	if (tmp1 > 0 && tmp1 < 0xffffffff) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  837) 		buf[0] = 0xa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  838) 		buf[1] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  839) 		buf[2] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  840) 		buf[3] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  841) 		gsl_ts_write(ts->client, 0xf0, buf, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  842) 		buf[0] = (u8)(tmp1 & 0xff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  843) 		buf[1] = (u8)((tmp1 >> 8) & 0xff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  844) 		buf[2] = (u8)((tmp1 >> 16) & 0xff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  845) 		buf[3] = (u8)((tmp1 >> 24) & 0xff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  846) 		print_info("tmp1=%08x,buf[0]=%02x,buf[1]=%02x,buf[2]=%02x,buf[3]=%02x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  847) 					tmp1, buf[0], buf[1], buf[2], buf[3]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  848) 		gsl_ts_write(ts->client, 0x8, buf, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  849) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  850) 	touches = cinfo.finger_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  851) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  852) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  853) 	for (i = 1; i <= MAX_CONTACTS; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  854) 		if (touches == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  855) 			id_sign[i] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  856) 		id_state_flag[i] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  857) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  858) 	for (i = 0; i < (touches > MAX_FINGERS ? MAX_FINGERS : touches); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  859) 	#ifdef GSL_NOID_VERSION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  860) 		id = cinfo.id[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  861) 		x =  cinfo.x[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  862) 		y =  cinfo.y[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  863) 	#else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  864) 		x = join_bytes((ts->touch_data[ts->dd->x_index  + 4 * i + 1] & 0xf),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  865) 					ts->touch_data[ts->dd->x_index + 4 * i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  866) 		y = join_bytes(ts->touch_data[ts->dd->y_index + 4 * i + 1],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  867) 					ts->touch_data[ts->dd->y_index + 4 * i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  868) 		id = ts->touch_data[ts->dd->id_index + 4 * i] >> 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  869) 	#endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  870) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  871) 		if (id >= 1 && id <= MAX_CONTACTS) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  872) 		#ifdef FILTER_POINT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  873) 			filter_point(x, y, id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  874) 		#else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  875) 			record_point(x, y, id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  876) 		#endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  877) 			report_data(ts, x_new, y_new, 10, id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  878) 			id_state_flag[id] = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  879) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  880) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  881) 	for (i = 1; i <= MAX_CONTACTS; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  882) 		if ((touches == 0) || ((id_state_old_flag[i] != 0) && (id_state_flag[i] == 0)))	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  883) 		#ifdef REPORT_DATA_ANDROID_4_0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  884) 			input_mt_slot(ts->input, i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  885) 			input_report_abs(ts->input, ABS_MT_TRACKING_ID, -1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  886) 			input_mt_report_slot_state(ts->input, MT_TOOL_FINGER, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  887) 		#endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  888) 			id_sign[i] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  889) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  890) 		id_state_old_flag[i] = id_state_flag[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  891) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  892) #ifndef REPORT_DATA_ANDROID_4_0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  893) 	if (touches == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  894) 		input_mt_sync(ts->input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  895) 	#ifdef HAVE_TOUCH_KEY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  896) 		if (key_state_flag) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  897) 			input_report_key(ts->input, key, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  898) 			input_sync(ts->input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  899) 			key_state_flag = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  900) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  901) 	#endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  902) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  903) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  904) 	input_sync(ts->input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  905) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  906) schedule:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  907) #ifdef GSL_MONITOR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  908) 	i2c_lock_flag = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  909) i2c_lock_schedule:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  910) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  911) 	enable_irq(ts->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  912) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  913) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  914) #ifdef GSL_MONITOR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  915) static void gsl_monitor_worker(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  916) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  917) 	char write_buf[4] = {0};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  918) 	char read_buf[4]  = {0};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  919) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  920) 	print_info("----------------gsl_monitor_worker-----------------\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  921) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  922) 	if (i2c_lock_flag != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  923) 		goto queue_monitor_work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  924) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  925) 		i2c_lock_flag = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  926) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  927) 	gsl_ts_read(gsl_client, 0xb0, read_buf, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  928) 	if (read_buf[3] != 0x5a || read_buf[2] != 0x5a || read_buf[1] != 0x5a || read_buf[0] != 0x5a)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  929) 		b0_counter++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  930) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  931) 		b0_counter = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  932) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  933) 	if (b0_counter > 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  934) 		pr_info("======read 0xb0: %x %x %x %x ======\n", read_buf[3], read_buf[2], read_buf[1], read_buf[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  935) 		init_chip(gsl_client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  936) 		b0_counter = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  937) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  938) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  939) 	gsl_ts_read(gsl_client, 0xb4, read_buf, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  940) 	int_2nd[3] = int_1st[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  941) 	int_2nd[2] = int_1st[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  942) 	int_2nd[1] = int_1st[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  943) 	int_2nd[0] = int_1st[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  944) 	int_1st[3] = read_buf[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  945) 	int_1st[2] = read_buf[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  946) 	int_1st[1] = read_buf[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  947) 	int_1st[0] = read_buf[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  948) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  949) 	if (int_1st[3] == int_2nd[3] && int_1st[2] == int_2nd[2] && int_1st[1] == int_2nd[1] && int_1st[0] == int_2nd[0]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  950) 		pr_info("======int_1st: %x %x %x %x , int_2nd: %x %x %x %x ======\n", int_1st[3], int_1st[2], int_1st[1], int_1st[0], int_2nd[3], int_2nd[2], int_2nd[1], int_2nd[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  951) 		init_chip(gsl_client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  952) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  953) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  954) 	write_buf[3] = 0x01;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  955) 	write_buf[2] = 0xfe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  956) 	write_buf[1] = 0x10;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  957) 	write_buf[0] = 0x00;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  958) 	gsl_ts_write(gsl_client, 0xf0, write_buf, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  959) 	gsl_ts_read(gsl_client, 0x10, read_buf, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  960) 	gsl_ts_read(gsl_client, 0x10, read_buf, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  961) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  962) 	if (read_buf[3] < 10 && read_buf[2] < 10 && read_buf[1] < 10 && read_buf[0] < 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  963) 		dac_counter++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  964) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  965) 		dac_counter = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  966) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  967) 	if (dac_counter > 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  968) 		pr_info("======read DAC1_0: %x %x %x %x ======\n", read_buf[3], read_buf[2], read_buf[1], read_buf[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  969) 		init_chip(gsl_client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  970) 		dac_counter = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  971) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  972) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  973) 	i2c_lock_flag = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  974) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  975) queue_monitor_work:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  976) 	queue_delayed_work(gsl_monitor_workqueue, &gsl_monitor_work, 100);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  977) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  978) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  979) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  980) static irqreturn_t gsl_ts_irq(int irq, void *dev_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  981) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  982) 	struct gsl_ts *ts = dev_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  983) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  984) 	print_info("========gslX680 Interrupt=========\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  985) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  986) 	disable_irq_nosync(ts->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  987) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  988) 	if (!work_pending(&ts->work))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  989) 		queue_work(ts->wq, &ts->work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  990) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  991) 	return IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  992) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  993) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  994) static int gslX680_ts_init(struct i2c_client *client, struct gsl_ts *ts)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  995) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  996) 	struct input_dev *input_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  997) 	int rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  998) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  999) 	pr_info("[GSLX680] Enter %s\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) 	ts->dd = &devices[ts->device_id];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) 	if (ts->device_id == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) 		ts->dd->data_size = MAX_FINGERS * ts->dd->touch_bytes + ts->dd->touch_meta_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) 		ts->dd->touch_index = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) 	ts->touch_data = devm_kzalloc(&client->dev, ts->dd->data_size, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) 	if (!ts->touch_data) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) 		pr_err("%s: Unable to allocate memory\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) 	input_device = devm_input_allocate_device(&client->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) 	if (!input_device) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) 		rc = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) 		goto error_alloc_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) 	ts->input = input_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) 	input_device->name = GSLX680_I2C_NAME;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) 	input_device->id.bustype = BUS_I2C;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) 	input_device->dev.parent = &client->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) 	input_set_drvdata(input_device, ts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) #ifdef REPORT_DATA_ANDROID_4_0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) 	__set_bit(EV_ABS, input_device->evbit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) 	__set_bit(EV_KEY, input_device->evbit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) 	__set_bit(EV_REP, input_device->evbit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) 	__set_bit(INPUT_PROP_DIRECT, input_device->propbit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) 	input_mt_init_slots(input_device, (MAX_CONTACTS + 1), 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) 	input_set_abs_params(input_device, ABS_MT_TRACKING_ID, 0, (MAX_CONTACTS + 1), 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) 	set_bit(EV_ABS, input_device->evbit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) 	set_bit(EV_KEY, input_device->evbit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) 	__set_bit(INPUT_PROP_DIRECT, input_device->propbit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) 	input_device->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) #ifdef HAVE_TOUCH_KEY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) 	input_device->evbit[0] = BIT_MASK(EV_KEY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) 	for (i = 0; i < MAX_KEY_NUM; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) 		set_bit(key_array[i], input_device->keybit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046) 	set_bit(ABS_MT_POSITION_X, input_device->absbit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) 	set_bit(ABS_MT_POSITION_Y, input_device->absbit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) 	set_bit(ABS_MT_TOUCH_MAJOR, input_device->absbit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) 	set_bit(ABS_MT_WIDTH_MAJOR, input_device->absbit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051) 	input_set_abs_params(input_device, ABS_MT_POSITION_X, 0, SCREEN_MAX_X, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) 	input_set_abs_params(input_device, ABS_MT_POSITION_Y, 0, SCREEN_MAX_Y, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) 	input_set_abs_params(input_device, ABS_MT_TOUCH_MAJOR, 0, PRESS_MAX, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) 	input_set_abs_params(input_device, ABS_MT_WIDTH_MAJOR, 0, 200, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) 	ts->wq = create_singlethread_workqueue("kworkqueue_ts");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) 	if (!ts->wq) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058) 		dev_err(&client->dev, "Could not create workqueue\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) 		goto error_wq_create;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) 	flush_workqueue(ts->wq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) 	INIT_WORK(&ts->work, gslX680_ts_worker);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) 	rc = input_register_device(input_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066) 	if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) 		goto error_unreg_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071) error_unreg_device:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) 	destroy_workqueue(ts->wq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) error_wq_create:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074) error_alloc_dev:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078) static int gsl_ts_suspend(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080) 	struct gsl_ts *ts = dev_get_drvdata(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083) 	pr_info("I'am in gsl_ts_suspend() start\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085) #ifdef GSL_MONITOR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086) 	pr_info("gsl_ts_suspend () : cancel gsl_monitor_work\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087) 	cancel_delayed_work_sync(&gsl_monitor_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090) 	disable_irq_nosync(ts->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) 	gslX680_shutdown_low();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094) #ifdef SLEEP_CLEAR_POINT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095) 	msleep(10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) 	#ifdef REPORT_DATA_ANDROID_4_0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097) 	for (i = 1; i <= MAX_CONTACTS; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098) 		input_mt_slot(ts->input, i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) 		input_report_abs(ts->input, ABS_MT_TRACKING_ID, -1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) 		input_mt_report_slot_state(ts->input, MT_TOOL_FINGER, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102) 	#else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103) 	input_mt_sync(ts->input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104) 	#endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105) 	input_sync(ts->input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106) 	msleep(10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107) 	report_data(ts, 1, 1, 10, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108) 	input_sync(ts->input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) static int gsl_ts_resume(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) 	struct gsl_ts *ts = dev_get_drvdata(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) 	pr_info("I'am in gsl_ts_resume() start\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121) 	gslX680_shutdown_high();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122) 	msleep(20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) 	reset_chip(ts->client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124) 	startup_chip(ts->client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125) 	check_mem_data(ts->client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) #ifdef SLEEP_CLEAR_POINT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128) 	#ifdef REPORT_DATA_ANDROID_4_0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129) 	for (i = 1; i <= MAX_CONTACTS; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130) 		input_mt_slot(ts->input, i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131) 		input_report_abs(ts->input, ABS_MT_TRACKING_ID, -1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132) 		input_mt_report_slot_state(ts->input, MT_TOOL_FINGER, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134) 	#else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135) 	input_mt_sync(ts->input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136) 	#endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137) 	input_sync(ts->input);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139) #ifdef GSL_MONITOR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140) 	pr_info("gsl_ts_resume () : queue gsl_monitor_work\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141) 	queue_delayed_work(gsl_monitor_workqueue, &gsl_monitor_work, 300);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143) 	pr_info("gsl_ts_resume () end\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144) 	enable_irq(ts->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148) #if 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149) static int gsl_ts_early_suspend(struct tp_device *tp_d)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151) 	struct gsl_ts *ts = container_of(tp_d, struct gsl_ts, tp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153) 	pr_info("[GSLX680] Enter %s\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154) 	return gsl_ts_suspend(&ts->client->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157) static int gsl_ts_late_resume(struct tp_device *tp_d)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159) 	struct gsl_ts *ts = container_of(tp_d, struct gsl_ts, tp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) 	pr_info("[GSLX680] Enter %s\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162) 	return gsl_ts_resume(&ts->client->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166) static int  gsl_ts_probe(struct i2c_client *client, const struct i2c_device_id *id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168) 	struct gsl_ts *ts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169) 	int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170) 	struct device_node *np = client->dev.of_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171) 	enum of_gpio_flags wake_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172) 	unsigned long irq_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174) 	pr_info("GSLX680 Enter %s\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175) 	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176) 		dev_err(&client->dev, "I2C functionality not supported\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179) 	ts = devm_kzalloc(&client->dev, sizeof(*ts), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180) 	if (!ts)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1182) 	pr_info("==kzalloc success=\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1183) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1184) 	ts->client = client;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185) 	i2c_set_clientdata(client, ts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186) 	ts->device_id = id->driver_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188) 	ts->irq_pin = of_get_named_gpio_flags(np, "irq-gpio", 0, (enum of_gpio_flags *)&irq_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189) 	ts->wake_pin = of_get_named_gpio_flags(np, "wake-gpio", 0, &wake_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191) 	if (gpio_is_valid(ts->wake_pin)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192) 		rc = devm_gpio_request_one(&client->dev, ts->wake_pin, (wake_flags & OF_GPIO_ACTIVE_LOW) ? GPIOF_OUT_INIT_LOW : GPIOF_OUT_INIT_HIGH, "gslX680 wake pin");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193) 		if (rc != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194) 			dev_err(&client->dev, "gslX680 wake pin error\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197) 		g_wake_pin = ts->wake_pin;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199) 		dev_info(&client->dev, "wake pin invalid\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201) 	if (gpio_is_valid(ts->irq_pin)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202) 		rc = devm_gpio_request_one(&client->dev, ts->irq_pin, (irq_flags & OF_GPIO_ACTIVE_LOW) ? GPIOF_OUT_INIT_LOW : GPIOF_OUT_INIT_HIGH, "gslX680 irq pin");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203) 		if (rc != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204) 			dev_err(&client->dev, "gslX680 irq pin error\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205) 			return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208) 		dev_info(&client->dev, "irq pin invalid\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211) 	rc = gslX680_ts_init(client, ts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212) 	if (rc < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1213) 		dev_err(&client->dev, "GSLX680 init failed\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1214) 		goto error_mutex_destroy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1215) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1216) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1217) 	gsl_client = client;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1218) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1219) 	init_chip(ts->client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1220) 	check_mem_data(ts->client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1221) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1222) 	ts->irq = gpio_to_irq(ts->irq_pin);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1223) 	if (ts->irq) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1224) 		rc = devm_request_irq(&client->dev, ts->irq, gsl_ts_irq, IRQF_TRIGGER_RISING, client->name, ts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1225) 		if (rc != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1226) 			pr_info("Cannot allocate ts INT!ERRNO:%d\n", rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1227) 			goto error_req_irq_fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1228) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1229) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1230) 		pr_info("gsl x680 irq req fail\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1231) 		goto error_req_irq_fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1232) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1233) 	/* create debug attribute */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1234) 	ts->tp.tp_resume = gsl_ts_late_resume;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1235) 	ts->tp.tp_suspend = gsl_ts_early_suspend;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1236) 	tp_register_fb(&ts->tp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1237) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1238) #ifdef CONFIG_HAS_EARLYSUSPEND
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1239) 	ts->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1240) 	ts->early_suspend.suspend = gsl_ts_early_suspend;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1241) 	ts->early_suspend.resume = gsl_ts_late_resume;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1242) 	register_early_suspend(&ts->early_suspend);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1243) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1244) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1245) #ifdef GSL_MONITOR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1246) 	pr_info("gsl_ts_probe () : queue gsl_monitor_workqueue\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1247) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1248) 	INIT_DELAYED_WORK(&gsl_monitor_work, gsl_monitor_worker);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1249) 	gsl_monitor_workqueue = create_singlethread_workqueue("gsl_monitor_workqueue");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1250) 	queue_delayed_work(gsl_monitor_workqueue, &gsl_monitor_work, 1000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1251) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1252) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1253) #ifdef TPD_PROC_DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1254) 	proc_create(GSL_CONFIG_PROC_FILE, 0644, NULL, &gsl_seq_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1255) 	gsl_proc_flag = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1256) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1257) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1258) 	pr_info("[GSLX680] End %s\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1259) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1260) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1261) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1262) error_req_irq_fail:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1263) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1264) error_mutex_destroy:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1265) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1266) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1267) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1268) static int gsl_ts_remove(struct i2c_client *client)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1269) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1270) 	struct gsl_ts *ts = i2c_get_clientdata(client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1271) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1272) 	pr_info("==gsl_ts_remove=\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1273) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1274) #ifdef CONFIG_HAS_EARLYSUSPEND
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1275) 	unregister_early_suspend(&ts->early_suspend);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1276) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1277) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1278) #ifdef GSL_MONITOR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1279) 	cancel_delayed_work_sync(&gsl_monitor_work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1280) 	destroy_workqueue(gsl_monitor_workqueue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1281) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1282) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1283) 	device_init_wakeup(&client->dev, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1284) 	cancel_work_sync(&ts->work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1285) 	destroy_workqueue(ts->wq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1286) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1287) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1288) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1289) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1290) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1291) static const struct i2c_device_id gsl_ts_id[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1292) 	{GSLX680_I2C_NAME, 0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1293) 	{}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1294) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1295) MODULE_DEVICE_TABLE(i2c, gsl_ts_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1296) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1297) #ifdef CONFIG_OF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1298) static const struct of_device_id gslx680a_of_match[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1299) 	{.compatible = "gsl,gslx680a"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1300) 	{}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1301) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1302) MODULE_DEVICE_TABLE(of, gslx680a_of_match);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1303) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1304) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1305) static struct i2c_driver gsl_ts_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1306) 	.driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1307) 		.of_match_table = of_match_ptr(gslx680a_of_match),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1308) 		.name = GSLX680_I2C_NAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1309) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1310) 	.probe		= gsl_ts_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1311) 	.remove		= gsl_ts_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1312) 	.id_table	= gsl_ts_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1313) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1314) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1315) module_i2c_driver(gsl_ts_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1316) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1317) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1318) MODULE_DESCRIPTION("GSLX680 touchscreen controller driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1319) MODULE_AUTHOR("Guan Yuwei, guanyuwei@basewin.com");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1320) MODULE_ALIAS("platform:gsl_ts");