2 * This file is part of the coreboot project.
4 * Copyright (C) 2011 Advanced Micro Devices, Inc.
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.
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.
18 #include <northbridge/amd/agesa/BiosCallOuts.h>
19 #include "heapManager.h"
21 #include <southbridge/amd/cimx/sb800/gpio_oem.h>
24 static AGESA_STATUS
board_BeforeDramInit (UINT32 Func
, UINTN Data
, VOID
*ConfigPtr
);
25 static AGESA_STATUS
board_GnbPcieSlotReset (UINT32 Func
, UINTN Data
, VOID
*ConfigPtr
);
27 const BIOS_CALLOUT_STRUCT BiosCallouts
[] =
29 {AGESA_DO_RESET
, agesa_Reset
},
30 {AGESA_READ_SPD
, agesa_ReadSpd
},
31 {AGESA_READ_SPD_RECOVERY
, agesa_NoopUnsupported
},
32 {AGESA_RUNFUNC_ONAP
, agesa_RunFuncOnAp
},
33 {AGESA_GNB_PCIE_SLOT_RESET
, board_GnbPcieSlotReset
},
34 {AGESA_HOOKBEFORE_DRAM_INIT
, board_BeforeDramInit
},
35 {AGESA_HOOKBEFORE_DRAM_INIT_RECOVERY
, agesa_NoopSuccess
},
36 {AGESA_HOOKBEFORE_DQS_TRAINING
, agesa_NoopSuccess
},
37 {AGESA_HOOKBEFORE_EXIT_SELF_REF
, agesa_NoopSuccess
},
39 const int BiosCalloutsLen
= ARRAY_SIZE(BiosCallouts
);
41 /* Call the host environment interface to provide a user hook opportunity. */
42 static AGESA_STATUS
board_BeforeDramInit (UINT32 Func
, UINTN Data
, VOID
*ConfigPtr
)
46 MEM_DATA_STRUCT
*MemData
;
56 Status
= AGESA_SUCCESS
;
57 /* Get SB MMIO Base (AcpiMmioAddr) */
58 WriteIo8 (0xCD6, 0x27);
59 Data8
= ReadIo8(0xCD7);
61 WriteIo8 (0xCD6, 0x26);
62 Data8
= ReadIo8(0xCD7);
64 AcpiMmioAddr
= (UINT32
)Data16
<< 16;
65 GpioMmioAddr
= AcpiMmioAddr
+ GPIO_BASE
;
67 Data8
= Read64Mem8(GpioMmioAddr
+SB_GPIO_REG178
);
69 TempData8
= Read64Mem8 (GpioMmioAddr
+SB_GPIO_REG178
);
72 Write64Mem8(GpioMmioAddr
+SB_GPIO_REG178
, TempData8
);
76 TempData8
= Read64Mem8 (GpioMmioAddr
+SB_GPIO_REG178
);
79 Write64Mem8(GpioMmioAddr
+SB_GPIO_REG178
, TempData8
);
81 Data8
= Read64Mem8(GpioMmioAddr
+SB_GPIO_REG179
);
83 TempData8
= Read64Mem8 (GpioMmioAddr
+SB_GPIO_REG179
);
86 Write64Mem8(GpioMmioAddr
+SB_GPIO_REG179
, TempData8
);
90 TempData8
= Read64Mem8 (GpioMmioAddr
+SB_GPIO_REG179
);
93 Write64Mem8(GpioMmioAddr
+SB_GPIO_REG179
, TempData8
);
95 switch(MemData
->ParameterListPtr
->DDR3Voltage
){
97 Data8
= Read64Mem8 (GpioMmioAddr
+SB_GPIO_REG178
);
98 Data8
&= ~(UINT8
)BIT6
;
99 Write64Mem8(GpioMmioAddr
+SB_GPIO_REG178
, Data8
);
100 Data8
= Read64Mem8 (GpioMmioAddr
+SB_GPIO_REG179
);
101 Data8
|= (UINT8
)BIT6
;
102 Write64Mem8(GpioMmioAddr
+SB_GPIO_REG179
, Data8
);
105 Data8
= Read64Mem8 (GpioMmioAddr
+SB_GPIO_REG178
);
106 Data8
&= ~(UINT8
)BIT6
;
107 Write64Mem8(GpioMmioAddr
+SB_GPIO_REG178
, Data8
);
108 Data8
= Read64Mem8 (GpioMmioAddr
+SB_GPIO_REG179
);
109 Data8
&= ~(UINT8
)BIT6
;
110 Write64Mem8(GpioMmioAddr
+SB_GPIO_REG179
, Data8
);
114 Data8
= Read64Mem8 (GpioMmioAddr
+SB_GPIO_REG178
);
115 Data8
|= (UINT8
)BIT6
;
116 Write64Mem8(GpioMmioAddr
+SB_GPIO_REG178
, Data8
);
117 Data8
= Read64Mem8 (GpioMmioAddr
+SB_GPIO_REG179
);
118 Data8
&= ~(UINT8
)BIT6
;
119 Write64Mem8(GpioMmioAddr
+SB_GPIO_REG179
, Data8
);
124 /* PCIE slot reset control */
125 static AGESA_STATUS
board_GnbPcieSlotReset (UINT32 Func
, UINTN Data
, VOID
*ConfigPtr
)
129 PCIe_SLOT_RESET_INFO
*ResetInfo
;
137 ResetInfo
= ConfigPtr
;
138 // Get SB800 MMIO Base (AcpiMmioAddr)
139 WriteIo8(0xCD6, 0x27);
140 Data8
= ReadIo8(0xCD7);
142 WriteIo8(0xCD6, 0x26);
143 Data8
= ReadIo8(0xCD7);
145 AcpiMmioAddr
= (UINT32
)Data16
<< 16;
146 Status
= AGESA_UNSUPPORTED
;
147 GpioMmioAddr
= AcpiMmioAddr
+ GPIO_BASE
;
148 switch (ResetInfo
->ResetId
)
151 switch (ResetInfo
->ResetControl
)
153 case AssertSlotReset
:
154 Data8
= Read64Mem8(GpioMmioAddr
+SB_GPIO_REG21
);
155 Data8
&= ~(UINT8
)BIT6
;
156 Write64Mem8(GpioMmioAddr
+SB_GPIO_REG21
, Data8
); // MXM_GPIO0. GPIO21
157 Status
= AGESA_SUCCESS
;
159 case DeassertSlotReset
:
160 Data8
= Read64Mem8(GpioMmioAddr
+SB_GPIO_REG21
);
162 Write64Mem8 (GpioMmioAddr
+SB_GPIO_REG21
, Data8
); // MXM_GPIO0. GPIO21
163 Status
= AGESA_SUCCESS
;
168 switch (ResetInfo
->ResetControl
)
170 case AssertSlotReset
:
171 Data8
= Read64Mem8(GpioMmioAddr
+SB_GPIO_REG25
);
172 Data8
&= ~(UINT8
)BIT6
;
173 Write64Mem8(GpioMmioAddr
+SB_GPIO_REG25
, Data8
); // PCIE_RST#_LAN, GPIO25
174 Status
= AGESA_SUCCESS
;
176 case DeassertSlotReset
:
177 Data8
= Read64Mem8(GpioMmioAddr
+SB_GPIO_REG25
);
179 Write64Mem8 (GpioMmioAddr
+SB_GPIO_REG25
, Data8
); // PCIE_RST#_LAN, GPIO25
180 Status
= AGESA_SUCCESS
;
185 switch (ResetInfo
->ResetControl
)
187 case AssertSlotReset
:
188 Data8
= Read64Mem8(GpioMmioAddr
+SB_GPIO_REG02
);
189 Data8
&= ~(UINT8
)BIT6
;
190 Write64Mem8(GpioMmioAddr
+SB_GPIO_REG02
, Data8
); // MPCIE_RST0, GPIO02
191 Status
= AGESA_SUCCESS
;
193 case DeassertSlotReset
:
194 Data8
= Read64Mem8(GpioMmioAddr
+SB_GPIO_REG02
);
196 Write64Mem8 (GpioMmioAddr
+SB_GPIO_REG02
, Data8
); // MPCIE_RST0, GPIO02
197 Status
= AGESA_SUCCESS
;