zbao | 7d94cf9 | 2012-07-02 14:19:14 +0800 | [diff] [blame] | 1 | /* $NoKeywords:$ */ |
| 2 | /** |
| 3 | * @file |
| 4 | * |
| 5 | * Fch Init during POWER-ON |
| 6 | * |
| 7 | * Prepare Fch environment during power on stage. |
| 8 | * |
| 9 | * @xrefitem bom "File Content Label" "Release Content" |
| 10 | * @e project: AGESA |
| 11 | * @e sub-project: FCH |
| 12 | * @e \$Revision: 63425 $ @e \$Date: 2011-12-22 11:24:10 -0600 (Thu, 22 Dec 2011) $ |
| 13 | * |
| 14 | */ |
| 15 | /*;******************************************************************************** |
| 16 | ; |
Siyuan Wang | 641f00c | 2013-06-08 11:50:55 +0800 | [diff] [blame] | 17 | * Copyright (c) 2008 - 2012, Advanced Micro Devices, Inc. |
| 18 | * All rights reserved. |
| 19 | * |
| 20 | * Redistribution and use in source and binary forms, with or without |
| 21 | * modification, are permitted provided that the following conditions are met: |
| 22 | * * Redistributions of source code must retain the above copyright |
| 23 | * notice, this list of conditions and the following disclaimer. |
| 24 | * * Redistributions in binary form must reproduce the above copyright |
| 25 | * notice, this list of conditions and the following disclaimer in the |
| 26 | * documentation and/or other materials provided with the distribution. |
| 27 | * * Neither the name of Advanced Micro Devices, Inc. nor the names of |
| 28 | * its contributors may be used to endorse or promote products derived |
| 29 | * from this software without specific prior written permission. |
| 30 | * |
| 31 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| 32 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 33 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 34 | * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY |
| 35 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 36 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 37 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 38 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 39 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 40 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
zbao | 7d94cf9 | 2012-07-02 14:19:14 +0800 | [diff] [blame] | 41 | ;*********************************************************************************/ |
| 42 | |
| 43 | #include "FchPlatform.h" |
| 44 | #include "Ids.h" |
| 45 | #include "heapManager.h" |
| 46 | #include "Filecode.h" |
| 47 | |
| 48 | #define FILECODE PROC_FCH_INTERFACE_INITENVDEF_FILECODE |
| 49 | |
| 50 | extern FCH_DATA_BLOCK InitEnvCfgDefault; |
| 51 | |
| 52 | FCH_DATA_BLOCK* |
| 53 | FchInitEnvCreatePrivateData ( |
| 54 | IN AMD_ENV_PARAMS *EnvParams |
| 55 | ); |
| 56 | |
| 57 | FCH_DATA_BLOCK* |
| 58 | FchInitLoadDataBlock ( |
| 59 | IN FCH_INTERFACE *FchInterface, |
| 60 | IN AMD_CONFIG_PARAMS *StdHeader |
| 61 | ); |
| 62 | |
| 63 | FCH_DATA_BLOCK* |
| 64 | FchInitLoadDataBlock ( |
| 65 | IN FCH_INTERFACE *FchInterface, |
| 66 | IN AMD_CONFIG_PARAMS *StdHeader |
| 67 | ) |
| 68 | { |
| 69 | FCH_DATA_BLOCK *FchParams; |
| 70 | LOCATE_HEAP_PTR LocHeapPtr; |
| 71 | AMD_CONFIG_PARAMS TempStdHeader; |
| 72 | AGESA_STATUS AgesaStatus; |
| 73 | |
| 74 | TempStdHeader = *StdHeader; |
| 75 | TempStdHeader.HeapStatus = HEAP_SYSTEM_MEM; |
| 76 | |
| 77 | // Locate the internal data block via heap manager |
| 78 | LocHeapPtr.BufferHandle = AMD_FCH_DATA_BLOCK_HANDLE; |
| 79 | AgesaStatus = HeapLocateBuffer (&LocHeapPtr, &TempStdHeader); |
| 80 | ASSERT (!AgesaStatus); |
| 81 | |
| 82 | FchParams = (FCH_DATA_BLOCK *) LocHeapPtr.BufferPtr; |
| 83 | ASSERT (FchParams != NULL); |
| 84 | FchParams->StdHeader = StdHeader; |
| 85 | return FchParams; |
| 86 | } |
| 87 | |
| 88 | |
| 89 | STATIC VOID |
| 90 | RetrieveDataBlockFromInitReset ( |
| 91 | IN FCH_DATA_BLOCK *FchParams |
| 92 | ) |
| 93 | { |
| 94 | LOCATE_HEAP_PTR LocHeapPtr; |
| 95 | FCH_RESET_DATA_BLOCK *ResetDb; |
| 96 | AGESA_STATUS AgesaStatus; |
| 97 | |
| 98 | LocHeapPtr.BufferHandle = AMD_FCH_RESET_DATA_BLOCK_HANDLE; |
| 99 | AgesaStatus = HeapLocateBuffer (&LocHeapPtr, FchParams->StdHeader); |
| 100 | if (AgesaStatus == AGESA_SUCCESS) { |
| 101 | ASSERT (LocHeapPtr.BufferPtr != NULL); |
| 102 | ResetDb = (FCH_RESET_DATA_BLOCK *) (LocHeapPtr.BufferPtr - sizeof (ResetDb) + sizeof (UINT32)); |
| 103 | // Override FchParams with contents in ResetDb |
| 104 | |
| 105 | FchParams->Usb.Xhci0Enable = ResetDb->FchReset.Xhci0Enable; |
| 106 | FchParams->Usb.Xhci1Enable = ResetDb->FchReset.Xhci1Enable; |
| 107 | FchParams->Spi.SpiFastSpeed = ResetDb->FastSpeed; |
| 108 | FchParams->Spi.WriteSpeed = ResetDb->WriteSpeed; |
| 109 | FchParams->Spi.SpiMode = ResetDb->Mode; |
| 110 | FchParams->Spi.AutoMode = ResetDb->AutoMode; |
| 111 | FchParams->Spi.SpiBurstWrite = ResetDb->BurstWrite; |
| 112 | FchParams->Sata.SataMode.Sata6AhciCap = (UINT8) ResetDb->Sata6AhciCap; |
| 113 | FchParams->Misc.Cg2Pll = ResetDb->Cg2Pll; |
| 114 | FchParams->Sata.SataMode.SataSetMaxGen2 = ResetDb->SataSetMaxGen2; |
| 115 | FchParams->Sata.SataMode.SataClkMode = ResetDb->SataClkMode; |
| 116 | FchParams->Sata.SataMode.SataModeReg = ResetDb->SataModeReg; |
| 117 | FchParams->Sata.SataInternal100Spread = (UINT8) ResetDb->SataInternal100Spread; |
| 118 | FchParams->Spi.SpiSpeed = ResetDb->SpiSpeed; |
| 119 | FchParams->Gpp = ResetDb->Gpp; |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | |
| 124 | FCH_DATA_BLOCK* |
| 125 | FchInitEnvCreatePrivateData ( |
| 126 | IN AMD_ENV_PARAMS *EnvParams |
| 127 | ) |
| 128 | { |
| 129 | FCH_DATA_BLOCK *FchParams; |
| 130 | ALLOCATE_HEAP_PARAMS AllocHeapParams; |
| 131 | AGESA_STATUS AgesaStatus; |
| 132 | |
| 133 | // First allocate internal data block via heap manager |
| 134 | AllocHeapParams.RequestedBufferSize = sizeof (FCH_DATA_BLOCK); |
| 135 | AllocHeapParams.Persist = HEAP_SYSTEM_MEM; |
| 136 | AllocHeapParams.BufferHandle = AMD_FCH_DATA_BLOCK_HANDLE; |
| 137 | AgesaStatus = HeapAllocateBuffer (&AllocHeapParams, &EnvParams->StdHeader); |
| 138 | ASSERT (!AgesaStatus); |
| 139 | |
| 140 | FchParams = (FCH_DATA_BLOCK *) AllocHeapParams.BufferPtr; |
| 141 | ASSERT (FchParams != NULL); |
Angel Pons | b382b89 | 2021-05-09 16:11:30 +0200 | [diff] [blame] | 142 | IDS_HDT_CONSOLE (FCH_TRACE, " FCH Data Block Allocation: [0x%x], Ptr = %p\n", AgesaStatus, FchParams); |
zbao | 7d94cf9 | 2012-07-02 14:19:14 +0800 | [diff] [blame] | 143 | |
| 144 | // Load private data block with default |
| 145 | *FchParams = InitEnvCfgDefault; |
| 146 | FchParams->StdHeader = &EnvParams->StdHeader; |
| 147 | |
| 148 | RetrieveDataBlockFromInitReset (FchParams); |
| 149 | |
| 150 | // Update with external parameters |
| 151 | FchParams->Sd.SdConfig = EnvParams->FchInterface.SdConfig; |
| 152 | FchParams->Ir.IrConfig = EnvParams->FchInterface.IrConfig; |
| 153 | FchParams->Ab.NbSbGen2 = EnvParams->FchInterface.UmiGen2; |
| 154 | FchParams->Sata.SataClass = EnvParams->FchInterface.SataClass; |
| 155 | FchParams->Sata.SataMode.SataEnable = EnvParams->FchInterface.SataEnable; |
| 156 | FchParams->Sata.SataMode.IdeEnable = EnvParams->FchInterface.IdeEnable; |
| 157 | FchParams->Sata.SataIdeMode = EnvParams->FchInterface.SataIdeMode; |
| 158 | FchParams->Usb.Ohci1Enable = EnvParams->FchInterface.Ohci1Enable; |
| 159 | FchParams->Usb.Ehci1Enable = EnvParams->FchInterface.Ohci1Enable; |
| 160 | FchParams->Usb.Ohci2Enable = EnvParams->FchInterface.Ohci2Enable; |
| 161 | FchParams->Usb.Ehci2Enable = EnvParams->FchInterface.Ohci2Enable; |
| 162 | FchParams->Usb.Ohci3Enable = EnvParams->FchInterface.Ohci3Enable; |
| 163 | FchParams->Usb.Ehci3Enable = EnvParams->FchInterface.Ohci3Enable; |
| 164 | FchParams->Usb.Ohci4Enable = EnvParams->FchInterface.Ohci4Enable; |
| 165 | FchParams->HwAcpi.PwrFailShadow = EnvParams->FchInterface.FchPowerFail; |
| 166 | FchParams->HwAcpi.Smbus0BaseAddress = UserOptions.FchBldCfg->CfgSmbus0BaseAddress; |
| 167 | FchParams->HwAcpi.Smbus1BaseAddress = UserOptions.FchBldCfg->CfgSmbus1BaseAddress; |
| 168 | FchParams->HwAcpi.SioPmeBaseAddress = UserOptions.FchBldCfg->CfgSioPmeBaseAddress; |
| 169 | FchParams->HwAcpi.AcpiPm1EvtBlkAddr = UserOptions.FchBldCfg->CfgAcpiPm1EvtBlkAddr; |
| 170 | FchParams->HwAcpi.AcpiPm1CntBlkAddr = UserOptions.FchBldCfg->CfgAcpiPm1CntBlkAddr; |
| 171 | FchParams->HwAcpi.AcpiPmTmrBlkAddr = UserOptions.FchBldCfg->CfgAcpiPmTmrBlkAddr; |
| 172 | FchParams->HwAcpi.CpuControlBlkAddr = UserOptions.FchBldCfg->CfgCpuControlBlkAddr; |
| 173 | FchParams->HwAcpi.AcpiGpe0BlkAddr = UserOptions.FchBldCfg->CfgAcpiGpe0BlkAddr; |
| 174 | FchParams->HwAcpi.SmiCmdPortAddr = UserOptions.FchBldCfg->CfgSmiCmdPortAddr; |
| 175 | FchParams->HwAcpi.AcpiPmaCntBlkAddr = UserOptions.FchBldCfg->CfgAcpiPmaCntBlkAddr; |
| 176 | FchParams->HwAcpi.WatchDogTimerBase = UserOptions.FchBldCfg->CfgWatchDogTimerBase; |
| 177 | FchParams->Sata.SataRaid5Ssid = UserOptions.FchBldCfg->CfgSataRaid5Ssid; |
| 178 | FchParams->Sata.SataRaidSsid = UserOptions.FchBldCfg->CfgSataRaidSsid; |
| 179 | FchParams->Sata.SataAhciSsid = UserOptions.FchBldCfg->CfgSataAhciSsid; |
| 180 | FchParams->Sata.SataIdeSsid = UserOptions.FchBldCfg->CfgSataIdeSsid; |
| 181 | FchParams->Gec.GecShadowRomBase = UserOptions.FchBldCfg->CfgGecShadowRomBase; |
| 182 | FchParams->Spi.RomBaseAddress = UserOptions.FchBldCfg->CfgSpiRomBaseAddress; |
| 183 | FchParams->Sd.SdSsid = UserOptions.FchBldCfg->CfgSdSsid; |
| 184 | FchParams->Spi.LpcSsid = UserOptions.FchBldCfg->CfgLpcSsid; |
| 185 | FchParams->Hpet.HpetBase = UserOptions.FchBldCfg->CfgHpetBaseAddress; |
| 186 | FchParams->Smbus.SmbusSsid = UserOptions.FchBldCfg->CfgSmbusSsid; |
| 187 | FchParams->Ide.IdeSsid = UserOptions.FchBldCfg->CfgIdeSsid; |
| 188 | FchParams->Usb.EhciSsid = UserOptions.FchBldCfg->CfgEhciSsid; |
| 189 | FchParams->Usb.OhciSsid = UserOptions.FchBldCfg->CfgOhciSsid; |
| 190 | FchParams->Usb.XhciSsid = UserOptions.FchBldCfg->CfgXhciSsid; |
| 191 | FchParams->Ir.IrPinControl = UserOptions.FchBldCfg->CfgFchIrPinControl; |
| 192 | FchParams->Sd.SdClockControl = UserOptions.FchBldCfg->CfgFchSdClockControl; |
| 193 | return FchParams; |
| 194 | } |
| 195 | |
| 196 | |