i.mx8qm: gpio_is_valid returns -517 error in built-in device driver

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

i.mx8qm: gpio_is_valid returns -517 error in built-in device driver

跳至解决方案
3,612 次查看
easternblack
Contributor II

Hello.

I have a problem with gpio on I.MX8mq. My Kernel version is 5.4.70.

I experienced making device drivers in I.MX6Q, and they worked well.

Recently I'm working on MCIMX8M-EVK, and made simple driver using GPIO, I omit details because it is really really simple driver using only one GPIO for the test.


I added new device node and pinmux to .dts, but gpio_is_valid() func returns -517 error. of course I get gpio information form .dtb by using of_get_gpio().

 

I know 517 error means probing GPIO should be deferred, but the only one way to make no error is compile driver to .ko module file. and it works very well in .ko

But I want to make it built-in one.

 

Is there any ideas that make GPIO works in built-in driver? 

0 项奖励
1 解答
3,592 次查看
jimmychan
NXP TechSupport
NXP TechSupport

Hello,

 

Add defer probe handler to wait GPIO driver probe.

 

For example :

https://community.nxp.com/t5/i-MX-Processors/CS-not-working-as-GPIO-just-native/m-p/1040037

 

Another example:

drivers/spi/spi-fsl-lpspi.c | 5 +++++

 1 file changed, 5 insertions(+)
diff --git a/drivers/spi/spi-fsl-lpspi.c b/drivers/spi/spi-fsl-lpspi.c
index f919fcd383f0..ae58853fcc2c 100644
--- a/drivers/spi/spi-fsl-lpspi.c
+++ b/drivers/spi/spi-fsl-lpspi.c
@@ -895,6 +895,11 @@ static int fsl_lpspi_probe(struct platform_device *pdev)
                        for (i = 0; i < controller->num_chipselect; i++) {
                                    int cs_gpio = of_get_named_gpio(np, "cs-gpios", i);

+                                  if (cs_gpio == -EPROBE_DEFER) {
+                                              ret = -EPROBE_DEFER;
+                                              goto out_controller_put;
+                                  }
+
                                    if (!gpio_is_valid(cs_gpio) && lpspi_platform_info)
                                                cs_gpio = lpspi_platform_info->chipselect[i];

 

Best regards,

Jimmy

在原帖中查看解决方案

1 回复
3,593 次查看
jimmychan
NXP TechSupport
NXP TechSupport

Hello,

 

Add defer probe handler to wait GPIO driver probe.

 

For example :

https://community.nxp.com/t5/i-MX-Processors/CS-not-working-as-GPIO-just-native/m-p/1040037

 

Another example:

drivers/spi/spi-fsl-lpspi.c | 5 +++++

 1 file changed, 5 insertions(+)
diff --git a/drivers/spi/spi-fsl-lpspi.c b/drivers/spi/spi-fsl-lpspi.c
index f919fcd383f0..ae58853fcc2c 100644
--- a/drivers/spi/spi-fsl-lpspi.c
+++ b/drivers/spi/spi-fsl-lpspi.c
@@ -895,6 +895,11 @@ static int fsl_lpspi_probe(struct platform_device *pdev)
                        for (i = 0; i < controller->num_chipselect; i++) {
                                    int cs_gpio = of_get_named_gpio(np, "cs-gpios", i);

+                                  if (cs_gpio == -EPROBE_DEFER) {
+                                              ret = -EPROBE_DEFER;
+                                              goto out_controller_put;
+                                  }
+
                                    if (!gpio_is_valid(cs_gpio) && lpspi_platform_info)
                                                cs_gpio = lpspi_platform_info->chipselect[i];

 

Best regards,

Jimmy