blob: 8e5e4725d85a5cc5ca79c60e565c7b170f336726 [file] [log] [blame]
Siyuan Wang3e32cc02013-07-09 17:16:20 +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.
Siyuan Wang3e32cc02013-07-09 17:16:20 +080014 */
15
16#include <console/console.h>
17#include <arch/io.h>
Kyösti Mälkki8ae16a42014-06-19 20:44:34 +030018#include <arch/acpi.h>
Vladimir Serbinenkodb09b0622014-10-08 22:15:17 +020019#include <arch/acpigen.h>
Siyuan Wang3e32cc02013-07-09 17:16:20 +080020#include <stdint.h>
21#include <device/device.h>
22#include <device/pci.h>
23#include <device/pci_ids.h>
24#include <device/hypertransport.h>
25#include <stdlib.h>
26#include <string.h>
27#include <lib.h>
28#include <cpu/cpu.h>
29#include <cbmem.h>
30
31#include <cpu/x86/lapic.h>
32#include <cpu/amd/mtrr.h>
33
34#include <Porting.h>
35#include <AGESA.h>
36#include <Options.h>
37#include <Topology.h>
Kyösti Mälkkid610c582017-03-05 06:28:18 +020038
Kyösti Mälkki28c4d2f2016-11-25 11:21:02 +020039#include <northbridge/amd/agesa/state_machine.h>
Kyösti Mälkkid610c582017-03-05 06:28:18 +020040#include <northbridge/amd/agesa/agesa_helper.h>
Siyuan Wang3e32cc02013-07-09 17:16:20 +080041
42#define MAX_NODE_NUMS (MAX_NODES * MAX_DIES)
43
Siyuan Wang3e32cc02013-07-09 17:16:20 +080044typedef struct dram_base_mask {
45 u32 base; //[47:27] at [28:8]
46 u32 mask; //[47:27] at [28:8] and enable at bit 0
47} dram_base_mask_t;
48
49static unsigned node_nums;
50static unsigned sblink;
51static device_t __f0_dev[MAX_NODE_NUMS];
52static device_t __f1_dev[MAX_NODE_NUMS];
53static device_t __f2_dev[MAX_NODE_NUMS];
54static device_t __f4_dev[MAX_NODE_NUMS];
55static unsigned fx_devs = 0;
56
57static dram_base_mask_t get_dram_base_mask(u32 nodeid)
58{
59 device_t dev;
60 dram_base_mask_t d;
61 dev = __f1_dev[0];
62 u32 temp;
63 temp = pci_read_config32(dev, 0x44 + (nodeid << 3)); //[39:24] at [31:16]
64 d.mask = ((temp & 0xfff80000)>>(8+3)); // mask out DramMask [26:24] too
65 temp = pci_read_config32(dev, 0x144 + (nodeid <<3)) & 0xff; //[47:40] at [7:0]
Elyes HAOUAS27e18012017-06-27 23:14:51 +020066 d.mask |= temp << 21;
Siyuan Wang3e32cc02013-07-09 17:16:20 +080067 temp = pci_read_config32(dev, 0x40 + (nodeid << 3)); //[39:24] at [31:16]
68 d.mask |= (temp & 1); // enable bit
69 d.base = ((temp & 0xfff80000)>>(8+3)); // mask out DramBase [26:24) too
70 temp = pci_read_config32(dev, 0x140 + (nodeid <<3)) & 0xff; //[47:40] at [7:0]
Elyes HAOUAS27e18012017-06-27 23:14:51 +020071 d.base |= temp << 21;
Siyuan Wang3e32cc02013-07-09 17:16:20 +080072 return d;
73}
74
75static void set_io_addr_reg(device_t dev, u32 nodeid, u32 linkn, u32 reg,
76 u32 io_min, u32 io_max)
77{
78 u32 i;
79 u32 tempreg;
80 /* io range allocation */
Elyes HAOUAS27e18012017-06-27 23:14:51 +020081 tempreg = (nodeid&0xf) | ((nodeid & 0x30)<<(8-4)) | (linkn << 4) | ((io_max&0xf0)<<(12-4)); //limit
Elyes HAOUAS1d8daa62016-09-18 08:50:54 +020082 for (i = 0; i < node_nums; i++)
Siyuan Wang3e32cc02013-07-09 17:16:20 +080083 pci_write_config32(__f1_dev[i], reg+4, tempreg);
Elyes HAOUAS27e18012017-06-27 23:14:51 +020084 tempreg = 3 /*| (3 << 4)*/ | ((io_min&0xf0)<<(12-4)); //base :ISA and VGA ?
Elyes HAOUAS1d8daa62016-09-18 08:50:54 +020085 for (i = 0; i < node_nums; i++)
Siyuan Wang3e32cc02013-07-09 17:16:20 +080086 pci_write_config32(__f1_dev[i], reg, tempreg);
87}
88
89static void set_mmio_addr_reg(u32 nodeid, u32 linkn, u32 reg, u32 index, u32 mmio_min, u32 mmio_max, u32 nodes)
90{
91 u32 i;
92 u32 tempreg;
93 /* io range allocation */
Elyes HAOUAS27e18012017-06-27 23:14:51 +020094 tempreg = (nodeid&0xf) | (linkn << 4) | (mmio_max&0xffffff00); //limit
Elyes HAOUAS1d8daa62016-09-18 08:50:54 +020095 for (i = 0; i < nodes; i++)
Siyuan Wang3e32cc02013-07-09 17:16:20 +080096 pci_write_config32(__f1_dev[i], reg+4, tempreg);
97 tempreg = 3 | (nodeid & 0x30) | (mmio_min&0xffffff00);
Elyes HAOUAS1d8daa62016-09-18 08:50:54 +020098 for (i = 0; i < node_nums; i++)
Siyuan Wang3e32cc02013-07-09 17:16:20 +080099 pci_write_config32(__f1_dev[i], reg, tempreg);
100}
101
102static device_t get_node_pci(u32 nodeid, u32 fn)
103{
104#if MAX_NODE_NUMS + CONFIG_CDB >= 32
105 if ((CONFIG_CDB + nodeid) < 32) {
106 return dev_find_slot(CONFIG_CBB, PCI_DEVFN(CONFIG_CDB + nodeid, fn));
107 } else {
108 return dev_find_slot(CONFIG_CBB-1, PCI_DEVFN(CONFIG_CDB + nodeid - 32, fn));
109 }
110#else
111 return dev_find_slot(CONFIG_CBB, PCI_DEVFN(CONFIG_CDB + nodeid, fn));
112#endif
113}
114
115static void get_fx_devs(void)
116{
117 int i;
118 for (i = 0; i < MAX_NODE_NUMS; i++) {
119 __f0_dev[i] = get_node_pci(i, 0);
120 __f1_dev[i] = get_node_pci(i, 1);
121 __f2_dev[i] = get_node_pci(i, 2);
122 __f4_dev[i] = get_node_pci(i, 4);
123 if (__f0_dev[i] != NULL && __f1_dev[i] != NULL)
124 fx_devs = i+1;
125 }
126 if (__f1_dev[0] == NULL || __f0_dev[0] == NULL || fx_devs == 0) {
127 die("Cannot find 0:0x18.[0|1]\n");
128 }
129 printk(BIOS_DEBUG, "fx_devs=0x%x\n", fx_devs);
130}
131
132static u32 f1_read_config32(unsigned reg)
133{
134 if (fx_devs == 0)
135 get_fx_devs();
136 return pci_read_config32(__f1_dev[0], reg);
137}
138
139static void f1_write_config32(unsigned reg, u32 value)
140{
141 int i;
142 if (fx_devs == 0)
143 get_fx_devs();
Elyes HAOUAS5a7e72f2016-08-23 21:36:02 +0200144 for (i = 0; i < fx_devs; i++) {
Siyuan Wang3e32cc02013-07-09 17:16:20 +0800145 device_t dev;
146 dev = __f1_dev[i];
147 if (dev && dev->enabled) {
148 pci_write_config32(dev, reg, value);
149 }
150 }
151}
152
153static u32 amdfam16_nodeid(device_t dev)
154{
155#if MAX_NODE_NUMS == 64
156 unsigned busn;
157 busn = dev->bus->secondary;
158 if (busn != CONFIG_CBB) {
159 return (dev->path.pci.devfn >> 3) - CONFIG_CDB + 32;
160 } else {
161 return (dev->path.pci.devfn >> 3) - CONFIG_CDB;
162 }
163
164#else
165 return (dev->path.pci.devfn >> 3) - CONFIG_CDB;
166#endif
167}
168
169static void set_vga_enable_reg(u32 nodeid, u32 linkn)
170{
171 u32 val;
172
Elyes HAOUAS27e18012017-06-27 23:14:51 +0200173 val = 1 | (nodeid << 4) | (linkn << 12);
Siyuan Wang3e32cc02013-07-09 17:16:20 +0800174 /* it will routing
175 * (1)mmio 0xa0000:0xbffff
176 * (2)io 0x3b0:0x3bb, 0x3c0:0x3df
177 */
178 f1_write_config32(0xf4, val);
179
180}
181
182/**
183 * @return
184 * @retval 2 resoure does not exist, usable
185 * @retval 0 resource exists, not usable
186 * @retval 1 resource exist, resource has been allocated before
187 */
188static int reg_useable(unsigned reg, device_t goal_dev, unsigned goal_nodeid,
189 unsigned goal_link)
190{
191 struct resource *res;
192 unsigned nodeid, link = 0;
193 int result;
194 res = 0;
195 for (nodeid = 0; !res && (nodeid < fx_devs); nodeid++) {
196 device_t dev;
197 dev = __f0_dev[nodeid];
198 if (!dev)
199 continue;
200 for (link = 0; !res && (link < 8); link++) {
201 res = probe_resource(dev, IOINDEX(0x1000 + reg, link));
202 }
203 }
204 result = 2;
205 if (res) {
206 result = 0;
207 if ((goal_link == (link - 1)) &&
208 (goal_nodeid == (nodeid - 1)) &&
209 (res->flags <= 1)) {
210 result = 1;
211 }
212 }
213 return result;
214}
215
216static struct resource *amdfam16_find_iopair(device_t dev, unsigned nodeid, unsigned link)
217{
218 struct resource *resource;
219 u32 free_reg, reg;
220 resource = 0;
221 free_reg = 0;
222 for (reg = 0xc0; reg <= 0xd8; reg += 0x8) {
223 int result;
224 result = reg_useable(reg, dev, nodeid, link);
225 if (result == 1) {
226 /* I have been allocated this one */
227 break;
228 }
229 else if (result > 1) {
230 /* I have a free register pair */
231 free_reg = reg;
232 }
233 }
234 if (reg > 0xd8) {
235 reg = free_reg; // if no free, the free_reg still be 0
236 }
237
238 resource = new_resource(dev, IOINDEX(0x1000 + reg, link));
239
240 return resource;
241}
242
243static struct resource *amdfam16_find_mempair(device_t dev, u32 nodeid, u32 link)
244{
245 struct resource *resource;
246 u32 free_reg, reg;
247 resource = 0;
248 free_reg = 0;
249 for (reg = 0x80; reg <= 0xb8; reg += 0x8) {
250 int result;
251 result = reg_useable(reg, dev, nodeid, link);
252 if (result == 1) {
253 /* I have been allocated this one */
254 break;
255 }
256 else if (result > 1) {
257 /* I have a free register pair */
258 free_reg = reg;
259 }
260 }
261 if (reg > 0xb8) {
262 reg = free_reg;
263 }
264
265 resource = new_resource(dev, IOINDEX(0x1000 + reg, link));
266 return resource;
267}
268
269static void amdfam16_link_read_bases(device_t dev, u32 nodeid, u32 link)
270{
271 struct resource *resource;
272
273 /* Initialize the io space constraints on the current bus */
274 resource = amdfam16_find_iopair(dev, nodeid, link);
275 if (resource) {
276 u32 align;
277 align = log2(HT_IO_HOST_ALIGN);
278 resource->base = 0;
279 resource->size = 0;
280 resource->align = align;
281 resource->gran = align;
282 resource->limit = 0xffffUL;
283 resource->flags = IORESOURCE_IO | IORESOURCE_BRIDGE;
284 }
285
286 /* Initialize the prefetchable memory constraints on the current bus */
287 resource = amdfam16_find_mempair(dev, nodeid, link);
288 if (resource) {
289 resource->base = 0;
290 resource->size = 0;
291 resource->align = log2(HT_MEM_HOST_ALIGN);
292 resource->gran = log2(HT_MEM_HOST_ALIGN);
293 resource->limit = 0xffffffffffULL;
294 resource->flags = IORESOURCE_MEM | IORESOURCE_PREFETCH;
295 resource->flags |= IORESOURCE_BRIDGE;
296 }
297
298 /* Initialize the memory constraints on the current bus */
299 resource = amdfam16_find_mempair(dev, nodeid, link);
300 if (resource) {
301 resource->base = 0;
302 resource->size = 0;
303 resource->align = log2(HT_MEM_HOST_ALIGN);
304 resource->gran = log2(HT_MEM_HOST_ALIGN);
305 resource->limit = 0xffffffffffULL;
306 resource->flags = IORESOURCE_MEM | IORESOURCE_BRIDGE;
307 }
308
309}
310
311static void read_resources(device_t dev)
312{
313 u32 nodeid;
314 struct bus *link;
315
316 nodeid = amdfam16_nodeid(dev);
317 for (link = dev->link_list; link; link = link->next) {
318 if (link->children) {
319 amdfam16_link_read_bases(dev, nodeid, link->link_num);
320 }
321 }
Edward O'Callaghan66c65322014-11-21 01:43:38 +1100322
323 /*
324 * This MMCONF resource must be reserved in the PCI_DOMAIN.
325 * It is not honored by the coreboot resource allocator if it is in
326 * the APIC_CLUSTER.
327 */
Kyösti Mälkkie25b5ef2016-12-02 08:56:05 +0200328 mmconf_resource(dev, 0xc0010058);
Siyuan Wang3e32cc02013-07-09 17:16:20 +0800329}
330
331static void set_resource(device_t dev, struct resource *resource, u32 nodeid)
332{
333 resource_t rbase, rend;
334 unsigned reg, link_num;
335 char buf[50];
336
337 /* Make certain the resource has actually been set */
338 if (!(resource->flags & IORESOURCE_ASSIGNED)) {
339 return;
340 }
341
342 /* If I have already stored this resource don't worry about it */
343 if (resource->flags & IORESOURCE_STORED) {
344 return;
345 }
346
347 /* Only handle PCI memory and IO resources */
348 if (!(resource->flags & (IORESOURCE_MEM | IORESOURCE_IO)))
349 return;
350
351 /* Ensure I am actually looking at a resource of function 1 */
352 if ((resource->index & 0xffff) < 0x1000) {
353 return;
354 }
355 /* Get the base address */
356 rbase = resource->base;
357
358 /* Get the limit (rounded up) */
359 rend = resource_end(resource);
360
361 /* Get the register and link */
362 reg = resource->index & 0xfff; // 4k
363 link_num = IOINDEX_LINK(resource->index);
364
365 if (resource->flags & IORESOURCE_IO) {
366 set_io_addr_reg(dev, nodeid, link_num, reg, rbase>>8, rend>>8);
367 }
368 else if (resource->flags & IORESOURCE_MEM) {
Edward O'Callaghanae5fd342014-11-20 19:58:09 +1100369 set_mmio_addr_reg(nodeid, link_num, reg, (resource->index >>24), rbase>>8, rend>>8, node_nums);// [39:8]
Siyuan Wang3e32cc02013-07-09 17:16:20 +0800370 }
371 resource->flags |= IORESOURCE_STORED;
Elyes HAOUAS0d4b11a2016-10-03 21:57:21 +0200372 snprintf(buf, sizeof(buf), " <node %x link %x>",
Siyuan Wang3e32cc02013-07-09 17:16:20 +0800373 nodeid, link_num);
374 report_resource_stored(dev, resource, buf);
375}
376
377/**
378 * I tried to reuse the resource allocation code in set_resource()
379 * but it is too difficult to deal with the resource allocation magic.
380 */
381
382static void create_vga_resource(device_t dev, unsigned nodeid)
383{
384 struct bus *link;
385
386 /* find out which link the VGA card is connected,
387 * we only deal with the 'first' vga card */
388 for (link = dev->link_list; link; link = link->next) {
389 if (link->bridge_ctrl & PCI_BRIDGE_CTL_VGA) {
Martin Roth77a58b92017-06-24 14:45:48 -0600390#if IS_ENABLED(CONFIG_MULTIPLE_VGA_ADAPTERS)
Siyuan Wang3e32cc02013-07-09 17:16:20 +0800391 extern device_t vga_pri; // the primary vga device, defined in device.c
392 printk(BIOS_DEBUG, "VGA: vga_pri bus num = %d bus range [%d,%d]\n", vga_pri->bus->secondary,
393 link->secondary,link->subordinate);
394 /* We need to make sure the vga_pri is under the link */
Elyes HAOUAS1d8daa62016-09-18 08:50:54 +0200395 if ((vga_pri->bus->secondary >= link->secondary) &&
396 (vga_pri->bus->secondary <= link->subordinate))
Siyuan Wang3e32cc02013-07-09 17:16:20 +0800397#endif
398 break;
399 }
400 }
401
402 /* no VGA card installed */
403 if (link == NULL)
404 return;
405
406 printk(BIOS_DEBUG, "VGA: %s (aka node %d) link %d has VGA device\n", dev_path(dev), nodeid, sblink);
407 set_vga_enable_reg(nodeid, sblink);
408}
409
410static void set_resources(device_t dev)
411{
412 unsigned nodeid;
413 struct bus *bus;
414 struct resource *res;
415
416 /* Find the nodeid */
417 nodeid = amdfam16_nodeid(dev);
418
419 create_vga_resource(dev, nodeid); //TODO: do we need this?
420
421 /* Set each resource we have found */
422 for (res = dev->resource_list; res; res = res->next) {
423 set_resource(dev, res, nodeid);
424 }
425
426 for (bus = dev->link_list; bus; bus = bus->next) {
427 if (bus->children) {
428 assign_resources(bus);
429 }
430 }
431}
432
Vladimir Serbinenkodb09b0622014-10-08 22:15:17 +0200433
Vladimir Serbinenko807127f2014-11-09 13:36:18 +0100434static unsigned long acpi_fill_hest(acpi_hest_t *hest)
Vladimir Serbinenkodb09b0622014-10-08 22:15:17 +0200435{
436 void *addr, *current;
437
438 /* Skip the HEST header. */
439 current = (void *)(hest + 1);
440
441 addr = agesawrapper_getlateinitptr(PICK_WHEA_MCE);
442 if (addr != NULL)
Stefan Reinauer77a1d1a2015-07-21 12:48:17 -0700443 current += acpi_create_hest_error_source(hest, current, 0,
444 addr + 2, *(UINT16 *)addr - 2);
Vladimir Serbinenkodb09b0622014-10-08 22:15:17 +0200445
446 addr = agesawrapper_getlateinitptr(PICK_WHEA_CMC);
447 if (addr != NULL)
Stefan Reinauer77a1d1a2015-07-21 12:48:17 -0700448 current += acpi_create_hest_error_source(hest, current, 1,
449 addr + 2, *(UINT16 *)addr - 2);
Vladimir Serbinenkodb09b0622014-10-08 22:15:17 +0200450
451 return (unsigned long)current;
452}
453
Alexander Couzens5eea4582015-04-12 22:18:55 +0200454static void northbridge_fill_ssdt_generator(device_t device)
Vladimir Serbinenkodb09b0622014-10-08 22:15:17 +0200455{
456 msr_t msr;
457 char pscope[] = "\\_SB.PCI0";
458
459 acpigen_write_scope(pscope);
460 msr = rdmsr(TOP_MEM);
461 acpigen_write_name_dword("TOM1", msr.lo);
462 msr = rdmsr(TOP_MEM2);
463 /*
464 * Since XP only implements parts of ACPI 2.0, we can't use a qword
465 * here.
466 * See http://www.acpi.info/presentations/S01USMOBS169_OS%2520new.ppt
467 * slide 22ff.
468 * Shift value right by 20 bit to make it fit into 32bit,
469 * giving us 1MB granularity and a limit of almost 4Exabyte of memory.
470 */
471 acpigen_write_name_dword("TOM2", (msr.hi << 12) | msr.lo >> 20);
472 acpigen_pop_len();
473}
474
Alexander Couzens83fc32f2015-04-12 22:28:37 +0200475static unsigned long agesa_write_acpi_tables(device_t device,
476 unsigned long current,
Vladimir Serbinenkodb09b0622014-10-08 22:15:17 +0200477 acpi_rsdp_t *rsdp)
478{
479 acpi_srat_t *srat;
480 acpi_slit_t *slit;
481 acpi_header_t *ssdt;
482 acpi_header_t *alib;
483 acpi_header_t *ivrs;
484 acpi_hest_t *hest;
485
486 /* HEST */
487 current = ALIGN(current, 8);
488 hest = (acpi_hest_t *)current;
Vladimir Serbinenko807127f2014-11-09 13:36:18 +0100489 acpi_write_hest((void *)current, acpi_fill_hest);
Vladimir Serbinenkodb09b0622014-10-08 22:15:17 +0200490 acpi_add_table(rsdp, (void *)current);
491 current += ((acpi_header_t *)current)->length;
492
493 current = ALIGN(current, 8);
494 printk(BIOS_DEBUG, "ACPI: * IVRS at %lx\n", current);
495 ivrs = agesawrapper_getlateinitptr(PICK_IVRS);
496 if (ivrs != NULL) {
497 memcpy((void *)current, ivrs, ivrs->length);
498 ivrs = (acpi_header_t *) current;
499 current += ivrs->length;
500 acpi_add_table(rsdp, ivrs);
501 } else {
502 printk(BIOS_DEBUG, " AGESA IVRS table NULL. Skipping.\n");
503 }
504
505 /* SRAT */
506 current = ALIGN(current, 8);
507 printk(BIOS_DEBUG, "ACPI: * SRAT at %lx\n", current);
508 srat = (acpi_srat_t *) agesawrapper_getlateinitptr (PICK_SRAT);
509 if (srat != NULL) {
510 memcpy((void *)current, srat, srat->header.length);
511 srat = (acpi_srat_t *) current;
512 current += srat->header.length;
513 acpi_add_table(rsdp, srat);
514 } else {
515 printk(BIOS_DEBUG, " AGESA SRAT table NULL. Skipping.\n");
516 }
517
518 /* SLIT */
519 current = ALIGN(current, 8);
520 printk(BIOS_DEBUG, "ACPI: * SLIT at %lx\n", current);
521 slit = (acpi_slit_t *) agesawrapper_getlateinitptr (PICK_SLIT);
522 if (slit != NULL) {
523 memcpy((void *)current, slit, slit->header.length);
524 slit = (acpi_slit_t *) current;
525 current += slit->header.length;
526 acpi_add_table(rsdp, slit);
527 } else {
528 printk(BIOS_DEBUG, " AGESA SLIT table NULL. Skipping.\n");
529 }
530
531 /* ALIB */
532 current = ALIGN(current, 16);
533 printk(BIOS_DEBUG, "ACPI: * AGESA ALIB SSDT at %lx\n", current);
534 alib = (acpi_header_t *)agesawrapper_getlateinitptr (PICK_ALIB);
535 if (alib != NULL) {
536 memcpy((void *)current, alib, alib->length);
537 alib = (acpi_header_t *) current;
538 current += alib->length;
539 acpi_add_table(rsdp, (void *)alib);
540 }
541 else {
542 printk(BIOS_DEBUG, " AGESA ALIB SSDT table NULL. Skipping.\n");
543 }
544
545 /* this pstate ssdt may cause Blue Screen: Fixed: Keep this comment for a while. */
546 /* SSDT */
547 current = ALIGN(current, 16);
548 printk(BIOS_DEBUG, "ACPI: * SSDT at %lx\n", current);
549 ssdt = (acpi_header_t *)agesawrapper_getlateinitptr (PICK_PSTATE);
550 if (ssdt != NULL) {
551 memcpy((void *)current, ssdt, ssdt->length);
552 ssdt = (acpi_header_t *) current;
553 current += ssdt->length;
554 }
555 else {
556 printk(BIOS_DEBUG, " AGESA PState table NULL. Skipping.\n");
557 }
558 acpi_add_table(rsdp,ssdt);
559
560 printk(BIOS_DEBUG, "ACPI: * SSDT for PState at %lx\n", current);
561
562 return current;
563}
564
Siyuan Wang3e32cc02013-07-09 17:16:20 +0800565static struct device_operations northbridge_operations = {
566 .read_resources = read_resources,
567 .set_resources = set_resources,
568 .enable_resources = pci_dev_enable_resources,
Edward O'Callaghand994ef12014-11-21 02:22:33 +1100569 .init = DEVICE_NOOP,
Vladimir Serbinenkodb09b0622014-10-08 22:15:17 +0200570 .acpi_fill_ssdt_generator = northbridge_fill_ssdt_generator,
571 .write_acpi_tables = agesa_write_acpi_tables,
Siyuan Wang3e32cc02013-07-09 17:16:20 +0800572 .enable = 0,
573 .ops_pci = 0,
574};
575
576static const struct pci_driver family16_northbridge __pci_driver = {
577 .ops = &northbridge_operations,
578 .vendor = PCI_VENDOR_ID_AMD,
579 .device = PCI_DEVICE_ID_AMD_16H_MODEL_000F_NB_HT,
580};
581
582static const struct pci_driver family10_northbridge __pci_driver = {
583 .ops = &northbridge_operations,
584 .vendor = PCI_VENDOR_ID_AMD,
585 .device = PCI_DEVICE_ID_AMD_10H_NB_HT,
586};
587
Kyösti Mälkki4ee82c62014-11-25 16:03:12 +0200588static void fam16_finalize(void *chip_info)
589{
590 device_t dev;
591 u32 value;
592 dev = dev_find_slot(0, PCI_DEVFN(0, 0)); /* clear IoapicSbFeatureEn */
593 pci_write_config32(dev, 0xF8, 0);
594 pci_write_config32(dev, 0xFC, 5); /* TODO: move it to dsdt.asl */
595
596 /* disable No Snoop */
597 dev = dev_find_slot(0, PCI_DEVFN(1, 1));
598 value = pci_read_config32(dev, 0x60);
599 value &= ~(1 << 11);
600 pci_write_config32(dev, 0x60, value);
601}
602
Siyuan Wang3e32cc02013-07-09 17:16:20 +0800603struct chip_operations northbridge_amd_agesa_family16kb_ops = {
604 CHIP_NAME("AMD FAM16 Northbridge")
605 .enable_dev = 0,
Kyösti Mälkki4ee82c62014-11-25 16:03:12 +0200606 .final = fam16_finalize,
Siyuan Wang3e32cc02013-07-09 17:16:20 +0800607};
608
609static void domain_read_resources(device_t dev)
610{
611 unsigned reg;
612
613 /* Find the already assigned resource pairs */
614 get_fx_devs();
615 for (reg = 0x80; reg <= 0xd8; reg+= 0x08) {
616 u32 base, limit;
617 base = f1_read_config32(reg);
618 limit = f1_read_config32(reg + 0x04);
619 /* Is this register allocated? */
620 if ((base & 3) != 0) {
621 unsigned nodeid, reg_link;
622 device_t reg_dev;
Elyes HAOUAS1d8daa62016-09-18 08:50:54 +0200623 if (reg < 0xc0) { // mmio
Siyuan Wang3e32cc02013-07-09 17:16:20 +0800624 nodeid = (limit & 0xf) + (base&0x30);
625 } else { // io
626 nodeid = (limit & 0xf) + ((base>>4)&0x30);
627 }
628 reg_link = (limit >> 4) & 7;
629 reg_dev = __f0_dev[nodeid];
630 if (reg_dev) {
631 /* Reserve the resource */
632 struct resource *res;
633 res = new_resource(reg_dev, IOINDEX(0x1000 + reg, reg_link));
634 if (res) {
635 res->flags = 1;
636 }
637 }
638 }
639 }
640 /* FIXME: do we need to check extend conf space?
641 I don't believe that much preset value */
642
Siyuan Wang3e32cc02013-07-09 17:16:20 +0800643 pci_domain_read_resources(dev);
Siyuan Wang3e32cc02013-07-09 17:16:20 +0800644}
645
Siyuan Wang3e32cc02013-07-09 17:16:20 +0800646#if CONFIG_HW_MEM_HOLE_SIZEK != 0
647struct hw_mem_hole_info {
648 unsigned hole_startk;
649 int node_id;
650};
651static struct hw_mem_hole_info get_hw_mem_hole_info(void)
652{
653 struct hw_mem_hole_info mem_hole;
654 int i;
655 mem_hole.hole_startk = CONFIG_HW_MEM_HOLE_SIZEK;
656 mem_hole.node_id = -1;
657 for (i = 0; i < node_nums; i++) {
658 dram_base_mask_t d;
659 u32 hole;
660 d = get_dram_base_mask(i);
661 if (!(d.mask & 1)) continue; // no memory on this node
662 hole = pci_read_config32(__f1_dev[i], 0xf0);
663 if (hole & 2) { // we find the hole
Elyes HAOUAS27e18012017-06-27 23:14:51 +0200664 mem_hole.hole_startk = (hole & (0xff << 24)) >> 10;
Siyuan Wang3e32cc02013-07-09 17:16:20 +0800665 mem_hole.node_id = i; // record the node No with hole
666 break; // only one hole
667 }
668 }
Kyösti Mälkki2f9b3af2014-06-26 05:30:54 +0300669
670 /* We need to double check if there is special set on base reg and limit reg
671 * are not continuous instead of hole, it will find out its hole_startk.
672 */
Siyuan Wang3e32cc02013-07-09 17:16:20 +0800673 if (mem_hole.node_id == -1) {
674 resource_t limitk_pri = 0;
Elyes HAOUAS1d8daa62016-09-18 08:50:54 +0200675 for (i = 0; i < node_nums; i++) {
Siyuan Wang3e32cc02013-07-09 17:16:20 +0800676 dram_base_mask_t d;
677 resource_t base_k, limit_k;
678 d = get_dram_base_mask(i);
679 if (!(d.base & 1)) continue;
680 base_k = ((resource_t)(d.base & 0x1fffff00)) <<9;
681 if (base_k > 4 *1024 * 1024) break; // don't need to go to check
682 if (limitk_pri != base_k) { // we find the hole
683 mem_hole.hole_startk = (unsigned)limitk_pri; // must beblow 4G
684 mem_hole.node_id = i;
685 break; //only one hole
686 }
687 limit_k = ((resource_t)(((d.mask & ~1) + 0x000FF) & 0x1fffff00)) << 9;
688 limitk_pri = limit_k;
689 }
690 }
691 return mem_hole;
692}
693#endif
694
Siyuan Wang3e32cc02013-07-09 17:16:20 +0800695static void domain_set_resources(device_t dev)
696{
Siyuan Wang3e32cc02013-07-09 17:16:20 +0800697 unsigned long mmio_basek;
698 u32 pci_tolm;
699 int i, idx;
700 struct bus *link;
701#if CONFIG_HW_MEM_HOLE_SIZEK != 0
702 struct hw_mem_hole_info mem_hole;
703 u32 reset_memhole = 1;
704#endif
705
Siyuan Wang3e32cc02013-07-09 17:16:20 +0800706 pci_tolm = 0xffffffffUL;
707 for (link = dev->link_list; link; link = link->next) {
708 pci_tolm = find_pci_tolm(link);
709 }
710
711 // FIXME handle interleaved nodes. If you fix this here, please fix
712 // amdk8, too.
713 mmio_basek = pci_tolm >> 10;
714 /* Round mmio_basek to something the processor can support */
715 mmio_basek &= ~((1 << 6) -1);
716
717 // FIXME improve mtrr.c so we don't use up all of the mtrrs with a 64M
718 // MMIO hole. If you fix this here, please fix amdk8, too.
719 /* Round the mmio hole to 64M */
720 mmio_basek &= ~((64*1024) - 1);
721
722#if CONFIG_HW_MEM_HOLE_SIZEK != 0
723 /* if the hw mem hole is already set in raminit stage, here we will compare
724 * mmio_basek and hole_basek. if mmio_basek is bigger that hole_basek and will
725 * use hole_basek as mmio_basek and we don't need to reset hole.
726 * otherwise We reset the hole to the mmio_basek
727 */
728
729 mem_hole = get_hw_mem_hole_info();
730
731 // Use hole_basek as mmio_basek, and we don't need to reset hole anymore
732 if ((mem_hole.node_id != -1) && (mmio_basek > mem_hole.hole_startk)) {
733 mmio_basek = mem_hole.hole_startk;
734 reset_memhole = 0;
735 }
736#endif
737
738 idx = 0x10;
739 for (i = 0; i < node_nums; i++) {
740 dram_base_mask_t d;
741 resource_t basek, limitk, sizek; // 4 1T
742
743 d = get_dram_base_mask(i);
744
745 if (!(d.mask & 1)) continue;
746 basek = ((resource_t)(d.base & 0x1fffff00)) << 9; // could overflow, we may lost 6 bit here
Edward O'Callaghanae5fd342014-11-20 19:58:09 +1100747 limitk = ((resource_t)(((d.mask & ~1) + 0x000FF) & 0x1fffff00)) << 9;
Siyuan Wang3e32cc02013-07-09 17:16:20 +0800748
749 sizek = limitk - basek;
750
751 /* see if we need a hole from 0xa0000 to 0xbffff */
752 if ((basek < ((8*64)+(8*16))) && (sizek > ((8*64)+(16*16)))) {
753 ram_resource(dev, (idx | i), basek, ((8*64)+(8*16)) - basek);
754 idx += 0x10;
755 basek = (8*64)+(16*16);
756 sizek = limitk - ((8*64)+(16*16));
Siyuan Wang3e32cc02013-07-09 17:16:20 +0800757 }
758
759 //printk(BIOS_DEBUG, "node %d : mmio_basek=%08lx, basek=%08llx, limitk=%08llx\n", i, mmio_basek, basek, limitk);
760
Kyösti Mälkki26c65432014-06-26 05:30:54 +0300761 /* split the region to accommodate pci memory space */
Elyes HAOUAS1d8daa62016-09-18 08:50:54 +0200762 if ((basek < 4*1024*1024) && (limitk > mmio_basek)) {
Siyuan Wang3e32cc02013-07-09 17:16:20 +0800763 if (basek <= mmio_basek) {
764 unsigned pre_sizek;
765 pre_sizek = mmio_basek - basek;
Elyes HAOUAS1d8daa62016-09-18 08:50:54 +0200766 if (pre_sizek > 0) {
Siyuan Wang3e32cc02013-07-09 17:16:20 +0800767 ram_resource(dev, (idx | i), basek, pre_sizek);
768 idx += 0x10;
769 sizek -= pre_sizek;
Siyuan Wang3e32cc02013-07-09 17:16:20 +0800770 }
771 basek = mmio_basek;
772 }
773 if ((basek + sizek) <= 4*1024*1024) {
774 sizek = 0;
775 }
776 else {
777 uint64_t topmem2 = bsp_topmem2();
778 basek = 4*1024*1024;
779 sizek = topmem2/1024 - basek;
780 }
781 }
782
783 ram_resource(dev, (idx | i), basek, sizek);
784 idx += 0x10;
785 printk(BIOS_DEBUG, "node %d: mmio_basek=%08lx, basek=%08llx, limitk=%08llx\n",
786 i, mmio_basek, basek, limitk);
Siyuan Wang3e32cc02013-07-09 17:16:20 +0800787 }
788
Kyösti Mälkki61be3602017-04-15 20:07:53 +0300789 add_uma_resource_below_tolm(dev, 7);
Siyuan Wang3e32cc02013-07-09 17:16:20 +0800790
Elyes HAOUAS5a7e72f2016-08-23 21:36:02 +0200791 for (link = dev->link_list; link; link = link->next) {
Siyuan Wang3e32cc02013-07-09 17:16:20 +0800792 if (link->children) {
793 assign_resources(link);
794 }
795 }
796}
797
Kevin Cody-Little06d23232018-05-09 14:22:15 -0400798static const char *domain_acpi_name(const struct device *dev)
799{
800 if (dev->path.type == DEVICE_PATH_DOMAIN)
801 return "PCI0";
802
803 return NULL;
804}
805
Siyuan Wang3e32cc02013-07-09 17:16:20 +0800806static struct device_operations pci_domain_ops = {
807 .read_resources = domain_read_resources,
808 .set_resources = domain_set_resources,
Edward O'Callaghane9e1d7a2015-01-02 15:11:49 +1100809 .init = DEVICE_NOOP,
Siyuan Wang3e32cc02013-07-09 17:16:20 +0800810 .scan_bus = pci_domain_scan_bus,
Kevin Cody-Little06d23232018-05-09 14:22:15 -0400811 .acpi_name = domain_acpi_name,
Siyuan Wang3e32cc02013-07-09 17:16:20 +0800812};
813
814static void sysconf_init(device_t dev) // first node
815{
816 sblink = (pci_read_config32(dev, 0x64)>>8) & 7; // don't forget sublink1
817 node_nums = ((pci_read_config32(dev, 0x60)>>4) & 7) + 1; //NodeCnt[2:0]
818}
819
820static void add_more_links(device_t dev, unsigned total_links)
821{
822 struct bus *link, *last = NULL;
823 int link_num;
824
825 for (link = dev->link_list; link; link = link->next)
826 last = link;
827
828 if (last) {
829 int links = total_links - last->link_num;
830 link_num = last->link_num;
831 if (links > 0) {
832 link = malloc(links*sizeof(*link));
833 if (!link)
834 die("Couldn't allocate more links!\n");
835 memset(link, 0, links*sizeof(*link));
836 last->next = link;
837 }
838 }
839 else {
840 link_num = -1;
841 link = malloc(total_links*sizeof(*link));
842 memset(link, 0, total_links*sizeof(*link));
843 dev->link_list = link;
844 }
845
846 for (link_num = link_num + 1; link_num < total_links; link_num++) {
847 link->link_num = link_num;
848 link->dev = dev;
849 link->next = link + 1;
850 last = link;
851 link = link->next;
852 }
853 last->next = NULL;
854}
855
Kyösti Mälkki580e7222015-03-19 21:04:23 +0200856static void cpu_bus_scan(device_t dev)
Siyuan Wang3e32cc02013-07-09 17:16:20 +0800857{
858 struct bus *cpu_bus;
859 device_t dev_mc;
860#if CONFIG_CBB
861 device_t pci_domain;
862#endif
863 int i,j;
864 int coreid_bits;
865 int core_max = 0;
866 unsigned ApicIdCoreIdSize;
867 unsigned core_nums;
868 int siblings = 0;
869 unsigned int family;
870
871#if CONFIG_CBB
872 dev_mc = dev_find_slot(0, PCI_DEVFN(CONFIG_CDB, 0)); //0x00
873 if (dev_mc && dev_mc->bus) {
874 printk(BIOS_DEBUG, "%s found", dev_path(dev_mc));
875 pci_domain = dev_mc->bus->dev;
876 if (pci_domain && (pci_domain->path.type == DEVICE_PATH_DOMAIN)) {
877 printk(BIOS_DEBUG, "\n%s move to ",dev_path(dev_mc));
878 dev_mc->bus->secondary = CONFIG_CBB; // move to 0xff
879 printk(BIOS_DEBUG, "%s",dev_path(dev_mc));
880 } else {
881 printk(BIOS_DEBUG, " but it is not under pci_domain directly ");
882 }
883 printk(BIOS_DEBUG, "\n");
884 }
885 dev_mc = dev_find_slot(CONFIG_CBB, PCI_DEVFN(CONFIG_CDB, 0));
886 if (!dev_mc) {
887 dev_mc = dev_find_slot(0, PCI_DEVFN(0x18, 0));
888 if (dev_mc && dev_mc->bus) {
889 printk(BIOS_DEBUG, "%s found\n", dev_path(dev_mc));
890 pci_domain = dev_mc->bus->dev;
891 if (pci_domain && (pci_domain->path.type == DEVICE_PATH_DOMAIN)) {
892 if ((pci_domain->link_list) && (pci_domain->link_list->children == dev_mc)) {
893 printk(BIOS_DEBUG, "%s move to ",dev_path(dev_mc));
894 dev_mc->bus->secondary = CONFIG_CBB; // move to 0xff
895 printk(BIOS_DEBUG, "%s\n",dev_path(dev_mc));
896 while (dev_mc) {
897 printk(BIOS_DEBUG, "%s move to ",dev_path(dev_mc));
898 dev_mc->path.pci.devfn -= PCI_DEVFN(0x18,0);
899 printk(BIOS_DEBUG, "%s\n",dev_path(dev_mc));
900 dev_mc = dev_mc->sibling;
901 }
902 }
903 }
904 }
905 }
906#endif
907 dev_mc = dev_find_slot(CONFIG_CBB, PCI_DEVFN(CONFIG_CDB, 0));
908 if (!dev_mc) {
909 printk(BIOS_ERR, "%02x:%02x.0 not found", CONFIG_CBB, CONFIG_CDB);
910 die("");
911 }
912 sysconf_init(dev_mc);
913#if CONFIG_CBB && (MAX_NODE_NUMS > 32)
Elyes HAOUAS1d8daa62016-09-18 08:50:54 +0200914 if (node_nums > 32) { // need to put node 32 to node 63 to bus 0xfe
Siyuan Wang3e32cc02013-07-09 17:16:20 +0800915 if (pci_domain->link_list && !pci_domain->link_list->next) {
916 struct bus *new_link = new_link(pci_domain);
917 pci_domain->link_list->next = new_link;
918 new_link->link_num = 1;
919 new_link->dev = pci_domain;
920 new_link->children = 0;
921 printk(BIOS_DEBUG, "%s links now 2\n", dev_path(pci_domain));
922 }
923 pci_domain->link_list->next->secondary = CONFIG_CBB - 1;
924 }
925#endif
926
927 /* Get Max Number of cores(MNC) */
Kyösti Mälkkid41feed2017-09-24 16:23:57 +0300928 coreid_bits = (cpuid_ecx(0x80000008) & 0x0000F000) >> 12;
Siyuan Wang3e32cc02013-07-09 17:16:20 +0800929 core_max = 1 << (coreid_bits & 0x000F); //mnc
930
931 ApicIdCoreIdSize = ((cpuid_ecx(0x80000008)>>12) & 0xF);
932 if (ApicIdCoreIdSize) {
933 core_nums = (1 << ApicIdCoreIdSize) - 1;
934 } else {
935 core_nums = 3; //quad core
936 }
937
938 /* Find which cpus are present */
939 cpu_bus = dev->link_list;
940 for (i = 0; i < node_nums; i++) {
941 device_t cdb_dev;
942 unsigned busn, devn;
943 struct bus *pbus;
944
945 busn = CONFIG_CBB;
946 devn = CONFIG_CDB + i;
947 pbus = dev_mc->bus;
948#if CONFIG_CBB && (MAX_NODE_NUMS > 32)
949 if (i >= 32) {
950 busn--;
951 devn -= 32;
952 pbus = pci_domain->link_list->next;
953 }
954#endif
955
956 /* Find the cpu's pci device */
957 cdb_dev = dev_find_slot(busn, PCI_DEVFN(devn, 0));
958 if (!cdb_dev) {
959 /* If I am probing things in a weird order
960 * ensure all of the cpu's pci devices are found.
961 */
962 int fn;
Elyes HAOUAS5a7e72f2016-08-23 21:36:02 +0200963 for (fn = 0; fn <= 5; fn++) { //FBDIMM?
Siyuan Wang3e32cc02013-07-09 17:16:20 +0800964 cdb_dev = pci_probe_dev(NULL, pbus,
965 PCI_DEVFN(devn, fn));
966 }
967 cdb_dev = dev_find_slot(busn, PCI_DEVFN(devn, 0));
968 } else {
969 /* Ok, We need to set the links for that device.
970 * otherwise the device under it will not be scanned
971 */
Kyösti Mälkki2a2d6132015-02-04 13:25:37 +0200972 add_more_links(cdb_dev, 4);
Siyuan Wang3e32cc02013-07-09 17:16:20 +0800973 }
974
975 family = cpuid_eax(1);
976 family = (family >> 20) & 0xFF;
977 if (family == 1) { //f10
978 u32 dword;
979 cdb_dev = dev_find_slot(busn, PCI_DEVFN(devn, 3));
980 dword = pci_read_config32(cdb_dev, 0xe8);
981 siblings = ((dword & BIT15) >> 13) | ((dword & (BIT13 | BIT12)) >> 12);
982 } else if (family == 7) {//f16
983 cdb_dev = dev_find_slot(busn, PCI_DEVFN(devn, 5));
984 if (cdb_dev && cdb_dev->enabled) {
985 siblings = pci_read_config32(cdb_dev, 0x84);
986 siblings &= 0xFF;
987 }
988 } else {
989 siblings = 0; //default one core
990 }
991 int enable_node = cdb_dev && cdb_dev->enabled;
992 printk(BIOS_SPEW, "%s family%xh, core_max=0x%x, core_nums=0x%x, siblings=0x%x\n",
993 dev_path(cdb_dev), 0x0f + family, core_max, core_nums, siblings);
994
Elyes HAOUAS1d8daa62016-09-18 08:50:54 +0200995 for (j = 0; j <= siblings; j++) {
Siyuan Wang3e32cc02013-07-09 17:16:20 +0800996 extern CONST OPTIONS_CONFIG_TOPOLOGY ROMDATA TopologyConfiguration;
997 u32 modules = TopologyConfiguration.PlatformNumberOfModules;
998 u32 lapicid_start = 0;
999
1000 /*
1001 * APIC ID calucation is tightly coupled with AGESA v5 code.
1002 * This calculation MUST match the assignment calculation done
1003 * in LocalApicInitializationAtEarly() function.
1004 * And reference GetLocalApicIdForCore()
1005 *
1006 * Apply apic enumeration rules
1007 * For systems with >= 16 APICs, put the IO-APICs at 0..n and
1008 * put the local-APICs at m..z
1009 *
1010 * This is needed because many IO-APIC devices only have 4 bits
1011 * for their APIC id and therefore must reside at 0..15
Elyes HAOUAS6e8b3c12016-09-02 19:22:00 +02001012 */
Kyösti Mälkki50036322016-05-18 13:35:21 +03001013
Elyes HAOUAS6e8b3c12016-09-02 19:22:00 +02001014 u8 plat_num_io_apics = 3; /* FIXME */
Kyösti Mälkki50036322016-05-18 13:35:21 +03001015
1016 if ((node_nums * core_max) + plat_num_io_apics >= 0x10) {
1017 lapicid_start = (plat_num_io_apics - 1) / core_max;
Siyuan Wang3e32cc02013-07-09 17:16:20 +08001018 lapicid_start = (lapicid_start + 1) * core_max;
1019 printk(BIOS_SPEW, "lpaicid_start=0x%x ", lapicid_start);
1020 }
1021 u32 apic_id = (lapicid_start * (i/modules + 1)) + ((i % modules) ? (j + (siblings + 1)) : j);
1022 printk(BIOS_SPEW, "node 0x%x core 0x%x apicid=0x%x\n",
1023 i, j, apic_id);
1024
1025 device_t cpu = add_cpu_device(cpu_bus, apic_id, enable_node);
1026 if (cpu)
1027 amd_cpu_topology(cpu, i, j);
1028 } //j
1029 }
Siyuan Wang3e32cc02013-07-09 17:16:20 +08001030}
1031
1032static void cpu_bus_init(device_t dev)
1033{
1034 initialize_cpus(dev->link_list);
1035}
1036
Siyuan Wang3e32cc02013-07-09 17:16:20 +08001037static struct device_operations cpu_bus_ops = {
Edward O'Callaghan66c65322014-11-21 01:43:38 +11001038 .read_resources = DEVICE_NOOP,
1039 .set_resources = DEVICE_NOOP,
Edward O'Callaghan812d2a42014-10-31 08:17:23 +11001040 .enable_resources = DEVICE_NOOP,
Siyuan Wang3e32cc02013-07-09 17:16:20 +08001041 .init = cpu_bus_init,
1042 .scan_bus = cpu_bus_scan,
1043};
1044
1045static void root_complex_enable_dev(struct device *dev)
1046{
1047 static int done = 0;
1048
Siyuan Wang3e32cc02013-07-09 17:16:20 +08001049 if (!done) {
1050 setup_bsp_ramtop();
Siyuan Wang3e32cc02013-07-09 17:16:20 +08001051 done = 1;
1052 }
1053
1054 /* Set the operations if it is a special bus type */
1055 if (dev->path.type == DEVICE_PATH_DOMAIN) {
1056 dev->ops = &pci_domain_ops;
1057 } else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER) {
1058 dev->ops = &cpu_bus_ops;
1059 }
1060}
1061
1062struct chip_operations northbridge_amd_agesa_family16kb_root_complex_ops = {
1063 CHIP_NAME("AMD FAM16 Root Complex")
1064 .enable_dev = root_complex_enable_dev,
1065};
Bruce Griffith76db07e2013-07-07 02:06:53 -06001066
1067/*********************************************************************
1068 * Change the vendor / device IDs to match the generic VBIOS header. *
1069 *********************************************************************/
1070u32 map_oprom_vendev(u32 vendev)
1071{
1072 u32 new_vendev = vendev;
1073
1074 switch(vendev) {
1075 case 0x10029830:
1076 case 0x10029831:
1077 case 0x10029832:
1078 case 0x10029833:
1079 case 0x10029834:
1080 case 0x10029835:
1081 case 0x10029836:
1082 case 0x10029837:
1083 case 0x10029838:
1084 case 0x10029839:
1085 case 0x1002983A:
1086 case 0x1002983D:
1087 new_vendev = 0x10029830; // This is the default value in AMD-generated VBIOS
1088 break;
1089 default:
1090 break;
1091 }
1092
1093 if (vendev != new_vendev)
1094 printk(BIOS_NOTICE, "Mapping PCI device %8x to %8x\n", vendev, new_vendev);
1095
1096 return new_vendev;
1097}