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>
21 #include <southbridge/amd/cimx/sb700/gpio_oem.h>
23 static AGESA_STATUS
board_BeforeDramInit (UINT32 Func
, UINTN Data
, VOID
*ConfigPtr
);
24 static AGESA_STATUS
board_GnbPcieSlotReset (UINT32 Func
, UINTN Data
, VOID
*ConfigPtr
);
26 const BIOS_CALLOUT_STRUCT BiosCallouts
[] =
28 {AGESA_DO_RESET
, agesa_Reset
},
29 {AGESA_READ_SPD
, agesa_ReadSpd
},
30 {AGESA_READ_SPD_RECOVERY
, agesa_NoopUnsupported
},
31 {AGESA_RUNFUNC_ONAP
, agesa_RunFuncOnAp
},
32 {AGESA_GNB_PCIE_SLOT_RESET
, board_GnbPcieSlotReset
},
33 {AGESA_GET_IDS_INIT_DATA
, agesa_EmptyIdsInitData
},
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
;
55 Status
= AGESA_SUCCESS
;
56 /* Get SB MMIO Base (AcpiMmioAddr) */
57 WriteIo8 (0xCD6, 0x27);
58 Data8
= ReadIo8(0xCD7);
60 WriteIo8 (0xCD6, 0x26);
61 Data8
= ReadIo8(0xCD7);
63 AcpiMmioAddr
= (UINT32
)Data16
<< 16;
64 GpioMmioAddr
= AcpiMmioAddr
+ GPIO_BASE
;
66 switch(MemData
->ParameterListPtr
->DDR3Voltage
){
68 Data8
= Read64Mem8 (GpioMmioAddr
+SB_GPIO_REG178
);
69 Data8
&= ~(UINT8
)BIT6
;
70 Write64Mem8(GpioMmioAddr
+SB_GPIO_REG178
, Data8
);
71 Data8
= Read64Mem8 (GpioMmioAddr
+SB_GPIO_REG179
);
73 Write64Mem8(GpioMmioAddr
+SB_GPIO_REG179
, Data8
);
76 Data8
= Read64Mem8 (GpioMmioAddr
+SB_GPIO_REG178
);
77 Data8
&= ~(UINT8
)BIT6
;
78 Write64Mem8(GpioMmioAddr
+SB_GPIO_REG178
, Data8
);
79 Data8
= Read64Mem8 (GpioMmioAddr
+SB_GPIO_REG179
);
80 Data8
&= ~(UINT8
)BIT6
;
81 Write64Mem8(GpioMmioAddr
+SB_GPIO_REG179
, Data8
);
85 Data8
= Read64Mem8 (GpioMmioAddr
+SB_GPIO_REG178
);
87 Write64Mem8(GpioMmioAddr
+SB_GPIO_REG178
, Data8
);
92 /* PCIE slot reset control */
93 static AGESA_STATUS
board_GnbPcieSlotReset (UINT32 Func
, UINTN Data
, VOID
*ConfigPtr
)
97 PCIe_SLOT_RESET_INFO
*ResetInfo
;
105 ResetInfo
= ConfigPtr
;
106 // Get SB MMIO Base (AcpiMmioAddr)
107 WriteIo8(0xCD6, 0x27);
108 Data8
= ReadIo8(0xCD7);
110 WriteIo8(0xCD6, 0x26);
111 Data8
= ReadIo8(0xCD7);
113 AcpiMmioAddr
= (UINT32
)Data16
<< 16;
114 Status
= AGESA_UNSUPPORTED
;
115 GpioMmioAddr
= AcpiMmioAddr
+ GPIO_BASE
;
117 if (ResetInfo
->ResetControl
== DeassertSlotReset
) {
118 if (ResetInfo
->ResetId
& (BIT2
+BIT3
)) { //de-assert
119 // [GPIO] GPIO45: PE_GPIO1 MXM_POWER_ENABLE, SET HIGH
120 Data8
= Read64Mem8(GpioMmioAddr
+SB_GPIO_REG45
);
122 Data8
= Read64Mem8(GpioMmioAddr
+SB_GPIO_REG28
);
123 while (!(Data8
& BIT7
)) {
124 Data8
= Read64Mem8(GpioMmioAddr
+SB_GPIO_REG28
);
126 // GPIO44: PE_GPIO0 MXM Reset
127 Data8
= Read64Mem8(GpioMmioAddr
+SB_GPIO_REG44
);
129 Write64Mem8 (GpioMmioAddr
+SB_GPIO_REG44
, Data8
);
130 Status
= AGESA_SUCCESS
;
133 Status
= AGESA_UNSUPPORTED
;
136 Data8
= Read64Mem8(GpioMmioAddr
+SB_GPIO_REG24
);
138 Write64Mem8 (GpioMmioAddr
+SB_GPIO_REG24
, Data8
);
139 //DE-Assert ALL PCIE RESET
141 Data8
= Read64Mem8(GpioMmioAddr
+SB_GPIO_REG25
);
143 Write64Mem8 (GpioMmioAddr
+SB_GPIO_REG25
, Data8
);
145 Data8
= Read64Mem8(GpioMmioAddr
+SB_GPIO_REG01
);
147 Write64Mem8 (GpioMmioAddr
+SB_GPIO_REG01
, Data8
);
149 Data8
= Read64Mem8(GpioMmioAddr
+SB_GPIO_REG00
);
151 Write64Mem8 (GpioMmioAddr
+SB_GPIO_REG00
, Data8
);
153 Data8
= Read64Mem8(GpioMmioAddr
+SB_GPIO_REG27
);
155 Write64Mem8 (GpioMmioAddr
+SB_GPIO_REG27
, Data8
);
157 if (ResetInfo
->ResetId
& (BIT2
+BIT3
)) { //Pcie Slot Reset is supported
158 // GPIO44: PE_GPIO0 MXM Reset
159 Data8
= Read64Mem8(GpioMmioAddr
+SB_GPIO_REG44
);
160 Data8
&= ~(UINT8
)BIT6
;
161 Write64Mem8 (GpioMmioAddr
+SB_GPIO_REG44
, Data8
);
162 Status
= AGESA_SUCCESS
;
165 Data8
= Read64Mem8(GpioMmioAddr
+SB_GPIO_REG24
);
166 Data8
&= ~(UINT8
)BIT6
;
167 Write64Mem8 (GpioMmioAddr
+SB_GPIO_REG24
, Data8
);
168 //Assert ALL PCIE RESET
170 Data8
= Read64Mem8(GpioMmioAddr
+SB_GPIO_REG25
);
171 Data8
&= ~(UINT8
)BIT6
;
172 Write64Mem8 (GpioMmioAddr
+SB_GPIO_REG25
, Data8
);
174 Data8
= Read64Mem8(GpioMmioAddr
+SB_GPIO_REG01
);
175 Data8
&= ~(UINT8
)BIT6
;
176 Write64Mem8 (GpioMmioAddr
+SB_GPIO_REG01
, Data8
);
178 Data8
= Read64Mem8(GpioMmioAddr
+SB_GPIO_REG00
);
179 Data8
&= ~(UINT8
)BIT6
;
180 Write64Mem8 (GpioMmioAddr
+SB_GPIO_REG00
, Data8
);
182 Data8
= Read64Mem8(GpioMmioAddr
+SB_GPIO_REG27
);
183 Data8
&= ~(UINT8
)BIT6
;
184 Write64Mem8 (GpioMmioAddr
+SB_GPIO_REG27
, Data8
);