本文只介绍驱动移植的过程,不做技术分析。
先在公司把手上的驱动顺利编译通过,验证正常。不要去到客户现场再出现一堆编译不过的问题。
驱动会去读取dts的配置内容,如:中断管脚、复位管脚等信息,所以要先配置dts。
添加文件 kernel/msm-3.18/arch/arm64/boot/dts/qcom/msm8953-chipsailing.dtsi
这个文件主要配置 复位管脚、中断管脚、spi管脚。主要如下:
&soc {
chipsailing_fp {
compatible = "chipsailing,fingerprint";
spi-max-frequency = <1000000>;
input-device-name = "cs3511";
interrupt-parent = <&tlmm>;
interrupts = <48 0x0>;
chipsailing,gpio_rst = <&tlmm 140 0>;
chipsailing,gpio_irq = <&tlmm 48 0>;
clock-names = "iface_clk", "core_clk";
clocks = <&clock_gcc clk_gcc_blsp2_ahb_clk>,
<&clock_gcc clk_gcc_blsp2_qup3_spi_apps_clk>;
pinctrl-names = "chipsailing_spi_active",
"fingerprint_reset_active",
"fingerprint_reset_suspend",
"fingerprint_irq";
pinctrl-0 = <&chipsailing_spi_active>;
pinctrl-1 = <&fps_reset_high>;
pinctrl-2 = <&fps_reset_low>;
pinctrl-3 = <&fps_irq>;
};
};
&tlmm {
chipsailing_spi_active: chipsailing_spi_active{
mux {
pins = "gpio135", "gpio136", "gpio137", "gpio138";
function = "blsp_spi7";
};
config {
pins = "gpio135", "gpio136", "gpio137", "gpio138";
drive-strength = <2>;
bias-disable = <0>;
};
};
fps_reset_high: fps_reset_high{
mux {
pins = "gpio140";
function = "gpio";
};
config {
pins = "gpio140";
drive-strength = <2>;
bias-disable = <0>;
output-high;
};
};
fps_reset_low: fps_reset_low{
mux {
pins = "gpio140";
function = "gpio";
};
config {
pins = "gpio140";
drive-strength = <2>;
bias-disable = <0>;
output-low;
};
};
fps_irq: fps_irq {
mux {
pins = "gpio48";
function = "gpio";
};
config {
pins = "gpio48";
drive-strength = <2>;
bias-disable = <0>;
input-enable;
};
};
};
msm8953-chipsailing.dtsi 会被板级的dts msm8953-mtp.dts文件所包含,引用的形式跟C语言头文件包含差不多,如下:
#include "msm8953.dtsi"
#include "msm-pmi8950.dtsi"
#include "msm8953-mtp.dtsi"
#include "msm8953-pmi8950.dtsi"
#include "msm8953-camera-sensor-mtp.dtsi"
#include "msm8953-goodix.dtsi"
#include "msm8953-chipsailing.dtsi"
chipsailing/
├── cf_ctl.c
├── cf_ctl.h
├── Kconfig
└── Makefile
1) 将 chipsailing 目录拷贝到 kernel/drivers/input下,修改kernel/drivers/input/Makefile 添加
obj-y +=chipsailing
这是比较暴力的做法,直接将驱动强制编译进内核。如果不希望这样做,则要编译Kconfig,进行选择。
kernel/msm-3.18/drivers/input/chipsailing/Kconfig 内容如下:
config CHIPSAILING_FINGERPRINT
tristate "generic chipsailing fingerprint driver"
default n
help
add support for chipsailing fingerprint driver.
2)修改kernel/msm-3.18/drivers/input/Makefile,添加
obj-$(CONFIG_CHIPSAILING_FINGERPRINT) += chipsailing/
3)修改kernel/msm-3.18/drivers/input/Kconfig,添加
source "drivers/input/chipsailing/Kconfig"
4)修改arch/arm64/configs/msmcortex_defconfig,添加
CONFIG_CHIPSAILING_FINGERPRINT=y
5)修改arch/arm64/configs/msmcortex-perf_defconfig,添加:
CONFIG_CHIPSAILING_FINGERPRINT=y
说明:第 4) 5) 步是在对应的板级config文件中定义 CONFIG_CHIPSAILING_FINGERPRINT 这个宏,不同的平台不同的项目可能修改的文件是不一样的,需要根据对应的项目进行修改。
1、如果有多家指纹应用在此项目,并且友商已经调试好,为了避免管脚资源占用,先不要编译他们的驱动。
2、编译boot.img 烧录之后,怎么判断驱动正不正常呢?
1)查看设备结点,/dev/cs_spi 就是驱动创建的结点,正常情况下应该是存在的。
ls /dev/cs_spi
/dev/cs_spi
2)查看中断是否注册上,关键字是 cf_irq。
cat /proc/interrupts | grep cf_irq
297: 3 mt-eint 9 cf_irq
3) 查看sys结点,这里跟内核空间将中断信号上报驱动空间相关。
ls /sys/devices/platform/cs_spi/ -l
-rw-r--r-- root root 4096 2015-01-02 00:24 driver_override
-rw-rw---- root root 4096 2015-01-01 00:02 irq
-r--r--r-- root root 4096 2015-01-02 00:24 modalias
drwxr-xr-x root root 2015-01-01 00:01 power
lrwxrwxrwx root root 2015-01-02 00:24 subsystem -> ../../../bus/platform
-rw-r--r-- root root 4096 2015-01-01 00:01 uevent
3. 查看驱动的log
关键字是:chipsailing
1)查看实时的log
cat /proc/kmsg | grep chipsailing //查看驱动的log
adb shell "cat /d/tzdbg/qsee_log | grep chipsailing" //查看TA的log
2)查看 log系统保存的log文件
打开Qualcomm的日志工具 QTI Logkit,里面有保存log,这个就跟mtklog差不多。
log的路径:/data/user/0/com.qualcomm.qti.logkit/files
目录结构:
.
├── logdata
│ └── Session_02-10_0446-3444414627
│ ├── out-Bootup-kmsg0.txt.zip
│ ├── out-Bootup-logcat0.txt.zip
│ ├── out-Diag0.isf.zip
│ ├── out-Diag1.isf.zip
│ ├── out-eHLOSCommand_ContLogcatEvents0.txt.zip
│ ├── out-eHLOSCommand_ContLogcatEvents1.txt.zip
│ ├── out-eHLOSCommand_ContLogcatRadio0.txt.zip
│ ├── out-eHLOSCommand_ContLogcatRadio1.txt.zip
│ ├── out-kmesg0.txt.zip
│ ├── out-kmesg1.txt.zip
│ ├── out-kmesg2.txt.zip
│ ├── out-logcat0.txt.zip
│ ├── out-logcat1.txt.zip
│ ├── out-logcat2.txt.zip
│ ├── out-msg_hash_088e96f5-9aa6-8b9a-48fc-a74849229247.qdb.zip
│ └── Package.xml
└── temp //这个目录是我们需要的log
├── Bootup-kmsg0.txt //驱动的log 相当于mtk_log的 kernel.boot
├── Bootup-logcat0.txt //logcat看到的log 相当于mainlog.boot
├── kmesg2.txt
├── kmesg3.txt
├── kmesg8.txt
├── kmesg9.txt
├── logcat2.txt
├── logcat3.txt
├── logcat8.txt
└── logcat9.txt