GPIO expander user space access(ie. pca9552)

Joel Stanley joel at jms.id.au
Tue Jan 31 11:24:00 AEDT 2017


On Tue, Jan 24, 2017 at 2:28 AM, Matt Barth <msbarth at linux.vnet.ibm.com> wrote:
> Is there a defined process/interface to access GPIO expanders from user
> space to be able to determine when the state changes? Possibly polling a fd
> or getting notified on the state change?

>From the GPIO documentation:

 "value" ... reads as either 0 (low) or 1 (high). If the GPIO
 is configured as an output, this value may be written;
 any nonzero value is treated as high.

 If the pin can be configured as interrupt-generating interrupt
 and if it has been configured to generate interrupts (see the
 description of "edge"), you can poll(2) on that file and
 poll(2) will return whenever the interrupt was triggered. If
 you use poll(2), set the events POLLPRI and POLLERR. If you
 use select(2), set the file descriptor in exceptfds. After
 poll(2) returns, either lseek(2) to the beginning of the sysfs
 file and read the new value or close the file and re-open it
 to read the value.

Is this what you are after?

What action do you need to take when the interrupt fires?

Cheers,

Joel

>
> Previously this was an i2c device that was accessed over i2c and the set of
> interested bits were simply read into the application. An example is the use
> of a pca9552 for presence detection on chassis fans.


More information about the openbmc mailing list