remove trailing whitespace
[coreboot.git] / src / mainboard / amd / torpedo / PlatformGnbPcie.c
1 /*
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"
26
27 #define FILECODE PROC_GNB_PCIE_FAMILY_0X12_F12PCIECOMPLEXCONFIG_FILECODE
28
29 PCIe_PORT_DESCRIPTOR PortList [] = {
30                         // Initialize Port descriptor (PCIe port, Lanes 8:15, PCI Device Number 2, ...)
31                         {
32                           0,   //Descriptor flags
33                           PCIE_ENGINE_DATA_INITIALIZER (PciePortEngine, 8, 15),
34                           PCIE_PORT_DATA_INITIALIZER (PortEnabled, ChannelTypeExt6db, 2, HotplugDisabled, PcieGenMaxSupported, PcieGenMaxSupported, AspmDisabled, BIT2)
35                         },
36                         // Initialize Port descriptor (PCIe port, Lanes 16:19, PCI Device Number 3, ...)
37                         {
38                           0,   //Descriptor flags
39                           PCIE_ENGINE_DATA_INITIALIZER (PciePortEngine, 16, 19),
40                           PCIE_PORT_DATA_INITIALIZER (PortEnabled, ChannelTypeExt6db, 3, HotplugDisabled, PcieGenMaxSupported, PcieGenMaxSupported, AspmDisabled, BIT3)
41                         },
42                         // Initialize Port descriptor (PCIe port, Lanes 4, PCI Device Number 4, ...)
43                         {
44                           0, //Descriptor flags  !!!IMPORTANT!!! Terminate last element of array
45                           PCIE_ENGINE_DATA_INITIALIZER (PciePortEngine, 4, 4),
46                           PCIE_PORT_DATA_INITIALIZER (PortEnabled, ChannelTypeExt6db, 4, HotplugDisabled, PcieGenMaxSupported, PcieGenMaxSupported, AspmDisabled, 0)
47                         },
48                         // Initialize Port descriptor (PCIe port, Lanes 5, PCI Device Number 5, ...)
49                         {
50                           0, //Descriptor flags  !!!IMPORTANT!!! Terminate last element of array
51                           PCIE_ENGINE_DATA_INITIALIZER (PciePortEngine, 5, 5),
52                           PCIE_PORT_DATA_INITIALIZER (PortEnabled, ChannelTypeExt6db, 5, HotplugDisabled, PcieGenMaxSupported, PcieGenMaxSupported, AspmDisabled, 0)
53                         },
54                         // Initialize Port descriptor (PCIe port, Lanes 6, PCI Device Number 6, ...)
55                         {
56                           0, //Descriptor flags  !!!IMPORTANT!!! Terminate last element of array
57                           PCIE_ENGINE_DATA_INITIALIZER (PciePortEngine, 6, 6),
58                           PCIE_PORT_DATA_INITIALIZER (PortEnabled, ChannelTypeExt6db, 6, HotplugDisabled, PcieGenMaxSupported, PcieGenMaxSupported, AspmDisabled, 0)
59                         },
60                         // Initialize Port descriptor (PCIe port, Lanes 7, PCI Device Number 7, ...)
61                         {
62                           DESCRIPTOR_TERMINATE_LIST, //Descriptor flags  !!!IMPORTANT!!! Terminate last element of array
63                           PCIE_ENGINE_DATA_INITIALIZER (PciePortEngine, 7, 7),
64                           PCIE_PORT_DATA_INITIALIZER (PortEnabled, ChannelTypeExt6db, 7, HotplugDisabled, PcieGenMaxSupported, PcieGenMaxSupported, AspmDisabled, 0)
65                         }
66                         // Initialize Port descriptor (PCIe port, Lanes 8, PCI Device Number 8, ...)
67 //                      {
68 //                        DESCRIPTOR_TERMINATE_LIST, //Descriptor flags  !!!IMPORTANT!!! Terminate last element of array
69 //                        PCIE_ENGINE_DATA_INITIALIZER (PciePortEngine, 8, 8),
70 //                        PCIE_PORT_DATA_INITIALIZER (PortEnabled, ChannelTypeExt6db, 8, HotplugDisabled, PcieGenMaxSupported, PcieGenMaxSupported, AspmDisabled, 0)
71 //                      }
72 };
73
74 PCIe_DDI_DESCRIPTOR DdiList [] = {
75                         // Initialize Ddi descriptor (DDI interface Lanes 24:27, DdA, ...)
76                         {
77                           0,   //Descriptor flags
78                           PCIE_ENGINE_DATA_INITIALIZER (PcieDdiEngine, 24, 27),
79                           PCIE_DDI_DATA_INITIALIZER (ConnectorTypeNutmegDpToVga, Aux2, Hdp2)
80                         },
81                         // Initialize Ddi descriptor (DDI interface Lanes 28:31, DdB, ...)
82                         {
83                           DESCRIPTOR_TERMINATE_LIST, //Descriptor flags  !!!IMPORTANT!!! Terminate last element of array
84                           PCIE_ENGINE_DATA_INITIALIZER (PcieDdiEngine, 28, 31),
85                           PCIE_DDI_DATA_INITIALIZER (ConnectorTypeEDP, Aux1, Hdp1)
86                         }
87 };
88
89 PCIe_COMPLEX_DESCRIPTOR Llano = {
90         DESCRIPTOR_TERMINATE_LIST,
91         0,
92         &PortList[0],
93         &DdiList[0]
94 };
95
96 /*---------------------------------------------------------------------------------------*/
97 /**
98  *  OemCustomizeInitEarly
99  *
100  *  Description:
101  *    This is the stub function will call the host environment through the binary block
102  *    interface (call-out port) to provide a user hook opportunity
103  *
104  *  Parameters:
105  *    @param[in]      **PeiServices
106  *    @param[in]      *InitEarly
107  *
108  *    @retval         VOID
109  *
110  **/
111 /*---------------------------------------------------------------------------------------*/
112 VOID
113 OemCustomizeInitEarly (
114   IN  OUT AMD_EARLY_PARAMS    *InitEarly
115   )
116 {
117   AGESA_STATUS         Status;
118   VOID                 *LlanoPcieComplexListPtr;
119   VOID                 *LlanoPciePortPtr;
120   VOID                 *LlanoPcieDdiPtr;
121
122   ALLOCATE_HEAP_PARAMS AllocHeapParams;
123
124   // GNB PCIe topology Porting
125
126   //
127   // Allocate buffer for PCIe_COMPLEX_DESCRIPTOR , PCIe_PORT_DESCRIPTOR and PCIe_DDI_DESCRIPTOR
128   //
129   AllocHeapParams.RequestedBufferSize = (sizeof (PCIe_COMPLEX_DESCRIPTOR)  +
130                                          sizeof (PCIe_PORT_DESCRIPTOR) * 7 +
131                                          sizeof (PCIe_DDI_DESCRIPTOR)) * 6;
132
133   AllocHeapParams.BufferHandle = AMD_MEM_MISC_HANDLES_START;
134   AllocHeapParams.Persist = HEAP_LOCAL_CACHE;
135   Status = HeapAllocateBuffer (&AllocHeapParams, &InitEarly->StdHeader);
136   if ( Status!= AGESA_SUCCESS) {
137     // Could not allocate buffer for PCIe_COMPLEX_DESCRIPTOR , PCIe_PORT_DESCRIPTOR and PCIe_DDI_DESCRIPTOR
138     ASSERT(FALSE);
139     return;
140   }
141
142   LlanoPcieComplexListPtr  =  (PCIe_COMPLEX_DESCRIPTOR *) AllocHeapParams.BufferPtr;
143
144   AllocHeapParams.BufferPtr += sizeof (PCIe_COMPLEX_DESCRIPTOR);
145   LlanoPciePortPtr         =  (PCIe_PORT_DESCRIPTOR *)AllocHeapParams.BufferPtr;
146
147   AllocHeapParams.BufferPtr += sizeof (PCIe_PORT_DESCRIPTOR) * 7;
148   LlanoPcieDdiPtr          =  (PCIe_DDI_DESCRIPTOR *) AllocHeapParams.BufferPtr;
149
150   LibAmdMemFill (LlanoPcieComplexListPtr,
151                    0,
152                    sizeof (PCIe_COMPLEX_DESCRIPTOR),
153                    &InitEarly->StdHeader);
154
155   LibAmdMemFill (LlanoPciePortPtr,
156                    0,
157                    sizeof (PCIe_PORT_DESCRIPTOR) * 7,
158                    &InitEarly->StdHeader);
159
160   LibAmdMemFill (LlanoPcieDdiPtr,
161                    0,
162                    sizeof (PCIe_DDI_DESCRIPTOR) * 6,
163                    &InitEarly->StdHeader);
164
165   LibAmdMemCopy  (LlanoPcieComplexListPtr, &Llano, sizeof (PCIe_COMPLEX_DESCRIPTOR), &InitEarly->StdHeader);
166   LibAmdMemCopy  (LlanoPciePortPtr, &PortList[0], sizeof (PCIe_PORT_DESCRIPTOR) * 7, &InitEarly->StdHeader);
167   LibAmdMemCopy  (LlanoPcieDdiPtr, &DdiList[0], sizeof (PCIe_DDI_DESCRIPTOR) * 6, &InitEarly->StdHeader);
168
169
170   ((PCIe_COMPLEX_DESCRIPTOR*)LlanoPcieComplexListPtr)->PciePortList =  (PCIe_PORT_DESCRIPTOR*)LlanoPciePortPtr;
171   ((PCIe_COMPLEX_DESCRIPTOR*)LlanoPcieComplexListPtr)->DdiLinkList  =  (PCIe_DDI_DESCRIPTOR*)LlanoPcieDdiPtr;
172
173   InitEarly->GnbConfig.PcieComplexList = LlanoPcieComplexListPtr;
174   InitEarly->GnbConfig.PsppPolicy      = 0;
175 }
176