Why I can't export a configured Gpio as output in the device tree ?

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

Why I can't export a configured Gpio as output in the device tree ?

跳至解决方案
1,676 次查看
LAAZIBI
Contributor II

I am using a iMX93 QS93, In the device tree I configured the gpio as an output line as you can see below

 

	gpio_pshold {
		compatible = "gpio-leds";
		pinctrl-names = "default";
		pinctrl-0 = <&pinctrl_gpiopshold>;

		power_button_pshold {
			label = "PSHOLD";
			gpios = <&gpio1 9 GPIO_ACTIVE_HIGH>;
			default-state = "off";
		};
	};

 

 And here the Pin Multiplexing configuration: 

 

	pinctrl_gpiopshold: gpiopsholdgrp {
		fsl,pins = <
			MX93_PAD_PDM_BIT_STREAM0__GPIO1_IO09		0x120
		>;
	};

 

The gpio1 9 is not used somewhere else. 

I am building my image using yocto and after the successful build, I run the image in the target and tried to export the gpio by running `echo 9 > /sys/class/gpio/export`. The export fails with the error : 

 

-bash: echo: write error: Device or resource busy

 


The `gpioinfo` shows this line under `gpiochip3 - 32lines:` 

 

        line   9:       unnamed                 output consumer=PSHOLD

 

 The output of `cat /sys/kernel/debug/gpio` shows :

 

gpiochip3: GPIOs 0-31, parent: platform/47400080.gpio, 47400080.gpio:
 gpio-0   (                    |scl                 ) out lo
 gpio-1   (                    |sda                 ) in  lo
 gpio-2   (                    |scl                 ) out lo
 gpio-3   (                    |sda                 ) in  lo
 gpio-9   (                    |PSHOLD              ) out lo

gpiochip0: GPIOs 32-63, parent: platform/43810080.gpio, 43810080.gpio:
 gpio-50  (                    |nPBOUT              ) in  hi IRQ ACTIVE LOW
 gpio-60  (                    |sda                 ) in  lo
 gpio-61  (                    |scl                 ) out lo

gpiochip1: GPIOs 64-95, parent: platform/43820080.gpio, 43820080.gpio:

gpiochip2: GPIOs 96-127, parent: platform/43830080.gpio, 43830080.gpio:

 

I am struggling find what prevent the export of that gpio and being able to set its value, could anyone help me with this issue? 

标签 (2)
标记 (2)
0 项奖励
回复
1 解答
1,645 次查看
Chavira
NXP TechSupport
NXP TechSupport

Hi @LAAZIBI!

Thank you for contacting NXP Support!

 

To use a gpios under Linux you have to use the gpioset command or configure the gpios under the driver gpio-leds in Linux.

 

To add the gpio-leds driver in Linux you can look the device tree file of the iMX8MP EVK board as a example.

 

https://github.com/nxp-imx/linux-imx/blob/lf-6.1.y/arch/arm64/boot/dts/freescale/imx8mp-evk.dts#L20

 

To control the LED in terminal using the gpio-leds driver you should use the next commands:

#Output at HIGH state
echo 1 >> /sys/class/leds/<GPIO LABEL>/brightness

#Output at LOW state
echo 0 >> /sys/class/leds/<GPIO LABEL>/brightness

 

Best Regards!

Chavira

在原帖中查看解决方案

0 项奖励
回复
1 回复
1,646 次查看
Chavira
NXP TechSupport
NXP TechSupport

Hi @LAAZIBI!

Thank you for contacting NXP Support!

 

To use a gpios under Linux you have to use the gpioset command or configure the gpios under the driver gpio-leds in Linux.

 

To add the gpio-leds driver in Linux you can look the device tree file of the iMX8MP EVK board as a example.

 

https://github.com/nxp-imx/linux-imx/blob/lf-6.1.y/arch/arm64/boot/dts/freescale/imx8mp-evk.dts#L20

 

To control the LED in terminal using the gpio-leds driver you should use the next commands:

#Output at HIGH state
echo 1 >> /sys/class/leds/<GPIO LABEL>/brightness

#Output at LOW state
echo 0 >> /sys/class/leds/<GPIO LABEL>/brightness

 

Best Regards!

Chavira

0 项奖励
回复