Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
Devicetree GPIO API

Macros

#define DT_GPIO_CTLR_BY_IDX(node_id, gpio_pha, idx)    DT_PHANDLE_BY_IDX(node_id, gpio_pha, idx)
 Get the node identifier for the controller phandle from a gpio phandle-array property at an index. More...
 
#define DT_GPIO_CTLR(node_id, gpio_pha)    DT_GPIO_CTLR_BY_IDX(node_id, gpio_pha, 0)
 Equivalent to DT_GPIO_CTLR_BY_IDX(node_id, gpio_pha, 0) More...
 
#define DT_GPIO_LABEL_BY_IDX(node_id, gpio_pha, idx)    DT_PROP(DT_GPIO_CTLR_BY_IDX(node_id, gpio_pha, idx), label)
 Get a label property from a gpio phandle-array property at an index. More...
 
#define DT_GPIO_LABEL(node_id, gpio_pha)    DT_GPIO_LABEL_BY_IDX(node_id, gpio_pha, 0)
 Equivalent to DT_GPIO_LABEL_BY_IDX(node_id, gpio_pha, 0) More...
 
#define DT_GPIO_PIN_BY_IDX(node_id, gpio_pha, idx)    DT_PHA_BY_IDX(node_id, gpio_pha, idx, pin)
 Get a GPIO specifier's pin cell at an index. More...
 
#define DT_GPIO_PIN(node_id, gpio_pha)    DT_GPIO_PIN_BY_IDX(node_id, gpio_pha, 0)
 Equivalent to DT_GPIO_PIN_BY_IDX(node_id, gpio_pha, 0) More...
 
#define DT_GPIO_FLAGS_BY_IDX(node_id, gpio_pha, idx)    DT_PHA_BY_IDX_OR(node_id, gpio_pha, idx, flags, 0)
 Get a GPIO specifier's flags cell at an index. More...
 
#define DT_GPIO_FLAGS(node_id, gpio_pha)    DT_GPIO_FLAGS_BY_IDX(node_id, gpio_pha, 0)
 Equivalent to DT_GPIO_FLAGS_BY_IDX(node_id, gpio_pha, 0) More...
 
#define DT_INST_GPIO_LABEL_BY_IDX(inst, gpio_pha, idx)    DT_GPIO_LABEL_BY_IDX(DT_DRV_INST(inst), gpio_pha, idx)
 Get a label property from a DT_DRV_COMPAT instance's GPIO property at an index. More...
 
#define DT_INST_GPIO_LABEL(inst, gpio_pha)    DT_INST_GPIO_LABEL_BY_IDX(inst, gpio_pha, 0)
 Equivalent to DT_INST_GPIO_LABEL_BY_IDX(inst, gpio_pha, 0) More...
 
#define DT_INST_GPIO_PIN_BY_IDX(inst, gpio_pha, idx)    DT_GPIO_PIN_BY_IDX(DT_DRV_INST(inst), gpio_pha, idx)
 Get a DT_DRV_COMPAT instance's GPIO specifier's pin cell value at an index. More...
 
#define DT_INST_GPIO_PIN(inst, gpio_pha)    DT_INST_GPIO_PIN_BY_IDX(inst, gpio_pha, 0)
 Equivalent to DT_INST_GPIO_PIN_BY_IDX(inst, gpio_pha, 0) More...
 
#define DT_INST_GPIO_FLAGS_BY_IDX(inst, gpio_pha, idx)    DT_GPIO_FLAGS_BY_IDX(DT_DRV_INST(inst), gpio_pha, idx)
 Get a DT_DRV_COMPAT instance's GPIO specifier's flags cell at an index. More...
 
#define DT_INST_GPIO_FLAGS(inst, gpio_pha)    DT_INST_GPIO_FLAGS_BY_IDX(inst, gpio_pha, 0)
 Equivalent to DT_INST_GPIO_FLAGS_BY_IDX(inst, gpio_pha, 0) More...
 

Detailed Description

Macro Definition Documentation

◆ DT_GPIO_CTLR

#define DT_GPIO_CTLR (   node_id,
  gpio_pha 
)     DT_GPIO_CTLR_BY_IDX(node_id, gpio_pha, 0)

#include <include/devicetree/gpio.h>

Equivalent to DT_GPIO_CTLR_BY_IDX(node_id, gpio_pha, 0)

Parameters
node_idnode identifier
gpio_phalowercase-and-underscores GPIO property with type "phandle-array"
Returns
a node identifier for the gpio controller at index 0 in "gpio_pha"
See also
DT_GPIO_CTLR_BY_IDX()

◆ DT_GPIO_CTLR_BY_IDX

#define DT_GPIO_CTLR_BY_IDX (   node_id,
  gpio_pha,
  idx 
)     DT_PHANDLE_BY_IDX(node_id, gpio_pha, idx)

#include <include/devicetree/gpio.h>

Get the node identifier for the controller phandle from a gpio phandle-array property at an index.

Example devicetree fragment:

gpio1: gpio@... { };

gpio2: gpio@... { };

n: node {
        gpios = <&gpio1 10 GPIO_ACTIVE_LOW>,
                <&gpio2 30 GPIO_ACTIVE_HIGH>;
};

Example usage:

DT_GPIO_CTLR_BY_IDX(DT_NODELABEL(n), gpios, 1) // DT_NODELABEL(gpio2)
Parameters
node_idnode identifier
gpio_phalowercase-and-underscores GPIO property with type "phandle-array"
idxlogical index into "gpio_pha"
Returns
the node identifier for the gpio controller referenced at index "idx"
See also
DT_PHANDLE_BY_IDX()

◆ DT_GPIO_FLAGS

#define DT_GPIO_FLAGS (   node_id,
  gpio_pha 
)     DT_GPIO_FLAGS_BY_IDX(node_id, gpio_pha, 0)

#include <include/devicetree/gpio.h>

Equivalent to DT_GPIO_FLAGS_BY_IDX(node_id, gpio_pha, 0)

Parameters
node_idnode identifier
gpio_phalowercase-and-underscores GPIO property with type "phandle-array"
Returns
the flags cell value at index 0, or zero if there is none
See also
DT_GPIO_FLAGS_BY_IDX()

◆ DT_GPIO_FLAGS_BY_IDX

#define DT_GPIO_FLAGS_BY_IDX (   node_id,
  gpio_pha,
  idx 
)     DT_PHA_BY_IDX_OR(node_id, gpio_pha, idx, flags, 0)

#include <include/devicetree/gpio.h>

Get a GPIO specifier's flags cell at an index.

This macro expects GPIO specifiers with cells named "flags". If there is no "flags" cell in the GPIO specifier, zero is returned. Refer to the node's binding to check specifier cell names if necessary.

Example devicetree fragment:

gpio1: gpio@... {
        compatible = "vnd,gpio";
        #gpio-cells = <2>;
};

gpio2: gpio@... {
        compatible = "vnd,gpio";
        #gpio-cells = <2>;
};

n: node {
        gpios = <&gpio1 10 GPIO_ACTIVE_LOW>,
                <&gpio2 30 GPIO_ACTIVE_HIGH>;
};

Bindings fragment for the vnd,gpio compatible:

gpio-cells:
  - pin
  - flags

Example usage:

DT_GPIO_FLAGS_BY_IDX(DT_NODELABEL(n), gpios, 0) // GPIO_ACTIVE_LOW
DT_GPIO_FLAGS_BY_IDX(DT_NODELABEL(n), gpios, 1) // GPIO_ACTIVE_HIGH
Parameters
node_idnode identifier
gpio_phalowercase-and-underscores GPIO property with type "phandle-array"
idxlogical index into "gpio_pha"
Returns
the flags cell value at index "idx", or zero if there is none
See also
DT_PHA_BY_IDX()

◆ DT_GPIO_LABEL

#define DT_GPIO_LABEL (   node_id,
  gpio_pha 
)     DT_GPIO_LABEL_BY_IDX(node_id, gpio_pha, 0)

#include <include/devicetree/gpio.h>

Equivalent to DT_GPIO_LABEL_BY_IDX(node_id, gpio_pha, 0)

Parameters
node_idnode identifier
gpio_phalowercase-and-underscores GPIO property with type "phandle-array"
Returns
the label property of the node referenced at index 0
See also
DT_GPIO_LABEL_BY_IDX()

◆ DT_GPIO_LABEL_BY_IDX

#define DT_GPIO_LABEL_BY_IDX (   node_id,
  gpio_pha,
  idx 
)     DT_PROP(DT_GPIO_CTLR_BY_IDX(node_id, gpio_pha, idx), label)

#include <include/devicetree/gpio.h>

Get a label property from a gpio phandle-array property at an index.

It's an error if the GPIO controller node referenced by the phandle in node_id's "gpio_pha" property at index "idx" has no label property.

Example devicetree fragment:

gpio1: gpio@... {
        label = "GPIO_1";
};

gpio2: gpio@... {
        label = "GPIO_2";
};

n: node {
        gpios = <&gpio1 10 GPIO_ACTIVE_LOW>,
                <&gpio2 30 GPIO_ACTIVE_HIGH>;
};

Example usage:

DT_GPIO_LABEL_BY_IDX(DT_NODELABEL(n), gpios, 1) // "GPIO_2"
Parameters
node_idnode identifier
gpio_phalowercase-and-underscores GPIO property with type "phandle-array"
idxlogical index into "gpio_pha"
Returns
the label property of the node referenced at index "idx"
See also
DT_PHANDLE_BY_IDX()

◆ DT_GPIO_PIN

#define DT_GPIO_PIN (   node_id,
  gpio_pha 
)     DT_GPIO_PIN_BY_IDX(node_id, gpio_pha, 0)

#include <include/devicetree/gpio.h>

Equivalent to DT_GPIO_PIN_BY_IDX(node_id, gpio_pha, 0)

Parameters
node_idnode identifier
gpio_phalowercase-and-underscores GPIO property with type "phandle-array"
Returns
the pin cell value at index 0
See also
DT_GPIO_PIN_BY_IDX()

◆ DT_GPIO_PIN_BY_IDX

#define DT_GPIO_PIN_BY_IDX (   node_id,
  gpio_pha,
  idx 
)     DT_PHA_BY_IDX(node_id, gpio_pha, idx, pin)

#include <include/devicetree/gpio.h>

Get a GPIO specifier's pin cell at an index.

This macro only works for GPIO specifiers with cells named "pin". Refer to the node's binding to check if necessary.

Example devicetree fragment:

gpio1: gpio@... {
        compatible = "vnd,gpio";
        #gpio-cells = <2>;
};

gpio2: gpio@... {
        compatible = "vnd,gpio";
        #gpio-cells = <2>;
};

n: node {
        gpios = <&gpio1 10 GPIO_ACTIVE_LOW>,
                <&gpio2 30 GPIO_ACTIVE_HIGH>;
};

Bindings fragment for the vnd,gpio compatible:

gpio-cells:
  - pin
  - flags

Example usage:

DT_GPIO_PIN_BY_IDX(DT_NODELABEL(n), gpios, 0) // 10
DT_GPIO_PIN_BY_IDX(DT_NODELABEL(n), gpios, 1) // 30
Parameters
node_idnode identifier
gpio_phalowercase-and-underscores GPIO property with type "phandle-array"
idxlogical index into "gpio_pha"
Returns
the pin cell value at index "idx"
See also
DT_PHA_BY_IDX()

◆ DT_INST_GPIO_FLAGS

#define DT_INST_GPIO_FLAGS (   inst,
  gpio_pha 
)     DT_INST_GPIO_FLAGS_BY_IDX(inst, gpio_pha, 0)

#include <include/devicetree/gpio.h>

Equivalent to DT_INST_GPIO_FLAGS_BY_IDX(inst, gpio_pha, 0)

Parameters
instDT_DRV_COMPAT instance number
gpio_phalowercase-and-underscores GPIO property with type "phandle-array"
Returns
the flags cell value at index 0, or zero if there is none
See also
DT_INST_GPIO_FLAGS_BY_IDX()

◆ DT_INST_GPIO_FLAGS_BY_IDX

#define DT_INST_GPIO_FLAGS_BY_IDX (   inst,
  gpio_pha,
  idx 
)     DT_GPIO_FLAGS_BY_IDX(DT_DRV_INST(inst), gpio_pha, idx)

#include <include/devicetree/gpio.h>

Get a DT_DRV_COMPAT instance's GPIO specifier's flags cell at an index.

Parameters
instDT_DRV_COMPAT instance number
gpio_phalowercase-and-underscores GPIO property with type "phandle-array"
idxlogical index into "gpio_pha"
Returns
the flags cell value at index "idx", or zero if there is none
See also
DT_GPIO_FLAGS_BY_IDX()

◆ DT_INST_GPIO_LABEL

#define DT_INST_GPIO_LABEL (   inst,
  gpio_pha 
)     DT_INST_GPIO_LABEL_BY_IDX(inst, gpio_pha, 0)

#include <include/devicetree/gpio.h>

Equivalent to DT_INST_GPIO_LABEL_BY_IDX(inst, gpio_pha, 0)

Parameters
instDT_DRV_COMPAT instance number
gpio_phalowercase-and-underscores GPIO property with type "phandle-array"
Returns
the label property of the node referenced at index 0

◆ DT_INST_GPIO_LABEL_BY_IDX

#define DT_INST_GPIO_LABEL_BY_IDX (   inst,
  gpio_pha,
  idx 
)     DT_GPIO_LABEL_BY_IDX(DT_DRV_INST(inst), gpio_pha, idx)

#include <include/devicetree/gpio.h>

Get a label property from a DT_DRV_COMPAT instance's GPIO property at an index.

Parameters
instDT_DRV_COMPAT instance number
gpio_phalowercase-and-underscores GPIO property with type "phandle-array"
idxlogical index into "gpio_pha"
Returns
the label property of the node referenced at index "idx"

◆ DT_INST_GPIO_PIN

#define DT_INST_GPIO_PIN (   inst,
  gpio_pha 
)     DT_INST_GPIO_PIN_BY_IDX(inst, gpio_pha, 0)

#include <include/devicetree/gpio.h>

Equivalent to DT_INST_GPIO_PIN_BY_IDX(inst, gpio_pha, 0)

Parameters
instDT_DRV_COMPAT instance number
gpio_phalowercase-and-underscores GPIO property with type "phandle-array"
Returns
the pin cell value at index 0
See also
DT_INST_GPIO_PIN_BY_IDX()

◆ DT_INST_GPIO_PIN_BY_IDX

#define DT_INST_GPIO_PIN_BY_IDX (   inst,
  gpio_pha,
  idx 
)     DT_GPIO_PIN_BY_IDX(DT_DRV_INST(inst), gpio_pha, idx)

#include <include/devicetree/gpio.h>

Get a DT_DRV_COMPAT instance's GPIO specifier's pin cell value at an index.

Parameters
instDT_DRV_COMPAT instance number
gpio_phalowercase-and-underscores GPIO property with type "phandle-array"
idxlogical index into "gpio_pha"
Returns
the pin cell value at index "idx"
See also
DT_GPIO_PIN_BY_IDX()