blob: 144dde726f08cfdd9c6a1afb9a3206fac1887c11 [file] [log] [blame]
zbao2c08f6a2012-07-02 15:32:58 +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 <console/console.h>
21#include <arch/io.h>
22#include <stdint.h>
23#include <device/device.h>
24#include <device/pci.h>
25#include <device/pci_ids.h>
26#include <device/hypertransport.h>
27#include <stdlib.h>
28#include <string.h>
Ronald G. Minnich5079a0d2012-11-27 11:32:38 -080029#include <lib.h>
zbao2c08f6a2012-07-02 15:32:58 +080030#include <cpu/cpu.h>
31#include <cbmem.h>
Martin Roth73e86a82013-01-17 16:28:30 -070032#include <AGESA.h>
zbao2c08f6a2012-07-02 15:32:58 +080033
34#include <cpu/x86/lapic.h>
Kyösti Mälkkidbc47392012-08-05 12:11:40 +030035#include <cpu/amd/mtrr.h>
zbao2c08f6a2012-07-02 15:32:58 +080036
37#include <Porting.h>
zbao2c08f6a2012-07-02 15:32:58 +080038#include <Options.h>
39#include <Topology.h>
40#include <cpu/amd/amdfam15.h>
41#include <cpuRegisters.h>
42#include "agesawrapper.h"
zbao2c08f6a2012-07-02 15:32:58 +080043#include "northbridge.h"
zbao2c08f6a2012-07-02 15:32:58 +080044
45#define MAX_NODE_NUMS (MAX_NODES * MAX_DIES)
46
47#if (defined CONFIG_EXT_CONF_SUPPORT) && CONFIG_EXT_CONF_SUPPORT == 1
48#error CONFIG_EXT_CONF_SUPPORT == 1 not support anymore!
49#endif
50
51typedef struct dram_base_mask {
52 u32 base; //[47:27] at [28:8]
53 u32 mask; //[47:27] at [28:8] and enable at bit 0
54} dram_base_mask_t;
55
56static unsigned node_nums;
57static unsigned sblink;
58static device_t __f0_dev[MAX_NODE_NUMS];
59static device_t __f1_dev[MAX_NODE_NUMS];
60static device_t __f2_dev[MAX_NODE_NUMS];
61static device_t __f4_dev[MAX_NODE_NUMS];
62static unsigned fx_devs = 0;
63
64static dram_base_mask_t get_dram_base_mask(u32 nodeid)
65{
66 device_t dev;
67 dram_base_mask_t d;
68 dev = __f1_dev[0];
69 u32 temp;
70 temp = pci_read_config32(dev, 0x44 + (nodeid << 3)); //[39:24] at [31:16]
71 d.mask = ((temp & 0xfff80000)>>(8+3)); // mask out DramMask [26:24] too
72 temp = pci_read_config32(dev, 0x144 + (nodeid <<3)) & 0xff; //[47:40] at [7:0]
73 d.mask |= temp<<21;
74 temp = pci_read_config32(dev, 0x40 + (nodeid << 3)); //[39:24] at [31:16]
75 d.mask |= (temp & 1); // enable bit
76 d.base = ((temp & 0xfff80000)>>(8+3)); // mask out DramBase [26:24) too
77 temp = pci_read_config32(dev, 0x140 + (nodeid <<3)) & 0xff; //[47:40] at [7:0]
78 d.base |= temp<<21;
79 return d;
80}
81
82static void set_io_addr_reg(device_t dev, u32 nodeid, u32 linkn, u32 reg,
83 u32 io_min, u32 io_max)
84{
85 u32 i;
86 u32 tempreg;
87 /* io range allocation */
88 tempreg = (nodeid&0xf) | ((nodeid & 0x30)<<(8-4)) | (linkn<<4) | ((io_max&0xf0)<<(12-4)); //limit
89 for (i=0; i<node_nums; i++)
90 pci_write_config32(__f1_dev[i], reg+4, tempreg);
91 tempreg = 3 /*| ( 3<<4)*/ | ((io_min&0xf0)<<(12-4)); //base :ISA and VGA ?
92#if 0
93 // FIXME: can we use VGA reg instead?
94 if (dev->link[link].bridge_ctrl & PCI_BRIDGE_CTL_VGA) {
95 printk(BIOS_SPEW, "%s, enabling legacy VGA IO forwarding for %s link %s\n",
96 __func__, dev_path(dev), link);
97 tempreg |= PCI_IO_BASE_VGA_EN;
98 }
99 if (dev->link[link].bridge_ctrl & PCI_BRIDGE_CTL_NO_ISA) {
100 tempreg |= PCI_IO_BASE_NO_ISA;
101 }
102#endif
103 for (i=0; i<node_nums; i++)
104 pci_write_config32(__f1_dev[i], reg, tempreg);
105}
106
107static void set_mmio_addr_reg(u32 nodeid, u32 linkn, u32 reg, u32 index, u32 mmio_min, u32 mmio_max, u32 nodes)
108{
109 u32 i;
110 u32 tempreg;
111 /* io range allocation */
112 tempreg = (nodeid&0xf) | (linkn<<4) | (mmio_max&0xffffff00); //limit
113 for (i=0; i<nodes; i++)
114 pci_write_config32(__f1_dev[i], reg+4, tempreg);
115 tempreg = 3 | (nodeid & 0x30) | (mmio_min&0xffffff00);
116 for (i=0; i<node_nums; i++)
117 pci_write_config32(__f1_dev[i], reg, tempreg);
118}
119
120static device_t get_node_pci(u32 nodeid, u32 fn)
121{
zbaod4627362012-07-23 19:49:40 +0800122#if MAX_NODE_NUMS + CONFIG_CDB >= 32
123 if ((CONFIG_CDB + nodeid) < 32) {
zbao2c08f6a2012-07-02 15:32:58 +0800124 return dev_find_slot(CONFIG_CBB, PCI_DEVFN(CONFIG_CDB + nodeid, fn));
125 } else {
126 return dev_find_slot(CONFIG_CBB-1, PCI_DEVFN(CONFIG_CDB + nodeid - 32, fn));
127 }
128#else
129 return dev_find_slot(CONFIG_CBB, PCI_DEVFN(CONFIG_CDB + nodeid, fn));
130#endif
131}
132
133static void get_fx_devs(void)
134{
135 int i;
136 for (i = 0; i < MAX_NODE_NUMS; i++) {
137 __f0_dev[i] = get_node_pci(i, 0);
138 __f1_dev[i] = get_node_pci(i, 1);
139 __f2_dev[i] = get_node_pci(i, 2);
140 __f4_dev[i] = get_node_pci(i, 4);
141 if (__f0_dev[i] != NULL && __f1_dev[i] != NULL)
142 fx_devs = i+1;
143 }
144 if (__f1_dev[0] == NULL || __f0_dev[0] == NULL || fx_devs == 0) {
145 die("Cannot find 0:0x18.[0|1]\n");
146 }
147 printk(BIOS_DEBUG, "fx_devs=0x%x\n", fx_devs);
148}
149
150static u32 f1_read_config32(unsigned reg)
151{
152 if (fx_devs == 0)
153 get_fx_devs();
154 return pci_read_config32(__f1_dev[0], reg);
155}
156
157static void f1_write_config32(unsigned reg, u32 value)
158{
159 int i;
160 if (fx_devs == 0)
161 get_fx_devs();
162 for(i = 0; i < fx_devs; i++) {
163 device_t dev;
164 dev = __f1_dev[i];
165 if (dev && dev->enabled) {
166 pci_write_config32(dev, reg, value);
167 }
168 }
169}
170
171static u32 amdfam15_nodeid(device_t dev)
172{
173#if MAX_NODE_NUMS == 64
174 unsigned busn;
175 busn = dev->bus->secondary;
176 if (busn != CONFIG_CBB) {
177 return (dev->path.pci.devfn >> 3) - CONFIG_CDB + 32;
178 } else {
179 return (dev->path.pci.devfn >> 3) - CONFIG_CDB;
180 }
181
182#else
183 return (dev->path.pci.devfn >> 3) - CONFIG_CDB;
184#endif
185}
186
187static void set_vga_enable_reg(u32 nodeid, u32 linkn)
188{
189 u32 val;
190
191 val = 1 | (nodeid<<4) | (linkn<<12);
192 /* it will routing
193 * (1)mmio 0xa0000:0xbffff
194 * (2)io 0x3b0:0x3bb, 0x3c0:0x3df
195 */
196 f1_write_config32(0xf4, val);
197
198}
199
200/**
201 * @return
202 * @retval 2 resoure not exist, usable
203 * @retval 0 resource exist, not usable
204 * @retval 1 resource exist, resource has been allocated before
205 */
206static int reg_useable(unsigned reg, device_t goal_dev, unsigned goal_nodeid,
207 unsigned goal_link)
208{
209 struct resource *res;
210 unsigned nodeid, link = 0;
211 int result;
212 res = 0;
213 for (nodeid = 0; !res && (nodeid < fx_devs); nodeid++) {
214 device_t dev;
215 dev = __f0_dev[nodeid];
216 if (!dev)
217 continue;
218 for (link = 0; !res && (link < 8); link++) {
219 res = probe_resource(dev, IOINDEX(0x1000 + reg, link));
220 }
221 }
222 result = 2;
223 if (res) {
224 result = 0;
225 if ((goal_link == (link - 1)) &&
226 (goal_nodeid == (nodeid - 1)) &&
227 (res->flags <= 1)) {
228 result = 1;
229 }
230 }
231 return result;
232}
233
234static struct resource *amdfam15_find_iopair(device_t dev, unsigned nodeid, unsigned link)
235{
236 struct resource *resource;
237 u32 free_reg, reg;
238 resource = 0;
239 free_reg = 0;
240 for (reg = 0xc0; reg <= 0xd8; reg += 0x8) {
241 int result;
242 result = reg_useable(reg, dev, nodeid, link);
243 if (result == 1) {
244 /* I have been allocated this one */
245 break;
246 }
247 else if (result > 1) {
248 /* I have a free register pair */
249 free_reg = reg;
250 }
251 }
252 if (reg > 0xd8) {
253 reg = free_reg; // if no free, the free_reg still be 0
254 }
255
256 resource = new_resource(dev, IOINDEX(0x1000 + reg, link));
257
258 return resource;
259}
260
261static struct resource *amdfam15_find_mempair(device_t dev, u32 nodeid, u32 link)
262{
263 struct resource *resource;
264 u32 free_reg, reg;
265 resource = 0;
266 free_reg = 0;
267 for (reg = 0x80; reg <= 0xb8; reg += 0x8) {
268 int result;
269 result = reg_useable(reg, dev, nodeid, link);
270 if (result == 1) {
271 /* I have been allocated this one */
272 break;
273 }
274 else if (result > 1) {
275 /* I have a free register pair */
276 free_reg = reg;
277 }
278 }
279 if (reg > 0xb8) {
280 reg = free_reg;
281 }
282
283 resource = new_resource(dev, IOINDEX(0x1000 + reg, link));
284 return resource;
285}
286
287static void amdfam15_link_read_bases(device_t dev, u32 nodeid, u32 link)
288{
289 struct resource *resource;
290
291 /* Initialize the io space constraints on the current bus */
292 resource = amdfam15_find_iopair(dev, nodeid, link);
293 if (resource) {
294 u32 align;
295 align = log2(HT_IO_HOST_ALIGN);
296 resource->base = 0;
297 resource->size = 0;
298 resource->align = align;
299 resource->gran = align;
300 resource->limit = 0xffffUL;
301 resource->flags = IORESOURCE_IO | IORESOURCE_BRIDGE;
302 }
303
304 /* Initialize the prefetchable memory constraints on the current bus */
305 resource = amdfam15_find_mempair(dev, nodeid, link);
306 if (resource) {
307 resource->base = 0;
308 resource->size = 0;
309 resource->align = log2(HT_MEM_HOST_ALIGN);
310 resource->gran = log2(HT_MEM_HOST_ALIGN);
311 resource->limit = 0xffffffffffULL;
312 resource->flags = IORESOURCE_MEM | IORESOURCE_PREFETCH;
313 resource->flags |= IORESOURCE_BRIDGE;
314 }
315
316 /* Initialize the memory constraints on the current bus */
317 resource = amdfam15_find_mempair(dev, nodeid, link);
318 if (resource) {
319 resource->base = 0;
320 resource->size = 0;
321 resource->align = log2(HT_MEM_HOST_ALIGN);
322 resource->gran = log2(HT_MEM_HOST_ALIGN);
323 resource->limit = 0xffffffffffULL;
324 resource->flags = IORESOURCE_MEM | IORESOURCE_BRIDGE;
325 }
326
327}
328
Steven Sherkf4340582013-01-29 16:13:35 -0700329static void nb_read_resources(device_t dev)
zbao2c08f6a2012-07-02 15:32:58 +0800330{
331 u32 nodeid;
332 struct bus *link;
333
334 nodeid = amdfam15_nodeid(dev);
335 for (link = dev->link_list; link; link = link->next) {
336 if (link->children) {
337 amdfam15_link_read_bases(dev, nodeid, link->link_num);
338 }
339 }
Steven Sherk1cbabb02013-02-01 09:22:35 -0700340
341 /*
Stefan Reinauer4aff4452013-02-12 14:17:15 -0800342 * This MMCONF resource must be reserved in the PCI domain.
Steven Sherk1cbabb02013-02-01 09:22:35 -0700343 * It is not honored by the coreboot resource allocator if it is in
Stefan Reinauer0aa37c42013-02-12 15:20:54 -0800344 * the CPU_CLUSTER.
Steven Sherk1cbabb02013-02-01 09:22:35 -0700345 */
346#if CONFIG_MMCONF_SUPPORT
347 struct resource *resource = new_resource(dev, 0xc0010058);
348 resource->base = CONFIG_MMCONF_BASE_ADDRESS;
349 resource->size = CONFIG_MMCONF_BUS_NUMBER * 4096 * 256;
350 resource->flags = IORESOURCE_MEM | IORESOURCE_RESERVE |
351 IORESOURCE_FIXED | IORESOURCE_STORED | IORESOURCE_ASSIGNED;
352#endif
zbao2c08f6a2012-07-02 15:32:58 +0800353}
354
355static void set_resource(device_t dev, struct resource *resource, u32 nodeid)
356{
357 resource_t rbase, rend;
358 unsigned reg, link_num;
359 char buf[50];
360
361 /* Make certain the resource has actually been set */
362 if (!(resource->flags & IORESOURCE_ASSIGNED)) {
363 return;
364 }
365
366 /* If I have already stored this resource don't worry about it */
367 if (resource->flags & IORESOURCE_STORED) {
368 return;
369 }
370
371 /* Only handle PCI memory and IO resources */
372 if (!(resource->flags & (IORESOURCE_MEM | IORESOURCE_IO)))
373 return;
374
375 /* Ensure I am actually looking at a resource of function 1 */
376 if ((resource->index & 0xffff) < 0x1000) {
377 return;
378 }
379 /* Get the base address */
380 rbase = resource->base;
381
382 /* Get the limit (rounded up) */
383 rend = resource_end(resource);
384
385 /* Get the register and link */
386 reg = resource->index & 0xfff; // 4k
387 link_num = IOINDEX_LINK(resource->index);
388
389 if (resource->flags & IORESOURCE_IO) {
390 set_io_addr_reg(dev, nodeid, link_num, reg, rbase>>8, rend>>8);
391 }
392 else if (resource->flags & IORESOURCE_MEM) {
393 set_mmio_addr_reg(nodeid, link_num, reg, (resource->index >>24), rbase>>8, rend>>8, node_nums) ;// [39:8]
394 }
395 resource->flags |= IORESOURCE_STORED;
396 sprintf(buf, " <node %x link %x>",
397 nodeid, link_num);
398 report_resource_stored(dev, resource, buf);
399}
400
401/**
402 * I tried to reuse the resource allocation code in set_resource()
403 * but it is too difficult to deal with the resource allocation magic.
404 */
405
406static void create_vga_resource(device_t dev, unsigned nodeid)
407{
408 struct bus *link;
409
410 /* find out which link the VGA card is connected,
411 * we only deal with the 'first' vga card */
412 for (link = dev->link_list; link; link = link->next) {
413 if (link->bridge_ctrl & PCI_BRIDGE_CTL_VGA) {
zbaod59d6242012-07-23 19:41:03 +0800414#if CONFIG_MULTIPLE_VGA_ADAPTERS
zbao2c08f6a2012-07-02 15:32:58 +0800415 extern device_t vga_pri; // the primary vga device, defined in device.c
416 printk(BIOS_DEBUG, "VGA: vga_pri bus num = %d bus range [%d,%d]\n", vga_pri->bus->secondary,
417 link->secondary,link->subordinate);
418 /* We need to make sure the vga_pri is under the link */
419 if((vga_pri->bus->secondary >= link->secondary ) &&
420 (vga_pri->bus->secondary <= link->subordinate )
421 )
422#endif
423 break;
424 }
425 }
426
427 /* no VGA card installed */
428 if (link == NULL)
429 return;
430
431 printk(BIOS_DEBUG, "VGA: %s (aka node %d) link %d has VGA device\n", dev_path(dev), nodeid, sblink);
432 set_vga_enable_reg(nodeid, sblink);
433}
434
Steven Sherkf4340582013-01-29 16:13:35 -0700435static void nb_set_resources(device_t dev)
zbao2c08f6a2012-07-02 15:32:58 +0800436{
437 unsigned nodeid;
438 struct bus *bus;
439 struct resource *res;
440
441 /* Find the nodeid */
442 nodeid = amdfam15_nodeid(dev);
443
444 create_vga_resource(dev, nodeid); //TODO: do we need this?
445
446 /* Set each resource we have found */
447 for (res = dev->resource_list; res; res = res->next) {
448 set_resource(dev, res, nodeid);
449 }
450
451 for (bus = dev->link_list; bus; bus = bus->next) {
452 if (bus->children) {
453 assign_resources(bus);
454 }
455 }
Steven Sherk1cbabb02013-02-01 09:22:35 -0700456
457 /* Print the MMCONF region if it has been reserved. */
458 res = find_resource(dev, 0xc0010058);
459 if (res) {
460 report_resource_stored(dev, res, " <mmconfig>");
461 }
zbao2c08f6a2012-07-02 15:32:58 +0800462}
463
464static void northbridge_init(struct device *dev)
465{
466}
467
zbaod59d6242012-07-23 19:41:03 +0800468
zbao2c08f6a2012-07-02 15:32:58 +0800469static struct device_operations northbridge_operations = {
Steven Sherkf4340582013-01-29 16:13:35 -0700470 .read_resources = nb_read_resources,
471 .set_resources = nb_set_resources,
zbao2c08f6a2012-07-02 15:32:58 +0800472 .enable_resources = pci_dev_enable_resources,
473 .init = northbridge_init,
zbao2c08f6a2012-07-02 15:32:58 +0800474 .enable = 0,
475 .ops_pci = 0,
476};
477
478static const struct pci_driver family15_northbridge __pci_driver = {
479 .ops = &northbridge_operations,
480 .vendor = PCI_VENDOR_ID_AMD,
481 .device = PCI_DEVICE_ID_AMD_15H_MODEL_001F_NB_HT,
482};
483
484static const struct pci_driver family10_northbridge __pci_driver = {
485 .ops = &northbridge_operations,
486 .vendor = PCI_VENDOR_ID_AMD,
487 .device = PCI_DEVICE_ID_AMD_10H_NB_HT,
488};
489
490struct chip_operations northbridge_amd_agesa_family15tn_ops = {
491 CHIP_NAME("AMD FAM15 Northbridge")
492 .enable_dev = 0,
493};
494
495static void domain_read_resources(device_t dev)
496{
497 unsigned reg;
498
499 /* Find the already assigned resource pairs */
500 get_fx_devs();
501 for (reg = 0x80; reg <= 0xd8; reg+= 0x08) {
502 u32 base, limit;
503 base = f1_read_config32(reg);
504 limit = f1_read_config32(reg + 0x04);
505 /* Is this register allocated? */
506 if ((base & 3) != 0) {
507 unsigned nodeid, reg_link;
508 device_t reg_dev;
509 if (reg<0xc0) { // mmio
510 nodeid = (limit & 0xf) + (base&0x30);
511 } else { // io
512 nodeid = (limit & 0xf) + ((base>>4)&0x30);
513 }
514 reg_link = (limit >> 4) & 7;
515 reg_dev = __f0_dev[nodeid];
516 if (reg_dev) {
517 /* Reserve the resource */
518 struct resource *res;
519 res = new_resource(reg_dev, IOINDEX(0x1000 + reg, reg_link));
520 if (res) {
521 res->flags = 1;
522 }
523 }
524 }
525 }
526 /* FIXME: do we need to check extend conf space?
527 I don't believe that much preset value */
528
zbaod59d6242012-07-23 19:41:03 +0800529#if !CONFIG_PCI_64BIT_PREF_MEM
zbao2c08f6a2012-07-02 15:32:58 +0800530 pci_domain_read_resources(dev);
531
532#else
533 struct bus *link;
534 struct resource *resource;
535 for (link=dev->link_list; link; link = link->next) {
536 /* Initialize the system wide io space constraints */
537 resource = new_resource(dev, 0|(link->link_num<<2));
538 resource->base = 0x400;
539 resource->limit = 0xffffUL;
540 resource->flags = IORESOURCE_IO;
541
542 /* Initialize the system wide prefetchable memory resources constraints */
543 resource = new_resource(dev, 1|(link->link_num<<2));
544 resource->limit = 0xfcffffffffULL;
545 resource->flags = IORESOURCE_MEM | IORESOURCE_PREFETCH;
546
547 /* Initialize the system wide memory resources constraints */
548 resource = new_resource(dev, 2|(link->link_num<<2));
549 resource->limit = 0xfcffffffffULL;
550 resource->flags = IORESOURCE_MEM;
551 }
552#endif
553}
554
555extern u8 acpi_slp_type;
556
557static void domain_enable_resources(device_t dev)
558{
559 u32 val;
560#if CONFIG_HAVE_ACPI_RESUME
561 if (acpi_slp_type == 3)
562 agesawrapper_fchs3laterestore();
563#endif
564
565 /* Must be called after PCI enumeration and resource allocation */
Mike Loptiene133aab2013-01-30 16:00:43 -0700566 printk(BIOS_DEBUG, "\nFam15 - %s: AmdInitMid.\n", __func__);
zbao2c08f6a2012-07-02 15:32:58 +0800567#if CONFIG_HAVE_ACPI_RESUME
568 if (acpi_slp_type != 3) {
569 printk(BIOS_DEBUG, "agesawrapper_amdinitmid ");
570 val = agesawrapper_amdinitmid ();
571 if (val)
572 printk(BIOS_DEBUG, "error level: %x \n", val);
573 else
574 printk(BIOS_DEBUG, "passed.\n");
575 }
576#else
577 printk(BIOS_DEBUG, "agesawrapper_amdinitmid ");
578 val = agesawrapper_amdinitmid ();
579 if (val)
580 printk(BIOS_DEBUG, "error level: %x \n", val);
581 else
582 printk(BIOS_DEBUG, "passed.\n");
583#endif
584
Mike Loptiene133aab2013-01-30 16:00:43 -0700585 printk(BIOS_DEBUG, " ader - leaving %s.\n", __func__);
zbao2c08f6a2012-07-02 15:32:58 +0800586}
587
588#if CONFIG_HW_MEM_HOLE_SIZEK != 0
589struct hw_mem_hole_info {
590 unsigned hole_startk;
591 int node_id;
592};
593static struct hw_mem_hole_info get_hw_mem_hole_info(void)
594{
595 struct hw_mem_hole_info mem_hole;
596 int i;
597 mem_hole.hole_startk = CONFIG_HW_MEM_HOLE_SIZEK;
598 mem_hole.node_id = -1;
599 for (i = 0; i < node_nums; i++) {
600 dram_base_mask_t d;
601 u32 hole;
602 d = get_dram_base_mask(i);
603 if (!(d.mask & 1)) continue; // no memory on this node
604 hole = pci_read_config32(__f1_dev[i], 0xf0);
605 if (hole & 1) { // we find the hole
606 mem_hole.hole_startk = (hole & (0xff<<24)) >> 10;
607 mem_hole.node_id = i; // record the node No with hole
608 break; // only one hole
609 }
610 }
611 //We need to double check if there is speical set on base reg and limit reg are not continous instead of hole, it will find out it's hole_startk
612 if (mem_hole.node_id == -1) {
613 resource_t limitk_pri = 0;
614 for (i=0; i<node_nums; i++) {
615 dram_base_mask_t d;
616 resource_t base_k, limit_k;
617 d = get_dram_base_mask(i);
618 if (!(d.base & 1)) continue;
619 base_k = ((resource_t)(d.base & 0x1fffff00)) <<9;
620 if (base_k > 4 *1024 * 1024) break; // don't need to go to check
621 if (limitk_pri != base_k) { // we find the hole
622 mem_hole.hole_startk = (unsigned)limitk_pri; // must beblow 4G
623 mem_hole.node_id = i;
624 break; //only one hole
625 }
zbao15dc3cc2012-08-03 15:56:21 +0800626 limit_k = ((resource_t)(((d.mask & ~1) + 0x000FF) & 0x1fffff00)) << 9;
zbao2c08f6a2012-07-02 15:32:58 +0800627 limitk_pri = limit_k;
628 }
629 }
630 return mem_hole;
631}
632#endif
633
zbao405cfe22012-07-23 19:44:29 +0800634#define ONE_MB_SHIFT 20
zbao6db7f342012-07-19 16:38:12 +0800635
Kyösti Mälkki6b5eb1c2012-07-19 19:26:43 +0300636static void setup_uma_memory(void)
zbao6db7f342012-07-19 16:38:12 +0800637{
638#if CONFIG_GFXUMA
Kyösti Mälkkidbc47392012-08-05 12:11:40 +0300639 uint32_t topmem = (uint32_t) bsp_topmem();
zbao6db7f342012-07-19 16:38:12 +0800640 uint32_t sys_mem;
641
zbao6db7f342012-07-19 16:38:12 +0800642 /* refer to UMA Size Consideration in Family15h BKDG. */
643 /* Please reference MemNGetUmaSizeOR () */
644 /*
645 * Total system memory UMASize
646 * >= 2G 512M
647 * >=1G 256M
648 * <1G 64M
649 */
Kyösti Mälkkidbc47392012-08-05 12:11:40 +0300650 sys_mem = topmem + (16 << ONE_MB_SHIFT); // Ignore 16MB allocated for C6 when finding UMA size
651 if ((bsp_topmem2()>>32) || (sys_mem >= 2048 << ONE_MB_SHIFT)) {
zbao405cfe22012-07-23 19:44:29 +0800652 uma_memory_size = 512 << ONE_MB_SHIFT;
653 } else if (sys_mem >= 1024 << ONE_MB_SHIFT) {
654 uma_memory_size = 256 << ONE_MB_SHIFT;
zbao6db7f342012-07-19 16:38:12 +0800655 } else {
zbao405cfe22012-07-23 19:44:29 +0800656 uma_memory_size = 64 << ONE_MB_SHIFT;
zbao6db7f342012-07-19 16:38:12 +0800657 }
Kyösti Mälkkidbc47392012-08-05 12:11:40 +0300658 uma_memory_base = topmem - uma_memory_size; /* TOP_MEM1 */
zbao6db7f342012-07-19 16:38:12 +0800659
660 printk(BIOS_INFO, "%s: uma size 0x%08llx, memory start 0x%08llx\n",
661 __func__, uma_memory_size, uma_memory_base);
zbao6db7f342012-07-19 16:38:12 +0800662#endif
663}
664
665
zbao2c08f6a2012-07-02 15:32:58 +0800666static void domain_set_resources(device_t dev)
667{
zbaod59d6242012-07-23 19:41:03 +0800668#if CONFIG_PCI_64BIT_PREF_MEM
zbao2c08f6a2012-07-02 15:32:58 +0800669 struct resource *io, *mem1, *mem2;
670 struct resource *res;
671#endif
672 unsigned long mmio_basek;
673 u32 pci_tolm;
674 int i, idx;
675 struct bus *link;
676#if CONFIG_HW_MEM_HOLE_SIZEK != 0
677 struct hw_mem_hole_info mem_hole;
678 u32 reset_memhole = 1;
679#endif
680
zbaod59d6242012-07-23 19:41:03 +0800681#if CONFIG_PCI_64BIT_PREF_MEM
zbao2c08f6a2012-07-02 15:32:58 +0800682
683 for (link = dev->link_list; link; link = link->next) {
684 /* Now reallocate the pci resources memory with the
685 * highest addresses I can manage.
686 */
687 mem1 = find_resource(dev, 1|(link->link_num<<2));
688 mem2 = find_resource(dev, 2|(link->link_num<<2));
689
690 printk(BIOS_DEBUG, "base1: 0x%08Lx limit1: 0x%08Lx size: 0x%08Lx align: %d\n",
691 mem1->base, mem1->limit, mem1->size, mem1->align);
692 printk(BIOS_DEBUG, "base2: 0x%08Lx limit2: 0x%08Lx size: 0x%08Lx align: %d\n",
693 mem2->base, mem2->limit, mem2->size, mem2->align);
694
695 /* See if both resources have roughly the same limits */
696 if (((mem1->limit <= 0xffffffff) && (mem2->limit <= 0xffffffff)) ||
697 ((mem1->limit > 0xffffffff) && (mem2->limit > 0xffffffff)))
698 {
699 /* If so place the one with the most stringent alignment first */
700 if (mem2->align > mem1->align) {
701 struct resource *tmp;
702 tmp = mem1;
703 mem1 = mem2;
704 mem2 = tmp;
705 }
706 /* Now place the memory as high up as it will go */
707 mem2->base = resource_max(mem2);
708 mem1->limit = mem2->base - 1;
709 mem1->base = resource_max(mem1);
710 }
711 else {
712 /* Place the resources as high up as they will go */
713 mem2->base = resource_max(mem2);
714 mem1->base = resource_max(mem1);
715 }
716
717 printk(BIOS_DEBUG, "base1: 0x%08Lx limit1: 0x%08Lx size: 0x%08Lx align: %d\n",
718 mem1->base, mem1->limit, mem1->size, mem1->align);
719 printk(BIOS_DEBUG, "base2: 0x%08Lx limit2: 0x%08Lx size: 0x%08Lx align: %d\n",
720 mem2->base, mem2->limit, mem2->size, mem2->align);
721 }
722
723 for (res = &dev->resource_list; res; res = res->next)
724 {
725 res->flags |= IORESOURCE_ASSIGNED;
726 res->flags |= IORESOURCE_STORED;
727 report_resource_stored(dev, res, "");
728 }
729#endif
730
731 pci_tolm = 0xffffffffUL;
732 for (link = dev->link_list; link; link = link->next) {
733 pci_tolm = find_pci_tolm(link);
734 }
735
736 // FIXME handle interleaved nodes. If you fix this here, please fix
737 // amdk8, too.
738 mmio_basek = pci_tolm >> 10;
739 /* Round mmio_basek to something the processor can support */
740 mmio_basek &= ~((1 << 6) -1);
741
742 // FIXME improve mtrr.c so we don't use up all of the mtrrs with a 64M
743 // MMIO hole. If you fix this here, please fix amdk8, too.
744 /* Round the mmio hole to 64M */
745 mmio_basek &= ~((64*1024) - 1);
746
747#if CONFIG_HW_MEM_HOLE_SIZEK != 0
748 /* if the hw mem hole is already set in raminit stage, here we will compare
749 * mmio_basek and hole_basek. if mmio_basek is bigger that hole_basek and will
750 * use hole_basek as mmio_basek and we don't need to reset hole.
751 * otherwise We reset the hole to the mmio_basek
752 */
753
754 mem_hole = get_hw_mem_hole_info();
755
756 // Use hole_basek as mmio_basek, and we don't need to reset hole anymore
757 if ((mem_hole.node_id != -1) && (mmio_basek > mem_hole.hole_startk)) {
758 mmio_basek = mem_hole.hole_startk;
759 reset_memhole = 0;
760 }
761#endif
762
763 idx = 0x10;
764 for (i = 0; i < node_nums; i++) {
765 dram_base_mask_t d;
766 resource_t basek, limitk, sizek; // 4 1T
767
768 d = get_dram_base_mask(i);
769
770 if (!(d.mask & 1)) continue;
771 basek = ((resource_t)(d.base & 0x1fffff00)) << 9; // could overflow, we may lost 6 bit here
zbao9fd183e2012-08-01 18:23:49 +0800772 limitk = ((resource_t)(((d.mask & ~1) + 0x000FF) & 0x1fffff00)) << 9 ;
zbao2c08f6a2012-07-02 15:32:58 +0800773
774 sizek = limitk - basek;
775
776 /* see if we need a hole from 0xa0000 to 0xbffff */
777 if ((basek < ((8*64)+(8*16))) && (sizek > ((8*64)+(16*16)))) {
778 ram_resource(dev, (idx | i), basek, ((8*64)+(8*16)) - basek);
779 idx += 0x10;
780 basek = (8*64)+(16*16);
781 sizek = limitk - ((8*64)+(16*16));
782
783 }
784
785 //printk(BIOS_DEBUG, "node %d : mmio_basek=%08lx, basek=%08llx, limitk=%08llx\n", i, mmio_basek, basek, limitk);
786
787 /* split the region to accomodate pci memory space */
788 if ((basek < 4*1024*1024 ) && (limitk > mmio_basek)) {
789 if (basek <= mmio_basek) {
790 unsigned pre_sizek;
791 pre_sizek = mmio_basek - basek;
792 if (pre_sizek>0) {
793 ram_resource(dev, (idx | i), basek, pre_sizek);
794 idx += 0x10;
795 sizek -= pre_sizek;
zbaod59d6242012-07-23 19:41:03 +0800796#if CONFIG_WRITE_HIGH_TABLES
zbao2c08f6a2012-07-02 15:32:58 +0800797 if (high_tables_base==0) {
798 /* Leave some space for ACPI, PIRQ and MP tables */
zbaod59d6242012-07-23 19:41:03 +0800799#if CONFIG_GFXUMA
zbao2c08f6a2012-07-02 15:32:58 +0800800 high_tables_base = uma_memory_base - HIGH_MEMORY_SIZE;
801#else
802 high_tables_base = (mmio_basek * 1024) - HIGH_MEMORY_SIZE;
803#endif
804 high_tables_size = HIGH_MEMORY_SIZE;
805 printk(BIOS_DEBUG, " split: %dK table at =%08llx\n",
806 (u32)(high_tables_size / 1024), high_tables_base);
807 }
808#endif
809 }
810 basek = mmio_basek;
811 }
812 if ((basek + sizek) <= 4*1024*1024) {
813 sizek = 0;
814 }
815 else {
816 basek = 4*1024*1024;
817 sizek -= (4*1024*1024 - mmio_basek);
818 }
819 }
820
zbao2c08f6a2012-07-02 15:32:58 +0800821 ram_resource(dev, (idx | i), basek, sizek);
822 idx += 0x10;
zbaod59d6242012-07-23 19:41:03 +0800823#if CONFIG_WRITE_HIGH_TABLES
zbao2c08f6a2012-07-02 15:32:58 +0800824 printk(BIOS_DEBUG, "node %d: mmio_basek=%08lx, basek=%08llx, limitk=%08llx\n",
825 i, mmio_basek, basek, limitk);
826 if (high_tables_base==0) {
827 /* Leave some space for ACPI, PIRQ and MP tables */
zbaod59d6242012-07-23 19:41:03 +0800828#if CONFIG_GFXUMA
zbao2c08f6a2012-07-02 15:32:58 +0800829 high_tables_base = uma_memory_base - HIGH_MEMORY_SIZE;
830#else
831 high_tables_base = (limitk * 1024) - HIGH_MEMORY_SIZE;
832#endif
833 high_tables_size = HIGH_MEMORY_SIZE;
834 }
835#endif
836 }
837
Kyösti Mälkki63f8c082012-07-10 13:27:26 +0300838#if CONFIG_GFXUMA
839 uma_resource(dev, 7, uma_memory_base >> 10, uma_memory_size >> 10);
zbao2c08f6a2012-07-02 15:32:58 +0800840#endif
841
842 for(link = dev->link_list; link; link = link->next) {
843 if (link->children) {
844 assign_resources(link);
845 }
846 }
847}
848
849static struct device_operations pci_domain_ops = {
850 .read_resources = domain_read_resources,
851 .set_resources = domain_set_resources,
852 .enable_resources = domain_enable_resources,
853 .init = NULL,
854 .scan_bus = pci_domain_scan_bus,
855
856#if CONFIG_MMCONF_SUPPORT_DEFAULT
857 .ops_pci_bus = &pci_ops_mmconf,
858#else
859 .ops_pci_bus = &pci_cf8_conf1,
860#endif
861};
862
863static void sysconf_init(device_t dev) // first node
864{
865 sblink = (pci_read_config32(dev, 0x64)>>8) & 7; // don't forget sublink1
866 node_nums = ((pci_read_config32(dev, 0x60)>>4) & 7) + 1; //NodeCnt[2:0]
867}
868
869static void add_more_links(device_t dev, unsigned total_links)
870{
871 struct bus *link, *last = NULL;
872 int link_num;
873
874 for (link = dev->link_list; link; link = link->next)
875 last = link;
876
877 if (last) {
878 int links = total_links - last->link_num;
879 link_num = last->link_num;
880 if (links > 0) {
881 link = malloc(links*sizeof(*link));
882 if (!link)
883 die("Couldn't allocate more links!\n");
884 memset(link, 0, links*sizeof(*link));
885 last->next = link;
886 }
887 }
888 else {
889 link_num = -1;
890 link = malloc(total_links*sizeof(*link));
891 memset(link, 0, total_links*sizeof(*link));
892 dev->link_list = link;
893 }
894
895 for (link_num = link_num + 1; link_num < total_links; link_num++) {
896 link->link_num = link_num;
897 link->dev = dev;
898 link->next = link + 1;
899 last = link;
900 link = link->next;
901 }
902 last->next = NULL;
903}
904
zbao2c08f6a2012-07-02 15:32:58 +0800905static u32 cpu_bus_scan(device_t dev, u32 max)
906{
907 struct bus *cpu_bus;
908 device_t dev_mc;
909#if CONFIG_CBB
910 device_t pci_domain;
911#endif
912 int i,j;
913 int coreid_bits;
914 int core_max = 0;
915 unsigned ApicIdCoreIdSize;
916 unsigned core_nums;
917 int siblings = 0;
918 unsigned int family;
919
920#if CONFIG_CBB
921 dev_mc = dev_find_slot(0, PCI_DEVFN(CONFIG_CDB, 0)); //0x00
922 if (dev_mc && dev_mc->bus) {
923 printk(BIOS_DEBUG, "%s found", dev_path(dev_mc));
924 pci_domain = dev_mc->bus->dev;
Stefan Reinauer4aff4452013-02-12 14:17:15 -0800925 if (pci_domain && (pci_domain->path.type == DEVICE_PATH_DOMAIN)) {
zbao2c08f6a2012-07-02 15:32:58 +0800926 printk(BIOS_DEBUG, "\n%s move to ",dev_path(dev_mc));
927 dev_mc->bus->secondary = CONFIG_CBB; // move to 0xff
928 printk(BIOS_DEBUG, "%s",dev_path(dev_mc));
929 } else {
930 printk(BIOS_DEBUG, " but it is not under pci_domain directly ");
931 }
932 printk(BIOS_DEBUG, "\n");
933 }
934 dev_mc = dev_find_slot(CONFIG_CBB, PCI_DEVFN(CONFIG_CDB, 0));
935 if (!dev_mc) {
936 dev_mc = dev_find_slot(0, PCI_DEVFN(0x18, 0));
937 if (dev_mc && dev_mc->bus) {
938 printk(BIOS_DEBUG, "%s found\n", dev_path(dev_mc));
939 pci_domain = dev_mc->bus->dev;
Stefan Reinauer4aff4452013-02-12 14:17:15 -0800940 if (pci_domain && (pci_domain->path.type == DEVICE_PATH_DOMAIN)) {
zbao2c08f6a2012-07-02 15:32:58 +0800941 if ((pci_domain->link_list) && (pci_domain->link_list->children == dev_mc)) {
942 printk(BIOS_DEBUG, "%s move to ",dev_path(dev_mc));
943 dev_mc->bus->secondary = CONFIG_CBB; // move to 0xff
944 printk(BIOS_DEBUG, "%s\n",dev_path(dev_mc));
945 while (dev_mc) {
946 printk(BIOS_DEBUG, "%s move to ",dev_path(dev_mc));
947 dev_mc->path.pci.devfn -= PCI_DEVFN(0x18,0);
948 printk(BIOS_DEBUG, "%s\n",dev_path(dev_mc));
949 dev_mc = dev_mc->sibling;
950 }
951 }
952 }
953 }
954 }
955#endif
956 dev_mc = dev_find_slot(CONFIG_CBB, PCI_DEVFN(CONFIG_CDB, 0));
957 if (!dev_mc) {
958 printk(BIOS_ERR, "%02x:%02x.0 not found", CONFIG_CBB, CONFIG_CDB);
959 die("");
960 }
961 sysconf_init(dev_mc);
962#if CONFIG_CBB && (MAX_NODE_NUMS > 32)
963 if (node_nums>32) { // need to put node 32 to node 63 to bus 0xfe
964 if (pci_domain->link_list && !pci_domain->link_list->next) {
965 struct bus *new_link = new_link(pci_domain);
966 pci_domain->link_list->next = new_link;
967 new_link->link_num = 1;
968 new_link->dev = pci_domain;
969 new_link->children = 0;
970 printk(BIOS_DEBUG, "%s links now 2\n", dev_path(pci_domain));
971 }
972 pci_domain->link_list->next->secondary = CONFIG_CBB - 1;
973 }
974#endif
975
976 /* Get Max Number of cores(MNC) */
977 coreid_bits = (cpuid_ecx(AMD_CPUID_ASIZE_PCCOUNT) & 0x0000F000) >> 12;
978 core_max = 1 << (coreid_bits & 0x000F); //mnc
979
980 ApicIdCoreIdSize = ((cpuid_ecx(0x80000008)>>12) & 0xF);
981 if (ApicIdCoreIdSize) {
982 core_nums = (1 << ApicIdCoreIdSize) - 1;
983 } else {
984 core_nums = 3; //quad core
985 }
986
987 /* Find which cpus are present */
988 cpu_bus = dev->link_list;
989 for (i = 0; i < node_nums; i++) {
Kyösti Mälkkicd9fc1a2012-07-06 19:02:56 +0300990 device_t cdb_dev;
zbao2c08f6a2012-07-02 15:32:58 +0800991 unsigned busn, devn;
992 struct bus *pbus;
993
994 busn = CONFIG_CBB;
995 devn = CONFIG_CDB + i;
996 pbus = dev_mc->bus;
997#if CONFIG_CBB && (MAX_NODE_NUMS > 32)
998 if (i >= 32) {
999 busn--;
1000 devn -= 32;
1001 pbus = pci_domain->link_list->next;
1002 }
1003#endif
1004
1005 /* Find the cpu's pci device */
1006 cdb_dev = dev_find_slot(busn, PCI_DEVFN(devn, 0));
1007 if (!cdb_dev) {
1008 /* If I am probing things in a weird order
1009 * ensure all of the cpu's pci devices are found.
1010 */
1011 int fn;
1012 for(fn = 0; fn <= 5; fn++) { //FBDIMM?
1013 cdb_dev = pci_probe_dev(NULL, pbus,
1014 PCI_DEVFN(devn, fn));
1015 }
1016 cdb_dev = dev_find_slot(busn, PCI_DEVFN(devn, 0));
1017 } else {
1018 /* Ok, We need to set the links for that device.
1019 * otherwise the device under it will not be scanned
1020 */
1021 int linknum;
zbaod59d6242012-07-23 19:41:03 +08001022#if CONFIG_HT3_SUPPORT
zbao2c08f6a2012-07-02 15:32:58 +08001023 linknum = 8;
1024#else
1025 linknum = 4;
1026#endif
1027 add_more_links(cdb_dev, linknum);
1028 }
1029
1030 family = cpuid_eax(1);
1031 family = (family >> 20) & 0xFF;
1032 if (family == 1) { //f10
1033 u32 dword;
1034 cdb_dev = dev_find_slot(busn, PCI_DEVFN(devn, 3));
1035 dword = pci_read_config32(cdb_dev, 0xe8);
1036 siblings = ((dword & BIT15) >> 13) | ((dword & (BIT13 | BIT12)) >> 12);
1037 } else if (family == 6) {//f15
1038 cdb_dev = dev_find_slot(busn, PCI_DEVFN(devn, 5));
1039 if (cdb_dev && cdb_dev->enabled) {
1040 siblings = pci_read_config32(cdb_dev, 0x84);
1041 siblings &= 0xFF;
1042 }
1043 } else {
1044 siblings = 0; //default one core
1045 }
Kyösti Mälkkicd9fc1a2012-07-06 19:02:56 +03001046 int enable_node = cdb_dev && cdb_dev->enabled;
zbao2c08f6a2012-07-02 15:32:58 +08001047 printk(BIOS_SPEW, "%s family%xh, core_max=0x%x, core_nums=0x%x, siblings=0x%x\n",
1048 dev_path(cdb_dev), 0x0f + family, core_max, core_nums, siblings);
1049
1050 for (j = 0; j <= siblings; j++ ) {
1051 extern CONST OPTIONS_CONFIG_TOPOLOGY ROMDATA TopologyConfiguration;
1052 u32 modules = TopologyConfiguration.PlatformNumberOfModules;
1053 u32 lapicid_start = 0;
1054
zbao2c08f6a2012-07-02 15:32:58 +08001055 /*
1056 * APIC ID calucation is tightly coupled with AGESA v5 code.
1057 * This calculation MUST match the assignment calculation done
1058 * in LocalApicInitializationAtEarly() function.
1059 * And reference GetLocalApicIdForCore()
1060 *
1061 * Apply apic enumeration rules
1062 * For systems with >= 16 APICs, put the IO-APICs at 0..n and
1063 * put the local-APICs at m..z
1064 *
1065 * This is needed because many IO-APIC devices only have 4 bits
1066 * for their APIC id and therefore must reside at 0..15
1067 */
1068#ifndef CFG_PLAT_NUM_IO_APICS /* defined in mainboard buildOpts.c */
1069#define CFG_PLAT_NUM_IO_APICS 3
1070#endif
1071 if ((node_nums * core_max) + CFG_PLAT_NUM_IO_APICS >= 0x10) {
1072 lapicid_start = (CFG_PLAT_NUM_IO_APICS - 1) / core_max;
1073 lapicid_start = (lapicid_start + 1) * core_max;
1074 printk(BIOS_SPEW, "lpaicid_start=0x%x ", lapicid_start);
1075 }
Kyösti Mälkkic33f1e92012-08-07 17:12:11 +03001076 u32 apic_id = (lapicid_start * (i/modules + 1)) + ((i % modules) ? (j + (siblings + 1)) : j);
zbao2c08f6a2012-07-02 15:32:58 +08001077 printk(BIOS_SPEW, "node 0x%x core 0x%x apicid=0x%x\n",
Kyösti Mälkkic33f1e92012-08-07 17:12:11 +03001078 i, j, apic_id);
zbao2c08f6a2012-07-02 15:32:58 +08001079
Kyösti Mälkkic33f1e92012-08-07 17:12:11 +03001080 device_t cpu = add_cpu_device(cpu_bus, apic_id, enable_node);
1081 if (cpu)
1082 amd_cpu_topology(cpu, i, j);
zbao2c08f6a2012-07-02 15:32:58 +08001083 } //j
1084 }
1085 return max;
1086}
1087
1088static void cpu_bus_init(device_t dev)
1089{
1090 initialize_cpus(dev->link_list);
1091}
1092
1093static void cpu_bus_noop(device_t dev)
1094{
1095}
1096
1097static void cpu_bus_read_resources(device_t dev)
1098{
zbao2c08f6a2012-07-02 15:32:58 +08001099}
1100
1101static void cpu_bus_set_resources(device_t dev)
1102{
zbao2c08f6a2012-07-02 15:32:58 +08001103}
1104
1105static struct device_operations cpu_bus_ops = {
1106 .read_resources = cpu_bus_read_resources,
1107 .set_resources = cpu_bus_set_resources,
1108 .enable_resources = cpu_bus_noop,
1109 .init = cpu_bus_init,
1110 .scan_bus = cpu_bus_scan,
1111};
1112
1113static void root_complex_enable_dev(struct device *dev)
1114{
Kyösti Mälkki87213b62012-08-27 20:00:33 +03001115 static int done = 0;
1116
1117 /* Do not delay UMA setup, as a device on the PCI bus may evaluate
1118 the global uma_memory variables already in its enable function. */
1119 if (!done) {
1120 setup_bsp_ramtop();
1121 setup_uma_memory();
1122 done = 1;
1123 }
1124
zbao2c08f6a2012-07-02 15:32:58 +08001125 /* Set the operations if it is a special bus type */
Stefan Reinauer4aff4452013-02-12 14:17:15 -08001126 if (dev->path.type == DEVICE_PATH_DOMAIN) {
zbao2c08f6a2012-07-02 15:32:58 +08001127 dev->ops = &pci_domain_ops;
Stefan Reinauer0aa37c42013-02-12 15:20:54 -08001128 } else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER) {
zbao2c08f6a2012-07-02 15:32:58 +08001129 dev->ops = &cpu_bus_ops;
1130 }
1131}
1132
1133struct chip_operations northbridge_amd_agesa_family15tn_root_complex_ops = {
1134 CHIP_NAME("AMD FAM15 Root Complex")
1135 .enable_dev = root_complex_enable_dev,
1136};
Dave Frodincbf3d402012-12-05 08:20:12 -07001137
1138/********************************************************************
1139* Change the vendor / device IDs to match the generic VBIOS header.
1140********************************************************************/
1141u32 map_oprom_vendev(u32 vendev)
1142{
1143 u32 new_vendev=vendev;
1144
1145 switch(vendev) {
1146 //case 0x10029900: //FS1r2
1147 case 0x10029901: //FM2
1148 case 0x10029903: //FS1r2
1149 case 0x10029904: //FM2
1150 case 0x10029906: //FM2
1151 case 0x10029907: //FP2
1152 case 0x10029908: //FP2
1153 case 0x1002990A: //FP2
1154 case 0x10029910: //FS1r2
1155 case 0x10029913: //FS1r2
1156 case 0x10029917: //FP2
1157 case 0x10029918: //FP2
1158 case 0x10029919: //FP2
1159 case 0x10029990: //FS1r2
1160 case 0x10029991: //FM2
1161 case 0x10029992: //FS1r2
1162 case 0x10029993: //FM2
1163 case 0x10029994: //FP2
1164 case 0x100299A0: //FS1r2
1165 case 0x100299A2: //FS1r2
1166 case 0x100299A4: //FP2
1167 new_vendev=0x10029900;
1168 break;
1169 }
1170
1171 return new_vendev;
1172}