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

Devicetree support for NVMEM. More...

Files

file  nvmem.h
 Public NVMEM devicetree header file.

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 holds 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)
 Get the node identifier for the NVMEM cell at index 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)
 Test if a DT_DRV_COMPAT instance has an nvmem-cells property at a given index.
#define DT_INST_NVMEM_CELLS_HAS_NAME(inst, name)
 Test if a DT_DRV_COMPAT instance has an nvmem-cell-names property with a given name.
#define DT_INST_NUM_NVMEM_CELLS(inst)
 Get the number of elements in a DT_DRV_COMPAT instance's nvmem-cells property.
#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)
 Get the node identifier for a DT_DRV_COMPAT instance's NVMEM cell at index 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

Devicetree support for NVMEM.

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:4085
#define DT_NUM_NVMEM_CELLS(node_id)
Get the number of elements in an nvmem-cells property.
Definition nvmem.h:109

Get the number of elements in a DT_DRV_COMPAT instance's nvmem-cells property.

Equivalent to DT_NUM_NVMEM_CELLS(DT_DRV_INST(inst)).

Parameters
instDT_DRV_COMPAT instance 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:249

Get the node identifier for a DT_DRV_COMPAT instance's NVMEM cell at index 0.

Equivalent to DT_INST_NVMEM_CELL_BY_IDX(inst, 0).

Parameters
instDT_DRV_COMPAT instance 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:147

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

Parameters
instDT_DRV_COMPAT instance number.
idxLogical index into nvmem-cells property.
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:200

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

Parameters
instDT_DRV_COMPAT instance 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:56

Test if a DT_DRV_COMPAT instance has an nvmem-cells property at a given index.

Equivalent to DT_NVMEM_CELLS_HAS_IDX(DT_DRV_INST(inst), idx).

Parameters
instDT_DRV_COMPAT instance number that may or may not have an 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 holds a given name.
Definition nvmem.h:85

Test if a DT_DRV_COMPAT instance has an nvmem-cell-names property with a given name.

Equivalent to DT_NVMEM_CELLS_HAS_NAME(DT_DRV_INST(inst), name).

Parameters
instDT_DRV_COMPAT instance number that may or may not have an 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:400

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:197
#define DT_NVMEM_CELL(node_id)
Get the node identifier for the NVMEM cell at index 0.
Definition nvmem.h:161
#define DT_MTD_FROM_NVMEM_CELL(node_id)
Get the node identifier of the memory controller for an nvmem cell.
Definition nvmem.h:316
Parameters
node_idNode identifier for an NVMEM cell.
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:832

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 for a node 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:

Get the node identifier for the NVMEM cell at index 0.

Equivalent to DT_NVMEM_CELL_BY_IDX(node_id, 0).

Parameters
node_idNode identifier for a node with an nvmem-cells property.
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:1833

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 an 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:1781

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 an 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:872

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 that may or may not have an nvmem-cells property.
idxIndex of an 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:907

Test if a node has an nvmem-cell-names array property holds 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 that may or may not have an nvmem-cell-names property.
nameLowercase-and-underscores nvmem-cell-names cell value name to check.
Returns
1 if the index exists, 0 otherwise.