blob: f980a15b0801767c696dd7136ef61753fd073ec2 [file] [log] [blame]
Edward O'Callaghan4726a872014-01-25 07:40:39 +11001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2011 Advanced Micro Devices, Inc.
Edward O'Callaghane2f3bfc2014-04-11 12:56:13 +10005 * Copyright (C) 2014 Edward O'Callaghan <eocallaghan@alterapraxis.com>.
Edward O'Callaghan4726a872014-01-25 07:40:39 +11006 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
Edward O'Callaghan4726a872014-01-25 07:40:39 +110015 */
16
Edward O'Callaghan4726a872014-01-25 07:40:39 +110017#include "PlatformGnbPcieComplex.h"
Edward O'Callaghan4726a872014-01-25 07:40:39 +110018
Edward O'Callaghane2f3bfc2014-04-11 12:56:13 +100019#include <string.h>
Kyösti Mälkki34ad72c2014-10-21 13:43:46 +030020#include <northbridge/amd/agesa/agesawrapper.h>
Edward O'Callaghan5ff4b082014-03-29 17:54:26 +110021#include <vendorcode/amd/agesa/f14/Proc/CPU/heapManager.h>
Kyösti Mälkki53052fe2016-04-27 09:04:11 +030022#include <PlatformMemoryConfiguration.h>
Edward O'Callaghan5ff4b082014-03-29 17:54:26 +110023
Edward O'Callaghan4726a872014-01-25 07:40:39 +110024#define FILECODE PROC_RECOVERY_MEM_NB_ON_MRNON_FILECODE
25
Edward O'Callaghan4726a872014-01-25 07:40:39 +110026/**
27 * OemCustomizeInitEarly
28 *
29 * Description:
30 * This stub function will call the host environment through the binary block
31 * interface (call-out port) to provide a user hook opportunity
32 *
33 * Parameters:
Edward O'Callaghan4726a872014-01-25 07:40:39 +110034 * @param[in] *InitEarly
35 *
Edward O'Callaghan4726a872014-01-25 07:40:39 +110036 **/
Kyösti Mälkki6e74b2c2014-12-16 07:34:58 +020037
38static AGESA_STATUS OemInitEarly(AMD_EARLY_PARAMS * InitEarly)
Edward O'Callaghan4726a872014-01-25 07:40:39 +110039{
Edward O'Callaghanc21bd882014-04-12 04:12:14 +100040 AGESA_STATUS Status;
41 void *BrazosPcieComplexListPtr;
42 void *BrazosPciePortPtr;
43 void *BrazosPcieDdiPtr;
Edward O'Callaghan4726a872014-01-25 07:40:39 +110044
45 ALLOCATE_HEAP_PARAMS AllocHeapParams;
46
Edward O'Callaghanfeebd862014-04-10 19:12:28 +100047/**
48 * @brief Initialize Port descriptors
49 */
Edward O'Callaghan4726a872014-01-25 07:40:39 +110050PCIe_PORT_DESCRIPTOR PortList [] = {
Edward O'Callaghanfeebd862014-04-10 19:12:28 +100051 /* (PCIe port, Lanes 4, PCI Device Number 4, ...) */
Edward O'Callaghan4726a872014-01-25 07:40:39 +110052 {
Edward O'Callaghanfeebd862014-04-10 19:12:28 +100053 0,
Edward O'Callaghan4726a872014-01-25 07:40:39 +110054 PCIE_ENGINE_DATA_INITIALIZER (PciePortEngine, 4, 4),
Edward O'Callaghanfeebd862014-04-10 19:12:28 +100055 PCIE_PORT_DATA_INITIALIZER (GNB_GPP_PORT4_PORT_PRESENT,
56 GNB_GPP_PORT4_CHANNEL_TYPE,
57 4,
58 GNB_GPP_PORT4_HOTPLUG_SUPPORT,
59 GNB_GPP_PORT4_SPEED_MODE,
60 GNB_GPP_PORT4_SPEED_MODE,
61 GNB_GPP_PORT4_LINK_ASPM,
62 46)
Edward O'Callaghan4726a872014-01-25 07:40:39 +110063 },
Edward O'Callaghanfeebd862014-04-10 19:12:28 +100064 /* (PCIe port, Lanes 5, PCI Device Number 5, ...) */
Edward O'Callaghan4726a872014-01-25 07:40:39 +110065 {
Edward O'Callaghanfeebd862014-04-10 19:12:28 +100066 0,
Edward O'Callaghan4726a872014-01-25 07:40:39 +110067 PCIE_ENGINE_DATA_INITIALIZER (PciePortEngine, 5, 5),
Edward O'Callaghanfeebd862014-04-10 19:12:28 +100068 PCIE_PORT_DATA_INITIALIZER (GNB_GPP_PORT5_PORT_PRESENT,
69 GNB_GPP_PORT5_CHANNEL_TYPE,
70 5,
71 GNB_GPP_PORT5_HOTPLUG_SUPPORT,
72 GNB_GPP_PORT5_SPEED_MODE,
73 GNB_GPP_PORT5_SPEED_MODE,
74 GNB_GPP_PORT5_LINK_ASPM,
75 46)
Edward O'Callaghan4726a872014-01-25 07:40:39 +110076 },
Edward O'Callaghanfeebd862014-04-10 19:12:28 +100077 /* (PCIe port, Lanes 6, PCI Device Number 6, ...) */
Edward O'Callaghan4726a872014-01-25 07:40:39 +110078 {
Edward O'Callaghanfeebd862014-04-10 19:12:28 +100079 0,
Edward O'Callaghan4726a872014-01-25 07:40:39 +110080 PCIE_ENGINE_DATA_INITIALIZER (PciePortEngine, 6, 6),
Edward O'Callaghanfeebd862014-04-10 19:12:28 +100081 PCIE_PORT_DATA_INITIALIZER (GNB_GPP_PORT6_PORT_PRESENT,
82 GNB_GPP_PORT6_CHANNEL_TYPE,
83 6,
84 GNB_GPP_PORT6_HOTPLUG_SUPPORT,
85 GNB_GPP_PORT6_SPEED_MODE,
86 GNB_GPP_PORT6_SPEED_MODE,
87 GNB_GPP_PORT6_LINK_ASPM,
88 46)
Edward O'Callaghan4726a872014-01-25 07:40:39 +110089 },
Edward O'Callaghanfeebd862014-04-10 19:12:28 +100090 /* (PCIe port, Lanes 7, PCI Device Number 7, ...) */
Edward O'Callaghan4726a872014-01-25 07:40:39 +110091 {
92 0,
93 PCIE_ENGINE_DATA_INITIALIZER (PciePortEngine, 7, 7),
Edward O'Callaghanfeebd862014-04-10 19:12:28 +100094 PCIE_PORT_DATA_INITIALIZER (GNB_GPP_PORT7_PORT_PRESENT,
95 GNB_GPP_PORT7_CHANNEL_TYPE,
96 7,
97 GNB_GPP_PORT7_HOTPLUG_SUPPORT,
98 GNB_GPP_PORT7_SPEED_MODE,
99 GNB_GPP_PORT7_SPEED_MODE,
100 GNB_GPP_PORT7_LINK_ASPM,
101 0)
Edward O'Callaghan4726a872014-01-25 07:40:39 +1100102 },
Edward O'Callaghanfeebd862014-04-10 19:12:28 +1000103 /* (PCIe port, Lanes 8, PCI Device Number 8, ...) */
Edward O'Callaghan4726a872014-01-25 07:40:39 +1100104 {
Edward O'Callaghanfeebd862014-04-10 19:12:28 +1000105 DESCRIPTOR_TERMINATE_LIST,
Edward O'Callaghan4726a872014-01-25 07:40:39 +1100106 PCIE_ENGINE_DATA_INITIALIZER (PciePortEngine, 0, 3),
Edward O'Callaghanfeebd862014-04-10 19:12:28 +1000107 PCIE_PORT_DATA_INITIALIZER (GNB_GPP_PORT8_PORT_PRESENT,
108 GNB_GPP_PORT8_CHANNEL_TYPE,
109 8,
110 GNB_GPP_PORT8_HOTPLUG_SUPPORT,
111 GNB_GPP_PORT8_SPEED_MODE,
112 GNB_GPP_PORT8_SPEED_MODE,
113 GNB_GPP_PORT8_LINK_ASPM,
114 0)
Edward O'Callaghan4726a872014-01-25 07:40:39 +1100115 }
116};
117
Edward O'Callaghanfeebd862014-04-10 19:12:28 +1000118/**
119 * @brief Initialize Ddi descriptors
120 */
Edward O'Callaghan4726a872014-01-25 07:40:39 +1100121PCIe_DDI_DESCRIPTOR DdiList [] = {
Edward O'Callaghanfeebd862014-04-10 19:12:28 +1000122 /* (DDI interface Lanes 8:11, DdA, ...) */
Edward O'Callaghan4726a872014-01-25 07:40:39 +1100123 {
Edward O'Callaghanfeebd862014-04-10 19:12:28 +1000124 0,
Edward O'Callaghan4726a872014-01-25 07:40:39 +1100125 PCIE_ENGINE_DATA_INITIALIZER (PcieDdiEngine, 8, 11),
Edward O'Callaghanfeebd862014-04-10 19:12:28 +1000126 /* PCIE_DDI_DATA_INITIALIZER (ConnectorTypeDP, Aux1, Hdp1) */
Edward O'Callaghan4726a872014-01-25 07:40:39 +1100127 {ConnectorTypeLvds, Aux1, Hdp1}
128 },
Edward O'Callaghanfeebd862014-04-10 19:12:28 +1000129 /* (DDI interface Lanes 12:15, DdB, ...) */
Edward O'Callaghan4726a872014-01-25 07:40:39 +1100130 {
Edward O'Callaghanfeebd862014-04-10 19:12:28 +1000131 DESCRIPTOR_TERMINATE_LIST,
Edward O'Callaghan4726a872014-01-25 07:40:39 +1100132 PCIE_ENGINE_DATA_INITIALIZER (PcieDdiEngine, 12, 15),
Edward O'Callaghanfeebd862014-04-10 19:12:28 +1000133 /* PCIE_DDI_DATA_INITIALIZER (ConnectorTypeDP, Aux2, Hdp2) */
Edward O'Callaghan4726a872014-01-25 07:40:39 +1100134 {ConnectorTypeDP, Aux2, Hdp2}
135 }
136};
137
138PCIe_COMPLEX_DESCRIPTOR Brazos = {
139 DESCRIPTOR_TERMINATE_LIST,
140 0,
141 &PortList[0],
142 &DdiList[0]
143};
144
Edward O'Callaghanfeebd862014-04-10 19:12:28 +1000145 /**
146 * @brief GNB PCIe topology Porting
147 *
148 * Allocate buffer for
149 * PCIe_COMPLEX_DESCRIPTOR, PCIe_PORT_DESCRIPTOR and PCIe_DDI_DESCRIPTOR
150 */
151 AllocHeapParams.RequestedBufferSize =
152 sizeof(Brazos) + sizeof(PortList) + sizeof(DdiList);
Edward O'Callaghan4726a872014-01-25 07:40:39 +1100153
154 AllocHeapParams.BufferHandle = AMD_MEM_MISC_HANDLES_START;
155 AllocHeapParams.Persist = HEAP_LOCAL_CACHE;
156 Status = HeapAllocateBuffer (&AllocHeapParams, &InitEarly->StdHeader);
Kyösti Mälkki1ef67e12014-12-16 16:45:52 +0200157 ASSERT(Status == AGESA_SUCCESS);
Edward O'Callaghan4726a872014-01-25 07:40:39 +1100158
Edward O'Callaghanfeebd862014-04-10 19:12:28 +1000159 BrazosPcieComplexListPtr =
160 (PCIe_COMPLEX_DESCRIPTOR *) AllocHeapParams.BufferPtr;
Edward O'Callaghan4726a872014-01-25 07:40:39 +1100161
162 AllocHeapParams.BufferPtr += sizeof(Brazos);
Edward O'Callaghanfeebd862014-04-10 19:12:28 +1000163 BrazosPciePortPtr = (PCIe_PORT_DESCRIPTOR *) AllocHeapParams.BufferPtr;
Edward O'Callaghan4726a872014-01-25 07:40:39 +1100164
165 AllocHeapParams.BufferPtr += sizeof(PortList);
Edward O'Callaghanfeebd862014-04-10 19:12:28 +1000166 BrazosPcieDdiPtr = (PCIe_DDI_DESCRIPTOR *) AllocHeapParams.BufferPtr;
Edward O'Callaghan4726a872014-01-25 07:40:39 +1100167
Edward O'Callaghane2f3bfc2014-04-11 12:56:13 +1000168 memcpy(BrazosPcieComplexListPtr, &Brazos, sizeof(Brazos));
169 memcpy(BrazosPciePortPtr, &PortList[0], sizeof(PortList));
170 memcpy(BrazosPcieDdiPtr, &DdiList[0], sizeof(DdiList));
Edward O'Callaghan4726a872014-01-25 07:40:39 +1100171
Edward O'Callaghanfeebd862014-04-10 19:12:28 +1000172 ((PCIe_COMPLEX_DESCRIPTOR *) BrazosPcieComplexListPtr)->PciePortList =
173 (PCIe_PORT_DESCRIPTOR *) BrazosPciePortPtr;
174 ((PCIe_COMPLEX_DESCRIPTOR *) BrazosPcieComplexListPtr)->DdiLinkList =
175 (PCIe_DDI_DESCRIPTOR *) BrazosPcieDdiPtr;
Edward O'Callaghan4726a872014-01-25 07:40:39 +1100176
177 InitEarly->GnbConfig.PcieComplexList = BrazosPcieComplexListPtr;
Edward O'Callaghanfeebd862014-04-10 19:12:28 +1000178 InitEarly->GnbConfig.PsppPolicy = 0;
Kyösti Mälkki6e74b2c2014-12-16 07:34:58 +0200179 return AGESA_SUCCESS;
Edward O'Callaghan4726a872014-01-25 07:40:39 +1100180}
Kyösti Mälkki6e74b2c2014-12-16 07:34:58 +0200181
Kyösti Mälkki53052fe2016-04-27 09:04:11 +0300182/**
183 * @brief Customer Overides Memory Table
184 *
185 * Platform Specific Overriding Table allows IBV/OEM to pass in platform
186 * information to AGESA
187 * (e.g. MemClk routing, the number of DIMM slots per channel,...).
188 * If PlatformSpecificTable is populated, AGESA will base its settings on the
189 * data from the table. Otherwise, it will use its default conservative settings.
190 */
191const PSO_ENTRY ROMDATA DefaultPlatformMemoryConfiguration[] = {
192 NUMBER_OF_DIMMS_SUPPORTED (ANY_SOCKET, ANY_CHANNEL, 2),
193 NUMBER_OF_CHANNELS_SUPPORTED (ANY_SOCKET, 1),
194 PSO_END
195};
196
Kyösti Mälkki6e74b2c2014-12-16 07:34:58 +0200197const struct OEM_HOOK OemCustomize = {
198 .InitEarly = OemInitEarly,
199};