5 Copyright (c) 2012 - 2014, Intel Corporation. All rights reserved
7 This program and the accompanying materials are licensed and made available under
8 the terms and conditions of the BSD License that accompanies this distribution.
9 The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php.
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
21 This file defines the EFI SPI Protocol which implements the
22 Intel(R) ICH SPI Host Controller Compatibility Interface.
30 #define EFI_SPI_PROTOCOL_GUID \
32 0x1156efc6, 0xea32, 0x4396, 0xb5, 0xd5, 0x26, 0x93, 0x2e, 0x83, 0xc3, 0x13 \
34 #define EFI_SMM_SPI_PROTOCOL_GUID \
36 0xD9072C35, 0xEB8F, 0x43ad, 0xA2, 0x20, 0x34, 0xD4, 0x0E, 0x2A, 0x82, 0x85 \
38 extern EFI_GUID gEfiSpiProtocolGuid
;
39 extern EFI_GUID gEfiSmmSpiProtocolGuid
;
42 /// Forward reference for ANSI C compatibility
44 typedef struct _EFI_SPI_PROTOCOL EFI_SPI_PROTOCOL
;
47 /// SPI protocol data structures and definitions
50 /// Number of Prefix Opcodes allowed on the SPI interface
52 #define SPI_NUM_PREFIX_OPCODE 2
55 /// Number of Opcodes in the Opcode Menu
57 #define SPI_NUM_OPCODE 8
61 /// EnumSpiOpcodeCommand: Command without address
62 /// EnumSpiOpcodeRead: Read with address
63 /// EnumSpiOpcodeWrite: Write with address
66 EnumSpiOpcodeReadNoAddr
,
67 EnumSpiOpcodeWriteNoAddr
,
76 EnumSpiCycle66MHz
, /// Not supported by VLV
79 } SPI_CYCLE_FREQUENCY
;
85 EnumSpiRegionDescriptor
,
86 EnumSpiRegionPlatformData
,
91 /// Hardware Sequencing required operations (as listed in Valleyview EDS "Hardware
92 /// Sequencing Commands and Opcode Requirements"
95 EnumSpiOperationWriteStatus
,
96 EnumSpiOperationProgramData_1_Byte
,
97 EnumSpiOperationProgramData_64_Byte
,
98 EnumSpiOperationReadData
,
99 EnumSpiOperationWriteDisable
,
100 EnumSpiOperationReadStatus
,
101 EnumSpiOperationWriteEnable
,
102 EnumSpiOperationFastRead
,
103 EnumSpiOperationEnableWriteStatus
,
104 EnumSpiOperationErase_256_Byte
,
105 EnumSpiOperationErase_4K_Byte
,
106 EnumSpiOperationErase_8K_Byte
,
107 EnumSpiOperationErase_64K_Byte
,
108 EnumSpiOperationFullChipErase
,
109 EnumSpiOperationJedecId
,
110 EnumSpiOperationDualOutputFastRead
,
111 EnumSpiOperationDiscoveryParameters
,
112 EnumSpiOperationOther
,
117 /// SPI Command Configuration
118 /// Frequency The expected frequency to be used (value to be programmed to the SSFC
120 /// Operation Which Hardware Sequencing required operation this opcode respoinds to.
121 /// The required operations are listed in EDS Table 5-55: "Hardware
122 /// Sequencing Commands and Opcode Requirements"
123 /// If the opcode does not corresponds to any operation listed, use
124 /// EnumSpiOperationOther, and provides TYPE and Code for it in
125 /// SpecialOpcodeEntry.
127 typedef struct _SPI_OPCODE_MENU_ENTRY
{
128 SPI_OPCODE_TYPE Type
;
130 SPI_CYCLE_FREQUENCY Frequency
;
131 SPI_OPERATION Operation
;
132 } SPI_OPCODE_MENU_ENTRY
;
135 // Initialization data table loaded to the SPI host controller
136 // VendorId Vendor ID of the SPI device
137 // DeviceId0 Device ID0 of the SPI device
138 // DeviceId1 Device ID1 of the SPI device
139 // PrefixOpcode Prefix opcodes which are loaded into the SPI host controller
140 // OpcodeMenu Opcodes which are loaded into the SPI host controller Opcode Menu
141 // BiosStartOffset The offset of the start of the BIOS image relative to the flash device.
142 // Please note this is a Flash Linear Address, NOT a memory space address.
143 // This value is platform specific and depends on the system flash map.
144 // This value is only used on non Descriptor mode.
145 // BiosSize The the BIOS Image size in flash. This value is platform specific
146 // and depends on the system flash map. Please note BIOS Image size may
147 // be smaller than BIOS Region size (in Descriptor Mode) or the flash size
148 // (in Non Descriptor Mode), and in this case, BIOS Image is supposed to be
149 // placed at the top end of the BIOS Region (in Descriptor Mode) or the flash
150 // (in Non Descriptor Mode)
152 typedef struct _SPI_INIT_TABLE
{
156 UINT8 PrefixOpcode
[SPI_NUM_PREFIX_OPCODE
];
157 SPI_OPCODE_MENU_ENTRY OpcodeMenu
[SPI_NUM_OPCODE
];
158 UINTN BiosStartOffset
;
163 // Protocol member functions
167 (EFIAPI
*EFI_SPI_INIT
) (
168 IN EFI_SPI_PROTOCOL
* This
,
169 IN SPI_INIT_TABLE
* InitTable
175 Initializes the host controller to execute SPI commands.
177 @param[in] This Pointer to the EFI_SPI_PROTOCOL instance.
178 @param[in] InitData Pointer to caller-allocated buffer containing the SPI
179 interface initialization table.
181 @retval EFI_SUCCESS Opcode initialization on the SPI host controller completed.
182 @retval EFI_ACCESS_DENIED The SPI configuration interface is locked.
183 @retval EFI_OUT_OF_RESOURCES Not enough resource available to initialize the device.
184 @retval EFI_DEVICE_ERROR Device error, operation failed.
190 (EFIAPI
*EFI_SPI_LOCK
) (
191 IN EFI_SPI_PROTOCOL
* This
196 Initializes the host controller to execute SPI commands.
198 @param[in] This Pointer to the EFI_SPI_PROTOCOL instance.
199 @param[in] InitData Pointer to caller-allocated buffer containing the SPI
200 interface initialization table.
202 @retval EFI_SUCCESS Opcode initialization on the SPI host controller completed.
203 @retval EFI_ACCESS_DENIED The SPI configuration interface is locked.
204 @retval EFI_OUT_OF_RESOURCES Not enough resource available to initialize the device.
205 @retval EFI_DEVICE_ERROR Device error, operation failed.
211 (EFIAPI
*EFI_SPI_EXECUTE
) (
212 IN EFI_SPI_PROTOCOL
* This
,
213 IN UINT8 OpcodeIndex
,
214 IN UINT8 PrefixOpcodeIndex
,
215 IN BOOLEAN DataCycle
,
219 IN UINT32 DataByteCount
,
220 IN OUT UINT8
*Buffer
,
221 IN SPI_REGION_TYPE SpiRegionType
226 Execute SPI commands from the host controller.
228 @param[in] This Pointer to the EFI_SPI_PROTOCOL instance.
229 @param[in] OpcodeIndex Index of the command in the OpCode Menu.
230 @param[in] PrefixOpcodeIndex Index of the first command to run when in an atomic cycle sequence.
231 @param[in] DataCycle TRUE if the SPI cycle contains data
232 @param[in] Atomic TRUE if the SPI cycle is atomic and interleave cycles are not allowed.
233 @param[in] ShiftOut If DataByteCount is not zero, TRUE to shift data out and FALSE to shift data in.
234 @param[in] Address In Descriptor Mode, for Descriptor Region, GbE Region, ME Region and Platform
235 Region, this value specifies the offset from the Region Base; for BIOS Region,
236 this value specifies the offset from the start of the BIOS Image. In Non
237 Descriptor Mode, this value specifies the offset from the start of the BIOS Image.
238 Please note BIOS Image size may be smaller than BIOS Region size (in Descriptor
239 Mode) or the flash size (in Non Descriptor Mode), and in this case, BIOS Image is
240 supposed to be placed at the top end of the BIOS Region (in Descriptor Mode) or
241 the flash (in Non Descriptor Mode)
242 @param[in] DataByteCount Number of bytes in the data portion of the SPI cycle.
243 @param[in] Buffer Pointer to caller-allocated buffer containing the dada received or sent during the SPI cycle.
244 @param[in] SpiRegionType SPI Region type. Values EnumSpiRegionBios, EnumSpiRegionGbE, EnumSpiRegionMe,
245 EnumSpiRegionDescriptor, and EnumSpiRegionPlatformData are only applicable in
246 Descriptor mode. Value EnumSpiRegionAll is applicable to both Descriptor Mode
247 and Non Descriptor Mode, which indicates "SpiRegionOffset" is actually relative
248 to base of the 1st flash device (i.e., it is a Flash Linear Address).
250 @retval EFI_SUCCESS Command succeed.
251 @retval EFI_INVALID_PARAMETER The parameters specified are not valid.
252 @exception EFI_UNSUPPORTED Command not supported.
253 @retval EFI_DEVICE_ERROR Device error, command aborts abnormally.
258 /// Protocol definition
260 struct _EFI_SPI_PROTOCOL
{
263 EFI_SPI_EXECUTE Execute
;