libre-computer-project / libretech-linux

Upstream and Mainline Linux Stable Fork for Libre Computer
https://libre.computer/
Other
50 stars 22 forks source link

gpiochip driver doesn't report falling edge transitions correctly #19

Open chrishamm opened 4 months ago

chrishamm commented 4 months ago

I've been trying to get my application running on a Le Potato AML-S905X-CC but after some debugging I found out that the gpiochip driver does not report high -> low transitions correctly.

It's easy to reproduce e.g. for pin 22 on the main header:

gpiomon /dev/gpiochip1 79
event:  RISING EDGE offset: 79 timestamp: [    1295.720182495]
event:  RISING EDGE offset: 79 timestamp: [    1295.720806423]
event:  RISING EDGE offset: 79 timestamp: [    1297.570469634]
event:  RISING EDGE offset: 79 timestamp: [    1298.608008469]
event:  RISING EDGE offset: 79 timestamp: [    1299.416658994]
event:  RISING EDGE offset: 79 timestamp: [    1301.248827348]

When I play with a standard jumper cable, I get a few FALLING EDGE reports here and there but not always between RISING EDGE messages as I'd expect.

I'm using an up-to-date Debian 12 base image from Libre Computer.

dsx724 commented 4 months ago

Can you report the kernel version you are using?

chrishamm commented 4 months ago

Yes:

Linux ender5pro 6.1.74-12781-g74961fb0a5d2 #1 SMP PREEMPT_DYNAMIC Wed Jan 24 02:05:32 EST 2024 aarch64 GNU/Linux
dsx724 commented 2 months ago

So the hardware itself is only able to handle level based interrupts. The edge based interrupts are emulated and is not very good. We are checking to see if we can improve the emulation.

For hardware expansion, we recommend writing an hardware overlay attached to the GPIO binded to a gpio-key or some other driver with level-based sensing. This is more reliable in capturing GPIO voltage changes.

chrishamm commented 2 months ago

Thanks, an improvement would be helpful. This feature works flawlessly on Raspberry Pi boards.

dsx724 commented 1 month ago

Can you let us know what you're trying to do? Like PPS or something else?