调试 stk3x1x(光感als+距离传感器ps)
配置ProjectConfig.mk中
CUSTOM_KERNEL_ALSPS =stk3x1x
Cust_alsps.h (customcommonkernelalspsinc) //这个文件是公共的,如果有设备的这个结构体不一样,把他的设备的参数都添加到这个结构体上。
#define C_CUST_I2C_ADDR_NUM 1 // 可以有多个,看设备能接收多少个地址//注意如果这里乱设置数量,可能会引起这个i2c上挂的别的设备挂载失败。
//比如:这个alps设备只能拉收一个地址,而改成为4个,导致了ft5260(Touchpanel)工作失败。
//从uart 口抓log来看,MTK平台,先初始化accelerometer再,接着alps,接着是TouchPanel....
struct alsps_hw {
int i2c_num; //这是这个设备挂在主板的哪个i2c接口总线上,MT6571上有i2c0和i2c1 ,一般摄像头是使用i2c0,别的设备都共用i2c1,(挂那么多设备,i2c要有上拉电阻,2.2K左右驱动能力才够) /* the i2c bus used by ALS/PS */
int power_id; /*the VDD power id of the als chip */
int power_vol; /* the VDD power voltage of the als chip */
int polling_mode; /* 1: polling mode ; 0:interrupt mode*/
int polling_mode_ps; /* 1: polling mode ; 0:interrupt mode*/
int polling_mode_als; /* 1: polling mode ; 0:interrupt mode*/
unsigned char i2c_addr[C_CUST_I2C_ADDR_NUM]; /*i2c address list, some chip will have multiple address */
//这个是设备的i2c地址,可能有多个,有这个设备能接收多个i2c地址,每个地址可能有相应的功能, 光感、距离、....
unsigned int als_level[C_CUST_ALS_LEVEL-1]; /* (C_CUST_ALS_LEVEL-1) levels divides all range into C_CUST_ALS_LEVEL levels*/
unsigned int als_value[C_CUST_ALS_LEVEL]; /* the value reported in each level */
unsigned int ps_threshold; /* the threshold of proximity sensor */
}
增加的文件
alpsmediatekcustomcommonkernelalspsstk3x1xstk3x1x.c stk3x1x.h
static struct platform_driver stk3x1x_alsps_driver = {
.probe = stk3x1x_probe,
.remove = stk3x1x_remove,
.driver = {
.name = "als_ps",
#if (LINUX_VERSION_CODE<KERNEL_VERSION(3,0,0))
.owner = THIS_MODULE,
#endif
}
};
/*----------------------------------------------------------------------------*/
static int __init stk3x1x_init(void)
{
#if (LINUX_VERSION_CODE>=KERNEL_VERSION(3,0,0))
struct alsps_hw *hw = get_cust_alsps_hw();
APS_LOG("%s: i2c_number=%dn", __func__,hw->i2c_num);
i2c_register_board_info(hw->i2c_num, &i2c_stk3x1x, 1);
#endif
APS_FUN();
if(platform_driver_register(&stk3x1x_alsps_driver))
{
APS_ERR("failed to register driver");
return -ENODEV;
}
return 0;
}
alpsmediatekcustommt6571v1_phone_emmckernelalspsstk3x1xcust_alsps.c
查设备挂在哪个总线上,就进入哪个总线上找,例如这个光感
root@android: /sys/devices/platform/mt-i2c.1/i2c-1 #cat 1-0048/name
stk3x1x
最后
以上就是殷勤诺言最近收集整理的关于MT6571 alps 光感 stk3x1x(光感als+距离传感器ps)的全部内容,更多相关MT6571内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复