Zephyr API Documentation 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
ranges property

Macros

#define DT_NUM_RANGES(node_id)
 Get the number of range blocks in the ranges property.
#define DT_RANGES_HAS_IDX(node_id, idx)
 Is idx a valid range block index?
#define DT_RANGES_HAS_CHILD_BUS_FLAGS_AT_IDX(node_id, idx)
 Does a ranges property have child bus flags at index?
#define DT_RANGES_CHILD_BUS_FLAGS_BY_IDX(node_id, idx)
 Get the ranges property child bus flags at index.
#define DT_RANGES_CHILD_BUS_ADDRESS_BY_IDX(node_id, idx)
 Get the ranges property child bus address at index.
#define DT_RANGES_PARENT_BUS_ADDRESS_BY_IDX(node_id, idx)
 Get the ranges property parent bus address at index.
#define DT_RANGES_LENGTH_BY_IDX(node_id, idx)
 Get the ranges property length at index.
#define DT_FOREACH_RANGE(node_id, fn)
 Invokes fn for each entry of node_id ranges property.
#define DT_DMA_RANGES_HAS_IDX(node_id, idx)
 Is idx a valid dma-range block index?
#define DT_DMA_RANGES_CHILD_BUS_ADDRESS_BY_IDX(node_id, idx)
 Get the dma-ranges property child bus address at index.
#define DT_DMA_RANGES_PARENT_BUS_ADDRESS_BY_IDX(node_id, idx)
 Get the dma-ranges property parent bus address at index.
#define DT_DMA_RANGES_LENGTH_BY_IDX(node_id, idx)
 Get the dma-ranges property length at index.
#define DT_NUM_DMA_RANGES(node_id)
 Get the number of dma-range blocks in the dma-ranges property.
#define DT_FOREACH_DMA_RANGE(node_id, fn)
 Invokes fn for each entry of node_id dma-ranges property.

Detailed Description

Macro Definition Documentation

◆ DT_DMA_RANGES_CHILD_BUS_ADDRESS_BY_IDX

#define DT_DMA_RANGES_CHILD_BUS_ADDRESS_BY_IDX ( node_id,
idx )

#include <zephyr/devicetree.h>

Value:
DT_CAT4(node_id, _DMA_RANGES_IDX_, idx, _VAL_CHILD_BUS_ADDRESS)

Get the dma-ranges property child bus address at index.

When the node is a PCIe bus, the Child Bus Address has an extra cell used to store some flags, thus this cell is removed from the Child Bus Address.

Example devicetree fragment:

parent {
#address-cells = <2>;
pcie0: pcie@0 {
compatible = "pcie-controller";
reg = <0 0 1>;
#address-cells = <3>;
#size-cells = <2>;
dma-ranges = <0x1000000 0 0 0 0x3eff0000 0 0x10000>,
<0x2000000 0 0x10000000 0 0x10000000 0 0x2eff0000>,
<0x3000000 0x80 0 0x80 0 0x80 0>;
};
other: other@1 {
reg = <0 1 1>;
dma-ranges = <0x0 0x0 0x0 0x3eff0000 0x10000>,
<0x0 0x10000000 0x0 0x10000000 0x2eff0000>;
};
};

Example usage:

#define DT_NODELABEL(label)
Get a node identifier for a node label.
Definition devicetree.h:197
#define DT_DMA_RANGES_CHILD_BUS_ADDRESS_BY_IDX(node_id, idx)
Get the dma-ranges property child bus address at index.
Definition devicetree.h:2413
Parameters
node_idnode identifier
idxlogical index into the dma-ranges array
Returns
dma-range child bus address field at idx

◆ DT_DMA_RANGES_HAS_IDX

#define DT_DMA_RANGES_HAS_IDX ( node_id,
idx )

#include <zephyr/devicetree.h>

Value:
IS_ENABLED(DT_CAT4(node_id, _DMA_RANGES_IDX_, idx, _EXISTS))
#define IS_ENABLED(config_macro)
Check for macro definition in compiler-visible expressions.
Definition util_macro.h:154

Is idx a valid dma-range block index?

If this returns 1, then DT_DMA_RANGES_CHILD_BUS_ADDRESS_BY_IDX(node_id, idx), DT_DMA_RANGES_PARENT_BUS_ADDRESS_BY_IDX(node_id, idx) or DT_DMA_RANGES_LENGTH_BY_IDX(node_id, idx) are valid. If it returns 0, it is an error to use those macros with index idx.

Example devicetree fragment:

parent {
#address-cells = <2>;
pcie0: pcie@0 {
compatible = "pcie-controller";
reg = <0 0 1>;
#address-cells = <3>;
#size-cells = <2>;
dma-ranges = <0x1000000 0 0 0 0x3eff0000 0 0x10000>,
<0x2000000 0 0x10000000 0 0x10000000 0 0x2eff0000>,
<0x3000000 0x80 0 0x80 0 0x80 0>;
};
other: other@1 {
reg = <0 1 1>;
dma-ranges = <0x0 0x0 0x0 0x3eff0000 0x10000>,
<0x0 0x10000000 0x0 0x10000000 0x2eff0000>;
};
};

Example usage:

#define DT_DMA_RANGES_HAS_IDX(node_id, idx)
Is idx a valid dma-range block index?
Definition devicetree.h:2363
Parameters
node_idnode identifier
idxlogical index into the dma-ranges array
Returns
1 if idx is a valid dma-ranges block index, 0 otherwise.

◆ DT_DMA_RANGES_LENGTH_BY_IDX

#define DT_DMA_RANGES_LENGTH_BY_IDX ( node_id,
idx )

#include <zephyr/devicetree.h>

Value:
DT_CAT4(node_id, _DMA_RANGES_IDX_, idx, _VAL_LENGTH)

Get the dma-ranges property length at index.

Similarly to DT_DMA_RANGES_CHILD_BUS_ADDRESS_BY_IDX(), this properly accounts for child bus flags cells when the node is a PCIe bus.

Example devicetree fragment:

parent {
#address-cells = <2>;
pcie0: pcie@0 {
compatible = "pcie-controller";
reg = <0 0 1>;
#address-cells = <3>;
#size-cells = <2>;
dma-ranges = <0x1000000 0 0 0 0x3eff0000 0 0x10000>,
<0x2000000 0 0x10000000 0 0x10000000 0 0x2eff0000>,
<0x3000000 0x80 0 0x80 0 0x80 0>;
};
other: other@1 {
reg = <0 1 1>;
dma-ranges = <0x0 0x0 0x0 0x3eff0000 0x10000>,
<0x0 0x10000000 0x0 0x10000000 0x2eff0000>;
};
};

Example usage:

DT_DMA_RANGES_LENGTH_BY_IDX(DT_NODELABEL(pcie0), 1) // 0x2eff0000
DT_DMA_RANGES_LENGTH_BY_IDX(DT_NODELABEL(pcie0), 2) // 0x8000000000
DT_DMA_RANGES_LENGTH_BY_IDX(DT_NODELABEL(other), 1) // 0x2eff0000
#define DT_DMA_RANGES_LENGTH_BY_IDX(node_id, idx)
Get the dma-ranges property length at index.
Definition devicetree.h:2513
Parameters
node_idnode identifier
idxlogical index into the dma-ranges array
Returns
dma-range length field at idx

◆ DT_DMA_RANGES_PARENT_BUS_ADDRESS_BY_IDX

#define DT_DMA_RANGES_PARENT_BUS_ADDRESS_BY_IDX ( node_id,
idx )

#include <zephyr/devicetree.h>

Value:
DT_CAT4(node_id, _DMA_RANGES_IDX_, idx, _VAL_PARENT_BUS_ADDRESS)

Get the dma-ranges property parent bus address at index.

Similarly to DT_DMA_RANGES_CHILD_BUS_ADDRESS_BY_IDX(), this properly accounts for child bus flags cells when the node is a PCIe bus.

Example devicetree fragment:

parent {
#address-cells = <2>;
pcie0: pcie@0 {
compatible = "pcie-controller";
reg = <0 0 1>;
#address-cells = <3>;
#size-cells = <2>;
dma-ranges = <0x1000000 0 0 0 0x3eff0000 0 0x10000>,
<0x2000000 0 0x10000000 0 0x10000000 0 0x2eff0000>,
<0x3000000 0x80 0 0x80 0 0x80 0>;
};
other: other@1 {
reg = <0 1 1>;
dma-ranges = <0x0 0x0 0x0 0x3eff0000 0x10000>,
<0x0 0x10000000 0x0 0x10000000 0x2eff0000>;
};
};

Example usage:

#define DT_DMA_RANGES_PARENT_BUS_ADDRESS_BY_IDX(node_id, idx)
Get the dma-ranges property parent bus address at index.
Definition devicetree.h:2463
Parameters
node_idnode identifier
idxlogical index into the dma-ranges array
Returns
dma-range parent bus address field at idx

◆ DT_FOREACH_DMA_RANGE

#define DT_FOREACH_DMA_RANGE ( node_id,
fn )

#include <zephyr/devicetree.h>

Value:
DT_CAT(node_id, _FOREACH_DMA_RANGE)(fn)

Invokes fn for each entry of node_id dma-ranges property.

The macro fn must take two parameters, node_id which will be the node identifier of the node with the dma-ranges property and idx the index of the dma-ranges block.

Example devicetree fragment:

parent {
#address-cells = <2>;
pcie0: pcie@0 {
compatible = "pcie-controller";
reg = <0 0 1>;
#address-cells = <3>;
#size-cells = <2>;
dma-ranges = <0x1000000 0 0 0 0x3eff0000 0 0x10000>,
<0x2000000 0 0x10000000 0 0x10000000 0 0x2eff0000>,
<0x3000000 0x80 0 0x80 0 0x80 0>;
};
other: other@1 {
reg = <0 1 1>;
dma-ranges = <0x0 0x0 0x0 0x3eff0000 0x10000>,
<0x0 0x10000000 0x0 0x10000000 0x2eff0000>;
};
};

Example usage:

#define DMA_RANGE_LENGTH(node_id, idx) DT_DMA_RANGES_LENGTH_BY_IDX(node_id, idx),
const uint64_t *dma_ranges_length[] = {
DT_FOREACH_DMA_RANGE(DT_NODELABEL(pcie0), DMA_RANGE_LENGTH)
};
#define DT_FOREACH_DMA_RANGE(node_id, fn)
Invokes fn for each entry of node_id dma-ranges property.
Definition devicetree.h:2605
__UINT64_TYPE__ uint64_t
Definition stdint.h:91
Parameters
node_idnode identifier with a dma-ranges property
fnmacro to invoke

◆ DT_FOREACH_RANGE

#define DT_FOREACH_RANGE ( node_id,
fn )

#include <zephyr/devicetree.h>

Value:
DT_CAT(node_id, _FOREACH_RANGE)(fn)

Invokes fn for each entry of node_id ranges property.

The macro fn must take two parameters, node_id which will be the node identifier of the node with the ranges property and idx the index of the ranges block.

Example devicetree fragment:

n: node@0 {
reg = <0 0 1>;
ranges = <0x0 0x0 0x0 0x3eff0000 0x10000>,
<0x0 0x10000000 0x0 0x10000000 0x2eff0000>;
};

Example usage:

#define RANGE_LENGTH(node_id, idx) DT_RANGES_LENGTH_BY_IDX(node_id, idx),
const uint64_t *ranges_length[] = {
DT_FOREACH_RANGE(DT_NODELABEL(n), RANGE_LENGTH)
};
#define DT_FOREACH_RANGE(node_id, fn)
Invokes fn for each entry of node_id ranges property.
Definition devicetree.h:2308

This expands to:

const char *ranges_length[] = {
0x10000, 0x2eff0000,
};
Parameters
node_idnode identifier
fnmacro to invoke

◆ DT_NUM_DMA_RANGES

#define DT_NUM_DMA_RANGES ( node_id)

#include <zephyr/devicetree.h>

Value:
DT_CAT(node_id, _NUM_DMA_RANGES)

Get the number of dma-range blocks in the dma-ranges property.

Use this instead of DT_PROP_LEN(node_id, dma_ranges).

Example devicetree fragment:

parent {
#address-cells = <2>;
pcie0: pcie@0 {
compatible = "pcie-controller";
reg = <0 0 1>;
#address-cells = <3>;
#size-cells = <2>;
dma-ranges = <0x1000000 0 0 0 0x3eff0000 0 0x10000>,
<0x2000000 0 0x10000000 0 0x10000000 0 0x2eff0000>,
<0x3000000 0x80 0 0x80 0 0x80 0>;
};
other: other@1 {
reg = <0 1 1>;
dma-ranges = <0x0 0x0 0x0 0x3eff0000 0x10000>,
<0x0 0x10000000 0x0 0x10000000 0x2eff0000>;
};
};

Example usage:

#define DT_NUM_DMA_RANGES(node_id)
Get the number of dma-range blocks in the dma-ranges property.
Definition devicetree.h:2557
Parameters
node_idnode identifier
Returns
Number of dma-range blocks in the dma-ranges property

◆ DT_NUM_RANGES

#define DT_NUM_RANGES ( node_id)

#include <zephyr/devicetree.h>

Value:
DT_CAT(node_id, _RANGES_NUM)

Get the number of range blocks in the ranges property.

Use this instead of DT_PROP_LEN(node_id, ranges).

Example devicetree fragment:

pcie0: pcie@0 {
compatible = "pcie-controller";
reg = <0 1>;
#address-cells = <3>;
#size-cells = <2>;
ranges = <0x1000000 0 0 0 0x3eff0000 0 0x10000>,
<0x2000000 0 0x10000000 0 0x10000000 0 0x2eff0000>,
<0x3000000 0x80 0 0x80 0 0x80 0>;
};
other: other@1 {
reg = <1 1>;
ranges = <0x0 0x0 0x0 0x3eff0000 0x10000>,
<0x0 0x10000000 0x0 0x10000000 0x2eff0000>;
};

Example usage:

#define DT_NUM_RANGES(node_id)
Get the number of range blocks in the ranges property.
Definition devicetree.h:1970
Parameters
node_idnode identifier

◆ DT_RANGES_CHILD_BUS_ADDRESS_BY_IDX

#define DT_RANGES_CHILD_BUS_ADDRESS_BY_IDX ( node_id,
idx )

#include <zephyr/devicetree.h>

Value:
DT_CAT4(node_id, _RANGES_IDX_, idx, _VAL_CHILD_BUS_ADDRESS)

Get the ranges property child bus address at index.

When the node is a PCIe bus, the Child Bus Address has an extra cell used to store some flags, thus this cell is removed from the Child Bus Address.

Example devicetree fragments:

parent {
#address-cells = <2>;
pcie0: pcie@0 {
compatible = "pcie-controller";
reg = <0 0 1>;
#address-cells = <3>;
#size-cells = <2>;
ranges = <0x1000000 0 0 0 0x3eff0000 0 0x10000>,
<0x2000000 0 0x10000000 0 0x10000000 0 0x2eff0000>,
<0x3000000 0x80 0 0x80 0 0x80 0>;
};
other: other@1 {
reg = <0 1 1>;
ranges = <0x0 0x0 0x0 0x3eff0000 0x10000>,
<0x0 0x10000000 0x0 0x10000000 0x2eff0000>;
};
};

Example usage:

#define DT_RANGES_CHILD_BUS_ADDRESS_BY_IDX(node_id, idx)
Get the ranges property child bus address at index.
Definition devicetree.h:2168
Parameters
node_idnode identifier
idxlogical index into the ranges array
Returns
range child bus address field at idx

◆ DT_RANGES_CHILD_BUS_FLAGS_BY_IDX

#define DT_RANGES_CHILD_BUS_FLAGS_BY_IDX ( node_id,
idx )

#include <zephyr/devicetree.h>

Value:
DT_CAT4(node_id, _RANGES_IDX_, idx, _VAL_CHILD_BUS_FLAGS)

Get the ranges property child bus flags at index.

When the node is a PCIe bus, the Child Bus Address has an extra cell used to store some flags, thus this cell is extracted from the Child Bus Address as Child Bus Flags field.

Example devicetree fragments:

parent {
#address-cells = <2>;
pcie0: pcie@0 {
compatible = "pcie-controller";
reg = <0 0 1>;
#address-cells = <3>;
#size-cells = <2>;
ranges = <0x1000000 0 0 0 0x3eff0000 0 0x10000>,
<0x2000000 0 0x10000000 0 0x10000000 0 0x2eff0000>,
<0x3000000 0x80 0 0x80 0 0x80 0>;
};
};

Example usage:

#define DT_RANGES_CHILD_BUS_FLAGS_BY_IDX(node_id, idx)
Get the ranges property child bus flags at index.
Definition devicetree.h:2119
Parameters
node_idnode identifier
idxlogical index into the ranges array
Returns
range child bus flags field at idx

◆ DT_RANGES_HAS_CHILD_BUS_FLAGS_AT_IDX

#define DT_RANGES_HAS_CHILD_BUS_FLAGS_AT_IDX ( node_id,
idx )

#include <zephyr/devicetree.h>

Value:
IS_ENABLED(DT_CAT4(node_id, _RANGES_IDX_, idx, _VAL_CHILD_BUS_FLAGS_EXISTS))

Does a ranges property have child bus flags at index?

If this returns 1, then DT_RANGES_CHILD_BUS_FLAGS_BY_IDX(node_id, idx) is valid. If it returns 0, it is an error to use this macro with index idx. This macro only returns 1 for PCIe buses (i.e. nodes whose bindings specify they are "pcie" bus nodes.)

Example devicetree fragment:

parent {
#address-cells = <2>;
pcie0: pcie@0 {
compatible = "pcie-controller";
reg = <0 0 1>;
#address-cells = <3>;
#size-cells = <2>;
ranges = <0x1000000 0 0 0 0x3eff0000 0 0x10000>,
<0x2000000 0 0x10000000 0 0x10000000 0 0x2eff0000>,
<0x3000000 0x80 0 0x80 0 0x80 0>;
};
other: other@1 {
reg = <0 1 1>;
ranges = <0x0 0x0 0x0 0x3eff0000 0x10000>,
<0x0 0x10000000 0x0 0x10000000 0x2eff0000>;
};
};

Example usage:

#define DT_RANGES_HAS_CHILD_BUS_FLAGS_AT_IDX(node_id, idx)
Does a ranges property have child bus flags at index?
Definition devicetree.h:2079
Parameters
node_idnode identifier
idxlogical index into the ranges array
Returns
1 if idx is a valid child bus flags index, 0 otherwise.

◆ DT_RANGES_HAS_IDX

#define DT_RANGES_HAS_IDX ( node_id,
idx )

#include <zephyr/devicetree.h>

Value:
IS_ENABLED(DT_CAT4(node_id, _RANGES_IDX_, idx, _EXISTS))

Is idx a valid range block index?

If this returns 1, then DT_RANGES_CHILD_BUS_ADDRESS_BY_IDX(node_id, idx), DT_RANGES_PARENT_BUS_ADDRESS_BY_IDX(node_id, idx) or DT_RANGES_LENGTH_BY_IDX(node_id, idx) are valid. For DT_RANGES_CHILD_BUS_FLAGS_BY_IDX(node_id, idx) the return value of DT_RANGES_HAS_CHILD_BUS_FLAGS_AT_IDX(node_id, idx) will indicate validity. If it returns 0, it is an error to use those macros with index idx, including DT_RANGES_CHILD_BUS_FLAGS_BY_IDX(node_id, idx).

Example devicetree fragment:

pcie0: pcie@0 {
compatible = "pcie-controller";
reg = <0 1>;
#address-cells = <3>;
#size-cells = <2>;
ranges = <0x1000000 0 0 0 0x3eff0000 0 0x10000>,
<0x2000000 0 0x10000000 0 0x10000000 0 0x2eff0000>,
<0x3000000 0x80 0 0x80 0 0x80 0>;
};
other: other@1 {
reg = <1 1>;
ranges = <0x0 0x0 0x0 0x3eff0000 0x10000>,
<0x0 0x10000000 0x0 0x10000000 0x2eff0000>;
};

Example usage:

#define DT_RANGES_HAS_IDX(node_id, idx)
Is idx a valid range block index?
Definition devicetree.h:2024
Parameters
node_idnode identifier
idxindex to check
Returns
1 if idx is a valid register block index, 0 otherwise.

◆ DT_RANGES_LENGTH_BY_IDX

#define DT_RANGES_LENGTH_BY_IDX ( node_id,
idx )

#include <zephyr/devicetree.h>

Value:
DT_CAT4(node_id, _RANGES_IDX_, idx, _VAL_LENGTH)

Get the ranges property length at index.

Similarly to DT_RANGES_CHILD_BUS_ADDRESS_BY_IDX(), this properly accounts for child bus flags cells when the node is a PCIe bus.

Example devicetree fragment:

parent {
#address-cells = <2>;
pcie0: pcie@0 {
compatible = "pcie-controller";
reg = <0 0 1>;
#address-cells = <3>;
#size-cells = <2>;
ranges = <0x1000000 0 0 0 0x3eff0000 0 0x10000>,
<0x2000000 0 0x10000000 0 0x10000000 0 0x2eff0000>,
<0x3000000 0x80 0 0x80 0 0x80 0>;
};
other: other@1 {
reg = <0 1 1>;
ranges = <0x0 0x0 0x0 0x3eff0000 0x10000>,
<0x0 0x10000000 0x0 0x10000000 0x2eff0000>;
};
};

Example usage:

DT_RANGES_LENGTH_BY_IDX(DT_NODELABEL(pcie0), 1) // 0x2eff0000
DT_RANGES_LENGTH_BY_IDX(DT_NODELABEL(pcie0), 2) // 0x8000000000
DT_RANGES_LENGTH_BY_IDX(DT_NODELABEL(other), 1) // 0x2eff0000
#define DT_RANGES_LENGTH_BY_IDX(node_id, idx)
Get the ranges property length at index.
Definition devicetree.h:2266
Parameters
node_idnode identifier
idxlogical index into the ranges array
Returns
range length field at idx

◆ DT_RANGES_PARENT_BUS_ADDRESS_BY_IDX

#define DT_RANGES_PARENT_BUS_ADDRESS_BY_IDX ( node_id,
idx )

#include <zephyr/devicetree.h>

Value:
DT_CAT4(node_id, _RANGES_IDX_, idx, _VAL_PARENT_BUS_ADDRESS)

Get the ranges property parent bus address at index.

Similarly to DT_RANGES_CHILD_BUS_ADDRESS_BY_IDX(), this properly accounts for child bus flags cells when the node is a PCIe bus.

Example devicetree fragment:

parent {
#address-cells = <2>;
pcie0: pcie@0 {
compatible = "pcie-controller";
reg = <0 0 1>;
#address-cells = <3>;
#size-cells = <2>;
ranges = <0x1000000 0 0 0 0x3eff0000 0 0x10000>,
<0x2000000 0 0x10000000 0 0x10000000 0 0x2eff0000>,
<0x3000000 0x80 0 0x80 0 0x80 0>;
};
other: other@1 {
reg = <0 1 1>;
ranges = <0x0 0x0 0x0 0x3eff0000 0x10000>,
<0x0 0x10000000 0x0 0x10000000 0x2eff0000>;
};
};

Example usage:

#define DT_RANGES_PARENT_BUS_ADDRESS_BY_IDX(node_id, idx)
Get the ranges property parent bus address at index.
Definition devicetree.h:2217
Parameters
node_idnode identifier
idxlogical index into the ranges array
Returns
range parent bus address field at idx