i.MX8M/8X GPIO probe failed

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

i.MX8M/8X GPIO probe failed

i.MX8M/8X GPIO probe failed

Symptoms

 

When configure a gpio pin for a driver in the dts/dtsi file like below example,

 

e.g.

 

a-switch {

           compatible = "a-switch-driver";

           pinctrl-names = "default";

           pinctrl-0 = <&pinctrl_switch>;

           gpios = <&lsio_gpio1 1 GPIO_ACTIVE_HIGH>;

           status = "okay";

};

 

pinctrl_switch: switch_gpio {
    fsl,pins = < IMX8QXP_SPI2_SDO_LSIO_GPIO1_IO01    0x21 >;
};

 

then you may get the error when request the gpio in the driver during the kernel boot up.

 

Error message like this:

a-switch: failed to request gpio

a-switch: probe of a-switch failed with error -22

 

Linux version: L5.4.x

 

Diagnosis

 

Because the gpio_mxc_init function run before the function imx_scu_driver_init. The pm_domains for gpio is not ready before running mxc_gpio_probe, so gpio request will be failed.

 

 

Solution

 

There are two ways to resolve this issue
1. Build the driver as a module. i.e. select the driver in kernel’s menuconfig as “M”. Then , run “insmod” to load the driver after the kernel boot up.

 

OR

 

2. Apply below patch, let gpio driver init after scu driver.

diff --git a/drivers/gpio/gpio-mxc.c b/drivers/gpio/gpio-mxc.c
index 1dfe513f8fcf..52b5799040b3 100644
--- a/drivers/gpio/gpio-mxc.c
+++ b/drivers/gpio/gpio-mxc.c
@@ -892,7 +892,7 @@ static int __init gpio_mxc_init(void)
return platform_driver_register(&mxc_gpio_driver);
}
-subsys_initcall(gpio_mxc_init);
+device_initcall(gpio_mxc_init);

 

%3CLINGO-SUB%20id%3D%22lingo-sub-1362335%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3Ei.MX8M%2F8X%20GPIO%20probe%20failed%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1362335%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CDIV%20class%3D%22lia-message-template-symptoms-zone%22%3E%0A%3CH2%20id%3D%22toc-hId--1353604393%22%20id%3D%22toc-hId--499286895%22%3ESymptoms%3C%2FH2%3E%0A%3CBR%20%2F%3E%0A%3CP%3EWhen%20configure%20a%20gpio%20pin%20for%20a%20driver%20in%20the%20dts%2Fdtsi%20file%20like%20below%20example%2C%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3Ee.g.%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3Ea-switch%20%7B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3Bcompatible%20%3D%20%22a-switch-driver%22%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%26nbsp%3B%26nbsp%3B%20pinctrl-names%20%3D%20%22default%22%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%26nbsp%3B%26nbsp%3B%20pinctrl-0%20%3D%20%26lt%3B%26amp%3Bpinctrl_switch%26gt%3B%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%26nbsp%3B%26nbsp%3B%20gpios%20%3D%20%26lt%3B%26amp%3Blsio_gpio1%201%20GPIO_ACTIVE_HIGH%26gt%3B%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%26nbsp%3B%26nbsp%3B%20status%20%3D%20%22okay%22%3B%3C%2FP%3E%0A%3CP%3E%7D%3B%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3Epinctrl_switch%3A%20switch_gpio%20%7B%20%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20fsl%2Cpins%20%3D%20%26lt%3B%20IMX8QXP_SPI2_SDO_LSIO_GPIO1_IO01%26nbsp%3B%26nbsp%3B%26nbsp%3B%200x21%20%26gt%3B%3B%20%3CBR%20%2F%3E%7D%3B%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3Ethen%20you%20may%20get%20the%20error%20when%20request%20the%20gpio%20in%20the%20driver%20during%20the%20kernel%20boot%20up.%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3EError%20message%20like%20this%3A%3C%2FP%3E%0A%3CP%3Ea-switch%3A%20failed%20to%20request%20gpio%3C%2FP%3E%0A%3CP%3Ea-switch%3A%20probe%20of%20a-switch%20failed%20with%20error%20-22%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3ELinux%20version%3A%20L5.4.x%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3C%2FDIV%3E%0A%3CDIV%20class%3D%22lia-message-template-diagnosis-zone%22%3E%0A%3CH2%20id%3D%22toc-hId-1133908440%22%20id%3D%22toc-hId-1988225938%22%3EDiagnosis%3C%2FH2%3E%0A%3CBR%20%2F%3E%0A%3CP%3EBecause%20the%20gpio_mxc_init%20function%20run%20before%20the%20function%20imx_scu_driver_init.%20The%20pm_domains%20for%20gpio%20is%20not%20ready%20before%20running%20mxc_gpio_probe%2C%20so%20gpio%20request%20will%20be%20failed.%3C%2FP%3E%0A%3C%2FDIV%3E%0A%3CDIV%20class%3D%22lia-message-template-solution-zone%22%3E%0A%3CH2%20id%3D%22toc-hId--673546023%22%20id%3D%22toc-hId-180771475%22%3E%26nbsp%3B%3C%2FH2%3E%0A%3CH2%20id%3D%22toc-hId-1813966810%22%20id%3D%22toc-hId--1626682988%22%3E%26nbsp%3B%3C%2FH2%3E%0A%3CH2%20id%3D%22toc-hId-6512347%22%20id%3D%22toc-hId-860829845%22%3ESolution%3C%2FH2%3E%0A%3CBR%20%2F%3E%0A%3CP%3EThere%20are%20two%20ways%20to%20resolve%20this%20issue%3CBR%20%2F%3E1.%20Build%20the%20driver%20as%20a%20module.%20i.e.%20select%20the%20driver%20in%20kernel%E2%80%99s%20menuconfig%20as%20%E2%80%9CM%E2%80%9D.%20Then%20%2C%20run%20%E2%80%9Cinsmod%E2%80%9D%20to%20load%20the%20driver%20after%20the%20kernel%20boot%20up.%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3EOR%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3E2.%20Apply%20below%20patch%2C%20let%20gpio%20driver%20init%20after%20scu%20driver.%3C%2FP%3E%0A%3CP%3Ediff%20--git%20a%2Fdrivers%2Fgpio%2Fgpio-mxc.c%20b%2Fdrivers%2Fgpio%2Fgpio-mxc.c%3CBR%20%2F%3Eindex%201dfe513f8fcf..52b5799040b3%20100644%3CBR%20%2F%3E---%20a%2Fdrivers%2Fgpio%2Fgpio-mxc.c%3CBR%20%2F%3E%2B%2B%2B%20b%2Fdrivers%2Fgpio%2Fgpio-mxc.c%3CBR%20%2F%3E%40%40%20-892%2C7%20%2B892%2C7%20%40%40%20static%20int%20__init%20gpio_mxc_init(void)%3CBR%20%2F%3Ereturn%20platform_driver_register(%26amp%3Bmxc_gpio_driver)%3B%3CBR%20%2F%3E%7D%3CBR%20%2F%3E-subsys_initcall(gpio_mxc_init)%3B%3CBR%20%2F%3E%2Bdevice_initcall(gpio_mxc_init)%3B%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1362335%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3Ei.MX%208%20Family%20%7C%20i.MX%208QuadMax%20(8QM)%20%7C%208QuadPlus%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Ei.MX%208M%20%7C%20i.MX%208M%20Mini%20%7C%20i.MX%208M%20Nano%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ELinux%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
100% helpful (2/2)
Version history
Last update:
‎10-27-2021 02:40 AM
Updated by: