Orange Pi5 kernel

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

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