Zephyr API Documentation 4.4.0
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)   DT_PROP_HAS_IDX(node_id, nvmem_cells, 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)   DT_PROP_HAS_NAME(node_id, nvmem_cells, name)
 Test if a node has an nvmem-cell-names array property holds a given name.
 
#define DT_NUM_NVMEM_CELLS(node_id)   DT_PROP_LEN(node_id, nvmem_cells)
 Get the number of elements in an nvmem-cells property.
 
#define DT_NVMEM_CELL_BY_IDX(node_id, idx)   DT_PHANDLE_BY_IDX(node_id, nvmem_cells, idx)
 Get the node identifier for the NVMEM cell from the nvmem-cells property by index.
 
#define DT_NVMEM_CELL(node_id)   DT_NVMEM_CELL_BY_IDX(node_id, 0)
 Get the node identifier for the NVMEM cell at index 0.
 
#define DT_NVMEM_CELL_BY_NAME(node_id, name)   DT_PHANDLE_BY_NAME(node_id, nvmem_cells, 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)   DT_NVMEM_CELLS_HAS_IDX(DT_DRV_INST(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)   DT_NVMEM_CELLS_HAS_NAME(DT_DRV_INST(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)   DT_NUM_NVMEM_CELLS(DT_DRV_INST(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)   DT_NVMEM_CELL_BY_IDX(DT_DRV_INST(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)   DT_INST_NVMEM_CELL_BY_IDX(inst, 0)
 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)   DT_NVMEM_CELL_BY_NAME(DT_DRV_INST(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)   DT_GPARENT(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)    DT_NUM_NVMEM_CELLS(DT_DRV_INST(inst))

#include <zephyr/devicetree/nvmem.h>

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)    DT_INST_NVMEM_CELL_BY_IDX(inst, 0)

#include <zephyr/devicetree/nvmem.h>

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 
)    DT_NVMEM_CELL_BY_IDX(DT_DRV_INST(inst), idx)

#include <zephyr/devicetree/nvmem.h>

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 
)    DT_NVMEM_CELL_BY_NAME(DT_DRV_INST(inst), name)

#include <zephyr/devicetree/nvmem.h>

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 
)    DT_NVMEM_CELLS_HAS_IDX(DT_DRV_INST(inst), idx)

#include <zephyr/devicetree/nvmem.h>

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 
)    DT_NVMEM_CELLS_HAS_NAME(DT_DRV_INST(inst), name)

#include <zephyr/devicetree/nvmem.h>

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)    DT_GPARENT(node_id)

#include <zephyr/devicetree/nvmem.h>

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)    DT_PROP_LEN(node_id, nvmem_cells)

#include <zephyr/devicetree/nvmem.h>

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:

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

#include <zephyr/devicetree/nvmem.h>

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 
)    DT_PHANDLE_BY_IDX(node_id, nvmem_cells, idx)

#include <zephyr/devicetree/nvmem.h>

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)
#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
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 
)    DT_PHANDLE_BY_NAME(node_id, nvmem_cells, name)

#include <zephyr/devicetree/nvmem.h>

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)
#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
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 
)    DT_PROP_HAS_IDX(node_id, nvmem_cells, idx)

#include <zephyr/devicetree/nvmem.h>

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:

#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
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 
)    DT_PROP_HAS_NAME(node_id, nvmem_cells, name)

#include <zephyr/devicetree/nvmem.h>

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:

DT_NVMEM_CELLS_HAS_NAME(DT_NODELABEL(eth), mac_address) // 1
#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
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.