Zephyr API Documentation  3.6.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
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33#define EMUL_ESPI_HOST_CHIPSEL 0
34
35struct espi_emul;
36
48typedef int (*emul_espi_api_set_vw)(const struct emul *target, enum espi_vwire_signal vw,
49 uint8_t level);
50
62typedef int (*emul_espi_api_get_vw)(const struct emul *target, enum espi_vwire_signal vw,
63 uint8_t *level);
64
65#ifdef CONFIG_ESPI_PERIPHERAL_ACPI_SHM_REGION
73typedef uintptr_t (*emul_espi_api_get_acpi_shm)(const struct emul *target);
74#endif
75
87typedef struct espi_emul *(*emul_find_emul)(const struct device *dev, unsigned int chipsel);
88
99typedef int (*emul_trigger_event)(const struct device *dev, struct espi_event *evt);
100
105#ifdef CONFIG_ESPI_PERIPHERAL_ACPI_SHM_REGION
106 emul_espi_api_get_acpi_shm get_acpi_shm;
107#endif
108};
109
111struct espi_emul {
114 const struct emul *target;
119};
120
123 /* The struct espi_driver_api has to be first in
124 * struct emul_espi_driver_api to make pointer casting working
125 */
126 struct espi_driver_api espi_api;
127 /* The rest, emulator specific functions */
130};
131
139int espi_emul_register(const struct device *dev, struct espi_emul *emul);
140
152int emul_espi_host_send_vw(const struct device *espi_dev, enum espi_vwire_signal vw, uint8_t level);
153
164int emul_espi_host_port80_write(const struct device *espi_dev, uint32_t data);
165
166#ifdef CONFIG_ESPI_PERIPHERAL_ACPI_SHM_REGION
174uintptr_t emul_espi_host_get_acpi_shm(const struct device *espi_dev);
175#endif
176
177#ifdef __cplusplus
178}
179#endif
180
185#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:62
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:99
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:87
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:48
espi_vwire_signal
eSPI system platform signals that can be send or receive through virtual wire channel
Definition: espi.h:199
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:399
Definition of the eSPI device emulator API.
Definition: espi_emul.h:102
emul_espi_api_set_vw set_vw
Definition: espi_emul.h:103
emul_espi_api_get_vw get_vw
Definition: espi_emul.h:104
Definition of the eSPI controller emulator API.
Definition: espi_emul.h:122
emul_trigger_event trigger_event
Definition: espi_emul.h:128
struct espi_driver_api espi_api
Definition: espi_emul.h:126
emul_find_emul find_emul
Definition: espi_emul.h:129
An emulator instance - represents the target emulated device/peripheral that is interacted with throu...
Definition: emul.h:78
Node in a linked list of emulators for eSPI devices.
Definition: espi_emul.h:111
const struct emul_espi_device_api * api
API provided for this device.
Definition: espi_emul.h:116
const struct emul * target
Target emulator - REQUIRED for all emulated bus nodes of any type.
Definition: espi_emul.h:114
uint16_t chipsel
eSPI chip-select of the emulated device
Definition: espi_emul.h:118
sys_snode_t node
Definition: espi_emul.h:112
eSPI event
Definition: espi.h:323