input: touchpanel: Add GT9xx touchpanel driver for skuf
This is the reference driver source code V1.8 for the GT9XX series.For this first commit just copy binary, the second commit decompress the binary and the third commit upgrade the version. We just need the newest version, so Squashed the following commits: commit 31915760747230826fa474fbb5b06a70b103c7e7 Author: Andrew Huang <andrew@goodix.com> Date: Thu Jun 27 10:06:56 2013 +0000 This is the official reference driver source code V1.8 for the GT9XX series CTP controller,release for CIENET. Signed-off-by: Andrew Huang <andrew@goodix.com> git-svn-id: http://gtp-drivers-for-android.googlecode.com/svn//drivers@15 4d552555-e8e2-8f43-36d7-85641c3b7a2e commit 82f70eaf58b0996e9f488b170f81a107642d4df8 Author: unknowtree@gmail.com <unknowtree@gmail.com> Date: Thu Jun 6 02:58:58 2013 +0000 git-svn-id: http://gtp-drivers-for-android.googlecode.com/svn//drivers@7 4d552555-e8e2-8f43-36d7-85641c3b7a2e commit 5c42b80f40a9731ac45d4e04a7a7528367f713e7 Author: unknowtree@gmail.com <unknowtree@gmail.com> Date: Tue Jun 4 08:53:01 2013 +0000 git-svn-id: http://gtp-drivers-for-android.googlecode.com/svn//drivers@5 4d552555-e8e2-8f43-36d7-85641c3b7a2e Change-Id: I30420fc51fe1bb153c36342e607539e5cd74de61 Signed-off-by: Pan Fang <fangpan@codeaurora.org> (cherry picked from commit ab45aab306d8b8d16619bc02f35465fb8d6ff066) Signed-off-by: Abinaya P <abinayap@codeaurora.org>
This commit is contained in:
parent
9e4b3ba4af
commit
cb440b458f
5 changed files with 4602 additions and 0 deletions
615
input/touchscreen/gt9xx/goodix_tool.c
Normal file
615
input/touchscreen/gt9xx/goodix_tool.c
Normal file
|
@ -0,0 +1,615 @@
|
|||
/* drivers/input/touchscreen/goodix_tool.c
|
||||
*
|
||||
* 2010 - 2012 Goodix Technology.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be a reference
|
||||
* to you, when you are integrating the GOODiX's CTP IC into your system,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* Version:1.6
|
||||
* V1.0:2012/05/01,create file.
|
||||
* V1.2:2012/06/08,modify some warning.
|
||||
* V1.4:2012/08/28,modified to support GT9XX
|
||||
* V1.6:new proc name
|
||||
*/
|
||||
|
||||
#include "gt9xx.h"
|
||||
|
||||
#define DATA_LENGTH_UINT 512
|
||||
#define CMD_HEAD_LENGTH (sizeof(st_cmd_head) - sizeof(u8*))
|
||||
static char procname[20] = {0};
|
||||
|
||||
#define UPDATE_FUNCTIONS
|
||||
|
||||
#ifdef UPDATE_FUNCTIONS
|
||||
extern s32 gup_enter_update_mode(struct i2c_client *client);
|
||||
extern void gup_leave_update_mode(void);
|
||||
extern s32 gup_update_proc(void *dir);
|
||||
#endif
|
||||
|
||||
extern void gtp_irq_disable(struct goodix_ts_data *);
|
||||
extern void gtp_irq_enable(struct goodix_ts_data *);
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct{
|
||||
u8 wr; //write read flag£¬0:R 1:W 2:PID 3:
|
||||
u8 flag; //0:no need flag/int 1: need flag 2:need int
|
||||
u8 flag_addr[2]; //flag address
|
||||
u8 flag_val; //flag val
|
||||
u8 flag_relation; //flag_val:flag 0:not equal 1:equal 2:> 3:<
|
||||
u16 circle; //polling cycle
|
||||
u8 times; //plling times
|
||||
u8 retry; //I2C retry times
|
||||
u16 delay; //delay befor read or after write
|
||||
u16 data_len; //data length
|
||||
u8 addr_len; //address length
|
||||
u8 addr[2]; //address
|
||||
u8 res[3]; //reserved
|
||||
u8* data; //data pointer
|
||||
}st_cmd_head;
|
||||
#pragma pack()
|
||||
st_cmd_head cmd_head;
|
||||
|
||||
static struct i2c_client *gt_client = NULL;
|
||||
|
||||
static struct proc_dir_entry *goodix_proc_entry;
|
||||
|
||||
static s32 goodix_tool_write(struct file *filp, const char __user *buff, unsigned long len, void *data);
|
||||
static s32 goodix_tool_read( char *page, char **start, off_t off, int count, int *eof, void *data );
|
||||
static s32 (*tool_i2c_read)(u8 *, u16);
|
||||
static s32 (*tool_i2c_write)(u8 *, u16);
|
||||
|
||||
#if GTP_ESD_PROTECT
|
||||
extern void gtp_esd_switch(struct i2c_client *, s32);
|
||||
#endif
|
||||
s32 DATA_LENGTH = 0;
|
||||
s8 IC_TYPE[16] = {0};
|
||||
|
||||
static void tool_set_proc_name(char * procname)
|
||||
{
|
||||
char *months[12] = {"Jan", "Feb", "Mar", "Apr", "May",
|
||||
"Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
|
||||
char date[20] = {0};
|
||||
char month[4] = {0};
|
||||
int i = 0, n_month = 1, n_day = 0, n_year = 0;
|
||||
|
||||
sprintf(date, "%s", __DATE__);
|
||||
|
||||
//GTP_DEBUG("compile date: %s", date);
|
||||
|
||||
sscanf(date, "%s %d %d", month, &n_day, &n_year);
|
||||
|
||||
for (i = 0; i < 12; ++i)
|
||||
{
|
||||
if (!memcmp(months[i], month, 3))
|
||||
{
|
||||
n_month = i+1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
sprintf(procname, "gmnode%04d%02d%02d", n_year, n_month, n_day);
|
||||
|
||||
//GTP_DEBUG("procname = %s", procname);
|
||||
}
|
||||
|
||||
|
||||
static s32 tool_i2c_read_no_extra(u8* buf, u16 len)
|
||||
{
|
||||
s32 ret = -1;
|
||||
s32 i = 0;
|
||||
struct i2c_msg msgs[2];
|
||||
|
||||
msgs[0].flags = !I2C_M_RD;
|
||||
msgs[0].addr = gt_client->addr;
|
||||
msgs[0].len = cmd_head.addr_len;
|
||||
msgs[0].buf = &buf[0];
|
||||
|
||||
msgs[1].flags = I2C_M_RD;
|
||||
msgs[1].addr = gt_client->addr;
|
||||
msgs[1].len = len;
|
||||
msgs[1].buf = &buf[GTP_ADDR_LENGTH];
|
||||
|
||||
for (i = 0; i < cmd_head.retry; i++)
|
||||
{
|
||||
ret=i2c_transfer(gt_client->adapter, msgs, 2);
|
||||
if (ret > 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static s32 tool_i2c_write_no_extra(u8* buf, u16 len)
|
||||
{
|
||||
s32 ret = -1;
|
||||
s32 i = 0;
|
||||
struct i2c_msg msg;
|
||||
|
||||
msg.flags = !I2C_M_RD;
|
||||
msg.addr = gt_client->addr;
|
||||
msg.len = len;
|
||||
msg.buf = buf;
|
||||
|
||||
for (i = 0; i < cmd_head.retry; i++)
|
||||
{
|
||||
ret=i2c_transfer(gt_client->adapter, &msg, 1);
|
||||
if (ret > 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static s32 tool_i2c_read_with_extra(u8* buf, u16 len)
|
||||
{
|
||||
s32 ret = -1;
|
||||
u8 pre[2] = {0x0f, 0xff};
|
||||
u8 end[2] = {0x80, 0x00};
|
||||
|
||||
tool_i2c_write_no_extra(pre, 2);
|
||||
ret = tool_i2c_read_no_extra(buf, len);
|
||||
tool_i2c_write_no_extra(end, 2);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static s32 tool_i2c_write_with_extra(u8* buf, u16 len)
|
||||
{
|
||||
s32 ret = -1;
|
||||
u8 pre[2] = {0x0f, 0xff};
|
||||
u8 end[2] = {0x80, 0x00};
|
||||
|
||||
tool_i2c_write_no_extra(pre, 2);
|
||||
ret = tool_i2c_write_no_extra(buf, len);
|
||||
tool_i2c_write_no_extra(end, 2);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void register_i2c_func(void)
|
||||
{
|
||||
// if (!strncmp(IC_TYPE, "GT818", 5) || !strncmp(IC_TYPE, "GT816", 5)
|
||||
// || !strncmp(IC_TYPE, "GT811", 5) || !strncmp(IC_TYPE, "GT818F", 6)
|
||||
// || !strncmp(IC_TYPE, "GT827", 5) || !strncmp(IC_TYPE,"GT828", 5)
|
||||
// || !strncmp(IC_TYPE, "GT813", 5))
|
||||
if (strncmp(IC_TYPE, "GT8110", 6) && strncmp(IC_TYPE, "GT8105", 6)
|
||||
&& strncmp(IC_TYPE, "GT801", 5) && strncmp(IC_TYPE, "GT800", 5)
|
||||
&& strncmp(IC_TYPE, "GT801PLUS", 9) && strncmp(IC_TYPE, "GT811", 5)
|
||||
&& strncmp(IC_TYPE, "GTxxx", 5))
|
||||
{
|
||||
tool_i2c_read = tool_i2c_read_with_extra;
|
||||
tool_i2c_write = tool_i2c_write_with_extra;
|
||||
GTP_DEBUG("I2C function: with pre and end cmd!");
|
||||
}
|
||||
else
|
||||
{
|
||||
tool_i2c_read = tool_i2c_read_no_extra;
|
||||
tool_i2c_write = tool_i2c_write_no_extra;
|
||||
GTP_INFO("I2C function: without pre and end cmd!");
|
||||
}
|
||||
}
|
||||
|
||||
static void unregister_i2c_func(void)
|
||||
{
|
||||
tool_i2c_read = NULL;
|
||||
tool_i2c_write = NULL;
|
||||
GTP_INFO("I2C function: unregister i2c transfer function!");
|
||||
}
|
||||
|
||||
|
||||
s32 init_wr_node(struct i2c_client *client)
|
||||
{
|
||||
s32 i;
|
||||
|
||||
gt_client = client;
|
||||
memset(&cmd_head, 0, sizeof(cmd_head));
|
||||
cmd_head.data = NULL;
|
||||
|
||||
i = 5;
|
||||
while ((!cmd_head.data) && i)
|
||||
{
|
||||
cmd_head.data = kzalloc(i * DATA_LENGTH_UINT, GFP_KERNEL);
|
||||
if (NULL != cmd_head.data)
|
||||
{
|
||||
break;
|
||||
}
|
||||
i--;
|
||||
}
|
||||
if (i)
|
||||
{
|
||||
DATA_LENGTH = i * DATA_LENGTH_UINT + GTP_ADDR_LENGTH;
|
||||
GTP_INFO("Applied memory size:%d.", DATA_LENGTH);
|
||||
}
|
||||
else
|
||||
{
|
||||
GTP_ERROR("Apply for memory failed.");
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
cmd_head.addr_len = 2;
|
||||
cmd_head.retry = 5;
|
||||
|
||||
register_i2c_func();
|
||||
|
||||
tool_set_proc_name(procname);
|
||||
goodix_proc_entry = create_proc_entry(procname, 0666, NULL);
|
||||
if (goodix_proc_entry == NULL)
|
||||
{
|
||||
GTP_ERROR("Couldn't create proc entry!");
|
||||
return FAIL;
|
||||
}
|
||||
else
|
||||
{
|
||||
GTP_INFO("Create proc entry success!");
|
||||
goodix_proc_entry->write_proc = goodix_tool_write;
|
||||
goodix_proc_entry->read_proc = goodix_tool_read;
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
void uninit_wr_node(void)
|
||||
{
|
||||
kfree(cmd_head.data);
|
||||
cmd_head.data = NULL;
|
||||
unregister_i2c_func();
|
||||
remove_proc_entry(procname, NULL);
|
||||
}
|
||||
|
||||
static u8 relation(u8 src, u8 dst, u8 rlt)
|
||||
{
|
||||
u8 ret = 0;
|
||||
|
||||
switch (rlt)
|
||||
{
|
||||
case 0:
|
||||
ret = (src != dst) ? true : false;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
ret = (src == dst) ? true : false;
|
||||
GTP_DEBUG("equal:src:0x%02x dst:0x%02x ret:%d.", src, dst, (s32)ret);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
ret = (src > dst) ? true : false;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
ret = (src < dst) ? true : false;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
ret = (src & dst) ? true : false;
|
||||
break;
|
||||
|
||||
case 5:
|
||||
ret = (!(src | dst)) ? true : false;
|
||||
break;
|
||||
|
||||
default:
|
||||
ret = false;
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*******************************************************
|
||||
Function:
|
||||
Comfirm function.
|
||||
Input:
|
||||
None.
|
||||
Output:
|
||||
Return write length.
|
||||
********************************************************/
|
||||
static u8 comfirm(void)
|
||||
{
|
||||
s32 i = 0;
|
||||
u8 buf[32];
|
||||
|
||||
// memcpy(&buf[GTP_ADDR_LENGTH - cmd_head.addr_len], &cmd_head.flag_addr, cmd_head.addr_len);
|
||||
// memcpy(buf, &cmd_head.flag_addr, cmd_head.addr_len);//Modified by Scott, 2012-02-17
|
||||
memcpy(buf, cmd_head.flag_addr, cmd_head.addr_len);
|
||||
|
||||
for (i = 0; i < cmd_head.times; i++)
|
||||
{
|
||||
if (tool_i2c_read(buf, 1) <= 0)
|
||||
{
|
||||
GTP_ERROR("Read flag data failed!");
|
||||
return FAIL;
|
||||
}
|
||||
if (true == relation(buf[GTP_ADDR_LENGTH], cmd_head.flag_val, cmd_head.flag_relation))
|
||||
{
|
||||
GTP_DEBUG("value at flag addr:0x%02x.", buf[GTP_ADDR_LENGTH]);
|
||||
GTP_DEBUG("flag value:0x%02x.", cmd_head.flag_val);
|
||||
break;
|
||||
}
|
||||
|
||||
msleep(cmd_head.circle);
|
||||
}
|
||||
|
||||
if (i >= cmd_head.times)
|
||||
{
|
||||
GTP_ERROR("Didn't get the flag to continue!");
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/*******************************************************
|
||||
Function:
|
||||
Goodix tool write function.
|
||||
Input:
|
||||
standard proc write function param.
|
||||
Output:
|
||||
Return write length.
|
||||
********************************************************/
|
||||
static s32 goodix_tool_write(struct file *filp, const char __user *buff, unsigned long len, void *data)
|
||||
{
|
||||
s32 ret = 0;
|
||||
GTP_DEBUG_FUNC();
|
||||
GTP_DEBUG_ARRAY((u8*)buff, len);
|
||||
|
||||
ret = copy_from_user(&cmd_head, buff, CMD_HEAD_LENGTH);
|
||||
if(ret)
|
||||
{
|
||||
GTP_ERROR("copy_from_user failed.");
|
||||
}
|
||||
|
||||
GTP_DEBUG("wr :0x%02x.", cmd_head.wr);
|
||||
GTP_DEBUG("flag:0x%02x.", cmd_head.flag);
|
||||
GTP_DEBUG("flag addr:0x%02x%02x.", cmd_head.flag_addr[0], cmd_head.flag_addr[1]);
|
||||
GTP_DEBUG("flag val:0x%02x.", cmd_head.flag_val);
|
||||
GTP_DEBUG("flag rel:0x%02x.", cmd_head.flag_relation);
|
||||
GTP_DEBUG("circle :%d.", (s32)cmd_head.circle);
|
||||
GTP_DEBUG("times :%d.", (s32)cmd_head.times);
|
||||
GTP_DEBUG("retry :%d.", (s32)cmd_head.retry);
|
||||
GTP_DEBUG("delay :%d.", (s32)cmd_head.delay);
|
||||
GTP_DEBUG("data len:%d.", (s32)cmd_head.data_len);
|
||||
GTP_DEBUG("addr len:%d.", (s32)cmd_head.addr_len);
|
||||
GTP_DEBUG("addr:0x%02x%02x.", cmd_head.addr[0], cmd_head.addr[1]);
|
||||
GTP_DEBUG("len:%d.", (s32)len);
|
||||
GTP_DEBUG("buf[20]:0x%02x.", buff[CMD_HEAD_LENGTH]);
|
||||
|
||||
if (1 == cmd_head.wr)
|
||||
{
|
||||
// copy_from_user(&cmd_head.data[cmd_head.addr_len], &buff[CMD_HEAD_LENGTH], cmd_head.data_len);
|
||||
ret = copy_from_user(&cmd_head.data[GTP_ADDR_LENGTH], &buff[CMD_HEAD_LENGTH], cmd_head.data_len);
|
||||
if(ret)
|
||||
{
|
||||
GTP_ERROR("copy_from_user failed.");
|
||||
}
|
||||
memcpy(&cmd_head.data[GTP_ADDR_LENGTH - cmd_head.addr_len], cmd_head.addr, cmd_head.addr_len);
|
||||
|
||||
GTP_DEBUG_ARRAY(cmd_head.data, cmd_head.data_len + cmd_head.addr_len);
|
||||
GTP_DEBUG_ARRAY((u8*)&buff[CMD_HEAD_LENGTH], cmd_head.data_len);
|
||||
|
||||
if (1 == cmd_head.flag)
|
||||
{
|
||||
if (FAIL == comfirm())
|
||||
{
|
||||
GTP_ERROR("[WRITE]Comfirm fail!");
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
else if (2 == cmd_head.flag)
|
||||
{
|
||||
//Need interrupt!
|
||||
}
|
||||
if (tool_i2c_write(&cmd_head.data[GTP_ADDR_LENGTH - cmd_head.addr_len],
|
||||
cmd_head.data_len + cmd_head.addr_len) <= 0)
|
||||
{
|
||||
GTP_ERROR("[WRITE]Write data failed!");
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
GTP_DEBUG_ARRAY(&cmd_head.data[GTP_ADDR_LENGTH - cmd_head.addr_len],cmd_head.data_len + cmd_head.addr_len);
|
||||
if (cmd_head.delay)
|
||||
{
|
||||
msleep(cmd_head.delay);
|
||||
}
|
||||
|
||||
return cmd_head.data_len + CMD_HEAD_LENGTH;
|
||||
}
|
||||
else if (3 == cmd_head.wr) //Write ic type
|
||||
{
|
||||
ret = copy_from_user(&cmd_head.data[0], &buff[CMD_HEAD_LENGTH], cmd_head.data_len);
|
||||
if(ret)
|
||||
{
|
||||
GTP_ERROR("copy_from_user failed.");
|
||||
}
|
||||
memcpy(IC_TYPE, cmd_head.data, cmd_head.data_len);
|
||||
|
||||
register_i2c_func();
|
||||
|
||||
return cmd_head.data_len + CMD_HEAD_LENGTH;
|
||||
}
|
||||
else if (5 == cmd_head.wr)
|
||||
{
|
||||
//memcpy(IC_TYPE, cmd_head.data, cmd_head.data_len);
|
||||
|
||||
return cmd_head.data_len + CMD_HEAD_LENGTH;
|
||||
}
|
||||
else if (7 == cmd_head.wr)//disable irq!
|
||||
{
|
||||
gtp_irq_disable(i2c_get_clientdata(gt_client));
|
||||
|
||||
#if GTP_ESD_PROTECT
|
||||
gtp_esd_switch(gt_client, SWITCH_OFF);
|
||||
#endif
|
||||
return CMD_HEAD_LENGTH;
|
||||
}
|
||||
else if (9 == cmd_head.wr) //enable irq!
|
||||
{
|
||||
gtp_irq_enable(i2c_get_clientdata(gt_client));
|
||||
|
||||
#if GTP_ESD_PROTECT
|
||||
gtp_esd_switch(gt_client, SWITCH_ON);
|
||||
#endif
|
||||
return CMD_HEAD_LENGTH;
|
||||
}
|
||||
else if(17 == cmd_head.wr)
|
||||
{
|
||||
struct goodix_ts_data *ts = i2c_get_clientdata(gt_client);
|
||||
ret = copy_from_user(&cmd_head.data[GTP_ADDR_LENGTH], &buff[CMD_HEAD_LENGTH], cmd_head.data_len);
|
||||
if(ret)
|
||||
{
|
||||
GTP_DEBUG("copy_from_user failed.");
|
||||
}
|
||||
if(cmd_head.data[GTP_ADDR_LENGTH])
|
||||
{
|
||||
GTP_DEBUG("gtp enter rawdiff.");
|
||||
ts->gtp_rawdiff_mode = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ts->gtp_rawdiff_mode = false;
|
||||
GTP_DEBUG("gtp leave rawdiff.");
|
||||
}
|
||||
return CMD_HEAD_LENGTH;
|
||||
}
|
||||
#ifdef UPDATE_FUNCTIONS
|
||||
else if (11 == cmd_head.wr)//Enter update mode!
|
||||
{
|
||||
if (FAIL == gup_enter_update_mode(gt_client))
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
else if (13 == cmd_head.wr)//Leave update mode!
|
||||
{
|
||||
gup_leave_update_mode();
|
||||
}
|
||||
else if (15 == cmd_head.wr) //Update firmware!
|
||||
{
|
||||
show_len = 0;
|
||||
total_len = 0;
|
||||
memset(cmd_head.data, 0, cmd_head.data_len + 1);
|
||||
memcpy(cmd_head.data, &buff[CMD_HEAD_LENGTH], cmd_head.data_len);
|
||||
|
||||
if (FAIL == gup_update_proc((void*)cmd_head.data))
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return CMD_HEAD_LENGTH;
|
||||
}
|
||||
|
||||
/*******************************************************
|
||||
Function:
|
||||
Goodix tool read function.
|
||||
Input:
|
||||
standard proc read function param.
|
||||
Output:
|
||||
Return read length.
|
||||
********************************************************/
|
||||
static s32 goodix_tool_read( char *page, char **start, off_t off, int count, int *eof, void *data )
|
||||
{
|
||||
GTP_DEBUG_FUNC();
|
||||
|
||||
if (cmd_head.wr % 2)
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
else if (!cmd_head.wr)
|
||||
{
|
||||
u16 len = 0;
|
||||
s16 data_len = 0;
|
||||
u16 loc = 0;
|
||||
|
||||
if (1 == cmd_head.flag)
|
||||
{
|
||||
if (FAIL == comfirm())
|
||||
{
|
||||
GTP_ERROR("[READ]Comfirm fail!");
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
else if (2 == cmd_head.flag)
|
||||
{
|
||||
//Need interrupt!
|
||||
}
|
||||
|
||||
memcpy(cmd_head.data, cmd_head.addr, cmd_head.addr_len);
|
||||
|
||||
GTP_DEBUG("[CMD HEAD DATA] ADDR:0x%02x%02x.", cmd_head.data[0], cmd_head.data[1]);
|
||||
GTP_DEBUG("[CMD HEAD ADDR] ADDR:0x%02x%02x.", cmd_head.addr[0], cmd_head.addr[1]);
|
||||
|
||||
if (cmd_head.delay)
|
||||
{
|
||||
msleep(cmd_head.delay);
|
||||
}
|
||||
|
||||
data_len = cmd_head.data_len;
|
||||
while(data_len > 0)
|
||||
{
|
||||
if (data_len > DATA_LENGTH)
|
||||
{
|
||||
len = DATA_LENGTH;
|
||||
}
|
||||
else
|
||||
{
|
||||
len = data_len;
|
||||
}
|
||||
data_len -= DATA_LENGTH;
|
||||
|
||||
if (tool_i2c_read(cmd_head.data, len) <= 0)
|
||||
{
|
||||
GTP_ERROR("[READ]Read data failed!");
|
||||
return FAIL;
|
||||
}
|
||||
memcpy(&page[loc], &cmd_head.data[GTP_ADDR_LENGTH], len);
|
||||
loc += len;
|
||||
|
||||
GTP_DEBUG_ARRAY(&cmd_head.data[GTP_ADDR_LENGTH], len);
|
||||
GTP_DEBUG_ARRAY(page, len);
|
||||
}
|
||||
}
|
||||
else if (2 == cmd_head.wr)
|
||||
{
|
||||
// memcpy(page, "gt8", cmd_head.data_len);
|
||||
// memcpy(page, "GT818", 5);
|
||||
// page[5] = 0;
|
||||
|
||||
GTP_DEBUG("Return ic type:%s len:%d.", page, (s32)cmd_head.data_len);
|
||||
return cmd_head.data_len;
|
||||
//return sizeof(IC_TYPE_NAME);
|
||||
}
|
||||
else if (4 == cmd_head.wr)
|
||||
{
|
||||
page[0] = show_len >> 8;
|
||||
page[1] = show_len & 0xff;
|
||||
page[2] = total_len >> 8;
|
||||
page[3] = total_len & 0xff;
|
||||
|
||||
return cmd_head.data_len;
|
||||
}
|
||||
else if (6 == cmd_head.wr)
|
||||
{
|
||||
//Read error code!
|
||||
}
|
||||
else if (8 == cmd_head.wr) //Read driver version
|
||||
{
|
||||
// memcpy(page, GTP_DRIVER_VERSION, strlen(GTP_DRIVER_VERSION));
|
||||
s32 tmp_len;
|
||||
tmp_len = strlen(GTP_DRIVER_VERSION);
|
||||
memcpy(page, GTP_DRIVER_VERSION, tmp_len);
|
||||
page[tmp_len] = 0;
|
||||
}
|
||||
|
||||
return cmd_head.data_len;
|
||||
}
|
1810
input/touchscreen/gt9xx/gt9xx.c
Normal file
1810
input/touchscreen/gt9xx/gt9xx.c
Normal file
File diff suppressed because it is too large
Load diff
241
input/touchscreen/gt9xx/gt9xx.h
Normal file
241
input/touchscreen/gt9xx/gt9xx.h
Normal file
|
@ -0,0 +1,241 @@
|
|||
/* drivers/input/touchscreen/gt9xx.h
|
||||
*
|
||||
* 2010 - 2013 Goodix Technology.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be a reference
|
||||
* to you, when you are integrating the GOODiX's CTP IC into your system,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _GOODIX_GT9XX_H_
|
||||
#define _GOODIX_GT9XX_H_
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/hrtimer.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/input.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/proc_fs.h>
|
||||
#include <linux/string.h>
|
||||
#include <asm/uaccess.h>
|
||||
#include <linux/vmalloc.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/io.h>
|
||||
#include <mach/gpio.h>
|
||||
#include <linux/earlysuspend.h>
|
||||
|
||||
struct goodix_ts_data {
|
||||
spinlock_t irq_lock;
|
||||
struct i2c_client *client;
|
||||
struct input_dev *input_dev;
|
||||
struct hrtimer timer;
|
||||
struct work_struct work;
|
||||
struct early_suspend early_suspend;
|
||||
s32 irq_is_disable;
|
||||
s32 use_irq;
|
||||
u16 abs_x_max;
|
||||
u16 abs_y_max;
|
||||
u8 max_touch_num;
|
||||
u8 int_trigger_type;
|
||||
u8 green_wake_mode;
|
||||
u8 chip_type;
|
||||
u8 enter_update;
|
||||
u8 gtp_is_suspend;
|
||||
u8 gtp_rawdiff_mode;
|
||||
u8 gtp_cfg_len;
|
||||
u8 fixed_cfg;
|
||||
u8 esd_running;
|
||||
u8 fw_error;
|
||||
};
|
||||
|
||||
extern u16 show_len;
|
||||
extern u16 total_len;
|
||||
|
||||
//***************************PART1:ON/OFF define*******************************
|
||||
#define GTP_CUSTOM_CFG 0
|
||||
#define GTP_CHANGE_X2Y 0
|
||||
#define GTP_DRIVER_SEND_CFG 1
|
||||
#define GTP_HAVE_TOUCH_KEY 0
|
||||
#define GTP_POWER_CTRL_SLEEP 0
|
||||
#define GTP_ICS_SLOT_REPORT 0
|
||||
|
||||
#define GTP_AUTO_UPDATE 1 // auto updated by .bin file as default
|
||||
#define GTP_HEADER_FW_UPDATE 0 // auto updated by head_fw_array in gt9xx_firmware.h, function together with GTP_AUTO_UPDATE
|
||||
|
||||
#define GTP_CREATE_WR_NODE 1
|
||||
#define GTP_ESD_PROTECT 0
|
||||
#define GTP_WITH_PEN 0
|
||||
|
||||
#define GTP_SLIDE_WAKEUP 0
|
||||
#define GTP_DBL_CLK_WAKEUP 0 // double-click wakeup, function together with GTP_SLIDE_WAKEUP
|
||||
|
||||
#define GTP_DEBUG_ON 1
|
||||
#define GTP_DEBUG_ARRAY_ON 0
|
||||
#define GTP_DEBUG_FUNC_ON 0
|
||||
|
||||
//*************************** PART2:TODO define **********************************
|
||||
// STEP_1(REQUIRED): Define Configuration Information Group(s)
|
||||
// Sensor_ID Map:
|
||||
/* sensor_opt1 sensor_opt2 Sensor_ID
|
||||
GND GND 0
|
||||
VDDIO GND 1
|
||||
NC GND 2
|
||||
GND NC/300K 3
|
||||
VDDIO NC/300K 4
|
||||
NC NC/300K 5
|
||||
*/
|
||||
// TODO: define your own default or for Sensor_ID == 0 config here.
|
||||
// The predefined one is just a sample config, which is not suitable for your tp in most cases.
|
||||
#define CTP_CFG_GROUP1 {\
|
||||
0x41,0x1C,0x02,0xC0,0x03,0x0A,0x05,0x01,0x01,0x0F,\
|
||||
0x23,0x0F,0x5F,0x41,0x03,0x05,0x00,0x00,0x00,0x00,\
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x91,0x00,0x0A,\
|
||||
0x28,0x00,0xB8,0x0B,0x00,0x00,0x00,0x9A,0x03,0x25,\
|
||||
0x00,0x00,0x00,0x00,0x00,0x03,0x64,0x32,0x00,0x00,\
|
||||
0x00,0x32,0x8C,0x94,0x05,0x01,0x05,0x00,0x00,0x96,\
|
||||
0x0C,0x22,0xD8,0x0E,0x23,0x56,0x11,0x25,0xFF,0x13,\
|
||||
0x28,0xA7,0x15,0x2E,0x00,0x00,0x10,0x30,0x48,0x00,\
|
||||
0x56,0x4A,0x3A,0xFF,0xFF,0x16,0x00,0x00,0x00,0x00,\
|
||||
0x00,0x01,0x1B,0x14,0x0D,0x19,0x00,0x00,0x01,0x00,\
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
|
||||
0x00,0x00,0x1A,0x18,0x16,0x14,0x12,0x10,0x0E,0x0C,\
|
||||
0x0A,0x08,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,\
|
||||
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,\
|
||||
0xFF,0xFF,0x1D,0x1E,0x1F,0x20,0x22,0x24,0x28,0x29,\
|
||||
0x0C,0x0A,0x08,0x00,0x02,0x04,0x05,0x06,0x0E,0xFF,\
|
||||
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,\
|
||||
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,\
|
||||
0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,\
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x91,0x01\
|
||||
}
|
||||
|
||||
// TODO: define your config for Sensor_ID == 1 here, if needed
|
||||
#define CTP_CFG_GROUP2 {\
|
||||
}
|
||||
// TODO: define your config for Sensor_ID == 2 here, if needed
|
||||
#define CTP_CFG_GROUP3 {\
|
||||
}
|
||||
|
||||
// TODO: define your config for Sensor_ID == 3 here, if needed
|
||||
#define CTP_CFG_GROUP4 {\
|
||||
}
|
||||
|
||||
// TODO: define your config for Sensor_ID == 4 here, if needed
|
||||
#define CTP_CFG_GROUP5 {\
|
||||
}
|
||||
|
||||
// TODO: define your config for Sensor_ID == 5 here, if needed
|
||||
#define CTP_CFG_GROUP6 {\
|
||||
}
|
||||
|
||||
// STEP_2(REQUIRED): Customize your I/O ports & I/O operations
|
||||
#define GTP_RST_PORT S5PV210_GPJ3(6)
|
||||
#define GTP_INT_PORT S5PV210_GPH1(3)
|
||||
#define GTP_INT_IRQ gpio_to_irq(GTP_INT_PORT)
|
||||
#define GTP_INT_CFG S3C_GPIO_SFN(0xF)
|
||||
|
||||
#define GTP_GPIO_AS_INPUT(pin) do{\
|
||||
gpio_direction_input(pin);\
|
||||
s3c_gpio_setpull(pin, S3C_GPIO_PULL_NONE);\
|
||||
}while(0)
|
||||
#define GTP_GPIO_AS_INT(pin) do{\
|
||||
GTP_GPIO_AS_INPUT(pin);\
|
||||
s3c_gpio_cfgpin(pin, GTP_INT_CFG);\
|
||||
}while(0)
|
||||
#define GTP_GPIO_GET_VALUE(pin) gpio_get_value(pin)
|
||||
#define GTP_GPIO_OUTPUT(pin,level) gpio_direction_output(pin,level)
|
||||
#define GTP_GPIO_REQUEST(pin, label) gpio_request(pin, label)
|
||||
#define GTP_GPIO_FREE(pin) gpio_free(pin)
|
||||
#define GTP_IRQ_TAB {IRQ_TYPE_EDGE_RISING, IRQ_TYPE_EDGE_FALLING, IRQ_TYPE_LEVEL_LOW, IRQ_TYPE_LEVEL_HIGH}
|
||||
|
||||
// STEP_3(optional): Specify your special config info if needed
|
||||
#if GTP_CUSTOM_CFG
|
||||
#define GTP_MAX_HEIGHT 800
|
||||
#define GTP_MAX_WIDTH 480
|
||||
#define GTP_INT_TRIGGER 0 // 0: Rising 1: Falling
|
||||
#else
|
||||
#define GTP_MAX_HEIGHT 4096
|
||||
#define GTP_MAX_WIDTH 4096
|
||||
#define GTP_INT_TRIGGER 1
|
||||
#endif
|
||||
#define GTP_MAX_TOUCH 5
|
||||
#define GTP_ESD_CHECK_CIRCLE 2000 // jiffy: ms
|
||||
|
||||
// STEP_4(optional): If keys are available and reported as keys, config your key info here
|
||||
#if GTP_HAVE_TOUCH_KEY
|
||||
#define GTP_KEY_TAB {KEY_MENU, KEY_HOME, KEY_BACK}
|
||||
#endif
|
||||
|
||||
//***************************PART3:OTHER define*********************************
|
||||
#define GTP_DRIVER_VERSION "V1.8<2013/06/08>"
|
||||
#define GTP_I2C_NAME "Goodix-TS"
|
||||
#define GTP_POLL_TIME 10 // jiffy: ms
|
||||
#define GTP_ADDR_LENGTH 2
|
||||
#define GTP_CONFIG_MIN_LENGTH 186
|
||||
#define GTP_CONFIG_MAX_LENGTH 240
|
||||
#define FAIL 0
|
||||
#define SUCCESS 1
|
||||
#define SWITCH_OFF 0
|
||||
#define SWITCH_ON 1
|
||||
|
||||
// Registers define
|
||||
#define GTP_READ_COOR_ADDR 0x814E
|
||||
#define GTP_REG_SLEEP 0x8040
|
||||
#define GTP_REG_SENSOR_ID 0x814A
|
||||
#define GTP_REG_CONFIG_DATA 0x8047
|
||||
#define GTP_REG_VERSION 0x8140
|
||||
|
||||
#define RESOLUTION_LOC 3
|
||||
#define TRIGGER_LOC 8
|
||||
|
||||
#define CFG_GROUP_LEN(p_cfg_grp) (sizeof(p_cfg_grp) / sizeof(p_cfg_grp[0]))
|
||||
// Log define
|
||||
#define GTP_INFO(fmt,arg...) printk("<<-GTP-INFO->> "fmt"\n",##arg)
|
||||
#define GTP_ERROR(fmt,arg...) printk("<<-GTP-ERROR->> "fmt"\n",##arg)
|
||||
#define GTP_DEBUG(fmt,arg...) do{\
|
||||
if(GTP_DEBUG_ON)\
|
||||
printk("<<-GTP-DEBUG->> [%d]"fmt"\n",__LINE__, ##arg);\
|
||||
}while(0)
|
||||
#define GTP_DEBUG_ARRAY(array, num) do{\
|
||||
s32 i;\
|
||||
u8* a = array;\
|
||||
if(GTP_DEBUG_ARRAY_ON)\
|
||||
{\
|
||||
printk("<<-GTP-DEBUG-ARRAY->>\n");\
|
||||
for (i = 0; i < (num); i++)\
|
||||
{\
|
||||
printk("%02x ", (a)[i]);\
|
||||
if ((i + 1 ) %10 == 0)\
|
||||
{\
|
||||
printk("\n");\
|
||||
}\
|
||||
}\
|
||||
printk("\n");\
|
||||
}\
|
||||
}while(0)
|
||||
#define GTP_DEBUG_FUNC() do{\
|
||||
if(GTP_DEBUG_FUNC_ON)\
|
||||
printk("<<-GTP-FUNC->> Func:%s@Line:%d\n",__func__,__LINE__);\
|
||||
}while(0)
|
||||
#define GTP_SWAP(x, y) do{\
|
||||
typeof(x) z = x;\
|
||||
x = y;\
|
||||
y = z;\
|
||||
}while (0)
|
||||
|
||||
//*****************************End of Part III********************************
|
||||
|
||||
#endif /* _GOODIX_GT9XX_H_ */
|
6
input/touchscreen/gt9xx/gt9xx_firmware.h
Normal file
6
input/touchscreen/gt9xx/gt9xx_firmware.h
Normal file
|
@ -0,0 +1,6 @@
|
|||
// make sense only when GTP_HEADER_FW_UPDATE & GTP_AUTO_UPDATE are enabled
|
||||
// define your own firmware array here
|
||||
const unsigned char header_fw_array[] =
|
||||
{
|
||||
|
||||
};
|
1930
input/touchscreen/gt9xx/gt9xx_update.c
Normal file
1930
input/touchscreen/gt9xx/gt9xx_update.c
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue