RK Android7.1 移植gt9271 TP偏移
一.原理图

dts 配置
goodix@14 {
compatible = "goodix,gt9xx";
reg = <0x14>;
max-x = <1280>;
max-y = <800>;
tp-size= <89>;
touch-gpio = <&gpio0 4 IRQ_TYPE_LEVEL_LOW>;
rst-gpio = <&gpio0 3 GPIO_ACTIVE_HIGH>;
通信失败
[ 1.661711] <<-GTP-ERROR->> GTP i2c test failed time 4. [ 1.675859] <<-GTP-ERROR->> I2C Read: 0x8047, 1 bytes failed, errcode: -6! Process reset. [ 1.758372] <<-GTP-ERROR->> GTP i2c test failed time 5. [ 1.771698] <goodix_ts_probe>_2555 I2C communication ERROR! [ 1.771717] <goodix_ts_probe>_2623 prob error !!!!!!!!!!!!!!! [ 1.771787] rk3x-i2c ff3d0000.i2c: Initialized RK3xxx I2C bus at ffffff80099d4000
linux i2c 的通信函数i2c_transfer出错码
参考errno-base.h
#define EPERM 1 /* Operation not permitted */
#define ENOENT 2 /* No such file or directory */
#define ESRCH 3 /* No such process */
#define EINTR 4 /* Interrupted system call */
#define EIO 5 /* I/O error */
#define ENXIO 6 /* No such device or address */
#define E2BIG 7 /* Argument list too long */
#define ENOEXEC 8 /* Exec format error */
#define EBADF 9 /* Bad file number */
#define ECHILD 10 /* No child processes */
#define EAGAIN 11 /* Try again */
#define ENOMEM 12 /* Out of memory */
#define EACCES 13 /* Permission denied */
#define EFAULT 14 /* Bad address */
#define ENOTBLK 15 /* Block device required */
正常
[ 1.298163] tp 00000000000000000000000000000 DPT [ 1.298163] [ 1.335636] input: goodix-ts as /devices/virtual/input/input1
三.kernel\drivers\input\touchscreen\GT9271\gt9xx.c
/*******************************************************
Function:
I2c probe.
Input:
client: i2c device struct.
id: device id.
Output:
Executive outcomes.
0: succeed.
*******************************************************/
static int goodix_ts_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
s32 ret = -1;
struct goodix_ts_data *ts;
u16 version_info;
struct device_node *np = client->dev.of_node;
enum of_gpio_flags rst_flags, pwr_flags, tp_select_flags;
unsigned long irq_flags;
u32 val;
printk("___%s() start____ \n", __func__);
GTP_DEBUG_FUNC();
//do NOT remove these logs
GTP_INFO("GTP Driver Version: %s", GTP_DRIVER_VERSION);
GTP_INFO("GTP Driver Built@%s, %s", __TIME__, __DATE__);
GTP_INFO("GTP I2C Address: 0x%02x", client->addr);
i2c_connect_client = client;
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
{
GTP_ERROR("I2C check functionality failed.");
return -ENODEV;
}
ts = kzalloc(sizeof(*ts), GFP_KERNEL);
if (ts == NULL)
{
GTP_ERROR("Alloc GFP_KERNEL memory failed.");
return -ENOMEM;
}
memset(ts, 0, sizeof(*ts));
if (!np) {
dev_err(&client->dev, "no device tree\n");
return -EINVAL;
}
if (of_property_read_u32(np, "tp-size", &val)) {
dev_err(&client->dev, "no max-x defined\n");
return -EINVAL;
}
if(val == 89){
m89or101 = TRUE;
mGtpChange_X2Y = TRUE;
mGtp_X_Reverse = FALSE;
mGtp_Y_Reverse = FALSE;
}else if(val == 101){
m89or101 = TRUE;
mGtpChange_X2Y = FALSE;
mGtp_X_Reverse = FALSE;
mGtp_Y_Reverse = FALSE;
}
ts->irq_pin = of_get_named_gpio_flags(np, "touch-gpio", 0, (enum of_gpio_flags *)(&ts->irq_flags));
ts->rst_pin = of_get_named_gpio_flags(np, "reset-gpio", 0, &rst_flags);
ts->pwr_pin = of_get_named_gpio_flags(np, "power-gpio", 0, &pwr_flags);
ts->tp_select_pin = of_get_named_gpio_flags(np, "tp-select-gpio", 0, &tp_select_flags);
if (of_property_read_u32(np, "max-x", &val)) {
dev_err(&client->dev, "no max-x defined\n");
return -EINVAL;
}
//ts->abs_x_max = val;
if (of_property_read_u32(np, "max-y", &val)) {
dev_err(&client->dev, "no max-y defined\n");
return -EINVAL;
}
//ts->abs_y_max = val;
ts->pendown =PEN_RELEASE;
ts->client = client;
INIT_WORK(&ts->work, goodix_ts_work_func);
ts->client = client;
spin_lock_init(&ts->irq_lock); // 2.6.39 later
// ts->irq_lock = SPIN_LOCK_UNLOCKED; // 2.6.39 & before
#if GTP_ESD_PROTECT
ts->clk_tick_cnt = 2 * HZ; // HZ: clock ticks in 1 second generated by system
GTP_DEBUG("Clock ticks for an esd cycle: %d", ts->clk_tick_cnt);
spin_lock_init(&ts->esd_lock);
// ts->esd_lock = SPIN_LOCK_UNLOCKED;
#endif
i2c_set_clientdata(client, ts);
ts->gtp_rawdiff_mode = 0;
ret = gtp_request_io_port(ts);
if (ret < 0)
{
GTP_ERROR("GTP request IO port failed.");
//return ret;
goto probe_init_error_requireio;
}
if(gpio_get_value(ts->tp_select_pin))//WGJ
{
printk("tp 11111111111111111111111111111 WGJ\n\n");
mGtp_X_Reverse = FALSE;
mGtp_Y_Reverse = FALSE;
}
else//DPT
{
printk("tp 00000000000000000000000000000 DPT\n\n");
mGtpChange_X2Y = TRUE;
mGtp_X_Reverse = TRUE;//FALSE;
mGtp_Y_Reverse = FALSE;
}
mGtpChange_X2Y = TRUE;
mGtp_X_Reverse = TRUE; X镜像
mGtp_Y_Reverse = FALSE; Y镜像
/*******************************************************
Function:
Report touch point event
Input:
ts: goodix i2c_client private data
id: trackId
x: input x coordinate
y: input y coordinate
w: input pressure
Output:
None.
*********************************************************/
static void gtp_touch_down(struct goodix_ts_data* ts,s32 id,s32 x,s32 y,s32 w)
{
if(mGtpChange_X2Y){
GTP_SWAP(x, y);
}
if(mGtp_X_Reverse){
x = ts->abs_x_max - x;
}
if(mGtp_Y_Reverse){
y = ts->abs_y_max - y;
}

浙公网安备 33010602011771号