Zephyr API Documentation 4.5.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches

Interfaces for Enhanced Serial Peripheral Interface (eSPI) target hardware. More...

Topics

 eSPI Driver Backend API
 eSPI Emulation Interface
 eSPI Emulation Interface
 eSPI SAF
 Interfaces for eSPI SAF (Serial Attached Flash) controllers.

Files

file  espi.h
 Main header file for eSPI (Enhanced Serial Peripheral Interface) driver API.
file  espi_realtek_rts5912.h
 Special operations for the Realtek RTS5912 ESPI driver.

Data Structures

struct  espi_evt_data_kbc
 Event data format for KBC events. More...
struct  espi_evt_data_acpi
 Event data format for ACPI events. More...
struct  espi_evt_data_pvt
 Event data format for Private Channel (PVT) events. More...
struct  espi_event
 eSPI event More...
struct  espi_cfg
 eSPI bus configuration parameters More...
struct  espi_request_packet
 eSPI peripheral request packet. More...
struct  espi_oob_packet
 eSPI out-of-band transaction packet format More...
struct  espi_flash_packet
 eSPI flash transactions packet format More...

Macros

#define ESPI_INT_ALL_MASK
 Selects all eSPI generic interrupts.
#define ESPI_INT_BUS_ONLY_MASK
 Selects only eSPI bus HW interrupts.
#define ESPI_INT_NONE_MASK   0U
 Disables all eSPI HW events.
#define HOST_KBC_EVT_IBF   BIT(0)
 KBC 8042 event: Input Buffer Full.
#define HOST_KBC_EVT_OBE   BIT(1)
 KBC 8042 event: Output Buffer Empty.
#define ESPI_EVENT_DATA_ACPI_TYPE_HOST_TO_EC_DATA   0
 ACPI event: Input Buffer Full.
#define ESPI_EVENT_DATA_ACPI_TYPE_HOST_TO_EC_CMD   1U
 ACPI event: Input Buffer Full.
#define ESPI_EVENT_DATA_ACPI_TYPE_HOST_RD_EC_TO_HOST   2U
 ACPI event: Output Buffer Empty: Host read data EC put in EC-to-Host register.

Typedefs

typedef 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.

Enumerations

enum  espi_io_mode { ESPI_IO_MODE_SINGLE_LINE = BIT(0) , ESPI_IO_MODE_DUAL_LINES = BIT(1) , ESPI_IO_MODE_QUAD_LINES = BIT(2) }
 eSPI I/O mode capabilities More...
enum  espi_channel { ESPI_CHANNEL_PERIPHERAL = BIT(0) , ESPI_CHANNEL_VWIRE = BIT(1) , ESPI_CHANNEL_OOB = BIT(2) , ESPI_CHANNEL_FLASH = BIT(3) }
 eSPI channel. More...
enum  espi_bus_event {
  ESPI_BUS_RESET = BIT(0) , ESPI_BUS_EVENT_CHANNEL_READY = BIT(1) , ESPI_BUS_EVENT_VWIRE_RECEIVED = BIT(2) , ESPI_BUS_EVENT_OOB_RECEIVED = BIT(3) ,
  ESPI_BUS_PERIPHERAL_NOTIFICATION = BIT(4) , ESPI_BUS_TAF_NOTIFICATION = BIT(5)
}
 eSPI bus event. More...
enum  espi_pc_event { ESPI_PC_EVT_BUS_CHANNEL_READY = BIT(0) , ESPI_PC_EVT_BUS_MASTER_ENABLE = BIT(1) }
 eSPI peripheral channel events. More...
enum  espi_virtual_peripheral {
  ESPI_PERIPHERAL_UART , ESPI_PERIPHERAL_8042_KBC , ESPI_PERIPHERAL_HOST_IO , ESPI_PERIPHERAL_DEBUG_PORT80 ,
  ESPI_PERIPHERAL_HOST_IO_PVT , ESPI_PERIPHERAL_HOST_IO_PVT2 , ESPI_PERIPHERAL_HOST_IO_PVT3 , ESPI_PERIPHERAL_EC_HOST_CMD
}
 eSPI peripheral notification type. More...
enum  espi_interrupt_flags {
  ESPI_BUS_EVENTS = BIT(0) , ESPI_VIRTUAL_WIRE_CHANNEL_EVENTS = BIT(1) , ESPI_OOB_CHANNEL_EVENTS = BIT(2) , ESPI_FLASH_CHANNEL_EVENTS = BIT(3) ,
  ESPI_PERIPHERAL_UART_EVENTS = BIT(4) , ESPI_PERIPHERAL_DEBUG_PORT80_EVENTS = BIT(5) , ESPI_PERIPHERAL_8042_KBC_EVENTS = BIT(6) , ESPI_PERIPHERAL_HOST_IO_EVENTS = BIT(7) ,
  ESPI_PERIPHERAL_SHARED_MEMORY_EVENTS = BIT(8)
}
 eSPI interrupt flags. More...
enum  espi_cycle_type {
  ESPI_CYCLE_MEMORY_READ32 , ESPI_CYCLE_MEMORY_READ64 , ESPI_CYCLE_MEMORY_WRITE32 , ESPI_CYCLE_MEMORY_WRITE64 ,
  ESPI_CYCLE_MESSAGE_NODATA , ESPI_CYCLE_MESSAGE_DATA , ESPI_CYCLE_OK_COMPLETION_NODATA , ESPI_CYCLE_OKCOMPLETION_DATA ,
  ESPI_CYCLE_NOK_COMPLETION_NODATA
}
 eSPI cycle types supported over eSPI peripheral channel More...
enum  espi_vwire_signal {
  ESPI_VWIRE_SIGNAL_SLP_S3 , ESPI_VWIRE_SIGNAL_SLP_S4 , ESPI_VWIRE_SIGNAL_SLP_S5 , ESPI_VWIRE_SIGNAL_OOB_RST_WARN ,
  ESPI_VWIRE_SIGNAL_PLTRST , ESPI_VWIRE_SIGNAL_SUS_STAT , ESPI_VWIRE_SIGNAL_NMIOUT , ESPI_VWIRE_SIGNAL_SMIOUT ,
  ESPI_VWIRE_SIGNAL_HOST_RST_WARN , ESPI_VWIRE_SIGNAL_SLP_A , ESPI_VWIRE_SIGNAL_SUS_PWRDN_ACK , ESPI_VWIRE_SIGNAL_SUS_WARN ,
  ESPI_VWIRE_SIGNAL_SLP_WLAN , ESPI_VWIRE_SIGNAL_SLP_LAN , ESPI_VWIRE_SIGNAL_HOST_C10 , ESPI_VWIRE_SIGNAL_DNX_WARN ,
  ESPI_VWIRE_SIGNAL_PME , ESPI_VWIRE_SIGNAL_WAKE , ESPI_VWIRE_SIGNAL_OOB_RST_ACK , ESPI_VWIRE_SIGNAL_TARGET_BOOT_STS ,
  ESPI_VWIRE_SIGNAL_ERR_NON_FATAL , ESPI_VWIRE_SIGNAL_ERR_FATAL , ESPI_VWIRE_SIGNAL_TARGET_BOOT_DONE , ESPI_VWIRE_SIGNAL_HOST_RST_ACK ,
  ESPI_VWIRE_SIGNAL_RST_CPU_INIT , ESPI_VWIRE_SIGNAL_SMI , ESPI_VWIRE_SIGNAL_SCI , ESPI_VWIRE_SIGNAL_DNX_ACK ,
  ESPI_VWIRE_SIGNAL_SUS_ACK , ESPI_VWIRE_SIGNAL_TARGET_GPIO_0 , ESPI_VWIRE_SIGNAL_TARGET_GPIO_1 , ESPI_VWIRE_SIGNAL_TARGET_GPIO_2 ,
  ESPI_VWIRE_SIGNAL_TARGET_GPIO_3 , ESPI_VWIRE_SIGNAL_TARGET_GPIO_4 , ESPI_VWIRE_SIGNAL_TARGET_GPIO_5 , ESPI_VWIRE_SIGNAL_TARGET_GPIO_6 ,
  ESPI_VWIRE_SIGNAL_TARGET_GPIO_7 , ESPI_VWIRE_SIGNAL_TARGET_GPIO_8 , ESPI_VWIRE_SIGNAL_TARGET_GPIO_9 , ESPI_VWIRE_SIGNAL_TARGET_GPIO_10 ,
  ESPI_VWIRE_SIGNAL_TARGET_GPIO_11 , ESPI_VWIRE_SIGNAL_COUNT
}
 eSPI system platform signals that can be sent or received through virtual wire channel More...
enum  lpc_peripheral_opcode {
  E8042_OBF_HAS_CHAR = 0x50 , E8042_IBF_HAS_CHAR , E8042_WRITE_KB_CHAR , E8042_WRITE_MB_CHAR ,
  E8042_RESUME_IRQ , E8042_PAUSE_IRQ , E8042_CLEAR_OBF , E8042_READ_KB_STS ,
  E8042_SET_FLAG , E8042_CLEAR_FLAG , E8042_READ_KB_CHAR , E8042_READ_MB_CHAR ,
  EACPI_OBF_HAS_CHAR = EACPI_START_OPCODE , EACPI_IBF_HAS_CHAR , EACPI_WRITE_CHAR , EACPI_READ_STS ,
  EACPI_WRITE_STS , EACPI_READ_CHAR , EACPI_RESUME_IRQ , EACPI_PAUSE_IRQ ,
  EACPI_GET_SHARED_MEMORY , ECUSTOM_HOST_SUBS_INTERRUPT_EN = ECUSTOM_START_OPCODE , ECUSTOM_HOST_CMD_GET_PARAM_MEMORY , ECUSTOM_HOST_CMD_GET_PARAM_MEMORY_SIZE ,
  ECUSTOM_HOST_CMD_SEND_RESULT
}
 eSPI LPC peripheral opcodes More...

Functions

int espi_config (const struct device *dev, struct espi_cfg *cfg)
 Configure operation of an eSPI device.
bool espi_get_channel_status (const struct device *dev, enum espi_channel ch)
 Query whether a logical channel is ready.
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_read_lpc_request (const struct device *dev, enum lpc_peripheral_opcode op, uint32_t *data)
 Reads SOC data from an LPC peripheral with information updated over eSPI.
int espi_write_lpc_request (const struct device *dev, enum lpc_peripheral_opcode op, uint32_t *data)
 Writes data to an LPC peripheral which generates an eSPI transaction.
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.
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_send_oob (const struct device *dev, struct espi_oob_packet *pckt)
 Sends SMBus transaction (out-of-band) packet over eSPI bus.
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_read_flash (const struct device *dev, struct espi_flash_packet *pckt)
 Sends a read request packet for shared flash.
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 an erase request packet for shared flash.
static void espi_init_callback (struct espi_callback *callback, espi_callback_handler_t handler, enum espi_bus_event evt_type)
 Callback model.
static int espi_add_callback (const struct device *dev, struct espi_callback *callback)
 Add an application callback.
static int espi_remove_callback (const struct device *dev, struct espi_callback *callback)
 Remove an application callback.
static int espi_interrupt_config (const struct device *dev, uint32_t espi_flags, uint32_t espi_vendor_flags)
 Control eSPI interrupts.

USB-C port over current signal aliases

#define ESPI_VWIRE_SIGNAL_OCB_0   ESPI_VWIRE_SIGNAL_TARGET_GPIO_0
 USB-C port 0 over current signal.
#define ESPI_VWIRE_SIGNAL_OCB_1   ESPI_VWIRE_SIGNAL_TARGET_GPIO_1
 USB-C port 1 over current signal.
#define ESPI_VWIRE_SIGNAL_OCB_2   ESPI_VWIRE_SIGNAL_TARGET_GPIO_2
 USB-C port 2 over current signal.
#define ESPI_VWIRE_SIGNAL_OCB_3   ESPI_VWIRE_SIGNAL_TARGET_GPIO_3
 USB-C port 3 over current signal.

Detailed Description

Interfaces for Enhanced Serial Peripheral Interface (eSPI) target hardware.

Since
2.0
Version
1.0.0

Macro Definition Documentation

◆ ESPI_EVENT_DATA_ACPI_TYPE_HOST_RD_EC_TO_HOST

#define ESPI_EVENT_DATA_ACPI_TYPE_HOST_RD_EC_TO_HOST   2U

#include <zephyr/drivers/espi.h>

ACPI event: Output Buffer Empty: Host read data EC put in EC-to-Host register.

◆ ESPI_EVENT_DATA_ACPI_TYPE_HOST_TO_EC_CMD

#define ESPI_EVENT_DATA_ACPI_TYPE_HOST_TO_EC_CMD   1U

#include <zephyr/drivers/espi.h>

ACPI event: Input Buffer Full.

Host wrote command register

◆ ESPI_EVENT_DATA_ACPI_TYPE_HOST_TO_EC_DATA

#define ESPI_EVENT_DATA_ACPI_TYPE_HOST_TO_EC_DATA   0

#include <zephyr/drivers/espi.h>

ACPI event: Input Buffer Full.

Host wrote a data register

◆ ESPI_INT_ALL_MASK

#define ESPI_INT_ALL_MASK

#include <zephyr/drivers/espi.h>

Value:
@ ESPI_PERIPHERAL_8042_KBC_EVENTS
Enables 8042 interrupt if HW supports it.
Definition espi.h:258
@ ESPI_BUS_EVENTS
Enables eSPI bus reset interrupts and channel negotiation changes.
Definition espi.h:239
@ ESPI_PERIPHERAL_DEBUG_PORT80_EVENTS
Enables Port80 eSPI interrupt if HW supports it.
Definition espi.h:256
@ ESPI_FLASH_CHANNEL_EVENTS
Enables eSPI Flash operations interrupt.
Definition espi.h:245
@ ESPI_OOB_CHANNEL_EVENTS
Enables eSPI OOB received interrupt.
Definition espi.h:243
@ ESPI_VIRTUAL_WIRE_CHANNEL_EVENTS
Enables eSPI VW received interrupt.
Definition espi.h:241
@ ESPI_PERIPHERAL_SHARED_MEMORY_EVENTS
Enables eSPI shared memory interrupt if HW supports it.
Definition espi.h:262
@ ESPI_PERIPHERAL_HOST_IO_EVENTS
Enables all ACPI eSPI host interface interrupt if HW supports it.
Definition espi.h:260

Selects all eSPI generic interrupts.

Note this does not include UART tunneled over eSPI interrupts Since this is usually desired by eSPI driver clients

◆ ESPI_INT_BUS_ONLY_MASK

#define ESPI_INT_BUS_ONLY_MASK

◆ ESPI_INT_NONE_MASK

#define ESPI_INT_NONE_MASK   0U

#include <zephyr/drivers/espi.h>

Disables all eSPI HW events.

◆ ESPI_VWIRE_SIGNAL_OCB_0

#define ESPI_VWIRE_SIGNAL_OCB_0   ESPI_VWIRE_SIGNAL_TARGET_GPIO_0

#include <zephyr/drivers/espi.h>

USB-C port 0 over current signal.

◆ ESPI_VWIRE_SIGNAL_OCB_1

#define ESPI_VWIRE_SIGNAL_OCB_1   ESPI_VWIRE_SIGNAL_TARGET_GPIO_1

#include <zephyr/drivers/espi.h>

USB-C port 1 over current signal.

◆ ESPI_VWIRE_SIGNAL_OCB_2

#define ESPI_VWIRE_SIGNAL_OCB_2   ESPI_VWIRE_SIGNAL_TARGET_GPIO_2

#include <zephyr/drivers/espi.h>

USB-C port 2 over current signal.

◆ ESPI_VWIRE_SIGNAL_OCB_3

#define ESPI_VWIRE_SIGNAL_OCB_3   ESPI_VWIRE_SIGNAL_TARGET_GPIO_3

#include <zephyr/drivers/espi.h>

USB-C port 3 over current signal.

◆ HOST_KBC_EVT_IBF

#define HOST_KBC_EVT_IBF   BIT(0)

#include <zephyr/drivers/espi.h>

KBC 8042 event: Input Buffer Full.

◆ HOST_KBC_EVT_OBE

#define HOST_KBC_EVT_OBE   BIT(1)

#include <zephyr/drivers/espi.h>

KBC 8042 event: Output Buffer Empty.

Typedef Documentation

◆ espi_callback_handler_t

typedef void(* espi_callback_handler_t) (const struct device *dev, struct espi_callback *cb, struct espi_event espi_evt)

#include <zephyr/drivers/espi.h>

Define the application callback handler function signature.

The handler should return quickly. Processing that is not time critical can be deferred, for example to a work queue. Deferring adds scheduling latency, so events that need a prompt response, such as eSPI bus reset and virtual wire events, should be handled in the handler.

Parameters
devDevice struct for the eSPI device.
cbOriginal struct espi_callback owning this handler.
espi_evtevent details that trigger the callback handler.

Enumeration Type Documentation

◆ espi_bus_event

#include <zephyr/drivers/espi.h>

eSPI bus event.

eSPI bus event to indicate events for which user can register callbacks

Enumerator
ESPI_BUS_RESET 

Indicates the eSPI bus was reset either via eSPI reset pin.

eSPI drivers should convey the eSPI reset status to eSPI driver clients following eSPI specification reset pin convention: 0-eSPI bus in reset, 1-eSPI bus out-of-reset

Note: There is no need to send this callback for in-band reset.

ESPI_BUS_EVENT_CHANNEL_READY 

Indicates the eSPI HW has received channel enable notification from eSPI controller, once the eSPI channel is signaled as ready to the eSPI controller, eSPI drivers should convey the eSPI channel ready to eSPI driver client via this event.

ESPI_BUS_EVENT_VWIRE_RECEIVED 

Indicates the eSPI HW has received a virtual wire message from eSPI controller.

eSPI drivers should convey the eSPI virtual wire latest status.

ESPI_BUS_EVENT_OOB_RECEIVED 

Indicates the eSPI HW has received a Out-of-band packet from eSPI controller.

ESPI_BUS_PERIPHERAL_NOTIFICATION 

Indicates the eSPI HW has received a peripheral eSPI host controller.

eSPI drivers should convey the peripheral type.

ESPI_BUS_TAF_NOTIFICATION 

Indicates the eSPI HW has received a Target Attached Flash (TAF) notification event.

◆ espi_channel

#include <zephyr/drivers/espi.h>

eSPI channel.

+----------------------------------------------------------------------+
| |
| eSPI controller +-------------+ |
| +-----------+ | Power | +----------+ |
| |Out of band| | management | | GPIO | |
| +------------+ |processor | | controller | | sources | |
| | SPI flash | +-----------+ +-------------+ +----------+ |
| | controller | | | | |
| +------------+ | | | |
| | | | +--------+ +---------------+ |
| | | | | | |
| | | +-----+ +--------+ +----------+ +----v-----+ |
| | | | | LPC | | Tunneled | | Tunneled | |
| | | | | bridge | | SMBus | | GPIO | |
| | | | +--------+ +----------+ +----------+ |
| | | | | | | |
| | | | ------+ | | |
| | | | | | | |
| | | +------v-----+ +---v-------v-------------v----+ |
| | | | eSPI Flash | | eSPI protocol block | |
| | | | access +--->+ | |
| | | +------------+ +------------------------------+ |
| | | | |
| | +-----------+ | |
| | v v |
| | XXXXXXXXXXXXXXXXXXXXXXX |
| | XXXXXXXXXXXXXXXXXXXXX |
| | XXXXXXXXXXXXXXXXXXX |
+----------------------------------------------------------------------+
| |
v +-----------------+
+---------+ | | | | | |
| Flash | | | | | | |
+---------+ | + + + + | eSPI bus
| CH0 CH1 CH2 CH3 | (logical channels)
| + + + + |
| | | | | |
+-----------------+
|
+-----------------------------------------------------------------------+
| eSPI target |
| |
| CH0 | CH1 | CH2 | CH3 |
| eSPI endpoint | VWIRE | OOB | Flash |
+-----------------------------------------------------------------------+

Identifies each eSPI logical channel supported by eSPI target hardware. Each channel allows independent traffic, but the assignment of channel type to channel number is fixed.

Note that generic commands are not associated with any channel, so traffic over eSPI can occur if all channels are disabled or not ready

Enumerator
ESPI_CHANNEL_PERIPHERAL 

Peripheral channel (channel 0).

ESPI_CHANNEL_VWIRE 

Virtual Wire channel (channel 1).

ESPI_CHANNEL_OOB 

Out-of-Band channel (channel 2).

ESPI_CHANNEL_FLASH 

Flash Access channel (channel 3).

◆ espi_cycle_type

#include <zephyr/drivers/espi.h>

eSPI cycle types supported over eSPI peripheral channel

Enumerator
ESPI_CYCLE_MEMORY_READ32 

32-bit memory read cycle

ESPI_CYCLE_MEMORY_READ64 

64-bit memory read cycle

ESPI_CYCLE_MEMORY_WRITE32 

32-bit memory write cycle

ESPI_CYCLE_MEMORY_WRITE64 

64-bit memory write cycle

ESPI_CYCLE_MESSAGE_NODATA 

Message cycle with no data.

ESPI_CYCLE_MESSAGE_DATA 

Message cycle with data.

ESPI_CYCLE_OK_COMPLETION_NODATA 

Successful completion with no data.

ESPI_CYCLE_OKCOMPLETION_DATA 

Successful completion with data.

ESPI_CYCLE_NOK_COMPLETION_NODATA 

Unsuccessful completion with no data.

◆ espi_interrupt_flags

#include <zephyr/drivers/espi.h>

eSPI interrupt flags.

Generic eSPI interrupt events selected with espi_interrupt_config(). Vendor-specific interrupt events are selected with the separate vendor-specific bitmap. These are defined and documented by each eSPI driver vendor.

Enumerator
ESPI_BUS_EVENTS 

Enables eSPI bus reset interrupts and channel negotiation changes.

ESPI_VIRTUAL_WIRE_CHANNEL_EVENTS 

Enables eSPI VW received interrupt.

ESPI_OOB_CHANNEL_EVENTS 

Enables eSPI OOB received interrupt.

ESPI_FLASH_CHANNEL_EVENTS 

Enables eSPI Flash operations interrupt.

ESPI_PERIPHERAL_UART_EVENTS 

Enables UART interrupt if HW supports it.

ESPI_PERIPHERAL_DEBUG_PORT80_EVENTS 

Enables Port80 eSPI interrupt if HW supports it.

The capture threshold that raises this interrupt could be set in devicetree, where the hardware supports it. The API does not support changing it at runtime, including through espi_interrupt_config().

ESPI_PERIPHERAL_8042_KBC_EVENTS 

Enables 8042 interrupt if HW supports it.

ESPI_PERIPHERAL_HOST_IO_EVENTS 

Enables all ACPI eSPI host interface interrupt if HW supports it.

ESPI_PERIPHERAL_SHARED_MEMORY_EVENTS 

Enables eSPI shared memory interrupt if HW supports it.

◆ espi_io_mode

#include <zephyr/drivers/espi.h>

eSPI I/O mode capabilities

Enumerator
ESPI_IO_MODE_SINGLE_LINE 

Single data line mode (traditional SPI).

ESPI_IO_MODE_DUAL_LINES 

Dual data line mode.

ESPI_IO_MODE_QUAD_LINES 

Quad data line mode.

◆ espi_pc_event

#include <zephyr/drivers/espi.h>

eSPI peripheral channel events.

eSPI peripheral channel event types to signal users.

Enumerator
ESPI_PC_EVT_BUS_CHANNEL_READY 

Bus channel ready event.

ESPI_PC_EVT_BUS_MASTER_ENABLE 

Bus master enable event.

◆ espi_virtual_peripheral

#include <zephyr/drivers/espi.h>

eSPI peripheral notification type.

eSPI peripheral notification event details to indicate which peripheral trigger the eSPI callback

Enumerator
ESPI_PERIPHERAL_UART 

UART peripheral.

ESPI_PERIPHERAL_8042_KBC 

8042 Keyboard peripheral

ESPI_PERIPHERAL_HOST_IO 

Host I/O peripheral.

ESPI_PERIPHERAL_DEBUG_PORT80 

Debug Port 80 peripheral.

ESPI_PERIPHERAL_HOST_IO_PVT 

Private Host I/O peripheral.

ESPI_PERIPHERAL_HOST_IO_PVT2 

Private Host I/O peripheral 2.

ESPI_PERIPHERAL_HOST_IO_PVT3 

Private Host I/O peripheral 3.

ESPI_PERIPHERAL_EC_HOST_CMD 

Embedded Controller Host Command peripheral.

Attention
Available only when the following Kconfig option is enabled: CONFIG_ESPI_PERIPHERAL_EC_HOST_CMD.

◆ espi_vwire_signal

#include <zephyr/drivers/espi.h>

eSPI system platform signals that can be sent or received through virtual wire channel

Enumerator
ESPI_VWIRE_SIGNAL_SLP_S3 

Sleep S3 state signal.

ESPI_VWIRE_SIGNAL_SLP_S4 

Sleep S4 state signal.

ESPI_VWIRE_SIGNAL_SLP_S5 

Sleep S5 state signal.

ESPI_VWIRE_SIGNAL_OOB_RST_WARN 

Out-of-band reset warning signal.

ESPI_VWIRE_SIGNAL_PLTRST 

Platform reset signal.

ESPI_VWIRE_SIGNAL_SUS_STAT 

Suspend status signal.

ESPI_VWIRE_SIGNAL_NMIOUT 

NMI output signal.

ESPI_VWIRE_SIGNAL_SMIOUT 

SMI output signal.

ESPI_VWIRE_SIGNAL_HOST_RST_WARN 

Host reset warning signal.

ESPI_VWIRE_SIGNAL_SLP_A 

Sleep A state signal.

ESPI_VWIRE_SIGNAL_SUS_PWRDN_ACK 

Suspend power down acknowledge signal.

ESPI_VWIRE_SIGNAL_SUS_WARN 

Suspend warning signal.

ESPI_VWIRE_SIGNAL_SLP_WLAN 

Sleep WLAN signal.

ESPI_VWIRE_SIGNAL_SLP_LAN 

Sleep LAN signal.

ESPI_VWIRE_SIGNAL_HOST_C10 

Host C10 state signal.

ESPI_VWIRE_SIGNAL_DNX_WARN 

DNX (Debug and eXception) warning signal.

ESPI_VWIRE_SIGNAL_PME 

Power Management Event signal.

ESPI_VWIRE_SIGNAL_WAKE 

Wake signal.

ESPI_VWIRE_SIGNAL_OOB_RST_ACK 

Out-of-band reset acknowledge signal.

ESPI_VWIRE_SIGNAL_TARGET_BOOT_STS 

Target boot status signal.

ESPI_VWIRE_SIGNAL_ERR_NON_FATAL 

Non-fatal error signal.

ESPI_VWIRE_SIGNAL_ERR_FATAL 

Fatal error signal.

ESPI_VWIRE_SIGNAL_TARGET_BOOT_DONE 

Target boot done signal.

ESPI_VWIRE_SIGNAL_HOST_RST_ACK 

Host reset acknowledge signal.

ESPI_VWIRE_SIGNAL_RST_CPU_INIT 

Reset CPU initialization signal.

ESPI_VWIRE_SIGNAL_SMI 

System Management Interrupt signal.

ESPI_VWIRE_SIGNAL_SCI 

System Control Interrupt signal.

ESPI_VWIRE_SIGNAL_DNX_ACK 

DNX acknowledge signal.

ESPI_VWIRE_SIGNAL_SUS_ACK 

Suspend acknowledge signal.

ESPI_VWIRE_SIGNAL_TARGET_GPIO_0 

Target GPIO 0 signal.

ESPI_VWIRE_SIGNAL_TARGET_GPIO_1 

Target GPIO 1 signal.

ESPI_VWIRE_SIGNAL_TARGET_GPIO_2 

Target GPIO 2 signal.

ESPI_VWIRE_SIGNAL_TARGET_GPIO_3 

Target GPIO 3 signal.

ESPI_VWIRE_SIGNAL_TARGET_GPIO_4 

Target GPIO 4 signal.

ESPI_VWIRE_SIGNAL_TARGET_GPIO_5 

Target GPIO 5 signal.

ESPI_VWIRE_SIGNAL_TARGET_GPIO_6 

Target GPIO 6 signal.

ESPI_VWIRE_SIGNAL_TARGET_GPIO_7 

Target GPIO 7 signal.

ESPI_VWIRE_SIGNAL_TARGET_GPIO_8 

Target GPIO 8 signal.

ESPI_VWIRE_SIGNAL_TARGET_GPIO_9 

Target GPIO 9 signal.

ESPI_VWIRE_SIGNAL_TARGET_GPIO_10 

Target GPIO 10 signal.

ESPI_VWIRE_SIGNAL_TARGET_GPIO_11 

Target GPIO 11 signal.

ESPI_VWIRE_SIGNAL_COUNT 

Number of Virtual Wire signals.

◆ lpc_peripheral_opcode

#include <zephyr/drivers/espi.h>

eSPI LPC peripheral opcodes

Opcodes for LPC peripheral operations that are tunneled through eSPI. These opcodes are used to interact with legacy LPC devices.

Enumerator
E8042_OBF_HAS_CHAR 

Check if 8042 output buffer has character.

E8042_IBF_HAS_CHAR 

Check if 8042 input buffer has character.

E8042_WRITE_KB_CHAR 

Write character to 8042 keyboard buffer.

E8042_WRITE_MB_CHAR 

Write character to 8042 mouse buffer.

E8042_RESUME_IRQ 

Resume 8042 interrupt processing.

E8042_PAUSE_IRQ 

Pause 8042 interrupt processing.

E8042_CLEAR_OBF 

Clear 8042 output buffer.

E8042_READ_KB_STS 

Read 8042 keyboard status.

E8042_SET_FLAG 

Set 8042 flag.

E8042_CLEAR_FLAG 

Clear 8042 flag.

E8042_READ_KB_CHAR 

Read character from 8042 keyboard buffer.

E8042_READ_MB_CHAR 

Read character from 8042 mouse buffer.

EACPI_OBF_HAS_CHAR 

Check if ACPI output buffer has character.

EACPI_IBF_HAS_CHAR 

Check if ACPI input buffer has character.

EACPI_WRITE_CHAR 

Write character to ACPI output buffer.

EACPI_READ_STS 

Read ACPI status.

EACPI_WRITE_STS 

Write ACPI status.

EACPI_READ_CHAR 

Read character from ACPI input buffer.

EACPI_RESUME_IRQ 

Resume ACPI interrupt processing.

EACPI_PAUSE_IRQ 

Pause ACPI interrupt processing.

EACPI_GET_SHARED_MEMORY 

Shared memory region support to return the ACPI response data.

Attention
Available only when the following Kconfig option is enabled: CONFIG_ESPI_PERIPHERAL_ACPI_SHM_REGION.
ECUSTOM_HOST_SUBS_INTERRUPT_EN 

Enable host subsystem interrupt (custom).

Attention
Available only when the following Kconfig option is enabled: CONFIG_ESPI_PERIPHERAL_CUSTOM_OPCODE.
Deprecated
Use espi_interrupt_config instead
ECUSTOM_HOST_CMD_GET_PARAM_MEMORY 

Get host command parameter memory (custom).

Attention
Available only when the following Kconfig option is enabled: CONFIG_ESPI_PERIPHERAL_CUSTOM_OPCODE.
ECUSTOM_HOST_CMD_GET_PARAM_MEMORY_SIZE 

Get host command parameter memory size (custom).

Attention
Available only when the following Kconfig option is enabled: CONFIG_ESPI_PERIPHERAL_CUSTOM_OPCODE.
ECUSTOM_HOST_CMD_SEND_RESULT 

Send host command result (custom).

Attention
Available only when the following Kconfig option is enabled: CONFIG_ESPI_PERIPHERAL_CUSTOM_OPCODE.

Function Documentation

◆ espi_add_callback()

int espi_add_callback ( const struct device * dev,
struct espi_callback * callback )
inlinestatic

#include <zephyr/drivers/espi.h>

Add an application callback.

Parameters
devPointer to the device structure for the driver instance.
callbackA valid Application's callback structure pointer.
Returns
0 if successful, negative errno code on failure.
Note
Callbacks may be added to the device from within a callback handler invocation, but whether they are invoked for the current eSPI event is not specified.

Note: enables to add as many callback as needed on the same device.

◆ espi_config()

int espi_config ( const struct device * dev,
struct espi_cfg * cfg )

#include <zephyr/drivers/espi.h>

Configure operation of an eSPI device.

This routine provides a generic interface to override eSPI hardware capabilities.

If this eSPI controller is acting as target, the values set here will be discovered as part through the GET_CONFIGURATION command issued by the eSPI controller during initialization.

If this eSPI controller is acting as controller, the values set here will be used by eSPI controller to determine minimum common capabilities with eSPI target then send via SET_CONFIGURATION command.

+---------+ +---------+ +------+ +---------+ +-------------+
| eSPI | | eSPI | | eSPI | | eSPI | | eSPI |
| target | | driver | | bus | | driver | | controller |
+---------+ +---------+ +------+ +---------+ +-------------+
| | | | |
| espi_config | Set eSPI | Set eSPI | espi_config |
+--------------+ ctrl regs | cap ctrl reg| +-----------+
| +-------+ | +--------+ |
| |<------+ | +------->| |
| | | | |
| | | | |
| | | GET_CONFIGURATION | |
| | +<------------------+ |
| |<-----------| | |
| | eSPI caps | | |
| |----------->+ response | |
| | |------------------>+ |
| | | | |
| | | SET_CONFIGURATION | |
| | +<------------------+ |
| | | accept | |
| | +------------------>+ |
+ + + + +
int espi_config(const struct device *dev, struct espi_cfg *cfg)
Configure operation of an eSPI device.
int accept(int sock, struct sockaddr *addr, socklen_t *addrlen)
Parameters
devPointer to the device structure for the driver instance.
cfgthe device runtime configuration for the eSPI controller.
Return values
0on success.
-EIOGeneral input / output error, failed to configure device.
-EINVALInvalid capabilities, failed to configure device.
-ENOTSUPCapability not supported by eSPI target.

◆ espi_flash_erase()

int espi_flash_erase ( const struct device * dev,
struct espi_flash_packet * pckt )

#include <zephyr/drivers/espi.h>

Sends an erase request packet for shared flash.

This routine provides an interface to send a request to erase the flash components shared between the eSPI controller and eSPI targets.

Parameters
devPointer to the device structure for the driver instance.
pcktAddress of the representation of erase flash transaction.
Return values
-ENOTSUPeSPI flash logical channel transactions not supported.
-EBUSYeSPI flash channel is not ready or disabled by controller.
-EIOGeneral input / output error, failed request to controller.

◆ espi_get_channel_status()

bool espi_get_channel_status ( const struct device * dev,
enum espi_channel ch )

#include <zephyr/drivers/espi.h>

Query whether a logical channel is ready.

This routine allows to check if logical channel is ready before use. Note that queries for channels not supported will always return false.

Parameters
devPointer to the device structure for the driver instance.
chthe eSPI channel for which status is to be retrieved.
Return values
trueIf eSPI channel is ready.
falseotherwise.

◆ espi_init_callback()

void espi_init_callback ( struct espi_callback * callback,
espi_callback_handler_t handler,
enum espi_bus_event evt_type )
inlinestatic

#include <zephyr/drivers/espi.h>

Callback model.

+-------------+ +-------------+ +--------+ +------------+
| Zephyr App | | eSPI driver | | eSPI | | eSPI |
| on | | | | target | | controller |
| eSPI target | | | | HW | | |
+---+---------+ +-------+-----+ +---+----+ +----+-------+
| | | |
+----------------------------> | | |
+----------------------------->+ | |
| | | eSPI reset | eSPI controller
| | IRQ +<--------------+ resets the
| | <-----------+ | bus
|<-----------------------------| | |
| Report eSPI bus reset | Processed | |
| | within the | |
| | driver | |
| | | |
| | | VW CH ready | eSPI controller
| | IRQ +<--------------+ enables VW
| | <-----------+ | channel
| | | |
| | Processed | |
| | within the | |
| | driver | |
| | | |
| | | Memory I/O | Peripheral
| | <---------------+ event
| +<------------+ |
+<-----------------------------+ callback | |
| Report peripheral event | | |
| and data for the event | | |
| | | |
| | | SLP_S5 | eSPI controller
| | <---------------+ send VWire
| +<------------+ |
+<-----------------------------+ callback | |
| App enables/configures | | |
| discrete regulator | | |
| | | |
| espi_send_vwire_signal | | |
+------------------------------>------------>|-------------->|
| | | |
| | | HOST_RST | eSPI controller
| | <---------------+ send VWire
| +<------------+ |
+<-----------------------------+ callback | |
| App reset host-related | | |
| data structures | | |
| | | |
| | | C10 | eSPI controller
| | +<--------------+ send VWire
| <-------------+ |
<------------------------------+ | |
| App executes | | |
+ power mgmt policy | | |
static void espi_init_callback(struct espi_callback *callback, espi_callback_handler_t handler, enum espi_bus_event evt_type)
Callback model.
Definition espi.h:1267
static int espi_add_callback(const struct device *dev, struct espi_callback *callback)
Add an application callback.
Definition espi.h:1290
ssize_t send(int sock, const void *buf, size_t len, int flags)

Helper to initialize an espi_callback structure properly.

Parameters
callbackA valid Application's callback structure pointer.
handlerA valid handler function pointer.
evt_typeindicates the eSPI event relevant for the handler. for VWIRE_RECEIVED event the data will indicate the new level asserted

◆ espi_interrupt_config()

int espi_interrupt_config ( const struct device * dev,
uint32_t espi_flags,
uint32_t espi_vendor_flags )
inlinestatic

#include <zephyr/drivers/espi.h>

Control eSPI interrupts.

This routine enables and disables the interrupt events of the eSPI driver: the eSPI bus and channel events, and the events of the eSPI peripheral channel hardware blocks.

Each call sets the complete set of enabled events. In both bitmaps, a bit set to 1 enables the corresponding event and a bit set to 0 disables it; the new set replaces the previous one. To disable some events and keep the others enabled, pass the events to keep enabled.

Default interrupt policy: during initialization, the driver enables the interrupts of the eSPI hardware blocks that are enabled in devicetree. Clients can change the enabled set at runtime with this routine.

Enabling and disabling take effect when this routine returns:

  • An enabled event whose hardware status is already pending is delivered immediately, without waiting for a new event.
  • Disabling an event stops its delivery. Hardware status that becomes pending while the event is disabled is kept where the hardware latches it, and is delivered once the event is enabled again.
  • Edge or level behavior is a property of each hardware source. A level source that stays asserted is delivered again after it is enabled; an edge source is delivered once per latched edge. Some sources stay asserted until serviced, for example the ACPI output buffer empty event; how the driver avoids their repeated delivery is driver specific.

This routine selects which events are delivered, not how they are reported: each callback receives a struct espi_event whose fields identify the source of the event.

After an eSPI bus reset, a client that changed the enabled set at runtime applies it again from its ESPI_BUS_RESET callback.

+---------+ +---------+ +------+ +---------+ +---------+
| eSPI | | eSPI | | eSPI | | eSPI | | eSPI |
| target | | driver | | bus | | driver | | host |
+--------+ +---------+ +------+ +---------+ +---------+
| | | | |
| +- eSPI---| | | |
+ +<- init--| | | |
| | | | |
| | | | |
| espi_config | Set eSPI | | |
+-------------------+ ctrl regs | | |
| +-------+ | | |
| |<------+ | | |
| | | | |
| interrupt_config | | | |
+-------------------+ | | |
| | | | | eSPI host
| | | VW packet +<------------+ sends VW
| | ISR | <-----------------+ |
| VWIRE_RECEIVED |<-----------| | |
+<------------------+ + + +
| | | | |
| | | | | eSPI host
| | | eSPI reset +<------------+ resets the
| | ISR | <-----------------+ | bus
| callback |<-----------| | |
+<------------------+ + + +
| | | | |
| interrupt_config | | | |
+-------------------+ | | |
Parameters
devPointer to the device structure for the driver instance.
espi_flagsBitmap of generic eSPI interrupt events, see espi_interrupt_flags.
espi_vendor_flagsBitmap of vendor-specific interrupt events, defined and documented by the eSPI driver vendor. 0 selects no vendor-specific event.
Return values
0If successful.
-EIOGeneral input / output error, failed to configure device.
-EINVALinvalid capabilities, failed to configure device.
-ENOTSUPcapability not supported by eSPI target.

◆ espi_read_flash()

int espi_read_flash ( const struct device * dev,
struct espi_flash_packet * pckt )

#include <zephyr/drivers/espi.h>

Sends a read request packet for shared flash.

This routine provides an interface to send a request to read the flash component shared between the eSPI controller and eSPI targets.

Parameters
devPointer to the device structure for the driver instance.
pcktAddress of the representation of read flash transaction.
Return values
-ENOTSUPeSPI flash logical channel transactions not supported.
-EBUSYeSPI flash channel is not ready or disabled by controller.
-EIOGeneral input / output error, failed request to controller.

◆ espi_read_lpc_request()

int espi_read_lpc_request ( const struct device * dev,
enum lpc_peripheral_opcode op,
uint32_t * data )

#include <zephyr/drivers/espi.h>

Reads SOC data from an LPC peripheral with information updated over eSPI.

This routine provides a generic interface to read a block whose information was updated by an eSPI transaction. Reading may trigger a transaction. The eSPI packet is assembled by the HW block.

Parameters
devPointer to the device structure for the driver instance.
opEnum representing opcode for peripheral type and read request.
dataParameter to be read from to the LPC peripheral.
Return values
0on success.
-ENOTSUPeSPI peripheral is off or not supported.
-EINVALFor unimplemented lpc opcode, but in range.

◆ espi_read_request()

int espi_read_request ( const struct device * dev,
struct espi_request_packet * req )

#include <zephyr/drivers/espi.h>

Sends memory, I/O or message read request over eSPI.

This routine provides a generic interface to send a read request packet.

Parameters
devPointer to the device structure for the driver instance.
reqAddress of structure representing a memory, I/O or message read request.
Return values
0on success.
-ENOTSUPeSPI controller doesn't support raw packets and instead low memory transactions are handled by controller hardware directly.
-EIOGeneral input / output error, failed to send over the bus.

◆ espi_receive_oob()

int espi_receive_oob ( const struct device * dev,
struct espi_oob_packet * pckt )

#include <zephyr/drivers/espi.h>

Receives SMBus transaction (out-of-band) packet from eSPI bus.

This routine provides an interface to receive and decode an SMBus transaction from eSPI bus

Parameters
devPointer to the device structure for the driver instance.
pcktAddress of the packet representation of SMBus transaction.
Return values
-EIOGeneral input / output error, failed request to controller.

◆ espi_receive_vwire()

int espi_receive_vwire ( const struct device * dev,
enum espi_vwire_signal signal,
uint8_t * level )

#include <zephyr/drivers/espi.h>

Retrieves level status for a signal encapsulated in a virtual wire.

This routine provides a generic interface to request a virtual wire packet from eSPI controller and retrieve the signal level.

Parameters
devPointer to the device structure for the driver instance.
signalthe signal to be requested from eSPI controller.
[out]levelthe level of signal requested 0b LOW, 1b HIGH.
Return values
-EIOGeneral input / output error, failed request to controller.

◆ espi_remove_callback()

int espi_remove_callback ( const struct device * dev,
struct espi_callback * callback )
inlinestatic

#include <zephyr/drivers/espi.h>

Remove an application callback.

Parameters
devPointer to the device structure for the driver instance.
callbackA valid application's callback structure pointer.
Returns
0 if successful, negative errno code on failure.
Warning
It is explicitly permitted, within a callback handler, to remove the registration for the callback that is running, i.e. callback. Attempts to remove other registrations on the same device may result in undefined behavior, including failure to invoke callbacks that remain registered and unintended invocation of removed callbacks.

Note: enables to remove as many callbacks as added through espi_add_callback().

◆ espi_send_oob()

int espi_send_oob ( const struct device * dev,
struct espi_oob_packet * pckt )

#include <zephyr/drivers/espi.h>

Sends SMBus transaction (out-of-band) packet over eSPI bus.

This routine provides an interface to encapsulate an SMBus transaction and send into packet over eSPI bus

Parameters
devPointer to the device structure for the driver instance.
pcktAddress of the packet representation of SMBus transaction.
Return values
-EIOGeneral input / output error, failed request to controller.

◆ espi_send_vwire()

int espi_send_vwire ( const struct device * dev,
enum espi_vwire_signal signal,
uint8_t level )

#include <zephyr/drivers/espi.h>

Sends system/platform signal as a virtual wire packet.

This routine provides a generic interface to send a virtual wire packet from target to controller.

The call is synchronous: it returns once the eSPI controller has read the new level of the virtual wire. Consecutive calls, such as the two edges of a pulse, need no delay between them. If the eSPI controller does not read the virtual wire within the driver timeout, the call returns -ETIMEDOUT and the new level stays set until the eSPI controller reads it.

The driver timeout bounds the wait, so the call never waits indefinitely for the eSPI controller. It is a time in microseconds, not a number of polls, defined by each driver as a constant or a vendor Kconfig option, with a default of 10 ms or less.

The eSPI target does not signal the transmission with an interrupt, so the driver polls for it with a busy wait that does not sleep. The call can be made from ISR context, where the wait adds up to the driver timeout to the interrupt latency. When the wait runs with interrupts locked, by the caller or by the driver, other interrupts are delayed by the same amount.

Parameters
devPointer to the device structure for the driver instance.
signalThe signal to be sent to eSPI controller.
levelThe level of signal requested. LOW (0) or HIGH (1).
Return values
0Virtual wire transmitted.
-EIOGeneral input / output error, failed to send over the bus.
-EINVALInvalid signal.
-ETIMEDOUTeSPI controller did not read the virtual wire within the driver timeout.

◆ espi_write_flash()

int espi_write_flash ( const struct device * dev,
struct espi_flash_packet * pckt )

#include <zephyr/drivers/espi.h>

Sends a write request packet for shared flash.

This routine provides an interface to send a request to write to the flash components shared between the eSPI controller and eSPI targets.

Parameters
devPointer to the device structure for the driver instance.
pcktAddress of the representation of write flash transaction.
Return values
-ENOTSUPeSPI flash logical channel transactions not supported.
-EBUSYeSPI flash channel is not ready or disabled by controller.
-EIOGeneral input / output error, failed request to controller.

◆ espi_write_lpc_request()

int espi_write_lpc_request ( const struct device * dev,
enum lpc_peripheral_opcode op,
uint32_t * data )

#include <zephyr/drivers/espi.h>

Writes data to an LPC peripheral which generates an eSPI transaction.

This routine provides a generic interface to write data to a block which triggers an eSPI transaction. The eSPI packet is assembled by the HW block.

Parameters
devPointer to the device structure for the driver instance.
opEnum representing an opcode for peripheral type and write request.
dataRepresents the parameter passed to the LPC peripheral.
Return values
0on success.
-ENOTSUPeSPI peripheral is off or not supported.
-EINVALFor unimplemented lpc opcode, but in range.

◆ espi_write_request()

int espi_write_request ( const struct device * dev,
struct espi_request_packet * req )

#include <zephyr/drivers/espi.h>

Sends memory, I/O or message write request over eSPI.

This routine provides a generic interface to send a write request packet.

Parameters
devPointer to the device structure for the driver instance.
reqAddress of structure representing a memory, I/O or message write request.
Return values
0on success.
-ENOTSUPeSPI controller doesn't support raw packets and instead low memory transactions are handled by controller hardware directly.
-EIOGeneral input / output error, failed to send over the bus.