]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - EmbeddedPkg/Include/Library/NorFlashInfoLib.h
EmbeddedPkg: Implement NorFlashInfoLib
[mirror_edk2.git] / EmbeddedPkg / Include / Library / NorFlashInfoLib.h
... / ...
CommitLineData
1/** @file\r
2*\r
3* Copyright (c) 2017 Marvell International Ltd.\r
4*\r
5* This program and the accompanying materials\r
6* are licensed and made available under the terms and conditions of the BSD License\r
7* which accompanies this distribution. The full text of the license may be found at\r
8* http://opensource.org/licenses/bsd-license.php\r
9*\r
10* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12*\r
13**/\r
14\r
15#ifndef __NOR_FLASH_ID_LIB_H__\r
16#define __NOR_FLASH_ID_LIB_H__\r
17\r
18#include <Uefi/UefiBaseType.h>\r
19\r
20#define NOR_FLASH_MAX_ID_LEN 6\r
21\r
22typedef struct {\r
23 /* Device name */\r
24 UINT16 *Name;\r
25\r
26 /*\r
27 * JEDEC ID\r
28 */\r
29 UINT8 Id[NOR_FLASH_MAX_ID_LEN];\r
30 UINT8 IdLen;\r
31\r
32 UINT16 PageSize;\r
33\r
34 /*\r
35 * Below parameters can be referred as BlockSize\r
36 * and BlockCount, when treating the NorFlash as\r
37 * block device.\r
38 */\r
39 UINT32 SectorSize;\r
40 UINT32 SectorCount;\r
41\r
42 UINT16 Flags;\r
43#define NOR_FLASH_ERASE_4K (1 << 0) /* Use 4 KB erase blocks and CMD_ERASE_4K */\r
44#define NOR_FLASH_ERASE_32K (1 << 1) /* Use 32 KB erase blocks and CMD_ERASE_32K */\r
45#define NOR_FLASH_WRITE_FSR (1 << 2) /* Use flag status register for write */\r
46#define NOR_FLASH_4B_ADDR (1 << 3) /* Use 4B addressing */\r
47} NOR_FLASH_INFO;\r
48\r
49/* Vendor IDs */\r
50#define NOR_FLASH_ID_ATMEL 0x1f\r
51#define NOR_FLASH_ID_EON 0x1c\r
52#define NOR_FLASH_ID_GIGADEVICE 0xc8\r
53#define NOR_FLASH_ID_ISSI 0x9d\r
54#define NOR_FLASH_ID_MACRONIX 0xc2\r
55#define NOR_FLASH_ID_SPANSION 0x01\r
56#define NOR_FLASH_ID_STMICRO 0x20\r
57#define NOR_FLASH_ID_SST 0xbf\r
58#define NOR_FLASH_ID_WINDBOND 0xef\r
59\r
60/**\r
61 Return an allocated copy pool of the NOR flash information structure.\r
62\r
63 @param[in] Id Pointer to an array with JEDEC ID obtained\r
64 from the NOR flash with READ_ID command\r
65 (0x9f)\r
66 @param[in out] FlashInfo Pointer to NOR flash information structure\r
67 @param[in] AllocateForRuntime A flag specifying a type of a copy pool\r
68 allocation (TRUE for runtime, FALSE for\r
69 normal)\r
70\r
71 @retval EFI_SUCCESS Operation completed successfully\r
72 @retval EFI_NOT_FOUND No matching entry in NOR ID table found\r
73 @retval EFI_OUT_OF_RESOURCES No pool memory available\r
74\r
75**/\r
76EFI_STATUS\r
77EFIAPI\r
78NorFlashGetInfo (\r
79 IN UINT8 *Id,\r
80 IN OUT NOR_FLASH_INFO **FlashInfo,\r
81 IN BOOLEAN AllocateForRuntime\r
82 );\r
83\r
84/**\r
85 Print NOR flash information basing on data stored in\r
86 the NOR_FLASH_INFO structure.\r
87\r
88 @param[in] FlashInfo Pointer to NOR flash information structure\r
89\r
90**/\r
91VOID\r
92EFIAPI\r
93NorFlashPrintInfo (\r
94 IN NOR_FLASH_INFO *Info\r
95 );\r
96#endif\r