Zephyr Project API  3.2.0
A Scalable Open Source RTOS
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/types.h>
14
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32#define EMUL_ESPI_HOST_CHIPSEL 0
33
34struct espi_emul;
35
47typedef int (*emul_espi_api_set_vw)(const struct emul *target, enum espi_vwire_signal vw,
48 uint8_t level);
49
61typedef int (*emul_espi_api_get_vw)(const struct emul *target, enum espi_vwire_signal vw,
62 uint8_t *level);
63
64#ifdef CONFIG_ESPI_PERIPHERAL_ACPI_SHM_REGION
72typedef uintptr_t (*emul_espi_api_get_acpi_shm)(const struct emul *target);
73#endif
74
86typedef struct espi_emul *(*emul_find_emul)(const struct device *dev, unsigned int chipsel);
87
98typedef int (*emul_trigger_event)(const struct device *dev, struct espi_event *evt);
99
104#ifdef CONFIG_ESPI_PERIPHERAL_ACPI_SHM_REGION
105 emul_espi_api_get_acpi_shm get_acpi_shm;
106#endif
107};
108
110struct espi_emul {
113 const struct emul *target;
118};
119
122 /* The struct espi_driver_api has to be first in
123 * struct emul_espi_driver_api to make pointer casting working
124 */
125 struct espi_driver_api espi_api;
126 /* The rest, emulator specific functions */
129};
130
138int espi_emul_register(const struct device *dev, struct espi_emul *emul);
139
151int emul_espi_host_send_vw(const struct device *espi_dev, enum espi_vwire_signal vw, uint8_t level);
152
163int emul_espi_host_port80_write(const struct device *espi_dev, uint32_t data);
164
165#ifdef CONFIG_ESPI_PERIPHERAL_ACPI_SHM_REGION
173uintptr_t emul_espi_host_get_acpi_shm(const struct device *espi_dev);
174#endif
175
176#ifdef __cplusplus
177}
178#endif
179
184#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)
Definition: espi_emul.h:61
int emul_espi_host_port80_write(const struct device *espi_dev, uint32_t data)
int(* emul_trigger_event)(const struct device *dev, struct espi_event *evt)
Definition: espi_emul.h:98
int emul_espi_host_send_vw(const struct device *espi_dev, enum espi_vwire_signal vw, uint8_t level)
struct espi_emul *(* emul_find_emul)(const struct device *dev, unsigned int chipsel)
Definition: espi_emul.h:86
int espi_emul_register(const struct device *dev, struct espi_emul *emul)
int(* emul_espi_api_set_vw)(const struct emul *target, enum espi_vwire_signal vw, uint8_t level)
Definition: espi_emul.h:47
espi_vwire_signal
eSPI system platform signals that can be send or receive through virtual wire channel
Definition: espi.h:194
int target
Definition: main.c:68
struct _snode sys_snode_t
Definition: slist.h:33
__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:435
Definition: espi_emul.h:101
emul_espi_api_set_vw set_vw
Definition: espi_emul.h:102
emul_espi_api_get_vw get_vw
Definition: espi_emul.h:103
Definition: espi_emul.h:121
emul_trigger_event trigger_event
Definition: espi_emul.h:127
struct espi_driver_api espi_api
Definition: espi_emul.h:125
emul_find_emul find_emul
Definition: espi_emul.h:128
Definition: emul.h:67
Definition: espi_emul.h:110
const struct emul_espi_device_api * api
Definition: espi_emul.h:115
const struct emul * target
Definition: espi_emul.h:113
uint16_t chipsel
Definition: espi_emul.h:117
sys_snode_t node
Definition: espi_emul.h:111
eSPI event
Definition: espi.h:313
static fdata_t data[2]
Definition: test_fifo_contexts.c:15