blob: 75ea76d5f6edc90351da9874e17907a4f03c0d64 [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
Paul Menzela46a7122013-02-23 18:37:27 +010017 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Frank Vibrans39fca802011-02-14 18:35:15 +000018 */
19
20#include <console/console.h>
21#include <arch/io.h>
Kyösti Mälkki8ae16a42014-06-19 20:44:34 +030022#include <arch/acpi.h>
Frank Vibrans39fca802011-02-14 18:35:15 +000023#include <stdint.h>
24#include <device/device.h>
25#include <device/pci.h>
26#include <device/pci_ids.h>
27#include <device/hypertransport.h>
28#include <stdlib.h>
29#include <string.h>
Ronald G. Minnich5079a0d2012-11-27 11:32:38 -080030#include <lib.h>
Frank Vibrans39fca802011-02-14 18:35:15 +000031#include <cpu/cpu.h>
Marc Jones5750ed22012-03-15 13:21:41 -060032#include <cbmem.h>
Frank Vibrans39fca802011-02-14 18:35:15 +000033
34#include <cpu/x86/lapic.h>
Kyösti Mälkki55fff9302012-07-11 08:02:39 +030035#include <cpu/amd/mtrr.h>
Frank Vibrans39fca802011-02-14 18:35:15 +000036
efdesign983f5ebd62011-09-14 13:47:17 -060037#include "agesawrapper.h"
Frank Vibrans39fca802011-02-14 18:35:15 +000038#include "northbridge.h"
Kerry Shefeed3292011-08-18 18:03:44 +080039#if CONFIG_AMD_SB_CIMX
40#include <sb_cimx.h>
41#endif
Frank Vibrans39fca802011-02-14 18:35:15 +000042
Frank Vibrans39fca802011-02-14 18:35:15 +000043//#define FX_DEVS NODE_NUMS
44#define FX_DEVS 1
45
46static device_t __f0_dev[FX_DEVS];
47static device_t __f1_dev[FX_DEVS];
48static device_t __f2_dev[FX_DEVS];
49static device_t __f4_dev[FX_DEVS];
Marc Jones8d595692012-03-15 12:55:26 -060050static unsigned fx_devs = 0;
Frank Vibrans39fca802011-02-14 18:35:15 +000051
52device_t get_node_pci(u32 nodeid, u32 fn)
53{
zbao49bb26a42012-08-03 15:44:42 +080054 if ((CONFIG_CDB + nodeid) < 32) {
55 return dev_find_slot(CONFIG_CBB, PCI_DEVFN(CONFIG_CDB + nodeid, fn));
56 } else {
57 return dev_find_slot(CONFIG_CBB-1, PCI_DEVFN(CONFIG_CDB + nodeid - 32, fn));
58 }
Frank Vibrans39fca802011-02-14 18:35:15 +000059}
60
Frank Vibrans39fca802011-02-14 18:35:15 +000061static void get_fx_devs(void)
62{
Marc Jones8d595692012-03-15 12:55:26 -060063 int i;
64 for (i = 0; i < FX_DEVS; i++) {
65 __f0_dev[i] = get_node_pci(i, 0);
66 __f1_dev[i] = get_node_pci(i, 1);
67 __f2_dev[i] = get_node_pci(i, 2);
68 __f4_dev[i] = get_node_pci(i, 4);
69 if (__f0_dev[i] != NULL && __f1_dev[i] != NULL)
70 fx_devs = i + 1;
71 }
72 if (__f1_dev[0] == NULL || __f0_dev[0] == NULL || fx_devs == 0) {
73 die("Cannot find 0:0x18.[0|1]\n");
74 }
Frank Vibrans39fca802011-02-14 18:35:15 +000075}
76
Frank Vibrans39fca802011-02-14 18:35:15 +000077static u32 f1_read_config32(unsigned reg)
78{
Marc Jones8d595692012-03-15 12:55:26 -060079 if (fx_devs == 0)
80 get_fx_devs();
81 return pci_read_config32(__f1_dev[0], reg);
Frank Vibrans39fca802011-02-14 18:35:15 +000082}
83
Frank Vibrans39fca802011-02-14 18:35:15 +000084static void f1_write_config32(unsigned reg, u32 value)
85{
Marc Jones8d595692012-03-15 12:55:26 -060086 int i;
87 if (fx_devs == 0)
88 get_fx_devs();
89 for (i = 0; i < fx_devs; i++) {
90 device_t dev;
91 dev = __f1_dev[i];
92 if (dev && dev->enabled) {
93 pci_write_config32(dev, reg, value);
94 }
95 }
Frank Vibrans39fca802011-02-14 18:35:15 +000096}
97
Frank Vibrans39fca802011-02-14 18:35:15 +000098static u32 amdfam14_nodeid(device_t dev)
99{
Marc Jones8d595692012-03-15 12:55:26 -0600100 return (dev->path.pci.devfn >> 3) - CONFIG_CDB;
Frank Vibrans39fca802011-02-14 18:35:15 +0000101}
102
Frank Vibrans39fca802011-02-14 18:35:15 +0000103#include "amdfam14_conf.c"
104
Frank Vibrans39fca802011-02-14 18:35:15 +0000105static void northbridge_init(device_t dev)
106{
Marc Jones8d595692012-03-15 12:55:26 -0600107 printk(BIOS_DEBUG, "Northbridge init\n");
Frank Vibrans39fca802011-02-14 18:35:15 +0000108}
109
Frank Vibrans39fca802011-02-14 18:35:15 +0000110static void set_vga_enable_reg(u32 nodeid, u32 linkn)
111{
Marc Jones8d595692012-03-15 12:55:26 -0600112 u32 val;
Frank Vibrans39fca802011-02-14 18:35:15 +0000113
Marc Jones8d595692012-03-15 12:55:26 -0600114 val = 1 | (nodeid << 4) | (linkn << 12);
115 /* it will routing (1)mmio 0xa0000:0xbffff (2) io 0x3b0:0x3bb,
116 0x3c0:0x3df */
117 f1_write_config32(0xf4, val);
Frank Vibrans39fca802011-02-14 18:35:15 +0000118
119}
120
Frank Vibrans39fca802011-02-14 18:35:15 +0000121static int reg_useable(unsigned reg, device_t goal_dev, unsigned goal_nodeid,
Marc Jones8d595692012-03-15 12:55:26 -0600122 unsigned goal_link)
Frank Vibrans39fca802011-02-14 18:35:15 +0000123{
Marc Jones8d595692012-03-15 12:55:26 -0600124 struct resource *res;
125 unsigned nodeid, link = 0;
126 int result;
127 res = 0;
128 for (nodeid = 0; !res && (nodeid < fx_devs); nodeid++) {
129 device_t dev;
130 dev = __f0_dev[nodeid];
131 if (!dev)
132 continue;
133 for (link = 0; !res && (link < 8); link++) {
134 res = probe_resource(dev, IOINDEX(0x1000 + reg, link));
135 }
136 }
137 result = 2;
138 if (res) {
139 result = 0;
140 if ((goal_link == (link - 1)) &&
141 (goal_nodeid == (nodeid - 1)) && (res->flags <= 1)) {
142 result = 1;
143 }
144 }
145 return result;
Frank Vibrans39fca802011-02-14 18:35:15 +0000146}
147
Marc Jones8d595692012-03-15 12:55:26 -0600148static struct resource *amdfam14_find_iopair(device_t dev, unsigned nodeid,
149 unsigned link)
Frank Vibrans39fca802011-02-14 18:35:15 +0000150{
Marc Jones8d595692012-03-15 12:55:26 -0600151 struct resource *resource;
152 u32 result, reg;
153 resource = 0;
154 reg = 0;
155 result = reg_useable(0xc0, dev, nodeid, link);
156 if (result >= 1) {
157 /* I have been allocated this one */
158 reg = 0xc0;
159 }
160 /* Ext conf space */
161 if (!reg) {
162 /* Because of Extend conf space, we will never run out of reg,
163 * but we need one index to differ them. So ,same node and same
164 * link can have multi range
165 */
166 u32 index = get_io_addr_index(nodeid, link);
167 reg = 0x110 + (index << 24) + (4 << 20); // index could be 0, 255
168 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000169
Marc Jones8d595692012-03-15 12:55:26 -0600170 resource = new_resource(dev, IOINDEX(0x1000 + reg, link));
Frank Vibrans39fca802011-02-14 18:35:15 +0000171
Marc Jones8d595692012-03-15 12:55:26 -0600172 return resource;
Frank Vibrans39fca802011-02-14 18:35:15 +0000173}
174
Marc Jones8d595692012-03-15 12:55:26 -0600175static struct resource *amdfam14_find_mempair(device_t dev, u32 nodeid,
176 u32 link)
Frank Vibrans39fca802011-02-14 18:35:15 +0000177{
Marc Jones8d595692012-03-15 12:55:26 -0600178 struct resource *resource;
179 u32 free_reg, reg;
180 resource = 0;
181 free_reg = 0;
182 for (reg = 0x80; reg <= 0xb8; reg += 0x8) {
183 int result;
184 result = reg_useable(reg, dev, nodeid, link);
185 if (result == 1) {
186 /* I have been allocated this one */
187 break;
188 } else if (result > 1) {
189 /* I have a free register pair */
190 free_reg = reg;
191 }
192 }
193 if (reg > 0xb8) {
194 reg = free_reg;
195 }
196 /* Ext conf space */
197 if (!reg) {
198 /* Because of Extend conf space, we will never run out of reg,
199 * but we need one index to differ them. So ,same node and same
200 * link can have multi range
201 */
202 u32 index = get_mmio_addr_index(nodeid, link);
203 reg = 0x110 + (index << 24) + (6 << 20); // index could be 0, 63
Frank Vibrans39fca802011-02-14 18:35:15 +0000204
Marc Jones8d595692012-03-15 12:55:26 -0600205 }
206 resource = new_resource(dev, IOINDEX(0x1000 + reg, link));
207 return resource;
Frank Vibrans39fca802011-02-14 18:35:15 +0000208}
209
Frank Vibrans39fca802011-02-14 18:35:15 +0000210static void amdfam14_link_read_bases(device_t dev, u32 nodeid, u32 link)
211{
Marc Jones8d595692012-03-15 12:55:26 -0600212 struct resource *resource;
Frank Vibrans39fca802011-02-14 18:35:15 +0000213
Marc Jones8d595692012-03-15 12:55:26 -0600214 /* Initialize the io space constraints on the current bus */
215 resource = amdfam14_find_iopair(dev, nodeid, link);
216 if (resource) {
217 u32 align;
Patrick Georgie1667822012-05-05 15:29:32 +0200218#if CONFIG_EXT_CONF_SUPPORT
Marc Jones8d595692012-03-15 12:55:26 -0600219 if ((resource->index & 0x1fff) == 0x1110) { // ext
220 align = 8;
221 } else
Frank Vibrans39fca802011-02-14 18:35:15 +0000222#endif
Marc Jones8d595692012-03-15 12:55:26 -0600223 align = log2(HT_IO_HOST_ALIGN);
224 resource->base = 0;
225 resource->size = 0;
226 resource->align = align;
227 resource->gran = align;
228 resource->limit = 0xffffUL;
229 resource->flags = IORESOURCE_IO | IORESOURCE_BRIDGE;
230 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000231
Marc Jones8d595692012-03-15 12:55:26 -0600232 /* Initialize the prefetchable memory constraints on the current bus */
233 resource = amdfam14_find_mempair(dev, nodeid, link);
234 if (resource) {
235 resource->base = 0;
236 resource->size = 0;
237 resource->align = log2(HT_MEM_HOST_ALIGN);
238 resource->gran = log2(HT_MEM_HOST_ALIGN);
239 resource->limit = 0xffffffffffULL;
240 resource->flags = IORESOURCE_MEM | IORESOURCE_PREFETCH;
241 resource->flags |= IORESOURCE_BRIDGE;
Frank Vibrans39fca802011-02-14 18:35:15 +0000242
Patrick Georgie1667822012-05-05 15:29:32 +0200243#if CONFIG_EXT_CONF_SUPPORT
Marc Jones8d595692012-03-15 12:55:26 -0600244 if ((resource->index & 0x1fff) == 0x1110) { // ext
245 normalize_resource(resource);
246 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000247#endif
248
Marc Jones8d595692012-03-15 12:55:26 -0600249 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000250
Marc Jones8d595692012-03-15 12:55:26 -0600251 /* Initialize the memory constraints on the current bus */
252 resource = amdfam14_find_mempair(dev, nodeid, link);
253 if (resource) {
254 resource->base = 0;
255 resource->size = 0;
256 resource->align = log2(HT_MEM_HOST_ALIGN);
257 resource->gran = log2(HT_MEM_HOST_ALIGN);
258 resource->limit = 0xffffffffffULL;
259 resource->flags = IORESOURCE_MEM | IORESOURCE_BRIDGE;
Patrick Georgie1667822012-05-05 15:29:32 +0200260#if CONFIG_EXT_CONF_SUPPORT
Marc Jones8d595692012-03-15 12:55:26 -0600261 if ((resource->index & 0x1fff) == 0x1110) { // ext
262 normalize_resource(resource);
263 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000264#endif
Marc Jones8d595692012-03-15 12:55:26 -0600265 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000266}
267
268static u32 my_find_pci_tolm(struct bus *bus, u32 tolm)
269{
Marc Jones8d595692012-03-15 12:55:26 -0600270 struct resource *min;
271 min = 0;
272 search_bus_resources(bus, IORESOURCE_MEM, IORESOURCE_MEM, tolm_test,
273 &min);
274 if (min && tolm > min->base) {
275 tolm = min->base;
276 }
277 return tolm;
Frank Vibrans39fca802011-02-14 18:35:15 +0000278}
279
280#if CONFIG_HW_MEM_HOLE_SIZEK != 0
281
282struct hw_mem_hole_info {
Marc Jones8d595692012-03-15 12:55:26 -0600283 unsigned hole_startk;
284 int node_id;
Frank Vibrans39fca802011-02-14 18:35:15 +0000285};
286
287static struct hw_mem_hole_info get_hw_mem_hole_info(void)
288{
Marc Jones8d595692012-03-15 12:55:26 -0600289 struct hw_mem_hole_info mem_hole;
Frank Vibrans39fca802011-02-14 18:35:15 +0000290
Marc Jones8d595692012-03-15 12:55:26 -0600291 mem_hole.hole_startk = CONFIG_HW_MEM_HOLE_SIZEK;
292 mem_hole.node_id = -1;
Frank Vibrans39fca802011-02-14 18:35:15 +0000293
Marc Jones8d595692012-03-15 12:55:26 -0600294 struct dram_base_mask_t d;
295 u32 hole;
296 d = get_dram_base_mask(0);
297 if (d.mask & 1) {
298 hole = pci_read_config32(__f1_dev[0], 0xf0);
299 if (hole & 1) { // we find the hole
300 mem_hole.hole_startk = (hole & (0xff << 24)) >> 10;
301 mem_hole.node_id = 0; // record the node No with hole
302 }
303 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000304#if 0
Marc Jones8d595692012-03-15 12:55:26 -0600305 /* We need to double check if there is speical set on base reg and limit reg
306 * are not continous instead of hole, it will find out it's hole_startk
307 */
308 if (mem_hole.node_id == -1) {
309 resource_t limitk_pri = 0;
310 struct dram_base_mask_t d;
311 resource_t base_k, limit_k;
312 d = get_dram_base_mask(0);
313 if (d.base & 1) {
314 base_k = ((resource_t) (d.base & 0x1fffff00)) << 9;
315 if (base_k <= 4 * 1024 * 1024) {
316 if (limitk_pri != base_k) { // we find the hole
317 mem_hole.hole_startk = (unsigned)limitk_pri; // must be below 4G
318 mem_hole.node_id = 0;
319 }
320 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000321
Marc Jones8d595692012-03-15 12:55:26 -0600322 limit_k =
323 ((resource_t) ((d.mask + 0x00000100) & 0x1fffff00))
324 << 9;
325 limitk_pri = limit_k;
326 }
327 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000328#endif
efdesign9805a89ab2011-06-20 17:38:49 -0700329
Marc Jones8d595692012-03-15 12:55:26 -0600330 return mem_hole;
Frank Vibrans39fca802011-02-14 18:35:15 +0000331}
332#endif
333
Marc Jones8a49ac72013-01-16 17:02:20 -0700334static void nb_read_resources(device_t dev)
Frank Vibrans39fca802011-02-14 18:35:15 +0000335{
Marc Jones8d595692012-03-15 12:55:26 -0600336 u32 nodeid;
337 struct bus *link;
Frank Vibrans39fca802011-02-14 18:35:15 +0000338
Mike Loptien58089e82013-01-29 15:45:09 -0700339 printk(BIOS_DEBUG, "\nFam14h - %s\n", __func__);
Frank Vibrans39fca802011-02-14 18:35:15 +0000340
Marc Jones8d595692012-03-15 12:55:26 -0600341 nodeid = amdfam14_nodeid(dev);
342 for (link = dev->link_list; link; link = link->next) {
343 if (link->children) {
344 amdfam14_link_read_bases(dev, nodeid, link->link_num);
345 }
346 }
Marc Jonesd5c998b2013-01-16 17:14:24 -0700347
348 /*
Stefan Reinauer4aff4452013-02-12 14:17:15 -0800349 * This MMCONF resource must be reserved in the PCI domain.
Marc Jonesd5c998b2013-01-16 17:14:24 -0700350 * It is not honored by the coreboot resource allocator if it is in
Stefan Reinauer0aa37c42013-02-12 15:20:54 -0800351 * the CPU_CLUSTER.
Marc Jonesd5c998b2013-01-16 17:14:24 -0700352 */
353#if CONFIG_MMCONF_SUPPORT
354 struct resource *resource = new_resource(dev, 0xc0010058);
355 resource->base = CONFIG_MMCONF_BASE_ADDRESS;
356 resource->size = CONFIG_MMCONF_BUS_NUMBER * 4096 * 256;
357 resource->flags = IORESOURCE_MEM | IORESOURCE_RESERVE |
358 IORESOURCE_FIXED | IORESOURCE_STORED | IORESOURCE_ASSIGNED;
359#endif
Frank Vibrans39fca802011-02-14 18:35:15 +0000360}
361
Marc Jones8d595692012-03-15 12:55:26 -0600362static void set_resource(device_t dev, struct resource *resource, u32 nodeid)
Frank Vibrans39fca802011-02-14 18:35:15 +0000363{
Marc Jones8d595692012-03-15 12:55:26 -0600364 resource_t rbase, rend;
365 unsigned reg, link_num;
366 char buf[50];
Frank Vibrans39fca802011-02-14 18:35:15 +0000367
Mike Loptien58089e82013-01-29 15:45:09 -0700368 printk(BIOS_DEBUG, "\nFam14h - %s\n", __func__);
Frank Vibrans39fca802011-02-14 18:35:15 +0000369
Marc Jones8d595692012-03-15 12:55:26 -0600370 /* Make certain the resource has actually been set */
371 if (!(resource->flags & IORESOURCE_ASSIGNED)) {
372 return;
373 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000374
Marc Jones8d595692012-03-15 12:55:26 -0600375 /* If I have already stored this resource don't worry about it */
376 if (resource->flags & IORESOURCE_STORED) {
377 return;
378 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000379
Marc Jones8d595692012-03-15 12:55:26 -0600380 /* Only handle PCI memory and IO resources */
381 if (!(resource->flags & (IORESOURCE_MEM | IORESOURCE_IO)))
382 return;
Frank Vibrans39fca802011-02-14 18:35:15 +0000383
Marc Jones8d595692012-03-15 12:55:26 -0600384 /* Ensure I am actually looking at a resource of function 1 */
385 if ((resource->index & 0xffff) < 0x1000) {
386 return;
387 }
388 /* Get the base address */
389 rbase = resource->base;
Frank Vibrans39fca802011-02-14 18:35:15 +0000390
Marc Jones8d595692012-03-15 12:55:26 -0600391 /* Get the limit (rounded up) */
392 rend = resource_end(resource);
Frank Vibrans39fca802011-02-14 18:35:15 +0000393
Marc Jones8d595692012-03-15 12:55:26 -0600394 /* Get the register and link */
395 reg = resource->index & 0xfff; // 4k
396 link_num = IOINDEX_LINK(resource->index);
Frank Vibrans39fca802011-02-14 18:35:15 +0000397
Marc Jones8d595692012-03-15 12:55:26 -0600398 if (resource->flags & IORESOURCE_IO) {
399 set_io_addr_reg(dev, nodeid, link_num, reg, rbase >> 8,
400 rend >> 8);
401 } else if (resource->flags & IORESOURCE_MEM) {
402 set_mmio_addr_reg(nodeid, link_num, reg, (resource->index >> 24),
403 rbase >> 8, rend >> 8, 1); // [39:8]
404 }
405 resource->flags |= IORESOURCE_STORED;
Vladimir Serbinenkoa37383d2013-11-26 02:41:26 +0100406 snprintf(buf, sizeof (buf), " <node %x link %x>", nodeid, link_num);
Marc Jones8d595692012-03-15 12:55:26 -0600407 report_resource_stored(dev, resource, buf);
Frank Vibrans39fca802011-02-14 18:35:15 +0000408}
409
efdesign983f5ebd62011-09-14 13:47:17 -0600410#if CONFIG_CONSOLE_VGA_MULTI
Marc Jones8d595692012-03-15 12:55:26 -0600411extern device_t vga_pri; // the primary vga device, defined in device.c
Frank Vibrans39fca802011-02-14 18:35:15 +0000412#endif
413
414static void create_vga_resource(device_t dev, unsigned nodeid)
415{
Marc Jones8d595692012-03-15 12:55:26 -0600416 struct bus *link;
Frank Vibrans39fca802011-02-14 18:35:15 +0000417
Mike Loptien58089e82013-01-29 15:45:09 -0700418 printk(BIOS_DEBUG, "\nFam14h - %s\n", __func__);
Frank Vibrans39fca802011-02-14 18:35:15 +0000419
Marc Jones8d595692012-03-15 12:55:26 -0600420 /* find out which link the VGA card is connected,
421 * we only deal with the 'first' vga card */
422 for (link = dev->link_list; link; link = link->next) {
423 if (link->bridge_ctrl & PCI_BRIDGE_CTL_VGA) {
efdesign983f5ebd62011-09-14 13:47:17 -0600424#if CONFIG_CONSOLE_VGA_MULTI
Marc Jones8d595692012-03-15 12:55:26 -0600425 printk(BIOS_DEBUG,
426 "VGA: vga_pri bus num = %d bus range [%d,%d]\n",
427 vga_pri->bus->secondary, link->secondary,
428 link->subordinate);
429 /* We need to make sure the vga_pri is under the link */
430 if ((vga_pri->bus->secondary >= link->secondary) &&
431 (vga_pri->bus->secondary <= link->subordinate))
Frank Vibrans39fca802011-02-14 18:35:15 +0000432#endif
Marc Jones8d595692012-03-15 12:55:26 -0600433 break;
434 }
435 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000436
Marc Jones8d595692012-03-15 12:55:26 -0600437 /* no VGA card installed */
438 if (link == NULL)
439 return;
Frank Vibrans39fca802011-02-14 18:35:15 +0000440
Marc Jones8d595692012-03-15 12:55:26 -0600441 printk(BIOS_DEBUG, "VGA: %s (aka node %d) link %d has VGA device\n",
442 dev_path(dev), nodeid, link->link_num);
443 set_vga_enable_reg(nodeid, link->link_num);
Frank Vibrans39fca802011-02-14 18:35:15 +0000444}
445
Marc Jones8a49ac72013-01-16 17:02:20 -0700446static void nb_set_resources(device_t dev)
Frank Vibrans39fca802011-02-14 18:35:15 +0000447{
Marc Jones8d595692012-03-15 12:55:26 -0600448 unsigned nodeid;
449 struct bus *bus;
450 struct resource *res;
Frank Vibrans39fca802011-02-14 18:35:15 +0000451
Mike Loptien58089e82013-01-29 15:45:09 -0700452 printk(BIOS_DEBUG, "\nFam14h - %s\n", __func__);
efdesign9805a89ab2011-06-20 17:38:49 -0700453
Marc Jones8d595692012-03-15 12:55:26 -0600454 /* Find the nodeid */
455 nodeid = amdfam14_nodeid(dev);
Frank Vibrans39fca802011-02-14 18:35:15 +0000456
Marc Jones8d595692012-03-15 12:55:26 -0600457 create_vga_resource(dev, nodeid);
Frank Vibrans39fca802011-02-14 18:35:15 +0000458
Marc Jones8d595692012-03-15 12:55:26 -0600459 /* Set each resource we have found */
460 for (res = dev->resource_list; res; res = res->next) {
461 set_resource(dev, res, nodeid);
462 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000463
Marc Jones8d595692012-03-15 12:55:26 -0600464 for (bus = dev->link_list; bus; bus = bus->next) {
465 if (bus->children) {
466 assign_resources(bus);
467 }
468 }
Marc Jonesd5c998b2013-01-16 17:14:24 -0700469
470 /* Print the MMCONF region if it has been reserved. */
471 res = find_resource(dev, 0xc0010058);
472 if (res) {
473 report_resource_stored(dev, res, " <mmconfig>");
474 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000475}
476
Frank Vibrans39fca802011-02-14 18:35:15 +0000477/* Domain/Root Complex related code */
478
479static void domain_read_resources(device_t dev)
480{
Marc Jones8d595692012-03-15 12:55:26 -0600481 unsigned reg;
Frank Vibrans39fca802011-02-14 18:35:15 +0000482
Mike Loptien58089e82013-01-29 15:45:09 -0700483 printk(BIOS_DEBUG, "\nFam14h - %s\n", __func__);
Frank Vibrans39fca802011-02-14 18:35:15 +0000484
Marc Jones8d595692012-03-15 12:55:26 -0600485 /* Find the already assigned resource pairs */
486 get_fx_devs();
487 for (reg = 0x80; reg <= 0xc0; reg += 0x08) {
488 u32 base, limit;
489 base = f1_read_config32(reg);
490 limit = f1_read_config32(reg + 0x04);
491 /* Is this register allocated? */
492 if ((base & 3) != 0) {
493 unsigned nodeid, reg_link;
494 device_t reg_dev;
495 if (reg < 0xc0) { // mmio
496 nodeid = (limit & 0xf) + (base & 0x30);
497 } else { // io
498 nodeid = (limit & 0xf) + ((base >> 4) & 0x30);
499 }
500 reg_link = (limit >> 4) & 7;
501 reg_dev = __f0_dev[nodeid];
502 if (reg_dev) {
503 /* Reserve the resource */
504 struct resource *res;
505 res =
506 new_resource(reg_dev,
507 IOINDEX(0x1000 + reg,
508 reg_link));
509 if (res) {
510 res->flags = 1;
511 }
512 }
513 }
514 }
515 /* FIXME: do we need to check extend conf space?
516 I don't believe that much preset value */
Frank Vibrans39fca802011-02-14 18:35:15 +0000517
Patrick Georgie1667822012-05-05 15:29:32 +0200518#if !CONFIG_PCI_64BIT_PREF_MEM
Marc Jones8d595692012-03-15 12:55:26 -0600519 pci_domain_read_resources(dev);
Frank Vibrans39fca802011-02-14 18:35:15 +0000520#else
Marc Jones8d595692012-03-15 12:55:26 -0600521 struct bus *link;
522 struct resource *resource;
523 for (link = dev->link_list; link; link = link->next) {
524 /* Initialize the system wide io space constraints */
525 resource = new_resource(dev, 0 | (link->link_num << 2));
526 resource->base = 0x400;
527 resource->limit = 0xffffUL;
528 resource->flags = IORESOURCE_IO;
Frank Vibrans39fca802011-02-14 18:35:15 +0000529
Marc Jones8d595692012-03-15 12:55:26 -0600530 /* Initialize the system wide prefetchable memory resources constraints */
531 resource = new_resource(dev, 1 | (link->link_num << 2));
532 resource->limit = 0xfcffffffffULL;
533 resource->flags = IORESOURCE_MEM | IORESOURCE_PREFETCH;
Frank Vibrans39fca802011-02-14 18:35:15 +0000534
Marc Jones8d595692012-03-15 12:55:26 -0600535 /* Initialize the system wide memory resources constraints */
536 resource = new_resource(dev, 2 | (link->link_num << 2));
537 resource->limit = 0xfcffffffffULL;
538 resource->flags = IORESOURCE_MEM;
539 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000540#endif
541}
542
Kyösti Mälkki6b5eb1c2012-07-19 19:26:43 +0300543static void setup_uma_memory(void)
Kyösti Mälkki55fff9302012-07-11 08:02:39 +0300544{
545#if CONFIG_GFXUMA
Kyösti Mälkkidbc47392012-08-05 12:11:40 +0300546 uint32_t topmem = (uint32_t) bsp_topmem();
Kyösti Mälkki55fff9302012-07-11 08:02:39 +0300547 uint32_t sys_mem;
548
Kyösti Mälkki55fff9302012-07-11 08:02:39 +0300549 /* refer to UMA Size Consideration in Family14h BKDG. */
Kyösti Mälkkidbc47392012-08-05 12:11:40 +0300550 sys_mem = topmem + 0x1000000; // Ignore 16MB allocated for C6 when finding UMA size, refer MemNGetUmaSizeON()
551 if ((bsp_topmem2()>>32) || (sys_mem >= 0x80000000)) {
Kyösti Mälkki55fff9302012-07-11 08:02:39 +0300552 uma_memory_size = 0x18000000; /* >= 2G memory, 384M recommended UMA */
553 }
554 else {
555 if (sys_mem >= 0x40000000) {
556 uma_memory_size = 0x10000000; /* >= 1G memory, 256M recommended UMA */
557 } else {
558 uma_memory_size = 0x4000000; /* <1G memory, 64M recommended UMA */
559 }
560 }
561
Kyösti Mälkkidbc47392012-08-05 12:11:40 +0300562 uma_memory_base = topmem - uma_memory_size; /* TOP_MEM1 */
Kyösti Mälkki55fff9302012-07-11 08:02:39 +0300563 printk(BIOS_INFO, "%s: uma size 0x%08llx, memory start 0x%08llx\n",
564 __func__, uma_memory_size, uma_memory_base);
Kyösti Mälkki55fff9302012-07-11 08:02:39 +0300565#endif
566}
567
Frank Vibrans39fca802011-02-14 18:35:15 +0000568static void domain_set_resources(device_t dev)
569{
Mike Loptien58089e82013-01-29 15:45:09 -0700570 printk(BIOS_DEBUG, "\nFam14h - %s\n", __func__);
Marc Jones8d595692012-03-15 12:55:26 -0600571 printk(BIOS_DEBUG, " amsr - incoming dev = %08x\n", (u32) dev);
Frank Vibrans39fca802011-02-14 18:35:15 +0000572
Patrick Georgie1667822012-05-05 15:29:32 +0200573#if CONFIG_PCI_64BIT_PREF_MEM
Marc Jones8d595692012-03-15 12:55:26 -0600574 struct resource *io, *mem1, *mem2;
575 struct resource *res;
Frank Vibrans39fca802011-02-14 18:35:15 +0000576#endif
Marc Jones8d595692012-03-15 12:55:26 -0600577 unsigned long mmio_basek;
578 u32 pci_tolm;
Kyösti Mälkki2b790f62013-09-03 05:25:57 +0300579 u64 ramtop = 0;
Marc Jones8d595692012-03-15 12:55:26 -0600580 int idx;
581 struct bus *link;
Frank Vibrans39fca802011-02-14 18:35:15 +0000582#if CONFIG_HW_MEM_HOLE_SIZEK != 0
Marc Jones8d595692012-03-15 12:55:26 -0600583 struct hw_mem_hole_info mem_hole;
584 u32 reset_memhole = 1;
Frank Vibrans39fca802011-02-14 18:35:15 +0000585#endif
586
Patrick Georgie1667822012-05-05 15:29:32 +0200587#if CONFIG_PCI_64BIT_PREF_MEM
Frank Vibrans39fca802011-02-14 18:35:15 +0000588
Marc Jones8d595692012-03-15 12:55:26 -0600589 printk(BIOS_DEBUG, "adsr - CONFIG_PCI_64BIT_PREF_MEM is true.\n");
590 for (link = dev->link_list; link; link = link->next) {
591 /* Now reallocate the pci resources memory with the
592 * highest addresses I can manage.
593 */
594 mem1 = find_resource(dev, 1 | (link->link_num << 2));
595 mem2 = find_resource(dev, 2 | (link->link_num << 2));
Frank Vibrans39fca802011-02-14 18:35:15 +0000596
Marc Jones8d595692012-03-15 12:55:26 -0600597 printk(BIOS_DEBUG,
598 "base1: 0x%08Lx limit1: 0x%08Lx size: 0x%08Lx align: %d\n",
599 (u32) (mem1->base), (u32) (mem1->limit),
600 (u32) (mem1->size), u32) (mem1->align));
601 printk(BIOS_DEBUG,
602 "base2: 0x%08Lx limit2: 0x%08Lx size: 0x%08Lx align: %d\n",
603 (u32) (mem2->base), (u32) (mem2->limit),
604 (u32) (mem2->size), (u32) (mem2->align));
Frank Vibrans39fca802011-02-14 18:35:15 +0000605
Marc Jones8d595692012-03-15 12:55:26 -0600606 /* See if both resources have roughly the same limits */
607 if (((mem1->limit <= 0xffffffff) && (mem2->limit <= 0xffffffff))
608 || ((mem1->limit > 0xffffffff)
609 && (mem2->limit > 0xffffffff))) {
610 /* If so place the one with the most stringent alignment first
611 */
612 if (mem2->align > mem1->align) {
613 struct resource *tmp;
614 tmp = mem1;
615 mem1 = mem2;
616 mem2 = tmp;
617 }
618 /* Now place the memory as high up as it will go */
619 mem2->base = resource_max(mem2);
620 mem1->limit = mem2->base - 1;
621 mem1->base = resource_max(mem1);
622 } else {
623 /* Place the resources as high up as they will go */
624 mem2->base = resource_max(mem2);
625 mem1->base = resource_max(mem1);
626 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000627
Marc Jones8d595692012-03-15 12:55:26 -0600628 printk(BIOS_DEBUG,
629 "base1: 0x%08Lx limit1: 0x%08Lx size: 0x%08Lx align: %d\n",
630 mem1->base, mem1->limit, mem1->size, mem1->align);
631 printk(BIOS_DEBUG,
632 "base2: 0x%08Lx limit2: 0x%08Lx size: 0x%08Lx align: %d\n",
633 mem2->base, mem2->limit, mem2->size, mem2->align);
634 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000635
Marc Jones8d595692012-03-15 12:55:26 -0600636 for (res = &dev->resource_list; res; res = res->next) {
637 res->flags |= IORESOURCE_ASSIGNED;
638 res->flags |= IORESOURCE_STORED;
639 report_resource_stored(dev, res, "");
640 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000641#endif
642
Marc Jones8d595692012-03-15 12:55:26 -0600643 pci_tolm = 0xffffffffUL;
644 for (link = dev->link_list; link; link = link->next) {
645 pci_tolm = my_find_pci_tolm(link, pci_tolm);
646 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000647
Marc Jones8d595692012-03-15 12:55:26 -0600648 // FIXME handle interleaved nodes. If you fix this here, please fix
649 // amdk8, too.
650 mmio_basek = pci_tolm >> 10;
651 /* Round mmio_basek to something the processor can support */
652 mmio_basek &= ~((1 << 6) - 1);
Frank Vibrans39fca802011-02-14 18:35:15 +0000653
Marc Jones8d595692012-03-15 12:55:26 -0600654 // FIXME improve mtrr.c so we don't use up all of the mtrrs with a 64M
655 // MMIO hole. If you fix this here, please fix amdk8, too.
656 /* Round the mmio hole to 64M */
657 mmio_basek &= ~((64 * 1024) - 1);
Frank Vibrans39fca802011-02-14 18:35:15 +0000658
659#if CONFIG_HW_MEM_HOLE_SIZEK != 0
660/* if the hw mem hole is already set in raminit stage, here we will compare
661 * mmio_basek and hole_basek. if mmio_basek is bigger that hole_basek and will
662 * use hole_basek as mmio_basek and we don't need to reset hole.
663 * otherwise We reset the hole to the mmio_basek
664 */
665
Marc Jones8d595692012-03-15 12:55:26 -0600666 mem_hole = get_hw_mem_hole_info();
Frank Vibrans39fca802011-02-14 18:35:15 +0000667
Marc Jones8d595692012-03-15 12:55:26 -0600668 // Use hole_basek as mmio_basek, and we don't need to reset hole anymore
669 if ((mem_hole.node_id != -1) && (mmio_basek > mem_hole.hole_startk)) {
670 mmio_basek = mem_hole.hole_startk;
671 reset_memhole = 0;
672 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000673#endif
674
Marc Jones8d595692012-03-15 12:55:26 -0600675 idx = 0x10;
Frank Vibrans39fca802011-02-14 18:35:15 +0000676
Marc Jones8d595692012-03-15 12:55:26 -0600677 struct dram_base_mask_t d;
678 resource_t basek, limitk, sizek; // 4 1T
Frank Vibrans39fca802011-02-14 18:35:15 +0000679
Marc Jones8d595692012-03-15 12:55:26 -0600680 d = get_dram_base_mask(0);
Frank Vibrans39fca802011-02-14 18:35:15 +0000681
Marc Jones8d595692012-03-15 12:55:26 -0600682 if (d.mask & 1) {
683 basek = ((resource_t) ((u64) d.base)) << 8;
684 limitk = (resource_t) (((u64) d.mask << 8) | 0xFFFFFF);
685 printk(BIOS_DEBUG,
686 "adsr: (before) basek = %llx, limitk = %llx.\n", basek,
687 limitk);
Frank Vibrans39fca802011-02-14 18:35:15 +0000688
Marc Jones8d595692012-03-15 12:55:26 -0600689 /* Convert these values to multiples of 1K for ease of math. */
690 basek >>= 10;
691 limitk >>= 10;
692 sizek = limitk - basek + 1;
Frank Vibrans39fca802011-02-14 18:35:15 +0000693
Marc Jones8d595692012-03-15 12:55:26 -0600694 printk(BIOS_DEBUG,
695 "adsr: (after) basek = %llx, limitk = %llx, sizek = %llx.\n",
696 basek, limitk, sizek);
Frank Vibrans39fca802011-02-14 18:35:15 +0000697
Marc Jones8d595692012-03-15 12:55:26 -0600698 /* see if we need a hole from 0xa0000 to 0xbffff */
699 if ((basek < 640) && (sizek > 768)) {
700 printk(BIOS_DEBUG,"adsr - 0xa0000 to 0xbffff resource.\n");
701 ram_resource(dev, (idx | 0), basek, 640 - basek);
702 idx += 0x10;
703 basek = 768;
704 sizek = limitk - 768;
705 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000706
Marc Jones8d595692012-03-15 12:55:26 -0600707 printk(BIOS_DEBUG,
708 "adsr: mmio_basek=%08lx, basek=%08llx, limitk=%08llx\n",
709 mmio_basek, basek, limitk);
Frank Vibrans39fca802011-02-14 18:35:15 +0000710
Kyösti Mälkki26c65432014-06-26 05:30:54 +0300711 /* split the region to accommodate pci memory space */
Marc Jones8d595692012-03-15 12:55:26 -0600712 if ((basek < 4 * 1024 * 1024) && (limitk > mmio_basek)) {
713 if (basek <= mmio_basek) {
714 unsigned pre_sizek;
715 pre_sizek = mmio_basek - basek;
716 if (pre_sizek > 0) {
717 ram_resource(dev, idx, basek,
718 pre_sizek);
719 idx += 0x10;
720 sizek -= pre_sizek;
Kyösti Mälkki2b790f62013-09-03 05:25:57 +0300721 if (!ramtop)
722 ramtop = mmio_basek * 1024;
Marc Jones8d595692012-03-15 12:55:26 -0600723 }
Marc Jones8d595692012-03-15 12:55:26 -0600724 basek = mmio_basek;
725 }
726 if ((basek + sizek) <= 4 * 1024 * 1024) {
727 sizek = 0;
728 } else {
729 basek = 4 * 1024 * 1024;
730 sizek -= (4 * 1024 * 1024 - mmio_basek);
731 }
732 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000733
Marc Jones8d595692012-03-15 12:55:26 -0600734 ram_resource(dev, (idx | 0), basek, sizek);
735 idx += 0x10;
Marc Jones8d595692012-03-15 12:55:26 -0600736 printk(BIOS_DEBUG,
737 "%d: mmio_basek=%08lx, basek=%08llx, limitk=%08llx\n", 0,
738 mmio_basek, basek, limitk);
Kyösti Mälkki2b790f62013-09-03 05:25:57 +0300739 if (!ramtop)
740 ramtop = limitk * 1024;
Marc Jones8d595692012-03-15 12:55:26 -0600741 }
742 printk(BIOS_DEBUG, " adsr - mmio_basek = %lx.\n", mmio_basek);
Frank Vibrans39fca802011-02-14 18:35:15 +0000743
Patrick Georgie1667822012-05-05 15:29:32 +0200744#if CONFIG_GFXUMA
Kyösti Mälkki2b790f62013-09-03 05:25:57 +0300745 set_top_of_ram(uma_memory_base);
Kyösti Mälkki63f8c082012-07-10 13:27:26 +0300746 uma_resource(dev, 7, uma_memory_base >> 10, uma_memory_size >> 10);
Kyösti Mälkki2b790f62013-09-03 05:25:57 +0300747#else
748 set_top_of_ram(ramtop);
Frank Vibrans39fca802011-02-14 18:35:15 +0000749#endif
750
Marc Jones8d595692012-03-15 12:55:26 -0600751 for (link = dev->link_list; link; link = link->next) {
752 if (link->children) {
753 assign_resources(link);
754 }
755 }
756 printk(BIOS_DEBUG, " adsr - leaving this lovely routine.\n");
Frank Vibrans39fca802011-02-14 18:35:15 +0000757}
758
zbaof7223732012-04-13 13:42:15 +0800759static void domain_enable_resources(device_t dev)
760{
Marc Jones8d595692012-03-15 12:55:26 -0600761 u32 val;
Kerry Shefeed3292011-08-18 18:03:44 +0800762
763#if CONFIG_AMD_SB_CIMX
Kyösti Mälkkic551caa2014-06-20 12:31:23 +0300764 if (!acpi_is_wakeup_s3()) {
zbaof7223732012-04-13 13:42:15 +0800765 sb_After_Pci_Init();
766 sb_Mid_Post_Init();
767 } else {
768 sb_After_Pci_Restore_Init();
769 }
Kerry Shefeed3292011-08-18 18:03:44 +0800770#endif
771
Marc Jones8d595692012-03-15 12:55:26 -0600772 /* Must be called after PCI enumeration and resource allocation */
Mike Loptien58089e82013-01-29 15:45:09 -0700773 printk(BIOS_DEBUG, "\nFam14h - %s\n", __func__);
zbaof7223732012-04-13 13:42:15 +0800774
Kyösti Mälkki8ae16a42014-06-19 20:44:34 +0300775 if (!acpi_is_wakeup_s3()) {
zbaof7223732012-04-13 13:42:15 +0800776 printk(BIOS_DEBUG, "agesawrapper_amdinitmid ");
777 val = agesawrapper_amdinitmid ();
778 if (val)
779 printk(BIOS_DEBUG, "error level: %x \n", val);
780 else
781 printk(BIOS_DEBUG, "passed.\n");
Marc Jones8d595692012-03-15 12:55:26 -0600782 }
efdesign9805a89ab2011-06-20 17:38:49 -0700783
Marc Jones8d595692012-03-15 12:55:26 -0600784 printk(BIOS_DEBUG, " ader - leaving domain_enable_resources.\n");
Frank Vibrans39fca802011-02-14 18:35:15 +0000785}
786
Frank Vibrans39fca802011-02-14 18:35:15 +0000787/* Bus related code */
788
Marc Jonesd5c998b2013-01-16 17:14:24 -0700789static void cpu_bus_read_resources(device_t dev)
790{
Frank Vibrans39fca802011-02-14 18:35:15 +0000791}
792
Marc Jonesd5c998b2013-01-16 17:14:24 -0700793static void cpu_bus_set_resources(device_t dev)
794{
Frank Vibrans39fca802011-02-14 18:35:15 +0000795}
efdesign9805a89ab2011-06-20 17:38:49 -0700796
zbaof7223732012-04-13 13:42:15 +0800797static u32 cpu_bus_scan(device_t dev, u32 max)
798{
Kyösti Mälkkic33f1e92012-08-07 17:12:11 +0300799 struct bus *cpu_bus = dev->link_list;
Scott Duplichan9ab3c6c2011-05-15 21:45:46 +0000800 device_t cpu;
zbaof7223732012-04-13 13:42:15 +0800801 int apic_id, cores_found;
Scott Duplichan9ab3c6c2011-05-15 21:45:46 +0000802
zbaof7223732012-04-13 13:42:15 +0800803 /* There is only one node for fam14, but there may be multiple cores. */
804 cpu = dev_find_slot(0, PCI_DEVFN(0x18, 0));
805 if (!cpu)
806 printk(BIOS_ERR, "ERROR: %02x:%02x.0 not found", 0, 0x18);
Scott Duplichan9ab3c6c2011-05-15 21:45:46 +0000807
zbaof7223732012-04-13 13:42:15 +0800808 cores_found = (pci_read_config32(dev_find_slot(0,PCI_DEVFN(0x18,0x3)), 0xe8) >> 12) & 3;
809 printk(BIOS_DEBUG, " AP siblings=%d\n", cores_found);
810
zbaof7223732012-04-13 13:42:15 +0800811 for (apic_id = 0; apic_id <= cores_found; apic_id++) {
Kyösti Mälkkic33f1e92012-08-07 17:12:11 +0300812 cpu = add_cpu_device(cpu_bus, apic_id, 1);
813 if (cpu)
814 amd_cpu_topology(cpu, 0, apic_id);
Marc Jones8d595692012-03-15 12:55:26 -0600815 }
zbaof7223732012-04-13 13:42:15 +0800816 return max;
817}
818
819static void cpu_bus_init(device_t dev)
820{
821 initialize_cpus(dev->link_list);
Frank Vibrans39fca802011-02-14 18:35:15 +0000822}
823
Frank Vibrans39fca802011-02-14 18:35:15 +0000824/* North Bridge Structures */
825
826static struct device_operations northbridge_operations = {
Marc Jones8a49ac72013-01-16 17:02:20 -0700827 .read_resources = nb_read_resources,
828 .set_resources = nb_set_resources,
Marc Jones8d595692012-03-15 12:55:26 -0600829 .enable_resources = pci_dev_enable_resources,
830 .init = northbridge_init,
831 .enable = 0,.ops_pci = 0,
Frank Vibrans39fca802011-02-14 18:35:15 +0000832};
833
Frank Vibrans39fca802011-02-14 18:35:15 +0000834static const struct pci_driver northbridge_driver __pci_driver = {
Marc Jones8d595692012-03-15 12:55:26 -0600835 .ops = &northbridge_operations,
836 .vendor = PCI_VENDOR_ID_AMD,
837 .device = 0x1510,
Frank Vibrans39fca802011-02-14 18:35:15 +0000838};
839
efdesign9805a89ab2011-06-20 17:38:49 -0700840struct chip_operations northbridge_amd_agesa_family14_ops = {
Marc Jones8d595692012-03-15 12:55:26 -0600841 CHIP_NAME("AMD Family 14h Northbridge")
842 .enable_dev = 0,
Frank Vibrans39fca802011-02-14 18:35:15 +0000843};
844
Frank Vibrans39fca802011-02-14 18:35:15 +0000845/* Root Complex Structures */
846
Frank Vibrans39fca802011-02-14 18:35:15 +0000847static struct device_operations pci_domain_ops = {
Marc Jones8d595692012-03-15 12:55:26 -0600848 .read_resources = domain_read_resources,
849 .set_resources = domain_set_resources,
850 .enable_resources = domain_enable_resources,
851 .init = NULL,
852 .scan_bus = pci_domain_scan_bus,
Frank Vibrans39fca802011-02-14 18:35:15 +0000853};
854
Frank Vibrans39fca802011-02-14 18:35:15 +0000855static struct device_operations cpu_bus_ops = {
Marc Jones8d595692012-03-15 12:55:26 -0600856 .read_resources = cpu_bus_read_resources,
857 .set_resources = cpu_bus_set_resources,
858 .enable_resources = NULL,
859 .init = cpu_bus_init,
zbaof7223732012-04-13 13:42:15 +0800860 .scan_bus = cpu_bus_scan,
Frank Vibrans39fca802011-02-14 18:35:15 +0000861};
862
Kyösti Mälkki87213b62012-08-27 20:00:33 +0300863static void root_complex_enable_dev(struct device *dev)
864{
865 static int done = 0;
866
867 /* Do not delay UMA setup, as a device on the PCI bus may evaluate
868 the global uma_memory variables already in its enable function. */
869 if (!done) {
870 setup_bsp_ramtop();
871 setup_uma_memory();
872 done = 1;
873 }
874
Marc Jones8d595692012-03-15 12:55:26 -0600875 /* Set the operations if it is a special bus type */
Stefan Reinauer4aff4452013-02-12 14:17:15 -0800876 if (dev->path.type == DEVICE_PATH_DOMAIN) {
Marc Jones8d595692012-03-15 12:55:26 -0600877 dev->ops = &pci_domain_ops;
Stefan Reinauer0aa37c42013-02-12 15:20:54 -0800878 } else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER) {
Marc Jones8d595692012-03-15 12:55:26 -0600879 dev->ops = &cpu_bus_ops;
880 }
Frank Vibrans39fca802011-02-14 18:35:15 +0000881}
882
efdesign9805a89ab2011-06-20 17:38:49 -0700883struct chip_operations northbridge_amd_agesa_family14_root_complex_ops = {
Marc Jones8d595692012-03-15 12:55:26 -0600884 CHIP_NAME("AMD Family 14h Root Complex")
885 .enable_dev = root_complex_enable_dev,
Frank Vibrans39fca802011-02-14 18:35:15 +0000886};