linux下移植电容屏驱动gt9xx 笔记

#  evtest  /dev/event0
或者
# hexdump /dev/event0

//////////////////////////////////////////////
分析:
\drivers\i2c\busses\I2c-digicolor.c
static struct platform_driver i2c_dc_driver = {
 .probe  = i2c_dc_probe,
 .remove  = __exit_p(i2c_dc_remove),
 .driver  = {
  .name = "i2c-digicolor",
  .owner = THIS_MODULE,
 },
};

static int i2c_dc_probe(struct platform_device *dev)
 --->i2c->adap.algo = &i2c_dc_algorithm;
 

static const struct i2c_algorithm i2c_dc_algorithm = {
 .master_xfer = i2c_dc_xfer,
 .functionality = i2c_dc_functionality,
};
 
static int i2c_dc_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
  --->i2c_dc_fatal_error(i2c, "excess retries");
 
 
在文件
\drivers\input\dc\Gt9xx.c
static int __devinit goodix_ts_init(void)
 ---> ret = i2c_add_driver(&goodix_ts_driver);
 
static struct i2c_driver goodix_ts_driver = {
    .probe      = goodix_ts_probe,
    .remove     = goodix_ts_remove,
#ifdef CONFIG_HAS_EARLYSUSPEND
    .suspend    = goodix_ts_early_suspend,
    .resume     = goodix_ts_late_resume,
#endif
    .id_table   = goodix_ts_id,
    .driver = {
        .name     = GTP_I2C_NAME,
        .owner    = THIS_MODULE,
    },
};

static int goodix_ts_probe(struct i2c_client *client, const struct i2c_device_id *id)
 --->INIT_WORK(&ts->work, goodix_ts_work_func);
    static void goodix_ts_work_func(struct work_struct *work)
        --->ret = gtp_i2c_read(ts->client, point_data, 12);
         --->ret = i2c_transfer(client->adapter, &msg, 1); 
                --->ret = adap->algo->master_xfer(adap, msgs, num);
                     最终调用i2c_dc_xfer 
 

//---------------------------------------------------------------------
//温度传感器Rtc-pcf8563
static int i2c_dc_probe(struct platform_device *dev)
 --->i2c_new_probed_device(&i2c->adap, &(i2c_dc_board_list[i].dc_board_info),i2c_dc_board_list[i].dc_board_addr_list);
 
 

static struct i2c_dc_board i2c_dc_board_list[] = 
 
 
--->
 //添加i2c子设备
 //ljh 
 #if defined 1
     {
         {I2C_BOARD_INFO("pcf8563", 0x51)},
         {0x51,I2C_CLIENT_END},
     },
 #endif
 
 
 
 
\drivers\rtc\Rtc-pcf8563.c
匹配name pcf8563
static struct i2c_driver pcf8563_driver = {
 .driver  = {
  //.name = "rtc-pcf8563",
  .name = "pcf8563", 
 },
 .probe  = pcf8563_probe,
 .remove  = pcf8563_remove,
 .id_table = pcf8563_id,
};
//-----------------------------------------------------------------------
 
 
2015-04-02
问1:内核启动的时候,加载i2c总线驱动,加载pcf8563设备和Goodix-TS设备出错

i2c /dev entries driver
i2c_dc_enable: RA_CSR_GP_MNOP_CTRL = 0x1f1f101f
i2c-digicolor: i2c-1: I2C adapter
i2c-digicolor: registering device dc_maui which has slave addr 0x4a
DigiColor MAUI registered with bus id (1) with slave address 0x4a
Forcing PLL3 to 960 MHz!
Forcing AUD_TX to 24.62 MHz!
dc_maui: read reg_id: ANALOG_TEST_26 addr: 0xbe result: 0x0d (13)
dc_maui: read reg_id: ANALOG_TEST_22 addr: 0xba result: 0x00 (0)
dc_maui: read reg_id: ANALOG_TEST_18 addr: 0xb6 result: 0x00 (0)
i2c-digicolor: registering device pcf8563 which has slave addr 0x51
i2c-digicolor: error: excess retries
i2c_dc: msg_num: 0 msg_idx: -11 msg_ptr: 0, bus: 0f cmd: 0a
i2c-digicolor: registering device Goodix-TS which has slave addr 0x5d
i2c-digicolor: error: excess retries
i2c_dc: msg_num: 0 msg_idx: -11 msg_ptr: 0, bus: 0f cmd: 0a

答1:入口跟踪分析
 static int i2c_dc_probe(struct platform_device *dev)
  ---> printk(KERN_INFO "i2c-digicolor: registering device %s which has slave addr 0x%x\n", i2c_dc_board_list[i].dc_board_info.type, i2c_dc_board_list[i].dc_board_addr_list[0]);
          i2c_new_probed_device(&i2c->adap, &(i2c_dc_board_list[i].dc_board_info),i2c_dc_board_list[i].dc_board_addr_list);
 
 
 
问2:加载gt9xx 驱动后错误信息:
i2c-digicolor: error: excess retries
i2c_dc: msg_num: 0 msg_idx: -11 msg_ptr: 0, bus: 0f cmd: 0a
i2c-digicolor: error: excess retries
i2c_dc: msg_num: 0 msg_idx: -11 msg_ptr: 0, bus: 0f cmd: 0a
i2c-digicolor: error: excess retries
i2c_dc: msg_num: 0 msg_idx: -11 msg_ptr: 0, bus: 0f cmd: 0a
i2c-digicolor: error: excess retries
i2c_dc: msg_num: 0 msg_idx: -11 msg_ptr: 0, bus: 0f cmd: 0a
i2c-digicolor: error: excess retries
i2c_dc: msg_num: 0 msg_idx: -11 msg_ptr: 0, bus: 0f cmd: 0a
<<-GTP-ERROR->> I2C retry timeout, reset chip.
<<-GTP-INFO->> I2C write end_cmd  error!
i2c-digicolor: error: excess retries
i2c_dc: msg_num: 0 msg_idx: -11 msg_ptr: 0, bus: 0f cmd: 0a
i2c-digicolor: error: excess retries
i2c_dc: msg_num: 0 msg_idx: -11 msg_ptr: 0, bus: 0f cmd: 0a
i2c-digicolor: error: excess retries
i2c_dc: msg_num: 0 msg_idx: -11 msg_ptr: 0, bus: 0f cmd: 0a
i2c-digicolor: error: excess retries
i2c_dc: msg_num: 0 msg_idx: -11 msg_ptr: 0, bus: 0f cmd: 0a
i2c-digicolor: error: excess retries
i2c_dc: msg_num: 0 msg_idx: -11 msg_ptr: 0, bus: 0f cmd: 0a
<<-GTP-ERROR->> I2C retry timeout, reset chip.
<<-GTP-ERROR->> I2C transfer error. errno:-121
 
i2c-digicolor: error: excess retries
i2c_dc: msg_num: 0 msg_idx: -11 msg_ptr: 0, bus: 0f cmd: 0a
i2c-digicolor: error: excess retries
i2c_dc: msg_num: 0 msg_idx: -11 msg_ptr: 0, bus: 0f cmd: 0a
i2c-digicolor: error: excess retries
i2c_dc: msg_num: 0 msg_idx: -11 msg_ptr: 0, bus: 0f cmd: 0a
i2c-digicolor: error: excess retries
i2c_dc: msg_num: 0 msg_idx: -11 msg_ptr: 0, bus: 0f cmd: 0a
i2c-digicolor: error: excess retries
i2c_dc: msg_num: 0 msg_idx: -11 msg_ptr: 0, bus: 0f cmd: 0a
<<-GTP-ERROR->> I2C retry timeout, reset chip.
<<-GTP-INFO->> I2C write end_cmd  error!
i2c-digicolor: error: excess retries
i2c_dc: msg_num: 0 msg_idx: -11 msg_ptr: 0, bus: 0f cmd: 0a
i2c-digicolor: error: excess retries
i2c_dc: msg_num: 0 msg_idx: -11 msg_ptr: 0, bus: 0f cmd: 0a
i2c-digicolor: error: excess retries
i2c_dc: msg_num: 0 msg_idx: -11 msg_ptr: 0, bus: 0f cmd: 0a
i2c-digicolor: error: excess retries
i2c_dc: msg_num: 0 msg_idx: -11 msg_ptr: 0, bus: 0f cmd: 0a
i2c-digicolor: error: excess retries
i2c_dc: msg_num: 0 msg_idx: -11 msg_ptr: 0, bus: 0f cmd: 0a
<<-GTP-ERROR->> I2C retry timeout, reset chip.
<<-GTP-ERROR->> I2C transfer error. errno:-121
一直循环打印出来
答2:i2c总线挂载了3个i2c从设备,上拉电阻改小,由4.7k改成1k左右就可以了,电阻小的话驱动能力加强了!
 
 

问3: i2c_client和i2c_driver结构体在设备驱动层如何填充?
答3: i2c驱动由3个部分组成,总线驱动层,核心驱动层,设备驱动层,
   平时我们移植驱动的话主要是移植设备驱动层, i2c_client和i2c_driver结构体都是设备驱动层相关的结构体
 
 
 
 
 

问4:定时36ms刷新触摸电容ic的数据,这些数据如何定义?
point_data[0]=129
point_data[1]=78
point_data[2]=0
point_data[3]=129
point_data[4]=11
point_data[5]=99
point_data[6]=31
point_data[7]=217
point_data[8]=29
point_data[9]=242
point_data[10]=194
point_data[11]=250
point_data[12]=0
point_data[13]=0
finger = 0
point_data[0]=129
point_data[1]=78
point_data[2]=0
point_data[3]=129
point_data[4]=11
point_data[5]=99
point_data[6]=31
point_data[7]=217
point_data[8]=29
point_data[9]=242
point_data[10]=194
point_data[11]=250
point_data[12]=0
point_data[13]=0
finger = 0
答4:
 这些都是电容屏gt9xx的坐标数据
 
 
问5:读取version出错?自己写入i2c,再去取i2c数据,有时候出错,不稳定?拔掉i2c屏幕,还是同样的现象,
     如何判定cpu和i2c芯片通信正常?

81,40, b9, 13, fa, 59, 72, c4
        185 s   250 y   114 196 
        
# insmod  gt9xx.ko 
<<-GTP-FUNC->> Func:goodix_ts_init@Line:1621
<<-GTP-FUNC->> Func:goodix_ts_probe@Line:1182
<<-GTP-INFO->> **************************************
<<-GTP-INFO->> GTP Driver Version:V1.5<2013/08/05>
<<-GTP-INFO->> GTP Driver build@15:22:34,Apr 11 2015
<<-GTP-INFO->> GTP I2C Address:0x14
<<-GTP-INFO->> **************************************
<<-GTP-INFO->>  
<<-GTP-FUNC->> Func:gtp_i2c_test@Line:958
<<-GTP-FUNC->> Func:gtp_i2c_read@Line:87
ret=2
test[0]=80
test[1]=47
test[2]=12
<<-GTP-DEBUG->> [806]len1=228,len2=0,len3=0,send_len:228
<<-GTP-DEBUG->> [823]SENSOR ID:0
ljh debug gt9xx
<<-GTP-FUNC->> Func:gtp_init_panel@Line:868
<<-GTP-FUNC->> Func:gtp_i2c_write@Line:132
<<-GTP-DEBUG->> [887]X_MAX = 1280,Y_MAX = 800,TRIGGER = 0x00
<<-GTP-FUNC->> Func:gtp_request_input_dev@Line:1097
input: Goodix Capacitive TouchScreen as /class/input/input1
<<-GTP-DEBUG->> [1048]INT trigger type:0
<<-GTP-ERROR->> Request IRQ failed!ERRNO:1.
<<-GTP-INFO->> GTP works in polling mode.
<<-GTP-FUNC->> Func:gtp_read_version@Line:911
<<-GTP-FUNC->> Func:gtp_i2c_read@Line:87
<<-GTP-INFO->> IC VERSION:14
IC VERSION:81,40,b9,01,fa,49,f2,d4
<<-GTP-FUNC->> Func:gtp_irq_enable@Line:222
# <<-GTP-FUNC->> Func:goodix_ts_timer_handler@Line:575
<<-GTP-FUNC->> Func:goodix_ts_work_func@Line:328
goodix_ts_work_func
<<-GTP-FUNC->> Func:gtp_i2c_read@Line:87
point_data[0]=81
point_data[1]=4e
point_data[2]=fb
point_data[3]=81
point_data[4]=10
point_data[5]=e3
point_data[6]=9e
point_data[7]=fa
point_data[8]=1d
point_data[9]=f2
point_data[10]=8a
point_data[11]=fb
point_data[12]=0
point_data[13]=0
finger = 251
<<-GTP-FUNC->> Func:gtp_i2c_write@Line:132
<<-GTP-FUNC->> Func:gtp_i2c_read@Line:87
test_buf[0]=80
test_buf[1]=9d
test_buf[2]=5a
test_buf[3]=5b
test_buf[4]=57
test_buf[5]=65
test_buf[6]=6a
test_buf[7]=6c
test_buf[8]=6d
test_buf[9]=0
test_buf[10]=0
touch_num = 11
<<-GTP-FUNC->> Func:gtp_i2c_write@Line:132
<<-GTP-FUNC->> Func:goodix_ts_timer_handler@Line:575
<<-GTP-FUNC->> Func:goodix_ts_work_func@Line:328
goodix_ts_work_func
<<-GTP-FUNC->> Func:gtp_i2c_read@Line:87
point_data[0]=81
point_data[1]=4e
point_data[2]=0
point_data[3]=81
point_data[4]=10
point_data[5]=e3
point_data[6]=9e
point_data[7]=fa
point_data[8]=1d
point_data[9]=f2
point_data[10]=8a
point_data[11]=fb
point_data[12]=0
point_data[13]=0
finger = 0
<<-GTP-FUNC->> Func:gtp_i2c_write@Line:132
<<-GTP-FUNC->> Func:gtp_i2c_read@Line:87
test_buf[0]=80
test_buf[1]=9d
test_buf[2]=59
test_buf[3]=5b
test_buf[4]=57
test_buf[5]=66
test_buf[6]=6a
test_buf[7]=6b
test_buf[8]=6d
test_buf[9]=0
test_buf[10]=0
<<-GTP-FUNC->> Func:gtp_i2c_write@Line:132
<<-GTP-FUNC->> Func:goodix_ts_timer_handler@Line:575
<<-GTP-FUNC->> Func:goodix_ts_work_func@Line:328
goodix_ts_work_func
<<-GTP-FUNC->> Func:gtp_i2c_read@Line:87
point_data[0]=81
point_data[1]=4e
point_data[2]=0
point_data[3]=81
point_data[4]=10
point_data[5]=e3
point_data[6]=9e
point_data[7]=fa
point_data[8]=1d
point_data[9]=f2
point_data[10]=8a
point_data[11]=fb
point_data[12]=0
point_data[13]=0
finger = 0
<<-GTP-FUNC->> Func:gtp_i2c_write@Line:132
<<-GTP-FUNC->> Func:gtp_i2c_read@Line:87
test_buf[0]=80
test_buf[1]=9d
test_buf[2]=59
test_buf[3]=5b
test_buf[4]=57
test_buf[5]=65
test_buf[6]=6a
test_buf[7]=6b
test_buf[8]=6d
test_buf[9]=0
test_buf[10]=0
<<-GTP-FUNC->> Func:gtp_i2c_write@Line:132
<<-GTP-FUNC->> Func:goodix_ts_timer_handler@Line:575
<<-GTP-FUNC->> Func:goodix_ts_work_func@Line:328
goodix_ts_work_func
<<-GTP-FUNC->> Func:gtp_i2c_read@Line:87
point_data[0]=81
point_data[1]=4e
point_data[2]=0
point_data[3]=81
point_data[4]=10
point_data[5]=e3
point_data[6]=9e
point_data[7]=fa
point_data[8]=1d
point_data[9]=f2
point_data[10]=8a
point_data[11]=fb
point_data[12]=0
point_data[13]=0
finger = 0

答5:写入寄存器数据,再读出寄存器的数据,如果一样就证明通信正常。最好的办法是读只读寄存器的数据,如果读出的值
  符合手册要求,就证明cpu与外设通信正常了。
 

问6:中断方式下无法进入goodix_ts_work_func函数,但是定时查询方式可以进入中断子函数goodix_ts_work_func?
答6:目前把io配置成查询方式
 
问7:hexdump /dev/event1 分析
地址            秒        微秒       类    code     value
按下打印
0000120  1341 0000  4ff0 0001  0003  0000  0211 0000   x坐标0x211 =529
0000130  1341 0000  4ff0 0001  0003  0001  000d 0000   y坐标0x0d  =13
0000140  1341 0000  4ff0 0001  0003  0018  00ff 0000
0000150  1341 0000  4ff0 0001  0001  014a  0001 0000
0000160  1341 0000  4ff0 0001  0000  0000  0000 0000
                                     
释放打印
0000170  1345 0000  b3b0 0000  0003  0018  0000 0000
0000180  1345 0000  b3b0 0000  0001  014a  0000 0000
0000190  1345 0000  b3b0 0000  0000  0000  0000 0000


你可能感兴趣的:(linux下移植电容屏驱动gt9xx 笔记)