Remove all enabling of CONFIG_EMUL_.* in favor of automatically enabling
peripheral emulators based on the compatible string presence in the device
tree and the one true CONFIG_EMUL.
Zephyr has long since moved to a model of enabling drivers based on the
presence of their associated IC's compatible string in the final devicetree
overlay. There is no reason that emulators can't align in just the same
way, and probably ought to to remove superfluous enabling of configs.
Signed-off-by: Aaron Massey <aaronmassey@google.com>
The emulator structure currently initializes a bus-level API that is
used to communicated register accesses to the emulator from the parent
bus.
Add support for declaring a backend API for emulators. This provides
tests a common way to interact with emulators of the same device type.
Signed-off-by: Keith Short <keithshort@google.com>
The data_host variable in the emul_espi_host_send_cw function should be
assigned the espi host emulator data and not the espi_emul data.
Assign the variable to correct reference.
Signed-off-by: Aaron Massey <aaronmassey@google.com>
Some paramaters in prior emulators have historically referred to instances
of struct emul as "emulator" or "emul". The proper parameter name for this
type is "target" as it designates the struct emul instance is the emul
bus (e.g. emul_i2c) controller's target peripheral for dispatch.
Do a small refactor renaming some of these parameters to "target".
TEST=twister on accel, espi, and eeprom drivers tests
Signed-off-by: Aaron Massey <aaronmassey@google.com>
In several locations of the emulator code there are unused function
arguments that were never caught.
Declare these as unused or remove the unused function parameters entirely.
Signed-off-by: Aaron Massey <aaronmassey@google.com>
Allow emulator creators to write an init function that can be used
across multiple busses so as to reduce the boilerplate and cognitive
load in creating an emulator.
Part of this change includes allowing access to the emul struct from a
field in a {bus}_struct api (e.g. i2c_struct), which removes the need for
sporadic usages of CONTAINER_OF to access the emul struct.
Overall, this change simplifies and reduces the amount of boilerplate
code to get a device emulator up and running, thus reducing excise work
to writing tests.
TEST=twister on accel,espi, and eeprom drivers tests
Signed-off-by: Aaron Massey <aaronmassey@google.com>
Run clang-format on all files touched by improved emulator API pull-request
that allowed access to the target device emulator from its bus api without
CONTAINER_OF usage.
drivers/i2c/i2c_emul.c
drivers/spi/spi_emul.c
include/zephyr/drivers/emul.h
include/zephyr/drivers/espi_emul.h
include/zephyr/drivers/i2c_emul.h
include/zephyr/drivers/spi_emul.h
subsys/emul/emul.c
subsys/emul/emul_bmi160.c
subsys/emul/espi/emul_espi_host.c
subsys/emul/i2c/emul_atmel_at24.c
TEST=twister on accel,espi, and eeprom drivers tests
Signed-off-by: Aaron Massey <aaronmassey@google.com>
In order to bring consistency in-tree, migrate all subsystems code to
the new prefix <zephyr/...>. Note that the conversion has been scripted,
refer to zephyrproject-rtos#45388 for more details.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Emulators are difficult to work with, they generally require maintaining
some state in a mutable data struct. Since the emulator struct doesn't
support a data field like devices do, the pattern seems to be to add it
to the configuration. This makes following the logic of where things are
difficult.
1. Add a `struct emul *parent` structure to the espi/i2c/spi emulator
structs to make it easier when casting up.
2. Add a `void *data` field to `struct emul` to hold the data for
emulators.
Signed-off-by: Yuval Peress <peress@chromium.org>
Move emul.h out of the top level include/ dir into
include/drivers/emul.h and deprecated the old location.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This emulator pretends a generic eSPI Host. It supports basic virtual
wires and port80 operations.
There are functions to trigger actions on the host side e.g. for
setting a virtual wire from the host to the eSPI slave, use
emul_espi_host_send_vw. It will prepare data and set a proper event
on the slave side which will trigger callback (if there is any).
Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com>