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,615件の閲覧回数
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? 

ラベル(2)
0 件の賞賛
1 解決策
3,595件の閲覧回数
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,596件の閲覧回数
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