blob: 021a1db2bfb2b6b56e50e87f6efb8481cc517f3d [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
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>
29#include <bitops.h>
30#include <cpu/cpu.h>
Marc Jones5750ed22012-03-15 13:21:41 -060031#include <cbmem.h>
Frank Vibrans39fca802011-02-14 18:35:15 +000032
33#include <cpu/x86/lapic.h>
34
efdesign983f5ebd62011-09-14 13:47:17 -060035#include "agesawrapper.h"
Frank Vibrans39fca802011-02-14 18:35:15 +000036#include "chip.h"
37#include "northbridge.h"
Kerry Shefeed3292011-08-18 18:03:44 +080038#if CONFIG_AMD_SB_CIMX
39#include <sb_cimx.h>
40#endif
Frank Vibrans39fca802011-02-14 18:35:15 +000041
Frank Vibrans39fca802011-02-14 18:35:15 +000042//#define FX_DEVS NODE_NUMS
43#define FX_DEVS 1
44
45static device_t __f0_dev[FX_DEVS];
46static device_t __f1_dev[FX_DEVS];
47static device_t __f2_dev[FX_DEVS];
48static device_t __f4_dev[FX_DEVS];
Marc Jones8d595692012-03-15 12:55:26 -060049static unsigned fx_devs = 0;
Frank Vibrans39fca802011-02-14 18:35:15 +000050
51device_t get_node_pci(u32 nodeid, u32 fn)
52{
Marc Jones8d595692012-03-15 12:55:26 -060053 return dev_find_slot(CONFIG_CBB, PCI_DEVFN(CONFIG_CDB + nodeid, fn));
Frank Vibrans39fca802011-02-14 18:35:15 +000054}
55
Frank Vibrans39fca802011-02-14 18:35:15 +000056static void get_fx_devs(void)
57{
Marc Jones8d595692012-03-15 12:55:26 -060058 int i;
59 for (i = 0; i < FX_DEVS; i++) {
60 __f0_dev[i] = get_node_pci(i, 0);
61 __f1_dev[i] = get_node_pci(i, 1);
62 __f2_dev[i] = get_node_pci(i, 2);
63 __f4_dev[i] = get_node_pci(i, 4);
64 if (__f0_dev[i] != NULL && __f1_dev[i] != NULL)
65 fx_devs = i + 1;
66 }
67 if (__f1_dev[0] == NULL || __f0_dev[0] == NULL || fx_devs == 0) {
68 die("Cannot find 0:0x18.[0|1]\n");
69 }
Frank Vibrans39fca802011-02-14 18:35:15 +000070}
71
Frank Vibrans39fca802011-02-14 18:35:15 +000072static u32 f1_read_config32(unsigned reg)
73{
Marc Jones8d595692012-03-15 12:55:26 -060074 if (fx_devs == 0)
75 get_fx_devs();
76 return pci_read_config32(__f1_dev[0], reg);
Frank Vibrans39fca802011-02-14 18:35:15 +000077}
78
Frank Vibrans39fca802011-02-14 18:35:15 +000079static void f1_write_config32(unsigned reg, u32 value)
80{
Marc Jones8d595692012-03-15 12:55:26 -060081 int i;
82 if (fx_devs == 0)
83 get_fx_devs();
84 for (i = 0; i < fx_devs; i++) {
85 device_t dev;
86 dev = __f1_dev[i];
87 if (dev && dev->enabled) {
88 pci_write_config32(dev, reg, value);
89 }
90 }
Frank Vibrans39fca802011-02-14 18:35:15 +000091}
92
Frank Vibrans39fca802011-02-14 18:35:15 +000093static u32 amdfam14_nodeid(device_t dev)
94{
Marc Jones8d595692012-03-15 12:55:26 -060095 return (dev->path.pci.devfn >> 3) - CONFIG_CDB;
Frank Vibrans39fca802011-02-14 18:35:15 +000096}
97
Frank Vibrans39fca802011-02-14 18:35:15 +000098#include "amdfam14_conf.c"
99
Frank Vibrans39fca802011-02-14 18:35:15 +0000100static void northbridge_init(device_t dev)
101{
Marc Jones8d595692012-03-15 12:55:26 -0600102 printk(BIOS_DEBUG, "Northbridge init\n");
Frank Vibrans39fca802011-02-14 18:35:15 +0000103}
104
Frank Vibrans39fca802011-02-14 18:35:15 +0000105static void set_vga_enable_reg(u32 nodeid, u32 linkn)
106{
Marc Jones8d595692012-03-15 12:55:26 -0600107 u32 val;
Frank Vibrans39fca802011-02-14 18:35:15 +0000108
Marc Jones8d595692012-03-15 12:55:26 -0600109 val = 1 | (nodeid << 4) | (linkn << 12);
110 /* it will routing (1)mmio 0xa0000:0xbffff (2) io 0x3b0:0x3bb,
111 0x3c0:0x3df */
112 f1_write_config32(0xf4, val);
Frank Vibrans39fca802011-02-14 18:35:15 +0000113
114}
115
Frank Vibrans39fca802011-02-14 18:35:15 +0000116static int reg_useable(unsigned reg, device_t goal_dev, unsigned goal_nodeid,
Marc Jones8d595692012-03-15 12:55:26 -0600117 unsigned goal_link)
Frank Vibrans39fca802011-02-14 18:35:15 +0000118{
Marc Jones8d595692012-03-15 12:55:26 -0600119 struct resource *res;
120 unsigned nodeid, link = 0;
121 int result;
122 res = 0;
123 for (nodeid = 0; !res && (nodeid < fx_devs); nodeid++) {
124 device_t dev;
125 dev = __f0_dev[nodeid];
126 if (!dev)
127 continue;
128 for (link = 0; !res && (link < 8); link++) {
129 res = probe_resource(dev, IOINDEX(0x1000 + reg, link));
130 }
131 }
132 result = 2;
133 if (res) {
134 result = 0;
135 if ((goal_link == (link - 1)) &&
136 (goal_nodeid == (nodeid - 1)) && (res->flags <= 1)) {
137 result = 1;
138 }
139 }
140 return result;
Frank Vibrans39fca802011-02-14 18:35:15 +0000141}
142
Marc Jones8d595692012-03-15 12:55:26 -0600143static struct resource *amdfam14_find_iopair(device_t dev, unsigned nodeid,
144 unsigned link)
Frank Vibrans39fca802011-02-14 18:35:15 +0000145{
Marc Jones8d595692012-03-15 12:55:26 -0600146 struct resource *resource;
147 u32 result, reg;
148 resource = 0;
149 reg = 0;
150 result = reg_useable(0xc0, dev, nodeid, link);
151 if (result >= 1) {
152 /* I have been allocated this one */
153 reg = 0xc0;
154 }
155 /* Ext conf space */
156 if (!reg) {
157 /* Because of Extend conf space, we will never run out of reg,
158 * but we need one index to differ them. So ,same node and same
159 * link can have multi range
160 */
161 u32 index = get_io_addr_index(nodeid, link);
162 reg = 0x110 + (index << 24) + (4 << 20); // index could be 0, 255
163 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000164
Marc Jones8d595692012-03-15 12:55:26 -0600165 resource = new_resource(dev, IOINDEX(0x1000 + reg, link));
Frank Vibrans39fca802011-02-14 18:35:15 +0000166
Marc Jones8d595692012-03-15 12:55:26 -0600167 return resource;
Frank Vibrans39fca802011-02-14 18:35:15 +0000168}
169
Marc Jones8d595692012-03-15 12:55:26 -0600170static struct resource *amdfam14_find_mempair(device_t dev, u32 nodeid,
171 u32 link)
Frank Vibrans39fca802011-02-14 18:35:15 +0000172{
Marc Jones8d595692012-03-15 12:55:26 -0600173 struct resource *resource;
174 u32 free_reg, reg;
175 resource = 0;
176 free_reg = 0;
177 for (reg = 0x80; reg <= 0xb8; reg += 0x8) {
178 int result;
179 result = reg_useable(reg, dev, nodeid, link);
180 if (result == 1) {
181 /* I have been allocated this one */
182 break;
183 } else if (result > 1) {
184 /* I have a free register pair */
185 free_reg = reg;
186 }
187 }
188 if (reg > 0xb8) {
189 reg = free_reg;
190 }
191 /* Ext conf space */
192 if (!reg) {
193 /* Because of Extend conf space, we will never run out of reg,
194 * but we need one index to differ them. So ,same node and same
195 * link can have multi range
196 */
197 u32 index = get_mmio_addr_index(nodeid, link);
198 reg = 0x110 + (index << 24) + (6 << 20); // index could be 0, 63
Frank Vibrans39fca802011-02-14 18:35:15 +0000199
Marc Jones8d595692012-03-15 12:55:26 -0600200 }
201 resource = new_resource(dev, IOINDEX(0x1000 + reg, link));
202 return resource;
Frank Vibrans39fca802011-02-14 18:35:15 +0000203}
204
Frank Vibrans39fca802011-02-14 18:35:15 +0000205static void amdfam14_link_read_bases(device_t dev, u32 nodeid, u32 link)
206{
Marc Jones8d595692012-03-15 12:55:26 -0600207 struct resource *resource;
Frank Vibrans39fca802011-02-14 18:35:15 +0000208
Marc Jones8d595692012-03-15 12:55:26 -0600209 /* Initialize the io space constraints on the current bus */
210 resource = amdfam14_find_iopair(dev, nodeid, link);
211 if (resource) {
212 u32 align;
Patrick Georgie1667822012-05-05 15:29:32 +0200213#if CONFIG_EXT_CONF_SUPPORT
Marc Jones8d595692012-03-15 12:55:26 -0600214 if ((resource->index & 0x1fff) == 0x1110) { // ext
215 align = 8;
216 } else
Frank Vibrans39fca802011-02-14 18:35:15 +0000217#endif
Marc Jones8d595692012-03-15 12:55:26 -0600218 align = log2(HT_IO_HOST_ALIGN);
219 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;
Frank Vibrans39fca802011-02-14 18:35:15 +0000237
Patrick Georgie1667822012-05-05 15:29:32 +0200238#if CONFIG_EXT_CONF_SUPPORT
Marc Jones8d595692012-03-15 12:55:26 -0600239 if ((resource->index & 0x1fff) == 0x1110) { // ext
240 normalize_resource(resource);
241 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000242#endif
243
Marc Jones8d595692012-03-15 12:55:26 -0600244 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000245
Marc Jones8d595692012-03-15 12:55:26 -0600246 /* Initialize the memory constraints on the current bus */
247 resource = amdfam14_find_mempair(dev, nodeid, link);
248 if (resource) {
249 resource->base = 0;
250 resource->size = 0;
251 resource->align = log2(HT_MEM_HOST_ALIGN);
252 resource->gran = log2(HT_MEM_HOST_ALIGN);
253 resource->limit = 0xffffffffffULL;
254 resource->flags = IORESOURCE_MEM | IORESOURCE_BRIDGE;
Patrick Georgie1667822012-05-05 15:29:32 +0200255#if CONFIG_EXT_CONF_SUPPORT
Marc Jones8d595692012-03-15 12:55:26 -0600256 if ((resource->index & 0x1fff) == 0x1110) { // ext
257 normalize_resource(resource);
258 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000259#endif
Marc Jones8d595692012-03-15 12:55:26 -0600260 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000261}
262
263static u32 my_find_pci_tolm(struct bus *bus, u32 tolm)
264{
Marc Jones8d595692012-03-15 12:55:26 -0600265 struct resource *min;
266 min = 0;
267 search_bus_resources(bus, IORESOURCE_MEM, IORESOURCE_MEM, tolm_test,
268 &min);
269 if (min && tolm > min->base) {
270 tolm = min->base;
271 }
272 return tolm;
Frank Vibrans39fca802011-02-14 18:35:15 +0000273}
274
275#if CONFIG_HW_MEM_HOLE_SIZEK != 0
276
277struct hw_mem_hole_info {
Marc Jones8d595692012-03-15 12:55:26 -0600278 unsigned hole_startk;
279 int node_id;
Frank Vibrans39fca802011-02-14 18:35:15 +0000280};
281
282static struct hw_mem_hole_info get_hw_mem_hole_info(void)
283{
Marc Jones8d595692012-03-15 12:55:26 -0600284 struct hw_mem_hole_info mem_hole;
Frank Vibrans39fca802011-02-14 18:35:15 +0000285
Marc Jones8d595692012-03-15 12:55:26 -0600286 mem_hole.hole_startk = CONFIG_HW_MEM_HOLE_SIZEK;
287 mem_hole.node_id = -1;
Frank Vibrans39fca802011-02-14 18:35:15 +0000288
Marc Jones8d595692012-03-15 12:55:26 -0600289 struct dram_base_mask_t d;
290 u32 hole;
291 d = get_dram_base_mask(0);
292 if (d.mask & 1) {
293 hole = pci_read_config32(__f1_dev[0], 0xf0);
294 if (hole & 1) { // we find the hole
295 mem_hole.hole_startk = (hole & (0xff << 24)) >> 10;
296 mem_hole.node_id = 0; // record the node No with hole
297 }
298 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000299#if 0
Marc Jones8d595692012-03-15 12:55:26 -0600300 /* We need to double check if there is speical set on base reg and limit reg
301 * are not continous instead of hole, it will find out it's hole_startk
302 */
303 if (mem_hole.node_id == -1) {
304 resource_t limitk_pri = 0;
305 struct dram_base_mask_t d;
306 resource_t base_k, limit_k;
307 d = get_dram_base_mask(0);
308 if (d.base & 1) {
309 base_k = ((resource_t) (d.base & 0x1fffff00)) << 9;
310 if (base_k <= 4 * 1024 * 1024) {
311 if (limitk_pri != base_k) { // we find the hole
312 mem_hole.hole_startk = (unsigned)limitk_pri; // must be below 4G
313 mem_hole.node_id = 0;
314 }
315 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000316
Marc Jones8d595692012-03-15 12:55:26 -0600317 limit_k =
318 ((resource_t) ((d.mask + 0x00000100) & 0x1fffff00))
319 << 9;
320 limitk_pri = limit_k;
321 }
322 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000323#endif
efdesign9805a89ab2011-06-20 17:38:49 -0700324
Marc Jones8d595692012-03-15 12:55:26 -0600325 return mem_hole;
Frank Vibrans39fca802011-02-14 18:35:15 +0000326}
327#endif
328
Frank Vibrans39fca802011-02-14 18:35:15 +0000329static void read_resources(device_t dev)
330{
Marc Jones8d595692012-03-15 12:55:26 -0600331 u32 nodeid;
332 struct bus *link;
Frank Vibrans39fca802011-02-14 18:35:15 +0000333
Marc Jones8d595692012-03-15 12:55:26 -0600334 printk(BIOS_DEBUG, "\nFam14h - read_resources.\n");
Frank Vibrans39fca802011-02-14 18:35:15 +0000335
Marc Jones8d595692012-03-15 12:55:26 -0600336 nodeid = amdfam14_nodeid(dev);
337 for (link = dev->link_list; link; link = link->next) {
338 if (link->children) {
339 amdfam14_link_read_bases(dev, nodeid, link->link_num);
340 }
341 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000342}
343
Marc Jones8d595692012-03-15 12:55:26 -0600344static void set_resource(device_t dev, struct resource *resource, u32 nodeid)
Frank Vibrans39fca802011-02-14 18:35:15 +0000345{
Marc Jones8d595692012-03-15 12:55:26 -0600346 resource_t rbase, rend;
347 unsigned reg, link_num;
348 char buf[50];
Frank Vibrans39fca802011-02-14 18:35:15 +0000349
Marc Jones8d595692012-03-15 12:55:26 -0600350 printk(BIOS_DEBUG, "\nFam14h - set_resource.\n");
Frank Vibrans39fca802011-02-14 18:35:15 +0000351
Marc Jones8d595692012-03-15 12:55:26 -0600352 /* Make certain the resource has actually been set */
353 if (!(resource->flags & IORESOURCE_ASSIGNED)) {
354 return;
355 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000356
Marc Jones8d595692012-03-15 12:55:26 -0600357 /* If I have already stored this resource don't worry about it */
358 if (resource->flags & IORESOURCE_STORED) {
359 return;
360 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000361
Marc Jones8d595692012-03-15 12:55:26 -0600362 /* Only handle PCI memory and IO resources */
363 if (!(resource->flags & (IORESOURCE_MEM | IORESOURCE_IO)))
364 return;
Frank Vibrans39fca802011-02-14 18:35:15 +0000365
Marc Jones8d595692012-03-15 12:55:26 -0600366 /* Ensure I am actually looking at a resource of function 1 */
367 if ((resource->index & 0xffff) < 0x1000) {
368 return;
369 }
370 /* Get the base address */
371 rbase = resource->base;
Frank Vibrans39fca802011-02-14 18:35:15 +0000372
Marc Jones8d595692012-03-15 12:55:26 -0600373 /* Get the limit (rounded up) */
374 rend = resource_end(resource);
Frank Vibrans39fca802011-02-14 18:35:15 +0000375
Marc Jones8d595692012-03-15 12:55:26 -0600376 /* Get the register and link */
377 reg = resource->index & 0xfff; // 4k
378 link_num = IOINDEX_LINK(resource->index);
Frank Vibrans39fca802011-02-14 18:35:15 +0000379
Marc Jones8d595692012-03-15 12:55:26 -0600380 if (resource->flags & IORESOURCE_IO) {
381 set_io_addr_reg(dev, nodeid, link_num, reg, rbase >> 8,
382 rend >> 8);
383 } else if (resource->flags & IORESOURCE_MEM) {
384 set_mmio_addr_reg(nodeid, link_num, reg, (resource->index >> 24),
385 rbase >> 8, rend >> 8, 1); // [39:8]
386 }
387 resource->flags |= IORESOURCE_STORED;
388 sprintf(buf, " <node %x link %x>", nodeid, link_num);
389 report_resource_stored(dev, resource, buf);
Frank Vibrans39fca802011-02-14 18:35:15 +0000390}
391
efdesign983f5ebd62011-09-14 13:47:17 -0600392#if CONFIG_CONSOLE_VGA_MULTI
Marc Jones8d595692012-03-15 12:55:26 -0600393extern device_t vga_pri; // the primary vga device, defined in device.c
Frank Vibrans39fca802011-02-14 18:35:15 +0000394#endif
395
396static void create_vga_resource(device_t dev, unsigned nodeid)
397{
Marc Jones8d595692012-03-15 12:55:26 -0600398 struct bus *link;
Frank Vibrans39fca802011-02-14 18:35:15 +0000399
Marc Jones8d595692012-03-15 12:55:26 -0600400 printk(BIOS_DEBUG, "\nFam14h - create_vga_resource.\n");
Frank Vibrans39fca802011-02-14 18:35:15 +0000401
Marc Jones8d595692012-03-15 12:55:26 -0600402 /* find out which link the VGA card is connected,
403 * we only deal with the 'first' vga card */
404 for (link = dev->link_list; link; link = link->next) {
405 if (link->bridge_ctrl & PCI_BRIDGE_CTL_VGA) {
efdesign983f5ebd62011-09-14 13:47:17 -0600406#if CONFIG_CONSOLE_VGA_MULTI
Marc Jones8d595692012-03-15 12:55:26 -0600407 printk(BIOS_DEBUG,
408 "VGA: vga_pri bus num = %d bus range [%d,%d]\n",
409 vga_pri->bus->secondary, link->secondary,
410 link->subordinate);
411 /* We need to make sure the vga_pri is under the link */
412 if ((vga_pri->bus->secondary >= link->secondary) &&
413 (vga_pri->bus->secondary <= link->subordinate))
Frank Vibrans39fca802011-02-14 18:35:15 +0000414#endif
Marc Jones8d595692012-03-15 12:55:26 -0600415 break;
416 }
417 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000418
Marc Jones8d595692012-03-15 12:55:26 -0600419 /* no VGA card installed */
420 if (link == NULL)
421 return;
Frank Vibrans39fca802011-02-14 18:35:15 +0000422
Marc Jones8d595692012-03-15 12:55:26 -0600423 printk(BIOS_DEBUG, "VGA: %s (aka node %d) link %d has VGA device\n",
424 dev_path(dev), nodeid, link->link_num);
425 set_vga_enable_reg(nodeid, link->link_num);
Frank Vibrans39fca802011-02-14 18:35:15 +0000426}
427
Frank Vibrans39fca802011-02-14 18:35:15 +0000428static void set_resources(device_t dev)
429{
Marc Jones8d595692012-03-15 12:55:26 -0600430 unsigned nodeid;
431 struct bus *bus;
432 struct resource *res;
Frank Vibrans39fca802011-02-14 18:35:15 +0000433
Marc Jones8d595692012-03-15 12:55:26 -0600434 printk(BIOS_DEBUG, "\nFam14h - set_resources.\n");
efdesign9805a89ab2011-06-20 17:38:49 -0700435
Marc Jones8d595692012-03-15 12:55:26 -0600436 /* Find the nodeid */
437 nodeid = amdfam14_nodeid(dev);
Frank Vibrans39fca802011-02-14 18:35:15 +0000438
Marc Jones8d595692012-03-15 12:55:26 -0600439 create_vga_resource(dev, nodeid);
Frank Vibrans39fca802011-02-14 18:35:15 +0000440
Marc Jones8d595692012-03-15 12:55:26 -0600441 /* Set each resource we have found */
442 for (res = dev->resource_list; res; res = res->next) {
443 set_resource(dev, res, nodeid);
444 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000445
Marc Jones8d595692012-03-15 12:55:26 -0600446 for (bus = dev->link_list; bus; bus = bus->next) {
447 if (bus->children) {
448 assign_resources(bus);
449 }
450 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000451}
452
Frank Vibrans39fca802011-02-14 18:35:15 +0000453/* Domain/Root Complex related code */
454
455static void domain_read_resources(device_t dev)
456{
Marc Jones8d595692012-03-15 12:55:26 -0600457 unsigned reg;
Frank Vibrans39fca802011-02-14 18:35:15 +0000458
Marc Jones8d595692012-03-15 12:55:26 -0600459 printk(BIOS_DEBUG, "\nFam14h - domain_read_resources.\n");
Frank Vibrans39fca802011-02-14 18:35:15 +0000460
Marc Jones8d595692012-03-15 12:55:26 -0600461 /* Find the already assigned resource pairs */
462 get_fx_devs();
463 for (reg = 0x80; reg <= 0xc0; reg += 0x08) {
464 u32 base, limit;
465 base = f1_read_config32(reg);
466 limit = f1_read_config32(reg + 0x04);
467 /* Is this register allocated? */
468 if ((base & 3) != 0) {
469 unsigned nodeid, reg_link;
470 device_t reg_dev;
471 if (reg < 0xc0) { // mmio
472 nodeid = (limit & 0xf) + (base & 0x30);
473 } else { // io
474 nodeid = (limit & 0xf) + ((base >> 4) & 0x30);
475 }
476 reg_link = (limit >> 4) & 7;
477 reg_dev = __f0_dev[nodeid];
478 if (reg_dev) {
479 /* Reserve the resource */
480 struct resource *res;
481 res =
482 new_resource(reg_dev,
483 IOINDEX(0x1000 + reg,
484 reg_link));
485 if (res) {
486 res->flags = 1;
487 }
488 }
489 }
490 }
491 /* FIXME: do we need to check extend conf space?
492 I don't believe that much preset value */
Frank Vibrans39fca802011-02-14 18:35:15 +0000493
Patrick Georgie1667822012-05-05 15:29:32 +0200494#if !CONFIG_PCI_64BIT_PREF_MEM
Marc Jones8d595692012-03-15 12:55:26 -0600495 pci_domain_read_resources(dev);
Frank Vibrans39fca802011-02-14 18:35:15 +0000496#else
Marc Jones8d595692012-03-15 12:55:26 -0600497 struct bus *link;
498 struct resource *resource;
499 for (link = dev->link_list; link; link = link->next) {
500 /* Initialize the system wide io space constraints */
501 resource = new_resource(dev, 0 | (link->link_num << 2));
502 resource->base = 0x400;
503 resource->limit = 0xffffUL;
504 resource->flags = IORESOURCE_IO;
Frank Vibrans39fca802011-02-14 18:35:15 +0000505
Marc Jones8d595692012-03-15 12:55:26 -0600506 /* Initialize the system wide prefetchable memory resources constraints */
507 resource = new_resource(dev, 1 | (link->link_num << 2));
508 resource->limit = 0xfcffffffffULL;
509 resource->flags = IORESOURCE_MEM | IORESOURCE_PREFETCH;
Frank Vibrans39fca802011-02-14 18:35:15 +0000510
Marc Jones8d595692012-03-15 12:55:26 -0600511 /* Initialize the system wide memory resources constraints */
512 resource = new_resource(dev, 2 | (link->link_num << 2));
513 resource->limit = 0xfcffffffffULL;
514 resource->flags = IORESOURCE_MEM;
515 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000516#endif
517}
518
Frank Vibrans39fca802011-02-14 18:35:15 +0000519static void domain_set_resources(device_t dev)
520{
Marc Jones8d595692012-03-15 12:55:26 -0600521 printk(BIOS_DEBUG, "\nFam14h - domain_set_resources.\n");
522 printk(BIOS_DEBUG, " amsr - incoming dev = %08x\n", (u32) dev);
Frank Vibrans39fca802011-02-14 18:35:15 +0000523
Patrick Georgie1667822012-05-05 15:29:32 +0200524#if CONFIG_PCI_64BIT_PREF_MEM
Marc Jones8d595692012-03-15 12:55:26 -0600525 struct resource *io, *mem1, *mem2;
526 struct resource *res;
Frank Vibrans39fca802011-02-14 18:35:15 +0000527#endif
Marc Jones8d595692012-03-15 12:55:26 -0600528 unsigned long mmio_basek;
529 u32 pci_tolm;
530 int idx;
531 struct bus *link;
Frank Vibrans39fca802011-02-14 18:35:15 +0000532#if CONFIG_HW_MEM_HOLE_SIZEK != 0
Marc Jones8d595692012-03-15 12:55:26 -0600533 struct hw_mem_hole_info mem_hole;
534 u32 reset_memhole = 1;
Frank Vibrans39fca802011-02-14 18:35:15 +0000535#endif
536
Patrick Georgie1667822012-05-05 15:29:32 +0200537#if CONFIG_PCI_64BIT_PREF_MEM
Frank Vibrans39fca802011-02-14 18:35:15 +0000538
Marc Jones8d595692012-03-15 12:55:26 -0600539 printk(BIOS_DEBUG, "adsr - CONFIG_PCI_64BIT_PREF_MEM is true.\n");
540 for (link = dev->link_list; link; link = link->next) {
541 /* Now reallocate the pci resources memory with the
542 * highest addresses I can manage.
543 */
544 mem1 = find_resource(dev, 1 | (link->link_num << 2));
545 mem2 = find_resource(dev, 2 | (link->link_num << 2));
Frank Vibrans39fca802011-02-14 18:35:15 +0000546
Marc Jones8d595692012-03-15 12:55:26 -0600547 printk(BIOS_DEBUG,
548 "base1: 0x%08Lx limit1: 0x%08Lx size: 0x%08Lx align: %d\n",
549 (u32) (mem1->base), (u32) (mem1->limit),
550 (u32) (mem1->size), u32) (mem1->align));
551 printk(BIOS_DEBUG,
552 "base2: 0x%08Lx limit2: 0x%08Lx size: 0x%08Lx align: %d\n",
553 (u32) (mem2->base), (u32) (mem2->limit),
554 (u32) (mem2->size), (u32) (mem2->align));
Frank Vibrans39fca802011-02-14 18:35:15 +0000555
Marc Jones8d595692012-03-15 12:55:26 -0600556 /* See if both resources have roughly the same limits */
557 if (((mem1->limit <= 0xffffffff) && (mem2->limit <= 0xffffffff))
558 || ((mem1->limit > 0xffffffff)
559 && (mem2->limit > 0xffffffff))) {
560 /* If so place the one with the most stringent alignment first
561 */
562 if (mem2->align > mem1->align) {
563 struct resource *tmp;
564 tmp = mem1;
565 mem1 = mem2;
566 mem2 = tmp;
567 }
568 /* Now place the memory as high up as it will go */
569 mem2->base = resource_max(mem2);
570 mem1->limit = mem2->base - 1;
571 mem1->base = resource_max(mem1);
572 } else {
573 /* Place the resources as high up as they will go */
574 mem2->base = resource_max(mem2);
575 mem1->base = resource_max(mem1);
576 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000577
Marc Jones8d595692012-03-15 12:55:26 -0600578 printk(BIOS_DEBUG,
579 "base1: 0x%08Lx limit1: 0x%08Lx size: 0x%08Lx align: %d\n",
580 mem1->base, mem1->limit, mem1->size, mem1->align);
581 printk(BIOS_DEBUG,
582 "base2: 0x%08Lx limit2: 0x%08Lx size: 0x%08Lx align: %d\n",
583 mem2->base, mem2->limit, mem2->size, mem2->align);
584 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000585
Marc Jones8d595692012-03-15 12:55:26 -0600586 for (res = &dev->resource_list; res; res = res->next) {
587 res->flags |= IORESOURCE_ASSIGNED;
588 res->flags |= IORESOURCE_STORED;
589 report_resource_stored(dev, res, "");
590 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000591#endif
592
Marc Jones8d595692012-03-15 12:55:26 -0600593 pci_tolm = 0xffffffffUL;
594 for (link = dev->link_list; link; link = link->next) {
595 pci_tolm = my_find_pci_tolm(link, pci_tolm);
596 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000597
Marc Jones8d595692012-03-15 12:55:26 -0600598 // FIXME handle interleaved nodes. If you fix this here, please fix
599 // amdk8, too.
600 mmio_basek = pci_tolm >> 10;
601 /* Round mmio_basek to something the processor can support */
602 mmio_basek &= ~((1 << 6) - 1);
Frank Vibrans39fca802011-02-14 18:35:15 +0000603
Marc Jones8d595692012-03-15 12:55:26 -0600604 // FIXME improve mtrr.c so we don't use up all of the mtrrs with a 64M
605 // MMIO hole. If you fix this here, please fix amdk8, too.
606 /* Round the mmio hole to 64M */
607 mmio_basek &= ~((64 * 1024) - 1);
Frank Vibrans39fca802011-02-14 18:35:15 +0000608
609#if CONFIG_HW_MEM_HOLE_SIZEK != 0
610/* if the hw mem hole is already set in raminit stage, here we will compare
611 * mmio_basek and hole_basek. if mmio_basek is bigger that hole_basek and will
612 * use hole_basek as mmio_basek and we don't need to reset hole.
613 * otherwise We reset the hole to the mmio_basek
614 */
615
Marc Jones8d595692012-03-15 12:55:26 -0600616 mem_hole = get_hw_mem_hole_info();
Frank Vibrans39fca802011-02-14 18:35:15 +0000617
Marc Jones8d595692012-03-15 12:55:26 -0600618 // Use hole_basek as mmio_basek, and we don't need to reset hole anymore
619 if ((mem_hole.node_id != -1) && (mmio_basek > mem_hole.hole_startk)) {
620 mmio_basek = mem_hole.hole_startk;
621 reset_memhole = 0;
622 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000623#endif
624
Marc Jones8d595692012-03-15 12:55:26 -0600625 idx = 0x10;
Frank Vibrans39fca802011-02-14 18:35:15 +0000626
Marc Jones8d595692012-03-15 12:55:26 -0600627 struct dram_base_mask_t d;
628 resource_t basek, limitk, sizek; // 4 1T
Frank Vibrans39fca802011-02-14 18:35:15 +0000629
Marc Jones8d595692012-03-15 12:55:26 -0600630 d = get_dram_base_mask(0);
Frank Vibrans39fca802011-02-14 18:35:15 +0000631
Marc Jones8d595692012-03-15 12:55:26 -0600632 if (d.mask & 1) {
633 basek = ((resource_t) ((u64) d.base)) << 8;
634 limitk = (resource_t) (((u64) d.mask << 8) | 0xFFFFFF);
635 printk(BIOS_DEBUG,
636 "adsr: (before) basek = %llx, limitk = %llx.\n", basek,
637 limitk);
Frank Vibrans39fca802011-02-14 18:35:15 +0000638
Marc Jones8d595692012-03-15 12:55:26 -0600639 /* Convert these values to multiples of 1K for ease of math. */
640 basek >>= 10;
641 limitk >>= 10;
642 sizek = limitk - basek + 1;
Frank Vibrans39fca802011-02-14 18:35:15 +0000643
Marc Jones8d595692012-03-15 12:55:26 -0600644 printk(BIOS_DEBUG,
645 "adsr: (after) basek = %llx, limitk = %llx, sizek = %llx.\n",
646 basek, limitk, sizek);
Frank Vibrans39fca802011-02-14 18:35:15 +0000647
Marc Jones8d595692012-03-15 12:55:26 -0600648 /* see if we need a hole from 0xa0000 to 0xbffff */
649 if ((basek < 640) && (sizek > 768)) {
650 printk(BIOS_DEBUG,"adsr - 0xa0000 to 0xbffff resource.\n");
651 ram_resource(dev, (idx | 0), basek, 640 - basek);
652 idx += 0x10;
653 basek = 768;
654 sizek = limitk - 768;
655 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000656
Marc Jones8d595692012-03-15 12:55:26 -0600657 printk(BIOS_DEBUG,
658 "adsr: mmio_basek=%08lx, basek=%08llx, limitk=%08llx\n",
659 mmio_basek, basek, limitk);
Frank Vibrans39fca802011-02-14 18:35:15 +0000660
Marc Jones8d595692012-03-15 12:55:26 -0600661 /* split the region to accomodate pci memory space */
662 if ((basek < 4 * 1024 * 1024) && (limitk > mmio_basek)) {
663 if (basek <= mmio_basek) {
664 unsigned pre_sizek;
665 pre_sizek = mmio_basek - basek;
666 if (pre_sizek > 0) {
667 ram_resource(dev, idx, basek,
668 pre_sizek);
669 idx += 0x10;
670 sizek -= pre_sizek;
Patrick Georgie1667822012-05-05 15:29:32 +0200671#if CONFIG_WRITE_HIGH_TABLES
Marc Jones8d595692012-03-15 12:55:26 -0600672 if (high_tables_base == 0) {
673 /* Leave some space for ACPI, PIRQ and MP tables */
Patrick Georgie1667822012-05-05 15:29:32 +0200674#if CONFIG_GFXUMA
Marc Jones5750ed22012-03-15 13:21:41 -0600675 high_tables_base = uma_memory_base - HIGH_MEMORY_SIZE;
Frank Vibrans39fca802011-02-14 18:35:15 +0000676#else
Marc Jones5750ed22012-03-15 13:21:41 -0600677 high_tables_base = (mmio_basek * 1024) - HIGH_MEMORY_SIZE;
Frank Vibrans39fca802011-02-14 18:35:15 +0000678#endif
Marc Jones5750ed22012-03-15 13:21:41 -0600679 high_tables_size = HIGH_MEMORY_SIZE;
680 printk(BIOS_DEBUG, " split: %dK table at =%08llx\n",
681 (u32)(high_tables_size / 1024), high_tables_base);
Marc Jones8d595692012-03-15 12:55:26 -0600682 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000683#endif
Marc Jones8d595692012-03-15 12:55:26 -0600684 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000685
Marc Jones8d595692012-03-15 12:55:26 -0600686 basek = mmio_basek;
687 }
688 if ((basek + sizek) <= 4 * 1024 * 1024) {
689 sizek = 0;
690 } else {
691 basek = 4 * 1024 * 1024;
692 sizek -= (4 * 1024 * 1024 - mmio_basek);
693 }
694 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000695
Marc Jones8d595692012-03-15 12:55:26 -0600696 ram_resource(dev, (idx | 0), basek, sizek);
697 idx += 0x10;
Patrick Georgie1667822012-05-05 15:29:32 +0200698#if CONFIG_WRITE_HIGH_TABLES
Marc Jones8d595692012-03-15 12:55:26 -0600699 printk(BIOS_DEBUG,
700 "%d: mmio_basek=%08lx, basek=%08llx, limitk=%08llx\n", 0,
701 mmio_basek, basek, limitk);
702 if (high_tables_base == 0) {
703 /* Leave some space for ACPI, PIRQ and MP tables */
Patrick Georgie1667822012-05-05 15:29:32 +0200704#if CONFIG_GFXUMA
Marc Jones5750ed22012-03-15 13:21:41 -0600705 high_tables_base = uma_memory_base - HIGH_MEMORY_SIZE;
Marc Jones8d595692012-03-15 12:55:26 -0600706 printk(BIOS_DEBUG, " adsr - uma_memory_base = %llx.\n", uma_memory_base);
Frank Vibrans39fca802011-02-14 18:35:15 +0000707#else
Marc Jones5750ed22012-03-15 13:21:41 -0600708 high_tables_base = (limitk * 1024) - HIGH_MEMORY_SIZE;
Frank Vibrans39fca802011-02-14 18:35:15 +0000709#endif
Marc Jones5750ed22012-03-15 13:21:41 -0600710 high_tables_size = HIGH_MEMORY_SIZE;
Marc Jones8d595692012-03-15 12:55:26 -0600711 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000712#endif
Marc Jones8d595692012-03-15 12:55:26 -0600713 }
714 printk(BIOS_DEBUG, " adsr - mmio_basek = %lx.\n", mmio_basek);
715 printk(BIOS_DEBUG, " adsr - high_tables_size = %llx.\n",
716 high_tables_size);
Frank Vibrans39fca802011-02-14 18:35:15 +0000717
Patrick Georgie1667822012-05-05 15:29:32 +0200718#if CONFIG_GFXUMA
Kyösti Mälkki63f8c082012-07-10 13:27:26 +0300719 uma_resource(dev, 7, uma_memory_base >> 10, uma_memory_size >> 10);
Frank Vibrans39fca802011-02-14 18:35:15 +0000720#endif
721
Marc Jones8d595692012-03-15 12:55:26 -0600722 for (link = dev->link_list; link; link = link->next) {
723 if (link->children) {
724 assign_resources(link);
725 }
726 }
727 printk(BIOS_DEBUG, " adsr - leaving this lovely routine.\n");
Frank Vibrans39fca802011-02-14 18:35:15 +0000728}
729
zbaof7223732012-04-13 13:42:15 +0800730extern u8 acpi_slp_type;
731
732static void domain_enable_resources(device_t dev)
733{
Marc Jones8d595692012-03-15 12:55:26 -0600734 u32 val;
Kerry Shefeed3292011-08-18 18:03:44 +0800735
736#if CONFIG_AMD_SB_CIMX
zbaof7223732012-04-13 13:42:15 +0800737 #if CONFIG_HAVE_ACPI_RESUME
738 if (acpi_slp_type != 3) {
739 sb_After_Pci_Init();
740 sb_Mid_Post_Init();
741 } else {
742 sb_After_Pci_Restore_Init();
743 }
744 #else
Marc Jones8d595692012-03-15 12:55:26 -0600745 sb_After_Pci_Init();
746 sb_Mid_Post_Init();
zbaof7223732012-04-13 13:42:15 +0800747 #endif
Kerry Shefeed3292011-08-18 18:03:44 +0800748#endif
749
Marc Jones8d595692012-03-15 12:55:26 -0600750 /* Must be called after PCI enumeration and resource allocation */
751 printk(BIOS_DEBUG, "\nFam14h - domain_enable_resources: AmdInitMid.\n");
zbaof7223732012-04-13 13:42:15 +0800752
753#if CONFIG_HAVE_ACPI_RESUME
754 if (acpi_slp_type != 3) {
755 printk(BIOS_DEBUG, "agesawrapper_amdinitmid ");
756 val = agesawrapper_amdinitmid ();
757 if (val)
758 printk(BIOS_DEBUG, "error level: %x \n", val);
759 else
760 printk(BIOS_DEBUG, "passed.\n");
Marc Jones8d595692012-03-15 12:55:26 -0600761 }
zbaof7223732012-04-13 13:42:15 +0800762#else
763 printk(BIOS_DEBUG, "agesawrapper_amdinitmid ");
764 val = agesawrapper_amdinitmid ();
765 if (val)
766 printk(BIOS_DEBUG, "error level: %x \n", val);
767 else
768 printk(BIOS_DEBUG, "passed.\n");
769#endif
efdesign9805a89ab2011-06-20 17:38:49 -0700770
Marc Jones8d595692012-03-15 12:55:26 -0600771 printk(BIOS_DEBUG, " ader - leaving domain_enable_resources.\n");
Frank Vibrans39fca802011-02-14 18:35:15 +0000772}
773
Frank Vibrans39fca802011-02-14 18:35:15 +0000774/* Bus related code */
775
Marc Jones8d595692012-03-15 12:55:26 -0600776static void cpu_bus_read_resources(device_t dev) {
777 printk(BIOS_DEBUG, "\nFam14h - cpu_bus_read_resources.\n");
Frank Vibrans39fca802011-02-14 18:35:15 +0000778
779#if CONFIG_MMCONF_SUPPORT
Marc Jones8d595692012-03-15 12:55:26 -0600780 struct resource *resource = new_resource(dev, 0xc0010058);
781 resource->base = CONFIG_MMCONF_BASE_ADDRESS;
782 resource->size = CONFIG_MMCONF_BUS_NUMBER * 4096 * 256;
783 resource->flags = IORESOURCE_MEM | IORESOURCE_RESERVE |
784 IORESOURCE_FIXED | IORESOURCE_STORED | IORESOURCE_ASSIGNED;
Frank Vibrans39fca802011-02-14 18:35:15 +0000785#endif
786}
787
Marc Jones8d595692012-03-15 12:55:26 -0600788static void cpu_bus_set_resources(device_t dev) {
789 struct resource *resource = find_resource(dev, 0xc0010058);
Frank Vibrans39fca802011-02-14 18:35:15 +0000790
Marc Jones8d595692012-03-15 12:55:26 -0600791 printk(BIOS_DEBUG, "\nFam14h - cpu_bus_set_resources.\n");
Frank Vibrans39fca802011-02-14 18:35:15 +0000792
Marc Jones8d595692012-03-15 12:55:26 -0600793 if (resource) {
794 report_resource_stored(dev, resource, " <mmconfig>");
795 }
796 pci_dev_set_resources(dev);
Frank Vibrans39fca802011-02-14 18:35:15 +0000797}
efdesign9805a89ab2011-06-20 17:38:49 -0700798
zbaof7223732012-04-13 13:42:15 +0800799static u32 cpu_bus_scan(device_t dev, u32 max)
800{
Scott Duplichan9ab3c6c2011-05-15 21:45:46 +0000801 device_t cpu;
zbaof7223732012-04-13 13:42:15 +0800802 struct device_path cpu_path;
803 int apic_id, cores_found;
Scott Duplichan9ab3c6c2011-05-15 21:45:46 +0000804
zbaof7223732012-04-13 13:42:15 +0800805 /* There is only one node for fam14, but there may be multiple cores. */
806 cpu = dev_find_slot(0, PCI_DEVFN(0x18, 0));
807 if (!cpu)
808 printk(BIOS_ERR, "ERROR: %02x:%02x.0 not found", 0, 0x18);
Scott Duplichan9ab3c6c2011-05-15 21:45:46 +0000809
zbaof7223732012-04-13 13:42:15 +0800810 cores_found = (pci_read_config32(dev_find_slot(0,PCI_DEVFN(0x18,0x3)), 0xe8) >> 12) & 3;
811 printk(BIOS_DEBUG, " AP siblings=%d\n", cores_found);
812
813
814 for (apic_id = 0; apic_id <= cores_found; apic_id++) {
Marc Jones8d595692012-03-15 12:55:26 -0600815 cpu_path.type = DEVICE_PATH_APIC;
816 cpu_path.apic.apic_id = apic_id;
zbaof7223732012-04-13 13:42:15 +0800817 cpu = alloc_find_dev(dev->link_list, &cpu_path);
818 if (cpu) {
819 cpu->enabled = 1;
820 cpu->path.apic.node_id = 0;
821 cpu->path.apic.core_id = apic_id;
822 printk(BIOS_DEBUG, "CPU: %s %s\n",
823 dev_path(cpu), cpu->enabled?"enabled":"disabled");
824 } else {
825 cpu->enabled = 0;
826 }
Marc Jones8d595692012-03-15 12:55:26 -0600827 }
zbaof7223732012-04-13 13:42:15 +0800828 return max;
829}
830
831static void cpu_bus_init(device_t dev)
832{
833 initialize_cpus(dev->link_list);
Frank Vibrans39fca802011-02-14 18:35:15 +0000834}
835
Frank Vibrans39fca802011-02-14 18:35:15 +0000836/* North Bridge Structures */
837
838static struct device_operations northbridge_operations = {
Marc Jones8d595692012-03-15 12:55:26 -0600839 .read_resources = read_resources,
840 .set_resources = set_resources,
841 .enable_resources = pci_dev_enable_resources,
842 .init = northbridge_init,
843 .enable = 0,.ops_pci = 0,
Frank Vibrans39fca802011-02-14 18:35:15 +0000844};
845
Frank Vibrans39fca802011-02-14 18:35:15 +0000846static const struct pci_driver northbridge_driver __pci_driver = {
Marc Jones8d595692012-03-15 12:55:26 -0600847 .ops = &northbridge_operations,
848 .vendor = PCI_VENDOR_ID_AMD,
849 .device = 0x1510,
Frank Vibrans39fca802011-02-14 18:35:15 +0000850};
851
efdesign9805a89ab2011-06-20 17:38:49 -0700852struct chip_operations northbridge_amd_agesa_family14_ops = {
Marc Jones8d595692012-03-15 12:55:26 -0600853 CHIP_NAME("AMD Family 14h Northbridge")
854 .enable_dev = 0,
Frank Vibrans39fca802011-02-14 18:35:15 +0000855};
856
Frank Vibrans39fca802011-02-14 18:35:15 +0000857/* Root Complex Structures */
858
Frank Vibrans39fca802011-02-14 18:35:15 +0000859static struct device_operations pci_domain_ops = {
Marc Jones8d595692012-03-15 12:55:26 -0600860 .read_resources = domain_read_resources,
861 .set_resources = domain_set_resources,
862 .enable_resources = domain_enable_resources,
863 .init = NULL,
864 .scan_bus = pci_domain_scan_bus,
Frank Vibrans39fca802011-02-14 18:35:15 +0000865};
866
Frank Vibrans39fca802011-02-14 18:35:15 +0000867static struct device_operations cpu_bus_ops = {
Marc Jones8d595692012-03-15 12:55:26 -0600868 .read_resources = cpu_bus_read_resources,
869 .set_resources = cpu_bus_set_resources,
870 .enable_resources = NULL,
871 .init = cpu_bus_init,
zbaof7223732012-04-13 13:42:15 +0800872 .scan_bus = cpu_bus_scan,
Frank Vibrans39fca802011-02-14 18:35:15 +0000873};
874
Marc Jones8d595692012-03-15 12:55:26 -0600875static void root_complex_enable_dev(struct device *dev) {
876 /* Set the operations if it is a special bus type */
877 if (dev->path.type == DEVICE_PATH_PCI_DOMAIN) {
878 dev->ops = &pci_domain_ops;
879 } else if (dev->path.type == DEVICE_PATH_APIC_CLUSTER) {
880 dev->ops = &cpu_bus_ops;
881 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000882}
883
efdesign9805a89ab2011-06-20 17:38:49 -0700884struct chip_operations northbridge_amd_agesa_family14_root_complex_ops = {
Marc Jones8d595692012-03-15 12:55:26 -0600885 CHIP_NAME("AMD Family 14h Root Complex")
886 .enable_dev = root_complex_enable_dev,
Frank Vibrans39fca802011-02-14 18:35:15 +0000887};