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
122 Read data from the flash part.
124 @param[in] FlashRegionType The Flash Region type for flash cycle which is listed in the Descriptor.
125 @param[in] Address The Flash Linear Address must fall within a region for which BIOS has access permissions.
126 @param[in] ByteCount Number of bytes in the data portion of the SPI cycle.
127 @param[out] Buffer The Pointer to caller-allocated buffer containing the dada received.
128 It is the caller's responsibility to make sure Buffer is large enough for the total number of bytes read.
130 @retval EFI_SUCCESS Command succeed.
131 @retval EFI_INVALID_PARAMETER The parameters specified are not valid.
132 @retval EFI_DEVICE_ERROR Device error, command aborts abnormally.
137 IN FLASH_REGION_TYPE FlashRegionType
,
144 Erase some area on the flash part.
146 @param[in] FlashRegionType The Flash Region type for flash cycle which is listed in the Descriptor.
147 @param[in] Address The Flash Linear Address must fall within a region for which BIOS has access permissions.
148 @param[in] ByteCount Number of bytes in the data portion of the SPI cycle.
150 @retval EFI_SUCCESS Command succeed.
151 @retval EFI_INVALID_PARAMETER The parameters specified are not valid.
152 @retval EFI_DEVICE_ERROR Device error, command aborts abnormally.
157 IN FLASH_REGION_TYPE FlashRegionType
,
163 Write data to the flash part.
165 @param[in] FlashRegionType The Flash Region type for flash cycle which is listed in the Descriptor.
166 @param[in] Address The Flash Linear Address must fall within a region for which BIOS has access permissions.
167 @param[in] ByteCount Number of bytes in the data portion of the SPI cycle.
168 @param[in] Buffer Pointer to caller-allocated buffer containing the data sent during the SPI cycle.
170 @retval EFI_SUCCESS Command succeed.
171 @retval EFI_INVALID_PARAMETER The parameters specified are not valid.
172 @retval EFI_DEVICE_ERROR Device error, command aborts abnormally.
177 IN FLASH_REGION_TYPE FlashRegionType
,
184 Initialize an SPI library.
186 @retval EFI_SUCCESS The protocol instance was properly initialized
187 @retval EFI_NOT_FOUND The expected SPI info could not be found
196 Get the SPI region base and size, based on the enum type
198 @param[in] FlashRegionType The Flash Region type for for the base address which is listed in the Descriptor.
199 @param[out] BaseAddress The Flash Linear Address for the Region 'n' Base
200 @param[out] RegionSize The size for the Region 'n'
202 @retval EFI_SUCCESS Read success
203 @retval EFI_INVALID_PARAMETER Invalid region type given
204 @retval EFI_DEVICE_ERROR The region is not used
208 SpiGetRegionAddress (
209 IN FLASH_REGION_TYPE FlashRegionType
,
210 OUT UINT32
*BaseAddress OPTIONAL
,
211 OUT UINT32
*RegionSize OPTIONAL