Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 1 | /* |
| 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 Jones | 5750ed2 | 2012-03-15 13:21:41 -0600 | [diff] [blame] | 31 | #include <cbmem.h> |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 32 | |
| 33 | #include <cpu/x86/lapic.h> |
Kyösti Mälkki | 55fff930 | 2012-07-11 08:02:39 +0300 | [diff] [blame] | 34 | #include <cpu/amd/mtrr.h> |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 35 | |
efdesign98 | 3f5ebd6 | 2011-09-14 13:47:17 -0600 | [diff] [blame] | 36 | #include "agesawrapper.h" |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 37 | #include "chip.h" |
| 38 | #include "northbridge.h" |
Kerry She | feed329 | 2011-08-18 18:03:44 +0800 | [diff] [blame] | 39 | #if CONFIG_AMD_SB_CIMX |
| 40 | #include <sb_cimx.h> |
| 41 | #endif |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 42 | |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 43 | //#define FX_DEVS NODE_NUMS |
| 44 | #define FX_DEVS 1 |
| 45 | |
| 46 | static device_t __f0_dev[FX_DEVS]; |
| 47 | static device_t __f1_dev[FX_DEVS]; |
| 48 | static device_t __f2_dev[FX_DEVS]; |
| 49 | static device_t __f4_dev[FX_DEVS]; |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 50 | static unsigned fx_devs = 0; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 51 | |
| 52 | device_t get_node_pci(u32 nodeid, u32 fn) |
| 53 | { |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 54 | return dev_find_slot(CONFIG_CBB, PCI_DEVFN(CONFIG_CDB + nodeid, fn)); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 55 | } |
| 56 | |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 57 | static void get_fx_devs(void) |
| 58 | { |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 59 | int i; |
| 60 | for (i = 0; i < FX_DEVS; i++) { |
| 61 | __f0_dev[i] = get_node_pci(i, 0); |
| 62 | __f1_dev[i] = get_node_pci(i, 1); |
| 63 | __f2_dev[i] = get_node_pci(i, 2); |
| 64 | __f4_dev[i] = get_node_pci(i, 4); |
| 65 | if (__f0_dev[i] != NULL && __f1_dev[i] != NULL) |
| 66 | fx_devs = i + 1; |
| 67 | } |
| 68 | if (__f1_dev[0] == NULL || __f0_dev[0] == NULL || fx_devs == 0) { |
| 69 | die("Cannot find 0:0x18.[0|1]\n"); |
| 70 | } |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 71 | } |
| 72 | |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 73 | static u32 f1_read_config32(unsigned reg) |
| 74 | { |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 75 | if (fx_devs == 0) |
| 76 | get_fx_devs(); |
| 77 | return pci_read_config32(__f1_dev[0], reg); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 78 | } |
| 79 | |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 80 | static void f1_write_config32(unsigned reg, u32 value) |
| 81 | { |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 82 | int i; |
| 83 | if (fx_devs == 0) |
| 84 | get_fx_devs(); |
| 85 | for (i = 0; i < fx_devs; i++) { |
| 86 | device_t dev; |
| 87 | dev = __f1_dev[i]; |
| 88 | if (dev && dev->enabled) { |
| 89 | pci_write_config32(dev, reg, value); |
| 90 | } |
| 91 | } |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 92 | } |
| 93 | |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 94 | static u32 amdfam14_nodeid(device_t dev) |
| 95 | { |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 96 | return (dev->path.pci.devfn >> 3) - CONFIG_CDB; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 97 | } |
| 98 | |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 99 | #include "amdfam14_conf.c" |
| 100 | |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 101 | static void northbridge_init(device_t dev) |
| 102 | { |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 103 | printk(BIOS_DEBUG, "Northbridge init\n"); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 104 | } |
| 105 | |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 106 | static void set_vga_enable_reg(u32 nodeid, u32 linkn) |
| 107 | { |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 108 | u32 val; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 109 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 110 | val = 1 | (nodeid << 4) | (linkn << 12); |
| 111 | /* it will routing (1)mmio 0xa0000:0xbffff (2) io 0x3b0:0x3bb, |
| 112 | 0x3c0:0x3df */ |
| 113 | f1_write_config32(0xf4, val); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 114 | |
| 115 | } |
| 116 | |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 117 | static int reg_useable(unsigned reg, device_t goal_dev, unsigned goal_nodeid, |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 118 | unsigned goal_link) |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 119 | { |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 120 | struct resource *res; |
| 121 | unsigned nodeid, link = 0; |
| 122 | int result; |
| 123 | res = 0; |
| 124 | for (nodeid = 0; !res && (nodeid < fx_devs); nodeid++) { |
| 125 | device_t dev; |
| 126 | dev = __f0_dev[nodeid]; |
| 127 | if (!dev) |
| 128 | continue; |
| 129 | for (link = 0; !res && (link < 8); link++) { |
| 130 | res = probe_resource(dev, IOINDEX(0x1000 + reg, link)); |
| 131 | } |
| 132 | } |
| 133 | result = 2; |
| 134 | if (res) { |
| 135 | result = 0; |
| 136 | if ((goal_link == (link - 1)) && |
| 137 | (goal_nodeid == (nodeid - 1)) && (res->flags <= 1)) { |
| 138 | result = 1; |
| 139 | } |
| 140 | } |
| 141 | return result; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 142 | } |
| 143 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 144 | static struct resource *amdfam14_find_iopair(device_t dev, unsigned nodeid, |
| 145 | unsigned link) |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 146 | { |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 147 | struct resource *resource; |
| 148 | u32 result, reg; |
| 149 | resource = 0; |
| 150 | reg = 0; |
| 151 | result = reg_useable(0xc0, dev, nodeid, link); |
| 152 | if (result >= 1) { |
| 153 | /* I have been allocated this one */ |
| 154 | reg = 0xc0; |
| 155 | } |
| 156 | /* Ext conf space */ |
| 157 | if (!reg) { |
| 158 | /* Because of Extend conf space, we will never run out of reg, |
| 159 | * but we need one index to differ them. So ,same node and same |
| 160 | * link can have multi range |
| 161 | */ |
| 162 | u32 index = get_io_addr_index(nodeid, link); |
| 163 | reg = 0x110 + (index << 24) + (4 << 20); // index could be 0, 255 |
| 164 | } |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 165 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 166 | resource = new_resource(dev, IOINDEX(0x1000 + reg, link)); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 167 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 168 | return resource; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 169 | } |
| 170 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 171 | static struct resource *amdfam14_find_mempair(device_t dev, u32 nodeid, |
| 172 | u32 link) |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 173 | { |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 174 | struct resource *resource; |
| 175 | u32 free_reg, reg; |
| 176 | resource = 0; |
| 177 | free_reg = 0; |
| 178 | for (reg = 0x80; reg <= 0xb8; reg += 0x8) { |
| 179 | int result; |
| 180 | result = reg_useable(reg, dev, nodeid, link); |
| 181 | if (result == 1) { |
| 182 | /* I have been allocated this one */ |
| 183 | break; |
| 184 | } else if (result > 1) { |
| 185 | /* I have a free register pair */ |
| 186 | free_reg = reg; |
| 187 | } |
| 188 | } |
| 189 | if (reg > 0xb8) { |
| 190 | reg = free_reg; |
| 191 | } |
| 192 | /* Ext conf space */ |
| 193 | if (!reg) { |
| 194 | /* Because of Extend conf space, we will never run out of reg, |
| 195 | * but we need one index to differ them. So ,same node and same |
| 196 | * link can have multi range |
| 197 | */ |
| 198 | u32 index = get_mmio_addr_index(nodeid, link); |
| 199 | reg = 0x110 + (index << 24) + (6 << 20); // index could be 0, 63 |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 200 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 201 | } |
| 202 | resource = new_resource(dev, IOINDEX(0x1000 + reg, link)); |
| 203 | return resource; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 204 | } |
| 205 | |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 206 | static void amdfam14_link_read_bases(device_t dev, u32 nodeid, u32 link) |
| 207 | { |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 208 | struct resource *resource; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 209 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 210 | /* Initialize the io space constraints on the current bus */ |
| 211 | resource = amdfam14_find_iopair(dev, nodeid, link); |
| 212 | if (resource) { |
| 213 | u32 align; |
Patrick Georgi | e166782 | 2012-05-05 15:29:32 +0200 | [diff] [blame] | 214 | #if CONFIG_EXT_CONF_SUPPORT |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 215 | if ((resource->index & 0x1fff) == 0x1110) { // ext |
| 216 | align = 8; |
| 217 | } else |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 218 | #endif |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 219 | align = log2(HT_IO_HOST_ALIGN); |
| 220 | resource->base = 0; |
| 221 | resource->size = 0; |
| 222 | resource->align = align; |
| 223 | resource->gran = align; |
| 224 | resource->limit = 0xffffUL; |
| 225 | resource->flags = IORESOURCE_IO | IORESOURCE_BRIDGE; |
| 226 | } |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 227 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 228 | /* Initialize the prefetchable memory constraints on the current bus */ |
| 229 | resource = amdfam14_find_mempair(dev, nodeid, link); |
| 230 | if (resource) { |
| 231 | resource->base = 0; |
| 232 | resource->size = 0; |
| 233 | resource->align = log2(HT_MEM_HOST_ALIGN); |
| 234 | resource->gran = log2(HT_MEM_HOST_ALIGN); |
| 235 | resource->limit = 0xffffffffffULL; |
| 236 | resource->flags = IORESOURCE_MEM | IORESOURCE_PREFETCH; |
| 237 | resource->flags |= IORESOURCE_BRIDGE; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 238 | |
Patrick Georgi | e166782 | 2012-05-05 15:29:32 +0200 | [diff] [blame] | 239 | #if CONFIG_EXT_CONF_SUPPORT |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 240 | if ((resource->index & 0x1fff) == 0x1110) { // ext |
| 241 | normalize_resource(resource); |
| 242 | } |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 243 | #endif |
| 244 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 245 | } |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 246 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 247 | /* Initialize the memory constraints on the current bus */ |
| 248 | resource = amdfam14_find_mempair(dev, nodeid, link); |
| 249 | if (resource) { |
| 250 | resource->base = 0; |
| 251 | resource->size = 0; |
| 252 | resource->align = log2(HT_MEM_HOST_ALIGN); |
| 253 | resource->gran = log2(HT_MEM_HOST_ALIGN); |
| 254 | resource->limit = 0xffffffffffULL; |
| 255 | resource->flags = IORESOURCE_MEM | IORESOURCE_BRIDGE; |
Patrick Georgi | e166782 | 2012-05-05 15:29:32 +0200 | [diff] [blame] | 256 | #if CONFIG_EXT_CONF_SUPPORT |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 257 | if ((resource->index & 0x1fff) == 0x1110) { // ext |
| 258 | normalize_resource(resource); |
| 259 | } |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 260 | #endif |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 261 | } |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 262 | } |
| 263 | |
| 264 | static u32 my_find_pci_tolm(struct bus *bus, u32 tolm) |
| 265 | { |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 266 | struct resource *min; |
| 267 | min = 0; |
| 268 | search_bus_resources(bus, IORESOURCE_MEM, IORESOURCE_MEM, tolm_test, |
| 269 | &min); |
| 270 | if (min && tolm > min->base) { |
| 271 | tolm = min->base; |
| 272 | } |
| 273 | return tolm; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 274 | } |
| 275 | |
| 276 | #if CONFIG_HW_MEM_HOLE_SIZEK != 0 |
| 277 | |
| 278 | struct hw_mem_hole_info { |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 279 | unsigned hole_startk; |
| 280 | int node_id; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 281 | }; |
| 282 | |
| 283 | static struct hw_mem_hole_info get_hw_mem_hole_info(void) |
| 284 | { |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 285 | struct hw_mem_hole_info mem_hole; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 286 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 287 | mem_hole.hole_startk = CONFIG_HW_MEM_HOLE_SIZEK; |
| 288 | mem_hole.node_id = -1; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 289 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 290 | struct dram_base_mask_t d; |
| 291 | u32 hole; |
| 292 | d = get_dram_base_mask(0); |
| 293 | if (d.mask & 1) { |
| 294 | hole = pci_read_config32(__f1_dev[0], 0xf0); |
| 295 | if (hole & 1) { // we find the hole |
| 296 | mem_hole.hole_startk = (hole & (0xff << 24)) >> 10; |
| 297 | mem_hole.node_id = 0; // record the node No with hole |
| 298 | } |
| 299 | } |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 300 | #if 0 |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 301 | /* We need to double check if there is speical set on base reg and limit reg |
| 302 | * are not continous instead of hole, it will find out it's hole_startk |
| 303 | */ |
| 304 | if (mem_hole.node_id == -1) { |
| 305 | resource_t limitk_pri = 0; |
| 306 | struct dram_base_mask_t d; |
| 307 | resource_t base_k, limit_k; |
| 308 | d = get_dram_base_mask(0); |
| 309 | if (d.base & 1) { |
| 310 | base_k = ((resource_t) (d.base & 0x1fffff00)) << 9; |
| 311 | if (base_k <= 4 * 1024 * 1024) { |
| 312 | if (limitk_pri != base_k) { // we find the hole |
| 313 | mem_hole.hole_startk = (unsigned)limitk_pri; // must be below 4G |
| 314 | mem_hole.node_id = 0; |
| 315 | } |
| 316 | } |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 317 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 318 | limit_k = |
| 319 | ((resource_t) ((d.mask + 0x00000100) & 0x1fffff00)) |
| 320 | << 9; |
| 321 | limitk_pri = limit_k; |
| 322 | } |
| 323 | } |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 324 | #endif |
efdesign98 | 05a89ab | 2011-06-20 17:38:49 -0700 | [diff] [blame] | 325 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 326 | return mem_hole; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 327 | } |
| 328 | #endif |
| 329 | |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 330 | static void read_resources(device_t dev) |
| 331 | { |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 332 | u32 nodeid; |
| 333 | struct bus *link; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 334 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 335 | printk(BIOS_DEBUG, "\nFam14h - read_resources.\n"); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 336 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 337 | nodeid = amdfam14_nodeid(dev); |
| 338 | for (link = dev->link_list; link; link = link->next) { |
| 339 | if (link->children) { |
| 340 | amdfam14_link_read_bases(dev, nodeid, link->link_num); |
| 341 | } |
| 342 | } |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 343 | } |
| 344 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 345 | static void set_resource(device_t dev, struct resource *resource, u32 nodeid) |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 346 | { |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 347 | resource_t rbase, rend; |
| 348 | unsigned reg, link_num; |
| 349 | char buf[50]; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 350 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 351 | printk(BIOS_DEBUG, "\nFam14h - set_resource.\n"); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 352 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 353 | /* Make certain the resource has actually been set */ |
| 354 | if (!(resource->flags & IORESOURCE_ASSIGNED)) { |
| 355 | return; |
| 356 | } |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 357 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 358 | /* If I have already stored this resource don't worry about it */ |
| 359 | if (resource->flags & IORESOURCE_STORED) { |
| 360 | return; |
| 361 | } |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 362 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 363 | /* Only handle PCI memory and IO resources */ |
| 364 | if (!(resource->flags & (IORESOURCE_MEM | IORESOURCE_IO))) |
| 365 | return; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 366 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 367 | /* Ensure I am actually looking at a resource of function 1 */ |
| 368 | if ((resource->index & 0xffff) < 0x1000) { |
| 369 | return; |
| 370 | } |
| 371 | /* Get the base address */ |
| 372 | rbase = resource->base; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 373 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 374 | /* Get the limit (rounded up) */ |
| 375 | rend = resource_end(resource); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 376 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 377 | /* Get the register and link */ |
| 378 | reg = resource->index & 0xfff; // 4k |
| 379 | link_num = IOINDEX_LINK(resource->index); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 380 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 381 | if (resource->flags & IORESOURCE_IO) { |
| 382 | set_io_addr_reg(dev, nodeid, link_num, reg, rbase >> 8, |
| 383 | rend >> 8); |
| 384 | } else if (resource->flags & IORESOURCE_MEM) { |
| 385 | set_mmio_addr_reg(nodeid, link_num, reg, (resource->index >> 24), |
| 386 | rbase >> 8, rend >> 8, 1); // [39:8] |
| 387 | } |
| 388 | resource->flags |= IORESOURCE_STORED; |
| 389 | sprintf(buf, " <node %x link %x>", nodeid, link_num); |
| 390 | report_resource_stored(dev, resource, buf); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 391 | } |
| 392 | |
efdesign98 | 3f5ebd6 | 2011-09-14 13:47:17 -0600 | [diff] [blame] | 393 | #if CONFIG_CONSOLE_VGA_MULTI |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 394 | extern device_t vga_pri; // the primary vga device, defined in device.c |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 395 | #endif |
| 396 | |
| 397 | static void create_vga_resource(device_t dev, unsigned nodeid) |
| 398 | { |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 399 | struct bus *link; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 400 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 401 | printk(BIOS_DEBUG, "\nFam14h - create_vga_resource.\n"); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 402 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 403 | /* find out which link the VGA card is connected, |
| 404 | * we only deal with the 'first' vga card */ |
| 405 | for (link = dev->link_list; link; link = link->next) { |
| 406 | if (link->bridge_ctrl & PCI_BRIDGE_CTL_VGA) { |
efdesign98 | 3f5ebd6 | 2011-09-14 13:47:17 -0600 | [diff] [blame] | 407 | #if CONFIG_CONSOLE_VGA_MULTI |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 408 | printk(BIOS_DEBUG, |
| 409 | "VGA: vga_pri bus num = %d bus range [%d,%d]\n", |
| 410 | vga_pri->bus->secondary, link->secondary, |
| 411 | link->subordinate); |
| 412 | /* We need to make sure the vga_pri is under the link */ |
| 413 | if ((vga_pri->bus->secondary >= link->secondary) && |
| 414 | (vga_pri->bus->secondary <= link->subordinate)) |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 415 | #endif |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 416 | break; |
| 417 | } |
| 418 | } |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 419 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 420 | /* no VGA card installed */ |
| 421 | if (link == NULL) |
| 422 | return; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 423 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 424 | printk(BIOS_DEBUG, "VGA: %s (aka node %d) link %d has VGA device\n", |
| 425 | dev_path(dev), nodeid, link->link_num); |
| 426 | set_vga_enable_reg(nodeid, link->link_num); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 427 | } |
| 428 | |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 429 | static void set_resources(device_t dev) |
| 430 | { |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 431 | unsigned nodeid; |
| 432 | struct bus *bus; |
| 433 | struct resource *res; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 434 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 435 | printk(BIOS_DEBUG, "\nFam14h - set_resources.\n"); |
efdesign98 | 05a89ab | 2011-06-20 17:38:49 -0700 | [diff] [blame] | 436 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 437 | /* Find the nodeid */ |
| 438 | nodeid = amdfam14_nodeid(dev); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 439 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 440 | create_vga_resource(dev, nodeid); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 441 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 442 | /* Set each resource we have found */ |
| 443 | for (res = dev->resource_list; res; res = res->next) { |
| 444 | set_resource(dev, res, nodeid); |
| 445 | } |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 446 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 447 | for (bus = dev->link_list; bus; bus = bus->next) { |
| 448 | if (bus->children) { |
| 449 | assign_resources(bus); |
| 450 | } |
| 451 | } |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 452 | } |
| 453 | |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 454 | /* Domain/Root Complex related code */ |
| 455 | |
| 456 | static void domain_read_resources(device_t dev) |
| 457 | { |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 458 | unsigned reg; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 459 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 460 | printk(BIOS_DEBUG, "\nFam14h - domain_read_resources.\n"); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 461 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 462 | /* Find the already assigned resource pairs */ |
| 463 | get_fx_devs(); |
| 464 | for (reg = 0x80; reg <= 0xc0; reg += 0x08) { |
| 465 | u32 base, limit; |
| 466 | base = f1_read_config32(reg); |
| 467 | limit = f1_read_config32(reg + 0x04); |
| 468 | /* Is this register allocated? */ |
| 469 | if ((base & 3) != 0) { |
| 470 | unsigned nodeid, reg_link; |
| 471 | device_t reg_dev; |
| 472 | if (reg < 0xc0) { // mmio |
| 473 | nodeid = (limit & 0xf) + (base & 0x30); |
| 474 | } else { // io |
| 475 | nodeid = (limit & 0xf) + ((base >> 4) & 0x30); |
| 476 | } |
| 477 | reg_link = (limit >> 4) & 7; |
| 478 | reg_dev = __f0_dev[nodeid]; |
| 479 | if (reg_dev) { |
| 480 | /* Reserve the resource */ |
| 481 | struct resource *res; |
| 482 | res = |
| 483 | new_resource(reg_dev, |
| 484 | IOINDEX(0x1000 + reg, |
| 485 | reg_link)); |
| 486 | if (res) { |
| 487 | res->flags = 1; |
| 488 | } |
| 489 | } |
| 490 | } |
| 491 | } |
| 492 | /* FIXME: do we need to check extend conf space? |
| 493 | I don't believe that much preset value */ |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 494 | |
Patrick Georgi | e166782 | 2012-05-05 15:29:32 +0200 | [diff] [blame] | 495 | #if !CONFIG_PCI_64BIT_PREF_MEM |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 496 | pci_domain_read_resources(dev); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 497 | #else |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 498 | struct bus *link; |
| 499 | struct resource *resource; |
| 500 | for (link = dev->link_list; link; link = link->next) { |
| 501 | /* Initialize the system wide io space constraints */ |
| 502 | resource = new_resource(dev, 0 | (link->link_num << 2)); |
| 503 | resource->base = 0x400; |
| 504 | resource->limit = 0xffffUL; |
| 505 | resource->flags = IORESOURCE_IO; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 506 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 507 | /* Initialize the system wide prefetchable memory resources constraints */ |
| 508 | resource = new_resource(dev, 1 | (link->link_num << 2)); |
| 509 | resource->limit = 0xfcffffffffULL; |
| 510 | resource->flags = IORESOURCE_MEM | IORESOURCE_PREFETCH; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 511 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 512 | /* Initialize the system wide memory resources constraints */ |
| 513 | resource = new_resource(dev, 2 | (link->link_num << 2)); |
| 514 | resource->limit = 0xfcffffffffULL; |
| 515 | resource->flags = IORESOURCE_MEM; |
| 516 | } |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 517 | #endif |
| 518 | } |
| 519 | |
Kyösti Mälkki | 6b5eb1c | 2012-07-19 19:26:43 +0300 | [diff] [blame^] | 520 | static void setup_uma_memory(void) |
Kyösti Mälkki | 55fff930 | 2012-07-11 08:02:39 +0300 | [diff] [blame] | 521 | { |
| 522 | #if CONFIG_GFXUMA |
| 523 | msr_t msr, msr2; |
| 524 | uint32_t sys_mem; |
| 525 | |
| 526 | /* TOP_MEM: the top of DRAM below 4G */ |
| 527 | msr = rdmsr(TOP_MEM); |
| 528 | printk |
| 529 | (BIOS_INFO, "%s, TOP MEM: msr.lo = 0x%08x, msr.hi = 0x%08x\n", |
| 530 | __func__, msr.lo, msr.hi); |
| 531 | |
| 532 | /* TOP_MEM2: the top of DRAM above 4G */ |
| 533 | msr2 = rdmsr(TOP_MEM2); |
| 534 | printk |
| 535 | (BIOS_INFO, "%s, TOP MEM2: msr2.lo = 0x%08x, msr2.hi = 0x%08x\n", |
| 536 | __func__, msr2.lo, msr2.hi); |
| 537 | |
| 538 | /* refer to UMA Size Consideration in Family14h BKDG. */ |
| 539 | sys_mem = msr.lo + 0x1000000; // Ignore 16MB allocated for C6 when finding UMA size, refer MemNGetUmaSizeON() |
| 540 | if ((msr.hi & 0x0000000F) || (sys_mem >= 0x80000000)) { |
| 541 | uma_memory_size = 0x18000000; /* >= 2G memory, 384M recommended UMA */ |
| 542 | } |
| 543 | else { |
| 544 | if (sys_mem >= 0x40000000) { |
| 545 | uma_memory_size = 0x10000000; /* >= 1G memory, 256M recommended UMA */ |
| 546 | } else { |
| 547 | uma_memory_size = 0x4000000; /* <1G memory, 64M recommended UMA */ |
| 548 | } |
| 549 | } |
| 550 | |
| 551 | uma_memory_base = msr.lo - uma_memory_size; /* TOP_MEM1 */ |
| 552 | printk(BIOS_INFO, "%s: uma size 0x%08llx, memory start 0x%08llx\n", |
| 553 | __func__, uma_memory_size, uma_memory_base); |
| 554 | |
| 555 | /* TODO: TOP_MEM2 */ |
Kyösti Mälkki | 55fff930 | 2012-07-11 08:02:39 +0300 | [diff] [blame] | 556 | #endif |
| 557 | } |
| 558 | |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 559 | static void domain_set_resources(device_t dev) |
| 560 | { |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 561 | printk(BIOS_DEBUG, "\nFam14h - domain_set_resources.\n"); |
| 562 | printk(BIOS_DEBUG, " amsr - incoming dev = %08x\n", (u32) dev); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 563 | |
Patrick Georgi | e166782 | 2012-05-05 15:29:32 +0200 | [diff] [blame] | 564 | #if CONFIG_PCI_64BIT_PREF_MEM |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 565 | struct resource *io, *mem1, *mem2; |
| 566 | struct resource *res; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 567 | #endif |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 568 | unsigned long mmio_basek; |
| 569 | u32 pci_tolm; |
| 570 | int idx; |
| 571 | struct bus *link; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 572 | #if CONFIG_HW_MEM_HOLE_SIZEK != 0 |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 573 | struct hw_mem_hole_info mem_hole; |
| 574 | u32 reset_memhole = 1; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 575 | #endif |
| 576 | |
Kyösti Mälkki | 6b5eb1c | 2012-07-19 19:26:43 +0300 | [diff] [blame^] | 577 | setup_uma_memory(); |
| 578 | |
Patrick Georgi | e166782 | 2012-05-05 15:29:32 +0200 | [diff] [blame] | 579 | #if CONFIG_PCI_64BIT_PREF_MEM |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 580 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 581 | printk(BIOS_DEBUG, "adsr - CONFIG_PCI_64BIT_PREF_MEM is true.\n"); |
| 582 | for (link = dev->link_list; link; link = link->next) { |
| 583 | /* Now reallocate the pci resources memory with the |
| 584 | * highest addresses I can manage. |
| 585 | */ |
| 586 | mem1 = find_resource(dev, 1 | (link->link_num << 2)); |
| 587 | mem2 = find_resource(dev, 2 | (link->link_num << 2)); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 588 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 589 | printk(BIOS_DEBUG, |
| 590 | "base1: 0x%08Lx limit1: 0x%08Lx size: 0x%08Lx align: %d\n", |
| 591 | (u32) (mem1->base), (u32) (mem1->limit), |
| 592 | (u32) (mem1->size), u32) (mem1->align)); |
| 593 | printk(BIOS_DEBUG, |
| 594 | "base2: 0x%08Lx limit2: 0x%08Lx size: 0x%08Lx align: %d\n", |
| 595 | (u32) (mem2->base), (u32) (mem2->limit), |
| 596 | (u32) (mem2->size), (u32) (mem2->align)); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 597 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 598 | /* See if both resources have roughly the same limits */ |
| 599 | if (((mem1->limit <= 0xffffffff) && (mem2->limit <= 0xffffffff)) |
| 600 | || ((mem1->limit > 0xffffffff) |
| 601 | && (mem2->limit > 0xffffffff))) { |
| 602 | /* If so place the one with the most stringent alignment first |
| 603 | */ |
| 604 | if (mem2->align > mem1->align) { |
| 605 | struct resource *tmp; |
| 606 | tmp = mem1; |
| 607 | mem1 = mem2; |
| 608 | mem2 = tmp; |
| 609 | } |
| 610 | /* Now place the memory as high up as it will go */ |
| 611 | mem2->base = resource_max(mem2); |
| 612 | mem1->limit = mem2->base - 1; |
| 613 | mem1->base = resource_max(mem1); |
| 614 | } else { |
| 615 | /* Place the resources as high up as they will go */ |
| 616 | mem2->base = resource_max(mem2); |
| 617 | mem1->base = resource_max(mem1); |
| 618 | } |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 619 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 620 | printk(BIOS_DEBUG, |
| 621 | "base1: 0x%08Lx limit1: 0x%08Lx size: 0x%08Lx align: %d\n", |
| 622 | mem1->base, mem1->limit, mem1->size, mem1->align); |
| 623 | printk(BIOS_DEBUG, |
| 624 | "base2: 0x%08Lx limit2: 0x%08Lx size: 0x%08Lx align: %d\n", |
| 625 | mem2->base, mem2->limit, mem2->size, mem2->align); |
| 626 | } |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 627 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 628 | for (res = &dev->resource_list; res; res = res->next) { |
| 629 | res->flags |= IORESOURCE_ASSIGNED; |
| 630 | res->flags |= IORESOURCE_STORED; |
| 631 | report_resource_stored(dev, res, ""); |
| 632 | } |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 633 | #endif |
| 634 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 635 | pci_tolm = 0xffffffffUL; |
| 636 | for (link = dev->link_list; link; link = link->next) { |
| 637 | pci_tolm = my_find_pci_tolm(link, pci_tolm); |
| 638 | } |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 639 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 640 | // FIXME handle interleaved nodes. If you fix this here, please fix |
| 641 | // amdk8, too. |
| 642 | mmio_basek = pci_tolm >> 10; |
| 643 | /* Round mmio_basek to something the processor can support */ |
| 644 | mmio_basek &= ~((1 << 6) - 1); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 645 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 646 | // FIXME improve mtrr.c so we don't use up all of the mtrrs with a 64M |
| 647 | // MMIO hole. If you fix this here, please fix amdk8, too. |
| 648 | /* Round the mmio hole to 64M */ |
| 649 | mmio_basek &= ~((64 * 1024) - 1); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 650 | |
| 651 | #if CONFIG_HW_MEM_HOLE_SIZEK != 0 |
| 652 | /* if the hw mem hole is already set in raminit stage, here we will compare |
| 653 | * mmio_basek and hole_basek. if mmio_basek is bigger that hole_basek and will |
| 654 | * use hole_basek as mmio_basek and we don't need to reset hole. |
| 655 | * otherwise We reset the hole to the mmio_basek |
| 656 | */ |
| 657 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 658 | mem_hole = get_hw_mem_hole_info(); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 659 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 660 | // Use hole_basek as mmio_basek, and we don't need to reset hole anymore |
| 661 | if ((mem_hole.node_id != -1) && (mmio_basek > mem_hole.hole_startk)) { |
| 662 | mmio_basek = mem_hole.hole_startk; |
| 663 | reset_memhole = 0; |
| 664 | } |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 665 | #endif |
| 666 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 667 | idx = 0x10; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 668 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 669 | struct dram_base_mask_t d; |
| 670 | resource_t basek, limitk, sizek; // 4 1T |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 671 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 672 | d = get_dram_base_mask(0); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 673 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 674 | if (d.mask & 1) { |
| 675 | basek = ((resource_t) ((u64) d.base)) << 8; |
| 676 | limitk = (resource_t) (((u64) d.mask << 8) | 0xFFFFFF); |
| 677 | printk(BIOS_DEBUG, |
| 678 | "adsr: (before) basek = %llx, limitk = %llx.\n", basek, |
| 679 | limitk); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 680 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 681 | /* Convert these values to multiples of 1K for ease of math. */ |
| 682 | basek >>= 10; |
| 683 | limitk >>= 10; |
| 684 | sizek = limitk - basek + 1; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 685 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 686 | printk(BIOS_DEBUG, |
| 687 | "adsr: (after) basek = %llx, limitk = %llx, sizek = %llx.\n", |
| 688 | basek, limitk, sizek); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 689 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 690 | /* see if we need a hole from 0xa0000 to 0xbffff */ |
| 691 | if ((basek < 640) && (sizek > 768)) { |
| 692 | printk(BIOS_DEBUG,"adsr - 0xa0000 to 0xbffff resource.\n"); |
| 693 | ram_resource(dev, (idx | 0), basek, 640 - basek); |
| 694 | idx += 0x10; |
| 695 | basek = 768; |
| 696 | sizek = limitk - 768; |
| 697 | } |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 698 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 699 | printk(BIOS_DEBUG, |
| 700 | "adsr: mmio_basek=%08lx, basek=%08llx, limitk=%08llx\n", |
| 701 | mmio_basek, basek, limitk); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 702 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 703 | /* split the region to accomodate pci memory space */ |
| 704 | if ((basek < 4 * 1024 * 1024) && (limitk > mmio_basek)) { |
| 705 | if (basek <= mmio_basek) { |
| 706 | unsigned pre_sizek; |
| 707 | pre_sizek = mmio_basek - basek; |
| 708 | if (pre_sizek > 0) { |
| 709 | ram_resource(dev, idx, basek, |
| 710 | pre_sizek); |
| 711 | idx += 0x10; |
| 712 | sizek -= pre_sizek; |
Patrick Georgi | e166782 | 2012-05-05 15:29:32 +0200 | [diff] [blame] | 713 | #if CONFIG_WRITE_HIGH_TABLES |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 714 | if (high_tables_base == 0) { |
| 715 | /* Leave some space for ACPI, PIRQ and MP tables */ |
Patrick Georgi | e166782 | 2012-05-05 15:29:32 +0200 | [diff] [blame] | 716 | #if CONFIG_GFXUMA |
Marc Jones | 5750ed2 | 2012-03-15 13:21:41 -0600 | [diff] [blame] | 717 | high_tables_base = uma_memory_base - HIGH_MEMORY_SIZE; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 718 | #else |
Marc Jones | 5750ed2 | 2012-03-15 13:21:41 -0600 | [diff] [blame] | 719 | high_tables_base = (mmio_basek * 1024) - HIGH_MEMORY_SIZE; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 720 | #endif |
Marc Jones | 5750ed2 | 2012-03-15 13:21:41 -0600 | [diff] [blame] | 721 | high_tables_size = HIGH_MEMORY_SIZE; |
| 722 | printk(BIOS_DEBUG, " split: %dK table at =%08llx\n", |
| 723 | (u32)(high_tables_size / 1024), high_tables_base); |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 724 | } |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 725 | #endif |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 726 | } |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 727 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 728 | basek = mmio_basek; |
| 729 | } |
| 730 | if ((basek + sizek) <= 4 * 1024 * 1024) { |
| 731 | sizek = 0; |
| 732 | } else { |
| 733 | basek = 4 * 1024 * 1024; |
| 734 | sizek -= (4 * 1024 * 1024 - mmio_basek); |
| 735 | } |
| 736 | } |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 737 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 738 | ram_resource(dev, (idx | 0), basek, sizek); |
| 739 | idx += 0x10; |
Patrick Georgi | e166782 | 2012-05-05 15:29:32 +0200 | [diff] [blame] | 740 | #if CONFIG_WRITE_HIGH_TABLES |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 741 | printk(BIOS_DEBUG, |
| 742 | "%d: mmio_basek=%08lx, basek=%08llx, limitk=%08llx\n", 0, |
| 743 | mmio_basek, basek, limitk); |
| 744 | if (high_tables_base == 0) { |
| 745 | /* Leave some space for ACPI, PIRQ and MP tables */ |
Patrick Georgi | e166782 | 2012-05-05 15:29:32 +0200 | [diff] [blame] | 746 | #if CONFIG_GFXUMA |
Marc Jones | 5750ed2 | 2012-03-15 13:21:41 -0600 | [diff] [blame] | 747 | high_tables_base = uma_memory_base - HIGH_MEMORY_SIZE; |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 748 | printk(BIOS_DEBUG, " adsr - uma_memory_base = %llx.\n", uma_memory_base); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 749 | #else |
Marc Jones | 5750ed2 | 2012-03-15 13:21:41 -0600 | [diff] [blame] | 750 | high_tables_base = (limitk * 1024) - HIGH_MEMORY_SIZE; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 751 | #endif |
Marc Jones | 5750ed2 | 2012-03-15 13:21:41 -0600 | [diff] [blame] | 752 | high_tables_size = HIGH_MEMORY_SIZE; |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 753 | } |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 754 | #endif |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 755 | } |
| 756 | printk(BIOS_DEBUG, " adsr - mmio_basek = %lx.\n", mmio_basek); |
| 757 | printk(BIOS_DEBUG, " adsr - high_tables_size = %llx.\n", |
| 758 | high_tables_size); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 759 | |
Patrick Georgi | e166782 | 2012-05-05 15:29:32 +0200 | [diff] [blame] | 760 | #if CONFIG_GFXUMA |
Kyösti Mälkki | 63f8c08 | 2012-07-10 13:27:26 +0300 | [diff] [blame] | 761 | uma_resource(dev, 7, uma_memory_base >> 10, uma_memory_size >> 10); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 762 | #endif |
| 763 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 764 | for (link = dev->link_list; link; link = link->next) { |
| 765 | if (link->children) { |
| 766 | assign_resources(link); |
| 767 | } |
| 768 | } |
| 769 | printk(BIOS_DEBUG, " adsr - leaving this lovely routine.\n"); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 770 | } |
| 771 | |
zbao | f722373 | 2012-04-13 13:42:15 +0800 | [diff] [blame] | 772 | extern u8 acpi_slp_type; |
| 773 | |
| 774 | static void domain_enable_resources(device_t dev) |
| 775 | { |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 776 | u32 val; |
Kerry She | feed329 | 2011-08-18 18:03:44 +0800 | [diff] [blame] | 777 | |
| 778 | #if CONFIG_AMD_SB_CIMX |
zbao | f722373 | 2012-04-13 13:42:15 +0800 | [diff] [blame] | 779 | #if CONFIG_HAVE_ACPI_RESUME |
| 780 | if (acpi_slp_type != 3) { |
| 781 | sb_After_Pci_Init(); |
| 782 | sb_Mid_Post_Init(); |
| 783 | } else { |
| 784 | sb_After_Pci_Restore_Init(); |
| 785 | } |
| 786 | #else |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 787 | sb_After_Pci_Init(); |
| 788 | sb_Mid_Post_Init(); |
zbao | f722373 | 2012-04-13 13:42:15 +0800 | [diff] [blame] | 789 | #endif |
Kerry She | feed329 | 2011-08-18 18:03:44 +0800 | [diff] [blame] | 790 | #endif |
| 791 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 792 | /* Must be called after PCI enumeration and resource allocation */ |
| 793 | printk(BIOS_DEBUG, "\nFam14h - domain_enable_resources: AmdInitMid.\n"); |
zbao | f722373 | 2012-04-13 13:42:15 +0800 | [diff] [blame] | 794 | |
| 795 | #if CONFIG_HAVE_ACPI_RESUME |
| 796 | if (acpi_slp_type != 3) { |
| 797 | printk(BIOS_DEBUG, "agesawrapper_amdinitmid "); |
| 798 | val = agesawrapper_amdinitmid (); |
| 799 | if (val) |
| 800 | printk(BIOS_DEBUG, "error level: %x \n", val); |
| 801 | else |
| 802 | printk(BIOS_DEBUG, "passed.\n"); |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 803 | } |
zbao | f722373 | 2012-04-13 13:42:15 +0800 | [diff] [blame] | 804 | #else |
| 805 | printk(BIOS_DEBUG, "agesawrapper_amdinitmid "); |
| 806 | val = agesawrapper_amdinitmid (); |
| 807 | if (val) |
| 808 | printk(BIOS_DEBUG, "error level: %x \n", val); |
| 809 | else |
| 810 | printk(BIOS_DEBUG, "passed.\n"); |
| 811 | #endif |
efdesign98 | 05a89ab | 2011-06-20 17:38:49 -0700 | [diff] [blame] | 812 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 813 | printk(BIOS_DEBUG, " ader - leaving domain_enable_resources.\n"); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 814 | } |
| 815 | |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 816 | /* Bus related code */ |
| 817 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 818 | static void cpu_bus_read_resources(device_t dev) { |
| 819 | printk(BIOS_DEBUG, "\nFam14h - cpu_bus_read_resources.\n"); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 820 | |
| 821 | #if CONFIG_MMCONF_SUPPORT |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 822 | struct resource *resource = new_resource(dev, 0xc0010058); |
| 823 | resource->base = CONFIG_MMCONF_BASE_ADDRESS; |
| 824 | resource->size = CONFIG_MMCONF_BUS_NUMBER * 4096 * 256; |
| 825 | resource->flags = IORESOURCE_MEM | IORESOURCE_RESERVE | |
| 826 | IORESOURCE_FIXED | IORESOURCE_STORED | IORESOURCE_ASSIGNED; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 827 | #endif |
| 828 | } |
| 829 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 830 | static void cpu_bus_set_resources(device_t dev) { |
| 831 | struct resource *resource = find_resource(dev, 0xc0010058); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 832 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 833 | printk(BIOS_DEBUG, "\nFam14h - cpu_bus_set_resources.\n"); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 834 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 835 | if (resource) { |
| 836 | report_resource_stored(dev, resource, " <mmconfig>"); |
| 837 | } |
| 838 | pci_dev_set_resources(dev); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 839 | } |
efdesign98 | 05a89ab | 2011-06-20 17:38:49 -0700 | [diff] [blame] | 840 | |
zbao | f722373 | 2012-04-13 13:42:15 +0800 | [diff] [blame] | 841 | static u32 cpu_bus_scan(device_t dev, u32 max) |
| 842 | { |
Scott Duplichan | 9ab3c6c | 2011-05-15 21:45:46 +0000 | [diff] [blame] | 843 | device_t cpu; |
zbao | f722373 | 2012-04-13 13:42:15 +0800 | [diff] [blame] | 844 | struct device_path cpu_path; |
| 845 | int apic_id, cores_found; |
Scott Duplichan | 9ab3c6c | 2011-05-15 21:45:46 +0000 | [diff] [blame] | 846 | |
zbao | f722373 | 2012-04-13 13:42:15 +0800 | [diff] [blame] | 847 | /* There is only one node for fam14, but there may be multiple cores. */ |
| 848 | cpu = dev_find_slot(0, PCI_DEVFN(0x18, 0)); |
| 849 | if (!cpu) |
| 850 | printk(BIOS_ERR, "ERROR: %02x:%02x.0 not found", 0, 0x18); |
Scott Duplichan | 9ab3c6c | 2011-05-15 21:45:46 +0000 | [diff] [blame] | 851 | |
zbao | f722373 | 2012-04-13 13:42:15 +0800 | [diff] [blame] | 852 | cores_found = (pci_read_config32(dev_find_slot(0,PCI_DEVFN(0x18,0x3)), 0xe8) >> 12) & 3; |
| 853 | printk(BIOS_DEBUG, " AP siblings=%d\n", cores_found); |
| 854 | |
| 855 | |
| 856 | for (apic_id = 0; apic_id <= cores_found; apic_id++) { |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 857 | cpu_path.type = DEVICE_PATH_APIC; |
| 858 | cpu_path.apic.apic_id = apic_id; |
zbao | f722373 | 2012-04-13 13:42:15 +0800 | [diff] [blame] | 859 | cpu = alloc_find_dev(dev->link_list, &cpu_path); |
| 860 | if (cpu) { |
| 861 | cpu->enabled = 1; |
| 862 | cpu->path.apic.node_id = 0; |
| 863 | cpu->path.apic.core_id = apic_id; |
| 864 | printk(BIOS_DEBUG, "CPU: %s %s\n", |
| 865 | dev_path(cpu), cpu->enabled?"enabled":"disabled"); |
| 866 | } else { |
| 867 | cpu->enabled = 0; |
| 868 | } |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 869 | } |
zbao | f722373 | 2012-04-13 13:42:15 +0800 | [diff] [blame] | 870 | return max; |
| 871 | } |
| 872 | |
| 873 | static void cpu_bus_init(device_t dev) |
| 874 | { |
| 875 | initialize_cpus(dev->link_list); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 876 | } |
| 877 | |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 878 | /* North Bridge Structures */ |
| 879 | |
| 880 | static struct device_operations northbridge_operations = { |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 881 | .read_resources = read_resources, |
| 882 | .set_resources = set_resources, |
| 883 | .enable_resources = pci_dev_enable_resources, |
| 884 | .init = northbridge_init, |
| 885 | .enable = 0,.ops_pci = 0, |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 886 | }; |
| 887 | |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 888 | static const struct pci_driver northbridge_driver __pci_driver = { |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 889 | .ops = &northbridge_operations, |
| 890 | .vendor = PCI_VENDOR_ID_AMD, |
| 891 | .device = 0x1510, |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 892 | }; |
| 893 | |
efdesign98 | 05a89ab | 2011-06-20 17:38:49 -0700 | [diff] [blame] | 894 | struct chip_operations northbridge_amd_agesa_family14_ops = { |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 895 | CHIP_NAME("AMD Family 14h Northbridge") |
| 896 | .enable_dev = 0, |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 897 | }; |
| 898 | |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 899 | /* Root Complex Structures */ |
| 900 | |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 901 | static struct device_operations pci_domain_ops = { |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 902 | .read_resources = domain_read_resources, |
| 903 | .set_resources = domain_set_resources, |
| 904 | .enable_resources = domain_enable_resources, |
| 905 | .init = NULL, |
| 906 | .scan_bus = pci_domain_scan_bus, |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 907 | }; |
| 908 | |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 909 | static struct device_operations cpu_bus_ops = { |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 910 | .read_resources = cpu_bus_read_resources, |
| 911 | .set_resources = cpu_bus_set_resources, |
| 912 | .enable_resources = NULL, |
| 913 | .init = cpu_bus_init, |
zbao | f722373 | 2012-04-13 13:42:15 +0800 | [diff] [blame] | 914 | .scan_bus = cpu_bus_scan, |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 915 | }; |
| 916 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 917 | static void root_complex_enable_dev(struct device *dev) { |
| 918 | /* Set the operations if it is a special bus type */ |
| 919 | if (dev->path.type == DEVICE_PATH_PCI_DOMAIN) { |
| 920 | dev->ops = &pci_domain_ops; |
| 921 | } else if (dev->path.type == DEVICE_PATH_APIC_CLUSTER) { |
| 922 | dev->ops = &cpu_bus_ops; |
| 923 | } |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 924 | } |
| 925 | |
efdesign98 | 05a89ab | 2011-06-20 17:38:49 -0700 | [diff] [blame] | 926 | struct chip_operations northbridge_amd_agesa_family14_root_complex_ops = { |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 927 | CHIP_NAME("AMD Family 14h Root Complex") |
| 928 | .enable_dev = root_complex_enable_dev, |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 929 | }; |