文章目录
前言
本文主要是参照Intel提供的eSPI规范的1.5版本进行编写,需要该版本规范的可以从下面链接中下载:
点击这里下载
介绍
eSPI全称Enhanced Serial Peripheral Interface,即增强型串行外设接口,是Intel在2016年推出的新一代总线接口,是为了替代LPC而设计。eSPI总线是根据SPI总线修改而来的。
eSPI总线的电气特性与SPI总线的电气特性类似,但有些偏差。
当eSPI Reset# de-asserted时, CLK必须在Chip Select# asserted边缘处处于低电平。当CLK仍然处于低电平时,从controller启动第一个数据,并由target在时钟的第一个上升沿上采样。后续数据由controller在CLK的下降沿发射,target在时钟的上升沿采样。
eSPI上的所有事务必须是8位(一个字节)的倍数。
基本协议
eSPI事务包含了一个由controller驱动的命令阶段、一个周转(TAR)阶段和一个由target驱动的响应阶段。
命令阶段,包含了一个CMD、一个可选报头(HDR)、一个可选数据和一个CRC。
响应阶段,包含了一个RSP、一个可选报头(HDR)、一个可选数据、一个状态和一个CRC。
所有eSPI事务都必须生成CRC,其中CRC字节总是在总线上传输。但是,复位后CRC检查默认为禁用,可以通过SET_CONFIGURATION使能。当禁用CRC检查时,接收方忽略CRC字节。
eSPI中包含了4个通道,如下图。
Peripheral Channel(Channel 0):为了兼容LPC总线通讯而设计,支持I/O、Memory访问。为KBC、ECI、UART、ShareMemory等Super I/O逻辑外设提供了访问基础。
Virtual Wire Channel(Channel 1):为了取消x86平台的一些实体功能引脚,转而采用数据包的方式在Master和Slave直接传递引脚状态。例如SCI、SLP_S3、SLP_S4、PLTRST#、SERIRQ等。
OOB(Tunneled SMBus) Message(Channel 2):采用一个通用的数据包格式,在Master和Slave之间传递大宗数据。
Run-time Flash Access Channel(Channel 3):为了解决Master和Slave之间SPI Flash共享的问题,以此降低成本。
Alert Event
Target可以通过向Controller发送Alert event信号来启动事务。Alert event可以通过两种方式发出信号。
在single controller - single target配置中,I/O[1]引脚可以被target用来指示Alert event。当target需要请求controller的服务时,可以将I/O[1]由tri-state切换到Low并一直保持到Chip Select#拉Low;一旦Chip Select#拉Low后,target必须释放掉I/O[1]的所有权。
在single controller - Multiple targets配置中,需要一个专用的Alert#引脚。
命令阶段
eSPI controller在命令阶段向target发起事务,或响应target发出的Alert event。命令阶段包含了一个CMD、一个可选报头(HDR)、一个可选数据和一个CRC。
CMD字段由一个字节的命令操作码组成。用于指示通道特定的命令和通讯链路管理事件。如果target接收到一个带有无效命令操作码的数据包,则target必须不响应该事务。事务将使用总线上的默认响应(NO_RESPONSE)终止。
CMD Opcode | Encoding[7:0] | Description |
---|---|---|
eSPI Peripheral Channel | ||
PUT_PC | 0000_0000 | Put a posted or completion header and optional data. Note: It is illegal to issue a PUT_PC unless the target has indicated that it is free to take the Posted or Completion packet. |
PUT_NP | 0000_0010 | Put a non-posted header and optional data. Note: It is illegal to issue a PUT_NP unless the target has indicated that it is free to take the Non-Posted packet. |
GET_PC | 0000_0001 | Get a posted or completion header and optional data. Note: It is illegal to issue a GET_PC unless the target has indicated that it has a Posted or Completion packet available. |
GET_NP | 0000_0011 | Get a non-posted header and optional data. Note: It is illegal to issue a GET_NP unless the target has indicated that it has a Non-Posted packet available. |
PUT_IORD_SHORT | 0100_00C1C01 | Put a short(1, 2 or 4 bytes) non-posted I/O Read packet. Note: It is illegal to issue a PUT_IORD_SHORT unless the target has indicated that it is free to take the Non-Posted packet. |
PUT_IOWR_SHORT | 0100_01C1C01 | Put a short(1, 2 or 4 bytes) non-posted I/O Write packet. Note: It is illegal to issue a PUT_IOWR_SHORT unless the target has indicated that it is free to take the Non-posted packet. |
PUT_MEMRD32_SHORT | 0100_10C1C01 | Put a short(1, 2 or 4 bytes) non-posted Memory Read 32 packet. Note: It is illegal to issue a PUT_MEMRD32_SHORT unless the target has indicated that it is free to take the Non-Posted packet. |
PUT_MEMWR32_SHORT | 0100_11C1C01 | Put a short(1, 2 or 4 bytes) posted Memory Write 32 packet. Note: It is illegal to issue a PUT_MEMWR32_SHORT unless the target has indicated that it is free to take the Posted or Completion packet. |
Virtual Wire Channel | ||
PUT_VWIRE | 0000_0100 | Put a Tunneled virtual wire packet. |
GET_VWIRE | 0000_0101 | Get a Tunneled virtual wire packket. |
OOB Message Channel | ||
PUT_OOB | 0000_0110 | Put an OOB(Tunneled SMBus) message. Note: It is illegal to issue a PUT_OOB unless the target has indicated that it is free to take the OOB message. |
GET_OOB | 0000_0111 | Get an OOB(Tunneled SMBus) message. Note: It is illegal to issue a GET_OOB unless the target has indicated that it has an OOB message available to send. |
Flash Access Channel | ||
PUT_FLASH_C | 0000_1000 | Put a Flash Access completion. Used in Controller Attached Flash Sharing mode for the controller to return a flash access completion to the target. Note: It is illegal to issue a PUT_FLASH_C unless the target has indicated that it is free to take the Flash Access completion. |
GET_FLASH_NP | 0000_1001 | Get a non-posted Flash Access request. Used in Controller Attached Flash Sharing mode for the target to issue a flash access request to the controller. Note: It is illegal to issue a GET_FLASH_NP unless the target has indicated that it has a non-posted Flash Access request available to send. |
PUT_FLASH_NP | 0000_1010 | Put a non-posted Flash Access request. Used in Target Attached Flash Sharing mode for the controller to issue a flash access request to the target. Note: It is illegal to issue a PUT_FLASH_NP unless the target has indicated that it is free to take the non-posted Flash Access request. |
GET_FLASH_C | 0000_1011 | Get a Flash Access completion. Used in Target Attached Flash Sharing mode for the target to return a flash access completion to the controller. Note: It is illegal to issue a GET_FLASH_C unless the target has indicated that it has a Flash Access completion available to send. |
Channel Independent2 | ||
GET_STATUS | 0010_0101 | Command initiated by the controller to read the status register of the target. |
SET_CONFIGURATION | 0010_0010 | Command to set the capabilities of the target as part of the initialization. This is typically done after the controller discovers the capabilities of the target. |
GET_CONFIGURATION | 0010_0001 | Command to discover the capabilities of the target ass part of the initialization. |
RESET | 1111_1111 | In-band RESET command. |
注意:
1. 操作码编码C1C01表示请求的长度。地址和长度不能跨越DWord边界。
Encoding[1:0] C1C0 | Request Length |
---|---|
00 | 1 byte |
01 | 2 bytes |
10 | Reserved |
11 | 4 bytes |
2. 该部分命令与通道无关,在eSPI Reset# deassertion后启用。
Turn-Around(TAR)
在命令阶段的最后一位在数据线上发出后,数据线进入Turn-Around window。eSPI controller需要将所有数据线驱动到逻辑’1’,用于Turn-Around window的第一个时钟,然后将数据线置于tri-state。Turn-Around window的时钟数量固定为2个串行时钟。
响应阶段
响应阶段由eSPI target驱动,以响应eSPI controller发起得命令。该阶段由一个RSP操作码、可选报头(HDR)、可选数据、状态和CRC组成。
RSP操作码
RSP操作码是一个8位字段,由一个响应码和一个响应修饰符组成,如下图:
RESPONSE | Encoding | Description | ||
---|---|---|---|---|
[7:6] | [5:4] | [3:0] | ||
ACCEPT | R1R01 | RSV | 1000 | Command was successfully received. If the command was a PUT_NP, a response of ACCEPT means that the non-posted transaction is being completed as a "connected" transaction. |
DEFFER | 00 | RSV | 0001 | Only valid in response to a PUT_NP. A non-posted command was successfully received, and completing the non-posted transaction is deferred to a future split completion. |
NON_FATAL_ERROR | 00 | RSV | 0010 | The received command had an error with non-fatal severity. The error does not affect the ability to process the received command. |
FATAL_ERROR | 00 | RSV | 0011 | The received command had a fatal error that prevented the transaction layer packet from being successfully processed. Fatal errors include malformed transactions, Put without Free, Get without Avail and so forth. |
WAIT_STATE | 00 | RSV | 1111 | Adds one byte-time of delay when responding to a transaction on the bus. |
NO_RESPONSE | 11 | 11 | 1111 | The response encoding of all 1's is defined as no response. It is the default response to the GET_CONFIGURATION when no target is present as a result of the weak pull-up on the data lines. It is also the default response when fatal CRC error is detected on the command packet, or when command opcode is not supported and the target must not drive the response phase. |
注意:
1.响应编码R1R0始终为“00”,但具有ACCEPT响应的GET_STATUS除外,该响应具有以下定义:
Encoding[7:6] R1R0 | Description |
---|---|
00 | No append. |
01 | A peripheral(channel 0) completion is appended. |
10 | A Virtual Wire(channel 1) packet is appended. |
11 | A Flash Access(channel 3) completion is appended. This is only applicable when target attached flash sharing is supported and in operation. |
状态
16位Status字段用于提供信息,例如来自target的新挂起请求和队列空闲信息。该字段反映了在总线上传输状态字段时target的实时状态。
STATUS | Bits Position | Description |
---|---|---|
Target's Rx queues Free | ||
PC_FREE | 0 | When '1', indicates the target is free to accept at least one channel 0 peripheral posted or completion header and data up to maximum payload size. |
NP_FREE | 1 | When '1', indicates the target is free to accept at least one channel 0 peripheral non-posted header and 1 DW of Data(if applicable). |
VWIRE_FREE | 2 | This bit must be always a '1'. Tunneling of channel 1 virtual wires is not flow controller. |
OOB_FREE | 3 | When '1', indicates the target is free to accept at least one channel 2 OOB(tunneled SMBus) message with data up to maximum payload size. |
Target's Tx queues Available | ||
PC_AVAIL | 4 | When '1', indicates the target has a channel 0 peripheral posted or completion header and optional data up to maximum payload size available to send. |
NP_AVAIL | 5 | When '1', indicates the target has a channel o peripheral non-posted header available to send. |
VWIRE_AVAIL | 6 | When '1', indicates the target has a channel 1 tunneled virtual wire available to send. |
OOB_AVAIL | 7 | When '1', indicates the target has a channel 2 OOB(tunneled SMBus) message with data up to maximum payload size available to send. |
Target's Rx queues Free | ||
FLASH_C_FREE | 8 | When '1', indicates the target is free to accept at least one channel 3 Flash Access completion header and data up to maximum payload size. This bit must be always a '1'. The target must be able to accept the completion for the non-posted request it sends. This bit is only applicable when controller attached flash sharing is supported and in operation. Otherwise, the bit is a don't care. |
FLASH_NP_FREE | 9 | When '1', indicates the target is free to accept at least one channel 3 Flash Access non-posted header and data up to maximum payload size. This bit is only applicable when target attached flash sharing is supported and in operation. Otherwise, the bit is a don't care. |
Reserved | 11:10 | Reserved. |
Target's Tx queues Available | ||
FLASH_C_AVAIL | 12 | When '1', indicates the target has a channel 3 Flash Access completion header and data up to maximum payload size available to send. This bit is only applicable when target attached flash sharing is supported and in operation. Otherwise, the bit is a don't care. |
FLASH_NP_AVAIL | 13 | When '1', indicates the target has a channel 3 Flash Access non-posted header and data up to maximum payload size available to send. This bit is only applicable when controller attached flash sharing is supported and in operation. Otherwise, the bit is a don't care. |
Reserved | 15:14 | Reserved. |
等待状态
在响应阶段,eSPI target的所有事务都支持WAIT_STATEs。在2个时钟循环(TAR)窗口之后,eSPI target在使用ACCEPT、DEFER、NON_FATAL_ERROR或FATAL_ERROR终止事务之前,允许使用WAIT_STATE响应码进行响应。在响应阶段开始时,eSPI target可以插入一个或多个WAIT_STATE响应码,直至eSPI controller配置的最大WAIT_STATE值。
WAIT_STATE响应码提供的额外延迟是一个字节时间,它分别对应于Single Mode下的8个串行时钟,Dual Mode下的4个串行时钟,Quad Mode下的2两个串行时钟。
Capabilities and Configuration Registers
功能和配置寄存器位通过eSPI reset#复位。GET_CONFIGURATION和SET_CONFIGURATION命令用于访问这些寄存器。当使用SET_CONFIGURATION命令配置寄存器时,target的新寄存器值将仅在Chip Select# deasserted时生效。
从偏移量800h到FFFh的寄存器被保留为特定于平台。这为特定于平台的应用程序提供了2KB的寄存器空间。
具体每个寄存器的内容大家可以查看spec。
Start(Hex) | End(Hex) | Register Name |
---|---|---|
000 | 003 | Reserved |
004 | 007 | Device Identification |
008 | 00B | General Capabilities and Configurations |
00C | 00F | Reserved |
010 | 013 | Channel 0 Capabilites and Configurations |
014 | 01F | Reserved |
020 | 023 | Channel 1 Capabilites and Configurations |
024 | 02F | Reserved |
030 | 033 | Channel 2 Capabilites and Configurations |
034 | 03F | Reserved |
040 | 043 | Channel 3 Capabilites and Configurations |
044 | 7FF | Reserved |