Re: Regarding export of GPIOs

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

 



On Fri, Aug 20, 2021 at 05:04:03PM +0300, Andy Shevchenko wrote:
> On Fri, Aug 20, 2021 at 6:27 AM Riz <mdrizwan827@xxxxxxxxx> wrote:
> >
> > Hello,
> > I have some basic questions around the exporting of a GPIO.
> >
> > 1. Regarding gpio-hog mechanism:
> > The gpio-hog mechanism would help us to initialise a GPIO to either
> > high/low & in/out during bootup.
> > This is fine.
> >
> > So my question is, if we hog a GPIO, does it also gets exported to the
> > userspace by default?
> >
> >
> > 2. With the older sysfs interface, we would be using "echo x >
> > /sys/class/gpio/export" to export the gpiox to userspace.
> >
> > I wanted to know what would be the right way to do this with the newer
> > interface?
> >
> > 3. To check if a GPIO is being exported or not, we would see the
> > /sys/class/gpio with the sysfs interface.
> >
> > With the newer character device interface, what would be the right way
> > to check what GPIOs are exported to userspace?
> >
> > Looking forward to hearing from you
> 
> https://stackoverflow.com/questions/68856801/regarding-gpio-export ?
> 
> I think I pretty much answered there.
> 

Continuing that thread and in response to your  comment:

> I agree with you. Even I looked into the kernel code, it sets the right
> direction of the hogged GPIO. I suspect this could be some issue with
> gpioinfo tool. I hog a GPIO as below
>
> pX { gpio-hog; gpios = < X 0 >; output-high; };
>
> The gpinfo reveals following info about the GPIO:
>
> line 13: "p.X" "some_name" input active-high [used]
>
> It shows it as [used] but the direction still says input
> 

I doubt that gpioinfo is the problem - it merely reports the flags
returned by the kernel and is known to correctly decode the flags for
lines requested using the GPIO API.
You could confirm that by comparing the output of lsgpio or the
libgpiod equivalent tools in my Go library[1].
You could also use strace to decode the GPIO ioctls with:

strace --trace=ioctl gpioinfo

That requires strace 5.11 or later.

If any of those demonstrate that the output flag is not being set then
the problem would appear to lie on the kernel side.

Cheers,
Kent.

[1] https://github.com/warthog618/gpiod




[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