MTK传感器驱动

1.修改 kernel-3.10/drivers/misc/mediatek/Kconfig.drivers增加选项:

config MTK_LSM303C_ACC
	bool "MTK_LSM303C_ACC for MediaTek package"
	default n
config MTK_LSM303C_MAG
	bool "MTK_LSM303C_MAG for MediaTek package"
	default n

修改device/${COMPANY}/${PROJECT}/ProjectConfig.mk

MTK_SERSOR_SUPPORT = yes
CUSTOM_KERNEL_ACCELEROMETER = dma280
CUSTOM_HAL_SENSOR = sensor

注意:M-sensor还要设置device/mediatek/mt6735/下的init_mt6735.rc中的daemon


2.添加kernel-3.10/drivers/misc/mediatek/accelerometer/Makefile,增加选项

ifeq ($(CONFIG_MTK_BMA280),y)
obj-y   +=  bma280/
endif
3.添加kernel-3.10/drivers/misc/mediatek/accelerometer/bma280/Makefile ,增加
include $(srctree)/drivers/misc/mediatek/Makefile.custom

obj-y	:=  bma280.o
4.把驱动bma280.c和bma280.h添加到 kernel-3.10/drivers/misc/mediatek/accelerometer/bma280/下
5.修改kernel-3.10/drivers/misc/mediatek/mach/mt6735/rq6735_35gt_b_l1/Makefile,增加

ifeq ($(CONFIG_MTK_BMA280),y)
obj-y   +=  accelerometer/bma280/
endif
6.添加kernel-3.10/drivers/misc/mediatek/mach/mt6735/rq6735_35gt_b_l1/accelerometer/bma280/Makefile,增加

include $(srctree)/drivers/misc/mediatek/Makefile.custom

obj-y	:=  cust_acc.o
7.添加kernel-3.10/drivers/misc/mediatek/mach/mt6735/rq6735_35gt_b_l1/accelerometer/bma280/cust_acc.c

#include <linux/types.h>
#include <cust_acc.h>
#include <mach/mt_pm_ldo.h>


/*---------------------------------------------------------------------------*/
static struct acc_hw cust_acc_hw = {
    .i2c_num = 2,
	.i2c_addr = {0x53,0,0,0},
    .direction = 4,
    .power_id = MT65XX_POWER_NONE,  /*!< LDO is not used */
    .power_vol= VOL_DEFAULT,        /*!< LDO is not used */
    .firlen = 0, //old value 16                /*!< don't enable low pass fileter */
    .is_batch_supported = false,
};
/*---------------------------------------------------------------------------*/
struct acc_hw* bma280_get_cust_acc_hw(void)
{
    return &cust_acc_hw;
}
8.添加kernel-3.10/drivers/misc/mediatek/accelerometer/inc/cust_acc.h
#ifndef __CUST_ACC_H__
#define __CUST_ACC_H__

#include <linux/types.h>
#define G_CUST_I2C_ADDR_NUM 2

struct acc_hw {
        int i2c_num;            /*!< the i2c bus used by the chip */
        int direction;          /*!< the direction of the chip */
        int power_id;           /*!< the VDD LDO ID of the chip, MT6516_POWER_NONE
 means the power is always on */
        int power_vol;          /*!< the VDD Power Voltage used by the chip */
        int firlen;             /*!< the length of low pass filter */
        int (*power) (struct acc_hw *hw, unsigned int on, char *devname);
        unsigned char i2c_addr[G_CUST_I2C_ADDR_NUM];    /*!< i2c address list,for
chips which has different addresses with different HW layout */
        int power_vio_id;       /*!< the VIO LDO ID of the chip, MT6516_POWER_NONE
 means the power is always on */
        int power_vio_vol;      /*!< the VIO Power Voltage used by the chip */
    bool is_batch_supported;
};

extern struct acc_hw *get_cust_acc_hw(void);
struct acc_hw* get_accel_dts_func(const char *, struct acc_hw*);
#endif




























  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值