Zephyr Project API 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
espi_emul.h
Go to the documentation of this file.
1/*
2 * Copyright 2020 Google LLC
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
12
13#ifndef ZEPHYR_INCLUDE_DRIVERS_ESPI_SPI_EMUL_H_
14#define ZEPHYR_INCLUDE_DRIVERS_ESPI_SPI_EMUL_H_
15
16#include <zephyr/device.h>
17#include <zephyr/drivers/emul.h>
18#include <zephyr/drivers/espi.h>
19#include <zephyr/sys/slist.h>
20#include <zephyr/types.h>
21
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34#define EMUL_ESPI_HOST_CHIPSEL 0
35
36struct espi_emul;
37
49typedef int (*emul_espi_api_set_vw)(const struct emul *target, enum espi_vwire_signal vw,
50 uint8_t level);
51
63typedef int (*emul_espi_api_get_vw)(const struct emul *target, enum espi_vwire_signal vw,
64 uint8_t *level);
65
75typedef uintptr_t (*emul_espi_api_get_acpi_shm)(const struct emul *target);
76
88typedef struct espi_emul *(*emul_find_emul)(const struct device *dev, unsigned int chipsel);
89
100typedef int (*emul_trigger_event)(const struct device *dev, struct espi_event *evt);
101
108#if defined(CONFIG_ESPI_PERIPHERAL_ACPI_SHM_REGION) || defined(__DOXYGEN__)
113#endif
114};
115
126
128__subsystem struct emul_espi_driver_api {
129 /* The struct espi_driver_api has to be first in
130 * struct emul_espi_driver_api to make pointer casting working
131 */
133 /* The rest, emulator specific functions */
136};
137
139DEVICE_API_EXTENDS(emul_espi, espi, espi_api);
141
149int espi_emul_register(const struct device *dev, struct espi_emul *emul);
150
162int emul_espi_host_send_vw(const struct device *espi_dev, enum espi_vwire_signal vw, uint8_t level);
163
174int emul_espi_host_port80_write(const struct device *espi_dev, uint32_t data);
175
186
187#ifdef __cplusplus
188}
189#endif
190
194
195#endif /* ZEPHYR_INCLUDE_DRIVERS_ESPI_SPI_EMUL_H_ */
APIs and macros for the Zephyr device model.
#define DEVICE_API_EXTENDS(_child, _parent, _member)
Declare that API class _child is an extension of device API class _parent.
Definition device.h:1451
Public APIs for the device emulation framework.
Main header file for eSPI (Enhanced Serial Peripheral Interface) driver API.
int(* emul_espi_api_get_vw)(const struct emul *target, enum espi_vwire_signal vw, uint8_t *level)
Passes eSPI virtual wires get request (virtual wire packet) to the emulator.
Definition espi_emul.h:63
int emul_espi_host_port80_write(const struct device *espi_dev, uint32_t data)
Perform port80 write on the emulated host side, which will trigger a proper event(and callbacks) on t...
int(* emul_trigger_event)(const struct device *dev, struct espi_event *evt)
Triggers an event on the emulator of eSPI controller side which causes calling specific callbacks.
Definition espi_emul.h:100
uintptr_t(* emul_espi_api_get_acpi_shm)(const struct emul *target)
Get the ACPI shared memory address owned by the emulator.
Definition espi_emul.h:75
int emul_espi_host_send_vw(const struct device *espi_dev, enum espi_vwire_signal vw, uint8_t level)
Sets the eSPI virtual wire on the host side, which will trigger a proper event(and callbacks) on the ...
struct espi_emul *(* emul_find_emul)(const struct device *dev, unsigned int chipsel)
Find an emulator present on a eSPI bus.
Definition espi_emul.h:88
uintptr_t emul_espi_host_get_acpi_shm(const struct device *espi_dev)
Get the host device's ACPI shared memory start address.
int espi_emul_register(const struct device *dev, struct espi_emul *emul)
Register an emulated device on the controller.
int(* emul_espi_api_set_vw)(const struct emul *target, enum espi_vwire_signal vw, uint8_t level)
Passes eSPI virtual wires set request (virtual wire packet) to the emulator.
Definition espi_emul.h:49
espi_vwire_signal
eSPI system platform signals that can be sent or received through virtual wire channel
Definition espi.h:303
struct _snode sys_snode_t
Single-linked list node structure.
Definition slist.h:44
Header file for the single-linked list API.
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINTPTR_TYPE__ uintptr_t
Definition stdint.h:105
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Runtime device structure (in ROM) per driver instance.
Definition device.h:543
Definition of the eSPI device emulator API.
Definition espi_emul.h:103
emul_espi_api_set_vw set_vw
eSPI virtual wires set handler
Definition espi_emul.h:105
emul_espi_api_get_vw get_vw
eSPI virtual wires get handler
Definition espi_emul.h:107
emul_espi_api_get_acpi_shm get_acpi_shm
ACPI shared memory address get handler.
Definition espi_emul.h:112
Definition of the eSPI controller emulator API.
Definition espi_emul.h:128
emul_trigger_event trigger_event
Definition espi_emul.h:134
struct espi_driver_api espi_api
Definition espi_emul.h:132
emul_find_emul find_emul
Definition espi_emul.h:135
An emulator instance - represents the target emulated device/peripheral that is interacted with throu...
Definition emul.h:88
@driver_ops{eSPI}
Definition espi.h:738
Node in a linked list of emulators for eSPI devices.
Definition espi_emul.h:117
const struct emul_espi_device_api * api
API provided for this device.
Definition espi_emul.h:122
const struct emul * target
Target emulator - REQUIRED for all emulated bus nodes of any type.
Definition espi_emul.h:120
uint16_t chipsel
eSPI chip-select of the emulated device
Definition espi_emul.h:124
sys_snode_t node
Definition espi_emul.h:118
eSPI event
Definition espi.h:499