Zephyr API Documentation 4.0.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
Devicetree Port Endpoint API

Macros

#define DT_INST_PORT_BY_ID(inst, pid)
 Get a port node from its id.
 
#define DT_INST_ENDPOINT_BY_ID(inst, pid, eid)
 Get an endpoint node from its id and its parent port id.
 
#define DT_NODE_BY_ENDPOINT(ep)
 Get the device node from its endpoint node.
 
#define DT_NODE_REMOTE_DEVICE(ep)
 Get the remote device node from a local endpoint node.
 

Detailed Description

Macro Definition Documentation

◆ DT_INST_ENDPOINT_BY_ID

#define DT_INST_ENDPOINT_BY_ID ( inst,
pid,
eid )

#include <zephyr/devicetree/port-endpoint.h>

Value:
COND_CODE_1(DT_NODE_EXISTS(_DT_INST_ENDPOINT_BY_ID(inst, pid, eid)), \
(_DT_INST_ENDPOINT_BY_ID(inst, pid, eid)), \
(DT_CHILD(DT_INST_PORT_BY_ID(inst, pid), endpoint)))
#define DT_NODE_EXISTS(node_id)
Does a node identifier refer to a node?
Definition devicetree.h:3555
#define DT_CHILD(node_id, child)
Get a node identifier for a child node.
Definition devicetree.h:426
#define DT_INST_PORT_BY_ID(inst, pid)
Get a port node from its id.
Definition port-endpoint.h:87
#define COND_CODE_1(_flag, _if_1_code, _else_code)
Insert code depending on whether _flag expands to 1 or not.
Definition util_macro.h:195

Get an endpoint node from its id and its parent port id.

Given a device instance number, a port ID and an endpoint ID, return the endpoint node. It handles various ways of how a port and an endpoint could be defined as described in DT_INST_PORT_BY_ID and below.

Example usage with DT_INST_ENDPOINT_BY_ID() to get the endpoint or endpoint@0 node:

#define DT_INST_ENDPOINT_BY_ID(inst, pid, eid)
Get an endpoint node from its id and its parent port id.
Definition port-endpoint.h:163

Example devicetree fragment:

&device {
port {
endpoint {
};
};
};
&device {
port {
#address-cells = <1>;
#size-cells = <0>;
endpoint@0 {
reg = <0x0>;
};
};
};
&device {
ports {
#address-cells = <1>;
#size-cells = <0>;
port@0 {
reg = <0x0>;
#address-cells = <1>;
#size-cells = <0>;
endpoint@0 {
reg = <0x0>;
};
};
};
};
Parameters
instinstance number
pidport ID
eidendpoint ID
Returns
endpoint node associated with eid and pid

◆ DT_INST_PORT_BY_ID

#define DT_INST_PORT_BY_ID ( inst,
pid )

#include <zephyr/devicetree/port-endpoint.h>

Value:
COND_CODE_1(DT_NODE_EXISTS(_DT_INST_PORT_BY_ID(inst, pid)), \
(_DT_INST_PORT_BY_ID(inst, pid)), (DT_INST_CHILD(inst, port)))
#define DT_INST_CHILD(inst, child)
Get a node identifier for a child node of DT_DRV_INST(inst)
Definition devicetree.h:3849

Get a port node from its id.

Given a device instance number, return a port node specified by its ID. It handles various ways of how a port could be defined.

Example usage with DT_INST_PORT_BY_ID() to get the port@0 or port node:

Example devicetree fragment:

&device {
ports {
#address-cells = <1>;
#size-cells = <0>;
port@0 {
reg = <0x0>;
};
};
};
&device {
#address-cells = <1>;
#size-cells = <0>;
port@0 {
reg = <0x0>;
};
};
&device {
port {
};
};
Parameters
instinstance number
pidport ID
Returns
port node associated with pid

◆ DT_NODE_BY_ENDPOINT

#define DT_NODE_BY_ENDPOINT ( ep)

#include <zephyr/devicetree/port-endpoint.h>

Value:
#define DT_PARENT(node_id)
Get a node identifier for a parent node.
Definition devicetree.h:364
#define DT_GPARENT(node_id)
Get a node identifier for a grandparent node.
Definition devicetree.h:389

Get the device node from its endpoint node.

Given an endpoint node id, return its device node id. This handles various ways of how a port and an endpoint could be defined as described in DT_NODE_BY_ENDPOINT.

Example usage with DT_NODE_BY_ENDPOINT() to get the &device node from its ep0 node:

#define DT_NODELABEL(label)
Get a node identifier for a node label.
Definition devicetree.h:196
#define DT_NODE_BY_ENDPOINT(ep)
Get the device node from its endpoint node.
Definition port-endpoint.h:215

Example devicetree fragment:

&device {
port {
#address-cells = <1>;
#size-cells = <0>;
ep0: endpoint@0 {
reg = <0x0>;
};
};
};
&device {
ports {
#address-cells = <1>;
#size-cells = <0>;
port@0 {
reg = <0x0>;
#address-cells = <1>;
#size-cells = <0>;
ep0: endpoint@0 {
reg = <0x0>;
};
};
};
};
Parameters
ependpoint node
Returns
device node associated with ep

◆ DT_NODE_REMOTE_DEVICE

#define DT_NODE_REMOTE_DEVICE ( ep)

#include <zephyr/devicetree/port-endpoint.h>

Value:
DT_NODE_BY_ENDPOINT(DT_NODELABEL(DT_STRING_TOKEN(ep, remote_endpoint_label)))
#define DT_STRING_TOKEN(node_id, prop)
Get a string property's value as a token.
Definition devicetree.h:1106

Get the remote device node from a local endpoint node.

Given an endpoint node id, return the remote device node that connects to this device via this local endpoint. This handles various ways of how a port and an endpoint could be defined as described in DT_INST_PORT_BY_ID and DT_INST_ENDPOINT_BY_ID.

Example usage with DT_NODE_REMOTE_DEVICE() to get the remote device node &device1 from the local endpoint endpoint@0 node of the device &device0 node:

#define DT_NODE_REMOTE_DEVICE(ep)
Get the remote device node from a local endpoint node.
Definition port-endpoint.h:264

Example devicetree fragment:

&device0 {
port {
#address-cells = <1>;
#size-cells = <0>;
device0_ep_out: endpoint@0 {
reg = <0x0>;
remote-endpoint-label = "device1_ep_in";
};
};
};
&device1 {
ports {
#address-cells = <1>;
#size-cells = <0>;
port@0 {
reg = <0x0>;
device1_ep_in: endpoint {
remote-endpoint-label = "device0_ep_out";
};
};
};
};
Parameters
ependpoint node
Returns
remote device node that connects to this device via ep