NorFlashInfoLib.h 2.5 KB

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