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 06/05/19 3:27 PM, Phil Reid wrote:
> 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.


Thanks for the input.

Can the maintainers please confirm how does they want to have this implemented?

i.e How to define the polarity for generic GPIOs exported to user space in the device tree, to be able to make user space GPIO usage independent of hardware revisions?


Thanks,

Harish Jenny K N





[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