当前位置:   article > 正文

MTK 平台TP 驱动_tpd-rst-ext-gpio-num not found

tpd-rst-ext-gpio-num not found

下面以汇顶gt9xx_driver.c 驱动为例讲解TP 驱动的整个关键点,本篇只讲TP 驱动本身的代码,

在驱动代码涉及的方法技术,因为每一个都牵涉linux内核的设计和知识,后面会逐个展开深入讲解。

首先,我们来总体看下TP 驱动代码初始化流程:


MTK kernel-4.14 TP 驱动初始化和部分工作流程main.cmain.cgt9xx_driver.cgt9xx_driver.cmtk_tpd.cmtk_tpd.ci2c.hi2c.hkthread.hkthread.hwait.hwait.hgt9xx_update.cgt9xx_update.cdo_initcallsmodule_inittpd_driver_inittpd_get_dts_infotpd_driver_addtpd_local_initi2c_add_drivertpd_i2c_probetpd_power_ongtp_init_panelkthread_runtouch_event_handlerwait_event_interruptibletpd_irq_registrationtpd_interrupt_handlerwake_up_interruptiblegup_init_update_proc

首先看TP 驱动模块初始化:

 

1

2

3

4

5

6

7

8

9

static int __init tpd_driver_init(void)

{

        GTP_INFO("GT9 series touch panel driver init");

        tpd_get_dts_info();

        if (tpd_driver_add(&tpd_device_driver) < 0)

                GTP_INFO("add generic driver failed");

 

                return 0;

}

 

 


请注意这个tpd_driver_init 是一个__init 修饰的函数,说明这个函数在编译时会被放到跟其他__init 修饰的函数放到一起,
在系统初始化,一旦内核启动后,就释放这些东西。一般用__init修饰的变量或者函数会编译到专门的一个段里面去,
这个段的数据和函数只有在kernel初始化的时候会被调用,以后一定不会被使用,kernel可能会在以后的某个时候释放掉这个段所占用的内存,
给别的地方使用,是不是设计很巧妙? 感兴趣的同学可以继续深入分析看看。

那么,我们看到这个函数主要就做了两件事情:
(1)是获取这个TP 所有的DTS 信息,我们看看这个代码的实现:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

void tpd_get_dts_info(void)

{

        struct device_node *node1 = NULL;

        int key_dim_local[16], i, ret;

 

        node1 = of_find_matching_node(node1, touch_of_match);

        if (node1) {

                ret = of_property_read_u32(node1, "tpd-max-touch-num", &tpd_dts_data.touch_max_num);

                if (ret != 0)

                        TPD_DEBUG("tpd-max-touch-num not found\n");

                ret = of_property_read_u32(node1, "use-tpd-button", &tpd_dts_data.use_tpd_button);

                if (ret != 0)

                        TPD_DEBUG("use-tpd-button not found\n");

                else

                        TPD_DEBUG("[tpd]use-tpd-button = %d\n", tpd_dts_data.use_tpd_button);

                ret = of_property_read_u32_array(node1, "tpd-resolution",

                        tpd_dts_data.tpd_resolution, ARRAY_SIZE(tpd_dts_data.tpd_resolution));

                if (ret != 0)

                        TPD_DEBUG("tpd-resolution not found\n");

                if (tpd_dts_data.use_tpd_button) {

                        ret = of_property_read_u32(node1, "tpd-key-num", &tpd_dts_data.tpd_key_num);

                        if (ret != 0)

                                TPD_DEBUG("tpd-key-num not found\n");

                        ret = of_property_read_u32_array(node1, "tpd-key-local",

                                tpd_dts_data.tpd_key_local, ARRAY_SIZE(tpd_dts_data.tpd_key_local));

                        if (ret != 0)

                                TPD_DEBUG("tpd-key-local not found\n");

                        ret = of_property_read_u32_array(node1, "tpd-key-dim-local",

                                key_dim_local, ARRAY_SIZE(key_dim_local));

                        if (ret != 0)

                                TPD_DEBUG("tpd-key-dim-local not found\n");

 

                        memcpy(tpd_dts_data.tpd_key_dim_local, key_dim_local, sizeof(key_dim_local));

                        for (i = 0; i < 4; i++) {

                                pr_debug("[tpd]key[%d].key_x = %d\n", i, tpd_dts_data.tpd_key_dim_local[i].key_x);

                                pr_debug("[tpd]key[%d].key_y = %d\n", i, tpd_dts_data.tpd_key_dim_local[i].key_y);

                                pr_debug("[tpd]key[%d].key_W = %d\n", i, tpd_dts_data.tpd_key_dim_local[i].key_width);

                                pr_debug("[tpd]key[%d].key_H = %d\n", i, tpd_dts_data.tpd_key_dim_local[i].key_height);

                        }

                }

                ret = of_property_read_u32(node1, "tpd-filter-enable", &tpd_dts_data.touch_filter.enable);

                if (ret != 0)

                        TPD_DEBUG("tpd-filter-enable not found\n");

                if (tpd_dts_data.touch_filter.enable) {

                        ret = of_property_read_u32(node1, "tpd-filter-pixel-density",

                                                 &tpd_dts_data.touch_filter.pixel_density);

                        if (ret != 0)

                                TPD_DEBUG("tpd-filter-pixel-density not found\n");

                        ret = of_property_read_u32_array(node1, "tpd-filter-custom-prameters",

                                (u32 *)tpd_dts_data.touch_filter.W_W, ARRAY_SIZE(tpd_dts_data.touch_filter.W_W));

                        if (ret != 0)

                                TPD_DEBUG("tpd-filter-custom-prameters not found\n");

                        ret = of_property_read_u32_array(node1, "tpd-filter-custom-speed",

                                tpd_dts_data.touch_filter.VECLOCITY_THRESHOLD,

                                ARRAY_SIZE(tpd_dts_data.touch_filter.VECLOCITY_THRESHOLD));

                        if (ret != 0)

                                TPD_DEBUG("tpd-filter-custom-speed not found\n");

                }

                memcpy(&tpd_filter, &tpd_dts_data.touch_filter, sizeof(tpd_filter));

                TPD_DEBUG("[tpd]tpd-filter-enable = %d, pixel_density = %d\n",

                                        tpd_filter.enable, tpd_filter.pixel_density);

                tpd_dts_data.tpd_use_ext_gpio = of_property_read_bool(node1, "tpd-use-ext-gpio");

                ret = of_property_read_u32(node1, "tpd-rst-ext-gpio-num", &tpd_dts_data.rst_ext_gpio_num);

                if (ret != 0)

                        TPD_DEBUG("tpd-rst-ext-gpio-num not found\n");

        else {

                pr_err("[tpd]%s can't find touch compatible custom node\n", __func__);

        }

}

 

这个函数看似很长,其实

声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop】
推荐阅读
相关标签
  

闽ICP备14008679号