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