Zephyr Project API 4.2.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
7#ifndef ZEPHYR_INCLUDE_DRIVERS_ESPI_SPI_EMUL_H_
8#define ZEPHYR_INCLUDE_DRIVERS_ESPI_SPI_EMUL_H_
9
10#include <zephyr/device.h>
11#include <zephyr/drivers/emul.h>
12#include <zephyr/drivers/espi.h>
13#include <zephyr/sys/slist.h>
14#include <zephyr/types.h>
15
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
66#ifdef CONFIG_ESPI_PERIPHERAL_ACPI_SHM_REGION
74typedef uintptr_t (*emul_espi_api_get_acpi_shm)(const struct emul *target);
75#endif
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
106#ifdef CONFIG_ESPI_PERIPHERAL_ACPI_SHM_REGION
107 emul_espi_api_get_acpi_shm get_acpi_shm;
108#endif
109};
110
121
124 /* The struct espi_driver_api has to be first in
125 * struct emul_espi_driver_api to make pointer casting working
126 */
127 struct espi_driver_api espi_api;
128 /* The rest, emulator specific functions */
131};
132
140int espi_emul_register(const struct device *dev, struct espi_emul *emul);
141
153int emul_espi_host_send_vw(const struct device *espi_dev, enum espi_vwire_signal vw, uint8_t level);
154
165int emul_espi_host_port80_write(const struct device *espi_dev, uint32_t data);
166
167#ifdef CONFIG_ESPI_PERIPHERAL_ACPI_SHM_REGION
175uintptr_t emul_espi_host_get_acpi_shm(const struct device *espi_dev);
176#endif
177
178#ifdef __cplusplus
179}
180#endif
181
186#endif /* ZEPHYR_INCLUDE_DRIVERS_ESPI_SPI_EMUL_H_ */
Public APIs for eSPI driver.
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
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
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:250
struct _snode sys_snode_t
Single-linked list node structure.
Definition slist.h:39
__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:510
Definition of the eSPI device emulator API.
Definition espi_emul.h:103
emul_espi_api_set_vw set_vw
Definition espi_emul.h:104
emul_espi_api_get_vw get_vw
Definition espi_emul.h:105
Definition of the eSPI controller emulator API.
Definition espi_emul.h:123
emul_trigger_event trigger_event
Definition espi_emul.h:129
struct espi_driver_api espi_api
Definition espi_emul.h:127
emul_find_emul find_emul
Definition espi_emul.h:130
An emulator instance - represents the target emulated device/peripheral that is interacted with throu...
Definition emul.h:82
Node in a linked list of emulators for eSPI devices.
Definition espi_emul.h:112
const struct emul_espi_device_api * api
API provided for this device.
Definition espi_emul.h:117
const struct emul * target
Target emulator - REQUIRED for all emulated bus nodes of any type.
Definition espi_emul.h:115
uint16_t chipsel
eSPI chip-select of the emulated device
Definition espi_emul.h:119
sys_snode_t node
Definition espi_emul.h:113
eSPI event
Definition espi.h:438