blob: 5677aa8a3ebea97d768e026399cce95a424b3ccd [file] [log] [blame]
Jens Rottmann16644042013-03-01 17:12:56 +01001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2011 Advanced Micro Devices, Inc.
5 *
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.
9 *
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.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20#include "AGESA.h"
21#include "amdlib.h"
22#include "Ids.h"
23#include "heapManager.h"
24#include "PlatformGnbPcieComplex.h"
25#include "Filecode.h"
Jens Rottmann16644042013-03-01 17:12:56 +010026
Edward O'Callaghan8864e1c2014-04-30 23:13:08 +100027#include <string.h>
Kyösti Mälkki34ad72c2014-10-21 13:43:46 +030028#include <northbridge/amd/agesa/agesawrapper.h>
Edward O'Callaghan8864e1c2014-04-30 23:13:08 +100029
Jens Rottmann16644042013-03-01 17:12:56 +010030#define FILECODE PROC_RECOVERY_MEM_NB_ON_MRNON_FILECODE
31
32/*---------------------------------------------------------------------------------------*/
33/**
34 * OemCustomizeInitEarly
35 *
36 * Description:
37 * This stub function will call the host environment through the binary block
38 * interface (call-out port) to provide a user hook opportunity
39 *
40 * Parameters:
41 * @param[in] **PeiServices
42 * @param[in] *InitEarly
43 *
44 * @retval VOID
45 *
46 **/
47/*---------------------------------------------------------------------------------------*/
48VOID
49OemCustomizeInitEarly (
50 IN OUT AMD_EARLY_PARAMS *InitEarly
51 )
52{
53 AGESA_STATUS Status;
54 VOID *BrazosPcieComplexListPtr;
55 VOID *BrazosPciePortPtr;
56 VOID *BrazosPcieDdiPtr;
57
58 ALLOCATE_HEAP_PARAMS AllocHeapParams;
59
60PCIe_PORT_DESCRIPTOR PortList [] = {
61 // Initialize Port descriptor (PCIe port, Lanes 4, PCI Device Number 4, ...)
62 {
63 0, //Descriptor flags !!!IMPORTANT!!! Terminate last element of array
64 PCIE_ENGINE_DATA_INITIALIZER (PciePortEngine, 4, 4),
Jens Rottmann68c9f2b2013-03-01 17:20:42 +010065 PCIE_PORT_DATA_INITIALIZER (GNB_GPP_PORT4_PORT_PRESENT, GNB_GPP_PORT4_CHANNEL_TYPE, 4, GNB_GPP_PORT4_HOTPLUG_SUPPORT, GNB_GPP_PORT4_SPEED_MODE, GNB_GPP_PORT4_SPEED_MODE, GNB_GPP_PORT4_LINK_ASPM, 0)
Jens Rottmann16644042013-03-01 17:12:56 +010066 },
67 // Initialize Port descriptor (PCIe port, Lanes 5, PCI Device Number 5, ...)
68 {
69 0, //Descriptor flags !!!IMPORTANT!!! Terminate last element of array
70 PCIE_ENGINE_DATA_INITIALIZER (PciePortEngine, 5, 5),
Jens Rottmann68c9f2b2013-03-01 17:20:42 +010071 PCIE_PORT_DATA_INITIALIZER (GNB_GPP_PORT5_PORT_PRESENT, GNB_GPP_PORT5_CHANNEL_TYPE, 5, GNB_GPP_PORT5_HOTPLUG_SUPPORT, GNB_GPP_PORT5_SPEED_MODE, GNB_GPP_PORT5_SPEED_MODE, GNB_GPP_PORT5_LINK_ASPM, 0)
Jens Rottmann16644042013-03-01 17:12:56 +010072 },
73 // Initialize Port descriptor (PCIe port, Lanes 6, PCI Device Number 6, ...)
74 {
75 0, //Descriptor flags !!!IMPORTANT!!! Terminate last element of array
76 PCIE_ENGINE_DATA_INITIALIZER (PciePortEngine, 6, 6),
Jens Rottmann68c9f2b2013-03-01 17:20:42 +010077 PCIE_PORT_DATA_INITIALIZER (GNB_GPP_PORT6_PORT_PRESENT, GNB_GPP_PORT6_CHANNEL_TYPE, 6, GNB_GPP_PORT6_HOTPLUG_SUPPORT, GNB_GPP_PORT6_SPEED_MODE, GNB_GPP_PORT6_SPEED_MODE, GNB_GPP_PORT6_LINK_ASPM, 0)
Jens Rottmann16644042013-03-01 17:12:56 +010078 },
79 // Initialize Port descriptor (PCIe port, Lanes 7, PCI Device Number 7, ...)
80 {
81 0,
82 PCIE_ENGINE_DATA_INITIALIZER (PciePortEngine, 7, 7),
83 PCIE_PORT_DATA_INITIALIZER (GNB_GPP_PORT7_PORT_PRESENT, GNB_GPP_PORT7_CHANNEL_TYPE, 7, GNB_GPP_PORT7_HOTPLUG_SUPPORT, GNB_GPP_PORT7_SPEED_MODE, GNB_GPP_PORT7_SPEED_MODE, GNB_GPP_PORT7_LINK_ASPM, 0)
84 },
85 // Initialize Port descriptor (PCIe port, Lanes 8, PCI Device Number 8, ...)
86 {
87 DESCRIPTOR_TERMINATE_LIST, //Descriptor flags !!!IMPORTANT!!! Terminate last element of array
88 PCIE_ENGINE_DATA_INITIALIZER (PciePortEngine, 0, 3),
89 PCIE_PORT_DATA_INITIALIZER (GNB_GPP_PORT8_PORT_PRESENT, GNB_GPP_PORT8_CHANNEL_TYPE, 8, GNB_GPP_PORT8_HOTPLUG_SUPPORT, GNB_GPP_PORT8_SPEED_MODE, GNB_GPP_PORT8_SPEED_MODE, GNB_GPP_PORT8_LINK_ASPM, 0)
90 }
91};
92
93PCIe_DDI_DESCRIPTOR DdiList [] = {
94 // Initialize Ddi descriptor (DDI interface Lanes 8:11, DdA, ...)
95 {
96 0, //Descriptor flags
97 PCIE_ENGINE_DATA_INITIALIZER (PcieDdiEngine, 8, 11),
98 //PCIE_DDI_DATA_INITIALIZER (ConnectorTypeDP, Aux1, Hdp1)
Jens Rottmann68c9f2b2013-03-01 17:20:42 +010099 {ConnectorTypeAutoDetect, Aux1, Hdp1}
Jens Rottmann16644042013-03-01 17:12:56 +0100100 },
101 // Initialize Ddi descriptor (DDI interface Lanes 12:15, DdB, ...)
102 {
103 DESCRIPTOR_TERMINATE_LIST, //Descriptor flags !!!IMPORTANT!!! Terminate last element of array
104 PCIE_ENGINE_DATA_INITIALIZER (PcieDdiEngine, 12, 15),
105 //PCIE_DDI_DATA_INITIALIZER (ConnectorTypeDP, Aux2, Hdp2)
Jens Rottmann68c9f2b2013-03-01 17:20:42 +0100106 {ConnectorTypeAutoDetect, Aux2, Hdp2}
Jens Rottmann16644042013-03-01 17:12:56 +0100107 }
108};
109
110PCIe_COMPLEX_DESCRIPTOR Brazos = {
111 DESCRIPTOR_TERMINATE_LIST,
112 0,
113 &PortList[0],
114 &DdiList[0]
115};
116
117 // GNB PCIe topology Porting
118
119 //
120 // Allocate buffer for PCIe_COMPLEX_DESCRIPTOR , PCIe_PORT_DESCRIPTOR and PCIe_DDI_DESCRIPTOR
121 //
Paul Menzeld1892292013-05-14 10:06:47 +0200122 AllocHeapParams.RequestedBufferSize = sizeof(Brazos) + sizeof(PortList) + sizeof(DdiList);
Jens Rottmann16644042013-03-01 17:12:56 +0100123
124 AllocHeapParams.BufferHandle = AMD_MEM_MISC_HANDLES_START;
125 AllocHeapParams.Persist = HEAP_LOCAL_CACHE;
126 Status = HeapAllocateBuffer (&AllocHeapParams, &InitEarly->StdHeader);
127 if ( Status!= AGESA_SUCCESS) {
128 // Could not allocate buffer for PCIe_COMPLEX_DESCRIPTOR , PCIe_PORT_DESCRIPTOR and PCIe_DDI_DESCRIPTOR
129 ASSERT(FALSE);
130 return;
131 }
132
133 BrazosPcieComplexListPtr = (PCIe_COMPLEX_DESCRIPTOR *) AllocHeapParams.BufferPtr;
134
Paul Menzeld1892292013-05-14 10:06:47 +0200135 AllocHeapParams.BufferPtr += sizeof(Brazos);
Jens Rottmann16644042013-03-01 17:12:56 +0100136 BrazosPciePortPtr = (PCIe_PORT_DESCRIPTOR *)AllocHeapParams.BufferPtr;
137
Paul Menzeld1892292013-05-14 10:06:47 +0200138 AllocHeapParams.BufferPtr += sizeof(PortList);
Jens Rottmann16644042013-03-01 17:12:56 +0100139 BrazosPcieDdiPtr = (PCIe_DDI_DESCRIPTOR *) AllocHeapParams.BufferPtr;
140
Edward O'Callaghan8864e1c2014-04-30 23:13:08 +1000141 memcpy(BrazosPcieComplexListPtr, &Brazos, sizeof(Brazos));
142 memcpy(BrazosPciePortPtr, &PortList[0], sizeof(PortList));
143 memcpy(BrazosPcieDdiPtr, &DdiList[0], sizeof(DdiList));
Jens Rottmann16644042013-03-01 17:12:56 +0100144
145
146 ((PCIe_COMPLEX_DESCRIPTOR*)BrazosPcieComplexListPtr)->PciePortList = (PCIe_PORT_DESCRIPTOR*)BrazosPciePortPtr;
147 ((PCIe_COMPLEX_DESCRIPTOR*)BrazosPcieComplexListPtr)->DdiLinkList = (PCIe_DDI_DESCRIPTOR*)BrazosPcieDdiPtr;
148
149 InitEarly->GnbConfig.PcieComplexList = BrazosPcieComplexListPtr;
150 InitEarly->GnbConfig.PsppPolicy = 0;
151}