Dan
Dan

Reputation: 883

GPIOd not detecting rising edge but SYSFS implementation did

I am working to upgrade a sysfs event polling rising edge detection implementation to gpiod to make use of the kernel event timestamping.

In testing I found that the gpiod is not able to detect rising edge's on my pins for some reason. I verified this was not a usage issue by testing with gpiomon in command line. gpiomon was also not detecting rising edges, although it did detect falling edges.

I cannot figure out why the old sysfs edge detection would function normally while the gpiod would not.

Relevant info:

Device Tree is a combination of these:

and this:

&am33xx_pinmux {
    ecap0_pins_default: ecap0_pins_default {
        pinctrl-single,pins = <
            AM33XX_IOPAD(0x964, PIN_INPUT | MUX_MODE0) /* gpio0[7] */
        >;
    };
    gpio3_pins_default: gpio3_pins_default {
        pinctrl-single,pins = <
            AM33XX_IOPAD(0x99c, PIN_INPUT | MUX_MODE7) /* gpio3[17] */
        >;
    };
};

When I run gpiomon on one pin I get both rising and falling edges:

gpiomon gpiochip0 7
event:  RISING EDGE offset: 7 timestamp: [1709072918.200972377]
event: FALLING EDGE offset: 7 timestamp: [1709072918.700979793]
event:  RISING EDGE offset: 7 timestamp: [1709072919.200997043]
event: FALLING EDGE offset: 7 timestamp: [1709072919.701002002]
event:  RISING EDGE offset: 7 timestamp: [1709072920.201015460]
event: FALLING EDGE offset: 7 timestamp: [1709072920.701029335]
event:  RISING EDGE offset: 7 timestamp: [1709072921.201066377]

But When I run it on another I get only falling edges:

gpiomon gpiochip3 17
event: FALLING EDGE offset: 17 timestamp: [1709073108.897098295]
event: FALLING EDGE offset: 17 timestamp: [1709073109.897153795]
event: FALLING EDGE offset: 17 timestamp: [1709073110.897172545]
event: FALLING EDGE offset: 17 timestamp: [1709073111.897198629]
event: FALLING EDGE offset: 17 timestamp: [1709073112.897222629]
event: FALLING EDGE offset: 17 timestamp: [1709073113.897253671]

Checking /sys/kernel/debug/gpio shows that they are definitely configured as IRQs:

gpiochip0: GPIOs 0-31, parent: platform/44e07000.gpio, gpio-0-31:
gpio-7   (ECAP0_IN_PWM0_OUT   |gpiomon             ) in  hi IRQ
gpiochip3: GPIOs 96-127, parent: platform/481ae000.gpio, gpio-96-127:
gpio-113 (MCASP0_AHCLKR       |gpiomon             ) in  lo IRQ

Running a sysfs based monitor on either pin is able to detect both rising and falling edges.

I suspect this is either a kernel issue in my kernel version or a device tree issue, but I can't figure it out. The part that really throws me is that the sysfs based gpio event polling works fine on the same pins.

Note: I realize it would be great to update the kernel/package versions, but unless I can pinpoint exactly what is not working and what update will fix it, I cannot. They are being updated as a different development effort elsewhere with a different priority.

TL;DR: Why is gpiod not detecting rising edges on some pins, but it is detecting falling edges?

Upvotes: 0

Views: 424

Answers (0)

Related Questions