Firefly开源社区

[Linux] 基于rk3288平台的gt9xx 触摸驱动移植

98

积分

0

威望

0

贡献

技术小白

积分
98
发表于 2019-7-31 12:37:51     
本帖最后由 17701603601 于 2019-8-3 11:17 编辑

                     基于rk3288平台的gt9xx 触摸驱动移植

一、硬件介绍:
    1 core-rk3288j 核心板
    2 外接lvds 1280*480的屏幕
    3 触摸芯片GT928,I2C驱动,触摸驱动发布版本和时间* Version: 2.4  * Release Date: 2014/11/28 */
    4 操作系统Ubuntu16.04
二、触摸芯片硬件电路描述
    1 触摸零点右上角
    2 触摸尺寸 1280*480
    3 中断下降沿触发;
    4 I2C1 接口
    如:
    GTP_INT  GPIO7_A6 <&gpio7 6 GPIO_ACTIVE_HIGH>;
    GTP_RST  GPIO7_A5 <&gpio7 5 GPIO_ACTIVE_LOW>
    I2C1_SDA
    I2C1_SCL
三、开启驱动移植
1 dts 配置硬件
&i2c1 {
        status = "okay";
        goodix_ts@5d {
                        compatible = "goodix,gt9xx";
                        reg = <0x5d>;
                        interrupt-parent = <&gpio7>;
                        interrupts = <6 IRQ_TYPE_EDGE_FALLING>;
                        goodix,rst-gpio = <&gpio7 5 GPIO_ACTIVE_LOW>;
                        goodix,irq-gpio = <&gpio7 6 GPIO_ACTIVE_HIGH>;
                        goodix,cfg-group2 = [
                                41 E0 01 00 05 05 05 00 02 08 28
                                05 5A 3C 03 05 00 00 00 00 00 00
                                00 00 00 00 00 90 30 66 36 2D 05
                                0D 00 00 00 00 03 25 00 00 00 00
                                00 00 00 00 00 00 00 00 00 00 00
                                00 00 00 00 00 00 00 00 00 00 00
                                00 00 00 00 00 00 00 00 00 00 00
                                00 00 00 00 00 00 00 00 00 00 00
                                00 00 00 00 00 00 00 00 00 00 00
                                00 00 00 00 00 00 00 00 00 00 00
                                00 00 00 01 04 05 06 07 08 09 0C
                                0D 0E 0F FF FF FF FF FF FF FF FF
                                FF FF FF FF 00 00 00 00 00 00 2A
                                29 28 27 26 25 24 23 22 21 20 1F
                                1E 1C 1B 19 14 13 12 11 10 0F 0E
                                0D 0C 0A 08 07 06 04 02 00 00 00
                                00 00 00 00 00 00 00 00 0C 01];
                };

};
2 gt9xx.h 文件配置修改
放在最前面的:
on/off 开启/关闭配置
1 打开 GTP_CUSTOM_CFG  需要配置成1,用来用户自定义设置;
2 打开GTP_DRIVER_SEND_CFG   需要配置成1 ,用来发送CFG文件配置;
3 打开GTP_DEBUG_ON        可以看到配置成1 ,可以看到调试信息;  

例如:

//***************************PART1:ON/OFF define*******************************
#define GTP_CUSTOM_CFG        1
#define GTP_CHANGE_X2Y        0    //swap x y
#define GTP_DRIVER_SEND_CFG   1    //driver send config
#define GTP_HAVE_TOUCH_KEY    0
#define GTP_POWER_CTRL_SLEEP  0    //power off when suspend
#define GTP_ICS_SLOT_REPORT   0    // slot protocol

#define GTP_AUTO_UPDATE       0    // auto update fw by .bin file as default
#define GTP_HEADER_FW_UPDATE  0    // auto update fw by gtp_default_FW in gt9xx_firmware.h, function together with

GTP_AUTO_UPDATE
#define GTP_AUTO_UPDATE_CFG   0    // auto update config by .cfg file, function together with GTP_AUTO_UPDATE

#define GTP_COMPATIBLE_MODE   0    // compatible with GT9XXF

#define GTP_CREATE_WR_NODE    0
#define GTP_ESD_PROTECT       0    // esd protection with a cycle of 2 seconds

#define GTP_WITH_PEN          0
#define GTP_PEN_HAVE_BUTTON   0    // active pen has buttons, function together with GTP_WITH_PEN

#define GTP_GESTURE_WAKEUP    0    // gesture wakeup

#define GTP_DEBUG_ON          1
#define GTP_DEBUG_ARRAY_ON    0
#define GTP_DEBUG_FUNC_ON     0

#if GTP_COMPATIBLE_MODE

第一步::
//*************************** 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_GROUP0 {\

}
    // TODO: define your config for Sensor_ID == 1 here, if needed
#define CTP_CFG_GROUP1 {\
    }

// TODO: define your config for Sensor_ID == 2 here, if needed
#define CTP_CFG_GROUP2 {\
        0x41,0xE0,0x01,0x00,0x05,0x05,0x05,0x00,0x02,0x08,0x28,\
        0x05,0x5A,0x3C,0x03,0x05,0x00,0x00,0x00,0x00,0x00,0x00,\
        0x00,0x00,0x00,0x00,0x00,0x90,0x30,0x66,0x36,0x2D,0x05,\
        0x0D,0x00,0x00,0x00,0x00,0x03,0x25,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,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,0x01,0x04,0x05,0x06,0x07,0x08,0x09,0x0C,\
        0x0D,0x0E,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,\
        0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x2A,\
        0x29,0x28,0x27,0x26,0x25,0x24,0x23,0x22,0x21,0x20,0x1F,\
        0x1E,0x1C,0x1B,0x19,0x14,0x13,0x12,0x11,0x10,0x0F,0x0E,\
        0x0D,0x0C,0x0A,0x08,0x07,0x06,0x04,0x02,0x00,0x00,0x00,\
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x01\
    }

// TODO: define your config for Sensor_ID == 3 here, if needed
#define CTP_CFG_GROUP3 {\
}
// TODO: define your config for Sensor_ID == 4 here, if needed
#define CTP_CFG_GROUP4 {\
    }

// TODO: define your config for Sensor_ID == 5 here, if needed
#define CTP_CFG_GROUP5 {\
    }
   
第二步:设置中断和复位引脚
// STEP_2(REQUIRED): Customize your I/O ports & I/O operations
#define GTP_RST_PORT    5//S5PV210_GPJ3(6)
#define GTP_INT_PORT    6//S5PV210_GPH1(3)

第三步:设置触摸区域和下降沿触发
// STEP_3(optional): Specify your special config info if needed
#if GTP_CUSTOM_CFG
  #define GTP_MAX_HEIGHT   480
  #define GTP_MAX_WIDTH    1280
  #define GTP_INT_TRIGGER  1            // 0: Rising 1: Falling


四、总结及问题汇总

1 触摸不灵或者不准的问题,需要厂家给CFG文件,修改gt9xx.h 文件,不是必须修改dts文件,需要把宏GTP_DRIVER_SEND_CFG 配置成1。
格式内容如下:

#define CTP_CFG_GROUP2 {\
        0x41,0x00,0x05,0xE0,0x01,0x05,0x0D,0x00,0x02,0x08,0x28,\
        0x05,0x5A,0x3C,0x03,0x05,0x00,0x00,0x00,0x00,0x00,0x00,\
        0x00,0x00,0x00,0x00,0x00,0x90,0x30,0x66,0x36,0x2D,0x05,\
        0x0D,0x00,0x00,0x00,0x00,0x03,0x25,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,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,0x0F,0x0E,0x0D,0x0C,0x09,0x08,0x07,0x06,0x05,\
        0x04,0x01,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,\
        0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x2A,\
        0x29,0x28,0x27,0x26,0x25,0x24,0x23,0x22,0x21,0x20,0x1F,\
        0x1E,0x1C,0x1B,0x19,0x14,0x13,0x12,0x11,0x10,0x0F,0x0E,\
        0x0D,0x0C,0x0A,0x08,0x07,0x06,0x04,0x02,0x00,0x00,0x00,\
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x01\
}
2 厂家 有指定也就是的sensorID, 配置到哪个group 是厂家指定的,比如有0-5,6个group,我的配置在了group2;
#define CTP_CFG_GROUP2
3 debug信息如下:
正确的

[    2.596431] <<-GTP-DEBUG->> [2356]GTP power on.
[    2.596491] <<-GTP-INFO->> Guitar reset
[    2.735657] <<-GTP-INFO->> IC Version: 928_1040
[    2.738181] <<-GTP-INFO->> Sensor_ID: 2
[    2.738186] <<-GTP-DEBUG->> [1394]Get config data from device tree.
[    2.738196] <<-GTP-INFO->> Config group2 used,length: 186
[    2.739467] <<-GTP-DEBUG->> [1430]Config Version: 65, 0x41; IC Config Version: 65, 0x41
[    2.739473] <<-GTP-INFO->> Driver send config.
[    2.765064] <<-GTP-INFO->> X_MAX: 1280, Y_MAX: 480, TRIGGER: 0x01
[    2.783848] <<-GTP-INFO->> create proc entry gt9xx_config success
[    2.784195] input: goodix-ts as /devices/virtual/input/input1
[    2.784497] <<-GTP-DEBUG->> [1746]INT trigger type:1

如果遇到如下debug信息,一般onfig data解析错误,GTP init panel failed.一般就是cfg文件没设置好,询问厂家技术支持放置在group0-group5的哪个里面。

[    2.585428] <<-GTP-DEBUG->> [2356]GTP power on.
[    2.585488] <<-GTP-INFO->> Guitar reset
[    2.725369] <<-GTP-INFO->> IC Version: 928_1040
[    2.727878] <<-GTP-INFO->> Sensor_ID: 2
[    2.727883] <<-GTP-DEBUG->> [1394]Get config data from device tree.
[    2.727891] <<-GTP-ERROR->> Failed to parse config data form device tree.
[    2.727893] <<-GTP-ERROR->> GTP init panel failed.
[    2.727914] <<-GTP-INFO->> create proc entry gt9xx_config success
[    2.728268] input: goodix-ts as /devices/virtual/input/input1
[    2.728591] <<-GTP-DEBUG->> [1746]INT trigger type:1
[    2.728674] <<-GTP-INFO->> GTP works in interrupt mode.

4 移植的时候需要定义个宏:
#define GTP_CONFIG_OF
这个宏非常关键,在gt9xx.c 文件头部位置,定义上去! 否则驱动无法正常执行。
回复

使用道具 举报

98

积分

0

威望

0

贡献

技术小白

积分
98
发表于 2019-7-31 12:45:09     
占个沙发!!!
回复

使用道具 举报

140

积分

0

威望

0

贡献

社区版主

Rank: 7Rank: 7Rank: 7

积分
140
发表于 2019-7-31 15:07:36     
回复

使用道具 举报

25

积分

0

威望

0

贡献

技术小白

积分
25
QQ
发表于 2020-4-22 18:31:19     
回复

使用道具 举报

22

积分

0

威望

0

贡献

技术小白

积分
22
发表于 2020-12-17 15:26:24     
配置了驱动,触屏有事件发生,就是屏幕界面没响应,楼主知道怎么回事吗
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

友情链接 : 爱板网 电子发烧友论坛 云汉电子社区 粤ICP备14022046号-2
快速回复 返回顶部 返回列表