2020-04-02 23:48:19 +02:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2014-05-04 16:07:45 +02:00
|
|
|
|
2014-05-05 15:40:15 +02:00
|
|
|
#include <cbfs.h>
|
2019-03-29 17:45:28 +01:00
|
|
|
#include <console/console.h>
|
2017-01-28 15:59:25 +01:00
|
|
|
#include <spd_bin.h>
|
2017-07-28 03:48:35 +02:00
|
|
|
#include <string.h>
|
2014-05-05 15:40:15 +02:00
|
|
|
|
2018-10-14 14:52:06 +02:00
|
|
|
#include <AGESA.h>
|
|
|
|
#include <amdlib.h>
|
2014-05-04 16:07:45 +02:00
|
|
|
#include "Ids.h"
|
2017-07-28 03:48:35 +02:00
|
|
|
#include <northbridge/amd/agesa/state_machine.h>
|
2017-09-08 06:14:17 +02:00
|
|
|
#include <northbridge/amd/agesa/BiosCallOuts.h>
|
|
|
|
#include <northbridge/amd/agesa/dimmSpd.h>
|
2014-05-04 16:07:45 +02:00
|
|
|
|
2020-06-08 05:05:03 +02:00
|
|
|
#if ENV_X86_64 && CONFIG(NORTHBRIDGE_AMD_PI)
|
2017-04-13 15:56:07 +02:00
|
|
|
#error "FIXME: CALLOUT_ENTRY is UINT32 Data, not UINT Data"
|
|
|
|
#endif
|
|
|
|
|
2015-07-30 20:16:37 +02:00
|
|
|
AGESA_STATUS GetBiosCallout (UINT32 Func, UINTN Data, VOID *ConfigPtr)
|
2014-05-05 12:20:56 +02:00
|
|
|
{
|
2015-01-02 21:46:32 +01:00
|
|
|
AGESA_STATUS status;
|
2014-05-05 12:20:56 +02:00
|
|
|
UINTN i;
|
|
|
|
|
2017-09-06 14:42:23 +02:00
|
|
|
if (ENV_RAMSTAGE) {
|
2017-09-08 06:37:06 +02:00
|
|
|
/* One HeapManager serves them all. */
|
|
|
|
status = HeapManagerCallout(Func, Data, ConfigPtr);
|
|
|
|
if (status != AGESA_UNSUPPORTED)
|
|
|
|
return status;
|
|
|
|
}
|
2015-01-02 21:46:32 +01:00
|
|
|
|
2017-03-30 16:26:25 +02:00
|
|
|
#if HAS_AGESA_FCH_OEM_CALLOUT
|
2017-09-06 14:42:23 +02:00
|
|
|
if (Func == AGESA_FCH_OEM_CALLOUT) {
|
2017-03-30 16:26:25 +02:00
|
|
|
agesa_fch_oem_config(Data, ConfigPtr);
|
|
|
|
return AGESA_SUCCESS;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-05-05 12:20:56 +02:00
|
|
|
for (i = 0; i < BiosCalloutsLen; i++) {
|
|
|
|
if (BiosCallouts[i].CalloutName == Func)
|
|
|
|
break;
|
|
|
|
}
|
2016-08-23 21:36:02 +02:00
|
|
|
if (i >= BiosCalloutsLen)
|
2014-05-05 12:20:56 +02:00
|
|
|
return AGESA_UNSUPPORTED;
|
|
|
|
|
|
|
|
return BiosCallouts[i].CalloutPtr (Func, Data, ConfigPtr);
|
|
|
|
}
|
|
|
|
|
2015-07-30 20:16:37 +02:00
|
|
|
AGESA_STATUS agesa_NoopUnsupported (UINT32 Func, UINTN Data, VOID *ConfigPtr)
|
2014-05-04 16:07:45 +02:00
|
|
|
{
|
|
|
|
return AGESA_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
|
2015-07-30 20:16:37 +02:00
|
|
|
AGESA_STATUS agesa_NoopSuccess (UINT32 Func, UINTN Data, VOID *ConfigPtr)
|
2014-05-04 16:07:45 +02:00
|
|
|
{
|
|
|
|
return AGESA_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2015-07-30 20:16:37 +02:00
|
|
|
AGESA_STATUS agesa_EmptyIdsInitData (UINT32 Func, UINTN Data, VOID *ConfigPtr)
|
2014-05-04 16:07:45 +02:00
|
|
|
{
|
|
|
|
IDS_NV_ITEM *IdsPtr = ((IDS_CALLOUT_STRUCT *) ConfigPtr)->IdsNvPtr;
|
|
|
|
if (Data == IDS_CALLOUT_INIT)
|
|
|
|
IdsPtr[0].IdsNvValue = IdsPtr[0].IdsNvId = 0xffff;
|
|
|
|
return AGESA_SUCCESS;
|
|
|
|
}
|
2014-05-04 22:13:54 +02:00
|
|
|
|
2015-07-30 20:16:37 +02:00
|
|
|
AGESA_STATUS agesa_Reset (UINT32 Func, UINTN Data, VOID *ConfigPtr)
|
2014-05-04 22:13:54 +02:00
|
|
|
{
|
|
|
|
AGESA_STATUS Status;
|
|
|
|
UINT8 Value;
|
|
|
|
UINTN ResetType;
|
|
|
|
AMD_CONFIG_PARAMS *StdHeader;
|
|
|
|
|
|
|
|
ResetType = Data;
|
|
|
|
StdHeader = ConfigPtr;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Perform the RESET based upon the ResetType. In case of
|
2018-08-07 12:23:16 +02:00
|
|
|
// WARM_RESET_WHENEVER and COLD_RESET_WHENEVER, the request will go to
|
2014-05-04 22:13:54 +02:00
|
|
|
// AmdResetManager. During the critical condition, where reset is required
|
|
|
|
// immediately, the reset will be invoked directly by writing 0x04 to port
|
|
|
|
// 0xCF9 (Reset Port).
|
|
|
|
//
|
|
|
|
switch (ResetType) {
|
|
|
|
case WARM_RESET_WHENEVER:
|
|
|
|
case COLD_RESET_WHENEVER:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WARM_RESET_IMMEDIATELY:
|
|
|
|
case COLD_RESET_IMMEDIATELY:
|
|
|
|
Value = 0x06;
|
|
|
|
LibAmdIoWrite (AccessWidth8, 0xCf9, &Value, StdHeader);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
Status = 0;
|
|
|
|
return Status;
|
|
|
|
}
|
2014-05-05 11:05:53 +02:00
|
|
|
|
2015-07-30 20:16:37 +02:00
|
|
|
AGESA_STATUS agesa_RunFuncOnAp (UINT32 Func, UINTN Data, VOID *ConfigPtr)
|
2014-05-05 11:05:53 +02:00
|
|
|
{
|
2016-11-25 10:21:02 +01:00
|
|
|
AMD_CONFIG_PARAMS *StdHeader = ConfigPtr;
|
2017-07-28 03:48:35 +02:00
|
|
|
AGESA_STATUS status;
|
|
|
|
AP_EXE_PARAMS ApExeParams;
|
2014-05-05 11:05:53 +02:00
|
|
|
|
2017-07-28 03:48:35 +02:00
|
|
|
memset(&ApExeParams, 0, sizeof(AP_EXE_PARAMS));
|
2017-09-06 14:42:23 +02:00
|
|
|
memcpy(&ApExeParams.StdHeader, StdHeader, sizeof(*StdHeader));
|
2016-11-25 10:21:02 +01:00
|
|
|
|
2017-07-28 03:48:35 +02:00
|
|
|
ApExeParams.FunctionNumber = Func;
|
|
|
|
ApExeParams.RelatedDataBlock = ConfigPtr;
|
|
|
|
|
2016-11-25 10:21:02 +01:00
|
|
|
status = module_dispatch(AMD_LATE_RUN_AP_TASK, &ApExeParams.StdHeader);
|
2017-07-28 03:48:35 +02:00
|
|
|
|
2016-11-25 10:21:02 +01:00
|
|
|
ASSERT(status == AGESA_SUCCESS);
|
2017-07-28 03:48:35 +02:00
|
|
|
return status;
|
2014-05-05 11:05:53 +02:00
|
|
|
}
|
|
|
|
|
2017-04-13 16:01:18 +02:00
|
|
|
#if defined(AGESA_GNB_GFX_GET_VBIOS_IMAGE)
|
2015-07-30 20:16:37 +02:00
|
|
|
AGESA_STATUS agesa_GfxGetVbiosImage(UINT32 Func, UINTN FchData, VOID *ConfigPrt)
|
2014-05-04 22:13:08 +02:00
|
|
|
{
|
|
|
|
GFX_VBIOS_IMAGE_INFO *pVbiosImageInfo = (GFX_VBIOS_IMAGE_INFO *)ConfigPrt;
|
2015-05-16 06:39:23 +02:00
|
|
|
pVbiosImageInfo->ImagePtr = cbfs_boot_map_with_leak(
|
|
|
|
"pci"CONFIG_VGA_BIOS_ID".rom",
|
2014-05-04 22:13:08 +02:00
|
|
|
CBFS_TYPE_OPTIONROM, NULL);
|
|
|
|
/* printk(BIOS_DEBUG, "IMGptr=%x\n", pVbiosImageInfo->ImagePtr); */
|
|
|
|
return pVbiosImageInfo->ImagePtr == NULL ? AGESA_WARNING : AGESA_SUCCESS;
|
|
|
|
}
|
2014-10-17 21:33:22 +02:00
|
|
|
#endif
|
2014-10-17 21:33:22 +02:00
|
|
|
|
2015-07-30 20:16:37 +02:00
|
|
|
AGESA_STATUS agesa_ReadSpd (UINT32 Func, UINTN Data, VOID *ConfigPtr)
|
2014-10-17 21:33:22 +02:00
|
|
|
{
|
2019-08-19 07:41:50 +02:00
|
|
|
if (!ENV_ROMSTAGE)
|
|
|
|
return AGESA_UNSUPPORTED;
|
|
|
|
|
|
|
|
return AmdMemoryReadSPD (Func, Data, ConfigPtr);
|
2014-10-17 21:33:22 +02:00
|
|
|
}
|
2014-05-05 15:40:15 +02:00
|
|
|
|
2015-07-30 20:16:37 +02:00
|
|
|
AGESA_STATUS agesa_ReadSpd_from_cbfs(UINT32 Func, UINTN Data, VOID *ConfigPtr)
|
2014-05-05 15:40:15 +02:00
|
|
|
{
|
|
|
|
AGESA_READ_SPD_PARAMS *info = ConfigPtr;
|
2019-08-19 07:41:50 +02:00
|
|
|
|
|
|
|
if (!ENV_ROMSTAGE)
|
|
|
|
return AGESA_UNSUPPORTED;
|
|
|
|
|
2014-05-05 15:40:15 +02:00
|
|
|
if (info->MemChannelId > 0)
|
|
|
|
return AGESA_UNSUPPORTED;
|
|
|
|
if (info->SocketId != 0)
|
|
|
|
return AGESA_UNSUPPORTED;
|
|
|
|
if (info->DimmId != 0)
|
|
|
|
return AGESA_UNSUPPORTED;
|
|
|
|
|
|
|
|
/* Read index 0, first SPD_SIZE bytes of spd.bin file. */
|
2017-01-28 15:26:43 +01:00
|
|
|
if (read_ddr3_spd_from_cbfs((u8*)info->Buffer, 0) < 0)
|
2014-05-05 15:40:15 +02:00
|
|
|
die("No SPD data\n");
|
|
|
|
|
2019-08-19 07:41:50 +02:00
|
|
|
return AGESA_SUCCESS;
|
2014-05-05 15:40:15 +02:00
|
|
|
}
|
2017-03-30 16:26:25 +02:00
|
|
|
|
|
|
|
#if HAS_AGESA_FCH_OEM_CALLOUT
|
|
|
|
void agesa_fch_oem_config(uintptr_t Data, AMD_CONFIG_PARAMS *StdHeader)
|
|
|
|
{
|
|
|
|
struct sysinfo *cb_NA = NULL;
|
|
|
|
|
|
|
|
if (StdHeader->Func == AMD_INIT_RESET) {
|
|
|
|
printk(BIOS_DEBUG, "Fch OEM config in INIT RESET\n");
|
|
|
|
board_FCH_InitReset(cb_NA, (FCH_RESET_DATA_BLOCK *)Data);
|
|
|
|
} else if (StdHeader->Func == AMD_INIT_ENV) {
|
|
|
|
printk(BIOS_DEBUG, "Fch OEM config in INIT ENV\n");
|
|
|
|
board_FCH_InitEnv(cb_NA, (FCH_DATA_BLOCK *)Data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|