Zephyr Project API 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)   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 hold 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)
 Equivalent to DT_NVMEM_CELL_BY_IDX(node_id, 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)
 Equivalent to DT_NVMEM_CELLS_HAS_IDX(DT_DRV_INST(inst), idx)
 
#define DT_INST_NVMEM_CELLS_HAS_NAME(inst, name)   DT_NVMEM_CELLS_HAS_NAME(DT_DRV_INST(inst), name)
 Equivalent to DT_NVMEM_CELLS_HAS_NAME(DT_DRV_INST(inst), name)
 
#define DT_INST_NUM_NVMEM_CELLS(inst)   DT_NUM_NVMEM_CELLS(DT_DRV_INST(inst))
 Equivalent to DT_NUM_NVMEM_CELLS(DT_DRV_INST(inst))
 
#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)
 Equivalent to DT_INST_NVMEM_CELL_BY_IDX(inst, 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

Macro Definition Documentation

◆ DT_INST_NUM_NVMEM_CELLS

#define DT_INST_NUM_NVMEM_CELLS (   inst)    DT_NUM_NVMEM_CELLS(DT_DRV_INST(inst))

#include <include/zephyr/devicetree/nvmem.h>

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

#include <include/zephyr/devicetree/nvmem.h>

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

#include <include/zephyr/devicetree/nvmem.h>

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

#include <include/zephyr/devicetree/nvmem.h>

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

#include <include/zephyr/devicetree/nvmem.h>

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

#include <include/zephyr/devicetree/nvmem.h>

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

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

#include <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:106
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)    DT_NVMEM_CELL_BY_IDX(node_id, 0)

#include <include/zephyr/devicetree/nvmem.h>

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

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

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

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

#include <include/zephyr/devicetree/nvmem.h>

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:

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 hold a given name.
Definition nvmem.h:82
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