touch GT9xx 技术厂家提供 driver 的参考代码, 是基于 device tree 的。 由于Hisi 目前对device tree 支持不好,需要改成非基于device tree 的driver。
1. 首先修改 gtp_init, 不通过 i2c_add_driver, 直接调用 i2c_new_device, 直接调用 probe
+static struct i2c_client* gt9xx_i2c_client = NULL;
+
+static struct i2c_board_info hi_info = {
+ I2C_BOARD_INFO("gt9xx", 0x5d),
};
static int __init gtp_init(void)
{
- s32 ret;
-
- pr_info("Gt9xx driver installing..\n");
- ret = i2c_add_driver(&goodix_ts_driver);
-
- return ret;
+ struct i2c_adapter* i2c_adap;
+
+ GTP_DEBUG("gt9xx touch panel driver init\n");
+
+ i2c_adap = i2c_get_adapter(ts_bus_num);
+ gt9xx_i2c_client = i2c_new_device(i2c_adap, &hi_info);
+ if(!gt9xx_i2c_client) {
+ GTP_DEBUG("gt9xx_i2c_client null\n");
+ return -1;
+ }
+ i2c_put_adapter(i2c_adap);
+
+
+ gtp_probe(gt9xx_i2c_client, gtp_device_id);
+
+ return 0;
}
2. 代码中 #ifdef CONFIG_OF 一律改成 #if 0 , #ifndef CONFIG_OF 一律改成 #if 1 , #ifdef CONFIG_FB 一律改成 #if 0
-#if defined(CONFIG_FB)
+#if 0
-#ifdef CONFIG_OF
+#if 0
-#ifndef CONFIG_OF
+#if 1
3. 注释和删除代码中全部无关紧要的代码, 比如 powermanager, esd, 部分修改如下,
-static int gtp_unregister_powermanager(struct goodix_ts_data *ts);
-static int gtp_register_powermanager(struct goodix_ts_data *ts);
+// static int gtp_unregister_powermanager(struct goodix_ts_data *ts);
+// static int gtp_register_powermanager(struct goodix_ts_data *ts);
-static int gtp_esd_init(struct goodix_ts_data *ts);
-static void gtp_esd_check_func(struct work_struct *);
-static int gtp_init_ext_watchdog(struct i2c_client *client);
+// static int gtp_esd_init(struct goodix_ts_data *ts);
+// static void gtp_esd_check_func(struct work_struct *);
+// static int gtp_init_ext_watchdog(struct i2c_client *client);
4. 修改函数 gtp_probe
- pdata->rst_gpio = GTP_RST_PORT;
- pdata->irq_gpio = GTP_INT_PORT;
+ pdata->rst_gpio = 181;
+ pdata->irq_gpio = 135;
+ pdata->irq_flags = GTP_DEFAULT_INT_TRIGGER;
+ pdata->swap_x2y = true;
5. 修改gtp_exit
static void __exit gtp_exit(void)
{
- pr_info("Gt9xx driver exited\n");
- i2c_del_driver(&goodix_ts_driver);
+ gtp_drv_remove(gt9xx_i2c_client);
+ i2c_unregister_device(gt9xx_i2c_client);
+
}
到此,移植工作基本完成,开始编译调试。
Makefile, 编译出.ko 放到nfs 目录
CFLAG = ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE)
EXTRA_CFLAGS += -Wall -std=gnu99 -Wno-error=date-time
all:
$(MAKE) -C $(KERN_DIR) $(CFLAG) M=`pwd` modules
clean:
$(MAKE) -C $(KERN_DIR) $(CFLAG) M=`pwd` modules clean
rm -rf modules.order
gt911-objs := gt9xx.o
obj-m += gt911.o
srwang@gmd:~/repo/repo-hicam/hicam/imvt/src/peripheral/imvt_os_driver/gt911$ make KERN_DIR=/lhome2/srwang/repo/repo-hicam/hicam/../hisi_osdrv/hi3559av100/opensource/kernel/linux-4.9.y ARCH=arm64 CROSS_COMPILE=aarch64-himix100-linux-
make -C /lhome2/srwang/repo/repo-hicam/hicam/../hisi_osdrv/hi3559av100/opensource/kernel/linux-4.9.y ARCH=arm64 CROSS_COMPILE=aarch64-himix100-linux- M=`pwd` modules
make[1]: Entering directory '/lhome2/srwang/repo/repo-hicam/hisi_osdrv/hi3559av100/opensource/kernel/linux-4.9.y'
Building modules, stage 2.
MODPOST 1 modules
LD [M] /lhome2/srwang/repo/repo-hicam/hicam/imvt/src/peripheral/imvt_os_driver/gt911/gt911.ko
make[1]: Leaving directory '/lhome2/srwang/repo/repo-hicam/hisi_osdrv/hi3559av100/opensource/kernel/linux-4.9.y'
srwang@gmd:~/repo/repo-hicam/hicam/imvt/src/peripheral/imvt_os_driver/gt911$ mv gt911.ko ~/nfs_bfe715b33b/
srwang@gmd:~/repo/repo-hicam/hicam/imvt/src/peripheral/imvt_os_driver/gt911$
配置I2C引脚,安装驱动
~ # udhcpc -i eth0
udhcpc: started, v1.26.2
udhcpc: sending discover
udhcpc: sending select for 192.168.9.24
udhcpc: lease of 192.168.9.24 obtained, lease time 7200
deleting routers
adding dns 192.168.9.1
adding dns 0.0.0.0
~ # mount -t nfs -o nolock -o tcp -o rsize=32768,wsize=32768 192.168.9.102:/lhom
e2/srwang/nfs_bfe715b33b /mnt
~ # cd /mnt
/mnt # echo 7 7 7 7 > /proc/sys/kernel/printk
/mnt #
/mnt # ./bin/himm 0x1f00007c 0x14f3
./bin/himm 0x1f000080 0x14f3
*** Board tools : ver0.0.1_20121120 ***
[debug]: {source/utils/cmdshell.c:168}cmdstr:himm
0x1f00007c: 0x00001400 --> 0x000014F3
[END]
/mnt # ./bin/himm 0x1f000080 0x14f3
*** Board tools : ver0.0.1_20121120 ***
[debug]: {source/utils/cmdshell.c:168}cmdstr:himm
0x1f000080: 0x00001400 --> 0x000014F3
[END]
/mnt # insmod gt911.ko
<<-GTP-DEBUG->> [2627]gt9xx touch panel driver init
i2c 1-005d: GTP Driver Version: V2.8.0.2<2017/12/14>
i2c 1-005d: GTP I2C Address: 0x5d
i2c 1-005d: Success request irq-gpio
i2c 1-005d: Success request rst-gpio
i2c 1-005d: Guitar reset
i2c 1-005d: I2C Addr is 5d
i2c 1-005d: IC Version: 911_1060
i2c 1-005d: Driver set not send config
i2c 1-005d: Use slot report protocol
input: goodix-ts as /devices/virtual/input/input1
i2c 1-005d: INT num 239, trigger type:1
i2c 1-005d: gtp_work_func return WORK_THREAD_ENABLED
i2c 1-005d: create proc entry gt9xx_config success
/mnt #
evtest 工具查看结果
/mnt # ./evtest
No device specified, trying to scan all of /dev/input/event*
Available devices:
/dev/input/event0: imvt_button
/dev/input/event1: goodix-ts
Select the device event number [0-1]: 1
Input driver version is 1.0.1
Input device ID: bus 0x18 vendor 0x416 product 0xbeef version 0x28bb
Input device name: "goodix-ts"
Supported events:
Event type 0 (EV_SYN)
Event type 1 (EV_KEY)
Event code 330 (BTN_TOUCH)
Event code 331 (BTN_STYLUS)
Event code 332 (BTN_STYLUS2)
Event type 3 (EV_ABS)
Event code 47 (ABS_MT_SLOT)
Value 0
Min 0
Max 15
Event code 48 (ABS_MT_TOUCH_MAJOR)
Value 0
Min 0
Max 1024
Event code 53 (ABS_MT_POSITION_X)
Value 0
Min 0
Max 1920
Event code 54 (ABS_MT_POSITION_Y)
Value 0
Min 0
Max 1080
Event code 55 (ABS_MT_TOOL_TYPE)
Value 0
Min 0
Max 2
Event code 57 (ABS_MT_TRACKING_ID)
Value 0
Min 0
Max 16
Event code 58 (ABS_MT_PRESSURE)
Value 0
Min 0
Max 1024
Properties:
Property type 1 (INPUT_PROP_DIRECT)
Testing ... (interrupt to exit)
i2c 1-005d: [0][68 0x044, 1052 0x41C ,35]
Event: time 363.850340, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value 0
Event: time 363.850340, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 68
Event: time 363.850340, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 1052
Event: time 363.i2c 1-005d: [0][68 0x044, 1052 0x41C ,35]
850340, type 3 (EV_ABS), code 48 (ABS_MT_TOUCH_MAJOR), value 35
Event: time 363.850340, type 3 (EV_ABS), code 58 (ABS_MT_PRESSURE), value 35
Event: time 363.850340, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 1
Event: tii2c 1-005d: [0][68 0x044, 1052 0x41C ,35]
me 363.850340, -------------- SYN_REPORT ------------
i2c 1-005d: [0][68 0x044, 1052 0x41C ,35]
i2c 1-005d: [0][68 0x044, 1052 0x41C ,35]
i2c 1-005d: [0][68 0x044, 1052 0x41C ,35]
i2c 1-005d: [0][68 0x044, 1052 0x41C ,35]
i2c 1-005d: [0][69 0x045, 1051 0x41B ,35]
Event: time 363.990488, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 69
Event: time 363.990488, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 1051
Event: time 363.990488, -------------- SYN_REPORT ------------
Event: time 363.998664, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value -1
Event: time 363.998664, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 0
Event: time 363.998664, -------------- SYN_REPORT ------------
i2c 1-005d: [0][1711 0x6AF, 977 0x3D1 ,19]
Event: time 378.366882, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value 1
Event: time 378.366882, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 1711
Event: time 378.366882, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 977
Event: time 378i2c 1-005d: [0][1712 0x6B0, 977 0x3D1 ,19]
.366882, type 3 (EV_ABS), code 48 (ABS_MT_TOUCH_MAJOR), value 19
Event: time 378.366882, type 3 (EV_ABS), code 58 (ABS_MT_PRESSURE), value 19
Event: time 378.366882, type 1 (EV_KEY), code 330 (BTNi2c 1-005d: [0][1712 0x6B0, 977 0x3D1 ,19]
_TOUCH), value 1
Event: time 378.366882, -------------- SYN_REPORT ------------
Event: time 378.393524, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 1712
Event: time 378.393524, -------------- SYN_REPORT ------------
i2c 1-005d: [0][1712 0x6B0, 977 0x3D1 ,19]
i2c 1-005d: [0][1712 0x6B0, 977 0x3D1 ,19]
i2c 1-005d: [0][1712 0x6B0, 977 0x3D1 ,19]
i2c 1-005d: [0][1712 0x6B0, 977 0x3D1 ,19]
i2c 1-005d: [0][1712 0x6B0, 977 0x3D1 ,19]
i2c 1-005d: [0][1712 0x6B0, 977 0x3D1 ,19]
i2c 1-005d: [0][1712 0x6B0, 977 0x3D1 ,19]
i2c 1-005d: [0][1712 0x6B0, 977 0x3D1 ,19]
i2c 1-005d: [0][1712 0x6B0, 977 0x3D1 ,20]
Event: time 378.624226, type 3 (EV_ABS), code 48 (ABS_MT_TOUCH_MAJOR), value 20
Event: time 378.624226, type 3 (EV_ABS), code 58 (ABS_MT_PRESSURE), value 20
Event: time 378.624226, -------------- SYN_REPORT ------------
i2c 1-005d: [0][1712 0x6B0, 977 0x3D1 ,21]
Event: time 378.647827, type 3 (EV_ABS), code 48 (ABS_MT_TOUCH_MAJOR), value 21
Event: time 378.647827, type 3 (EV_ABS), code 58 (ABS_MT_PRESSURE), value 21
Event: time 378.647827, -------------- SYN_REPORT ------------
i2c 1-005d: [0][1712 0x6B0, 977 0x3D1 ,21]
i2c 1-005d: [0][1712 0x6B0, 977 0x3D1 ,21]
i2c 1-005d: [0][1712 0x6B0, 977 0x3D1 ,21]
i2c 1-005d: [0][1710 0x6AE, 978 0x3D2 ,21]
Event: time 378.717664, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 1710
Event: time 378.717664, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 978
Event: time 378.717664, -------------- SYN_REPORT ------------
Event: time 378.725528, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value -1
Event: time 378.725528, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 0
Event: time 378.725528, -------------- SYN_REPORT ------------
i2c 1-005d: [0][61 0x03D, 5 0x005 ,25]
Event: time 380.870035, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value 2
Event: time 380.870035, type 3 (EV_ABS), code 53 (i2c 1-005d: [0][61 0x03D, 5 0x005 ,25]
ABS_MT_POSITION_X), value 61
Event: time 380.870035, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 5
Event: time 380.870035, type 3 (EV_ABS), code 48 (ABS_MT_TOUCH_MAJOR), value 25
Event: time 380.870035, type 3 (EVi2c 1-005d: [0][61 0x03D, 5 0x005 ,25]
_ABS), code 58 (ABS_MT_PRESSURE), value 25
Event: time 380.870035, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 1
Event: time 380.870035, -------------- SYN_REPORT ------------
i2c 1-005d: [0][61 0x03D, 5 0x005 ,25]
i2c 1-005d: [0][61 0x03D, 5 0x005 ,25]
i2c 1-005d: [0][61 0x03D, 5 0x005 ,25]
i2c 1-005d: [0][61 0x03D, 5 0x005 ,25]
i2c 1-005d: [0][61 0x03D, 5 0x005 ,25]
i2c 1-005d: [0][61 0x03D, 5 0x005 ,25]
i2c 1-005d: [0][62 0x03E, 5 0x005 ,25]
Event: time 381.068930, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 62
Event: time 381.068930, -------------- SYN_REPORT ------------
i2c 1-005d: [0][62 0x03E, 5 0x005 ,25]
i2c 1-005d: [0][62 0x03E, 5 0x005 ,25]
i2c 1-005d: [0][62 0x03E, 5 0x005 ,25]
i2c 1-005d: [0][62 0x03E, 5 0x005 ,25]
Event: time 381.135541, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value -1
Event: time 381.135541, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 0
Event: time 381.135541, -------------- SYN_REPORT ------------
i2c 1-005d: [0][1920 0x780, 611 0x263 ,9]
Event: time 381.618983, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value 3
Event: time 381.618983, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 1920
Event: time 381.618983, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 611
Event: time 381i2c 1-005d: [0][1920 0x780, 611 0x263 ,9]
.618983, type 3 (EV_ABS), code 48 (ABS_MT_TOUCH_MAJOR), value 9
Event: time 381.618983, type 3 (EV_ABS), code 58 (ABS_MT_PRESSURE), value 9
Event: time 381.618983, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 1
Event: timi2c 1-005d: [0][1920 0x780, 611 0x263 ,9]
e 381.618983, -------------- SYN_REPORT ------------
i2c 1-005d: [0][1920 0x780, 610 0x262 ,9]
Event: time 381.689121, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 610
Event: time 381.i2c 1-005d: [0][1920 0x780, 610 0x262 ,9]
689121, -------------- SYN_REPORT ------------
i2c 1-005d: [0][1920 0x780, 610 0x262 ,9]
i2c 1-005d: [0][1920 0x780, 609 0x261 ,9]
Event: time 381.724193, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 609
Event: time 381.724193, -------------- SYN_REPORT ------------
Event: time 381.732123, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value -1
Event: time 381.732123, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 0
Event: time 381.732123, -------------- SYN_REPORT ------------
i2c 1-005d: [0][1710 0x6AE, 24 0x018 ,40]
Event: time 382.543382, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value 4
Event: time 382.543382, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 1710
Event: time 382.543382, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 24
Event: time 382.i2c 1-005d: [0][1710 0x6AE, 24 0x018 ,40]
543382, type 3 (EV_ABS), code 48 (ABS_MT_TOUCH_MAJOR), value 40
Event: time 382.543382, type 3 (EV_ABS), code 58 (ABS_MT_PRESSURE), value 40
Event: time 382.543382, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 1
Event: tii2c 1-005d: [0][1710 0x6AE, 24 0x018 ,40]
me 382.543382, -------------- SYN_REPORT ------------
i2c 1-005d: [0][1710 0x6AE, 24 0x018 ,40]
i2c 1-005d: [0][1710 0x6AE, 24 0x018 ,40]
i2c 1-005d: [0][1710 0x6AE, 24 0x018 ,40]
i2c 1-005d: [0][1710 0x6AE, 24 0x018 ,40]
i2c 1-005d: [0][1710 0x6AE, 24 0x018 ,40]
i2c 1-005d: [0][1709 0x6AD, 24 0x018 ,40]
Event: time 382.706948, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 1709
Event: time 382i2c 1-005d: [0][1704 0x6A8, 23 0x017 ,40]
.706948, -------------- SYN_REPORT ------------
Event: time 382.719529, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 1704
Event: time 382.719529, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 23
Event: time 382.719529, -------------- SYN_REPORT ------------
Event: time 382.726589, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value -1
Event: time 382.726589, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 0
Event: time 382.726589, -------------- SYN_REPORT ------------