MT8788 android 9.0 sensor 驱动移植

时间:2023-02-02 18:56:03

1. 硬件配置

打开 MT8788 核心板原理图,配置 GYRO (陀螺仪),ALSPS (光感),G-sensor (加速度) 的 ENIT 和 GPIO 以及 I2C,打开
vendor\mediatek\proprietary\scripts\dct\DrvGen.exe 工具选择
(1)vendor\mediatek\proprietary\bootable\bootloader\lk\target\tb8788p1_64_bsp\dct\dct\codegen.dws
(2)kernel-4.4\drivers\misc\mediatek\dws\mt6771\tb8788p1_64_bsp.dws
 

如果不知道 I2C 挂在哪个总线上,地址是多少,可以参考一下操作
路径: kernel-4.4\arch\arm64\boot\dts\mediatek\tb8788p1_64_bsp.dts (搜索 sensor)


2.sensor 驱动移植

2.1 添加光感驱动文件 (ap3xx6c)
将 ap3xx6c 驱动文件夹添加到 alsps (光感) 目录中
kernel-4.4\drivers\misc\mediatek\sensors-1.0\alsps\ap3xx6c

2.2 修改配置文件
(1) 路径:device/mediateksample/tb8788p1_64_bsp/ProjectConfig.mk

CUSTOM_KERNEL_GYROSCOPE = yes

(2) 路径:kernel-4.4/arch/arm64/configs/tb8788p1_64_bsp_defconfig,添加以下代码,有的话就不用添加,添加没有的就行

CONFIG_MTK_SENSORS_1_0=y
CONFIG_CUSTOM_KERNEL_ACCELEROMETER=y
#CONFIG_MTK_MC3410_I2C is not set
CONFIG_CUSTOM_KERNEL_ALSPS=y
CONFIG_MTK_LTR303=y
#CONFIG_MTK_LTR303 is not set
CONFIG_MTK_AP3XX6C=y
CONFIG_CUSTOM_KERNEL_MAGNETOMETER=y
CONFIG_MTK_AKM09918=y
CONFIG_CUSTOM_KERNEL_GYROSCOPE=y
CONFIG_MTK_MPU6050GY=y
CONFIG_MTK_MPU6050G=y

(3) 路径:kernel-4.4/drivers/misc/mediatek/sensors-1.0/alsps/Kconfig

source "drivers/misc/mediatek/sensors-1.0/alsps/ap3xx6c/Kconfig"

(4) 路径:kernel-4.4/drivers/misc/mediatek/sensors-1.0/alsps/Makefile

obj-$(CONFIG_MTK_AP3XX6C)      +=  ap3xx6c/