UefiPayloadPkg[all]  0.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
SpiFlashLib.h File Reference

Enumerations

enum  FLASH_REGION_TYPE {
  FlashRegionDescriptor, FlashRegionBios, FlashRegionMe, FlashRegionGbE,
  FlashRegionPlatformData, FlashRegionDer, FlashRegionAll, FlashRegionMax
}
 

Functions

EFI_STATUS EFIAPI SpiFlashReadSfdp (IN UINT8 ComponentNumber, IN UINT32 ByteCount, OUT UINT8 *SfdpData)
 
EFI_STATUS EFIAPI SpiFlashReadJedecId (IN UINT8 ComponentNumber, IN UINT32 ByteCount, OUT UINT8 *JedecId)
 
EFI_STATUS EFIAPI SpiFlashWriteStatus (IN UINT32 ByteCount, IN UINT8 *StatusValue)
 
EFI_STATUS EFIAPI SpiFlashReadStatus (IN UINT32 ByteCount, OUT UINT8 *StatusValue)
 
EFI_STATUS EFIAPI SpiReadPchSoftStrap (IN UINT32 SoftStrapAddr, IN UINT32 ByteCount, OUT UINT8 *SoftStrapValue)
 
EFI_STATUS EFIAPI SpiFlashRead (IN FLASH_REGION_TYPE FlashRegionType, IN UINT32 Address, IN UINT32 ByteCount, OUT UINT8 *Buffer)
 
EFI_STATUS EFIAPI SpiFlashErase (IN FLASH_REGION_TYPE FlashRegionType, IN UINT32 Address, IN UINT32 ByteCount)
 
EFI_STATUS EFIAPI SpiFlashWrite (IN FLASH_REGION_TYPE FlashRegionType, IN UINT32 Address, IN UINT32 ByteCount, IN UINT8 *Buffer)
 
EFI_STATUS EFIAPI SpiConstructor (VOID)
 
EFI_STATUS EFIAPI SpiGetRegionAddress (IN FLASH_REGION_TYPE FlashRegionType, OUT UINT32 *BaseAddress, OUT UINT32 *RegionSize)
 

Detailed Description

PCH SPI Common Driver implements the SPI Host Controller Compatibility Interface.

Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Enumeration Type Documentation

Flash Region Type

Enumerator
FlashRegionDescriptor 
FlashRegionBios 
FlashRegionMe 
FlashRegionGbE 
FlashRegionPlatformData 
FlashRegionDer 
FlashRegionAll 
FlashRegionMax 

Function Documentation

EFI_STATUS EFIAPI SpiConstructor ( VOID  )

Initialize an SPI library.

Return values
EFI_SUCCESSThe protocol instance was properly initialized
EFI_NOT_FOUNDThe expected SPI info could not be found
EFI_STATUS EFIAPI SpiFlashErase ( IN FLASH_REGION_TYPE  FlashRegionType,
IN UINT32  Address,
IN UINT32  ByteCount 
)

Erase some area on the flash part.

Parameters
[in]FlashRegionTypeThe Flash Region type for flash cycle which is listed in the Descriptor.
[in]AddressThe Flash Linear Address must fall within a region for which BIOS has access permissions.
[in]ByteCountNumber of bytes in the data portion of the SPI cycle.
Return values
EFI_SUCCESSCommand succeed.
EFI_INVALID_PARAMETERThe parameters specified are not valid.
EFI_DEVICE_ERRORDevice error, command aborts abnormally.
EFI_STATUS EFIAPI SpiFlashRead ( IN FLASH_REGION_TYPE  FlashRegionType,
IN UINT32  Address,
IN UINT32  ByteCount,
OUT UINT8 *  Buffer 
)

Read data from the flash part.

Parameters
[in]FlashRegionTypeThe Flash Region type for flash cycle which is listed in the Descriptor.
[in]AddressThe Flash Linear Address must fall within a region for which BIOS has access permissions.
[in]ByteCountNumber of bytes in the data portion of the SPI cycle.
[out]BufferThe Pointer to caller-allocated buffer containing the dada received. It is the caller's responsibility to make sure Buffer is large enough for the total number of bytes read.
Return values
EFI_SUCCESSCommand succeed.
EFI_INVALID_PARAMETERThe parameters specified are not valid.
EFI_DEVICE_ERRORDevice error, command aborts abnormally.
EFI_STATUS EFIAPI SpiFlashReadJedecId ( IN UINT8  ComponentNumber,
IN UINT32  ByteCount,
OUT UINT8 *  JedecId 
)

Read Jedec Id from the flash part.

Parameters
[in]ComponentNumberThe Component Number for chip select
[in]ByteCountNumber of bytes in JedecId data portion of the SPI cycle, the data size is 3 typically
[out]JedecIdThe Pointer to caller-allocated buffer containing JEDEC ID received It is the caller's responsibility to make sure Buffer is large enough for the total number of bytes read.
Return values
EFI_SUCCESSCommand succeed.
EFI_INVALID_PARAMETERThe parameters specified are not valid.
EFI_DEVICE_ERRORDevice error, command aborts abnormally.
EFI_STATUS EFIAPI SpiFlashReadSfdp ( IN UINT8  ComponentNumber,
IN UINT32  ByteCount,
OUT UINT8 *  SfdpData 
)

Read SFDP data from the flash part.

Parameters
[in]ComponentNumberThe Component Number for chip select
[in]ByteCountNumber of bytes in SFDP data portion of the SPI cycle, the max number is 64
[out]SfdpDataThe Pointer to caller-allocated buffer containing the SFDP data received It is the caller's responsibility to make sure Buffer is large enough for the total number of bytes read.
Return values
EFI_SUCCESSCommand succeed.
EFI_INVALID_PARAMETERThe parameters specified are not valid.
EFI_DEVICE_ERRORDevice error, command aborts abnormally.
EFI_STATUS EFIAPI SpiFlashReadStatus ( IN UINT32  ByteCount,
OUT UINT8 *  StatusValue 
)

Read status register in the flash part.

Parameters
[in]ByteCountNumber of bytes in Status data portion of the SPI cycle, the data size is 1 typically
[out]StatusValueThe Pointer to caller-allocated buffer containing the value of Status register received.
Return values
EFI_SUCCESSCommand succeed.
EFI_INVALID_PARAMETERThe parameters specified are not valid.
EFI_DEVICE_ERRORDevice error, command aborts abnormally.
EFI_STATUS EFIAPI SpiFlashWrite ( IN FLASH_REGION_TYPE  FlashRegionType,
IN UINT32  Address,
IN UINT32  ByteCount,
IN UINT8 *  Buffer 
)

Write data to the flash part.

Parameters
[in]FlashRegionTypeThe Flash Region type for flash cycle which is listed in the Descriptor.
[in]AddressThe Flash Linear Address must fall within a region for which BIOS has access permissions.
[in]ByteCountNumber of bytes in the data portion of the SPI cycle.
[in]BufferPointer to caller-allocated buffer containing the data sent during the SPI cycle.
Return values
EFI_SUCCESSCommand succeed.
EFI_INVALID_PARAMETERThe parameters specified are not valid.
EFI_DEVICE_ERRORDevice error, command aborts abnormally.
EFI_STATUS EFIAPI SpiFlashWriteStatus ( IN UINT32  ByteCount,
IN UINT8 *  StatusValue 
)

Write the status register in the flash part.

Parameters
[in]ByteCountNumber of bytes in Status data portion of the SPI cycle, the data size is 1 typically
[in]StatusValueThe Pointer to caller-allocated buffer containing the value of Status register writing
Return values
EFI_SUCCESSCommand succeed.
EFI_INVALID_PARAMETERThe parameters specified are not valid.
EFI_DEVICE_ERRORDevice error, command aborts abnormally.
EFI_STATUS EFIAPI SpiGetRegionAddress ( IN FLASH_REGION_TYPE  FlashRegionType,
OUT UINT32 *  BaseAddress,
OUT UINT32 *  RegionSize 
)

Get the SPI region base and size, based on the enum type

Parameters
[in]FlashRegionTypeThe Flash Region type for for the base address which is listed in the Descriptor.
[out]BaseAddressThe Flash Linear Address for the Region 'n' Base
[out]RegionSizeThe size for the Region 'n'
Return values
EFI_SUCCESSRead success
EFI_INVALID_PARAMETERInvalid region type given
EFI_DEVICE_ERRORThe region is not used
EFI_STATUS EFIAPI SpiReadPchSoftStrap ( IN UINT32  SoftStrapAddr,
IN UINT32  ByteCount,
OUT UINT8 *  SoftStrapValue 
)

Read SC Soft Strap Values

Parameters
[in]SoftStrapAddrSC Soft Strap address offset from FPSBA.
[in]ByteCountNumber of bytes in SoftStrap data portion of the SPI cycle
[out]SoftStrapValueThe Pointer to caller-allocated buffer containing SC Soft Strap Value. It is the caller's responsibility to make sure Buffer is large enough for the total number of bytes read.
Return values
EFI_SUCCESSCommand succeed.
EFI_INVALID_PARAMETERThe parameters specified are not valid.
EFI_DEVICE_ERRORDevice error, command aborts abnormally.