Re: [PATCH V1 1/2] gpio: make it possible to set active-state on GPIO lines

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 6/05/2019 17:15, Harish Jenny K N wrote:

On 06/05/19 2:02 PM, Linus Walleij wrote:
On Mon, May 6, 2019 at 9:57 AM Harish Jenny K N
<harish_kandiga@xxxxxxxxxx> wrote:

Can the userspace consumers define the polarity?
Yes. From userspace after opening the GPIO character
device:

#include <linux/gpio.h>

struct gpiohandle_request req;

req.flags = GPIOHANDLE_REQUEST_ACTIVE_LOW | GPIOHANDLE_REQUEST_OUTPUT;
req.lines = 1;
req.lineoffsets[0] = 0;

ret = ioctl(fd, GPIO_GET_LINEHANDLE_IOCTL, &req);
(...)

For more details on how to use the character device see tools/gpio/*
in the kernel tree.

Intention was to define polarity for lines which are not having consumers from kernelspace.
OK the above should work fine :)

Even when using GPIOs from userspace (which I do not
recommend) the character device suppors a polarity flag
GPIOLINE_FLAG_ACTIVE_LOW so also userspace
consumers define polarity.
yes. aware of the GPIOLINE_FLAG_ACTIVE_LOW flag to get the status.
Sorry, I was being unclear,
GPIOHANDLE_REQUEST_ACTIVE_LOW
is what you want to use.

Thanks. I will explore GPIOHANDLE_REQUEST_ACTIVE_LOW to see if we can use this.

Again I wanted to highlight that the intention of the patch was to make it generic and avoid changes in userspace for different hardware samples. (i.e  Some pins in hardware be configured as active low, this can vary between hardware samples. User application uses gpio-line-name property to map pins and port, this helps the application to handle pin change from hardware sample to sample. As of now there is no configuration available for user space applications for polarity.)


This is pretty useful to be able to abstract polarity (and other properties from userspace).

I was thinking of adding a virtual gpio provider for one pin that just uses the dt consumer bindings to hide
polarities etc from userspace.

Or use the gpio led driver (or similar)

--
Regards
Phil Reid





[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux