]> git.proxmox.com Git - mirror_edk2.git/blob - Omap35xxPkg/Flash/Flash.h
Omap35xxPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / Omap35xxPkg / Flash / Flash.h
1 /** @file
2
3 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
4
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9 #ifndef FLASH_H
10 #define FLASH_H
11
12 #include <Uefi.h>
13
14 #include <Library/BaseLib.h>
15 #include <Library/BaseMemoryLib.h>
16 #include <Library/MemoryAllocationLib.h>
17 #include <Library/DebugLib.h>
18 #include <Library/IoLib.h>
19 #include <Library/PcdLib.h>
20 #include <Library/UefiBootServicesTableLib.h>
21 #include <Library/IoLib.h>
22
23 #include <Protocol/BlockIo.h>
24 #include <Protocol/Cpu.h>
25 #include <Omap3530/Omap3530.h>
26
27 #define PAGE_SIZE(x) ((x) & 0x01)
28 #define PAGE_SIZE_2K_VAL (0x01UL)
29
30 #define SPARE_AREA_SIZE(x) (((x) >> 2) & 0x01)
31 #define SPARE_AREA_SIZE_64B_VAL (0x1UL)
32
33 #define BLOCK_SIZE(x) (((x) >> 4) & 0x01)
34 #define BLOCK_SIZE_128K_VAL (0x01UL)
35
36 #define ORGANIZATION(x) (((x) >> 6) & 0x01)
37 #define ORGANIZATION_X8 (0x0UL)
38 #define ORGANIZATION_X16 (0x1UL)
39
40 #define PAGE_SIZE_512B (512)
41 #define PAGE_SIZE_2K (2048)
42 #define PAGE_SIZE_4K (4096)
43 #define SPARE_AREA_SIZE_16B (16)
44 #define SPARE_AREA_SIZE_64B (64)
45
46 #define BLOCK_SIZE_16K (16*1024)
47 #define BLOCK_SIZE_128K (128*1024)
48
49 #define BLOCK_COUNT (2048)
50 #define LAST_BLOCK (BLOCK_COUNT - 1)
51
52 #define ECC_POSITION 2
53
54 //List of commands.
55 #define RESET_CMD 0xFF
56 #define READ_ID_CMD 0x90
57
58 #define READ_STATUS_CMD 0x70
59
60 #define PAGE_READ_CMD 0x00
61 #define PAGE_READ_CONFIRM_CMD 0x30
62
63 #define BLOCK_ERASE_CMD 0x60
64 #define BLOCK_ERASE_CONFIRM_CMD 0xD0
65
66 #define PROGRAM_PAGE_CMD 0x80
67 #define PROGRAM_PAGE_CONFIRM_CMD 0x10
68
69 //Nand status register bit definition
70 #define NAND_SUCCESS (0x0UL << 0)
71 #define NAND_FAILURE BIT0
72
73 #define NAND_BUSY (0x0UL << 6)
74 #define NAND_READY BIT6
75
76 #define NAND_RESET_STATUS (0x60UL << 0)
77
78 #define MAX_RETRY_COUNT 1500
79
80
81 typedef struct {
82 UINT8 ManufactureId;
83 UINT8 DeviceId;
84 UINT8 BlockAddressStart; //Start of the Block address in actual NAND
85 UINT8 PageAddressStart; //Start of the Page address in actual NAND
86 } NAND_PART_INFO_TABLE;
87
88 typedef struct {
89 UINT8 ManufactureId;
90 UINT8 DeviceId;
91 UINT8 Organization; //x8 or x16
92 UINT32 PageSize;
93 UINT32 SparePageSize;
94 UINT32 BlockSize;
95 UINT32 NumPagesPerBlock;
96 UINT8 BlockAddressStart; //Start of the Block address in actual NAND
97 UINT8 PageAddressStart; //Start of the Page address in actual NAND
98 } NAND_FLASH_INFO;
99
100 #endif //FLASH_H