* How do I set user space GPIO polarity (active state) via device tree?
@ 2018-02-08 17:55 Jonas Mark (ST-FIR/ENG1)
2018-02-14 14:59 ` AW: " Jonas Mark (ST-FIR/ENG1)
0 siblings, 1 reply; 2+ messages in thread
From: Jonas Mark (ST-FIR/ENG1) @ 2018-02-08 17:55 UTC (permalink / raw)
To: linux-gpio
Cc: Jonas Mark (ST-FIR/ENG1), Heiko Schocher (hs@denx.de),
GUAN Ben (ST-FIR/ENG1-Zhu), ZHU Yi (ST-FIR/ENG1-Zhu)
Hello,
tl;dr: How do I set the polarity (active state) of a GPIO in the device
tree and use it from user space?
I have an i.MX6 based board where some GPIO lines are controlled from
user space. The access to the GPIOs is done by name using libgpio from
kernel.org. So far this works fine. In the latest revision of the board
the polarity of a GPIO was changed from active-high to active-low.
At first I thought it would be easy to store this information in the
device tree. Sadly, I cannot find the right way how to do it. What
works is to create a gpio-hog and to set the polarity there. The
unwanted side effect there is that the GPIO is hogged and thus not
accessible by user space any more.
How is that done correctly?
Why do I want to do this via the device tree? Because I do not want to
hard code this into the user land. I would like to run the same kernel
and user land on boards with different GPIO polarity.
The following is the relevant except from the device tree; the gpio5
node is created by the mainline arch/arm/boot/dts/imx6qdl.dtsi.
&gpio5 {
gpio-line-names = "", "", "", "",
"", "", "", "",
"", "", "", "",
"", "", "", "",
"", "", "RESET_COMPANION", "",
"", "", "", "",
"", "", "", "",
"", "", "", "";
reset_companion {
gpio-hog;
gpios = <18 GPIO_ACTIVE_LOW>;
output-high;
};
};
This is where the user space now sees that the GPIO is active-low -- but
it is hogged by the kernel and thus cannot be used.
# gpioinfo gpiochip4
gpiochip4 - 32 lines:
line 0: unnamed "spi_imx" output active-high [kernel]
line 1: unnamed unused input active-high
line 2: unnamed "spi_imx" output active-high [kernel]
line 3: unnamed unused input active-high
[..]
line 17: unnamed unused input active-high
line 18: "RESET_COMPANION" "reset_companion" output active-low [kernel]
line 19: unnamed unused input active-high
line 20: unnamed "watchdog" output active-high [kernel]
line 21: unnamed unused input active-high
[..]
line 31: unnamed unused input active-high
Thank you very much in advance for your help.
Regards,
Mark Jonas
Mit freundlichen Grüßen / Best regards
Mark Jonas
Security Systems, Panel Software Fire (ST-FIR/ENG1)
Bosch Sicherheitssysteme GmbH | Postfach 11 11 | 85626 Grasbrunn | GERMANY | www.bosch-sicherheitsprodukte.de
Sitz: Stuttgart, Registergericht: Amtsgericht Stuttgart HRB 23118
Aufsichtsratsvorsitzender: Stefan Hartung; Geschäftsführung: Gert van Iperen, Andreas Bartz, Thomas Quante, Bernhard Schuster
^ permalink raw reply [flat|nested] 2+ messages in thread
* AW: How do I set user space GPIO polarity (active state) via device tree?
2018-02-08 17:55 How do I set user space GPIO polarity (active state) via device tree? Jonas Mark (ST-FIR/ENG1)
@ 2018-02-14 14:59 ` Jonas Mark (ST-FIR/ENG1)
0 siblings, 0 replies; 2+ messages in thread
From: Jonas Mark (ST-FIR/ENG1) @ 2018-02-14 14:59 UTC (permalink / raw)
To: linux-gpio
Cc: Heiko Schocher (hs@denx.de), GUAN Ben (ST-FIR/ENG1-Zhu),
ZHU Yi (ST-FIR/ENG1-Zhu)
Hello,
> tl;dr: How do I set the polarity (active state) of a GPIO in the device
> tree and use it from user space?
I am still not able to declare the polarity of a GPIO via device tree
so it can be used from user space using libgpio.
I read the kernel documentation and did not find hint how to do this.
What I found is how to set the polarity of a GPIO for a gpio-hog or a
kernel driver. But that prevents the GPIO being used from user space.
Thank you in advance for your help,
Mark Jonas
Mit freundlichen Grüßen / Best regards
Mark Jonas
Security Systems, Panel Software Fire (ST-FIR/ENG1)
Bosch Sicherheitssysteme GmbH | Postfach 11 11 | 85626 Grasbrunn | GERMANY | www.bosch-sicherheitsprodukte.de
Sitz: Stuttgart, Registergericht: Amtsgericht Stuttgart HRB 23118
Aufsichtsratsvorsitzender: Stefan Hartung; Geschäftsführung: Gert van Iperen, Andreas Bartz, Thomas Quante, Bernhard Schuster
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-02-14 14:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-08 17:55 How do I set user space GPIO polarity (active state) via device tree? Jonas Mark (ST-FIR/ENG1)
2018-02-14 14:59 ` AW: " Jonas Mark (ST-FIR/ENG1)
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.