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