TianoCore EDK2 master
|
#include <PiDxe.h>
#include <Protocol/SpiNorFlash.h>
#include <Protocol/SpiIo.h>
#include <IndustryStandard/SpiNorFlashJedecSfdp.h>
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 } |
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.
#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.
#define SPI_NOR_FLASH_SIGNATURE SIGNATURE_32 ('s', 'n', 'f', 'm') |
Definition at line 18 of file SpiNorFlashJedecSfdpInternal.h.
enum SFDP_SEARCH_ERASE_TYPE |
Definition at line 40 of file SpiNorFlashJedecSfdpInternal.h.
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.
[in] | Instance | Spi Nor Flash Instance data with pointer to EFI_SPI_NOR_FLASH_PROTOCOL and EFI_SPI_IO_PROTOCOL |
[in] | FlashRegion | The region the flash address belong. |
[in] | FlashAddress | The target flash address. |
[in] | RemainingSize | Remaining size to erase. |
[in,out] | BlockSizeToErase | Input - The block erase size for this continious blocks. Output - The determined block size for erasing. |
[in,out] | BlockCountToErase | Input - The expected blocks to erase. Output - The determined number of blocks to erase. |
[out] | BlockEraseCommand | The erase command used for this continious blocks. |
[out] | TypicalTime | Pointer to receive the typical time in millisecond to erase this erase type size. |
[out] | MaximumTimeout | Pointer to receive the maximum timeout in millisecond to erase this erase type size. |
EFI_SUCCESS | The erase block attribute is returned. |
EFI_DEVICE_ERROR | No valid SFDP discovered. |
EFI_NOT_FOUND | No valud erase block attribute found. |
Definition at line 439 of file SpiNorFlashJedecSfdp.c.
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.
[in] | Instance | Spi Nor Flash Instance data with pointer to EFI_SPI_NOR_FLASH_PROTOCOL and EFI_SPI_IO_PROTOCOL |
[in,out] | FastReadInstruction | Fast Read instruction, the input is the default value. |
[in,out] | FastReadOperationClock | Fast Read operation clock, the input is the default value. |
[in,out] | FastReadDummyClocks | Fast Read wait state (Dummy clocks), the input is the default value. |
EFI_SUCCESS | The parameters are updated. |
EFI_NOT_FOUND | No desired Fas Read mode found. |
This routine returns the desired Fast Read mode.
[in] | Instance | Spi Nor Flash Instance data with pointer to EFI_SPI_NOR_FLASH_PROTOCOL and EFI_SPI_IO_PROTOCOL |
[in,out] | FastReadInstruction | Fast Read instruction, the input is the default value. |
[in,out] | FastReadModeBits | The operational mode bits. |
[in,out] | FastReadDummyClocks | Fast Read wait state (Dummy clocks), the input is the default value. |
EFI_SUCCESS | The parameters are updated. |
EFI_NOT_FOUND | No desired Fas Read mode found. |
Definition at line 1150 of file SpiNorFlashJedecSfdp.c.
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.
[in] | Instance | Spi Nor Flash Instance data with pointer to EFI_SPI_NOR_FLASH_PROTOCOL and EFI_SPI_IO_PROTOCOL |
[in] | FlashAddress | The target flash address. |
[out] | FlashRegion | The target flash address. |
EFI_SUCCESS | The region is returned. |
EFI_INVALID_PARAMETER | FlashAddress is not belong to any region. |
EFI_INVALID_PARAMETER | Other errors. |
Get the erase block attribute for the target address.
[in] | Instance | Spi Nor Flash Instance data with pointer to EFI_SPI_NOR_FLASH_PROTOCOL and EFI_SPI_IO_PROTOCOL |
[in] | FlashAddress | The target flash address. |
[out] | FlashRegion | The target flash address. |
EFI_SUCCESS | The region is returned. |
EFI_INVALID_PARAMETER | FlashAddress is not belong to any region. |
Otherwise | Other errors. |
Definition at line 503 of file SpiNorFlashJedecSfdp.c.
EFI_STATUS InitialSpiNorFlashSfdpInstance | ( | IN SPI_NOR_FLASH_INSTANCE * | Instance | ) |
Initial SPI_NOR_FLASH_INSTANCE structure.
[in] | Instance | Pointer to SPI_NOR_FLASH_INSTANCE. EFI_SPI_NOR_FLASH_PROTOCOL and EFI_SPI_IO_PROTOCOL |
EFI_SUCCESS | SPI_NOR_FLASH_INSTANCE is initialized according to SPI NOR Flash SFDP specification. |
Otherwisw | Failed to initial SPI_NOR_FLASH_INSTANCE structure. |
Initial SPI_NOR_FLASH_INSTANCE structure.
[in] | Instance | Pointer to SPI_NOR_FLASH_INSTANCE. EFI_SPI_NOR_FLASH_PROTOCOL and EFI_SPI_IO_PROTOCOL |
EFI_SUCCESS | SPI_NOR_FLASH_INSTANCE is initialized according to SPI NOR Flash SFDP specification. |
EFI_INVALID_PARAMETER | Instance = NULL or Instance->SpiIo == NULL or Instance->SpiIo->SpiPeripheral == NULL or Instance->SpiIo->SpiPeripheral->SpiBus == NULL or Instance->SpiIo->SpiPeripheral->SpiBus->ControllerPath. |
Otherwise | Failed to initial SPI_NOR_FLASH_INSTANCE structure. |
Definition at line 1710 of file SpiNorFlashJedecSfdp.c.
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.
[in] | Instance | Spi Nor Flash Instance data with pointer to EFI_SPI_NOR_FLASH_PROTOCOL and EFI_SPI_IO_PROTOCOL |
EFI_SUCCESS | Header is filled in |
EFI_DEVICE_ERROR | Invalid data received from SPI flash part. |
Definition at line 1289 of file SpiNorFlashJedecSfdp.c.
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.
[in] | Instance | Spi Nor Flash Instance data with pointer to EFI_SPI_NOR_FLASH_PROTOCOL and EFI_SPI_IO_PROTOCOL |
EFI_SUCCESS | The SPI part size is filled. |
EFI_DEVICE_ERROR | Invalid 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.
[in] | Instance | Spi Nor Flash Instance data with pointer to EFI_SPI_NOR_FLASH_PROTOCOL and EFI_SPI_IO_PROTOCOL |
EFI_SUCCESS | The SPI part size is filled. |
EFI_DEVICE_ERROR | Invalid data received from SPI flash part. |
EFI_NOT_FOUND | Parameter header is not found. |
Definition at line 1640 of file SpiNorFlashJedecSfdp.c.
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.
[in] | Instance | Spi Nor Flash Instance data with pointer to EFI_SPI_NOR_FLASH_PROTOCOL and EFI_SPI_IO_PROTOCOL |
EFI_SUCCESS | The SPI part size is filled. |
EFI_DEVICE_ERROR | Invalid 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.
[in] | Instance | Spi Nor Flash Instance data with pointer to EFI_SPI_NOR_FLASH_PROTOCOL and EFI_SPI_IO_PROTOCOL |
EFI_SUCCESS | The SPI part size is filled. |
EFI_DEVICE_ERROR | Invalid data received from SPI flash part. |
Definition at line 1572 of file SpiNorFlashJedecSfdp.c.
EFI_STATUS SetSectorEraseBlockSize | ( | IN SPI_NOR_FLASH_INSTANCE * | Instance | ) |
Set EraseBlockBytes in SPI NOR Flash Protocol
[in] | Instance | Spi Nor Flash Instance data with pointer to EFI_SPI_NOR_FLASH_PROTOCOL and EFI_SPI_IO_PROTOCOL |
EFI_SUCCESS | The erase block size is returned. |
Otherwise | Failed to get erase block size. |
Set EraseBlockBytes in SPI NOR Flash Protocol.
[in] | Instance | Spi Nor Flash Instance data with pointer to EFI_SPI_NOR_FLASH_PROTOCOL and EFI_SPI_IO_PROTOCOL |
EFI_SUCCESS | The erase block size is returned. |
Otherwise | Failed to get erase block size. |
Definition at line 768 of file SpiNorFlashJedecSfdp.c.
UINT32 SfdpGetFlashSize | ( | IN SPI_NOR_FLASH_INSTANCE * | Instance | ) |
Return flash device size from SFDP Basic Flash Parameter Table DWORD 2
[in] | Instance | Spi Nor Flash Instance data with pointer to EFI_SPI_NOR_FLASH_PROTOCOL and EFI_SPI_IO_PROTOCOL. |
UINT32 | Flash device size in byte, zero indicates error. |
Return the flash device size from SFDP Basic Flash Parameter Table DWORD 2.
[in] | Instance | Spi Nor Flash Instance data with pointer to EFI_SPI_NOR_FLASH_PROTOCOL and EFI_SPI_IO_PROTOCOL. |
UINT32 | Flash device size in byte, zero indicates error. |
Definition at line 1186 of file SpiNorFlashJedecSfdp.c.