soc/intel/alderlake: Add ADL-P 4+4 with 28W TDP
[coreboot.git] / src / drivers / amd / agesa / def_callouts.c
blobab4269d3abf939c0981c3ab174f083814929aae6
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <cbfs.h>
4 #include <console/console.h>
5 #include <spd_bin.h>
6 #include <string.h>
8 #include <AGESA.h>
9 #include <amdlib.h>
10 #include "Ids.h"
11 #include <northbridge/amd/agesa/state_machine.h>
12 #include <northbridge/amd/agesa/BiosCallOuts.h>
13 #include <northbridge/amd/agesa/dimmSpd.h>
15 #if ENV_X86_64 && CONFIG(NORTHBRIDGE_AMD_PI)
16 #error "FIXME: CALLOUT_ENTRY is UINT32 Data, not UINT Data"
17 #endif
19 AGESA_STATUS GetBiosCallout (UINT32 Func, UINTN Data, VOID *ConfigPtr)
21 AGESA_STATUS status;
22 UINTN i;
24 if (ENV_RAMSTAGE) {
25 /* One HeapManager serves them all. */
26 status = HeapManagerCallout(Func, Data, ConfigPtr);
27 if (status != AGESA_UNSUPPORTED)
28 return status;
31 #if HAS_AGESA_FCH_OEM_CALLOUT
32 if (Func == AGESA_FCH_OEM_CALLOUT) {
33 agesa_fch_oem_config(Data, ConfigPtr);
34 return AGESA_SUCCESS;
36 #endif
38 for (i = 0; i < BiosCalloutsLen; i++) {
39 if (BiosCallouts[i].CalloutName == Func)
40 break;
42 if (i >= BiosCalloutsLen)
43 return AGESA_UNSUPPORTED;
45 return BiosCallouts[i].CalloutPtr(Func, Data, ConfigPtr);
48 AGESA_STATUS agesa_NoopUnsupported(UINT32 Func, UINTN Data, VOID *ConfigPtr)
50 return AGESA_UNSUPPORTED;
53 AGESA_STATUS agesa_NoopSuccess(UINT32 Func, UINTN Data, VOID *ConfigPtr)
55 return AGESA_SUCCESS;
58 AGESA_STATUS agesa_EmptyIdsInitData(UINT32 Func, UINTN Data, VOID *ConfigPtr)
60 IDS_NV_ITEM *IdsPtr = ((IDS_CALLOUT_STRUCT *) ConfigPtr)->IdsNvPtr;
61 if (Data == IDS_CALLOUT_INIT)
62 IdsPtr[0].IdsNvValue = IdsPtr[0].IdsNvId = 0xffff;
63 return AGESA_SUCCESS;
66 AGESA_STATUS agesa_Reset(UINT32 Func, UINTN Data, VOID *ConfigPtr)
68 AGESA_STATUS Status;
69 UINT8 Value;
70 UINTN ResetType;
71 AMD_CONFIG_PARAMS *StdHeader;
73 ResetType = Data;
74 StdHeader = ConfigPtr;
77 // Perform the RESET based upon the ResetType. In case of
78 // WARM_RESET_WHENEVER and COLD_RESET_WHENEVER, the request will go to
79 // AmdResetManager. During the critical condition, where reset is required
80 // immediately, the reset will be invoked directly by writing 0x04 to port
81 // 0xCF9 (Reset Port).
83 switch (ResetType) {
84 case WARM_RESET_WHENEVER:
85 case COLD_RESET_WHENEVER:
86 break;
88 case WARM_RESET_IMMEDIATELY:
89 case COLD_RESET_IMMEDIATELY:
90 Value = 0x06;
91 LibAmdIoWrite(AccessWidth8, 0xCf9, &Value, StdHeader);
92 break;
94 default:
95 break;
98 Status = 0;
99 return Status;
102 AGESA_STATUS agesa_RunFuncOnAp(UINT32 Func, UINTN Data, VOID *ConfigPtr)
104 AMD_CONFIG_PARAMS *StdHeader = ConfigPtr;
105 AGESA_STATUS status;
106 AP_EXE_PARAMS ApExeParams;
108 memset(&ApExeParams, 0, sizeof(AP_EXE_PARAMS));
109 memcpy(&ApExeParams.StdHeader, StdHeader, sizeof(*StdHeader));
111 ApExeParams.FunctionNumber = Func;
112 ApExeParams.RelatedDataBlock = ConfigPtr;
114 status = module_dispatch(AMD_LATE_RUN_AP_TASK, &ApExeParams.StdHeader);
116 ASSERT(status == AGESA_SUCCESS);
117 return status;
120 #if defined(AGESA_GNB_GFX_GET_VBIOS_IMAGE)
121 AGESA_STATUS agesa_GfxGetVbiosImage(UINT32 Func, UINTN FchData, VOID *ConfigPrt)
123 GFX_VBIOS_IMAGE_INFO *pVbiosImageInfo = (GFX_VBIOS_IMAGE_INFO *)ConfigPrt;
124 pVbiosImageInfo->ImagePtr = cbfs_map("pci"CONFIG_VGA_BIOS_ID".rom", NULL);
125 /* printk(BIOS_DEBUG, "IMGptr=%x\n", pVbiosImageInfo->ImagePtr); */
126 return pVbiosImageInfo->ImagePtr == NULL ? AGESA_WARNING : AGESA_SUCCESS;
128 #endif
130 AGESA_STATUS agesa_ReadSpd(UINT32 Func, UINTN Data, VOID *ConfigPtr)
132 if (!ENV_RAMINIT)
133 return AGESA_UNSUPPORTED;
135 return AmdMemoryReadSPD(Func, Data, ConfigPtr);
138 AGESA_STATUS agesa_ReadSpd_from_cbfs(UINT32 Func, UINTN Data, VOID *ConfigPtr)
140 AGESA_READ_SPD_PARAMS *info = ConfigPtr;
142 if (!ENV_RAMINIT)
143 return AGESA_UNSUPPORTED;
145 if (info->MemChannelId > 0)
146 return AGESA_UNSUPPORTED;
147 if (info->SocketId != 0)
148 return AGESA_UNSUPPORTED;
149 if (info->DimmId != 0)
150 return AGESA_UNSUPPORTED;
152 /* Read index 0, first SPD_SIZE bytes of spd.bin file. */
153 if (read_ddr3_spd_from_cbfs((u8*)info->Buffer, 0) < 0)
154 die("No SPD data\n");
156 return AGESA_SUCCESS;
159 #if HAS_AGESA_FCH_OEM_CALLOUT
160 void agesa_fch_oem_config(uintptr_t Data, AMD_CONFIG_PARAMS *StdHeader)
162 struct sysinfo *cb_NA = NULL;
164 if (StdHeader->Func == AMD_INIT_RESET) {
165 printk(BIOS_DEBUG, "Fch OEM config in INIT RESET\n");
166 board_FCH_InitReset(cb_NA, (FCH_RESET_DATA_BLOCK *)Data);
167 } else if (StdHeader->Func == AMD_INIT_ENV) {
168 printk(BIOS_DEBUG, "Fch OEM config in INIT ENV\n");
169 board_FCH_InitEnv(cb_NA, (FCH_DATA_BLOCK *)Data);
172 #endif