Zephyr API Documentation 4.4.0-rc1
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
reg property

Macros

#define DT_NUM_REGS(node_id)
 Get the number of register blocks in the reg property.
#define DT_REG_HAS_IDX(node_id, idx)
 Is idx a valid register block index?
#define DT_REG_HAS_NAME(node_id, name)
 Is name a valid register block name?
#define DT_REG_ADDR_BY_IDX_RAW(node_id, idx)
 Get the base raw address of the register block at index idx.
#define DT_REG_ADDR_RAW(node_id)
 Get a node's (only) register block raw address.
#define DT_REG_ADDR_BY_IDX(node_id, idx)
 Get the base address of the register block at index idx.
#define DT_REG_SIZE_BY_IDX(node_id, idx)
 Get the size of the register block at index idx.
#define DT_REG_ADDR(node_id)
 Get a node's (only) register block address.
#define DT_REG_ADDR_U64(node_id)
 64-bit version of DT_REG_ADDR()
#define DT_REG_SIZE(node_id)
 Get a node's (only) register block size.
#define DT_REG_ADDR_BY_NAME(node_id, name)
 Get a register block's base address by name.
#define DT_REG_ADDR_BY_NAME_OR(node_id, name, default_value)
 Like DT_REG_ADDR_BY_NAME(), but with a fallback to default_value.
#define DT_REG_ADDR_BY_NAME_U64(node_id, name)
 64-bit version of DT_REG_ADDR_BY_NAME()
#define DT_REG_SIZE_BY_NAME(node_id, name)
 Get a register block's size by name.
#define DT_REG_SIZE_BY_NAME_OR(node_id, name, default_value)
 Like DT_REG_SIZE_BY_NAME(), but with a fallback to default_value.
#define DT_FOREACH_REG(node_id, fn)
 Invokes fn for each entry of node_id reg property.
#define DT_FOREACH_REG_SEP(node_id, fn, sep)
 Invokes fn for each entry of node_id reg property with separator.
#define DT_FOREACH_REG_VARGS(node_id, fn, ...)
 Invokes fn for each entry of node_id reg property with multiple arguments.
#define DT_FOREACH_REG_SEP_VARGS(node_id, fn, sep, ...)
 Invokes fn for each entry of node_id reg property with separator and multiple arguments.

Detailed Description

Macro Definition Documentation

◆ DT_FOREACH_REG

#define DT_FOREACH_REG ( node_id,
fn )

#include <zephyr/devicetree.h>

Value:
DT_CAT(node_id, _FOREACH_REG)(fn)

Invokes fn for each entry of node_id reg property.

The macro fn takes two parameters, node_id which will be the node identifier of the node with the reg property and idx the index of the reg array.

Example devicetree fragment:

n: node@0 {
#address-cells = <0x2>;
#size-cells = <0x2>;
reg = <0x0 0x0 0x0 0x1000>,
<0x0 0x1000 0x0 0x1000>,
<0x0 0x2000 0x0 0x1000>;
};

Example usage:

#define REG_ADDR(node_id, idx) DT_REG_ADDR_BY_IDX(node_id, idx),
#define REG_SIZE(node_id, idx) DT_REG_SIZE_BY_IDX(node_id, idx),
const uint64_t reg_addrs[] = {
};
const uint64_t reg_sizes[] = {
};
#define DT_NODELABEL(label)
Get a node identifier for a node label.
Definition devicetree.h:197
#define DT_FOREACH_REG(node_id, fn)
Invokes fn for each entry of node_id reg property.
Definition devicetree.h:2637
__UINT64_TYPE__ uint64_t
Definition stdint.h:91

This expands to:

const uint64_t reg_addrs[] = {
0x0, 0x1000, 0x2000,
};
const uint64_t reg_sizes[] = {
0x1000, 0x1000, 0x1000,
};
Parameters
node_idnode identifier
fnmacro to invoke

◆ DT_FOREACH_REG_SEP

#define DT_FOREACH_REG_SEP ( node_id,
fn,
sep )

#include <zephyr/devicetree.h>

Value:
DT_CAT(node_id, _FOREACH_REG_SEP)(fn, sep)

Invokes fn for each entry of node_id reg property with separator.

The macro fn takes two parameters, node_id which will be the node identifier of the node with the reg property and idx the index of the reg array.

Example devicetree fragment:

n: node@0 {
#address-cells = <0x2>;
#size-cells = <0x2>;
reg = <0x0 0x0 0x0 0x1000>,
<0x0 0x1000 0x0 0x1000>,
<0x0 0x2000 0x0 0x1000>;
};

Example usage:

const uint64_t reg_addrs[] = {
};
const uint64_t reg_sizes[] = {
};
#define DT_REG_SIZE_BY_IDX(node_id, idx)
Get the size of the register block at index idx.
Definition devicetree.h:2499
#define DT_REG_ADDR_BY_IDX(node_id, idx)
Get the base address of the register block at index idx.
Definition devicetree.h:2485
#define DT_FOREACH_REG_SEP(node_id, fn, sep)
Invokes fn for each entry of node_id reg property with separator.
Definition devicetree.h:2688

This expands to:

const uint64_t reg_addrs[] = {
0x0, 0x1000, 0x2000
};
const uint64_t reg_sizes[] = {
0x1000, 0x1000, 0x1000
};
Parameters
node_idnode identifier
fnmacro to invoke
sepSeparator (e.g. comma or semicolon). Must be in parentheses; this is required to enable providing a comma as separator.
See also
DT_FOREACH_REG

◆ DT_FOREACH_REG_SEP_VARGS

#define DT_FOREACH_REG_SEP_VARGS ( node_id,
fn,
sep,
... )

#include <zephyr/devicetree.h>

Value:
DT_CAT(node_id, _FOREACH_REG_SEP_VARGS)(fn, sep, __VA_ARGS__)

Invokes fn for each entry of node_id reg property with separator and multiple arguments.

The macro fn takes multiple arguments. The first one node_id will be the node identifier of the node with the reg property and idx the index of the reg array. The remaining are passed-in by the caller.

Parameters
node_idnode identifier
fnmacro to invoke
sepSeparator (e.g. comma or semicolon). Must be in parentheses; this is required to enable providing a comma as separator.
...variable number of arguments to pass to fn
See also
DT_FOREACH_REG

◆ DT_FOREACH_REG_VARGS

#define DT_FOREACH_REG_VARGS ( node_id,
fn,
... )

#include <zephyr/devicetree.h>

Value:
DT_CAT(node_id, _FOREACH_REG_VARGS)(fn, __VA_ARGS__)

Invokes fn for each entry of node_id reg property with multiple arguments.

The macro fn takes multiple arguments. The first one node_id will be the node identifier of the node with the reg property and idx the index of the reg array. The remaining are passed-in by the caller.

Parameters
node_idnode identifier
fnmacro to invoke
...variable number of arguments to pass to fn
See also
DT_FOREACH_REG

◆ DT_NUM_REGS

#define DT_NUM_REGS ( node_id)

#include <zephyr/devicetree.h>

Value:
DT_CAT(node_id, _REG_NUM)

Get the number of register blocks in the reg property.

Use this instead of DT_PROP_LEN(node_id, reg).

Parameters
node_idnode identifier
Returns
Number of register blocks in the node's "reg" property.

◆ DT_REG_ADDR

#define DT_REG_ADDR ( node_id)

#include <zephyr/devicetree.h>

Value:
DT_REG_ADDR_BY_IDX(node_id, 0)

Get a node's (only) register block address.

Equivalent to DT_REG_ADDR_BY_IDX(node_id, 0).

Parameters
node_idnode identifier
Returns
node's register block address

◆ DT_REG_ADDR_BY_IDX

#define DT_REG_ADDR_BY_IDX ( node_id,
idx )

#include <zephyr/devicetree.h>

Value:
DT_U32_C(DT_REG_ADDR_BY_IDX_RAW(node_id, idx))
#define DT_REG_ADDR_BY_IDX_RAW(node_id, idx)
Get the base raw address of the register block at index idx.
Definition devicetree.h:2462

Get the base address of the register block at index idx.

Parameters
node_idnode identifier
idxindex of the register whose address to return
Returns
address of the idx-th register block

◆ DT_REG_ADDR_BY_IDX_RAW

#define DT_REG_ADDR_BY_IDX_RAW ( node_id,
idx )

#include <zephyr/devicetree.h>

Value:
DT_CAT4(node_id, _REG_IDX_, idx, _VAL_ADDRESS)

Get the base raw address of the register block at index idx.

Get the base address of the register block at index idx without any type suffix. This can be used to index other devicetree properties, use the non _RAW macros for assigning values in actual code.

Parameters
node_idnode identifier
idxindex of the register whose address to return
Returns
address of the idx-th register block

◆ DT_REG_ADDR_BY_NAME

#define DT_REG_ADDR_BY_NAME ( node_id,
name )

#include <zephyr/devicetree.h>

Value:
DT_U32_C(DT_CAT4(node_id, _REG_NAME_, name, _VAL_ADDRESS))

Get a register block's base address by name.

Parameters
node_idnode identifier
namelowercase-and-underscores register specifier name
Returns
address of the register block specified by name

◆ DT_REG_ADDR_BY_NAME_OR

#define DT_REG_ADDR_BY_NAME_OR ( node_id,
name,
default_value )

#include <zephyr/devicetree.h>

Value:
COND_CODE_1(DT_REG_HAS_NAME(node_id, name), \
(DT_REG_ADDR_BY_NAME(node_id, name)), (default_value))
#define DT_REG_HAS_NAME(node_id, name)
Is name a valid register block name?
Definition devicetree.h:2448
#define DT_REG_ADDR_BY_NAME(node_id, name)
Get a register block's base address by name.
Definition devicetree.h:2538
#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:209

Like DT_REG_ADDR_BY_NAME(), but with a fallback to default_value.

Parameters
node_idnode identifier
namelowercase-and-underscores register specifier name
default_valuea fallback value to expand to
Returns
address of the register block specified by name if present, default_value otherwise

◆ DT_REG_ADDR_BY_NAME_U64

#define DT_REG_ADDR_BY_NAME_U64 ( node_id,
name )

#include <zephyr/devicetree.h>

Value:
DT_U64_C(DT_CAT4(node_id, _REG_NAME_, name, _VAL_ADDRESS))

64-bit version of DT_REG_ADDR_BY_NAME()

This macro version adds the appropriate suffix for 64-bit unsigned integer literals. Note that this macro is equivalent to DT_REG_ADDR_BY_NAME() in linker/ASM context.

Parameters
node_idnode identifier
namelowercase-and-underscores register specifier name
Returns
address of the register block specified by name

◆ DT_REG_ADDR_RAW

#define DT_REG_ADDR_RAW ( node_id)

#include <zephyr/devicetree.h>

Value:

Get a node's (only) register block raw address.

Get a node's only register block address without any type suffix. This can be used to index other devicetree properties, use the non _RAW macros for assigning values in actual code.

Equivalent to DT_REG_ADDR_BY_IDX_RAW(node_id, 0).

Parameters
node_idnode identifier
Returns
node's register block address

◆ DT_REG_ADDR_U64

#define DT_REG_ADDR_U64 ( node_id)

#include <zephyr/devicetree.h>

Value:
DT_U64_C(DT_REG_ADDR_BY_IDX_RAW(node_id, 0))

64-bit version of DT_REG_ADDR()

This macro version adds the appropriate suffix for 64-bit unsigned integer literals. Note that this macro is equivalent to DT_REG_ADDR() in linker/ASM context.

Parameters
node_idnode identifier
Returns
node's register block address

◆ DT_REG_HAS_IDX

#define DT_REG_HAS_IDX ( node_id,
idx )

#include <zephyr/devicetree.h>

Value:
IS_ENABLED(DT_CAT4(node_id, _REG_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 register block index?

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

Parameters
node_idnode identifier
idxindex to check
Returns
1 if idx is a valid register block index, 0 otherwise.

◆ DT_REG_HAS_NAME

#define DT_REG_HAS_NAME ( node_id,
name )

#include <zephyr/devicetree.h>

Value:
IS_ENABLED(DT_CAT4(node_id, _REG_NAME_, name, _EXISTS))

Is name a valid register block name?

If this returns 1, then DT_REG_ADDR_BY_NAME(node_id, name) or DT_REG_SIZE_BY_NAME(node_id, name) are valid. If it returns 0, it is an error to use those macros with name name.

Parameters
node_idnode identifier
namename to check
Returns
1 if name is a valid register block name, 0 otherwise.

◆ DT_REG_SIZE

#define DT_REG_SIZE ( node_id)

#include <zephyr/devicetree.h>

Value:
DT_REG_SIZE_BY_IDX(node_id, 0)

Get a node's (only) register block size.

Equivalent to DT_REG_SIZE_BY_IDX(node_id, 0).

Parameters
node_idnode identifier
Returns
node's only register block's size

◆ DT_REG_SIZE_BY_IDX

#define DT_REG_SIZE_BY_IDX ( node_id,
idx )

#include <zephyr/devicetree.h>

Value:
DT_U32_C(DT_CAT4(node_id, _REG_IDX_, idx, _VAL_SIZE))

Get the size of the register block at index idx.

This is the size of an individual register block, not the total number of register blocks in the property; use DT_NUM_REGS() for that.

Parameters
node_idnode identifier
idxindex of the register whose size to return
Returns
size of the idx-th register block

◆ DT_REG_SIZE_BY_NAME

#define DT_REG_SIZE_BY_NAME ( node_id,
name )

#include <zephyr/devicetree.h>

Value:
DT_U32_C(DT_CAT4(node_id, _REG_NAME_, name, _VAL_SIZE))

Get a register block's size by name.

Parameters
node_idnode identifier
namelowercase-and-underscores register specifier name
Returns
size of the register block specified by name

◆ DT_REG_SIZE_BY_NAME_OR

#define DT_REG_SIZE_BY_NAME_OR ( node_id,
name,
default_value )

#include <zephyr/devicetree.h>

Value:
COND_CODE_1(DT_REG_HAS_NAME(node_id, name), \
(DT_REG_SIZE_BY_NAME(node_id, name)), (default_value))
#define DT_REG_SIZE_BY_NAME(node_id, name)
Get a register block's size by name.
Definition devicetree.h:2574

Like DT_REG_SIZE_BY_NAME(), but with a fallback to default_value.

Parameters
node_idnode identifier
namelowercase-and-underscores register specifier name
default_valuea fallback value to expand to
Returns
size of the register block specified by name if present, default_value otherwise