49 DEBUG ((DEBUG_VERBOSE,
"%a - ENTRY\n", __func__));
52 Status =
gBS->LocateHandleBuffer (
54 &gEfiSpiHcProtocolGuid,
60 if (EFI_ERROR (Status)) {
61 DEBUG ((DEBUG_VERBOSE,
"No SpiHcProtocol is found\n"));
62 Status = EFI_NOT_FOUND;
67 Status =
gBS->LocateProtocol (
68 &gEfiSpiConfigurationProtocolGuid,
70 (VOID **)&SpiConfiguration
73 if (EFI_ERROR (Status)) {
74 DEBUG ((DEBUG_VERBOSE,
"No SpiConfigurationProtocol is found\n"));
75 Status = EFI_NOT_FOUND;
80 for (HcIndex = 0; HcIndex < HandleCount; HcIndex++) {
81 Status =
gBS->HandleProtocol (
82 SpiHcHandles[HcIndex],
83 &gEfiDevicePathProtocolGuid,
84 (VOID **)&SpiHcDevicePath
87 if (EFI_ERROR (Status)) {
88 DEBUG ((DEBUG_VERBOSE,
"Error locating EFI device path for this SPI controller, status=%r \n", Status));
93 for (BusIndex = 0; BusIndex < SpiConfiguration->
BusCount; BusIndex++) {
96 DEBUG ((DEBUG_VERBOSE,
"SpiHc and SpiConfig device paths dont match, continue parsing\n"));
102 "%a: Found matching device paths, Enumerating SPI BUS: %s with DevicePath: %s\n",
109 Status =
gBS->HandleProtocol (
110 SpiHcHandles[HcIndex],
111 &gEfiDevicePathProtocolGuid,
115 if (EFI_ERROR (Status)) {
116 DEBUG ((DEBUG_VERBOSE,
"%a - Error getting SpiHc from Handle\n", __func__));
121 if (SpiPeripheral !=
NULL) {
125 "%a: Installing SPI IO protocol for %s, by %s, PN=%s\n",
133 ASSERT (SpiChip !=
NULL);
134 if (SpiChip !=
NULL) {
136 SpiChip->Signature = SPI_IO_SIGNATURE;
137 SpiChip->SpiConfig = SpiConfiguration;
138 SpiChip->SpiHc = SpiHc;
139 SpiChip->SpiBus = Bus;
144 if ((SpiHc->Attributes & HC_TRANSFER_SIZE_INCLUDES_ADDRESS) != 0) {
145 SpiChip->Protocol.
Attributes |= SPI_IO_TRANSFER_SIZE_INCLUDES_ADDRESS;
148 if ((SpiHc->Attributes & HC_TRANSFER_SIZE_INCLUDES_OPCODE) != 0) {
149 SpiChip->Protocol.
Attributes |= SPI_IO_TRANSFER_SIZE_INCLUDES_OPCODE;
152 if ((SpiHc->Attributes & HC_SUPPORTS_8_BIT_DATA_BUS_WIDTH) != 0) {
153 SpiChip->Protocol.
Attributes |= SPI_IO_SUPPORTS_8_BIT_DATA_BUS_WIDTH;
156 if ((SpiHc->Attributes & HC_SUPPORTS_4_BIT_DATA_BUS_WIDTH) != 0) {
157 SpiChip->Protocol.
Attributes |= SPI_IO_SUPPORTS_4_BIT_DATA_BUS_WIDTH;
160 if ((SpiHc->Attributes & HC_SUPPORTS_2_BIT_DATA_BUS_WIDTH) != 0) {
167 Status =
gBS->InstallProtocolInterface (
173 if (EFI_ERROR (Status)) {
174 DEBUG ((DEBUG_VERBOSE,
"%a - Error installing SpiIoProtocol\n", __func__));
178 Status = EFI_OUT_OF_RESOURCES;
181 "%a: Out of Memory resources\n",
188 }
while (SpiPeripheral !=
NULL);
190 Status = EFI_DEVICE_ERROR;
196 DEBUG ((DEBUG_VERBOSE,
"%a - EXIT (Status = %r)\n", __func__, Status));
CHAR16 *EFIAPI ConvertDevicePathToText(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN BOOLEAN DisplayOnly, IN BOOLEAN AllowShortcuts)
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)
BOOLEAN EFIAPI DevicePathsAreEqual(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath1, IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath2)
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)
CONST EFI_SPI_PERIPHERAL * Peripherallist
CONST EFI_DEVICE_PATH_PROTOCOL * ControllerPath
CONST CHAR16 * FriendlyName
CONST EFI_SPI_BUS *CONST *CONST Buslist
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