Zheng Bao | 7b4a99c | 2013-11-05 13:58:50 +0800 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2013 Advanced Micro Devices, Inc. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 of the License. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
Zheng Bao | 7b4a99c | 2013-11-05 13:58:50 +0800 | [diff] [blame] | 14 | */ |
| 15 | |
Alexandru Gagniuc | 01e0adf | 2014-03-29 17:07:26 -0500 | [diff] [blame] | 16 | #include <Proc/Fch/FchPlatform.h> |
| 17 | #include <Proc/Fch/Fch.h> |
Zheng Bao | 7b4a99c | 2013-11-05 13:58:50 +0800 | [diff] [blame] | 18 | #include <cpu/amd/agesa/s3_resume.h> |
| 19 | #include <device/device.h> |
| 20 | #include "hudson.h" |
| 21 | #include "AGESA.h" |
| 22 | |
Kyösti Mälkki | 38aff1a | 2017-07-26 00:57:30 +0300 | [diff] [blame^] | 23 | #include <northbridge/amd/agesa/state_machine.h> |
| 24 | |
Zheng Bao | 7b4a99c | 2013-11-05 13:58:50 +0800 | [diff] [blame] | 25 | extern FCH_DATA_BLOCK InitEnvCfgDefault; |
| 26 | extern FCH_INTERFACE FchInterfaceDefault; |
| 27 | extern FCH_RESET_DATA_BLOCK InitResetCfgDefault; |
| 28 | extern FCH_RESET_INTERFACE FchResetInterfaceDefault; |
| 29 | |
| 30 | #define DUMP_FCH_SETTING 0 |
| 31 | |
Kyösti Mälkki | 38aff1a | 2017-07-26 00:57:30 +0300 | [diff] [blame^] | 32 | static void s3_resume_init_data(FCH_DATA_BLOCK *FchParams) |
Zheng Bao | 7b4a99c | 2013-11-05 13:58:50 +0800 | [diff] [blame] | 33 | { |
Zheng Bao | 7b4a99c | 2013-11-05 13:58:50 +0800 | [diff] [blame] | 34 | *FchParams = InitEnvCfgDefault; |
Zheng Bao | 7b4a99c | 2013-11-05 13:58:50 +0800 | [diff] [blame] | 35 | |
| 36 | FchParams->Usb.Xhci0Enable = InitResetCfgDefault.FchReset.Xhci0Enable; |
| 37 | FchParams->Usb.Xhci1Enable = InitResetCfgDefault.FchReset.Xhci1Enable; |
| 38 | FchParams->Spi.SpiFastSpeed = InitResetCfgDefault.FastSpeed; |
| 39 | FchParams->Spi.WriteSpeed = InitResetCfgDefault.WriteSpeed; |
| 40 | FchParams->Spi.SpiMode = InitResetCfgDefault.Mode; |
| 41 | FchParams->Spi.AutoMode = InitResetCfgDefault.AutoMode; |
| 42 | FchParams->Spi.SpiBurstWrite = InitResetCfgDefault.BurstWrite; |
| 43 | FchParams->Sata.SataMode.Sata6AhciCap = (UINT8) InitResetCfgDefault.Sata6AhciCap; |
| 44 | FchParams->Misc.Cg2Pll = InitResetCfgDefault.Cg2Pll; |
| 45 | FchParams->Sata.SataMode.SataSetMaxGen2 = InitResetCfgDefault.SataSetMaxGen2; |
| 46 | FchParams->Sata.SataMode.SataClkMode = InitResetCfgDefault.SataClkMode; |
| 47 | FchParams->Sata.SataMode.SataModeReg = InitResetCfgDefault.SataModeReg; |
| 48 | FchParams->Sata.SataInternal100Spread = (UINT8) InitResetCfgDefault.SataInternal100Spread; |
| 49 | FchParams->Spi.SpiSpeed = InitResetCfgDefault.SpiSpeed; |
| 50 | FchParams->Gpp = InitResetCfgDefault.Gpp; |
| 51 | FchParams->Gpp.GppFunctionEnable = FchResetInterfaceDefault.GppEnable; |
| 52 | |
| 53 | FchParams->Gpp.GppLinkConfig = UserOptions.FchBldCfg->CfgFchGppLinkConfig; |
| 54 | FchParams->Gpp.PortCfg[0].PortPresent = UserOptions.FchBldCfg->CfgFchGppPort0Present; |
| 55 | FchParams->Gpp.PortCfg[1].PortPresent = UserOptions.FchBldCfg->CfgFchGppPort1Present; |
| 56 | FchParams->Gpp.PortCfg[2].PortPresent = UserOptions.FchBldCfg->CfgFchGppPort2Present; |
| 57 | FchParams->Gpp.PortCfg[3].PortPresent = UserOptions.FchBldCfg->CfgFchGppPort3Present; |
| 58 | FchParams->Gpp.PortCfg[0].PortHotPlug = UserOptions.FchBldCfg->CfgFchGppPort0HotPlug; |
| 59 | FchParams->Gpp.PortCfg[1].PortHotPlug = UserOptions.FchBldCfg->CfgFchGppPort1HotPlug; |
| 60 | FchParams->Gpp.PortCfg[2].PortHotPlug = UserOptions.FchBldCfg->CfgFchGppPort2HotPlug; |
| 61 | FchParams->Gpp.PortCfg[3].PortHotPlug = UserOptions.FchBldCfg->CfgFchGppPort3HotPlug; |
| 62 | |
| 63 | FchParams->HwAcpi.Smbus0BaseAddress = UserOptions.FchBldCfg->CfgSmbus0BaseAddress; |
| 64 | FchParams->HwAcpi.Smbus1BaseAddress = UserOptions.FchBldCfg->CfgSmbus1BaseAddress; |
| 65 | FchParams->HwAcpi.SioPmeBaseAddress = UserOptions.FchBldCfg->CfgSioPmeBaseAddress; |
| 66 | FchParams->HwAcpi.AcpiPm1EvtBlkAddr = UserOptions.FchBldCfg->CfgAcpiPm1EvtBlkAddr; |
| 67 | FchParams->HwAcpi.AcpiPm1CntBlkAddr = UserOptions.FchBldCfg->CfgAcpiPm1CntBlkAddr; |
| 68 | FchParams->HwAcpi.AcpiPmTmrBlkAddr = UserOptions.FchBldCfg->CfgAcpiPmTmrBlkAddr; |
| 69 | FchParams->HwAcpi.CpuControlBlkAddr = UserOptions.FchBldCfg->CfgCpuControlBlkAddr; |
| 70 | FchParams->HwAcpi.AcpiGpe0BlkAddr = UserOptions.FchBldCfg->CfgAcpiGpe0BlkAddr; |
| 71 | FchParams->HwAcpi.SmiCmdPortAddr = UserOptions.FchBldCfg->CfgSmiCmdPortAddr; |
| 72 | FchParams->HwAcpi.AcpiPmaCntBlkAddr = UserOptions.FchBldCfg->CfgAcpiPmaCntBlkAddr; |
| 73 | FchParams->HwAcpi.WatchDogTimerBase = UserOptions.FchBldCfg->CfgWatchDogTimerBase; |
| 74 | FchParams->Sata.SataRaid5Ssid = UserOptions.FchBldCfg->CfgSataRaid5Ssid; |
| 75 | FchParams->Sata.SataRaidSsid = UserOptions.FchBldCfg->CfgSataRaidSsid; |
| 76 | FchParams->Sata.SataAhciSsid = UserOptions.FchBldCfg->CfgSataAhciSsid; |
| 77 | FchParams->Sata.SataIdeSsid = UserOptions.FchBldCfg->CfgSataIdeSsid; |
| 78 | FchParams->Spi.RomBaseAddress = UserOptions.FchBldCfg->CfgSpiRomBaseAddress; |
| 79 | FchParams->Sd.SdSsid = UserOptions.FchBldCfg->CfgSdSsid; |
| 80 | FchParams->Spi.LpcSsid = UserOptions.FchBldCfg->CfgLpcSsid; |
| 81 | FchParams->Hpet.HpetBase = UserOptions.FchBldCfg->CfgHpetBaseAddress; |
| 82 | FchParams->Azalia.AzaliaSsid = UserOptions.FchBldCfg->CfgAzaliaSsid; |
| 83 | FchParams->Smbus.SmbusSsid = UserOptions.FchBldCfg->CfgSmbusSsid; |
| 84 | FchParams->Ide.IdeSsid = UserOptions.FchBldCfg->CfgIdeSsid; |
| 85 | FchParams->Usb.EhciSsid = UserOptions.FchBldCfg->CfgEhciSsid; |
| 86 | FchParams->Usb.OhciSsid = UserOptions.FchBldCfg->CfgOhciSsid; |
| 87 | FchParams->Usb.XhciSsid = UserOptions.FchBldCfg->CfgXhciSsid; |
| 88 | FchParams->Ir.IrPinControl = UserOptions.FchBldCfg->CfgFchIrPinControl; |
| 89 | FchParams->Sd.SdClockControl = UserOptions.FchBldCfg->CfgFchSdClockControl; |
| 90 | |
| 91 | FchParams->Sd.SdConfig = FchInterfaceDefault.SdConfig; |
| 92 | FchParams->Azalia.AzaliaEnable = FchInterfaceDefault.AzaliaController; |
| 93 | FchParams->Ir.IrConfig = FchInterfaceDefault.IrConfig; |
| 94 | FchParams->Ab.NbSbGen2 = FchInterfaceDefault.UmiGen2; |
| 95 | FchParams->Sata.SataClass = FchInterfaceDefault.SataClass; |
| 96 | FchParams->Sata.SataMode.SataEnable = FchInterfaceDefault.SataEnable; |
| 97 | FchParams->Sata.SataMode.IdeEnable = FchInterfaceDefault.IdeEnable; |
| 98 | FchParams->Sata.SataIdeMode = FchInterfaceDefault.SataIdeMode; |
| 99 | FchParams->Usb.Ohci1Enable = FchInterfaceDefault.Ohci1Enable; |
| 100 | FchParams->Usb.Ehci1Enable = FchInterfaceDefault.Ohci1Enable; |
| 101 | FchParams->Usb.Ohci2Enable = FchInterfaceDefault.Ohci2Enable; |
| 102 | FchParams->Usb.Ehci2Enable = FchInterfaceDefault.Ohci2Enable; |
| 103 | FchParams->Usb.Ohci3Enable = FchInterfaceDefault.Ohci3Enable; |
| 104 | FchParams->Usb.Ehci3Enable = FchInterfaceDefault.Ohci3Enable; |
| 105 | FchParams->Usb.Ohci4Enable = FchInterfaceDefault.Ohci4Enable; |
| 106 | FchParams->HwAcpi.PwrFailShadow = FchInterfaceDefault.FchPowerFail; |
| 107 | |
Kyösti Mälkki | b166628 | 2014-07-06 22:40:15 +0300 | [diff] [blame] | 108 | FchParams->Usb.Xhci0Enable = IS_ENABLED(CONFIG_HUDSON_XHCI_ENABLE); |
| 109 | FchParams->Usb.Xhci1Enable = FALSE; |
Zheng Bao | 7b4a99c | 2013-11-05 13:58:50 +0800 | [diff] [blame] | 110 | |
| 111 | #if DUMP_FCH_SETTING |
| 112 | int i; |
| 113 | |
| 114 | for (i = 0; i < sizeof(FchParams); i++) { |
| 115 | printk(BIOS_DEBUG, " %02x", ((u8 *) FchParams)[i]); |
| 116 | if ((i % 16) == 15) |
| 117 | printk(BIOS_DEBUG, "\n"); |
| 118 | } |
| 119 | #endif |
| 120 | } |
Kyösti Mälkki | 38aff1a | 2017-07-26 00:57:30 +0300 | [diff] [blame^] | 121 | |
| 122 | AGESA_STATUS fchs3earlyrestore(AMD_CONFIG_PARAMS *StdHeader) |
| 123 | { |
| 124 | FCH_DATA_BLOCK FchParams; |
| 125 | |
| 126 | /* FIXME: Recover FCH_DATA_BLOCK from CBMEM. */ |
| 127 | s3_resume_init_data(&FchParams); |
| 128 | |
| 129 | FchParams.StdHeader = StdHeader; |
| 130 | FchInitS3EarlyRestore(&FchParams); |
| 131 | return AGESA_SUCCESS; |
| 132 | } |
| 133 | |
| 134 | AGESA_STATUS fchs3laterestore(AMD_CONFIG_PARAMS *StdHeader) |
| 135 | { |
| 136 | FCH_DATA_BLOCK FchParams; |
| 137 | |
| 138 | /* FIXME: Recover FCH_DATA_BLOCK from CBMEM. */ |
| 139 | s3_resume_init_data(&FchParams); |
| 140 | |
| 141 | FchParams.StdHeader = StdHeader; |
| 142 | FchInitS3LateRestore(&FchParams); |
| 143 | |
| 144 | return AGESA_SUCCESS; |
| 145 | } |