2 PCH SPI Common Driver implements the SPI Host Controller Compatibility Interface.
4 Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #ifndef SPI_FLASH_LIB_H_
10 #define SPI_FLASH_LIB_H_
16 FlashRegionDescriptor
,
20 FlashRegionPlatformData
,
27 Read SFDP data from the flash part.
29 @param[in] ComponentNumber The Component Number for chip select
30 @param[in] ByteCount Number of bytes in SFDP data portion of the SPI cycle, the max number is 64
31 @param[out] SfdpData The Pointer to caller-allocated buffer containing the SFDP data received
32 It is the caller's responsibility to make sure Buffer is large enough for the total number of bytes read.
34 @retval EFI_SUCCESS Command succeed.
35 @retval EFI_INVALID_PARAMETER The parameters specified are not valid.
36 @retval EFI_DEVICE_ERROR Device error, command aborts abnormally.
41 IN UINT8 ComponentNumber
,
47 Read Jedec Id from the flash part.
49 @param[in] ComponentNumber The Component Number for chip select
50 @param[in] ByteCount Number of bytes in JedecId data portion of the SPI cycle, the data size is 3 typically
51 @param[out] JedecId The Pointer to caller-allocated buffer containing JEDEC ID received
52 It is the caller's responsibility to make sure Buffer is large enough for the total number of bytes read.
54 @retval EFI_SUCCESS Command succeed.
55 @retval EFI_INVALID_PARAMETER The parameters specified are not valid.
56 @retval EFI_DEVICE_ERROR Device error, command aborts abnormally.
61 IN UINT8 ComponentNumber
,
67 Write the status register in the flash part.
69 @param[in] ByteCount Number of bytes in Status data portion of the SPI cycle, the data size is 1 typically
70 @param[in] StatusValue The Pointer to caller-allocated buffer containing the value of Status register writing
72 @retval EFI_SUCCESS Command succeed.
73 @retval EFI_INVALID_PARAMETER The parameters specified are not valid.
74 @retval EFI_DEVICE_ERROR Device error, command aborts abnormally.
84 Read status register in the flash part.
86 @param[in] ByteCount Number of bytes in Status data portion of the SPI cycle, the data size is 1 typically
87 @param[out] StatusValue The Pointer to caller-allocated buffer containing the value of Status register received.
89 @retval EFI_SUCCESS Command succeed.
90 @retval EFI_INVALID_PARAMETER The parameters specified are not valid.
91 @retval EFI_DEVICE_ERROR Device error, command aborts abnormally.
97 OUT UINT8
*StatusValue
101 Read SC Soft Strap Values
103 @param[in] SoftStrapAddr SC Soft Strap address offset from FPSBA.
104 @param[in] ByteCount Number of bytes in SoftStrap data portion of the SPI cycle
105 @param[out] SoftStrapValue The Pointer to caller-allocated buffer containing SC Soft Strap Value.
106 It is the caller's responsibility to make sure Buffer is large enough for the total number of bytes read.
108 @retval EFI_SUCCESS Command succeed.
109 @retval EFI_INVALID_PARAMETER The parameters specified are not valid.
110 @retval EFI_DEVICE_ERROR Device error, command aborts abnormally.
114 SpiReadPchSoftStrap (
115 IN UINT32 SoftStrapAddr
,
117 OUT UINT8
*SoftStrapValue
121 Read data from the flash part.
123 @param[in] FlashRegionType The Flash Region type for flash cycle which is listed in the Descriptor.
124 @param[in] Address The Flash Linear Address must fall within a region for which BIOS has access permissions.
125 @param[in] ByteCount Number of bytes in the data portion of the SPI cycle.
126 @param[out] Buffer The Pointer to caller-allocated buffer containing the dada received.
127 It is the caller's responsibility to make sure Buffer is large enough for the total number of bytes read.
129 @retval EFI_SUCCESS Command succeed.
130 @retval EFI_INVALID_PARAMETER The parameters specified are not valid.
131 @retval EFI_DEVICE_ERROR Device error, command aborts abnormally.
136 IN FLASH_REGION_TYPE FlashRegionType
,
143 Erase some area on the flash part.
145 @param[in] FlashRegionType The Flash Region type for flash cycle which is listed in the Descriptor.
146 @param[in] Address The Flash Linear Address must fall within a region for which BIOS has access permissions.
147 @param[in] ByteCount Number of bytes in the data portion of the SPI cycle.
149 @retval EFI_SUCCESS Command succeed.
150 @retval EFI_INVALID_PARAMETER The parameters specified are not valid.
151 @retval EFI_DEVICE_ERROR Device error, command aborts abnormally.
156 IN FLASH_REGION_TYPE FlashRegionType
,
162 Write data to the flash part.
164 @param[in] FlashRegionType The Flash Region type for flash cycle which is listed in the Descriptor.
165 @param[in] Address The Flash Linear Address must fall within a region for which BIOS has access permissions.
166 @param[in] ByteCount Number of bytes in the data portion of the SPI cycle.
167 @param[in] Buffer Pointer to caller-allocated buffer containing the data sent during the SPI cycle.
169 @retval EFI_SUCCESS Command succeed.
170 @retval EFI_INVALID_PARAMETER The parameters specified are not valid.
171 @retval EFI_DEVICE_ERROR Device error, command aborts abnormally.
176 IN FLASH_REGION_TYPE FlashRegionType
,
183 Initialize an SPI library.
185 @retval EFI_SUCCESS The protocol instance was properly initialized
186 @retval EFI_NOT_FOUND The expected SPI info could not be found
195 Get the SPI region base and size, based on the enum type
197 @param[in] FlashRegionType The Flash Region type for for the base address which is listed in the Descriptor.
198 @param[out] BaseAddress The Flash Linear Address for the Region 'n' Base
199 @param[out] RegionSize The size for the Region 'n'
201 @retval EFI_SUCCESS Read success
202 @retval EFI_INVALID_PARAMETER Invalid region type given
203 @retval EFI_DEVICE_ERROR The region is not used
207 SpiGetRegionAddress (
208 IN FLASH_REGION_TYPE FlashRegionType
,
209 OUT UINT32
*BaseAddress OPTIONAL
,
210 OUT UINT32
*RegionSize OPTIONAL