16位寄存器的TP驱动.docx
- 文档编号:26205190
- 上传时间:2023-06-17
- 格式:DOCX
- 页数:32
- 大小:21.42KB
16位寄存器的TP驱动.docx
《16位寄存器的TP驱动.docx》由会员分享,可在线阅读,更多相关《16位寄存器的TP驱动.docx(32页珍藏版)》请在冰豆网上搜索。
16位寄存器的TP驱动
TP移植
lionking0809
发表于2012-11-2610:
13:
19浏览(132200)
1、修改alps/mediatek/config/${Project}/ProjectConfig.mk中的CUSTOM_KERNEL_TOUCHPANEL值为gb818b
2、用DCT软件配置硬件接口:
EINT3改为TOUCHPANEL,GPIO43的VarName1值改为GPIO_CTP_EN_PIN,GPIO190的DefMode值改为EINT3,VarName1值改为GPIO_CTP_EINT_PIN
3、修改头文件alps/mediatek/custom/cenon13_gb/kernel/touchpanel/gt818b/tpd_custom_gt818b.h(若没有则新建,可仿照cy8ctma300的tpd_custom_cy8ctma300.h)将TPD_CALIBRATION_MATRIX值改为{-384,0,1966080,0,426,0,0,0},
增加如下代码:
staticu8cfg_data[]=
{
#ifdefCUSTOM_KERNEL_ALSPS
0x0E,0x0C,0x0A,0x08,0x06,0x04,0x02,0x00,
0x10,0x12,0x01,0x11,0x11,0x11,0x21,0x11,
0x31,0x11,0x41,0x11,0x51,0x11,0x61,0x11,
0x71,0x11,0x81,0x11,0x91,0x11,0xA1,0x11,
0xB1,0x11,0xC1,0x11,0xD1,0x11,0xE1,0x11,
0xF1,0x11,0x17,0x03,0xE8,0xE8,0xE8,0x2A,
0x2A,0x2A,0x0C,0x0C,0x08,0x40,0x30,0x1d,
0x03,0x00,0x05,0x40,0x01,0xE0,0x01,0x00,
0x00,0x53,0x53,0x4E,0x4E,0x00,0x00,0x1B,
0x14,0x05,0x0A,0x00,0x21,0x33,0x3F,0x04,
0x14,0x10,0x00,0x00,0x04,0x00,0x00,0x00,
0x00,0x08,0x00,0x00,0x00,0x00,0x0B,0x55,
0x40,0x3C,0x28,0x00,0x00,0x00,0x00,0x00,
0x10,0x01
#else
0x12,0x10,0x0E,0x0C,0x0A,0x08,0x06,0x04,
0x02,0x00,0xE0,0x00,0x60,0x00,0xD0,0x00,
0x50,0x00,0xC0,0x00,0x40,0x00,0xB0,0x00,
0x30,0x00,0xA0,0x00,0x20,0x00,0x90,0x00,
0x10,0x00,0x80,0x00,0x00,0x00,0x70,0x00,
0xF0,0x00,0x1D,0x03,0x10,0x10,0x10,0x2A,
0x2A,0x2A,0x0F,0x0F,0x0A,0x40,0x30,0x3B,
0x03,0x00,0x05,0x40,0x01,0xF7,0x01,0x00,
0x00,0x5A,0x59,0x5E,0x5D,0x00,0x00,0x34,
0x14,0x03,0x08,0xEF,0x7D,0xFB,0x77,0xFF,
0x14,0x10,0xE4,0x03,0xFF,0x00,0x00,0x00,
0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xF7,0xED,0xFF,0xDB,0x00,
0x00,0x01
#endif
}
4、alps/mediatek/custom/common/kernel/touchpanel/gt818b/gt818b_driver.c文件参考代码:
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#ifdefCONFIG_HAS_EARLYSUSPEND
#include
#endif
#include
#include
#include
#include
#include
#include"tpd.h"
#include
#include
#ifndefTPD_NO_GPIO
#include"cust_gpio_usage.h"
#endif
#include"tpd_custom_gt818b.h"
externstructtpd_device*tpd;
staticinttpd_flag=0;
staticinttpd_halt=0;
staticinti2c_clock=400;
staticstructtask_struct*thread=NULL;
staticDECLARE_WAIT_QUEUE_HEAD(waiter);
#if(defined(TPD_WARP_START)&&defined(TPD_WARP_END))
staticinttpd_wb_start_local[TPD_WARP_CNT]=TPD_WARP_START;
staticinttpd_wb_end_local[TPD_WARP_CNT] =TPD_WARP_END;
#endif
#if(defined(TPD_HAVE_CALIBRATION)&&!
defined(TPD_CUSTOM_CALIBRATION))
staticinttpd_calmat_local[8] =TPD_CALIBRATION_MATRIX;
staticinttpd_def_calmat_local[8]=TPD_CALIBRATION_MATRIX;
#endif
staticvoidtpd_eint_interrupt_handler(void);
staticinttouch_event_handler(void*unused);
staticinttpd_i2c_probe(structi2c_client*client,conststructi2c_device_id*id);
staticinttpd_i2c_detect(structi2c_client*client,intkind,structi2c_board_info*info);
staticinttpd_i2c_remove(structi2c_client*client);
externvoidmt65xx_eint_unmask(unsignedintline);
externvoidmt65xx_eint_mask(unsignedintline);
externvoidmt65xx_eint_set_hw_debounce(kal_uint8eintno,kal_uint32ms);
externkal_uint32mt65xx_eint_set_sens(kal_uint8eintno,kal_boolsens);
externvoidmt65xx_eint_registration(kal_uint8eintno,kal_boolDbounce_En,
kal_boolACT_Polarity,void(EINT_FUNC_PTR)(void),
kal_boolauto_umask);
externint gt818_downloader(structi2c_client*client,unsignedshortver,unsignedchar*data);
#defineTPD_DITO_SENSOR
#defineTPD_RESET_ISSUE_WORKAROUND
#defineTPD_MAX_RESET_COUNT3
#defineTPD_FREQ_HOPPING
#defineTPD_OK0
#defineTPD_CONFIG_REG_BASE 0x6A2
#defineTPD_FREQ_CAL_RESULT 0x70F
#defineTPD_TOUCH_INFO_REG_BASE 0x712
#defineTPD_KEY_INFO_REG_BASE 0x721
#defineTPD_POINT_INFO_REG_BASE 0x722
#defineTPD_VERSION_INFO_REG 0x713
#defineTPD_POWER_MODE_REG 0x692
#defineTPD_HANDSHAKING_START_REG 0xFFF
#defineTPD_HANDSHAKING_END_REG 0x8000
#defineTPD_FREQ_REG 0x1522
#defineTPD_SOFT_RESET_MODE 0x01
#defineTPD_POINT_INFO_LEN 8
#defineTPD_MAX_POINTS 5
#defineTPD_MAX_KEYS 4
#defineMAX_TRANSACTION_LENGTH8
#defineI2C_DEVICE_ADDRESS_LEN2
#defineI2C_MASTER_CLOCK 400
#defineTPD_CONFIG_SIZE 106
#defineCHR_CON0 (0xF7000000+0x2FA00)
#defineMAX_I2C_TRANSFER_SIZE(MAX_TRANSACTION_LENGTH-I2C_DEVICE_ADDRESS_LEN)
#defineGT818_CONFIG_PROC_FILE"gt818_config"
#defineGT818_CONFIG_I2C_PROC_FILE"gt818_config_i2c"
structtpd_info_t
{
u8vendor_id_1;
u8vendor_id_2;
u8product_id_1;
u8product_id_2;
u8version_1;
u8version_2;
};
staticstructi2c_client*i2c_client=NULL;
staticconststructi2c_device_idtpd_i2c_id[]={{"gt818_tpd",0},{}};
staticunsignedshortforce[]={TPD_I2C_NUMBER,0xBA,I2C_CLIENT_END,I2C_CLIENT_END};
staticconstunsignedshort*constforces[]={force,NULL};
staticstructi2c_client_address_dataaddr_data={.forces=forces,};
staticstructi2c_drivertpd_i2c_driver=
{
.probe=tpd_i2c_probe,
.remove=tpd_i2c_remove,
.detect=tpd_i2c_detect,
.driver.name="gt818_tpd",
.id_table=tpd_i2c_id,
.address_data=&addr_data,
};
structtpd_info_ttpd_info;
#ifdefTPD_FREQ_HOPPING
staticu8freq_base_value=0;
#endif
staticinti2c_write_bytes(structi2c_client*client,u16addr,u8*txbuf,intlen);
staticinti2c_write_dummy(structi2c_client*client,u16addr);
staticstructproc_dir_entry*gt818_config_proc=NULL;
staticintgt818_config_read_proc(char*page,char**start,off_toff,intcount,int*eof,void*data)
{
char*ptr=page;
inti;
ptr+=sprintf(ptr,"====GT818normalconfig====\n");
for(i=0;i { ptr+=sprintf(ptr,"0xX",cfg_data[i]); if(i%8==7) ptr+=sprintf(ptr,"\n"); } ptr+=sprintf(ptr,"\n"); *eof=1; return(ptr-page); } staticintgt818_config_write_proc(structfile*file,constchar*buffer,unsignedlongcount,void*data) { TPD_DEBUG("writecount%ld\n",count); if(count! =TPD_CONFIG_SIZE*2) { TPD_DEBUG("sizenotmatch[%d: %ld]\n",TPD_CONFIG_SIZE*2,count); return-EFAULT; } if(copy_from_user(cfg_data,buffer,count/2)) { TPD_DEBUG("copyfromuserfail\n"); return-EFAULT; } i2c_write_dummy(i2c_client,TPD_HANDSHAKING_START_REG); i2c_write_bytes(i2c_client,TPD_CONFIG_REG_BASE,cfg_data,sizeof(cfg_data)); i2c_write_dummy(i2c_client,TPD_HANDSHAKING_END_REG); returncount; } staticstructproc_dir_entry*gt818_config_i2c_proc=NULL; staticintgt818_config_i2c_read_proc(char*page,char**start,off_toff,intcount,int*eof,void*data) { char*ptr=page; TPD_DMESG("i2cclock%d\n",i2c_clock); ptr+=sprintf(ptr,"i2cclock%d\n",i2c_clock); *eof=1; return(ptr-page); } staticintgt818_config_i2c_write_proc(structfile*file,constchar*buffer,unsignedlongcount,void*data) { charch; intvalue; if(copy_from_user(&ch,buffer,1)) { TPD_DMESG("copyfromuserfail\n"); return-EFAULT; } value=ch-'0'; TPD_DMESG("seti2cclock%d\n",value); if(value>0&&value<5) i2c_clock=value*100; else return-EFAULT; returncount; } staticinti2c_read_bytes(structi2c_client*client,u16addr,u8*rxbuf,intlen) { u8buffer[I2C_DEVICE_ADDRESS_LEN]; u8retry; u16left=len; u16offset=0; structi2c_msgmsg[2]= { { .addr=client->addr, .flags=0, .buf=buffer, .len=I2C_DEVICE_ADDRESS_LEN, .timing=I2C_MASTER_CLOCK }, { .addr=client->addr, .flags=I2C_M_RD, .timing=I2C_MASTER_CLOCK }, }; if(rxbuf==NULL) return-1; TPD_DEBUG("i2c_read_bytestodeviceXaddressXlen%d\n",client->addr,addr,len); while(left>0) { buffer[0]=((addr+offset)>>8)&0xFF; buffer[1]=(addr+offset)&0xFF; msg[1].buf=&rxbuf[offset]; if(left>MAX_TRANSACTION_LENGTH) { msg[1].len=MAX_TRANSACTION_LENGTH; left-=MAX_TRANSACTION_LENGTH; offset+=MAX_TRANSACTION_LENGTH; } else { msg[1].len=left; left=0; } retry=0; while(i2c_transfer(client->adapter,&msg[0],2)! =2) { retry++; if(retry==20) { TPD_DEBUG("I2Cread0x%Xlength=%dfailed\n",addr+offset,len); return-1; } } } return0; } staticinti2c_write_bytes(structi2c_client*client,u16addr,u8*txbuf,intlen) { u8buffer[MAX_TRANSACTION_LENGTH]; u16left=len; u16offset=0;
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 16 寄存器 TP 驱动