coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
BiosCallOuts.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <AGESA.h>
4 #include <amdlib.h>
5 #include <amdblocks/acpimmio.h>
7 #include <SB800.h>
8 
9 static AGESA_STATUS board_BeforeDramInit (UINT32 Func, UINTN Data, VOID *ConfigPtr);
10 
12 {
13  {AGESA_DO_RESET, agesa_Reset },
14  {AGESA_READ_SPD, agesa_ReadSpd },
15  {AGESA_READ_SPD_RECOVERY, agesa_NoopUnsupported },
16  {AGESA_RUNFUNC_ONAP, agesa_RunFuncOnAp },
17  {AGESA_HOOKBEFORE_DQS_TRAINING, agesa_NoopSuccess },
18  {AGESA_HOOKBEFORE_DRAM_INIT, board_BeforeDramInit },
19  {AGESA_HOOKBEFORE_EXIT_SELF_REF, agesa_NoopSuccess },
20  {AGESA_GNB_PCIE_SLOT_RESET, agesa_NoopUnsupported },
21 };
23 
24 /* Call the host environment interface to provide a user hook opportunity. */
25 static AGESA_STATUS board_BeforeDramInit (UINT32 Func, UINTN Data, VOID *ConfigPtr)
26 {
27  AGESA_STATUS Status;
28  MEM_DATA_STRUCT *MemData;
29  UINT32 GpioMmioAddr;
30  UINT8 Data8;
31  UINT8 TempData8;
32 
33  MemData = ConfigPtr;
34 
35  Status = AGESA_SUCCESS;
36  GpioMmioAddr = (uintptr_t)acpimmio_gpio_100;
37 
38  Data8 = Read64Mem8(GpioMmioAddr+SB_GPIO_REG178);
39  Data8 &= ~BIT5;
40  TempData8 = Read64Mem8(GpioMmioAddr+SB_GPIO_REG178);
41  TempData8 &= 0x03;
42  TempData8 |= Data8;
43  Write64Mem8(GpioMmioAddr+SB_GPIO_REG178, TempData8);
44 
45  Data8 |= BIT2+BIT3;
46  Data8 &= ~BIT4;
47  TempData8 = Read64Mem8(GpioMmioAddr+SB_GPIO_REG178);
48  TempData8 &= 0x23;
49  TempData8 |= Data8;
50  Write64Mem8(GpioMmioAddr+SB_GPIO_REG178, TempData8);
51  Data8 = Read64Mem8(GpioMmioAddr+SB_GPIO_REG179);
52  Data8 &= ~BIT5;
53  TempData8 = Read64Mem8(GpioMmioAddr+SB_GPIO_REG179);
54  TempData8 &= 0x03;
55  TempData8 |= Data8;
56  Write64Mem8(GpioMmioAddr+SB_GPIO_REG179, TempData8);
57  Data8 |= BIT2+BIT3;
58  Data8 &= ~BIT4;
59  TempData8 = Read64Mem8(GpioMmioAddr+SB_GPIO_REG179);
60  TempData8 &= 0x23;
61  TempData8 |= Data8;
62  Write64Mem8(GpioMmioAddr+SB_GPIO_REG179, TempData8);
63 
64  /*
65  * this seems to be just copy-pasted from the AMD reference boards and
66  * needs some investigation
67  */
68  switch (MemData->ParameterListPtr->DDR3Voltage) {
69  case VOLT1_35:
70  Data8 = Read64Mem8(GpioMmioAddr+SB_GPIO_REG178);
71  Data8 &= ~(UINT8)BIT6;
72  Write64Mem8(GpioMmioAddr+SB_GPIO_REG178, Data8);
73  Data8 = Read64Mem8(GpioMmioAddr+SB_GPIO_REG179);
74  Data8 |= (UINT8)BIT6;
75  Write64Mem8(GpioMmioAddr+SB_GPIO_REG179, Data8);
76  break;
77  case VOLT1_25:
78  Data8 = Read64Mem8(GpioMmioAddr+SB_GPIO_REG178);
79  Data8 &= ~(UINT8)BIT6;
80  Write64Mem8(GpioMmioAddr+SB_GPIO_REG178, Data8);
81  Data8 = Read64Mem8(GpioMmioAddr+SB_GPIO_REG179);
82  Data8 &= ~(UINT8)BIT6;
83  Write64Mem8(GpioMmioAddr+SB_GPIO_REG179, Data8);
84  break;
85  case VOLT1_5:
86  default:
87  Data8 = Read64Mem8(GpioMmioAddr+SB_GPIO_REG178);
88  Data8 |= (UINT8)BIT6;
89  Write64Mem8(GpioMmioAddr+SB_GPIO_REG178, Data8);
90  Data8 = Read64Mem8(GpioMmioAddr+SB_GPIO_REG179);
91  Data8 &= ~(UINT8)BIT6;
92  Write64Mem8(GpioMmioAddr+SB_GPIO_REG179, Data8);
93  }
94  /* disable memory clear for boot time reduction */
95  MemData->ParameterListPtr->EnableMemClr = FALSE;
96  return Status;
97 }
#define AGESA_SUCCESS
Definition: Amd.h:38
unsigned int AGESA_STATUS
Definition: Amd.h:36
#define BIT3
Definition: Ioh.h:10
#define BIT2
Definition: Ioh.h:9
#define BIT4
Definition: Ioh.h:11
#define BIT6
Definition: Ioh.h:13
#define BIT5
Definition: Ioh.h:12
uint8_t *MAYBE_CONST acpimmio_gpio_100
#define ARRAY_SIZE(a)
Definition: helpers.h:12
AGESA_STATUS agesa_RunFuncOnAp(UINT32 Func, UINTN Data, VOID *ConfigPtr)
Definition: def_callouts.c:102
AGESA_STATUS agesa_NoopUnsupported(UINT32 Func, UINTN Data, VOID *ConfigPtr)
Definition: def_callouts.c:48
AGESA_STATUS agesa_NoopSuccess(UINT32 Func, UINTN Data, VOID *ConfigPtr)
Definition: def_callouts.c:53
AGESA_STATUS agesa_Reset(UINT32 Func, UINTN Data, VOID *ConfigPtr)
Definition: def_callouts.c:66
const int BiosCalloutsLen
Definition: BiosCallOuts.c:25
const BIOS_CALLOUT_STRUCT BiosCallouts[]
Definition: BiosCallOuts.c:13
static AGESA_STATUS board_BeforeDramInit(UINT32 Func, UINTN Data, VOID *ConfigPtr)
Definition: BiosCallOuts.c:25
AGESA_STATUS agesa_ReadSpd(uint32_t Func, uintptr_t Data, void *ConfigPtr)
Definition: BiosCallOuts.c:81
unsigned long uintptr_t
Definition: stdint.h:21