首页 > 运维 > linux运维 > 正文

DRV_06_I2C接口触摸屏驱动分析

看不見的法師
发布: 2025-06-27 13:44:01
原创
759人浏览过

资料下载

由于无法通过浏览器直接访问coding,您需要使用git工具进行下载:

git clone https://e.coding.net/weidongshan/linux/doc_and_source_for_drivers.git
登录后复制

视频观看

您可以观看百问网的驱动大全视频。

I2C接口触摸屏驱动分析参考资料

  • Linux 5.x内核

    • Documentation\devicetree\bindings\input\touchscreen\goodix.txt
    • drivers/input/touchscreen/goodix.c
  • Linux 4.x内核

    • Documentation\devicetree\bindings\input\touchscreen\goodix.txt
    • drivers/input/touchscreen/gt9xx/gt9xx.c
  • 设备树

    • IMX6ULL:Linux-4.9.88/arch/arm/boot/dts/100ask_imx6ull-14x14.dts
    • STM32MP157:Linux-5.4/arch/arm/boot/dts/stm32mp15xx-100ask.dtsi

驱动程序框架

DRV_06_I2C接口触摸屏驱动分析

设备树示例

设备树讲解示例

作为一个I2C设备,在某个I2C控制器节点下创建一个子节点。属性包括:

  • 必备,根据这个属性找到驱动程序:compatible = "xxxx";
  • 必备,I2C设备地址:reg = ;
  • 可选:中断、复位引脚
i2c@00000000 {/* ... */gt928@5d {compatible = "goodix,gt928";reg = ;interrupt-parent = ;interrupts = ;irq-gpios = ;reset-gpios = ;};/* ... */};
登录后复制

100ASK_IMX6ULL

&i2c2 {gt9xx@5d {compatible = "goodix,gt9xx";reg = ;status = "okay";interrupt-parent = ;interrupts = ;pinctrl-names = "default";pinctrl-0 = ;/*pinctrl-1 = ;*//* pinctrl-names = "default", "int-output-low", "int-output-high", "int-input"; pinctrl-0 = ; pinctrl-1 = ; pinctrl-2 = ; pinctrl-3 = ;*/reset-gpios = ;irq-gpios = ;irq-flags = ;                /*1:rising 2: falling*/touchscreen-max-id = ;touchscreen-size-x = ;touchscreen-size-y = ;touchscreen-max-w = ;touchscreen-max-p = ;/*touchscreen-key-map = , ;*/ /*KEY_HOMEPAGE, KEY_BACK*/goodix,type-a-report = ;goodix,driver-send-cfg = ;goodix,create-wr-node = ;goodix,wakeup-with-reset = ;goodix,resume-in-workqueue = ;goodix,int-sync = ;goodix,swap-x2y = ;goodix,esd-protect = ;goodix,pen-suppress-finger = ;goodix,auto-update = ;goodix,auto-update-cfg = ;goodix,power-off-sleep = ;/* ...... */};};
登录后复制

100ASK_STM32MP157

&i2c4 {    gt911@5d {compatible = "goodix,gt928";reg = ;interrupt-parent = ;interrupts = ;reset-gpios = ;irq-gpios = ;irq-flags = ;                /*1:rising 2: falling*/touchscreen-max-id = ;touchscreen-size-x = ;touchscreen-size-y = ;};};
登录后复制

驱动程序分析

分配/设置/注册input_dev

  • IMX6ULL Linux 4.x
gtp_proberet = gtp_request_input_dev(ts);ts->input_dev = input_allocate_device();......ret = input_register_device(ts->input_dev);ret = gtp_request_irq(ts);
登录后复制
  • STM32MP157 Linux 5.x
goodix_ts_probeerror = request_firmware_nowait(THIS_MODULE, true, ts->cfg_name,&client->dev, GFP_KERNEL, ts,goodix_config_cb);goodix_config_cbgoodix_configure_dev(ts);ts->input_dev = devm_input_allocate_device(&ts->client->dev);......error = input_register_device(ts->input_dev);error = goodix_request_irq(ts);
登录后复制

注册中断处理函数

  • IMX6ULL Linux 4.x
ret = request_threaded_irq(ts->client->irq, NULL,gtp_irq_handler,ts->pdata->irq_flags | IRQF_ONESHOT,ts->client->name,ts);
登录后复制
  • STM32MP157 Linux 5.x
static int goodix_request_irq(struct goodix_ts_data *ts){return devm_request_threaded_irq(&ts->client->dev, ts->client->irq, NULL, goodix_ts_irq_handler, ts->irq_flags, ts->client->name, ts);}
登录后复制

中断处理函数分析

通过I2C函数读取数据、上报数据。

  • IMX6ULL Linux 4.x
gtp_irq_handlergtp_work_func(ts);point_state = gtp_get_points(ts, points, &key_value);gtp_i2c_readi2c_transfergtp_mt_slot_report(ts, point_state & 0x0f, points);input_mt_slotinput_mt_report_slot_stateinput_report_abs
登录后复制
  • STM32MP157 Linux 5.x
goodix_ts_irq_handlergoodix_process_events(ts);touch_num = goodix_ts_read_input_report(ts, point_data);goodix_i2c_readi2c_transfergoodix_ts_report_touch_9binput_mt_slotinput_mt_report_slot_statetouchscreen_report_posinput_report_abs
登录后复制

以上就是DRV_06_I2C接口触摸屏驱动分析的详细内容,更多请关注php中文网其它相关文章!

驱动精灵
驱动精灵

驱动精灵基于驱动之家十余年的专业数据积累,驱动支持度高,已经为数亿用户解决了各种电脑驱动问题、系统故障,是目前有效的驱动软件,有需要的小伙伴快来保存下载体验吧!

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号