TianoCore EDK2 master
Loading...
Searching...
No Matches
SpiNorFlashJedecSfdpInternal.h File Reference

Go to the source code of this file.

Data Structures

struct  SFPD_FAST_READ_CAPBILITY_RECORD
 
struct  SFDP_SUPPORTED_ERASE_TYPE_RECORD
 
struct  SFDP_SECTOR_MAP_DETECTION_RECORD
 
struct  SFDP_SECTOR_REGION_RECORD
 
struct  SFDP_SECTOR_MAP_RECORD
 
struct  SPI_NOR_FLASH_INSTANCE
 

Macros

#define SPI_NOR_FLASH_SIGNATURE   SIGNATURE_32 ('s', 'n', 'f', 'm')
 
#define SPI_NOR_FLASH_FROM_THIS(a)   CR (a, SPI_NOR_FLASH_INSTANCE, Protocol, SPI_NOR_FLASH_SIGNATURE)
 

Enumerations

enum  SFDP_SEARCH_ERASE_TYPE {
  SearchEraseTypeByType = 1 , SearchEraseTypeByCommand , SearchEraseTypeBySize , SearchEraseTypeBySmallestSize ,
  SearchEraseTypeByBiggestSize
}
 

Functions

EFI_STATUS GetFastReadParameter (IN SPI_NOR_FLASH_INSTANCE *Instance, IN OUT UINT8 *FastReadInstruction, IN OUT UINT8 *FastReadOperationClock, IN OUT UINT8 *FastReadDummyClocks)
 
EFI_STATUS ReadSfdpBasicParameterTable (IN SPI_NOR_FLASH_INSTANCE *Instance)
 
EFI_STATUS ReadSfdpSectorMapParameterTable (IN SPI_NOR_FLASH_INSTANCE *Instance)
 
UINT32 SfdpGetFlashSize (IN SPI_NOR_FLASH_INSTANCE *Instance)
 
EFI_STATUS ReadSfdp (IN SPI_NOR_FLASH_INSTANCE *Instance)
 
EFI_STATUS SetSectorEraseBlockSize (IN SPI_NOR_FLASH_INSTANCE *Instance)
 
EFI_STATUS GetEraseBlockAttribute (IN SPI_NOR_FLASH_INSTANCE *Instance, IN SFDP_SECTOR_REGION_RECORD *FlashRegion, IN UINT32 FlashAddress, IN UINT32 RemainingSize, IN OUT UINT32 *BlockSizeToErase, IN OUT UINT32 *BlockCountToErase, OUT UINT8 *BlockEraseCommand, OUT UINT32 *TypicalTime, OUT UINT64 *MaximumTimeout)
 
EFI_STATUS GetRegionByFlashAddress (IN SPI_NOR_FLASH_INSTANCE *Instance, IN UINT32 FlashAddress, OUT SFDP_SECTOR_REGION_RECORD **FlashRegion)
 
EFI_STATUS InitialSpiNorFlashSfdpInstance (IN SPI_NOR_FLASH_INSTANCE *Instance)
 

Detailed Description

SPI NOR flash driver internal definitions.

Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.

SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file SpiNorFlashJedecSfdpInternal.h.

Macro Definition Documentation

◆ SPI_NOR_FLASH_FROM_THIS

#define SPI_NOR_FLASH_FROM_THIS (   a)    CR (a, SPI_NOR_FLASH_INSTANCE, Protocol, SPI_NOR_FLASH_SIGNATURE)

Definition at line 20 of file SpiNorFlashJedecSfdpInternal.h.

◆ SPI_NOR_FLASH_SIGNATURE

#define SPI_NOR_FLASH_SIGNATURE   SIGNATURE_32 ('s', 'n', 'f', 'm')

Definition at line 18 of file SpiNorFlashJedecSfdpInternal.h.

Enumeration Type Documentation

◆ SFDP_SEARCH_ERASE_TYPE

enum SFDP_SEARCH_ERASE_TYPE

Definition at line 40 of file SpiNorFlashJedecSfdpInternal.h.

Function Documentation

◆ GetEraseBlockAttribute()

EFI_STATUS GetEraseBlockAttribute ( IN SPI_NOR_FLASH_INSTANCE Instance,
IN SFDP_SECTOR_REGION_RECORD FlashRegion,
IN UINT32  FlashAddress,
IN UINT32  RemainingSize,
IN OUT UINT32 *  BlockSizeToErase,
IN OUT UINT32 *  BlockCountToErase,
OUT UINT8 *  BlockEraseCommand,
OUT UINT32 *  TypicalTime,
OUT UINT64 *  MaximumTimeout 
)

Get the erase block attribute for the target address.

Parameters
[in]InstanceSpi Nor Flash Instance data with pointer to EFI_SPI_NOR_FLASH_PROTOCOL and EFI_SPI_IO_PROTOCOL
[in]FlashRegionThe region the flash address belong.
[in]FlashAddressThe target flash address.
[in]RemainingSizeRemaining size to erase.
[in,out]BlockSizeToEraseInput - The block erase size for this continious blocks. Output - The determined block size for erasing.
[in,out]BlockCountToEraseInput - The expected blocks to erase. Output - The determined number of blocks to erase.
[out]BlockEraseCommandThe erase command used for this continious blocks.
[out]TypicalTimePointer to receive the typical time in millisecond to erase this erase type size.
[out]MaximumTimeoutPointer to receive the maximum timeout in millisecond to erase this erase type size.
Return values
EFI_SUCCESSThe erase block attribute is returned.
EFI_DEVICE_ERRORNo valid SFDP discovered.
EFI_NOT_FOUNDNo valud erase block attribute found.

Definition at line 439 of file SpiNorFlashJedecSfdp.c.

◆ GetFastReadParameter()

EFI_STATUS GetFastReadParameter ( IN SPI_NOR_FLASH_INSTANCE Instance,
IN OUT UINT8 *  FastReadInstruction,
IN OUT UINT8 *  FastReadModeBits,
IN OUT UINT8 *  FastReadDummyClocks 
)

This routine returns the desired Fast Read mode.

Parameters
[in]InstanceSpi Nor Flash Instance data with pointer to EFI_SPI_NOR_FLASH_PROTOCOL and EFI_SPI_IO_PROTOCOL
[in,out]FastReadInstructionFast Read instruction, the input is the default value.
[in,out]FastReadOperationClockFast Read operation clock, the input is the default value.
[in,out]FastReadDummyClocksFast Read wait state (Dummy clocks), the input is the default value.
Return values
EFI_SUCCESSThe parameters are updated.
EFI_NOT_FOUNDNo desired Fas Read mode found.

This routine returns the desired Fast Read mode.

Parameters
[in]InstanceSpi Nor Flash Instance data with pointer to EFI_SPI_NOR_FLASH_PROTOCOL and EFI_SPI_IO_PROTOCOL
[in,out]FastReadInstructionFast Read instruction, the input is the default value.
[in,out]FastReadModeBitsThe operational mode bits.
[in,out]FastReadDummyClocksFast Read wait state (Dummy clocks), the input is the default value.
Return values
EFI_SUCCESSThe parameters are updated.
EFI_NOT_FOUNDNo desired Fas Read mode found.

Definition at line 1150 of file SpiNorFlashJedecSfdp.c.

◆ GetRegionByFlashAddress()

EFI_STATUS GetRegionByFlashAddress ( IN SPI_NOR_FLASH_INSTANCE Instance,
IN UINT32  FlashAddress,
OUT SFDP_SECTOR_REGION_RECORD **  FlashRegion 
)

Get the erase block attribute for the target address.

Parameters
[in]InstanceSpi Nor Flash Instance data with pointer to EFI_SPI_NOR_FLASH_PROTOCOL and EFI_SPI_IO_PROTOCOL
[in]FlashAddressThe target flash address.
[out]FlashRegionThe target flash address.
Return values
EFI_SUCCESSThe region is returned.
EFI_INVALID_PARAMETERFlashAddress is not belong to any region.
EFI_INVALID_PARAMETEROther errors.

Get the erase block attribute for the target address.

Parameters
[in]InstanceSpi Nor Flash Instance data with pointer to EFI_SPI_NOR_FLASH_PROTOCOL and EFI_SPI_IO_PROTOCOL
[in]FlashAddressThe target flash address.
[out]FlashRegionThe target flash address.
Return values
EFI_SUCCESSThe region is returned.
EFI_INVALID_PARAMETERFlashAddress is not belong to any region.
OtherwiseOther errors.

Definition at line 503 of file SpiNorFlashJedecSfdp.c.

◆ InitialSpiNorFlashSfdpInstance()

EFI_STATUS InitialSpiNorFlashSfdpInstance ( IN SPI_NOR_FLASH_INSTANCE Instance)

Initial SPI_NOR_FLASH_INSTANCE structure.

Parameters
[in]InstancePointer to SPI_NOR_FLASH_INSTANCE. EFI_SPI_NOR_FLASH_PROTOCOL and EFI_SPI_IO_PROTOCOL
Return values
EFI_SUCCESSSPI_NOR_FLASH_INSTANCE is initialized according to SPI NOR Flash SFDP specification.
OtherwiswFailed to initial SPI_NOR_FLASH_INSTANCE structure.

Initial SPI_NOR_FLASH_INSTANCE structure.

Parameters
[in]InstancePointer to SPI_NOR_FLASH_INSTANCE. EFI_SPI_NOR_FLASH_PROTOCOL and EFI_SPI_IO_PROTOCOL
Return values
EFI_SUCCESSSPI_NOR_FLASH_INSTANCE is initialized according to SPI NOR Flash SFDP specification.
EFI_INVALID_PARAMETERInstance = NULL or Instance->SpiIo == NULL or Instance->SpiIo->SpiPeripheral == NULL or Instance->SpiIo->SpiPeripheral->SpiBus == NULL or Instance->SpiIo->SpiPeripheral->SpiBus->ControllerPath.
OtherwiseFailed to initial SPI_NOR_FLASH_INSTANCE structure.

Definition at line 1710 of file SpiNorFlashJedecSfdp.c.

◆ ReadSfdp()

EFI_STATUS ReadSfdp ( IN SPI_NOR_FLASH_INSTANCE Instance)

Read SFDP This routine reads the JEDEC SPI Flash Discoverable Parameters. We just read the necessary tables in this routine.

Parameters
[in]InstanceSpi Nor Flash Instance data with pointer to EFI_SPI_NOR_FLASH_PROTOCOL and EFI_SPI_IO_PROTOCOL
Return values
EFI_SUCCESSHeader is filled in
EFI_DEVICE_ERRORInvalid data received from SPI flash part.

Definition at line 1289 of file SpiNorFlashJedecSfdp.c.

◆ ReadSfdpBasicParameterTable()

EFI_STATUS ReadSfdpBasicParameterTable ( IN SPI_NOR_FLASH_INSTANCE Instance)

Read SFDP parameters into buffer

This routine reads the JEDEC SPI Flash Discoverable Parameters from the SPI chip.

Parameters
[in]InstanceSpi Nor Flash Instance data with pointer to EFI_SPI_NOR_FLASH_PROTOCOL and EFI_SPI_IO_PROTOCOL
Return values
EFI_SUCCESSThe SPI part size is filled.
EFI_DEVICE_ERRORInvalid data received from SPI flash part.

Read SFDP Basic Parameters into buffer.

This routine reads the JEDEC SPI Flash Discoverable Parameters from the SPI chip.

Parameters
[in]InstanceSpi Nor Flash Instance data with pointer to EFI_SPI_NOR_FLASH_PROTOCOL and EFI_SPI_IO_PROTOCOL
Return values
EFI_SUCCESSThe SPI part size is filled.
EFI_DEVICE_ERRORInvalid data received from SPI flash part.
EFI_NOT_FOUNDParameter header is not found.

Definition at line 1640 of file SpiNorFlashJedecSfdp.c.

◆ ReadSfdpSectorMapParameterTable()

EFI_STATUS ReadSfdpSectorMapParameterTable ( IN SPI_NOR_FLASH_INSTANCE Instance)

Read SFDP Sector Map Parameter into buffer

This routine reads the JEDEC SPI Flash Discoverable Parameters from the SPI chip.

Parameters
[in]InstanceSpi Nor Flash Instance data with pointer to EFI_SPI_NOR_FLASH_PROTOCOL and EFI_SPI_IO_PROTOCOL
Return values
EFI_SUCCESSThe SPI part size is filled.
EFI_DEVICE_ERRORInvalid data received from SPI flash part.

Read SFDP Sector Map Parameter into buffer.

This routine reads the JEDEC SPI Flash Discoverable Parameters from the SPI chip.

Parameters
[in]InstanceSpi Nor Flash Instance data with pointer to EFI_SPI_NOR_FLASH_PROTOCOL and EFI_SPI_IO_PROTOCOL
Return values
EFI_SUCCESSThe SPI part size is filled.
EFI_DEVICE_ERRORInvalid data received from SPI flash part.

Definition at line 1572 of file SpiNorFlashJedecSfdp.c.

◆ SetSectorEraseBlockSize()

EFI_STATUS SetSectorEraseBlockSize ( IN SPI_NOR_FLASH_INSTANCE Instance)

Set EraseBlockBytes in SPI NOR Flash Protocol

Parameters
[in]InstanceSpi Nor Flash Instance data with pointer to EFI_SPI_NOR_FLASH_PROTOCOL and EFI_SPI_IO_PROTOCOL
Return values
EFI_SUCCESSThe erase block size is returned.
OtherwiseFailed to get erase block size.

Set EraseBlockBytes in SPI NOR Flash Protocol.

Parameters
[in]InstanceSpi Nor Flash Instance data with pointer to EFI_SPI_NOR_FLASH_PROTOCOL and EFI_SPI_IO_PROTOCOL
Return values
EFI_SUCCESSThe erase block size is returned.
OtherwiseFailed to get erase block size.

Definition at line 768 of file SpiNorFlashJedecSfdp.c.

◆ SfdpGetFlashSize()

UINT32 SfdpGetFlashSize ( IN SPI_NOR_FLASH_INSTANCE Instance)

Return flash device size from SFDP Basic Flash Parameter Table DWORD 2

Parameters
[in]InstanceSpi Nor Flash Instance data with pointer to EFI_SPI_NOR_FLASH_PROTOCOL and EFI_SPI_IO_PROTOCOL.
Return values
UINT32Flash device size in byte, zero indicates error.

Return the flash device size from SFDP Basic Flash Parameter Table DWORD 2.

Parameters
[in]InstanceSpi Nor Flash Instance data with pointer to EFI_SPI_NOR_FLASH_PROTOCOL and EFI_SPI_IO_PROTOCOL.
Return values
UINT32Flash device size in byte, zero indicates error.

Definition at line 1186 of file SpiNorFlashJedecSfdp.c.