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