blob: 4f8bc82f403918b25e21a08012545be4c34c9f17 [file] [log] [blame]
WANG Siyuanf77f7342013-08-13 17:09:51 +08001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2012 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"
WANG Siyuanf77f7342013-08-13 17:09:51 +080024#include "Filecode.h"
25
Kyösti Mälkki34ad72c2014-10-21 13:43:46 +030026#include <northbridge/amd/agesa/agesawrapper.h>
27
WANG Siyuanf77f7342013-08-13 17:09:51 +080028#define FILECODE PROC_GNB_PCIE_FAMILY_0X15_F15PCIECOMPLEXCONFIG_FILECODE
29
30static const PCIe_PORT_DESCRIPTOR PortList [] = {
31 {
32 0, //Descriptor flags !!!IMPORTANT!!! Terminate last element of array
33 PCIE_ENGINE_DATA_INITIALIZER (PciePortEngine, 3, 3),
34 PCIE_PORT_DATA_INITIALIZER_V2 (PortEnabled, ChannelTypeExt6db, 2, 5,
35 HotplugDisabled,
36 PcieGenMaxSupported,
37 PcieGenMaxSupported,
38 AspmDisabled, 0x01, 0)
39 },
40 /* Initialize Port descriptor (PCIe port, Lanes 1, PCI Device Number 2, ...) */
41 {
42 0, //Descriptor flags !!!IMPORTANT!!! Terminate last element of array
43 PCIE_ENGINE_DATA_INITIALIZER (PciePortEngine, 2, 2),
44 PCIE_PORT_DATA_INITIALIZER_V2 (PortEnabled, ChannelTypeExt6db, 2, 4,
45 HotplugDisabled,
46 PcieGenMaxSupported,
47 PcieGenMaxSupported,
48 AspmDisabled, 0x02, 0)
49 },
50 /* Initialize Port descriptor (PCIe port, Lanes 2, PCI Device Number 2, ...) */
51 {
52 0, //Descriptor flags !!!IMPORTANT!!! Terminate last element of array
53 PCIE_ENGINE_DATA_INITIALIZER (PciePortEngine, 1, 1),
54 PCIE_PORT_DATA_INITIALIZER_V2 (PortEnabled, ChannelTypeExt6db, 2, 3,
55 HotplugDisabled,
56 PcieGenMaxSupported,
57 PcieGenMaxSupported,
58 AspmDisabled, 0x03, 0)
59 },
60 /* Initialize Port descriptor (PCIe port, Lanes 3, PCI Device Number 2, ...) */
61 {
62 0,
63 PCIE_ENGINE_DATA_INITIALIZER (PciePortEngine, 0, 0),
64 PCIE_PORT_DATA_INITIALIZER_V2 (PortEnabled, ChannelTypeExt6db, 2, 2,
65 HotplugDisabled,
66 PcieGenMaxSupported,
67 PcieGenMaxSupported,
68 AspmDisabled, 0x04, 0)
69 },
70 /* Initialize Port descriptor (PCIe port, Lanes 4-7, PCI Device Number 4, ...) */
71 {
72 DESCRIPTOR_TERMINATE_LIST, //Descriptor flags !!!IMPORTANT!!! Terminate last element of array
73 PCIE_ENGINE_DATA_INITIALIZER (PciePortEngine, 4, 7),
74 PCIE_PORT_DATA_INITIALIZER_V2 (PortEnabled, ChannelTypeExt6db, 2, 1,
75 HotplugDisabled,
76 PcieGenMaxSupported,
77 PcieGenMaxSupported,
78 AspmDisabled, 0x05, 0)
79 }
80};
81
82static const PCIe_DDI_DESCRIPTOR DdiList [] = {
83 /* DP0 to HDMI0/DP */
84 {
85 0,
86 PCIE_ENGINE_DATA_INITIALIZER (PcieDdiEngine, 8, 11),
87 PCIE_DDI_DATA_INITIALIZER (ConnectorTypeHDMI, Aux1, Hdp1)
88 },
89 /* DP1 to FCH */
90 {
91 0,
92 PCIE_ENGINE_DATA_INITIALIZER (PcieDdiEngine, 12, 15),
93 PCIE_DDI_DATA_INITIALIZER (ConnectorTypeHDMI, Aux2, Hdp2)
94 },
95 /* DP2 to HDMI1/DP */
96 {
97 DESCRIPTOR_TERMINATE_LIST,
98 PCIE_ENGINE_DATA_INITIALIZER (PcieDdiEngine, 16, 19),
99 PCIE_DDI_DATA_INITIALIZER (ConnectorTypeCrt, Aux3, Hdp3)
100 },
101};
102
103static const PCIe_COMPLEX_DESCRIPTOR PcieComplex = {
104 .Flags = DESCRIPTOR_TERMINATE_LIST,
105 .SocketId = 0,
106 .PciePortList = PortList,
107 .DdiLinkList = DdiList
108};
109
110/*---------------------------------------------------------------------------------------*/
111/**
112 * OemCustomizeInitEarly
113 *
114 * Description:
115 * This is the stub function will call the host environment through the binary block
116 * interface (call-out port) to provide a user hook opportunity
117 *
118 * Parameters:
119 * @param[in] **PeiServices
120 * @param[in] *InitEarly
121 *
122 * @retval VOID
123 *
124 **/
125/*---------------------------------------------------------------------------------------*/
126VOID
127OemCustomizeInitEarly (
128 IN OUT AMD_EARLY_PARAMS *InitEarly
129 )
130{
131 AGESA_STATUS Status;
132 PCIe_COMPLEX_DESCRIPTOR *PcieComplexListPtr;
133
134 ALLOCATE_HEAP_PARAMS AllocHeapParams;
135
136 /* GNB PCIe topology Porting */
137
138 /* */
139 /* Allocate buffer for PCIe_COMPLEX_DESCRIPTOR , PCIe_PORT_DESCRIPTOR and PCIe_DDI_DESCRIPTOR */
140 /* */
141 AllocHeapParams.RequestedBufferSize = sizeof(PcieComplex);
142
143 AllocHeapParams.BufferHandle = AMD_MEM_MISC_HANDLES_START;
144 AllocHeapParams.Persist = HEAP_LOCAL_CACHE;
145 Status = HeapAllocateBuffer (&AllocHeapParams, &InitEarly->StdHeader);
Kyösti Mälkki1ef67e12014-12-16 16:45:52 +0200146 ASSERT(Status == AGESA_SUCCESS);
WANG Siyuanf77f7342013-08-13 17:09:51 +0800147
148 PcieComplexListPtr = (PCIe_COMPLEX_DESCRIPTOR *) AllocHeapParams.BufferPtr;
149 LibAmdMemCopy (PcieComplexListPtr, &PcieComplex, sizeof(PcieComplex), &InitEarly->StdHeader);
150 InitEarly->GnbConfig.PcieComplexList = PcieComplexListPtr;
151}