3 PCH SPI SMM Driver implements the SPI Host Controller Compatibility Interface.
5 Copyright (c) 2013-2015 Intel Corporation.
7 This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19 SPI_INSTANCE
*mSpiInstance
;
21 CONST UINT32 mSpiRegister
[] = {
25 R_QNC_RCRB_SPIOPMENU
+ 4
31 IN EFI_HANDLE ImageHandle
,
32 IN EFI_SYSTEM_TABLE
*SystemTable
38 Entry point for the SPI host controller driver.
42 ImageHandle Image handle of this driver.
43 SystemTable Global system service table.
47 EFI_SUCCESS Initialization complete.
48 EFI_UNSUPPORTED The chipset is unsupported by this driver.
49 EFI_OUT_OF_RESOURCES Do not have enough resources to initialize the driver.
50 EFI_DEVICE_ERROR Device error, driver exits abnormally.
57 // Allocate pool for SPI protocol instance
59 Status
= gSmst
->SmmAllocatePool (
60 EfiRuntimeServicesData
, // MemoryType don't care
61 sizeof (SPI_INSTANCE
),
62 (VOID
**) &mSpiInstance
64 if (EFI_ERROR (Status
)) {
67 if (mSpiInstance
== NULL
) {
68 return EFI_OUT_OF_RESOURCES
;
70 ZeroMem ((VOID
*) mSpiInstance
, sizeof (SPI_INSTANCE
));
72 // Initialize the SPI protocol instance
74 Status
= SpiProtocolConstructor (mSpiInstance
);
75 if (EFI_ERROR (Status
)) {
80 // Install the SMM EFI_SPI_PROTOCOL interface
82 Status
= gSmst
->SmmInstallProtocolInterface (
83 &(mSpiInstance
->Handle
),
84 &gEfiSmmSpiProtocolGuid
,
86 &(mSpiInstance
->SpiProtocol
)
88 if (EFI_ERROR (Status
)) {
89 gSmst
->SmmFreePool (mSpiInstance
);
90 return EFI_DEVICE_ERROR
;
104 This function is a a hook for Spi Smm phase specific initialization
119 // Save SPI Registers for S3 resume usage
121 for (Index
= 0; Index
< sizeof (mSpiRegister
) / sizeof (UINT32
); Index
++) {
122 S3BootScriptSaveMemWrite (
123 S3BootScriptWidthUint32
,
124 (UINTN
) (mSpiInstance
->PchRootComplexBar
+ mSpiRegister
[Index
]),
126 (VOID
*) (UINTN
) (mSpiInstance
->PchRootComplexBar
+ mSpiRegister
[Index
])