Re: Reading current output value

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

 



On Wed, Jun 22, 2022 at 09:54:41AM +0200, Yegor Yefremov wrote:
> On a am335x based board I have a GPIO pin that enables/disables power
> of an external device (the bootloader sets this pin to output and 1,
> and the kernel is instructed to not change it). Using kernel
> 5.19.0-rc2 and sysfs interface, I can read the current status as
> follows:
> 
> echo 68 > /sys/class/gpio/export
> cat /sys/class/gpio/gpio68/value
> 
> As a result, I read 1.
> 
> Using gpioget (libgpiod) v1.6.3, the line will be configured to
> "input" and the value is set to 0:
> 
> # gpioget 2 4
> 0
> 
> So, how can I read the state without changing it? I am mostly
> interested in using the kernel userspace API directly.
> 

The API itself supports it, but it isn't exposed in gpioget v1.6.3.
The gpioget in libgpiod master has a --dir-as-is option for exactly
this case, but that hasn't made its way into a libgpiod release yet.
(commit 3a912fbc1e2 tools: gpioget: add new --dir-as-is option for GPO read-back)
Can you try master?

> By the way, setting pin to 0 works but not to 1:
> 
> gpioset 2 4=0 - OK
> gpioset 2 4=1 - no level change
> 

gpioset has to remain running to guarantee the output level.
The pin is probably reverting when gpioset exits.
Try the --mode=wait option.

> sysfs works.
> 

Yes and no.

Cheers,
Kent.



[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