我正在尝试使用 spi-gpio 驱动程序设置 spidev 设备,但无法使其工作。我在设备树中创建了一个 spi-gpio 设备,如下所示:
spi4 {
compatible = "spi-gpio";
pinctrl-names = "default";
//pinctrl-0 = <&pinctrl_ecspi1_1>;
#address-cells = <0x1>;
ranges;
gpio-sck = <&gpio4 6 0>;
gpio-mosi = <&gpio3 18 0>;
gpio-miso = <&gpio3 17 0>;
num-chipselects = <1>;
status = "ok";
spidev@0x00 {
compatible = "spidev";
spi-max-frequency = <20000000>;
reg = <0>;
};
但是当我在 iMX6Q 上尝试并执行以下操作时:modprobe spi-gpio
我收到以下错误:
[ 29.830946] WARNING: at drivers/gpio/gpiolib.c:126 gpio_to_desc+0x44/0x4c()
[ 29.830954] invalid GPIO -2
[ 29.830959] Modules linked in: spi_gpio(+) usb_f_acm u_serial g_serial libcomposite xxeng [last unloaded: at25]
[ 29.831005] CPU: 3 PID: 908 Comm: modprobe Not tainted 3.10.17-p16163-Q7+gd2d3122 #1
[ 29.831014] Backtrace:
[ 29.831060] [<800128a4>] (dump_backtrace+0x0/0x110) from [<80012abc>] (show_stack+0x18/0x1c)
[ 29.831070] r6:80267514 r5:00000009 r4:d88dfbd0 r3:00000000
[ 29.831115] [<80012aa4>] (show_stack+0x0/0x1c) from [<80552a40>] (dump_stack+0x24/0x28)
[ 29.831146] [<80552a1c>] (dump_stack+0x0/0x28) from [<80026c80>] (warn_slowpath_common+0x5c/0x74)
[ 29.831166] [<80026c24>] (warn_slowpath_common+0x0/0x74) from [<80026cd0>] (warn_slowpath_fmt+0x38/0x40)
[ 29.831171] r8:00000000 r7:00000000 r6:fffffffe r5:d8436e28 r4:d871f140
r3:00000009
[ 29.831203] [<80026c98>] (warn_slowpath_fmt+0x0/0x40) from [<80267514>] (gpio_to_desc+0x44/0x4c)
[ 29.831210] r3:fffffffe r2:806858b8
[ 29.831234] [<802674d0>] (gpio_to_desc+0x0/0x4c) from [<8026886c>] (gpio_request+0x14/0x20)
[ 29.831270] [<80268858>] (gpio_request+0x0/0x20) from [<7f12f750>] (spi_gpio_setup+0x9c/0xe0 [spi_gpio])
[ 29.831282] r4:d865b000 r3:00000000
[ 29.831325] [<7f12f6b4>] (spi_gpio_setup+0x0/0xe0 [spi_gpio]) from [<80357910>] (spi_setup+0x78/0x178)
[ 29.831334] r7:00000000 r6:d819fa10 r5:d8436c00 r4:d865b000
[ 29.831369] [<80357898>] (spi_setup+0x0/0x178) from [<80357bc4>] (spi_add_device+0xbc/0x17c)
[ 29.831382] r9:d819fa10 r8:00000000 r7:00000000 r6:d819fa10 r5:d8436c00
r4:d865b000
[ 29.831432] [<80357b08>] (spi_add_device+0x0/0x17c) from [<80359178>] (spi_register_master+0x620/0x760)
[ 29.831442] r7:d865b174 r6:d865b000 r5:81e1f754 r4:d8436c00
[ 29.831478] [<80358b58>] (spi_register_master+0x0/0x760) from [<8035aa44>] (spi_bitbang_start+0xa4/0x110)
[ 29.831502] [<8035a9a0>] (spi_bitbang_start+0x0/0x110) from [<7f12fa5c>] (spi_gpio_probe+0x2c8/0x45c [spi_gpio])
[ 29.831511] r4:d8764910 r3:8035a2cc
[ 29.831553] [<7f12f794>] (spi_gpio_probe+0x0/0x45c [spi_gpio]) from [<802d84b8>] (platform_drv_probe+0x20/0x24)
[ 29.831577] [<802d8498>] (platform_drv_probe+0x0/0x24) from [<802d6ea4>] (driver_probe_device+0x140/0x384)
[ 29.831596] [<802d6d64>] (driver_probe_device+0x0/0x384) from [<802d71c8>] (__driver_attach+0x94/0x98)
[ 29.831608] r8:00000000 r7:00000000 r6:d819fa44 r5:7f12fecc r4:d819fa10
[ 29.831646] [<802d7134>] (__driver_attach+0x0/0x98) from [<802d4f34>] (bus_for_each_dev+0x68/0x9c)
[ 29.831659] r6:802d7134 r5:7f12fecc r4:00000000 r3:00000000
[ 29.831696] [<802d4ecc>] (bus_for_each_dev+0x0/0x9c) from [<802d6884>] (driver_attach+0x24/0x28)
[ 29.831709] r6:80763840 r5:d84b1c80 r4:7f12fecc
[ 29.831741] [<802d6860>] (driver_attach+0x0/0x28) from [<802d6458>] (bus_add_driver+0x1d8/0x27c)
[ 29.831753] [<802d6280>] (bus_add_driver+0x0/0x27c) from [<802d7838>] (driver_register+0x80/0x148)
[ 29.831764] r7:d88de000 r6:807870c0 r5:7f12ff18 r4:7f12fecc
[ 29.831795] [<802d77b8>] (driver_register+0x0/0x148) from [<802d8b70>] (platform_driver_register+0x58/0x60)
[ 29.831807] r8:00000000 r7:d88de000 r6:807870c0 r5:7f12ff18 r4:d88dff48
r3:00000000
[ 29.831842] [<802d8b18>] (platform_driver_register+0x0/0x60) from [<7f132014>] (spi_gpio_driver_init+0x14/0x1c [spi_gpio])
[ 29.831857] [<7f132000>] (spi_gpio_driver_init+0x0/0x1c [spi_gpio]) from [<8000867c>] (do_one_initcall+0xe0/0x18c)
[ 29.831885] [<8000859c>] (do_one_initcall+0x0/0x18c) from [<8006fcb0>] (load_module+0x1be8/0x223c)
[ 29.831911] [<8006e0c8>] (load_module+0x0/0x223c) from [<800704a4>] (SyS_finit_module+0x88/0xb8)
[ 29.831938] [<8007041c>] (SyS_finit_module+0x0/0xb8) from [<8000f080>] (ret_fast_syscall+0x0/0x30)
[ 29.831947] r6:00000000 r5:00000000 r4:00000000
[ 29.831966] ---[ end trace 689f08d95c191798 ]---
[ 29.831978] gpiod_request: invalid GPIO
[ 29.832003] spi_gpio spi4.22: can't setup spi32762.0, status -22
[ 29.838036] spi_master spi32762: spi_device register error /spi4/spidev@0x00
[ 29.846522] ------------[ cut here ]------------
[ 29.846559] WARNING: at drivers/gpio/gpiolib.c:126 gpio_to_desc+0x44/0x4c()
[ 29.846567] invalid GPIO -2
[ 29.846572] Modules linked in: spi_gpio(+) usb_f_acm u_serial g_serial libcomposite xxeng [last unloaded: at25]
[ 29.846603] CPU: 3 PID: 908 Comm: modprobe Tainted: G W 3.10.17-p16163-Q7+gd2d3122 #1
[ 29.846610] Backtrace:
[ 29.846634] [<800128a4>] (dump_backtrace+0x0/0x110) from [<80012abc>] (show_stack+0x18/0x1c)
[ 29.846640] r6:80267514 r5:00000009 r4:d88dfbb0 r3:00000000
[ 29.846663] [<80012aa4>] (show_stack+0x0/0x1c) from [<80552a40>] (dump_stack+0x24/0x28)
[ 29.846679] [<80552a1c>] (dump_stack+0x0/0x28) from [<80026c80>] (warn_slowpath_common+0x5c/0x74)
[ 29.846689] [<80026c24>] (warn_slowpath_common+0x0/0x74) from [<80026cd0>] (warn_slowpath_fmt+0x38/0x40)
[ 29.846694] r8:d865b008 r7:d871f140 r6:00000000 r5:d865b000 r4:d865b000
r3:00000009
[ 29.846716] [<80026c98>] (warn_slowpath_fmt+0x0/0x40) from [<80267514>] (gpio_to_desc+0x44/0x4c)
[ 29.846720] r3:fffffffe r2:806858b8
[ 29.846737] [<802674d0>] (gpio_to_desc+0x0/0x4c) from [<80269be8>] (gpio_free+0x10/0x18)
[ 29.846756] [<80269bd8>] (gpio_free+0x0/0x18) from [<7f12f6a8>] (spi_gpio_cleanup+0x30/0x3c [spi_gpio])
[ 29.846776] [<7f12f678>] (spi_gpio_cleanup+0x0/0x3c [spi_gpio]) from [<80357ae8>] (spidev_release+0x24/0x44)
[ 29.846781] r4:d865b000 r3:d8436c00
[ 29.846807] [<80357ac4>] (spidev_release+0x0/0x44) from [<802d2a8c>] (device_release+0x34/0x98)
[ 29.846812] r4:d865b008 r3:80357ac4
[ 29.846831] [<802d2a58>] (device_release+0x0/0x98) from [<80247938>] (kobject_release+0x9c/0x1b4)
[ 29.846836] r6:80763588 r5:d865b024 r4:8077dae0 r3:802d2a58
[ 29.846860] [<8024789c>] (kobject_release+0x0/0x1b4) from [<80247aa0>] (kobject_put+0x50/0x7c)
[ 29.846867] r8:00000000 r7:d865b174 r6:d865b000 r5:81e1f754 r4:d865b008
[ 29.846889] [<80247a50>] (kobject_put+0x0/0x7c) from [<802d2ddc>] (put_device+0x1c/0x20)
[ 29.846894] r4:d8436c00
[ 29.846914] [<802d2dc0>] (put_device+0x0/0x20) from [<8035919c>] (spi_register_master+0x644/0x760)
[ 29.846938] [<80358b58>] (spi_register_master+0x0/0x760) from [<8035aa44>] (spi_bitbang_start+0xa4/0x110)
[ 29.846959] [<8035a9a0>] (spi_bitbang_start+0x0/0x110) from [<7f12fa5c>] (spi_gpio_probe+0x2c8/0x45c [spi_gpio])
[ 29.846971] r4:d8764910 r3:8035a2cc
[ 29.847002] [<7f12f794>] (spi_gpio_probe+0x0/0x45c [spi_gpio]) from [<802d84b8>] (platform_drv_probe+0x20/0x24)
[ 29.847024] [<802d8498>] (platform_drv_probe+0x0/0x24) from [<802d6ea4>] (driver_probe_device+0x140/0x384)
[ 29.847043] [<802d6d64>] (driver_probe_device+0x0/0x384) from [<802d71c8>] (__driver_attach+0x94/0x98)
[ 29.847051] r8:00000000 r7:00000000 r6:d819fa44 r5:7f12fecc r4:d819fa10
[ 29.847082] [<802d7134>] (__driver_attach+0x0/0x98) from [<802d4f34>] (bus_for_each_dev+0x68/0x9c)
[ 29.847092] r6:802d7134 r5:7f12fecc r4:00000000 r3:00000000
[ 29.847125] [<802d4ecc>] (bus_for_each_dev+0x0/0x9c) from [<802d6884>] (driver_attach+0x24/0x28)
[ 29.847135] r6:80763840 r5:d84b1c80 r4:7f12fecc
[ 29.847152] [<802d6860>] (driver_attach+0x0/0x28) from [<802d6458>] (bus_add_driver+0x1d8/0x27c)
[ 29.847164] [<802d6280>] (bus_add_driver+0x0/0x27c) from [<802d7838>] (driver_register+0x80/0x148)
[ 29.847171] r7:d88de000 r6:807870c0 r5:7f12ff18 r4:7f12fecc
[ 29.847193] [<802d77b8>] (driver_register+0x0/0x148) from [<802d8b70>] (platform_driver_register+0x58/0x60)
[ 29.847198] r8:00000000 r7:d88de000 r6:807870c0 r5:7f12ff18 r4:d88dff48
r3:00000000
[ 29.847239] [<802d8b18>] (platform_driver_register+0x0/0x60) from [<7f132014>] (spi_gpio_driver_init+0x14/0x1c [spi_gpio])
[ 29.847260] [<7f132000>] (spi_gpio_driver_init+0x0/0x1c [spi_gpio]) from [<8000867c>] (do_one_initcall+0xe0/0x18c)
[ 29.847281] [<8000859c>] (do_one_initcall+0x0/0x18c) from [<8006fcb0>] (load_module+0x1be8/0x223c)
[ 29.847294] [<8006e0c8>] (load_module+0x0/0x223c) from [<800704a4>] (SyS_finit_module+0x88/0xb8)
[ 29.847311] [<8007041c>] (SyS_finit_module+0x0/0xb8) from [<8000f080>] (ret_fast_syscall+0x0/0x30)
[ 29.847318] r6:00000000 r5:00000000 r4:00000000
[ 29.847334] ---[ end trace 689f08d95c191799 ]---
我知道设置无效,所以我的问题是,我可以在 spi-gpio 中使用 spidev 吗?如果不是,那么可以提供用户空间驱动程序的最接近的驱动程序是什么?
或者,如果这只是一个常规错误,我该如何调试?