EmbeddedPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / EmbeddedPkg / Include / Library / NorFlashInfoLib.h
1 /** @file
2 *
3 * Copyright (c) 2017 Marvell International Ltd.
4 *
5 * SPDX-License-Identifier: BSD-2-Clause-Patent
6 *
7 **/
8
9 #ifndef __NOR_FLASH_ID_LIB_H__
10 #define __NOR_FLASH_ID_LIB_H__
11
12 #include <Uefi/UefiBaseType.h>
13
14 #define NOR_FLASH_MAX_ID_LEN 6
15
16 typedef struct {
17 /* Device name */
18 UINT16 *Name;
19
20 /*
21 * JEDEC ID
22 */
23 UINT8 Id[NOR_FLASH_MAX_ID_LEN];
24 UINT8 IdLen;
25
26 UINT16 PageSize;
27
28 /*
29 * Below parameters can be referred as BlockSize
30 * and BlockCount, when treating the NorFlash as
31 * block device.
32 */
33 UINT32 SectorSize;
34 UINT32 SectorCount;
35
36 UINT16 Flags;
37 #define NOR_FLASH_ERASE_4K (1 << 0) /* Use 4 KB erase blocks and CMD_ERASE_4K */
38 #define NOR_FLASH_ERASE_32K (1 << 1) /* Use 32 KB erase blocks and CMD_ERASE_32K */
39 #define NOR_FLASH_WRITE_FSR (1 << 2) /* Use flag status register for write */
40 #define NOR_FLASH_4B_ADDR (1 << 3) /* Use 4B addressing */
41 } NOR_FLASH_INFO;
42
43 /* Vendor IDs */
44 #define NOR_FLASH_ID_ATMEL 0x1f
45 #define NOR_FLASH_ID_EON 0x1c
46 #define NOR_FLASH_ID_GIGADEVICE 0xc8
47 #define NOR_FLASH_ID_ISSI 0x9d
48 #define NOR_FLASH_ID_MACRONIX 0xc2
49 #define NOR_FLASH_ID_SPANSION 0x01
50 #define NOR_FLASH_ID_STMICRO 0x20
51 #define NOR_FLASH_ID_SST 0xbf
52 #define NOR_FLASH_ID_WINDBOND 0xef
53
54 /**
55 Return an allocated copy pool of the NOR flash information structure.
56
57 @param[in] Id Pointer to an array with JEDEC ID obtained
58 from the NOR flash with READ_ID command
59 (0x9f)
60 @param[in out] FlashInfo Pointer to NOR flash information structure
61 @param[in] AllocateForRuntime A flag specifying a type of a copy pool
62 allocation (TRUE for runtime, FALSE for
63 normal)
64
65 @retval EFI_SUCCESS Operation completed successfully
66 @retval EFI_NOT_FOUND No matching entry in NOR ID table found
67 @retval EFI_OUT_OF_RESOURCES No pool memory available
68
69 **/
70 EFI_STATUS
71 EFIAPI
72 NorFlashGetInfo (
73 IN UINT8 *Id,
74 IN OUT NOR_FLASH_INFO **FlashInfo,
75 IN BOOLEAN AllocateForRuntime
76 );
77
78 /**
79 Print NOR flash information basing on data stored in
80 the NOR_FLASH_INFO structure.
81
82 @param[in] FlashInfo Pointer to NOR flash information structure
83
84 **/
85 VOID
86 EFIAPI
87 NorFlashPrintInfo (
88 IN NOR_FLASH_INFO *Info
89 );
90 #endif