]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EmbeddedPkg/Include/Library/NorFlashInfoLib.h
EmbeddedPkg: Implement NorFlashInfoLib
[mirror_edk2.git] / EmbeddedPkg / Include / Library / NorFlashInfoLib.h
diff --git a/EmbeddedPkg/Include/Library/NorFlashInfoLib.h b/EmbeddedPkg/Include/Library/NorFlashInfoLib.h
new file mode 100644 (file)
index 0000000..c376110
--- /dev/null
@@ -0,0 +1,96 @@
+/** @file\r
+*\r
+*  Copyright (c) 2017 Marvell International Ltd.\r
+*\r
+*  This program and the accompanying materials\r
+*  are licensed and made available under the terms and conditions of the BSD License\r
+*  which accompanies this distribution.  The full text of the license may be found at\r
+*  http://opensource.org/licenses/bsd-license.php\r
+*\r
+*  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+*  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+*\r
+**/\r
+\r
+#ifndef __NOR_FLASH_ID_LIB_H__\r
+#define __NOR_FLASH_ID_LIB_H__\r
+\r
+#include <Uefi/UefiBaseType.h>\r
+\r
+#define NOR_FLASH_MAX_ID_LEN    6\r
+\r
+typedef struct {\r
+  /* Device name */\r
+  UINT16 *Name;\r
+\r
+  /*\r
+   * JEDEC ID\r
+   */\r
+  UINT8  Id[NOR_FLASH_MAX_ID_LEN];\r
+  UINT8  IdLen;\r
+\r
+  UINT16 PageSize;\r
+\r
+  /*\r
+   * Below parameters can be referred as BlockSize\r
+   * and BlockCount, when treating the NorFlash as\r
+   * block device.\r
+   */\r
+  UINT32 SectorSize;\r
+  UINT32 SectorCount;\r
+\r
+  UINT16 Flags;\r
+#define NOR_FLASH_ERASE_4K     (1 << 0)  /* Use 4 KB erase blocks and CMD_ERASE_4K */\r
+#define NOR_FLASH_ERASE_32K    (1 << 1)  /* Use 32 KB erase blocks and CMD_ERASE_32K */\r
+#define NOR_FLASH_WRITE_FSR    (1 << 2)  /* Use flag status register for write */\r
+#define NOR_FLASH_4B_ADDR      (1 << 3)  /* Use 4B addressing */\r
+} NOR_FLASH_INFO;\r
+\r
+/* Vendor IDs */\r
+#define NOR_FLASH_ID_ATMEL      0x1f\r
+#define NOR_FLASH_ID_EON        0x1c\r
+#define NOR_FLASH_ID_GIGADEVICE 0xc8\r
+#define NOR_FLASH_ID_ISSI       0x9d\r
+#define NOR_FLASH_ID_MACRONIX   0xc2\r
+#define NOR_FLASH_ID_SPANSION   0x01\r
+#define NOR_FLASH_ID_STMICRO    0x20\r
+#define NOR_FLASH_ID_SST        0xbf\r
+#define NOR_FLASH_ID_WINDBOND   0xef\r
+\r
+/**\r
+  Return an allocated copy pool of the NOR flash information structure.\r
+\r
+  @param[in]       Id                 Pointer to an array with JEDEC ID obtained\r
+                                      from the NOR flash with READ_ID command\r
+                                      (0x9f)\r
+  @param[in out]   FlashInfo          Pointer to NOR flash information structure\r
+  @param[in]       AllocateForRuntime A flag specifying a type of a copy pool\r
+                                      allocation (TRUE for runtime, FALSE for\r
+                                      normal)\r
+\r
+  @retval       EFI_SUCCESS           Operation completed successfully\r
+  @retval       EFI_NOT_FOUND         No matching entry in NOR ID table found\r
+  @retval       EFI_OUT_OF_RESOURCES  No pool memory available\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+NorFlashGetInfo (\r
+  IN UINT8                *Id,\r
+  IN OUT NOR_FLASH_INFO  **FlashInfo,\r
+  IN BOOLEAN               AllocateForRuntime\r
+  );\r
+\r
+/**\r
+  Print NOR flash information basing on data stored in\r
+  the NOR_FLASH_INFO structure.\r
+\r
+  @param[in]       FlashInfo          Pointer to NOR flash information structure\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+NorFlashPrintInfo (\r
+  IN     NOR_FLASH_INFO  *Info\r
+  );\r
+#endif\r