Hi, > > Might I suggest before we go to deep down the rabbit hole that you take a > > look at the GPIO FDT bindings? > > > > > > https://github.com/devicetree-org/devicetree-source/blob/master/Bindings/gpio/gpio.txt
Looking at the bindings, there are definitions of polarity, which I need but I don't see anything about the use of the pin, apart from the naming. For example. the LEDs are all named "LED N". The attached patch provides the information that I need, but perhaps it's perfereble to encode the pin-specific information in strings? Following the FDT model, I could use: polarity="ACTIVE_LOW" name="LED activity" name="LED disk5_fault" name="INDICATOR key_diag" name="INDICATOR disk5_present" and similar, then parse that in MI code. Regards, Julian
Index: gpio.h =================================================================== RCS file: /cvsroot/src/sys/sys/gpio.h,v retrieving revision 1.16 diff -u -r1.16 gpio.h --- gpio.h 19 May 2018 13:59:06 -0000 1.16 +++ gpio.h 27 Oct 2020 11:12:47 -0000 @@ -26,6 +26,8 @@ /* GPIO pin states */ #define GPIO_PIN_LOW 0x00 /* low level (logical 0) */ #define GPIO_PIN_HIGH 0x01 /* high level (logical 1) */ +#define GPIO_ACTIVE_LOW GPIO_PIN_LOW /* pin active at logical 0 */ +#define GPIO_ACTIVE_HIGH GPIO_PIN_HIGH /* pin active at logical 1 */ /* Max name length of a pin */ #define GPIOMAXNAME 64 @@ -79,6 +81,11 @@ #define GPIO_INTR_MODE_MASK (GPIO_INTR_EDGE_MASK | \ GPIO_INTR_LEVEL_MASK) +/* GPIO pin connections that are set up in hardware */ +#define GPIO_LED 0x00000001 /* connected to LED */ +#define GPIO_INDICATOR 0x00000002 /* connected to indicator */ +#define GPIO_INTERRUPT 0x00000004 /* connected to intr src */ + /* GPIO controller description */ struct gpio_info { int gpio_npins; /* total number of pins available */