ls1028ardb gpio control(/sys/class/gpio/export)

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

ls1028ardb gpio control(/sys/class/gpio/export)

跳至解决方案
2,096 次查看
pjw
Contributor II

Hi, I'm using ls1028ardb and Trying to control gpio.

 

It is possible to control gpio with the command below.

echo 500 > /sys/class/gpio/export

Entering the command creates the gpio500 folder.

What I want to do is to have the gpio500 folder present without having to enter a command at boot time.

So I'm modifying the dts file and I don't know how to modify it.

 

Below is the file contents of fsl-ls1028a.dtsi.

gpio1: gpio@2300000 {
compatible = "fsl,ls1028a-gpio","fsl,qoriq-gpio";
reg = <0x0 0x2300000 0x0 0x10000>;
interrupts = <GIC_SPI 36 IRQ_TYPE_LEVEL_HIGH>;
gpio-controller;
#gpio-cells = <2>;
interrupt-controller;
#interrupt-cells = <2>;
little-endian;

};

gpio2: gpio@2310000 {
compatible = "fsl,ls1028a-gpio","fsl,qoriq-gpio";
reg = <0x0 0x2310000 0x0 0x10000>;
interrupts = <GIC_SPI 36 IRQ_TYPE_LEVEL_HIGH>;
gpio-controller;
#gpio-cells = <2>;
interrupt-controller;
#interrupt-cells = <2>;
little-endian;
};

gpio3: gpio@2320000 {
compatible = "fsl,ls1028a-gpio","fsl,qoriq-gpio";
reg = <0x0 0x2320000 0x0 0x10000>;
interrupts = <GIC_SPI 37 IRQ_TYPE_LEVEL_HIGH>;
gpio-controller;
#gpio-cells = <2>;
interrupt-controller;
#interrupt-cells = <2>;
little-endian;

};

And nothing is written in the dts file.

So, as a result of inputting below, "test1" was created in /sys/firmware/devicetree/base/soc/gpio@2300000/gpio but not in /sys/class/gpio/.

 

&gpio3 {
compatible="gpio-test";
pinctrl-names="default";
pinctrl-0 = <&gpio3>;
status = "okay";

test1{
label="test1";
gpios = <&gpio3 9 0>;
default-state = "on";
};
};

 

Please let me know if it is right to modify dts file and how to modify it if right.

0 项奖励
回复
1 解答
2,077 次查看
yipingwang
NXP TechSupport
NXP TechSupport

If you need to trigger gpiolib operations from device tree at bootup itself then you will need to either have this logic in our existing driver's probe function or write your own driver. Basically you need to use API's like- gpiod_request, gpiod_export, gpiod_export_link etc in your driver.

在原帖中查看解决方案

0 项奖励
回复
1 回复
2,078 次查看
yipingwang
NXP TechSupport
NXP TechSupport

If you need to trigger gpiolib operations from device tree at bootup itself then you will need to either have this logic in our existing driver's probe function or write your own driver. Basically you need to use API's like- gpiod_request, gpiod_export, gpiod_export_link etc in your driver.

0 项奖励
回复