3 PCH SPI SMM Driver implements the SPI Host Controller Compatibility Interface.
5 Copyright (c) 2013-2015 Intel Corporation.
7 SPDX-License-Identifier: BSD-2-Clause-Patent
13 SPI_INSTANCE
*mSpiInstance
;
15 CONST UINT32 mSpiRegister
[] = {
19 R_QNC_RCRB_SPIOPMENU
+ 4
25 IN EFI_HANDLE ImageHandle
,
26 IN EFI_SYSTEM_TABLE
*SystemTable
32 Entry point for the SPI host controller driver.
36 ImageHandle Image handle of this driver.
37 SystemTable Global system service table.
41 EFI_SUCCESS Initialization complete.
42 EFI_UNSUPPORTED The chipset is unsupported by this driver.
43 EFI_OUT_OF_RESOURCES Do not have enough resources to initialize the driver.
44 EFI_DEVICE_ERROR Device error, driver exits abnormally.
51 // Allocate pool for SPI protocol instance
53 Status
= gSmst
->SmmAllocatePool (
54 EfiRuntimeServicesData
, // MemoryType don't care
55 sizeof (SPI_INSTANCE
),
56 (VOID
**) &mSpiInstance
58 if (EFI_ERROR (Status
)) {
61 if (mSpiInstance
== NULL
) {
62 return EFI_OUT_OF_RESOURCES
;
64 ZeroMem ((VOID
*) mSpiInstance
, sizeof (SPI_INSTANCE
));
66 // Initialize the SPI protocol instance
68 Status
= SpiProtocolConstructor (mSpiInstance
);
69 if (EFI_ERROR (Status
)) {
74 // Install the SMM EFI_SPI_PROTOCOL interface
76 Status
= gSmst
->SmmInstallProtocolInterface (
77 &(mSpiInstance
->Handle
),
78 &gEfiSmmSpiProtocolGuid
,
80 &(mSpiInstance
->SpiProtocol
)
82 if (EFI_ERROR (Status
)) {
83 gSmst
->SmmFreePool (mSpiInstance
);
84 return EFI_DEVICE_ERROR
;
98 This function is a a hook for Spi Smm phase specific initialization
113 // Save SPI Registers for S3 resume usage
115 for (Index
= 0; Index
< sizeof (mSpiRegister
) / sizeof (UINT32
); Index
++) {
116 S3BootScriptSaveMemWrite (
117 S3BootScriptWidthUint32
,
118 (UINTN
) (mSpiInstance
->PchRootComplexBar
+ mSpiRegister
[Index
]),
120 (VOID
*) (UINTN
) (mSpiInstance
->PchRootComplexBar
+ mSpiRegister
[Index
])