Zephyr Project API 3.7.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
MSPI Devicetree related macros

MSPI Devicetree related macros. More...

Macros

#define MSPI_DEVICE_CONFIG_DT(mspi_dev)
 Structure initializer for struct mspi_dev_cfg from devicetree.
 
#define MSPI_DEVICE_CONFIG_DT_INST(inst)   MSPI_DEVICE_CONFIG_DT(DT_DRV_INST(inst))
 Structure initializer for struct mspi_dev_cfg from devicetree instance.
 
#define MSPI_XIP_CONFIG_DT_NO_CHECK(mspi_dev)
 Structure initializer for struct mspi_xip_cfg from devicetree.
 
#define MSPI_XIP_CONFIG_DT(mspi_dev)
 Structure initializer for struct mspi_xip_cfg from devicetree.
 
#define MSPI_XIP_CONFIG_DT_INST(inst)   MSPI_XIP_CONFIG_DT(DT_DRV_INST(inst))
 Structure initializer for struct mspi_xip_cfg from devicetree instance.
 
#define MSPI_SCRAMBLE_CONFIG_DT_NO_CHECK(mspi_dev)
 Structure initializer for struct mspi_scramble_cfg from devicetree.
 
#define MSPI_SCRAMBLE_CONFIG_DT(mspi_dev)
 Structure initializer for struct mspi_scramble_cfg from devicetree.
 
#define MSPI_SCRAMBLE_CONFIG_DT_INST(inst)   MSPI_SCRAMBLE_CONFIG_DT(DT_DRV_INST(inst))
 Structure initializer for struct mspi_scramble_cfg from devicetree instance.
 
#define MSPI_DEVICE_ID_DT(mspi_dev)
 Structure initializer for struct mspi_dev_id from devicetree.
 
#define MSPI_DEVICE_ID_DT_INST(inst)   MSPI_DEVICE_ID_DT(DT_DRV_INST(inst))
 Structure initializer for struct mspi_dev_id from devicetree instance.
 
#define MSPI_DEV_CE_GPIOS_DT_SPEC_GET(mspi_dev)    GPIO_DT_SPEC_GET_BY_IDX_OR(DT_BUS(mspi_dev), ce_gpios, DT_REG_ADDR(mspi_dev), {})
 Get a struct gpio_dt_spec for a MSPI device's chip enable pin.
 
#define MSPI_DEV_CE_GPIOS_DT_SPEC_INST_GET(inst)    MSPI_DEV_CE_GPIOS_DT_SPEC_GET(DT_DRV_INST(inst))
 Get a struct gpio_dt_spec for a MSPI device's chip enable pin.
 
#define MSPI_CE_GPIOS_DT_SPEC_GET(node_id)
 Get an array of struct gpio_dt_spec from devicetree for a MSPI controller.
 
#define MSPI_CE_GPIOS_DT_SPEC_INST_GET(inst)    MSPI_CE_GPIOS_DT_SPEC_GET(DT_DRV_INST(inst))
 Get an array of struct gpio_dt_spec for a MSPI controller.
 
#define MSPI_CE_CONTROL_INIT(node_id, delay_)
 Initialize and get a pointer to a mspi_ce_control from a devicetree node identifier.
 
#define MSPI_CE_CONTROL_INIT_INST(inst, delay_)   MSPI_CE_CONTROL_INIT(DT_DRV_INST(inst), delay_)
 Get a pointer to a mspi_ce_control from a devicetree node.
 

Detailed Description

MSPI Devicetree related macros.

Macro Definition Documentation

◆ MSPI_CE_CONTROL_INIT

#define MSPI_CE_CONTROL_INIT (   node_id,
  delay_ 
)

#include <include/zephyr/drivers/mspi/devicetree.h>

Value:
{ \
.gpio = MSPI_DEV_CE_GPIOS_DT_SPEC_GET(node_id), .delay = (delay_), \
}
#define MSPI_DEV_CE_GPIOS_DT_SPEC_GET(mspi_dev)
Get a struct gpio_dt_spec for a MSPI device's chip enable pin.
Definition devicetree.h:214

Initialize and get a pointer to a mspi_ce_control from a devicetree node identifier.

This helper is useful for initializing a device on a MSPI bus. It initializes a struct mspi_ce_control and returns a pointer to it. Here, node_id is a node identifier for a MSPI device, not a MSPI controller.

Example devicetree fragment:

mspi@abcd0001 {
ce-gpios = <&gpio0 1 GPIO_ACTIVE_LOW>;
mspidev: mspi-device@0 { ... };
};

Example usage:

struct mspi_ce_control ctrl =
#define DT_NODELABEL(label)
Get a node identifier for a node label.
Definition devicetree.h:200
#define MSPI_CE_CONTROL_INIT(node_id, delay_)
Initialize and get a pointer to a mspi_ce_control from a devicetree node identifier.
Definition devicetree.h:297
MSPI Chip Select control structure.
Definition mspi.h:345

This example is equivalent to:

struct mspi_ce_control ctrl = {
.delay = 2,
};
struct gpio_dt_spec gpio
GPIO devicetree specification of CE GPIO.
Definition mspi.h:352
Parameters
node_idDevicetree node identifier for a device on a MSPI bus
delay_The delay field to set in the mspi_ce_control
Returns
a pointer to the mspi_ce_control structure

◆ MSPI_CE_CONTROL_INIT_INST

#define MSPI_CE_CONTROL_INIT_INST (   inst,
  delay_ 
)    MSPI_CE_CONTROL_INIT(DT_DRV_INST(inst), delay_)

#include <include/zephyr/drivers/mspi/devicetree.h>

Get a pointer to a mspi_ce_control from a devicetree node.

This is equivalent to MSPI_CE_CONTROL_INIT(DT_DRV_INST(inst), delay).

Therefore, DT_DRV_COMPAT must already be defined before using this macro.

Parameters
instDevicetree node instance number
delay_The delay field to set in the mspi_ce_control
Returns
a pointer to the mspi_ce_control structure

◆ MSPI_CE_GPIOS_DT_SPEC_GET

#define MSPI_CE_GPIOS_DT_SPEC_GET (   node_id)

#include <include/zephyr/drivers/mspi/devicetree.h>

Value:
{ \
COND_CODE_1(DT_NODE_HAS_PROP(node_id, ce_gpios), \
(DT_FOREACH_PROP_ELEM_SEP(node_id, ce_gpios, GPIO_DT_SPEC_GET_BY_IDX, (,))), \
()) \
}
#define DT_NODE_HAS_PROP(node_id, prop)
Does a devicetree node have a property?
Definition devicetree.h:3479
#define DT_FOREACH_PROP_ELEM_SEP(node_id, prop, fn, sep)
Invokes fn for each element in the value of property prop with separator.
Definition devicetree.h:3103
#define GPIO_DT_SPEC_GET_BY_IDX(node_id, prop, idx)
Static initializer for a gpio_dt_spec.
Definition gpio.h:331

Get an array of struct gpio_dt_spec from devicetree for a MSPI controller.

This helper macro check whether ce_gpios binding exist first before calling GPIO_DT_SPEC_GET_BY_IDX and expand to an array of gpio_dt_spec.

Parameters
node_idDevicetree node identifier for the MSPI controller
Returns
an array of gpio_dt_spec struct corresponding with mspi_dev's chip enables

◆ MSPI_CE_GPIOS_DT_SPEC_INST_GET

#define MSPI_CE_GPIOS_DT_SPEC_INST_GET (   inst)     MSPI_CE_GPIOS_DT_SPEC_GET(DT_DRV_INST(inst))

#include <include/zephyr/drivers/mspi/devicetree.h>

Get an array of struct gpio_dt_spec for a MSPI controller.

This is equivalent to MSPI_CE_GPIOS_DT_SPEC_GET(DT_DRV_INST(inst)).

Parameters
instDevicetree instance number
Returns
an array of gpio_dt_spec struct corresponding with mspi_dev's chip enables

◆ MSPI_DEV_CE_GPIOS_DT_SPEC_GET

#define MSPI_DEV_CE_GPIOS_DT_SPEC_GET (   mspi_dev)     GPIO_DT_SPEC_GET_BY_IDX_OR(DT_BUS(mspi_dev), ce_gpios, DT_REG_ADDR(mspi_dev), {})

#include <include/zephyr/drivers/mspi/devicetree.h>

Get a struct gpio_dt_spec for a MSPI device's chip enable pin.

Example devicetree fragment:

gpio1: gpio@abcd0001 { ... };
gpio2: gpio@abcd0002 { ... };
mspi@abcd0003 {
compatible = "ambiq,mspi";
ce-gpios = <&gpio1 10 GPIO_ACTIVE_LOW>,
<&gpio2 20 GPIO_ACTIVE_LOW>;
a: mspi-dev-a@0 {
reg = <0>;
};
b: mspi-dev-b@1 {
reg = <1>;
};
};

Example usage:

// { DEVICE_DT_GET(DT_NODELABEL(gpio1)), 10, GPIO_ACTIVE_LOW }
// { DEVICE_DT_GET(DT_NODELABEL(gpio2)), 20, GPIO_ACTIVE_LOW }
Parameters
mspi_deva MSPI device node identifier
Returns
gpio_dt_spec struct corresponding with mspi_dev's chip enable

◆ MSPI_DEV_CE_GPIOS_DT_SPEC_INST_GET

#define MSPI_DEV_CE_GPIOS_DT_SPEC_INST_GET (   inst)     MSPI_DEV_CE_GPIOS_DT_SPEC_GET(DT_DRV_INST(inst))

#include <include/zephyr/drivers/mspi/devicetree.h>

Get a struct gpio_dt_spec for a MSPI device's chip enable pin.

This is equivalent to MSPI_DEV_CE_GPIOS_DT_SPEC_GET(DT_DRV_INST(inst)).

Parameters
instDevicetree instance number
Returns
gpio_dt_spec struct corresponding with mspi_dev's chip enable

◆ MSPI_DEVICE_CONFIG_DT

#define MSPI_DEVICE_CONFIG_DT (   mspi_dev)

#include <include/zephyr/drivers/mspi/devicetree.h>

Value:
{ \
.ce_num = DT_PROP_OR(mspi_dev, mspi_hardware_ce_num, 0), \
.freq = DT_PROP(mspi_dev, mspi_max_frequency), \
.io_mode = DT_ENUM_IDX_OR(mspi_dev, mspi_io_mode, \
.data_rate = DT_ENUM_IDX_OR(mspi_dev, mspi_data_rate, \
.endian = DT_ENUM_IDX_OR(mspi_dev, mspi_endian, \
.ce_polarity = DT_ENUM_IDX_OR(mspi_dev, mspi_ce_polarity, \
.dqs_enable = DT_PROP(mspi_dev, mspi_dqs_enable), \
.rx_dummy = DT_PROP_OR(mspi_dev, rx_dummy, 0), \
.tx_dummy = DT_PROP_OR(mspi_dev, tx_dummy, 0), \
.read_cmd = DT_PROP_OR(mspi_dev, read_command, 0), \
.write_cmd = DT_PROP_OR(mspi_dev, write_command, 0), \
.cmd_length = DT_ENUM_IDX_OR(mspi_dev, command_length, 0), \
.addr_length = DT_ENUM_IDX_OR(mspi_dev, address_length, 0), \
.mem_boundary = COND_CODE_1(DT_NODE_HAS_PROP(mspi_dev, ce_break_config), \
(DT_PROP_BY_IDX(mspi_dev, ce_break_config, 0)), \
(0)), \
.time_to_break = COND_CODE_1(DT_NODE_HAS_PROP(mspi_dev, ce_break_config), \
(DT_PROP_BY_IDX(mspi_dev, ce_break_config, 1)), \
(0)), \
}
#define DT_PROP_BY_IDX(node_id, prop, idx)
Get the value at index idx in an array type property.
Definition devicetree.h:809
#define DT_PROP_OR(node_id, prop, default_value)
Like DT_PROP(), but with a fallback to default_value.
Definition devicetree.h:825
#define DT_PROP(node_id, prop)
Get a devicetree property value.
Definition devicetree.h:663
#define DT_ENUM_IDX_OR(node_id, prop, default_idx_value)
Like DT_ENUM_IDX(), but with a fallback to a default enum index.
Definition devicetree.h:885
mspi_ce_polarity
MSPI chip enable polarity.
Definition mspi.h:113
mspi_endian
MSPI Endian.
Definition mspi.h:105
mspi_cpp_mode
MSPI Polarity & Phase Modes.
Definition mspi.h:95
mspi_io_mode
MSPI I/O mode capabilities Postfix like 1_4_4 stands for the number of lines used for command,...
Definition mspi.h:58
mspi_data_rate
MSPI data rate capabilities SINGLE stands for single data rate for all phases.
Definition mspi.h:84
@ MSPI_CE_ACTIVE_LOW
Definition mspi.h:114
@ MSPI_XFER_LITTLE_ENDIAN
Definition mspi.h:106
@ MSPI_CPP_MODE_0
Definition mspi.h:96
@ MSPI_IO_MODE_SINGLE
Definition mspi.h:59
@ MSPI_DATA_RATE_SINGLE
Definition mspi.h:85
#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:179

Structure initializer for struct mspi_dev_cfg from devicetree.

This helper macro expands to a static initializer for a struct mspi_dev_cfg by reading the relevant data from the devicetree.

Parameters
mspi_devDevicetree node identifier for the MSPI device whose struct mspi_dev_cfg to create an initializer for

◆ MSPI_DEVICE_CONFIG_DT_INST

#define MSPI_DEVICE_CONFIG_DT_INST (   inst)    MSPI_DEVICE_CONFIG_DT(DT_DRV_INST(inst))

#include <include/zephyr/drivers/mspi/devicetree.h>

Structure initializer for struct mspi_dev_cfg from devicetree instance.

This is equivalent to MSPI_DEVICE_CONFIG_DT(DT_DRV_INST(inst)).

Parameters
instDevicetree instance number

◆ MSPI_DEVICE_ID_DT

#define MSPI_DEVICE_ID_DT (   mspi_dev)

#include <include/zephyr/drivers/mspi/devicetree.h>

Value:
{ \
.ce = MSPI_DEV_CE_GPIOS_DT_SPEC_GET(mspi_dev), \
.dev_idx = DT_REG_ADDR(mspi_dev), \
}
#define DT_REG_ADDR(node_id)
Get a node's (only) register block address.
Definition devicetree.h:2276

Structure initializer for struct mspi_dev_id from devicetree.

This helper macro expands to a static initializer for a struct mspi_dev_id by reading the relevant data from the devicetree.

Parameters
mspi_devDevicetree node identifier for the MSPI device whose struct mspi_dev_id to create an initializer for

◆ MSPI_DEVICE_ID_DT_INST

#define MSPI_DEVICE_ID_DT_INST (   inst)    MSPI_DEVICE_ID_DT(DT_DRV_INST(inst))

#include <include/zephyr/drivers/mspi/devicetree.h>

Structure initializer for struct mspi_dev_id from devicetree instance.

This is equivalent to MSPI_DEVICE_ID_DT(DT_DRV_INST(inst)).

Parameters
instDevicetree instance number

◆ MSPI_SCRAMBLE_CONFIG_DT

#define MSPI_SCRAMBLE_CONFIG_DT (   mspi_dev)

#include <include/zephyr/drivers/mspi/devicetree.h>

Value:
COND_CODE_1(DT_NODE_HAS_PROP(mspi_dev, scramble_config), \
({}))
#define MSPI_SCRAMBLE_CONFIG_DT_NO_CHECK(mspi_dev)
Structure initializer for struct mspi_scramble_cfg from devicetree.
Definition devicetree.h:120

Structure initializer for struct mspi_scramble_cfg from devicetree.

This helper macro check whether scramble_config binding exist first before calling MSPI_SCRAMBLE_CONFIG_DT_NO_CHECK.

Parameters
mspi_devDevicetree node identifier for the MSPI device whose struct mspi_scramble_cfg to create an initializer for

◆ MSPI_SCRAMBLE_CONFIG_DT_INST

#define MSPI_SCRAMBLE_CONFIG_DT_INST (   inst)    MSPI_SCRAMBLE_CONFIG_DT(DT_DRV_INST(inst))

#include <include/zephyr/drivers/mspi/devicetree.h>

Structure initializer for struct mspi_scramble_cfg from devicetree instance.

This is equivalent to MSPI_SCRAMBLE_CONFIG_DT(DT_DRV_INST(inst)).

Parameters
instDevicetree instance number

◆ MSPI_SCRAMBLE_CONFIG_DT_NO_CHECK

#define MSPI_SCRAMBLE_CONFIG_DT_NO_CHECK (   mspi_dev)

#include <include/zephyr/drivers/mspi/devicetree.h>

Value:
{ \
.enable = DT_PROP_BY_IDX(mspi_dev, scramble_config, 0), \
.address_offset = DT_PROP_BY_IDX(mspi_dev, scramble_config, 1), \
.size = DT_PROP_BY_IDX(mspi_dev, scramble_config, 2), \
}

Structure initializer for struct mspi_scramble_cfg from devicetree.

This helper macro expands to a static initializer for a struct mspi_scramble_cfg by reading the relevant data from the devicetree.

Parameters
mspi_devDevicetree node identifier for the MSPI device whose struct mspi_scramble_cfg to create an initializer for

◆ MSPI_XIP_CONFIG_DT

#define MSPI_XIP_CONFIG_DT (   mspi_dev)

#include <include/zephyr/drivers/mspi/devicetree.h>

Value:
COND_CODE_1(DT_NODE_HAS_PROP(mspi_dev, xip_config), \
({}))
#define MSPI_XIP_CONFIG_DT_NO_CHECK(mspi_dev)
Structure initializer for struct mspi_xip_cfg from devicetree.
Definition devicetree.h:79

Structure initializer for struct mspi_xip_cfg from devicetree.

This helper macro check whether xip_config binding exist first before calling MSPI_XIP_CONFIG_DT_NO_CHECK.

Parameters
mspi_devDevicetree node identifier for the MSPI device whose struct mspi_xip_cfg to create an initializer for

◆ MSPI_XIP_CONFIG_DT_INST

#define MSPI_XIP_CONFIG_DT_INST (   inst)    MSPI_XIP_CONFIG_DT(DT_DRV_INST(inst))

#include <include/zephyr/drivers/mspi/devicetree.h>

Structure initializer for struct mspi_xip_cfg from devicetree instance.

This is equivalent to MSPI_XIP_CONFIG_DT(DT_DRV_INST(inst)).

Parameters
instDevicetree instance number

◆ MSPI_XIP_CONFIG_DT_NO_CHECK

#define MSPI_XIP_CONFIG_DT_NO_CHECK (   mspi_dev)

#include <include/zephyr/drivers/mspi/devicetree.h>

Value:
{ \
.enable = DT_PROP_BY_IDX(mspi_dev, xip_config, 0), \
.address_offset = DT_PROP_BY_IDX(mspi_dev, xip_config, 1), \
.size = DT_PROP_BY_IDX(mspi_dev, xip_config, 2), \
.permission = DT_PROP_BY_IDX(mspi_dev, xip_config, 3), \
}

Structure initializer for struct mspi_xip_cfg from devicetree.

This helper macro expands to a static initializer for a struct mspi_xip_cfg by reading the relevant data from the devicetree.

Parameters
mspi_devDevicetree node identifier for the MSPI device whose struct mspi_xip_cfg to create an initializer for