MT6580 Android8.1调试移植费恩格尔指纹驱动

  • Post author:
  • Post category:其他


1、首先用万用表确定好vcc 2.8v和1.8v的供电正常,有的平台2.8v是软件控制打开,有的平台是直接硬件长供的。

2、根据原理图确定好gpio的配置主要包括spi_cs,spi_sck,spi_miso,spi_mosi,还有复位脚rst和中断脚int:,使用的是哪一组SPI通讯等。

3、dts添加cdfinger 的节点,gpio的配置等,注意查看所使用的gpio是否有其他地方有复用:

vim kernel-3.18/arch/arm/boot/dts/alongk80_bsp.dts

&cdfinger {

compatible = “cdfinger,fps1098”;

reg = <0>;

interrupt-parent = <&eintc>;

interrupts = <83 IRQ_TYPE_EDGE_RISING>;

debounce = <83 0>;

vdd_ldo_enable = <0>;

vio_ldo_enable = <0>;

config_spi_pin = <1>;

spi-max-frequency = <8000000>;

pinctrl-names = “fingerprint_reset_high”,

“fingerprint_reset_low”,

“fingerprint_spi_miso”,

“fingerprint_spi_mosi”,

“fingerprint_spi_sck”,

“fingerprint_spi_cs”,

“fingerprint_irq”;

pinctrl-0 = <&fps_reset_high>;

pinctrl-1 = <&fps_reset_low>;

pinctrl-2 = <&fps_spi_miso>;

pinctrl-3 = <&fps_spi_mosi>;

pinctrl-4 = <&fps_spi_sck>;

pinctrl-5 = <&fps_spi_cs>;

pinctrl-6 = <&fps_irq>;

status = “okay”;

};

&pio {

fps_reset_high: fps_reset_high {

pins_cmd_dat {

pins = ;

slew-rate = <1>;

bias-disable;

output-high;

};

};

fps_reset_low: fps_reset_low {

pins_cmd_dat {

pins = ;

slew-rate = <1>;

bias-disable;

output-low;

};

};

fps_spi_miso:fps_spi_miso@gpio3{

pins_cmd_dat {

pins = ;

slew-rate = <0>;

bias-pull-up = <11>;

output-low;

};

};

fps_spi_mosi:fps_spi_mosi@gpio2{

pins_cmd_dat {

pins = ;

slew-rate = <1>;

bias-pull-up = <11>;

output-low;

};

};

fps_spi_sck:fps_spi_sck@gpio1{

pins_cmd_dat {

pins = ;

slew-rate = <1>;

bias-pull-up = <11>;

output-low;

};

};

fps_spi_cs:fps_spi_cs@gpio0{

pins_cmd_dat {

pins = ;

slew-rate = <1>;

bias-pull-up = <11>;

output-low;

};

};

fps_irq: fps_irq {

pins_cmd_dat {

pins = ;

slew-rate = <0>;

bias-disable;

output-low;

};

};

};

4、mt6580.dts添加pmic的配置

vim /kernel-3.18/arch/arm/boot/dts/mt6580.dts

@@ -773,6 +773,13 @@

#size-cells = <0>;

};

+

+               cdfinger:cdfinger@ {

+                       compatible = “cdfinger,fps1098”;

+                       finger-supply = <&mt_pmic_vgp1_ldo_reg>;

+               };

+

5、defconfig打开要编译驱动的宏配置

vim kernel-3.18/arch/arm/configs/alongk80_bsp_debug_defconfig

+# for finger

+CONFIG_MTK_FINGERPRINT_SUPPORT=y

+CONFIG_CDFINGER_FP_REE_FINGERPRINT=y

vim kernel-3.18/arch/arm/configs/alongk80_bsp_defconfig

+# for finger

+CONFIG_MTK_FINGERPRINT_SUPPORT=y

+CONFIG_CDFINGER_FP_REE_FINGERPRINT=y

6、修改Makefile和Kconfig文件:

vim /kernel-3.18/drivers/input/fingerprint/Kconfig

+config CDFINGER_FP_REE_FINGERPRINT

+       bool “Mediatek cdfinger_fp_ree Fingerprint”

+       default n

+       —help—

+       Fingerprint mtk driver enable/disable in the kernel.

+       Say Y here if you want to use mediatek fingerprint driver,

+       fingerprint driver will support fingerprint function

+

vim kernel-3.18/drivers/input/fingerprint/Makefile

obj-$(CONFIG_CDFINGER_FP_REE_FINGERPRINT) += cdfinger_fp_ree/

把驱动文件放到对应kernel目录:

kernel-3.18/drivers/input/fingerprint/cdfinger_fp_ree/

7、使用gpio工具配置gpio配置文件dws,

kernel-3.18/drivers/misc/mediatek/dws/mt6580/alongk80_bsp.dws

把kernel下的dws文件拷贝到其它对应目录,注意名称跟kernel不一样

vendor/mediatek/proprietary/bootable/bootloader/lk/target/alongk80_bsp/dct/dct/codegen.dws

vendor/mediatek/proprietary/bootable/bootloader/preloader/custom/alongk80_bsp/dct/dct/codegen.dws

vendor/mediatek/proprietary/custom/alongk80_bsp/kernel/dct/dct/codegen.dws

然后编译kernel-3.18,驱动加载运行成功后会生成/dev/fpsdev0 的驱动设备节点。

8、上层的移植:

SELinux 权 限 位 于 软 件 包 android/device/cdfinger/sepolicy 目 录 下 , 其 中cdfinger.te 为新增文件,其它文件是在源码上追加。将 cdfinger 整个文件夹放到源 码 device 目 录 下 。 若 需 放 到 其 它 目 录 , 把 Android.mk 和

cdfinger_product_32bit.mk/cdfinger_product_64bit.mk 中 LOCAL_PATH 改成相应目录即可。

编译时 cdfinger 目录下的 Android.mk 中使用 BOARD_SEPOLICY_DIRS 将会把权限加入源码中。加入权限后第一次编译需要删除之前的中间文件,保证改动生效:

rm-rf out/target/product/xxxx/obj/ETC/sepolicy_intermediates

即把cdfinger文件夹拷贝到device目录下,注意使用的是64bit还算32bit,一般保留一个即可,本案例使用32bit的驱动,故没有把64bit的库文件放进device/cdfinger目录,而且使用cdfinger_product_32bit.mk文件。

修改device/along/alongk80_bsp/device.mk

— a/device/along/alongk80_bsp/device.mk

+++ b/device/along/alongk80_bsp/device.mk

@@ -183,3 +183,9 @@ PRODUCT_PACKAGES += \

FactoryTest \

MtkSoundRecorder

# end by chengl

+

+# add for cdfinger start by caizd

+PRODUCT_PACKAGES += android.hardware.biometrics.fingerprint@2.1-service

+

+$(call inherit-product, device/cdfinger/cdfinger_product_32bit.mk)

+# add for cdfinger end by caizd

vim device/mediatek/mt6580/manifest.xml添加cdfinger在设置的菜单选项:

+

+        android.hardware.biometrics.fingerprint

+        hwbinder

+        2.1

+

+            IBiometricsFingerprint

+            default

+

+

9、在system/core/rootdir/init.rc

添加init.cdfinger.rc文件的引用:

+++ b/system/core/rootdir/init.rc

@@ -11,6 +11,10 @@ import /vendor/etc/init/hw/init.${ro.hardware}.rc

import /init.usb.configfs.rc

import /init.${ro.zygote}.rc

+# add for cdfinger start by caizd

+import /init.cdfinger.rc

+# add for cdfinger end by caizd

+