blob: 21d0f8dffcc97c5d39681face2998026e460343c [file] [log] [blame]
Scott Duplichana649a962011-02-24 05:00:33 +00001/*
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
Paul Menzela46a7122013-02-23 18:37:27 +010017 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Scott Duplichana649a962011-02-24 05:00:33 +000018 */
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"
26
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
Scott Duplichana649a962011-02-24 05:00:33 +000030#define FILECODE PROC_RECOVERY_MEM_NB_ON_MRNON_FILECODE
31
32/*---------------------------------------------------------------------------------------*/
33/**
34 * OemCustomizeInitEarly
35 *
36 * Description:
Paul Menzel63950f82013-02-01 23:51:40 +010037 * This stub function will call the host environment through the binary block
Scott Duplichana649a962011-02-24 05:00:33 +000038 * 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),
Paul Menzele988b512013-02-23 00:15:49 +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)
Scott Duplichana649a962011-02-24 05:00:33 +000066 },
67 #if 1
68 // Initialize Port descriptor (PCIe port, Lanes 5, PCI Device Number 5, ...)
69 {
70 0, //Descriptor flags !!!IMPORTANT!!! Terminate last element of array
71 PCIE_ENGINE_DATA_INITIALIZER (PciePortEngine, 5, 5),
Paul Menzele988b512013-02-23 00:15:49 +010072 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)
Scott Duplichana649a962011-02-24 05:00:33 +000073 },
74 // Initialize Port descriptor (PCIe port, Lanes 6, PCI Device Number 6, ...)
75 {
76 0, //Descriptor flags !!!IMPORTANT!!! Terminate last element of array
77 PCIE_ENGINE_DATA_INITIALIZER (PciePortEngine, 6, 6),
Paul Menzele988b512013-02-23 00:15:49 +010078 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)
Scott Duplichana649a962011-02-24 05:00:33 +000079 },
80 // Initialize Port descriptor (PCIe port, Lanes 7, PCI Device Number 7, ...)
81 {
82 0,
83 PCIE_ENGINE_DATA_INITIALIZER (PciePortEngine, 7, 7),
Paul Menzele988b512013-02-23 00:15:49 +010084 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)
Scott Duplichana649a962011-02-24 05:00:33 +000085 },
86 #endif
87 // Initialize Port descriptor (PCIe port, Lanes 8, PCI Device Number 8, ...)
88 {
89 DESCRIPTOR_TERMINATE_LIST, //Descriptor flags !!!IMPORTANT!!! Terminate last element of array
90 PCIE_ENGINE_DATA_INITIALIZER (PciePortEngine, 0, 3),
91 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)
Stefan Reinauer5ff7c132011-10-31 12:56:45 -070092 }
Scott Duplichana649a962011-02-24 05:00:33 +000093};
94
95PCIe_DDI_DESCRIPTOR DdiList [] = {
96 // Initialize Ddi descriptor (DDI interface Lanes 8:11, DdA, ...)
97 {
98 0, //Descriptor flags
99 PCIE_ENGINE_DATA_INITIALIZER (PcieDdiEngine, 8, 11),
100 //PCIE_DDI_DATA_INITIALIZER (ConnectorTypeDP, Aux1, Hdp1)
101 {ConnectorTypeDP, Aux1, Hdp1}
102 },
103 // Initialize Ddi descriptor (DDI interface Lanes 12:15, DdB, ...)
104 {
105 DESCRIPTOR_TERMINATE_LIST, //Descriptor flags !!!IMPORTANT!!! Terminate last element of array
106 PCIE_ENGINE_DATA_INITIALIZER (PcieDdiEngine, 12, 15),
107 //PCIE_DDI_DATA_INITIALIZER (ConnectorTypeDP, Aux2, Hdp2)
108 {ConnectorTypeDP, Aux2, Hdp2}
109 }
110};
111
112PCIe_COMPLEX_DESCRIPTOR Brazos = {
113 DESCRIPTOR_TERMINATE_LIST,
114 0,
115 &PortList[0],
116 &DdiList[0]
117};
118
119 // GNB PCIe topology Porting
120
121 //
122 // Allocate buffer for PCIe_COMPLEX_DESCRIPTOR , PCIe_PORT_DESCRIPTOR and PCIe_DDI_DESCRIPTOR
123 //
Paul Menzeld1892292013-05-14 10:06:47 +0200124 AllocHeapParams.RequestedBufferSize = sizeof(Brazos) + sizeof(PortList) + sizeof(DdiList);
Scott Duplichana649a962011-02-24 05:00:33 +0000125
126 AllocHeapParams.BufferHandle = AMD_MEM_MISC_HANDLES_START;
127 AllocHeapParams.Persist = HEAP_LOCAL_CACHE;
128 Status = HeapAllocateBuffer (&AllocHeapParams, &InitEarly->StdHeader);
Kyösti Mälkki1ef67e12014-12-16 16:45:52 +0200129 ASSERT(Status == AGESA_SUCCESS);
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700130
Scott Duplichana649a962011-02-24 05:00:33 +0000131 BrazosPcieComplexListPtr = (PCIe_COMPLEX_DESCRIPTOR *) AllocHeapParams.BufferPtr;
132
Paul Menzeld1892292013-05-14 10:06:47 +0200133 AllocHeapParams.BufferPtr += sizeof(Brazos);
Scott Duplichana649a962011-02-24 05:00:33 +0000134 BrazosPciePortPtr = (PCIe_PORT_DESCRIPTOR *)AllocHeapParams.BufferPtr;
135
Paul Menzeld1892292013-05-14 10:06:47 +0200136 AllocHeapParams.BufferPtr += sizeof(PortList);
Scott Duplichana649a962011-02-24 05:00:33 +0000137 BrazosPcieDdiPtr = (PCIe_DDI_DESCRIPTOR *) AllocHeapParams.BufferPtr;
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700138
Edward O'Callaghan8864e1c2014-04-30 23:13:08 +1000139 memcpy(BrazosPcieComplexListPtr, &Brazos, sizeof(Brazos));
140 memcpy(BrazosPciePortPtr, &PortList[0], sizeof(PortList));
141 memcpy(BrazosPcieDdiPtr, &DdiList[0], sizeof(DdiList));
Scott Duplichana649a962011-02-24 05:00:33 +0000142
143
144 ((PCIe_COMPLEX_DESCRIPTOR*)BrazosPcieComplexListPtr)->PciePortList = (PCIe_PORT_DESCRIPTOR*)BrazosPciePortPtr;
145 ((PCIe_COMPLEX_DESCRIPTOR*)BrazosPcieComplexListPtr)->DdiLinkList = (PCIe_DDI_DESCRIPTOR*)BrazosPcieDdiPtr;
146
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700147 InitEarly->GnbConfig.PcieComplexList = BrazosPcieComplexListPtr;
148 InitEarly->GnbConfig.PsppPolicy = 0;
Scott Duplichana649a962011-02-24 05:00:33 +0000149}