1 /* SPDX-License-Identifier: GPL-2.0-only */
4 #include <console/console.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"
19 AGESA_STATUS
GetBiosCallout (UINT32 Func
, UINTN Data
, VOID
*ConfigPtr
)
25 /* One HeapManager serves them all. */
26 status
= HeapManagerCallout(Func
, Data
, ConfigPtr
);
27 if (status
!= AGESA_UNSUPPORTED
)
31 #if HAS_AGESA_FCH_OEM_CALLOUT
32 if (Func
== AGESA_FCH_OEM_CALLOUT
) {
33 agesa_fch_oem_config(Data
, ConfigPtr
);
38 for (i
= 0; i
< BiosCalloutsLen
; i
++) {
39 if (BiosCallouts
[i
].CalloutName
== Func
)
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
)
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;
66 AGESA_STATUS
agesa_Reset(UINT32 Func
, UINTN Data
, VOID
*ConfigPtr
)
71 AMD_CONFIG_PARAMS
*StdHeader
;
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).
84 case WARM_RESET_WHENEVER
:
85 case COLD_RESET_WHENEVER
:
88 case WARM_RESET_IMMEDIATELY
:
89 case COLD_RESET_IMMEDIATELY
:
91 LibAmdIoWrite(AccessWidth8
, 0xCf9, &Value
, StdHeader
);
102 AGESA_STATUS
agesa_RunFuncOnAp(UINT32 Func
, UINTN Data
, VOID
*ConfigPtr
)
104 AMD_CONFIG_PARAMS
*StdHeader
= ConfigPtr
;
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
);
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
;
130 AGESA_STATUS
agesa_ReadSpd(UINT32 Func
, UINTN Data
, VOID
*ConfigPtr
)
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
;
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
);