MT6571 alps 光感 stk3x1x(光感als+距离传感器ps)

来源:互联网 发布:国家甲醛检测标准 知乎 编辑:程序博客网 时间:2024/04/26 19:03
调试 stk3x1x(光感als+距离传感器ps)

配置ProjectConfig.mk

CUSTOM_KERNEL_ALSPS =stk3x1x

Cust_alsps.h (custom\common\kernel\alsps\inc) //这个文件是公共的,如果有设备的这个结构体不一样,把他的设备的参数都添加到这个结构体上。
#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 */}



增加的文件

alps\mediatek\custom\common\kernel\alsps\stk3x1x\stk3x1x.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=%d\n", __func__,hw->i2c_num); i2c_register_board_info(hw->i2c_num, &i2c_stk3x1x, 1);#endifAPS_FUN();if(platform_driver_register(&stk3x1x_alsps_driver)){APS_ERR("failed to register driver");return -ENODEV;}return 0;}


alps\mediatek\custom\mt6571v1_phone_emmc\kernel\alsps\stk3x1x\cust_alsps.c


查设备挂在哪个总线上,就进入哪个总线上找,例如这个光感
root@android:/sys/devices/platform/mt-i2c.1/i2c-1 #cat 1-0048/name
stk3x1x
0 0
原创粉丝点击