12#ifndef ZEPHYR_INCLUDE_ESPI_H_
13#define ZEPHYR_INCLUDE_ESPI_H_
122#define ESPI_PERIPHERAL_INDEX_0 0ul
123#define ESPI_PERIPHERAL_INDEX_1 1ul
124#define ESPI_PERIPHERAL_INDEX_2 2ul
126#define ESPI_SLAVE_TO_MASTER 0ul
127#define ESPI_MASTER_TO_SLAVE 1ul
129#define ESPI_VWIRE_SRC_ID0 0ul
130#define ESPI_VWIRE_SRC_ID1 1ul
131#define ESPI_VWIRE_SRC_ID2 2ul
132#define ESPI_VWIRE_SRC_ID3 3ul
133#define ESPI_VWIRE_SRC_ID_MAX 4ul
135#define ESPI_PERIPHERAL_NODATA 0ul
137#define E8042_START_OPCODE 0x50
138#define E8042_MAX_OPCODE 0x5F
140#define EACPI_START_OPCODE 0x60
141#define EACPI_MAX_OPCODE 0x6F
143#define ECUSTOM_START_OPCODE 0xF0
144#define ECUSTOM_MAX_OPCODE 0xFF
160#if defined(CONFIG_ESPI_PERIPHERAL_EC_HOST_CMD)
161 ESPI_PERIPHERAL_EC_HOST_CMD,
244#if defined(CONFIG_ESPI_PERIPHERAL_ACPI_SHM_REGION)
246 EACPI_GET_SHARED_MEMORY,
248#if defined(CONFIG_ESPI_PERIPHERAL_CUSTOM_OPCODE)
250 ECUSTOM_HOST_SUBS_INTERRUPT_EN = ECUSTOM_START_OPCODE,
251 ECUSTOM_HOST_CMD_GET_PARAM_MEMORY,
252 ECUSTOM_HOST_CMD_SEND_RESULT,
257#define HOST_KBC_EVT_IBF BIT(0)
259#define HOST_KBC_EVT_OBE BIT(1)
343 struct espi_callback *cb,
356struct espi_callback {
379typedef int (*espi_api_config)(
const struct device *dev,
struct espi_cfg *cfg);
380typedef bool (*espi_api_get_channel_status)(
const struct device *dev,
383typedef int (*espi_api_read_request)(
const struct device *dev,
385typedef int (*espi_api_write_request)(
const struct device *dev,
387typedef int (*espi_api_lpc_read_request)(
const struct device *dev,
390typedef int (*espi_api_lpc_write_request)(
const struct device *dev,
394typedef int (*espi_api_send_vwire)(
const struct device *dev,
397typedef int (*espi_api_receive_vwire)(
const struct device *dev,
401typedef int (*espi_api_send_oob)(
const struct device *dev,
403typedef int (*espi_api_receive_oob)(
const struct device *dev,
406typedef int (*espi_api_flash_read)(
const struct device *dev,
408typedef int (*espi_api_flash_write)(
const struct device *dev,
410typedef int (*espi_api_flash_erase)(
const struct device *dev,
413typedef int (*espi_api_manage_callback)(
const struct device *dev,
414 struct espi_callback *callback,
417__subsystem
struct espi_driver_api {
418 espi_api_config config;
419 espi_api_get_channel_status get_channel_status;
420 espi_api_read_request read_request;
421 espi_api_write_request write_request;
422 espi_api_lpc_read_request read_lpc_request;
423 espi_api_lpc_write_request write_lpc_request;
424 espi_api_send_vwire send_vwire;
425 espi_api_receive_vwire receive_vwire;
426 espi_api_send_oob send_oob;
427 espi_api_receive_oob receive_oob;
431 espi_api_manage_callback manage_callback;
486static inline int z_impl_espi_config(
const struct device *dev,
489 const struct espi_driver_api *api =
490 (
const struct espi_driver_api *)dev->
api;
492 return api->config(dev, cfg);
510static inline bool z_impl_espi_get_channel_status(
const struct device *dev,
513 const struct espi_driver_api *api =
514 (
const struct espi_driver_api *)dev->
api;
516 return api->get_channel_status(dev, ch);
536static inline int z_impl_espi_read_request(
const struct device *dev,
539 const struct espi_driver_api *api =
540 (
const struct espi_driver_api *)dev->
api;
542 if (!api->read_request) {
546 return api->read_request(dev, req);
566static inline int z_impl_espi_write_request(
const struct device *dev,
569 const struct espi_driver_api *api =
570 (
const struct espi_driver_api *)dev->
api;
572 if (!api->write_request) {
576 return api->write_request(dev, req);
599static inline int z_impl_espi_read_lpc_request(
const struct device *dev,
603 const struct espi_driver_api *api =
604 (
const struct espi_driver_api *)dev->
api;
606 if (!api->read_lpc_request) {
610 return api->read_lpc_request(dev, op,
data);
632static inline int z_impl_espi_write_lpc_request(
const struct device *dev,
636 const struct espi_driver_api *api =
637 (
const struct espi_driver_api *)dev->
api;
639 if (!api->write_lpc_request) {
643 return api->write_lpc_request(dev, op,
data);
663static inline int z_impl_espi_send_vwire(
const struct device *dev,
667 const struct espi_driver_api *api =
668 (
const struct espi_driver_api *)dev->
api;
670 return api->send_vwire(dev,
signal, level);
689static inline int z_impl_espi_receive_vwire(
const struct device *dev,
693 const struct espi_driver_api *api =
694 (
const struct espi_driver_api *)dev->
api;
696 return api->receive_vwire(dev,
signal, level);
713static inline int z_impl_espi_send_oob(
const struct device *dev,
716 const struct espi_driver_api *api =
717 (
const struct espi_driver_api *)dev->
api;
719 if (!api->send_oob) {
723 return api->send_oob(dev, pckt);
740static inline int z_impl_espi_receive_oob(
const struct device *dev,
743 const struct espi_driver_api *api =
744 (
const struct espi_driver_api *)dev->
api;
746 if (!api->receive_oob) {
750 return api->receive_oob(dev, pckt);
769static inline int z_impl_espi_read_flash(
const struct device *dev,
772 const struct espi_driver_api *api =
773 (
const struct espi_driver_api *)dev->
api;
775 if (!api->flash_read) {
779 return api->flash_read(dev, pckt);
798static inline int z_impl_espi_write_flash(
const struct device *dev,
801 const struct espi_driver_api *api =
802 (
const struct espi_driver_api *)dev->
api;
804 if (!api->flash_write) {
808 return api->flash_write(dev, pckt);
827static inline int z_impl_espi_flash_erase(
const struct device *dev,
830 const struct espi_driver_api *api =
831 (
const struct espi_driver_api *)dev->
api;
833 if (!api->flash_erase) {
837 return api->flash_erase(dev, pckt);
912 __ASSERT(callback,
"Callback pointer should not be NULL");
913 __ASSERT(
handler,
"Callback handler pointer should not be NULL");
916 callback->evt_type = evt_type;
932 struct espi_callback *callback)
934 const struct espi_driver_api *api =
935 (
const struct espi_driver_api *)dev->
api;
937 if (!api->manage_callback) {
941 return api->manage_callback(dev, callback,
true);
961 struct espi_callback *callback)
963 const struct espi_driver_api *api =
964 (
const struct espi_driver_api *)dev->
api;
966 if (!api->manage_callback) {
970 return api->manage_callback(dev, callback,
false);
980#include <syscalls/espi.h>
void
Definition: eswifi_shell.c:15
int espi_read_flash(const struct device *dev, struct espi_flash_packet *pckt)
Sends a read request packet for shared flash.
espi_io_mode
eSPI I/O mode capabilities
Definition: espi.h:33
int espi_read_request(const struct device *dev, struct espi_request_packet *req)
Sends memory, I/O or message read request over eSPI.
int espi_write_request(const struct device *dev, struct espi_request_packet *req)
Sends memory, I/O or message write request over eSPI.
int espi_send_oob(const struct device *dev, struct espi_oob_packet *pckt)
Sends SMBus transaction (out-of-band) packet over eSPI bus.
espi_virtual_peripheral
eSPI peripheral notification type.
Definition: espi.h:154
void(* espi_callback_handler_t)(const struct device *dev, struct espi_callback *cb, struct espi_event espi_evt)
Define the application callback handler function signature.
Definition: espi.h:342
espi_bus_event
eSPI bus event.
Definition: espi.h:110
espi_cycle_type
eSPI cycle types supported over eSPI peripheral channel
Definition: espi.h:168
int espi_receive_oob(const struct device *dev, struct espi_oob_packet *pckt)
Receives SMBus transaction (out-of-band) packet from eSPI bus.
int espi_config(const struct device *dev, struct espi_cfg *cfg)
Configure operation of a eSPI controller.
static int espi_remove_callback(const struct device *dev, struct espi_callback *callback)
Remove an application callback.
Definition: espi.h:960
bool espi_get_channel_status(const struct device *dev, enum espi_channel ch)
Query to see if it a channel is ready.
int espi_write_lpc_request(const struct device *dev, enum lpc_peripheral_opcode op, uint32_t *data)
Writes data to a LPC peripheral which generates an eSPI transaction.
static void espi_init_callback(struct espi_callback *callback, espi_callback_handler_t handler, enum espi_bus_event evt_type)
Helper to initialize a struct espi_callback properly.
Definition: espi.h:908
int espi_receive_vwire(const struct device *dev, enum espi_vwire_signal signal, uint8_t *level)
Retrieves level status for a signal encapsulated in a virtual wire.
int espi_write_flash(const struct device *dev, struct espi_flash_packet *pckt)
Sends a write request packet for shared flash.
int espi_flash_erase(const struct device *dev, struct espi_flash_packet *pckt)
Sends a write request packet for shared flash.
espi_vwire_signal
eSPI system platform signals that can be send or receive through virtual wire channel
Definition: espi.h:184
static int espi_add_callback(const struct device *dev, struct espi_callback *callback)
Add an application callback.
Definition: espi.h:931
int espi_send_vwire(const struct device *dev, enum espi_vwire_signal signal, uint8_t level)
Sends system/platform signal as a virtual wire packet.
lpc_peripheral_opcode
Definition: espi.h:221
int espi_read_lpc_request(const struct device *dev, enum lpc_peripheral_opcode op, uint32_t *data)
Reads SOC data from a LPC peripheral with information updated over eSPI.
espi_channel
eSPI channel.
Definition: espi.h:98
@ ESPI_IO_MODE_QUAD_LINES
Definition: espi.h:36
@ ESPI_IO_MODE_SINGLE_LINE
Definition: espi.h:34
@ ESPI_IO_MODE_DUAL_LINES
Definition: espi.h:35
@ ESPI_PERIPHERAL_UART
Definition: espi.h:155
@ ESPI_PERIPHERAL_HOST_IO
Definition: espi.h:157
@ ESPI_PERIPHERAL_HOST_IO_PVT
Definition: espi.h:159
@ ESPI_PERIPHERAL_8042_KBC
Definition: espi.h:156
@ ESPI_PERIPHERAL_DEBUG_PORT80
Definition: espi.h:158
@ ESPI_BUS_EVENT_OOB_RECEIVED
Definition: espi.h:114
@ ESPI_BUS_EVENT_CHANNEL_READY
Definition: espi.h:112
@ ESPI_BUS_PERIPHERAL_NOTIFICATION
Definition: espi.h:115
@ ESPI_BUS_EVENT_VWIRE_RECEIVED
Definition: espi.h:113
@ ESPI_BUS_RESET
Definition: espi.h:111
@ ESPI_CYCLE_OK_COMPLETION_NODATA
Definition: espi.h:175
@ ESPI_CYCLE_NOK_COMPLETION_NODATA
Definition: espi.h:177
@ ESPI_CYCLE_MEMORY_WRITE32
Definition: espi.h:171
@ ESPI_CYCLE_MESSAGE_DATA
Definition: espi.h:174
@ ESPI_CYCLE_MEMORY_WRITE64
Definition: espi.h:172
@ ESPI_CYCLE_MEMORY_READ32
Definition: espi.h:169
@ ESPI_CYCLE_MESSAGE_NODATA
Definition: espi.h:173
@ ESPI_CYCLE_MEMORY_READ64
Definition: espi.h:170
@ ESPI_CYCLE_OKCOMPLETION_DATA
Definition: espi.h:176
@ ESPI_VWIRE_SIGNAL_PLTRST
Definition: espi.h:190
@ ESPI_VWIRE_SIGNAL_SUS_STAT
Definition: espi.h:191
@ ESPI_VWIRE_SIGNAL_RST_CPU_INIT
Definition: espi.h:211
@ ESPI_VWIRE_SIGNAL_SMIOUT
Definition: espi.h:193
@ ESPI_VWIRE_SIGNAL_SMI
Definition: espi.h:213
@ ESPI_VWIRE_SIGNAL_OOB_RST_WARN
Definition: espi.h:189
@ ESPI_VWIRE_SIGNAL_SLP_WLAN
Definition: espi.h:198
@ ESPI_VWIRE_SIGNAL_SLP_S4
Definition: espi.h:187
@ ESPI_VWIRE_SIGNAL_ERR_NON_FATAL
Definition: espi.h:207
@ ESPI_VWIRE_SIGNAL_DNX_ACK
Definition: espi.h:216
@ ESPI_VWIRE_SIGNAL_WAKE
Definition: espi.h:204
@ ESPI_VWIRE_SIGNAL_HOST_RST_ACK
Definition: espi.h:210
@ ESPI_VWIRE_SIGNAL_OOB_RST_ACK
Definition: espi.h:205
@ ESPI_VWIRE_SIGNAL_DNX_WARN
Definition: espi.h:201
@ ESPI_VWIRE_SIGNAL_SUS_WARN
Definition: espi.h:197
@ ESPI_VWIRE_SIGNAL_SLP_A
Definition: espi.h:195
@ ESPI_VWIRE_SIGNAL_PME
Definition: espi.h:203
@ ESPI_VWIRE_SIGNAL_SLV_BOOT_DONE
Definition: espi.h:209
@ ESPI_VWIRE_SIGNAL_ERR_FATAL
Definition: espi.h:208
@ ESPI_VWIRE_SIGNAL_SUS_PWRDN_ACK
Definition: espi.h:196
@ ESPI_VWIRE_SIGNAL_SLP_S3
Definition: espi.h:186
@ ESPI_VWIRE_SIGNAL_HOST_C10
Definition: espi.h:200
@ ESPI_VWIRE_SIGNAL_SLP_LAN
Definition: espi.h:199
@ ESPI_VWIRE_SIGNAL_SUS_ACK
Definition: espi.h:217
@ ESPI_VWIRE_SIGNAL_SLP_S5
Definition: espi.h:188
@ ESPI_VWIRE_SIGNAL_NMIOUT
Definition: espi.h:192
@ ESPI_VWIRE_SIGNAL_SLV_BOOT_STS
Definition: espi.h:206
@ ESPI_VWIRE_SIGNAL_HOST_RST_WARN
Definition: espi.h:194
@ ESPI_VWIRE_SIGNAL_SCI
Definition: espi.h:215
@ EACPI_READ_STS
Definition: espi.h:242
@ EACPI_WRITE_STS
Definition: espi.h:243
@ EACPI_IBF_HAS_CHAR
Definition: espi.h:238
@ EACPI_OBF_HAS_CHAR
Definition: espi.h:237
@ E8042_CLEAR_FLAG
Definition: espi.h:235
@ E8042_PAUSE_IRQ
Definition: espi.h:230
@ EACPI_WRITE_CHAR
Definition: espi.h:240
@ E8042_SET_FLAG
Definition: espi.h:234
@ E8042_READ_KB_STS
Definition: espi.h:233
@ E8042_WRITE_KB_CHAR
Definition: espi.h:226
@ E8042_WRITE_MB_CHAR
Definition: espi.h:227
@ E8042_IBF_HAS_CHAR
Definition: espi.h:224
@ E8042_OBF_HAS_CHAR
Definition: espi.h:223
@ E8042_RESUME_IRQ
Definition: espi.h:229
@ E8042_CLEAR_OBF
Definition: espi.h:231
@ ESPI_CHANNEL_OOB
Definition: espi.h:101
@ ESPI_CHANNEL_PERIPHERAL
Definition: espi.h:99
@ ESPI_CHANNEL_FLASH
Definition: espi.h:102
@ ESPI_CHANNEL_VWIRE
Definition: espi.h:100
int flash_erase(const struct device *dev, off_t offset, size_t size)
Erase part or all of a flash memory.
int flash_write(const struct device *dev, off_t offset, const void *data, size_t len)
Write buffer into flash memory.
int flash_read(const struct device *dev, off_t offset, void *data, size_t len)
Read data from flash.
#define BIT(n)
Unsigned integer with bit position n set (signed in assembly language).
Definition: util_macro.h:44
#define ENOTSUP
Definition: errno.h:115
struct _snode sys_snode_t
Definition: slist.h:33
#define bool
Definition: stdbool.h:13
__UINT32_TYPE__ uint32_t
Definition: stdint.h:60
__UINT8_TYPE__ uint8_t
Definition: stdint.h:58
__UINT16_TYPE__ uint16_t
Definition: stdint.h:59
Runtime device structure (in ROM) per driver instance.
Definition: device.h:367
const void * api
Definition: device.h:373
eSPI bus configuration parameters
Definition: espi.h:294
enum espi_io_mode io_caps
Definition: espi.h:296
enum espi_channel channel_caps
Definition: espi.h:298
uint8_t max_freq
Definition: espi.h:300
eSPI event
Definition: espi.h:282
uint32_t evt_data
Definition: espi.h:288
enum espi_bus_event evt_type
Definition: espi.h:284
uint32_t evt_details
Definition: espi.h:286
Bit field definition of evt_data in struct espi_event for ACPI.
Definition: espi.h:273
uint32_t data
Definition: espi.h:275
uint32_t type
Definition: espi.h:274
uint32_t reserved
Definition: espi.h:276
Bit field definition of evt_data in struct espi_event for KBC.
Definition: espi.h:263
uint32_t reserved
Definition: espi.h:267
uint32_t evt
Definition: espi.h:266
uint32_t data
Definition: espi.h:265
uint32_t type
Definition: espi.h:264
eSPI flash transactions packet format
Definition: espi.h:325
uint8_t * buf
Definition: espi.h:326
uint32_t flash_addr
Definition: espi.h:327
uint16_t len
Definition: espi.h:328
eSPI out-of-band transaction packet format
Definition: espi.h:317
uint8_t * buf
Definition: espi.h:318
uint16_t len
Definition: espi.h:319
eSPI peripheral request packet format
Definition: espi.h:306
uint8_t tag
Definition: espi.h:308
uint32_t address
Definition: espi.h:310
uint8_t * data
Definition: espi.h:311
enum espi_cycle_type cycle_type
Definition: espi.h:307
uint16_t len
Definition: espi.h:309
static fdata_t data[2]
Definition: test_fifo_contexts.c:15
static struct k_poll_signal signal
Definition: test_poll.c:696
static void handler(struct k_timer *timer)
Definition: main.c:19