Commit graph

14 commits

Author SHA1 Message Date
Jose Alberto Meza
30eda2058b treewide: drivers: espi: Adjust terms per eSPI specification 1.5
1) Replace master/slave in API for new terms in eSPI spec 1.5
2) Reflect eSPI VW change and macro changes across eSPI drivers
3) Update terms in eSPI driver sample and eSPI test driver

Signed-off-by: Jose Alberto Meza <jose.a.meza.arellano@intel.com>
2024-05-02 13:56:46 -04:00
Keith Short
6062914cf2 emul: Add support for backend APIs
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>
2023-01-27 01:01:06 +09:00
Abe Levkoy
c7b0b13fb2 emul: Update EMUL_DEFINE usages in emulators
Use EMUL_DT_INST_DEFINE instead.

Part of #45976.

Signed-off-by: Abe Levkoy <alevkoy@google.com>
2022-08-17 15:47:52 +00:00
Aaron Massey
1cebee4a43 emul: Fix emul_espi_host.c type coercion
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>
2022-07-29 20:05:38 -05:00
Aaron Massey
5e2678135d emul: Make emulator parameters consistently named
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>
2022-07-19 11:43:30 -05:00
Aaron Massey
76ae0ba270 emul: Remove or declare unused args
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>
2022-07-19 11:43:30 -05:00
Aaron Massey
9d7b9dc807 emul: Simplify emulator bus initialization and API
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>
2022-07-19 11:43:30 -05:00
Aaron Massey
1028459afd emul: Run clang-format
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>
2022-07-19 11:43:30 -05:00
Kumar Gala
c3d65b7f6b emul: espi: Remove unused struct element
espi_label struct element wasn't used anywhere so remove it.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-07-08 10:53:02 +02:00
Gerard Marull-Paretas
5113c1418d subsystems: migrate includes to <zephyr/...>
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>
2022-05-09 12:07:35 +02:00
Yuval Peress
2629fc566d emul: Add data and parent pointers to emulators
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>
2021-10-05 19:21:39 -04:00
Yuval Peress
ab6e724ab4 emul: espi: Add ACPI Shared Memory functions
Add the bare minimum to set and access the ACPI shared memory via the
eSPI emulator.

Signed-off-by: Yuval Peress <peress@chromium.org>
2021-08-26 13:14:05 -04:00
Kumar Gala
e1032ad2c3 include: Move emul.h to drivers/emul.h
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>
2021-04-22 12:51:01 -04:00
Dawid Niedzwiecki
6ec4ff22e3 emul: Add an emulator for the eSPI Host
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>
2021-01-20 17:49:19 -05:00