Zephyr API Documentation 4.2.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
Devicetree NVMEM API

Macros

#define DT_NVMEM_CELLS_HAS_IDX(node_id, idx)
 Test if a node has an nvmem-cells phandle-array property at a given index.
#define DT_NVMEM_CELLS_HAS_NAME(node_id, name)
 Test if a node has an nvmem-cell-names array property hold a given name.
#define DT_NUM_NVMEM_CELLS(node_id)
 Get the number of elements in an nvmem-cells property.
#define DT_NVMEM_CELL_BY_IDX(node_id, idx)
 Get the node identifier for the NVMEM cell from the nvmem-cells property by index.
#define DT_NVMEM_CELL(node_id)
 Equivalent to DT_NVMEM_CELL_BY_IDX(node_id, 0)
#define DT_NVMEM_CELL_BY_NAME(node_id, name)
 Get the node identifier for the NVMEM cell from the nvmem-cells property by name.
#define DT_INST_NVMEM_CELLS_HAS_IDX(inst, idx)
 Equivalent to DT_NVMEM_CELLS_HAS_IDX(DT_DRV_INST(inst), idx)
#define DT_INST_NVMEM_CELLS_HAS_NAME(inst, name)
 Equivalent to DT_NVMEM_CELLS_HAS_NAME(DT_DRV_INST(inst), name)
#define DT_INST_NUM_NVMEM_CELLS(inst)
 Equivalent to DT_NUM_NVMEM_CELLS(DT_DRV_INST(inst))
#define DT_INST_NVMEM_CELL_BY_IDX(inst, idx)
 Get the node identifier for the controller phandle from an nvmem-cells phandle-array property at an index.
#define DT_INST_NVMEM_CELL(inst)
 Equivalent to DT_INST_NVMEM_CELL_BY_IDX(inst, 0)
#define DT_INST_NVMEM_CELL_BY_NAME(inst, name)
 Get the node identifier for the controller phandle from an nvmem-cells phandle-array property by name.
#define DT_MTD_FROM_NVMEM_CELL(node_id)
 Get the node identifier of the memory controller for an nvmem cell.

Detailed Description

Macro Definition Documentation

◆ DT_INST_NUM_NVMEM_CELLS

#define DT_INST_NUM_NVMEM_CELLS ( inst)

#include <zephyr/devicetree/nvmem.h>

Value:
#define DT_DRV_INST(inst)
Node identifier for an instance of a DT_DRV_COMPAT compatible.
Definition devicetree.h:4037
#define DT_NUM_NVMEM_CELLS(node_id)
Get the number of elements in an nvmem-cells property.
Definition nvmem.h:106

Equivalent to DT_NUM_NVMEM_CELLS(DT_DRV_INST(inst))

Parameters
instinstance number
Returns
number of elements in the nvmem-cells property

◆ DT_INST_NVMEM_CELL

#define DT_INST_NVMEM_CELL ( inst)

#include <zephyr/devicetree/nvmem.h>

Value:
#define DT_INST_NVMEM_CELL_BY_IDX(inst, idx)
Get the node identifier for the controller phandle from an nvmem-cells phandle-array property at an i...
Definition nvmem.h:238

Equivalent to DT_INST_NVMEM_CELL_BY_IDX(inst, 0)

Parameters
instinstance number
Returns
a node identifier for the nvmem cell at index 0 in nvmem-cells
See also
DT_NVMEM_CELL()

◆ DT_INST_NVMEM_CELL_BY_IDX

#define DT_INST_NVMEM_CELL_BY_IDX ( inst,
idx )

#include <zephyr/devicetree/nvmem.h>

Value:
#define DT_NVMEM_CELL_BY_IDX(node_id, idx)
Get the node identifier for the NVMEM cell from the nvmem-cells property by index.
Definition nvmem.h:144

Get the node identifier for the controller phandle from an nvmem-cells phandle-array property at an index.

Parameters
instinstance number
idxlogical index into nvmem-cells
Returns
the node identifier for the nvmem cell referenced at index "idx"
See also
DT_NVMEM_CELL_CTLR_BY_IDX()

◆ DT_INST_NVMEM_CELL_BY_NAME

#define DT_INST_NVMEM_CELL_BY_NAME ( inst,
name )

#include <zephyr/devicetree/nvmem.h>

Value:
#define DT_NVMEM_CELL_BY_NAME(node_id, name)
Get the node identifier for the NVMEM cell from the nvmem-cells property by name.
Definition nvmem.h:195

Get the node identifier for the controller phandle from an nvmem-cells phandle-array property by name.

Parameters
instinstance number
namelowercase-and-underscores name of an nvmem-cells element as defined by the node's nvmem-cell-names property
Returns
the node identifier for the nvmem cell referenced by the named element
See also
DT_NVMEM_CELL_BY_NAME()

◆ DT_INST_NVMEM_CELLS_HAS_IDX

#define DT_INST_NVMEM_CELLS_HAS_IDX ( inst,
idx )

#include <zephyr/devicetree/nvmem.h>

Value:
#define DT_NVMEM_CELLS_HAS_IDX(node_id, idx)
Test if a node has an nvmem-cells phandle-array property at a given index.
Definition nvmem.h:53

Equivalent to DT_NVMEM_CELLS_HAS_IDX(DT_DRV_INST(inst), idx)

Parameters
instDT_DRV_COMPAT instance number; may or may not have any nvmem-cells property
idxindex of an nvmem-cells property phandle-array whose existence to check
Returns
1 if the index exists, 0 otherwise

◆ DT_INST_NVMEM_CELLS_HAS_NAME

#define DT_INST_NVMEM_CELLS_HAS_NAME ( inst,
name )

#include <zephyr/devicetree/nvmem.h>

Value:
#define DT_NVMEM_CELLS_HAS_NAME(node_id, name)
Test if a node has an nvmem-cell-names array property hold a given name.
Definition nvmem.h:82

Equivalent to DT_NVMEM_CELLS_HAS_NAME(DT_DRV_INST(inst), name)

Parameters
instDT_DRV_COMPAT instance number; may or may not have any nvmem-cell-names property.
namelowercase-and-underscores nvmem-cell-names cell value name to check
Returns
1 if the nvmem cell name exists, 0 otherwise

◆ DT_MTD_FROM_NVMEM_CELL

#define DT_MTD_FROM_NVMEM_CELL ( node_id)

#include <zephyr/devicetree/nvmem.h>

Value:
DT_GPARENT(node_id)
#define DT_GPARENT(node_id)
Get a node identifier for a grandparent node.
Definition devicetree.h:399

Get the node identifier of the memory controller for an nvmem cell.

Example devicetree fragment:

mac_eeprom: mac_eeprom@2 {
nvmem-layout {
compatible = "fixed-layout";
#address-cells = <1>;
#size-cells = <1>;
mac_address: mac_address@fa {
reg = <0xfa 0x06>;
#nvmem-cell-cells = <0>;
};
};
};
eth: ethernet {
nvmem-cells = <&mac_address>;
nvmem-cell-names = "mac-address";
};

Example usage:

DT_MTD_FROM_NVMEM_CELL(DT_NVMEM_CELL(DT_NODELABEL(eth))) // DT_NODELABEL(mac_eeprom)
#define DT_NODELABEL(label)
Get a node identifier for a node label.
Definition devicetree.h:196
#define DT_NVMEM_CELL(node_id)
Equivalent to DT_NVMEM_CELL_BY_IDX(node_id, 0)
Definition nvmem.h:156
#define DT_MTD_FROM_NVMEM_CELL(node_id)
Get the node identifier of the memory controller for an nvmem cell.
Definition nvmem.h:303
Parameters
node_idnode identifier for an nvmem cell node
Returns
the node identifier of the Memory Technology Device (MTD) that contains the nvmem cell node.

◆ DT_NUM_NVMEM_CELLS

#define DT_NUM_NVMEM_CELLS ( node_id)

#include <zephyr/devicetree/nvmem.h>

Value:
DT_PROP_LEN(node_id, nvmem_cells)
#define DT_PROP_LEN(node_id, prop)
Get a property's logical length.
Definition devicetree.h:796

Get the number of elements in an nvmem-cells property.

Example devicetree fragment:

eth: ethernet {
nvmem-cells = <&mac_address>;
nvmem-cell-names = "mac-address";
};

Example usage:

Parameters
node_idnode identifier with an nvmem-cells property
Returns
number of elements in the property

◆ DT_NVMEM_CELL

#define DT_NVMEM_CELL ( node_id)

#include <zephyr/devicetree/nvmem.h>

Value:

Equivalent to DT_NVMEM_CELL_BY_IDX(node_id, 0)

Parameters
node_idnode identifier
Returns
a node identifier for the NVMEM cell at index 0 in "nvmem-cells"
See also
DT_NVMEM_CELL_BY_IDX()

◆ DT_NVMEM_CELL_BY_IDX

#define DT_NVMEM_CELL_BY_IDX ( node_id,
idx )

#include <zephyr/devicetree/nvmem.h>

Value:
DT_PHANDLE_BY_IDX(node_id, nvmem_cells, idx)
#define DT_PHANDLE_BY_IDX(node_id, prop, idx)
Get a node identifier for a phandle in a property.
Definition devicetree.h:1785

Get the node identifier for the NVMEM cell from the nvmem-cells property by index.

Example devicetree fragment:

mac_eeprom: mac_eeprom@2 {
nvmem-layout {
compatible = "fixed-layout";
#address-cells = <1>;
#size-cells = <1>;
mac_address: mac_address@fa {
reg = <0xfa 0x06>;
#nvmem-cell-cells = <0>;
};
};
};
eth: ethernet {
nvmem-cells = <&mac_address>;
nvmem-cell-names = "mac-address";
};

Example usage:

DT_NVMEM_CELL_BY_IDX(DT_NODELABEL(eth), 0) // DT_NODELABEL(mac_address)
Parameters
node_idnode identifier for a node with a nvmem-cells property
idxindex into the nvmem-cells property
Returns
the node identifier for the NVMEM cell at index idx

◆ DT_NVMEM_CELL_BY_NAME

#define DT_NVMEM_CELL_BY_NAME ( node_id,
name )

#include <zephyr/devicetree/nvmem.h>

Value:
DT_PHANDLE_BY_NAME(node_id, nvmem_cells, name)
#define DT_PHANDLE_BY_NAME(node_id, pha, name)
Get a phandle's node identifier from a phandle array by name.
Definition devicetree.h:1733

Get the node identifier for the NVMEM cell from the nvmem-cells property by name.

Example devicetree fragment:

mac_eeprom: mac_eeprom@2 {
nvmem-layout {
compatible = "fixed-layout";
#address-cells = <1>;
#size-cells = <1>;
mac_address: mac_address@fa {
reg = <0xfa 0x06>;
#nvmem-cell-cells = <0>;
};
};
};
eth: ethernet {
nvmem-cells = <&mac_address>;
nvmem-cell-names = "mac-address";
};

Example usage:

DT_NVMEM_CELL_BY_NAME(DT_NODELABEL(eth), mac_address) // DT_NODELABEL(mac_address)
Parameters
node_idnode identifier for a node with a nvmem-cells property
namelowercase-and-underscores name of an nvmem-cells element as defined by the node's nvmem-cell-names property
Returns
the node identifier for the NVMEM cell by name

◆ DT_NVMEM_CELLS_HAS_IDX

#define DT_NVMEM_CELLS_HAS_IDX ( node_id,
idx )

#include <zephyr/devicetree/nvmem.h>

Value:
DT_PROP_HAS_IDX(node_id, nvmem_cells, idx)
#define DT_PROP_HAS_IDX(node_id, prop, idx)
Is index idx valid for an array type property?
Definition devicetree.h:836

Test if a node has an nvmem-cells phandle-array property at a given index.

This expands to 1 if the given index is a valid nvmem-cells property phandle-array index. Otherwise, it expands to 0.

Example devicetree fragment:

eth: ethernet {
nvmem-cells = <&mac_address>;
nvmem-cell-names = "mac-address";
};

Example usage:

Parameters
node_idnode identifier; may or may not have any nvmem-cells property
idxindex of a nvmem-cells property phandle-array whose existence to check
Returns
1 if the index exists, 0 otherwise

◆ DT_NVMEM_CELLS_HAS_NAME

#define DT_NVMEM_CELLS_HAS_NAME ( node_id,
name )

#include <zephyr/devicetree/nvmem.h>

Value:
DT_PROP_HAS_NAME(node_id, nvmem_cells, name)
#define DT_PROP_HAS_NAME(node_id, prop, name)
Is name name available in a foo-names property?
Definition devicetree.h:871

Test if a node has an nvmem-cell-names array property hold a given name.

This expands to 1 if the name is available as nvmem-cells-name array property cell. Otherwise, it expands to 0.

Example devicetree fragment:

eth: ethernet {
nvmem-cells = <&mac_address>;
nvmem-cell-names = "mac-address";
};

Example usage:

Parameters
node_idnode identifier; may or may not have any nvmem-cell-names property
namelowercase-and-underscores nvmem-cell-names cell value name to check
Returns
1 if the index exists, 0 otherwise