44 DEBUG ((DEBUG_VERBOSE,
"%a - ENTRY\n", __func__));
47 Status = gMmst->MmLocateProtocol (
48 &gEfiSpiSmmHcProtocolGuid,
53 if (EFI_ERROR (Status)) {
54 DEBUG ((DEBUG_VERBOSE,
"No SpiHcProtocol is found\n"));
55 Status = EFI_NOT_FOUND;
60 Status = gMmst->MmLocateProtocol (
61 &gEfiSpiSmmConfigurationProtocolGuid,
63 (VOID **)&SpiConfiguration
66 if (EFI_ERROR (Status)) {
67 DEBUG ((DEBUG_VERBOSE,
"No SpiConfigurationProtocol is found\n"));
68 Status = EFI_NOT_FOUND;
73 if (SpiConfiguration->
BusCount != 1) {
74 DEBUG ((DEBUG_VERBOSE,
"Only one SPI Bus supported in SMM\n"));
75 Status = EFI_UNSUPPORTED;
81 if (EFI_ERROR (Status)) {
82 DEBUG ((DEBUG_VERBOSE,
"%a - Error getting SpiHc from Handle\n", __func__));
87 if (SpiPeripheral !=
NULL) {
91 "%a: Installing SPI IO protocol for %s, by %s, PN=%s\n",
99 ASSERT (SpiChip !=
NULL);
100 if (SpiChip !=
NULL) {
102 SpiChip->Signature = SPI_IO_SIGNATURE;
103 SpiChip->SpiConfig = SpiConfiguration;
104 SpiChip->SpiHc = SpiHc;
105 SpiChip->SpiBus = Bus;
110 if ((SpiHc->
Attributes & HC_TRANSFER_SIZE_INCLUDES_ADDRESS) != 0) {
111 SpiChip->Protocol.
Attributes |= SPI_IO_TRANSFER_SIZE_INCLUDES_ADDRESS;
114 if ((SpiHc->
Attributes & HC_TRANSFER_SIZE_INCLUDES_OPCODE) != 0) {
115 SpiChip->Protocol.
Attributes |= SPI_IO_TRANSFER_SIZE_INCLUDES_OPCODE;
118 if ((SpiHc->
Attributes & HC_SUPPORTS_8_BIT_DATA_BUS_WIDTH) != 0) {
119 SpiChip->Protocol.
Attributes |= SPI_IO_SUPPORTS_8_BIT_DATA_BUS_WIDTH;
122 if ((SpiHc->
Attributes & HC_SUPPORTS_4_BIT_DATA_BUS_WIDTH) != 0) {
123 SpiChip->Protocol.
Attributes |= SPI_IO_SUPPORTS_4_BIT_DATA_BUS_WIDTH;
126 if ((SpiHc->
Attributes & HC_SUPPORTS_2_BIT_DATA_BUS_WIDTH) != 0) {
139 if (EFI_ERROR (Status)) {
140 DEBUG ((DEBUG_VERBOSE,
"%a - Error installing SpiIoProtocol\n", __func__));
144 Status = EFI_OUT_OF_RESOURCES;
147 "%a: Out of Memory resources\n",
154 }
while (SpiPeripheral !=
NULL);
156 Status = EFI_DEVICE_ERROR;
160 DEBUG ((DEBUG_VERBOSE,
"%a - EXIT (Status = %r)\n", __func__, Status));
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
#define DEBUG(Expression)
EFI_STATUS EFIAPI UpdateSpiPeripheral(IN CONST EFI_SPI_IO_PROTOCOL *This, IN CONST EFI_SPI_PERIPHERAL *SpiPeripheral)
EFI_STATUS EFIAPI Transaction(IN CONST EFI_SPI_IO_PROTOCOL *This, IN EFI_SPI_TRANSACTION_TYPE TransactionType, IN BOOLEAN DebugTransaction, IN UINT32 ClockHz OPTIONAL, IN UINT32 BusWidth, IN UINT32 FrameSize, IN UINT32 WriteBytes, IN UINT8 *WriteBuffer, IN UINT32 ReadBytes, OUT UINT8 *ReadBuffer)
EFI_STATUS EFIAPI SpiBusEntry(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
#define SPI_IO_SUPPORTS_2_BIT_DATA_BUS_WIDTH
VOID EFIAPI Exit(IN EFI_STATUS Status)
EFI_INSTALL_PROTOCOL_INTERFACE MmInstallProtocolInterface
CONST EFI_SPI_PERIPHERAL * Peripherallist
CONST EFI_SPI_BUS *CONST *CONST Buslist
UINT32 MaximumTransferBytes
UINT32 FrameSizeSupportMask
CONST EFI_SPI_PERIPHERAL * SpiPeripheral
UINT32 MaximumTransferBytes
EFI_SPI_IO_PROTOCOL_TRANSACTION Transaction
EFI_SPI_IO_PROTOCOL_UPDATE_SPI_PERIPHERAL UpdateSpiPeripheral
UINT32 FrameSizeSupportMask
CONST EFI_SPI_PERIPHERAL * OriginalSpiPeripheral
CONST CHAR16 * PartNumber
CONST GUID * SpiPeripheralDriverGuid
CONST EFI_SPI_PERIPHERAL * NextSpiPeripheral
CONST CHAR16 * FriendlyName
CONST EFI_SPI_PART * SpiPart