GPIOIRQ(4) NetBSD Kernel Interfaces Manual GPIOIRQ(4)
NAME
gpioirq -- Install an interrupt handler on GPIO pins
SYNOPSIS
gpioirq* at gpio? offset 0 mask 0x1 flag 0x00
DESCRIPTION
The gpioirq driver attaches an interrupt handler to a one or more GPIO pins. The base pin number is specified in the kernel configuration file with the offset locator. The mask locator can be 0x01 or greater to indicate that more pins should have an interrupt handler attached to them. The flag locator specifies the interrupt mode to use: 0x01 Interrupt on the positive (rising) edge of the pin. 0x02 Interrupt on the negative (falling) edge of the pin. 0x04 Interrupt on both edges of the pin. 0x08 Assert the interrupt as long as the pin is high. 0x10 Assert the interrupt as long as the pin is low. Note that the interrupts modes are mutually-exclusive, and exactly one interrupt mode must be specified. These flags correspond to the GPIO_INTR mode bits defined in sys/gpio.h. In addition to the interrupt mode, setting 0x1000 in flags will enable the printing of a message to the console whenever the interrupt handler is called. The offset, mask, and flag locators can also be specified when gpioirq is attached at runtime using the GPIOATTACH ioctl(2) on the gpio(4) device.
FILES
/dev/gpioirqu GPIOIRQ device unit u file. The output from this device are three uint8_t bytes every time an interrupt fires. The bytes contain the device unit, pin number and the cur- rent state of the pin.
EXAMPLES
The following example will output the device unit, pin and the pins cur- rent state for pins 4, 5, 6, 7, 8, 9, 10, 11, 12 on gpio0: /etc/gpio.conf contains: gpio0 attach gpioirq 4 0x1ff 0x04 or a kernel was compiled to have the same parameters. #!/usr/pkg/bin/perl $dev = "/dev/gpioirq0"; sysopen(DEV,$dev,O_RDONLY) || die "sysopen: $!"; while (sysread(DEV,$b,3)) { @v = unpack("CCC",$b); print join(',',@v); print "\n"; }
SEE ALSO
gpio(4), drvctl(8), gpioctl(8)
HISTORY
The gpioirq driver first appeared in NetBSD 9.0.
AUTHORS
The gpioirq driver was written by Brad Spencer <brad@anduin.eldar.org>.
BUGS
When an interrupt fires in most devices there is not any information car- ried along in the interrupt as to whether or not the pin is high or low. Hence the driver reads the current state of the pin after the interrupt has fired and it is possible that the state of the pin could have changed between the time the interrupt fired and the reading of the state. As a practical matter the only time the pin state will be reported wrong is if there is a very large number of interrupts happening. The driver could have made some assumptions if the interrupt was only for a rising edge or falling edge as in those cases it would be possible to know what the pin state would have been, but in the case of the double edge, there really will not be any way to be sure with most hardware and, in any case, the gpio(4) infrastructure does not support getting at that information even if it did exist. It is important that if the gpioirq(4) device is opened that it be read, as it may be possible to run the kernel out of memory if the device is opened but not read and interrupts occur on a pin tied to the driver. NetBSD 10.99 November 5, 2023 NetBSD 10.99
Powered by man-cgi (2024-08-26). Maintained for NetBSD by Kimmo Suominen. Based on man-cgi by Panagiotis Christias.