赞
踩
RK3588S Android12 SDK源码中kernel 版本为kernel-5.10,使用的是gf3626指纹模组。使用ree 进行spi 通讯。
指纹模组供电电压3.3V, SPI通讯电压1.8V, 最高通讯速率24M。
以此记录移植过程。
digipro@P510:~/RK3588S/android12-rkr14.1-rk3588/kernel-5.10/drivers/input$ mkdir gf3626
digipro@P510:~/RK3588S/android12-rkr14.1-rk3588/kernel-5.10/drivers/input$ ls
gameport keyboard misc sensors tablet gf3626 joystick
Makefile remotectl serio touchscreen Kconfig mouse rmi4
digipro@P510:~/RK3588S/android12-rkr14.1-rk3588/kernel-5.10/drivers/input$ vim Makefile
obj-y += gf3626/
digipro@P510:~/RK3588S/android12-rkr14.1-rk3588/kernel-5.10/drivers/input/gf3626$ ls
gf_common.c gf_common.h gf_common.o gf_platform.c gf_spi_access.c gf_spi_access.h Kconfig Makefile
digipro@P510:~/RK3588S/android12-rkr14.1-rk3588/kernel-5.10/drivers/input/gf3626$vim Makefile
obj-y += gf_common.o gf_spi_access.o gf_platform.o
从开发板外接是GPIO脚看,只有SPI0_M2可用,DTSI 添加内容如下,compatible 需要与kernel 里面的compatible 相同, 不然无法加载probe。 电源使用3.3V长供电,因此暂时不用测试电源脚。
digipro@P510:~/RK3588S/android12-rkr14.1-rk3588$ vim kernel-5.10/arch/arm64/boot/dts/rockchip/rk3588s-lubancat-4.dtsi
&spi0 { status = "okay"; #address-cells = <1>; #size-cells = <0>; pinctrl-names = "default"; pinctrl-0 = <&spi0m2_cs0 &spi0m2_pins>; //设定SPI 相关引脚 num-cs = <1>; goodix_fp@0 { compatible = "rockchip,fingerprint"; reg = <0>; //chip select 0:cs0 1:cs1 spi-max-frequency = <24000000>; //spi output clock interrupt-parent = <&gpio3>; interrupts = <RK_PD4 IRQ_TYPE_EDGE_FALLING>; irq-gpios = <&gpio3 RK_PD4 IRQ_TYPE_EDGE_FALLING>; reset-gpios = <&gpio3 RK_PD2 GPIO_ACTIVE_LOW>; }; };
//compatible
static const struct of_device_id gf_of_match[] = {
{ .compatible = "rockchip,fingerprint", },
{},
};
/*INT REST pins reference.*/ int gf_get_gpio_dts_info(struct gf_device *gf_dev) { int rc = 0; //get reset resource gf_dev->reset_gpio = of_get_named_gpio(gf_dev->spi->dev.of_node, "reset-gpios", 0); if (!gpio_is_valid(gf_dev->reset_gpio)) { gf_debug(ERR_LOG, "%s, of_get_named_gpio RESET GPIO is invalid.\n", __func__); return -1; } rc = gpio_request(gf_dev->reset_gpio, "reset-gpios"); if (rc) { gf_debug(ERR_LOG, "%s, Failed to request RESET GPIO. rc = %d\n", __func__, rc); return -1; } gpio_direction_output(gf_dev->reset_gpio, 1); //get irq resourece gf_dev->irq_gpio = of_get_named_gpio(gf_dev->spi->dev.of_node, "irq-gpios", 0); gf_debug(DEBUG_LOG, "%s, gf:irq-gpios :%d\n", __func__, gf_dev->irq_gpio); if (!gpio_is_valid(gf_dev->irq_gpio)) { gf_debug(ERR_LOG, "%s, IRQ GPIO is invalid.\n", __func__); return -1; } rc = gpio_request(gf_dev->irq_gpio, "irq-gpios"); if (rc) { gf_debug(ERR_LOG, "%s, Failed to request IRQ GPIO. rc = %d\n", __func__, rc); return -1; } gpio_direction_input(gf_dev->irq_gpio); return 0; }
static struct spi_driver gf_spi_driver = { .driver = { .name = GF_DEV_NAME, .bus = &spi_bus_type, .owner = THIS_MODULE, #ifdef CONFIG_OF .of_match_table = gf_of_match, #endif }, .probe = gf_probe, .remove = gf_remove, }; static int __init gf_init(void) { int status = 0; FUNC_ENTRY(); status = spi_register_driver(&gf_spi_driver); if (status < 0) { gf_debug(ERR_LOG, "%s, Failed to register SPI driver.\n", __func__); return -EINVAL; } FUNC_EXIT(); return status; }
老版本的kernel 的 access_ok 函数有三个参数, kernel-5.10 这个版本的access_ok 只有两个参数, 需要修改 。 不然会编译报错。
//修改前
retval = !access_ok(VERIFY_WRITE, (void __user *)arg, _IOC_SIZE(cmd));
//修改后
retval = !access_ok( (void __user *)arg, _IOC_SIZE(cmd));
编译完成后, 烧录boot 重开机后,dev下 指纹驱动设备节点goodix_fp 已生成。
rk3588s_lubancat_4_mipi600p:/dev # ls goo*
goodix_fp
probe 函数中有加spi 读取 ID 的代码。 获取到期望的数值。chip id = 0x7, 0xa0, 0x0, 0x25。
[10:37:33.169] [ 2.984206][ T1] [gf] gf_init, 1300, enter [10:37:33.169] [ 2.984245][ T1] [gf] gf_probe, 991, enter [10:37:33.169] [ 2.984250][ T1] [gf] gf_probe, Setting gf device configuration========== [10:37:33.169] [ 2.984275][ T1] [gf] gf_get_gpio_dts_info, gf:irq-gpios :124 [10:37:33.169] [ 2.984309][ T1] [gf] gf_probe, major=235, minor=0 [10:37:33.169] [ 2.984366][ T1] [gf] gf_probe, device create success. [10:37:33.169] [ 2.984372][ T1] [gf] gf_probe, Success create sysfs file. [10:37:33.169] [ 2.984416][ T1] input: gf-keys as /devices/virtual/input/input2 [10:37:33.169] [ 2.984539][ T1] [gf] gf_probe irq thread request success! [10:37:33.169] [ 2.984545][ T1] [gf] gf_disable_irq disable interrupt! [10:37:33.169] [ 2.984558][ T1] [gf] [gf_netlink_init] : netlink create success [10:37:33.169] [ 2.984768][ T1] [gf] gf_probe, chip id = 0x7, 0xa0, 0x0, 0x25 [10:37:33.169] [ 2.984772][ T1] [gf] gf_probe probe finished [10:37:33.169] [ 2.984776][ T1] version V1.2.02 [10:37:33.169] [ 2.984780][ T1] [gf] gf_probe, 1173, exit [10:37:33.169] [ 2.984801][ T1] [gf] gf_init, 1308, exit
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。