8#ifndef ZEPHYR_INCLUDE_DRIVERS_EMUL_H_
9#define ZEPHYR_INCLUDE_DRIVERS_EMUL_H_
95#define EMUL_DT_NAME_GET(node_id) _CONCAT(__emulreg_, node_id)
101#define Z_EMUL_REG_BUS_IDENTIFIER(_dev_node_id) (_CONCAT(_CONCAT(__emulreg_, _dev_node_id), _bus))
104#define Z_EMUL_BUS(_dev_node_id, _i2c, _espi, _spi) \
105 COND_CODE_1(DT_ON_BUS(_dev_node_id, i2c), (_i2c), \
106 (COND_CODE_1(DT_ON_BUS(_dev_node_id, espi), (_espi), \
107 (COND_CODE_1(DT_ON_BUS(_dev_node_id, spi), (_spi), (-EINVAL))))))
122#define EMUL_DT_DEFINE(node_id, init_fn, data_ptr, cfg_ptr, bus_api, _backend_api) \
123 static struct Z_EMUL_BUS(node_id, i2c_emul, espi_emul, spi_emul) \
124 Z_EMUL_REG_BUS_IDENTIFIER(node_id) = { \
126 .Z_EMUL_BUS(node_id, addr, chipsel, chipsel) = DT_REG_ADDR(node_id), \
128 const STRUCT_SECTION_ITERABLE(emul, EMUL_DT_NAME_GET(node_id)) \
131 .dev = DEVICE_DT_GET(node_id), \
133 .data = (data_ptr), \
134 .bus_type = Z_EMUL_BUS(node_id, EMUL_BUS_TYPE_I2C, EMUL_BUS_TYPE_ESPI, \
135 EMUL_BUS_TYPE_SPI), \
136 .bus = {.Z_EMUL_BUS(node_id, i2c, espi, spi) = \
137 &(Z_EMUL_REG_BUS_IDENTIFIER(node_id))}, \
138 .backend_api = (_backend_api), \
149#define EMUL_DT_INST_DEFINE(inst, ...) EMUL_DT_DEFINE(DT_DRV_INST(inst), __VA_ARGS__)
165#define EMUL_DT_GET(node_id) (&EMUL_DT_NAME_GET(node_id))
194#if defined(CONFIG_HAS_DTS) || defined(__DOXYGEN__)
195#define Z_MAYBE_EMUL_DECLARE_INTERNAL(node_id) extern const struct emul EMUL_DT_NAME_GET(node_id);
Public APIs for the eSPI emulation drivers.
#define DT_FOREACH_STATUS_OKAY_NODE(fn)
Invokes fn for every status okay node in the tree.
Definition: devicetree.h:2498
emul_bus_type
The types of supported buses.
Definition: emul.h:35
int(* emul_init_t)(const struct emul *emul, const struct device *parent)
Standard callback for emulator initialisation providing the initialiser record and the device that ca...
Definition: emul.h:63
const struct emul * emul_get_binding(const char *name)
Retrieve the emul structure for an emulator by name.
int emul_init_for_bus(const struct device *dev)
Set up a list of emulators.
@ EMUL_BUS_TYPE_SPI
Definition: emul.h:38
@ EMUL_BUS_TYPE_I2C
Definition: emul.h:36
@ EMUL_BUS_TYPE_ESPI
Definition: emul.h:37
Public APIs for the I2C emulation drivers.
Public APIs for the SPI emulation drivers.
Runtime device structure (in ROM) per driver instance.
Definition: device.h:381
Structure uniquely identifying a device to be emulated.
Definition: emul.h:44
const struct device * dev
Definition: emul.h:45
List of emulators attached to a bus.
Definition: emul.h:49
const struct emul_link_for_bus * children
Identifiers for children of the node.
Definition: emul.h:51
unsigned int num_children
Number of children of the node.
Definition: emul.h:53
An emulator instance - represents the target emulated device/peripheral that is interacted with throu...
Definition: emul.h:69
const struct device * dev
handle to the device for which this provides low-level emulation
Definition: emul.h:73
emul_init_t init
function used to initialise the emulator state
Definition: emul.h:71
void * data
Emulator-specific data.
Definition: emul.h:77
enum emul_bus_type bus_type
The bus type that the emulator is attached to.
Definition: emul.h:79
const void * backend_api
Address of the API structure exposed by the emulator instance.
Definition: emul.h:87
const void * cfg
Emulator-specific configuration data.
Definition: emul.h:75
Node in a linked list of emulators for eSPI devices.
Definition: espi_emul.h:111
Node in a linked list of emulators for I2C devices.
Definition: i2c_emul.h:36
Node in a linked list of emulators for SPI devices.
Definition: spi_emul.h:37
Pointer to the emulated bus node.
Definition: emul.h:81
struct i2c_emul * i2c
Definition: emul.h:82
struct spi_emul * spi
Definition: emul.h:84
struct espi_emul * espi
Definition: emul.h:83