Re: intr notification when a gpio changes?
Ahmad Khalifa <[email protected]> Sun, 14 Jun 2026 18:44:13 -0700
| Newsgroups | gmane.os.freebsd.devel.arm |
|---|---|
| Message-ID | <CAMLT6uD6aMOt=Po71b__pvQ6Lzn2wPFpgkOVZ0jouKH6N2gkCg@mail.gmail.com> |
On Mon Jun 15, 2026 at 2:33 AM +0300, Bjoern A. Zeeb wrote: > On Sun, 14 Jun 2026, Ahmad Khalifa wrote: > >> On Mon Jun 15, 2026 at 2:21 AM +0300, Bjoern A. Zeeb wrote: >>> On Sun, 14 Jun 2026, Ahmad Khalifa wrote: >>> >>>> On Mon Jun 15, 2026 at 2:05 AM +0300, Sulev-Madis Silber wrote: >>>>> On June 15, 2026 1:53:11 AM GMT+03:00, Ahmad Khalifa <[email protected]> wrote: >>>>>> On Mon Jun 15, 2026 at 12:28 AM +0300, Bjoern A. Zeeb wrote: >>>>>>> Hi, >>>>>>> >>>>>>> sorry for asking here but I figured most knowledgeable people will be here. >>>>>>> >>>>>>> I need to be able from a kernel driver to get a notification if a gpio >>>>>>> pin changes. >>>>>>> >>>>>>> I believe to understand that from userspace GPIOSETCONFIG can do the job, >>>>>>> but what's in-kernel API I am looking for? >>>>>> >>>>>> You can call gpio_alloc_intr_resource to get an interrupt resource, then >>>>>> use bus_setup_intr like normal to setup an interrupt. >>>>>> >>>>>> Note that this only works on INTRNG platforms currently. There are no >>>>>> GPIO interrupts on amd64. >>>>>> >>>>>> sys/dev/gpio/gpioaei.c is a good example of setting up GPIO interrupts. >>>>>> >>>>>>> >>>>>>> /bz >>>>>> >>>>> >>>>> >>>>> let me hop on this wagon. what is the userland option to watch gpios? i'm talking about something that could run shell scripts. ot be opened as some device that outputs events >>>>> >>>>> from 10 years ago i modified someone's c example for that >>>>> >>>>> could be nice addon to gpioctl. of course if i'm blind and it's there, point me to it >>>> >>>> No way to do it with gpioctl AFAIK, but there's tools/test/gpioevents in >>>> src. >>> >>> I do not know what happened to https://wiki.freebsd.org/SummerOfCode2018Projects/UserSpaceGPIOinterrupts ? >> >> It landed as ff3468ac94597efdcbc56f372528dfc98b114dac, but gpioctl was >> never extended to use it. > > But there's the sample tools/test there too (separat repo) and that's the > interetsing bits for the "userland option to watch gpios". Hmm, it doesn't look much different to the in-tree gpioevents. Unless I'm looking at the wrong repo.