[edk2-devel] [PATCH V3 15/32] AMD/VanGoghBoard: Check in SpiFlashDeviceLib

Zhai, MingXin (Duke) via groups.io posted 32 patches 7 months, 2 weeks ago
Only 28 patches received!
[edk2-devel] [PATCH V3 15/32] AMD/VanGoghBoard: Check in SpiFlashDeviceLib
Posted by Zhai, MingXin (Duke) via groups.io 7 months, 2 weeks ago
From: Duke Zhai <Duke.Zhai@amd.com>

BZ #:4640
In V2: Improve coding style.
  1.Remove the leading underscore and use double underscore at trailing in C header files.
  2.Remove old tianocore licenses and redundant license description.
  3.Improve coding style. For example: remove space between @param.

In V1:
  Initial AMD SpiFlashDeviceLib for Chachani board flash IC.
  Chachani board use the W25Q256JW as flash IC.

Signed-off-by: Duke Zhai <duke.zhai@amd.com>
Cc: Eric Xing <eric.xing@amd.com>
Cc: Ken Yao <ken.yao@amd.com>
Cc: Igniculus Fu <igniculus.fu@amd.com>
Cc: Abner Chang <abner.chang@amd.com>
---
 .../SpiFlashDeviceLib/SpiFlashDeviceLib.c     | 42 +++++++++++++++++++
 .../SpiFlashDeviceLib/SpiFlashDeviceLib.inf   | 29 +++++++++++++
 2 files changed, 71 insertions(+)
 create mode 100644 Platform/AMD/VanGoghBoard/VanGoghCommonPkg/Library/SpiFlashDeviceLib/SpiFlashDeviceLib.c
 create mode 100644 Platform/AMD/VanGoghBoard/VanGoghCommonPkg/Library/SpiFlashDeviceLib/SpiFlashDeviceLib.inf

diff --git a/Platform/AMD/VanGoghBoard/VanGoghCommonPkg/Library/SpiFlashDeviceLib/SpiFlashDeviceLib.c b/Platform/AMD/VanGoghBoard/VanGoghCommonPkg/Library/SpiFlashDeviceLib/SpiFlashDeviceLib.c
new file mode 100644
index 0000000000..49636f6a89
--- /dev/null
+++ b/Platform/AMD/VanGoghBoard/VanGoghCommonPkg/Library/SpiFlashDeviceLib/SpiFlashDeviceLib.c
@@ -0,0 +1,42 @@
+/** @file
+  Implements SpiFlashDeviceLib.c
+
+  Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Library/SpiFlashDeviceLib.h>
+
+SPI_INIT_TABLE  mSpiInitTable[] = {
+  { // W25Q256JW/W74M25JW
+    SF_VENDOR_ID_WINBOND,
+    SF_DEVICE_ID0_W25Q256JW,
+    SF_DEVICE_ID1_W25Q256JW,
+    {
+      SPI_COMMAND_WRITE_ENABLE,
+      SPI_COMMAND_WRITE_S_EN
+    },
+    {
+      { EnumSpiOpcodeReadNoAddr,SPI_COMMAND_JEDEC_ID,          EnumSpiOperationJedecId            },
+      { EnumSpiOpcodeWriteNoAddr,SPI_COMMAND_WRITE_S,           EnumSpiOperationWriteStatus        },
+      { EnumSpiOpcodeWrite,    SPI_COMMAND_WRITE,             EnumSpiOperationProgramData_1_Byte },
+      { EnumSpiOpcodeRead,     SPI_COMMAND_READ,              EnumSpiOperationReadData           },
+      { EnumSpiOpcodeWrite,    SPI_COMMAND_ERASE,             EnumSpiOperationErase_4K_Byte      },
+      { EnumSpiOpcodeReadNoAddr,SPI_COMMAND_READ_S,            EnumSpiOperationReadStatus         },
+      { EnumSpiOpcodeWriteNoAddr,SPI_COMMAND_CHIP_ERASE,        EnumSpiOperationFullChipErase      },
+      { EnumSpiOpcodeRead,     SPI_COMMAND_READ_SFDP,         EnumSpiOperationReadData           },
+      { EnumSpiOpcodeWriteNoAddr,SPI_COMMAND_RPMC_OP1,          EnumSpiOperationOther              },
+      { EnumSpiOpcodeReadNoAddr,SPI_COMMAND_RPMC_OP2,          EnumSpiOperationReadData           },
+      { EnumSpiOpcodeReadNoAddr,SPI_COMMAND_Enter_4Byte_Addr,  EnumSpiOperationOther              },
+      { EnumSpiOpcodeReadNoAddr,SPI_COMMAND_Exit_4Byte_Addr,   EnumSpiOperationOther              }
+    },
+    0,
+    0x2000000   // BIOS image size in flash
+  }
+};
+
+//
+// The total number of support flash part
+//
+UINT8  mNumSpiFlashMax = sizeof (mSpiInitTable) / sizeof (mSpiInitTable[0]);
diff --git a/Platform/AMD/VanGoghBoard/VanGoghCommonPkg/Library/SpiFlashDeviceLib/SpiFlashDeviceLib.inf b/Platform/AMD/VanGoghBoard/VanGoghCommonPkg/Library/SpiFlashDeviceLib/SpiFlashDeviceLib.inf
new file mode 100644
index 0000000000..951cf6c480
--- /dev/null
+++ b/Platform/AMD/VanGoghBoard/VanGoghCommonPkg/Library/SpiFlashDeviceLib/SpiFlashDeviceLib.inf
@@ -0,0 +1,29 @@
+## @file
+# SpiFlashDeviceLib
+#
+# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION                    = 0x00010005
+  BASE_NAME                      = SpiFlashDeviceLib
+  FILE_GUID                      = D5A903A8-4D19-4E4C-AAF4-07C5D10D5939
+  MODULE_TYPE                    = BASE
+  VERSION_STRING                 = 1.0
+  LIBRARY_CLASS                  = SpiFlashDeviceLib
+
+#
+#  VALID_ARCHITECTURES           = IA32 X64
+#
+
+[Sources]
+  SpiFlashDeviceLib.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  VanGoghCommonPkg/AmdCommonPkg.dec
+
+[LibraryClasses]
+  SpiFlashDeviceLib
-- 
2.31.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#114591): https://edk2.groups.io/g/devel/message/114591
Mute This Topic: https://groups.io/mt/103975457/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-