Flash.h 2.7 KB

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