blob: fcc0d87580c3e4c520f941beefe020868265ce9c [file] [log] [blame]
Frank Vibrans39fca802011-02-14 18:35:15 +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
Patrick Georgib890a122015-03-26 15:17:45 +010017 * Foundation, Inc.
Frank Vibrans39fca802011-02-14 18:35:15 +000018 */
19
20#include <console/console.h>
21#include <arch/io.h>
Kyösti Mälkki8ae16a42014-06-19 20:44:34 +030022#include <arch/acpi.h>
Kyösti Mälkki68a83df2014-11-26 09:51:14 +020023#include <arch/acpigen.h>
Frank Vibrans39fca802011-02-14 18:35:15 +000024#include <stdint.h>
25#include <device/device.h>
26#include <device/pci.h>
27#include <device/pci_ids.h>
28#include <device/hypertransport.h>
29#include <stdlib.h>
30#include <string.h>
Ronald G. Minnich5079a0d2012-11-27 11:32:38 -080031#include <lib.h>
Frank Vibrans39fca802011-02-14 18:35:15 +000032#include <cpu/cpu.h>
Marc Jones5750ed22012-03-15 13:21:41 -060033#include <cbmem.h>
Frank Vibrans39fca802011-02-14 18:35:15 +000034
35#include <cpu/x86/lapic.h>
Kyösti Mälkki55fff9302012-07-11 08:02:39 +030036#include <cpu/amd/mtrr.h>
Frank Vibrans39fca802011-02-14 18:35:15 +000037
Kyösti Mälkkif21c2ac2014-10-19 09:35:18 +030038#include <northbridge/amd/agesa/agesawrapper.h>
Kerry Shefeed3292011-08-18 18:03:44 +080039#if CONFIG_AMD_SB_CIMX
40#include <sb_cimx.h>
41#endif
Frank Vibrans39fca802011-02-14 18:35:15 +000042
Frank Vibrans39fca802011-02-14 18:35:15 +000043//#define FX_DEVS NODE_NUMS
44#define FX_DEVS 1
45
46static device_t __f0_dev[FX_DEVS];
47static device_t __f1_dev[FX_DEVS];
48static device_t __f2_dev[FX_DEVS];
49static device_t __f4_dev[FX_DEVS];
Marc Jones8d595692012-03-15 12:55:26 -060050static unsigned fx_devs = 0;
Frank Vibrans39fca802011-02-14 18:35:15 +000051
Edward O'Callaghan541ac592014-11-21 00:37:02 +110052static device_t get_node_pci(u32 nodeid, u32 fn)
Frank Vibrans39fca802011-02-14 18:35:15 +000053{
zbao49bb26a42012-08-03 15:44:42 +080054 if ((CONFIG_CDB + nodeid) < 32) {
55 return dev_find_slot(CONFIG_CBB, PCI_DEVFN(CONFIG_CDB + nodeid, fn));
56 } else {
57 return dev_find_slot(CONFIG_CBB-1, PCI_DEVFN(CONFIG_CDB + nodeid - 32, fn));
58 }
Frank Vibrans39fca802011-02-14 18:35:15 +000059}
60
Frank Vibrans39fca802011-02-14 18:35:15 +000061static void get_fx_devs(void)
62{
Marc Jones8d595692012-03-15 12:55:26 -060063 int i;
64 for (i = 0; i < FX_DEVS; i++) {
65 __f0_dev[i] = get_node_pci(i, 0);
66 __f1_dev[i] = get_node_pci(i, 1);
67 __f2_dev[i] = get_node_pci(i, 2);
68 __f4_dev[i] = get_node_pci(i, 4);
69 if (__f0_dev[i] != NULL && __f1_dev[i] != NULL)
70 fx_devs = i + 1;
71 }
72 if (__f1_dev[0] == NULL || __f0_dev[0] == NULL || fx_devs == 0) {
73 die("Cannot find 0:0x18.[0|1]\n");
74 }
Frank Vibrans39fca802011-02-14 18:35:15 +000075}
76
Frank Vibrans39fca802011-02-14 18:35:15 +000077static u32 f1_read_config32(unsigned reg)
78{
Marc Jones8d595692012-03-15 12:55:26 -060079 if (fx_devs == 0)
80 get_fx_devs();
81 return pci_read_config32(__f1_dev[0], reg);
Frank Vibrans39fca802011-02-14 18:35:15 +000082}
83
Frank Vibrans39fca802011-02-14 18:35:15 +000084static void f1_write_config32(unsigned reg, u32 value)
85{
Marc Jones8d595692012-03-15 12:55:26 -060086 int i;
87 if (fx_devs == 0)
88 get_fx_devs();
89 for (i = 0; i < fx_devs; i++) {
90 device_t dev;
91 dev = __f1_dev[i];
92 if (dev && dev->enabled) {
93 pci_write_config32(dev, reg, value);
94 }
95 }
Frank Vibrans39fca802011-02-14 18:35:15 +000096}
97
Frank Vibrans39fca802011-02-14 18:35:15 +000098static u32 amdfam14_nodeid(device_t dev)
99{
Marc Jones8d595692012-03-15 12:55:26 -0600100 return (dev->path.pci.devfn >> 3) - CONFIG_CDB;
Frank Vibrans39fca802011-02-14 18:35:15 +0000101}
102
Frank Vibrans39fca802011-02-14 18:35:15 +0000103#include "amdfam14_conf.c"
104
Frank Vibrans39fca802011-02-14 18:35:15 +0000105static void northbridge_init(device_t dev)
106{
Marc Jones8d595692012-03-15 12:55:26 -0600107 printk(BIOS_DEBUG, "Northbridge init\n");
Frank Vibrans39fca802011-02-14 18:35:15 +0000108}
109
Frank Vibrans39fca802011-02-14 18:35:15 +0000110static void set_vga_enable_reg(u32 nodeid, u32 linkn)
111{
Marc Jones8d595692012-03-15 12:55:26 -0600112 u32 val;
Frank Vibrans39fca802011-02-14 18:35:15 +0000113
Marc Jones8d595692012-03-15 12:55:26 -0600114 val = 1 | (nodeid << 4) | (linkn << 12);
115 /* it will routing (1)mmio 0xa0000:0xbffff (2) io 0x3b0:0x3bb,
116 0x3c0:0x3df */
117 f1_write_config32(0xf4, val);
Frank Vibrans39fca802011-02-14 18:35:15 +0000118
119}
120
Frank Vibrans39fca802011-02-14 18:35:15 +0000121static int reg_useable(unsigned reg, device_t goal_dev, unsigned goal_nodeid,
Marc Jones8d595692012-03-15 12:55:26 -0600122 unsigned goal_link)
Frank Vibrans39fca802011-02-14 18:35:15 +0000123{
Marc Jones8d595692012-03-15 12:55:26 -0600124 struct resource *res;
125 unsigned nodeid, link = 0;
126 int result;
127 res = 0;
128 for (nodeid = 0; !res && (nodeid < fx_devs); nodeid++) {
129 device_t dev;
130 dev = __f0_dev[nodeid];
131 if (!dev)
132 continue;
133 for (link = 0; !res && (link < 8); link++) {
134 res = probe_resource(dev, IOINDEX(0x1000 + reg, link));
135 }
136 }
137 result = 2;
138 if (res) {
139 result = 0;
140 if ((goal_link == (link - 1)) &&
141 (goal_nodeid == (nodeid - 1)) && (res->flags <= 1)) {
142 result = 1;
143 }
144 }
145 return result;
Frank Vibrans39fca802011-02-14 18:35:15 +0000146}
147
Marc Jones8d595692012-03-15 12:55:26 -0600148static struct resource *amdfam14_find_iopair(device_t dev, unsigned nodeid,
149 unsigned link)
Frank Vibrans39fca802011-02-14 18:35:15 +0000150{
Marc Jones8d595692012-03-15 12:55:26 -0600151 struct resource *resource;
152 u32 result, reg;
153 resource = 0;
154 reg = 0;
155 result = reg_useable(0xc0, dev, nodeid, link);
156 if (result >= 1) {
157 /* I have been allocated this one */
158 reg = 0xc0;
159 }
160 /* Ext conf space */
161 if (!reg) {
162 /* Because of Extend conf space, we will never run out of reg,
163 * but we need one index to differ them. So ,same node and same
164 * link can have multi range
165 */
166 u32 index = get_io_addr_index(nodeid, link);
167 reg = 0x110 + (index << 24) + (4 << 20); // index could be 0, 255
168 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000169
Marc Jones8d595692012-03-15 12:55:26 -0600170 resource = new_resource(dev, IOINDEX(0x1000 + reg, link));
Frank Vibrans39fca802011-02-14 18:35:15 +0000171
Marc Jones8d595692012-03-15 12:55:26 -0600172 return resource;
Frank Vibrans39fca802011-02-14 18:35:15 +0000173}
174
Marc Jones8d595692012-03-15 12:55:26 -0600175static struct resource *amdfam14_find_mempair(device_t dev, u32 nodeid,
176 u32 link)
Frank Vibrans39fca802011-02-14 18:35:15 +0000177{
Marc Jones8d595692012-03-15 12:55:26 -0600178 struct resource *resource;
179 u32 free_reg, reg;
180 resource = 0;
181 free_reg = 0;
182 for (reg = 0x80; reg <= 0xb8; reg += 0x8) {
183 int result;
184 result = reg_useable(reg, dev, nodeid, link);
185 if (result == 1) {
186 /* I have been allocated this one */
187 break;
188 } else if (result > 1) {
189 /* I have a free register pair */
190 free_reg = reg;
191 }
192 }
193 if (reg > 0xb8) {
194 reg = free_reg;
195 }
196 /* Ext conf space */
197 if (!reg) {
198 /* Because of Extend conf space, we will never run out of reg,
199 * but we need one index to differ them. So ,same node and same
200 * link can have multi range
201 */
202 u32 index = get_mmio_addr_index(nodeid, link);
203 reg = 0x110 + (index << 24) + (6 << 20); // index could be 0, 63
Frank Vibrans39fca802011-02-14 18:35:15 +0000204
Marc Jones8d595692012-03-15 12:55:26 -0600205 }
206 resource = new_resource(dev, IOINDEX(0x1000 + reg, link));
207 return resource;
Frank Vibrans39fca802011-02-14 18:35:15 +0000208}
209
Frank Vibrans39fca802011-02-14 18:35:15 +0000210static void amdfam14_link_read_bases(device_t dev, u32 nodeid, u32 link)
211{
Marc Jones8d595692012-03-15 12:55:26 -0600212 struct resource *resource;
Frank Vibrans39fca802011-02-14 18:35:15 +0000213
Marc Jones8d595692012-03-15 12:55:26 -0600214 /* Initialize the io space constraints on the current bus */
215 resource = amdfam14_find_iopair(dev, nodeid, link);
216 if (resource) {
217 u32 align;
Kyösti Mälkkiac7402d2014-12-14 08:30:17 +0200218 align = log2(HT_IO_HOST_ALIGN);
Marc Jones8d595692012-03-15 12:55:26 -0600219 resource->base = 0;
220 resource->size = 0;
221 resource->align = align;
222 resource->gran = align;
223 resource->limit = 0xffffUL;
224 resource->flags = IORESOURCE_IO | IORESOURCE_BRIDGE;
225 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000226
Marc Jones8d595692012-03-15 12:55:26 -0600227 /* Initialize the prefetchable memory constraints on the current bus */
228 resource = amdfam14_find_mempair(dev, nodeid, link);
229 if (resource) {
230 resource->base = 0;
231 resource->size = 0;
232 resource->align = log2(HT_MEM_HOST_ALIGN);
233 resource->gran = log2(HT_MEM_HOST_ALIGN);
234 resource->limit = 0xffffffffffULL;
235 resource->flags = IORESOURCE_MEM | IORESOURCE_PREFETCH;
236 resource->flags |= IORESOURCE_BRIDGE;
Marc Jones8d595692012-03-15 12:55:26 -0600237 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000238
Marc Jones8d595692012-03-15 12:55:26 -0600239 /* Initialize the memory constraints on the current bus */
240 resource = amdfam14_find_mempair(dev, nodeid, link);
241 if (resource) {
242 resource->base = 0;
243 resource->size = 0;
244 resource->align = log2(HT_MEM_HOST_ALIGN);
245 resource->gran = log2(HT_MEM_HOST_ALIGN);
246 resource->limit = 0xffffffffffULL;
247 resource->flags = IORESOURCE_MEM | IORESOURCE_BRIDGE;
Marc Jones8d595692012-03-15 12:55:26 -0600248 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000249}
250
251static u32 my_find_pci_tolm(struct bus *bus, u32 tolm)
252{
Marc Jones8d595692012-03-15 12:55:26 -0600253 struct resource *min;
254 min = 0;
255 search_bus_resources(bus, IORESOURCE_MEM, IORESOURCE_MEM, tolm_test,
256 &min);
257 if (min && tolm > min->base) {
258 tolm = min->base;
259 }
260 return tolm;
Frank Vibrans39fca802011-02-14 18:35:15 +0000261}
262
263#if CONFIG_HW_MEM_HOLE_SIZEK != 0
264
265struct hw_mem_hole_info {
Marc Jones8d595692012-03-15 12:55:26 -0600266 unsigned hole_startk;
267 int node_id;
Frank Vibrans39fca802011-02-14 18:35:15 +0000268};
269
270static struct hw_mem_hole_info get_hw_mem_hole_info(void)
271{
Marc Jones8d595692012-03-15 12:55:26 -0600272 struct hw_mem_hole_info mem_hole;
Frank Vibrans39fca802011-02-14 18:35:15 +0000273
Marc Jones8d595692012-03-15 12:55:26 -0600274 mem_hole.hole_startk = CONFIG_HW_MEM_HOLE_SIZEK;
275 mem_hole.node_id = -1;
Frank Vibrans39fca802011-02-14 18:35:15 +0000276
Marc Jones8d595692012-03-15 12:55:26 -0600277 struct dram_base_mask_t d;
278 u32 hole;
279 d = get_dram_base_mask(0);
280 if (d.mask & 1) {
281 hole = pci_read_config32(__f1_dev[0], 0xf0);
282 if (hole & 1) { // we find the hole
283 mem_hole.hole_startk = (hole & (0xff << 24)) >> 10;
284 mem_hole.node_id = 0; // record the node No with hole
285 }
286 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000287#if 0
Kyösti Mälkki2f9b3af2014-06-26 05:30:54 +0300288 /* We need to double check if there is special set on base reg and limit reg
289 * are not continuous instead of hole, it will find out its hole_startk.
Marc Jones8d595692012-03-15 12:55:26 -0600290 */
291 if (mem_hole.node_id == -1) {
292 resource_t limitk_pri = 0;
293 struct dram_base_mask_t d;
294 resource_t base_k, limit_k;
295 d = get_dram_base_mask(0);
296 if (d.base & 1) {
297 base_k = ((resource_t) (d.base & 0x1fffff00)) << 9;
298 if (base_k <= 4 * 1024 * 1024) {
299 if (limitk_pri != base_k) { // we find the hole
300 mem_hole.hole_startk = (unsigned)limitk_pri; // must be below 4G
301 mem_hole.node_id = 0;
302 }
303 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000304
Marc Jones8d595692012-03-15 12:55:26 -0600305 limit_k =
306 ((resource_t) ((d.mask + 0x00000100) & 0x1fffff00))
307 << 9;
308 limitk_pri = limit_k;
309 }
310 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000311#endif
efdesign9805a89ab2011-06-20 17:38:49 -0700312
Marc Jones8d595692012-03-15 12:55:26 -0600313 return mem_hole;
Frank Vibrans39fca802011-02-14 18:35:15 +0000314}
315#endif
316
Marc Jones8a49ac72013-01-16 17:02:20 -0700317static void nb_read_resources(device_t dev)
Frank Vibrans39fca802011-02-14 18:35:15 +0000318{
Marc Jones8d595692012-03-15 12:55:26 -0600319 u32 nodeid;
320 struct bus *link;
Frank Vibrans39fca802011-02-14 18:35:15 +0000321
Mike Loptien58089e82013-01-29 15:45:09 -0700322 printk(BIOS_DEBUG, "\nFam14h - %s\n", __func__);
Frank Vibrans39fca802011-02-14 18:35:15 +0000323
Marc Jones8d595692012-03-15 12:55:26 -0600324 nodeid = amdfam14_nodeid(dev);
325 for (link = dev->link_list; link; link = link->next) {
326 if (link->children) {
327 amdfam14_link_read_bases(dev, nodeid, link->link_num);
328 }
329 }
Marc Jonesd5c998b2013-01-16 17:14:24 -0700330
331 /*
Stefan Reinauer4aff4452013-02-12 14:17:15 -0800332 * This MMCONF resource must be reserved in the PCI domain.
Marc Jonesd5c998b2013-01-16 17:14:24 -0700333 * It is not honored by the coreboot resource allocator if it is in
Stefan Reinauer0aa37c42013-02-12 15:20:54 -0800334 * the CPU_CLUSTER.
Marc Jonesd5c998b2013-01-16 17:14:24 -0700335 */
336#if CONFIG_MMCONF_SUPPORT
337 struct resource *resource = new_resource(dev, 0xc0010058);
338 resource->base = CONFIG_MMCONF_BASE_ADDRESS;
339 resource->size = CONFIG_MMCONF_BUS_NUMBER * 4096 * 256;
340 resource->flags = IORESOURCE_MEM | IORESOURCE_RESERVE |
341 IORESOURCE_FIXED | IORESOURCE_STORED | IORESOURCE_ASSIGNED;
342#endif
Frank Vibrans39fca802011-02-14 18:35:15 +0000343}
344
Marc Jones8d595692012-03-15 12:55:26 -0600345static void set_resource(device_t dev, struct resource *resource, u32 nodeid)
Frank Vibrans39fca802011-02-14 18:35:15 +0000346{
Marc Jones8d595692012-03-15 12:55:26 -0600347 resource_t rbase, rend;
348 unsigned reg, link_num;
349 char buf[50];
Frank Vibrans39fca802011-02-14 18:35:15 +0000350
Mike Loptien58089e82013-01-29 15:45:09 -0700351 printk(BIOS_DEBUG, "\nFam14h - %s\n", __func__);
Frank Vibrans39fca802011-02-14 18:35:15 +0000352
Marc Jones8d595692012-03-15 12:55:26 -0600353 /* Make certain the resource has actually been set */
354 if (!(resource->flags & IORESOURCE_ASSIGNED)) {
355 return;
356 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000357
Marc Jones8d595692012-03-15 12:55:26 -0600358 /* If I have already stored this resource don't worry about it */
359 if (resource->flags & IORESOURCE_STORED) {
360 return;
361 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000362
Marc Jones8d595692012-03-15 12:55:26 -0600363 /* Only handle PCI memory and IO resources */
364 if (!(resource->flags & (IORESOURCE_MEM | IORESOURCE_IO)))
365 return;
Frank Vibrans39fca802011-02-14 18:35:15 +0000366
Marc Jones8d595692012-03-15 12:55:26 -0600367 /* Ensure I am actually looking at a resource of function 1 */
368 if ((resource->index & 0xffff) < 0x1000) {
369 return;
370 }
371 /* Get the base address */
372 rbase = resource->base;
Frank Vibrans39fca802011-02-14 18:35:15 +0000373
Marc Jones8d595692012-03-15 12:55:26 -0600374 /* Get the limit (rounded up) */
375 rend = resource_end(resource);
Frank Vibrans39fca802011-02-14 18:35:15 +0000376
Marc Jones8d595692012-03-15 12:55:26 -0600377 /* Get the register and link */
378 reg = resource->index & 0xfff; // 4k
379 link_num = IOINDEX_LINK(resource->index);
Frank Vibrans39fca802011-02-14 18:35:15 +0000380
Marc Jones8d595692012-03-15 12:55:26 -0600381 if (resource->flags & IORESOURCE_IO) {
382 set_io_addr_reg(dev, nodeid, link_num, reg, rbase >> 8,
383 rend >> 8);
384 } else if (resource->flags & IORESOURCE_MEM) {
385 set_mmio_addr_reg(nodeid, link_num, reg, (resource->index >> 24),
386 rbase >> 8, rend >> 8, 1); // [39:8]
387 }
388 resource->flags |= IORESOURCE_STORED;
Vladimir Serbinenkoa37383d2013-11-26 02:41:26 +0100389 snprintf(buf, sizeof (buf), " <node %x link %x>", nodeid, link_num);
Marc Jones8d595692012-03-15 12:55:26 -0600390 report_resource_stored(dev, resource, buf);
Frank Vibrans39fca802011-02-14 18:35:15 +0000391}
392
efdesign983f5ebd62011-09-14 13:47:17 -0600393#if CONFIG_CONSOLE_VGA_MULTI
Marc Jones8d595692012-03-15 12:55:26 -0600394extern device_t vga_pri; // the primary vga device, defined in device.c
Frank Vibrans39fca802011-02-14 18:35:15 +0000395#endif
396
397static void create_vga_resource(device_t dev, unsigned nodeid)
398{
Marc Jones8d595692012-03-15 12:55:26 -0600399 struct bus *link;
Frank Vibrans39fca802011-02-14 18:35:15 +0000400
Mike Loptien58089e82013-01-29 15:45:09 -0700401 printk(BIOS_DEBUG, "\nFam14h - %s\n", __func__);
Frank Vibrans39fca802011-02-14 18:35:15 +0000402
Marc Jones8d595692012-03-15 12:55:26 -0600403 /* find out which link the VGA card is connected,
404 * we only deal with the 'first' vga card */
405 for (link = dev->link_list; link; link = link->next) {
406 if (link->bridge_ctrl & PCI_BRIDGE_CTL_VGA) {
efdesign983f5ebd62011-09-14 13:47:17 -0600407#if CONFIG_CONSOLE_VGA_MULTI
Marc Jones8d595692012-03-15 12:55:26 -0600408 printk(BIOS_DEBUG,
409 "VGA: vga_pri bus num = %d bus range [%d,%d]\n",
410 vga_pri->bus->secondary, link->secondary,
411 link->subordinate);
412 /* We need to make sure the vga_pri is under the link */
413 if ((vga_pri->bus->secondary >= link->secondary) &&
414 (vga_pri->bus->secondary <= link->subordinate))
Frank Vibrans39fca802011-02-14 18:35:15 +0000415#endif
Marc Jones8d595692012-03-15 12:55:26 -0600416 break;
417 }
418 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000419
Marc Jones8d595692012-03-15 12:55:26 -0600420 /* no VGA card installed */
421 if (link == NULL)
422 return;
Frank Vibrans39fca802011-02-14 18:35:15 +0000423
Marc Jones8d595692012-03-15 12:55:26 -0600424 printk(BIOS_DEBUG, "VGA: %s (aka node %d) link %d has VGA device\n",
425 dev_path(dev), nodeid, link->link_num);
426 set_vga_enable_reg(nodeid, link->link_num);
Frank Vibrans39fca802011-02-14 18:35:15 +0000427}
428
Marc Jones8a49ac72013-01-16 17:02:20 -0700429static void nb_set_resources(device_t dev)
Frank Vibrans39fca802011-02-14 18:35:15 +0000430{
Marc Jones8d595692012-03-15 12:55:26 -0600431 unsigned nodeid;
432 struct bus *bus;
433 struct resource *res;
Frank Vibrans39fca802011-02-14 18:35:15 +0000434
Mike Loptien58089e82013-01-29 15:45:09 -0700435 printk(BIOS_DEBUG, "\nFam14h - %s\n", __func__);
efdesign9805a89ab2011-06-20 17:38:49 -0700436
Marc Jones8d595692012-03-15 12:55:26 -0600437 /* Find the nodeid */
438 nodeid = amdfam14_nodeid(dev);
Frank Vibrans39fca802011-02-14 18:35:15 +0000439
Marc Jones8d595692012-03-15 12:55:26 -0600440 create_vga_resource(dev, nodeid);
Frank Vibrans39fca802011-02-14 18:35:15 +0000441
Marc Jones8d595692012-03-15 12:55:26 -0600442 /* Set each resource we have found */
443 for (res = dev->resource_list; res; res = res->next) {
444 set_resource(dev, res, nodeid);
445 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000446
Marc Jones8d595692012-03-15 12:55:26 -0600447 for (bus = dev->link_list; bus; bus = bus->next) {
448 if (bus->children) {
449 assign_resources(bus);
450 }
451 }
Marc Jonesd5c998b2013-01-16 17:14:24 -0700452
453 /* Print the MMCONF region if it has been reserved. */
454 res = find_resource(dev, 0xc0010058);
455 if (res) {
456 report_resource_stored(dev, res, " <mmconfig>");
457 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000458}
459
Frank Vibrans39fca802011-02-14 18:35:15 +0000460/* Domain/Root Complex related code */
461
462static void domain_read_resources(device_t dev)
463{
Marc Jones8d595692012-03-15 12:55:26 -0600464 unsigned reg;
Frank Vibrans39fca802011-02-14 18:35:15 +0000465
Mike Loptien58089e82013-01-29 15:45:09 -0700466 printk(BIOS_DEBUG, "\nFam14h - %s\n", __func__);
Frank Vibrans39fca802011-02-14 18:35:15 +0000467
Marc Jones8d595692012-03-15 12:55:26 -0600468 /* Find the already assigned resource pairs */
469 get_fx_devs();
470 for (reg = 0x80; reg <= 0xc0; reg += 0x08) {
471 u32 base, limit;
472 base = f1_read_config32(reg);
473 limit = f1_read_config32(reg + 0x04);
474 /* Is this register allocated? */
475 if ((base & 3) != 0) {
476 unsigned nodeid, reg_link;
477 device_t reg_dev;
478 if (reg < 0xc0) { // mmio
479 nodeid = (limit & 0xf) + (base & 0x30);
480 } else { // io
481 nodeid = (limit & 0xf) + ((base >> 4) & 0x30);
482 }
483 reg_link = (limit >> 4) & 7;
484 reg_dev = __f0_dev[nodeid];
485 if (reg_dev) {
486 /* Reserve the resource */
487 struct resource *res;
488 res =
489 new_resource(reg_dev,
490 IOINDEX(0x1000 + reg,
491 reg_link));
492 if (res) {
493 res->flags = 1;
494 }
495 }
496 }
497 }
498 /* FIXME: do we need to check extend conf space?
499 I don't believe that much preset value */
Frank Vibrans39fca802011-02-14 18:35:15 +0000500
Marc Jones8d595692012-03-15 12:55:26 -0600501 pci_domain_read_resources(dev);
Frank Vibrans39fca802011-02-14 18:35:15 +0000502}
503
Kyösti Mälkki6b5eb1c2012-07-19 19:26:43 +0300504static void setup_uma_memory(void)
Kyösti Mälkki55fff9302012-07-11 08:02:39 +0300505{
506#if CONFIG_GFXUMA
Kyösti Mälkkidbc47392012-08-05 12:11:40 +0300507 uint32_t topmem = (uint32_t) bsp_topmem();
Kyösti Mälkki55fff9302012-07-11 08:02:39 +0300508 uint32_t sys_mem;
509
Kyösti Mälkki55fff9302012-07-11 08:02:39 +0300510 /* refer to UMA Size Consideration in Family14h BKDG. */
Kyösti Mälkkidbc47392012-08-05 12:11:40 +0300511 sys_mem = topmem + 0x1000000; // Ignore 16MB allocated for C6 when finding UMA size, refer MemNGetUmaSizeON()
512 if ((bsp_topmem2()>>32) || (sys_mem >= 0x80000000)) {
Kyösti Mälkki55fff9302012-07-11 08:02:39 +0300513 uma_memory_size = 0x18000000; /* >= 2G memory, 384M recommended UMA */
514 }
515 else {
516 if (sys_mem >= 0x40000000) {
517 uma_memory_size = 0x10000000; /* >= 1G memory, 256M recommended UMA */
518 } else {
519 uma_memory_size = 0x4000000; /* <1G memory, 64M recommended UMA */
520 }
521 }
522
Kyösti Mälkkidbc47392012-08-05 12:11:40 +0300523 uma_memory_base = topmem - uma_memory_size; /* TOP_MEM1 */
Kyösti Mälkki55fff9302012-07-11 08:02:39 +0300524 printk(BIOS_INFO, "%s: uma size 0x%08llx, memory start 0x%08llx\n",
525 __func__, uma_memory_size, uma_memory_base);
Kyösti Mälkki55fff9302012-07-11 08:02:39 +0300526#endif
527}
528
Frank Vibrans39fca802011-02-14 18:35:15 +0000529static void domain_set_resources(device_t dev)
530{
Mike Loptien58089e82013-01-29 15:45:09 -0700531 printk(BIOS_DEBUG, "\nFam14h - %s\n", __func__);
Marc Jones8d595692012-03-15 12:55:26 -0600532 printk(BIOS_DEBUG, " amsr - incoming dev = %08x\n", (u32) dev);
Frank Vibrans39fca802011-02-14 18:35:15 +0000533
Marc Jones8d595692012-03-15 12:55:26 -0600534 unsigned long mmio_basek;
535 u32 pci_tolm;
Kyösti Mälkki2b790f62013-09-03 05:25:57 +0300536 u64 ramtop = 0;
Marc Jones8d595692012-03-15 12:55:26 -0600537 int idx;
538 struct bus *link;
Frank Vibrans39fca802011-02-14 18:35:15 +0000539#if CONFIG_HW_MEM_HOLE_SIZEK != 0
Marc Jones8d595692012-03-15 12:55:26 -0600540 struct hw_mem_hole_info mem_hole;
541 u32 reset_memhole = 1;
Frank Vibrans39fca802011-02-14 18:35:15 +0000542#endif
543
Marc Jones8d595692012-03-15 12:55:26 -0600544 pci_tolm = 0xffffffffUL;
545 for (link = dev->link_list; link; link = link->next) {
546 pci_tolm = my_find_pci_tolm(link, pci_tolm);
547 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000548
Marc Jones8d595692012-03-15 12:55:26 -0600549 // FIXME handle interleaved nodes. If you fix this here, please fix
550 // amdk8, too.
551 mmio_basek = pci_tolm >> 10;
552 /* Round mmio_basek to something the processor can support */
553 mmio_basek &= ~((1 << 6) - 1);
Frank Vibrans39fca802011-02-14 18:35:15 +0000554
Marc Jones8d595692012-03-15 12:55:26 -0600555 // FIXME improve mtrr.c so we don't use up all of the mtrrs with a 64M
556 // MMIO hole. If you fix this here, please fix amdk8, too.
557 /* Round the mmio hole to 64M */
558 mmio_basek &= ~((64 * 1024) - 1);
Frank Vibrans39fca802011-02-14 18:35:15 +0000559
560#if CONFIG_HW_MEM_HOLE_SIZEK != 0
561/* if the hw mem hole is already set in raminit stage, here we will compare
562 * mmio_basek and hole_basek. if mmio_basek is bigger that hole_basek and will
563 * use hole_basek as mmio_basek and we don't need to reset hole.
564 * otherwise We reset the hole to the mmio_basek
565 */
566
Marc Jones8d595692012-03-15 12:55:26 -0600567 mem_hole = get_hw_mem_hole_info();
Frank Vibrans39fca802011-02-14 18:35:15 +0000568
Marc Jones8d595692012-03-15 12:55:26 -0600569 // Use hole_basek as mmio_basek, and we don't need to reset hole anymore
570 if ((mem_hole.node_id != -1) && (mmio_basek > mem_hole.hole_startk)) {
571 mmio_basek = mem_hole.hole_startk;
572 reset_memhole = 0;
573 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000574#endif
575
Marc Jones8d595692012-03-15 12:55:26 -0600576 idx = 0x10;
Frank Vibrans39fca802011-02-14 18:35:15 +0000577
Marc Jones8d595692012-03-15 12:55:26 -0600578 struct dram_base_mask_t d;
579 resource_t basek, limitk, sizek; // 4 1T
Frank Vibrans39fca802011-02-14 18:35:15 +0000580
Marc Jones8d595692012-03-15 12:55:26 -0600581 d = get_dram_base_mask(0);
Frank Vibrans39fca802011-02-14 18:35:15 +0000582
Marc Jones8d595692012-03-15 12:55:26 -0600583 if (d.mask & 1) {
584 basek = ((resource_t) ((u64) d.base)) << 8;
585 limitk = (resource_t) (((u64) d.mask << 8) | 0xFFFFFF);
586 printk(BIOS_DEBUG,
587 "adsr: (before) basek = %llx, limitk = %llx.\n", basek,
588 limitk);
Frank Vibrans39fca802011-02-14 18:35:15 +0000589
Marc Jones8d595692012-03-15 12:55:26 -0600590 /* Convert these values to multiples of 1K for ease of math. */
591 basek >>= 10;
592 limitk >>= 10;
593 sizek = limitk - basek + 1;
Frank Vibrans39fca802011-02-14 18:35:15 +0000594
Marc Jones8d595692012-03-15 12:55:26 -0600595 printk(BIOS_DEBUG,
596 "adsr: (after) basek = %llx, limitk = %llx, sizek = %llx.\n",
597 basek, limitk, sizek);
Frank Vibrans39fca802011-02-14 18:35:15 +0000598
Marc Jones8d595692012-03-15 12:55:26 -0600599 /* see if we need a hole from 0xa0000 to 0xbffff */
600 if ((basek < 640) && (sizek > 768)) {
601 printk(BIOS_DEBUG,"adsr - 0xa0000 to 0xbffff resource.\n");
602 ram_resource(dev, (idx | 0), basek, 640 - basek);
603 idx += 0x10;
604 basek = 768;
605 sizek = limitk - 768;
606 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000607
Marc Jones8d595692012-03-15 12:55:26 -0600608 printk(BIOS_DEBUG,
609 "adsr: mmio_basek=%08lx, basek=%08llx, limitk=%08llx\n",
610 mmio_basek, basek, limitk);
Frank Vibrans39fca802011-02-14 18:35:15 +0000611
Kyösti Mälkki26c65432014-06-26 05:30:54 +0300612 /* split the region to accommodate pci memory space */
Marc Jones8d595692012-03-15 12:55:26 -0600613 if ((basek < 4 * 1024 * 1024) && (limitk > mmio_basek)) {
614 if (basek <= mmio_basek) {
615 unsigned pre_sizek;
616 pre_sizek = mmio_basek - basek;
617 if (pre_sizek > 0) {
618 ram_resource(dev, idx, basek,
619 pre_sizek);
620 idx += 0x10;
621 sizek -= pre_sizek;
Kyösti Mälkki2b790f62013-09-03 05:25:57 +0300622 if (!ramtop)
623 ramtop = mmio_basek * 1024;
Marc Jones8d595692012-03-15 12:55:26 -0600624 }
Marc Jones8d595692012-03-15 12:55:26 -0600625 basek = mmio_basek;
626 }
627 if ((basek + sizek) <= 4 * 1024 * 1024) {
628 sizek = 0;
629 } else {
630 basek = 4 * 1024 * 1024;
631 sizek -= (4 * 1024 * 1024 - mmio_basek);
632 }
633 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000634
Marc Jones8d595692012-03-15 12:55:26 -0600635 ram_resource(dev, (idx | 0), basek, sizek);
636 idx += 0x10;
Marc Jones8d595692012-03-15 12:55:26 -0600637 printk(BIOS_DEBUG,
638 "%d: mmio_basek=%08lx, basek=%08llx, limitk=%08llx\n", 0,
639 mmio_basek, basek, limitk);
Kyösti Mälkki2b790f62013-09-03 05:25:57 +0300640 if (!ramtop)
641 ramtop = limitk * 1024;
Marc Jones8d595692012-03-15 12:55:26 -0600642 }
643 printk(BIOS_DEBUG, " adsr - mmio_basek = %lx.\n", mmio_basek);
Frank Vibrans39fca802011-02-14 18:35:15 +0000644
Patrick Georgie1667822012-05-05 15:29:32 +0200645#if CONFIG_GFXUMA
Kyösti Mälkki2b790f62013-09-03 05:25:57 +0300646 set_top_of_ram(uma_memory_base);
Kyösti Mälkki63f8c082012-07-10 13:27:26 +0300647 uma_resource(dev, 7, uma_memory_base >> 10, uma_memory_size >> 10);
Kyösti Mälkki2b790f62013-09-03 05:25:57 +0300648#else
649 set_top_of_ram(ramtop);
Frank Vibrans39fca802011-02-14 18:35:15 +0000650#endif
651
Marc Jones8d595692012-03-15 12:55:26 -0600652 for (link = dev->link_list; link; link = link->next) {
653 if (link->children) {
654 assign_resources(link);
655 }
656 }
657 printk(BIOS_DEBUG, " adsr - leaving this lovely routine.\n");
Frank Vibrans39fca802011-02-14 18:35:15 +0000658}
659
zbaof7223732012-04-13 13:42:15 +0800660static void domain_enable_resources(device_t dev)
661{
Kerry Shefeed3292011-08-18 18:03:44 +0800662#if CONFIG_AMD_SB_CIMX
Kyösti Mälkkic551caa2014-06-20 12:31:23 +0300663 if (!acpi_is_wakeup_s3()) {
zbaof7223732012-04-13 13:42:15 +0800664 sb_After_Pci_Init();
665 sb_Mid_Post_Init();
666 } else {
667 sb_After_Pci_Restore_Init();
668 }
Kerry Shefeed3292011-08-18 18:03:44 +0800669#endif
670
Marc Jones8d595692012-03-15 12:55:26 -0600671 /* Must be called after PCI enumeration and resource allocation */
Mike Loptien58089e82013-01-29 15:45:09 -0700672 printk(BIOS_DEBUG, "\nFam14h - %s\n", __func__);
zbaof7223732012-04-13 13:42:15 +0800673
Kyösti Mälkkib139b5e2014-10-20 07:41:20 +0300674 if (!acpi_is_wakeup_s3()) {
675 /* Enable MMIO on AMD CPU Address Map Controller */
Kyösti Mälkki48518f02014-11-25 14:20:57 +0200676 amd_initcpuio();
Kyösti Mälkkib139b5e2014-10-20 07:41:20 +0300677
Kyösti Mälkki1aa35c62014-10-21 14:19:04 +0300678 agesawrapper_amdinitmid();
Kyösti Mälkkib139b5e2014-10-20 07:41:20 +0300679 }
efdesign9805a89ab2011-06-20 17:38:49 -0700680
Marc Jones8d595692012-03-15 12:55:26 -0600681 printk(BIOS_DEBUG, " ader - leaving domain_enable_resources.\n");
Frank Vibrans39fca802011-02-14 18:35:15 +0000682}
683
Frank Vibrans39fca802011-02-14 18:35:15 +0000684/* Bus related code */
685
Kyösti Mälkki580e7222015-03-19 21:04:23 +0200686static void cpu_bus_scan(struct device *dev)
zbaof7223732012-04-13 13:42:15 +0800687{
Kyösti Mälkkic33f1e92012-08-07 17:12:11 +0300688 struct bus *cpu_bus = dev->link_list;
Scott Duplichan9ab3c6c2011-05-15 21:45:46 +0000689 device_t cpu;
zbaof7223732012-04-13 13:42:15 +0800690 int apic_id, cores_found;
Scott Duplichan9ab3c6c2011-05-15 21:45:46 +0000691
zbaof7223732012-04-13 13:42:15 +0800692 /* There is only one node for fam14, but there may be multiple cores. */
693 cpu = dev_find_slot(0, PCI_DEVFN(0x18, 0));
694 if (!cpu)
695 printk(BIOS_ERR, "ERROR: %02x:%02x.0 not found", 0, 0x18);
Scott Duplichan9ab3c6c2011-05-15 21:45:46 +0000696
zbaof7223732012-04-13 13:42:15 +0800697 cores_found = (pci_read_config32(dev_find_slot(0,PCI_DEVFN(0x18,0x3)), 0xe8) >> 12) & 3;
698 printk(BIOS_DEBUG, " AP siblings=%d\n", cores_found);
699
zbaof7223732012-04-13 13:42:15 +0800700 for (apic_id = 0; apic_id <= cores_found; apic_id++) {
Kyösti Mälkkic33f1e92012-08-07 17:12:11 +0300701 cpu = add_cpu_device(cpu_bus, apic_id, 1);
702 if (cpu)
703 amd_cpu_topology(cpu, 0, apic_id);
Marc Jones8d595692012-03-15 12:55:26 -0600704 }
zbaof7223732012-04-13 13:42:15 +0800705}
706
707static void cpu_bus_init(device_t dev)
708{
709 initialize_cpus(dev->link_list);
Frank Vibrans39fca802011-02-14 18:35:15 +0000710}
711
Frank Vibrans39fca802011-02-14 18:35:15 +0000712/* North Bridge Structures */
713
Alexander Couzens5eea4582015-04-12 22:18:55 +0200714static void northbridge_fill_ssdt_generator(device_t device)
Vladimir Serbinenko4ab588b2014-10-08 21:18:31 +0200715{
716 msr_t msr;
717 char pscope[] = "\\_SB.PCI0";
718
719 acpigen_write_scope(pscope);
720 msr = rdmsr(TOP_MEM);
721 acpigen_write_name_dword("TOM1", msr.lo);
722 msr = rdmsr(TOP_MEM2);
723 /*
724 * Since XP only implements parts of ACPI 2.0, we can't use a qword
725 * here.
726 * See http://www.acpi.info/presentations/S01USMOBS169_OS%2520new.ppt
727 * slide 22ff.
728 * Shift value right by 20 bit to make it fit into 32bit,
729 * giving us 1MB granularity and a limit of almost 4Exabyte of memory.
730 */
731 acpigen_write_name_dword("TOM2", (msr.hi << 12) | msr.lo >> 20);
732 acpigen_pop_len();
733}
734
Vladimir Serbinenko807127f2014-11-09 13:36:18 +0100735static unsigned long acpi_fill_hest(acpi_hest_t *hest)
Vladimir Serbinenko4ab588b2014-10-08 21:18:31 +0200736{
737 void *addr, *current;
738
739 /* Skip the HEST header. */
740 current = (void *)(hest + 1);
741
742 addr = agesawrapper_getlateinitptr(PICK_WHEA_MCE);
743 if (addr != NULL)
744 current += acpi_create_hest_error_source(hest, current, 0, (void *)((u32)addr + 2), *(UINT16 *)addr - 2);
745
746 addr = agesawrapper_getlateinitptr(PICK_WHEA_CMC);
747 if (addr != NULL)
748 current += acpi_create_hest_error_source(hest, current, 1, (void *)((u32)addr + 2), *(UINT16 *)addr - 2);
749
750 return (unsigned long)current;
751}
752
Alexander Couzens83fc32f2015-04-12 22:28:37 +0200753static unsigned long agesa_write_acpi_tables(device_t device,
754 unsigned long current,
Vladimir Serbinenko4ab588b2014-10-08 21:18:31 +0200755 acpi_rsdp_t *rsdp)
756{
757 acpi_srat_t *srat;
758 acpi_slit_t *slit;
759 acpi_header_t *ssdt;
760 acpi_header_t *alib;
761 acpi_hest_t *hest;
762
763 /* HEST */
764 current = ALIGN(current, 8);
765 hest = (acpi_hest_t *)current;
Vladimir Serbinenko807127f2014-11-09 13:36:18 +0100766 acpi_write_hest((void *)current, acpi_fill_hest);
Vladimir Serbinenko4ab588b2014-10-08 21:18:31 +0200767 acpi_add_table(rsdp, (void *)current);
768 current += ((acpi_header_t *)current)->length;
769
770 /* SRAT */
771 current = ALIGN(current, 8);
772 printk(BIOS_DEBUG, "ACPI: * SRAT at %lx\n", current);
773 srat = (acpi_srat_t *) agesawrapper_getlateinitptr (PICK_SRAT);
774 if (srat != NULL) {
775 memcpy((void *)current, srat, srat->header.length);
776 srat = (acpi_srat_t *) current;
777 current += srat->header.length;
778 acpi_add_table(rsdp, srat);
779 }
780 else {
781 printk(BIOS_DEBUG, " AGESA SRAT table NULL. Skipping.\n");
782 }
783
784 /* SLIT */
785 current = ALIGN(current, 8);
786 printk(BIOS_DEBUG, "ACPI: * SLIT at %lx\n", current);
787 slit = (acpi_slit_t *) agesawrapper_getlateinitptr (PICK_SLIT);
788 if (slit != NULL) {
789 memcpy((void *)current, slit, slit->header.length);
790 slit = (acpi_slit_t *) current;
791 current += slit->header.length;
792 acpi_add_table(rsdp, slit);
793 }
794 else {
795 printk(BIOS_DEBUG, " AGESA SLIT table NULL. Skipping.\n");
796 }
797
798 /* SSDT */
799 current = ALIGN(current, 16);
800 printk(BIOS_DEBUG, "ACPI: * AGESA ALIB SSDT at %lx\n", current);
801 alib = (acpi_header_t *)agesawrapper_getlateinitptr (PICK_ALIB);
802 if (alib != NULL) {
803 memcpy((void *)current, alib, alib->length);
804 alib = (acpi_header_t *) current;
805 current += alib->length;
806 acpi_add_table(rsdp, (void *)alib);
807 } else {
808 printk(BIOS_DEBUG, " AGESA ALIB SSDT table NULL. Skipping.\n");
809 }
810
811 /* The DSDT needs additional work for the AGESA SSDT Pstate table */
812 /* Keep the comment for a while. */
813 current = ALIGN(current, 16);
814 printk(BIOS_DEBUG, "ACPI: * AGESA SSDT Pstate at %lx\n", current);
815 ssdt = (acpi_header_t *)agesawrapper_getlateinitptr (PICK_PSTATE);
816 if (ssdt != NULL) {
817 memcpy((void *)current, ssdt, ssdt->length);
818 ssdt = (acpi_header_t *) current;
819 current += ssdt->length;
820 acpi_add_table(rsdp,ssdt);
821 } else {
822 printk(BIOS_DEBUG, " AGESA SSDT Pstate table NULL. Skipping.\n");
823 }
824
825 return current;
826}
827
Frank Vibrans39fca802011-02-14 18:35:15 +0000828static struct device_operations northbridge_operations = {
Marc Jones8a49ac72013-01-16 17:02:20 -0700829 .read_resources = nb_read_resources,
830 .set_resources = nb_set_resources,
Marc Jones8d595692012-03-15 12:55:26 -0600831 .enable_resources = pci_dev_enable_resources,
Vladimir Serbinenko4ab588b2014-10-08 21:18:31 +0200832 .acpi_fill_ssdt_generator = northbridge_fill_ssdt_generator,
833 .write_acpi_tables = agesa_write_acpi_tables,
Marc Jones8d595692012-03-15 12:55:26 -0600834 .init = northbridge_init,
835 .enable = 0,.ops_pci = 0,
Frank Vibrans39fca802011-02-14 18:35:15 +0000836};
837
Frank Vibrans39fca802011-02-14 18:35:15 +0000838static const struct pci_driver northbridge_driver __pci_driver = {
Marc Jones8d595692012-03-15 12:55:26 -0600839 .ops = &northbridge_operations,
840 .vendor = PCI_VENDOR_ID_AMD,
841 .device = 0x1510,
Frank Vibrans39fca802011-02-14 18:35:15 +0000842};
843
efdesign9805a89ab2011-06-20 17:38:49 -0700844struct chip_operations northbridge_amd_agesa_family14_ops = {
Marc Jones8d595692012-03-15 12:55:26 -0600845 CHIP_NAME("AMD Family 14h Northbridge")
846 .enable_dev = 0,
Frank Vibrans39fca802011-02-14 18:35:15 +0000847};
848
Frank Vibrans39fca802011-02-14 18:35:15 +0000849/* Root Complex Structures */
850
Frank Vibrans39fca802011-02-14 18:35:15 +0000851static struct device_operations pci_domain_ops = {
Marc Jones8d595692012-03-15 12:55:26 -0600852 .read_resources = domain_read_resources,
853 .set_resources = domain_set_resources,
854 .enable_resources = domain_enable_resources,
Edward O'Callaghane9e1d7a2015-01-02 15:11:49 +1100855 .init = DEVICE_NOOP,
Marc Jones8d595692012-03-15 12:55:26 -0600856 .scan_bus = pci_domain_scan_bus,
Frank Vibrans39fca802011-02-14 18:35:15 +0000857};
858
Frank Vibrans39fca802011-02-14 18:35:15 +0000859static struct device_operations cpu_bus_ops = {
Edward O'Callaghan2837ab22014-11-06 08:57:40 +1100860 .read_resources = DEVICE_NOOP,
861 .set_resources = DEVICE_NOOP,
Edward O'Callaghane9e1d7a2015-01-02 15:11:49 +1100862 .enable_resources = DEVICE_NOOP,
Marc Jones8d595692012-03-15 12:55:26 -0600863 .init = cpu_bus_init,
zbaof7223732012-04-13 13:42:15 +0800864 .scan_bus = cpu_bus_scan,
Frank Vibrans39fca802011-02-14 18:35:15 +0000865};
866
Kyösti Mälkki87213b62012-08-27 20:00:33 +0300867static void root_complex_enable_dev(struct device *dev)
868{
869 static int done = 0;
870
871 /* Do not delay UMA setup, as a device on the PCI bus may evaluate
872 the global uma_memory variables already in its enable function. */
873 if (!done) {
874 setup_bsp_ramtop();
875 setup_uma_memory();
876 done = 1;
877 }
878
Marc Jones8d595692012-03-15 12:55:26 -0600879 /* Set the operations if it is a special bus type */
Stefan Reinauer4aff4452013-02-12 14:17:15 -0800880 if (dev->path.type == DEVICE_PATH_DOMAIN) {
Marc Jones8d595692012-03-15 12:55:26 -0600881 dev->ops = &pci_domain_ops;
Stefan Reinauer0aa37c42013-02-12 15:20:54 -0800882 } else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER) {
Marc Jones8d595692012-03-15 12:55:26 -0600883 dev->ops = &cpu_bus_ops;
884 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000885}
886
efdesign9805a89ab2011-06-20 17:38:49 -0700887struct chip_operations northbridge_amd_agesa_family14_root_complex_ops = {
Marc Jones8d595692012-03-15 12:55:26 -0600888 CHIP_NAME("AMD Family 14h Root Complex")
889 .enable_dev = root_complex_enable_dev,
Frank Vibrans39fca802011-02-14 18:35:15 +0000890};