Re: intr notification when a gpio changes?

Ahmad Khalifa <[email protected]> Sun, 14 Jun 2026 18:53:11 -0400
Newsgroups gmane.os.freebsd.devel.arm
Message-ID <CAMLT6uBED2m1Vu8YU4qUtreEOZG8K4G2-9WzzSc-OwBNS_sYKw@mail.gmail.com>
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