Angel Pons | 4b42983 | 2020-04-02 23:48:50 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 2 | |
| 3 | #include <console/console.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 4 | #include <device/pci_ops.h> |
Furquan Shaikh | 76cedd2 | 2020-05-02 10:24:23 -0700 | [diff] [blame] | 5 | #include <acpi/acpi.h> |
| 6 | #include <acpi/acpigen.h> |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 7 | #include <stdint.h> |
| 8 | #include <device/device.h> |
| 9 | #include <device/pci.h> |
| 10 | #include <device/pci_ids.h> |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 11 | #include <string.h> |
Ronald G. Minnich | 5079a0d | 2012-11-27 11:32:38 -0800 | [diff] [blame] | 12 | #include <lib.h> |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 13 | #include <cpu/cpu.h> |
Elyes HAOUAS | 400ce55 | 2018-10-12 10:54:30 +0200 | [diff] [blame] | 14 | #include <cpu/amd/msr.h> |
Kyösti Mälkki | 55fff930 | 2012-07-11 08:02:39 +0300 | [diff] [blame] | 15 | #include <cpu/amd/mtrr.h> |
Angel Pons | ec5cf15 | 2020-11-10 20:42:07 +0100 | [diff] [blame] | 16 | #include <northbridge/amd/nb_common.h> |
Kyösti Mälkki | 28c4d2f | 2016-11-25 11:21:02 +0200 | [diff] [blame] | 17 | #include <northbridge/amd/agesa/state_machine.h> |
Kyösti Mälkki | d610c58 | 2017-03-05 06:28:18 +0200 | [diff] [blame] | 18 | #include <northbridge/amd/agesa/agesa_helper.h> |
Kerry She | feed329 | 2011-08-18 18:03:44 +0800 | [diff] [blame] | 19 | #include <sb_cimx.h> |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 20 | |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 21 | #define FX_DEVS 1 |
| 22 | |
Kyösti Mälkki | e2c2a4c | 2018-05-20 20:59:52 +0300 | [diff] [blame] | 23 | static struct device *__f0_dev[FX_DEVS]; |
| 24 | static struct device *__f1_dev[FX_DEVS]; |
| 25 | static struct device *__f2_dev[FX_DEVS]; |
| 26 | static struct device *__f4_dev[FX_DEVS]; |
Subrata Banik | b1434fc | 2019-03-15 22:20:41 +0530 | [diff] [blame] | 27 | static unsigned int fx_devs = 0; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 28 | |
Kyösti Mälkki | 2b218e3 | 2019-01-15 11:14:28 +0200 | [diff] [blame] | 29 | static u32 get_io_addr_index(u32 nodeid, u32 linkn) |
| 30 | { |
| 31 | return 0; |
| 32 | } |
| 33 | |
| 34 | static u32 get_mmio_addr_index(u32 nodeid, u32 linkn) |
| 35 | { |
| 36 | return 0; |
| 37 | } |
| 38 | |
| 39 | static void set_io_addr_reg(struct device *dev, u32 nodeid, u32 linkn, u32 reg, |
| 40 | u32 io_min, u32 io_max) |
| 41 | { |
| 42 | |
| 43 | u32 tempreg; |
| 44 | /* io range allocation */ |
| 45 | tempreg = (nodeid & 0xf) | ((nodeid & 0x30) << (8 - 4)) | (linkn << 4) | |
| 46 | ((io_max & 0xf0) << (12 - 4)); //limit |
Elyes Haouas | 3adfde9 | 2022-07-16 09:36:01 +0200 | [diff] [blame^] | 47 | pci_write_config32(__f1_dev[0], reg + 4, tempreg); |
Kyösti Mälkki | 2b218e3 | 2019-01-15 11:14:28 +0200 | [diff] [blame] | 48 | |
| 49 | tempreg = 3 | ((io_min & 0xf0) << (12 - 4)); //base :ISA and VGA ? |
| 50 | pci_write_config32(__f1_dev[0], reg, tempreg); |
| 51 | } |
| 52 | |
| 53 | static void set_mmio_addr_reg(u32 nodeid, u32 linkn, u32 reg, u32 index, |
| 54 | u32 mmio_min, u32 mmio_max, u32 nodes) |
| 55 | { |
| 56 | |
| 57 | u32 tempreg; |
| 58 | /* io range allocation */ |
| 59 | tempreg = (nodeid & 0xf) | (linkn << 4) | (mmio_max & 0xffffff00); |
| 60 | pci_write_config32(__f1_dev[0], reg + 4, tempreg); |
| 61 | tempreg = 3 | (nodeid & 0x30) | (mmio_min & 0xffffff00); |
| 62 | pci_write_config32(__f1_dev[0], reg, tempreg); |
| 63 | } |
| 64 | |
Kyösti Mälkki | e2c2a4c | 2018-05-20 20:59:52 +0300 | [diff] [blame] | 65 | static struct device *get_node_pci(u32 nodeid, u32 fn) |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 66 | { |
Kyösti Mälkki | 3d3152e | 2019-01-10 09:05:30 +0200 | [diff] [blame] | 67 | return pcidev_on_root(DEV_CDB + nodeid, fn); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 68 | } |
| 69 | |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 70 | static void get_fx_devs(void) |
| 71 | { |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 72 | int i; |
| 73 | for (i = 0; i < FX_DEVS; i++) { |
| 74 | __f0_dev[i] = get_node_pci(i, 0); |
| 75 | __f1_dev[i] = get_node_pci(i, 1); |
| 76 | __f2_dev[i] = get_node_pci(i, 2); |
| 77 | __f4_dev[i] = get_node_pci(i, 4); |
| 78 | if (__f0_dev[i] != NULL && __f1_dev[i] != NULL) |
| 79 | fx_devs = i + 1; |
| 80 | } |
| 81 | if (__f1_dev[0] == NULL || __f0_dev[0] == NULL || fx_devs == 0) { |
| 82 | die("Cannot find 0:0x18.[0|1]\n"); |
| 83 | } |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 84 | } |
| 85 | |
Subrata Banik | b1434fc | 2019-03-15 22:20:41 +0530 | [diff] [blame] | 86 | static u32 f1_read_config32(unsigned int reg) |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 87 | { |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 88 | if (fx_devs == 0) |
| 89 | get_fx_devs(); |
| 90 | return pci_read_config32(__f1_dev[0], reg); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 91 | } |
| 92 | |
Subrata Banik | b1434fc | 2019-03-15 22:20:41 +0530 | [diff] [blame] | 93 | static void f1_write_config32(unsigned int reg, u32 value) |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 94 | { |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 95 | int i; |
| 96 | if (fx_devs == 0) |
| 97 | get_fx_devs(); |
| 98 | for (i = 0; i < fx_devs; i++) { |
Elyes HAOUAS | 0d7c7a8 | 2018-05-09 17:58:33 +0200 | [diff] [blame] | 99 | struct device *dev; |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 100 | dev = __f1_dev[i]; |
| 101 | if (dev && dev->enabled) { |
| 102 | pci_write_config32(dev, reg, value); |
| 103 | } |
| 104 | } |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 105 | } |
| 106 | |
Michał Żygowski | 88a0ce6 | 2021-05-05 09:52:59 +0200 | [diff] [blame] | 107 | static int get_dram_base_limit(u32 nodeid, resource_t *basek, resource_t *limitk) |
| 108 | { |
| 109 | u32 temp; |
| 110 | |
| 111 | if (fx_devs == 0) |
| 112 | get_fx_devs(); |
| 113 | |
| 114 | |
| 115 | temp = pci_read_config32(__f1_dev[nodeid], 0x40 + (nodeid << 3)); //[39:24] at [31:16] |
| 116 | if (!(temp & 1)) |
| 117 | return 0; // this memory range is not enabled |
| 118 | /* |
| 119 | * BKDG: {DramBase[35:24], 00_0000h} <= address[35:0] so shift left by 8 bits |
| 120 | * for physical address and the convert to KiB by shifting 10 bits left |
| 121 | */ |
| 122 | *basek = ((temp & 0x0fff0000)) >> (10 - 8); |
| 123 | /* |
| 124 | * BKDG address[35:0] <= {DramLimit[35:24], FF_FFFFh} converted as above but |
| 125 | * ORed with 0xffff to get real limit before shifting. |
| 126 | */ |
| 127 | temp = pci_read_config32(__f1_dev[nodeid], 0x44 + (nodeid << 3)); //[39:24] at [31:16] |
| 128 | *limitk = ((temp & 0x0fff0000) | 0xffff) >> (10 - 8); |
| 129 | *limitk += 1; // round up last byte |
| 130 | |
| 131 | return 1; |
| 132 | } |
| 133 | |
Elyes HAOUAS | 0d7c7a8 | 2018-05-09 17:58:33 +0200 | [diff] [blame] | 134 | static u32 amdfam14_nodeid(struct device *dev) |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 135 | { |
Kyösti Mälkki | 3d3152e | 2019-01-10 09:05:30 +0200 | [diff] [blame] | 136 | return (dev->path.pci.devfn >> 3) - DEV_CDB; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 137 | } |
| 138 | |
Elyes HAOUAS | 0d7c7a8 | 2018-05-09 17:58:33 +0200 | [diff] [blame] | 139 | static void northbridge_init(struct device *dev) |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 140 | { |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 141 | printk(BIOS_DEBUG, "Northbridge init\n"); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 142 | } |
| 143 | |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 144 | static void set_vga_enable_reg(u32 nodeid, u32 linkn) |
| 145 | { |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 146 | u32 val; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 147 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 148 | val = 1 | (nodeid << 4) | (linkn << 12); |
| 149 | /* it will routing (1)mmio 0xa0000:0xbffff (2) io 0x3b0:0x3bb, |
| 150 | 0x3c0:0x3df */ |
| 151 | f1_write_config32(0xf4, val); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 152 | |
| 153 | } |
| 154 | |
Subrata Banik | b1434fc | 2019-03-15 22:20:41 +0530 | [diff] [blame] | 155 | static int reg_useable(unsigned int reg, struct device *goal_dev, |
| 156 | unsigned int goal_nodeid, unsigned int goal_link) |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 157 | { |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 158 | struct resource *res; |
Subrata Banik | b1434fc | 2019-03-15 22:20:41 +0530 | [diff] [blame] | 159 | unsigned int nodeid, link = 0; |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 160 | int result; |
| 161 | res = 0; |
| 162 | for (nodeid = 0; !res && (nodeid < fx_devs); nodeid++) { |
Elyes HAOUAS | 0d7c7a8 | 2018-05-09 17:58:33 +0200 | [diff] [blame] | 163 | struct device *dev; |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 164 | dev = __f0_dev[nodeid]; |
| 165 | if (!dev) |
| 166 | continue; |
| 167 | for (link = 0; !res && (link < 8); link++) { |
| 168 | res = probe_resource(dev, IOINDEX(0x1000 + reg, link)); |
| 169 | } |
| 170 | } |
| 171 | result = 2; |
| 172 | if (res) { |
| 173 | result = 0; |
| 174 | if ((goal_link == (link - 1)) && |
| 175 | (goal_nodeid == (nodeid - 1)) && (res->flags <= 1)) { |
| 176 | result = 1; |
| 177 | } |
| 178 | } |
| 179 | return result; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 180 | } |
| 181 | |
Elyes HAOUAS | 0d7c7a8 | 2018-05-09 17:58:33 +0200 | [diff] [blame] | 182 | static struct resource *amdfam14_find_iopair(struct device *dev, |
Subrata Banik | b1434fc | 2019-03-15 22:20:41 +0530 | [diff] [blame] | 183 | unsigned int nodeid, unsigned int link) |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 184 | { |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 185 | struct resource *resource; |
| 186 | u32 result, reg; |
| 187 | resource = 0; |
| 188 | reg = 0; |
| 189 | result = reg_useable(0xc0, dev, nodeid, link); |
| 190 | if (result >= 1) { |
| 191 | /* I have been allocated this one */ |
| 192 | reg = 0xc0; |
| 193 | } |
| 194 | /* Ext conf space */ |
| 195 | if (!reg) { |
| 196 | /* Because of Extend conf space, we will never run out of reg, |
Elyes HAOUAS | a342f39 | 2018-10-17 10:56:26 +0200 | [diff] [blame] | 197 | * but we need one index to differ them. So,same node and same |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 198 | * link can have multi range |
| 199 | */ |
| 200 | u32 index = get_io_addr_index(nodeid, link); |
| 201 | reg = 0x110 + (index << 24) + (4 << 20); // index could be 0, 255 |
| 202 | } |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 203 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 204 | resource = new_resource(dev, IOINDEX(0x1000 + reg, link)); |
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 | return resource; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 207 | } |
| 208 | |
Elyes HAOUAS | 0d7c7a8 | 2018-05-09 17:58:33 +0200 | [diff] [blame] | 209 | static struct resource *amdfam14_find_mempair(struct device *dev, u32 nodeid, |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 210 | u32 link) |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 211 | { |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 212 | struct resource *resource; |
| 213 | u32 free_reg, reg; |
| 214 | resource = 0; |
| 215 | free_reg = 0; |
| 216 | for (reg = 0x80; reg <= 0xb8; reg += 0x8) { |
| 217 | int result; |
| 218 | result = reg_useable(reg, dev, nodeid, link); |
| 219 | if (result == 1) { |
| 220 | /* I have been allocated this one */ |
| 221 | break; |
| 222 | } else if (result > 1) { |
| 223 | /* I have a free register pair */ |
| 224 | free_reg = reg; |
| 225 | } |
| 226 | } |
| 227 | if (reg > 0xb8) { |
| 228 | reg = free_reg; |
| 229 | } |
| 230 | /* Ext conf space */ |
| 231 | if (!reg) { |
| 232 | /* Because of Extend conf space, we will never run out of reg, |
Elyes HAOUAS | a342f39 | 2018-10-17 10:56:26 +0200 | [diff] [blame] | 233 | * but we need one index to differ them. So,same node and same |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 234 | * link can have multi range |
| 235 | */ |
| 236 | u32 index = get_mmio_addr_index(nodeid, link); |
| 237 | reg = 0x110 + (index << 24) + (6 << 20); // index could be 0, 63 |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 238 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 239 | } |
| 240 | resource = new_resource(dev, IOINDEX(0x1000 + reg, link)); |
| 241 | return resource; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 242 | } |
| 243 | |
Elyes HAOUAS | 0d7c7a8 | 2018-05-09 17:58:33 +0200 | [diff] [blame] | 244 | static void amdfam14_link_read_bases(struct device *dev, u32 nodeid, u32 link) |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 245 | { |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 246 | struct resource *resource; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 247 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 248 | /* Initialize the io space constraints on the current bus */ |
| 249 | resource = amdfam14_find_iopair(dev, nodeid, link); |
| 250 | if (resource) { |
| 251 | u32 align; |
Kyösti Mälkki | ac7402d | 2014-12-14 08:30:17 +0200 | [diff] [blame] | 252 | align = log2(HT_IO_HOST_ALIGN); |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 253 | resource->base = 0; |
| 254 | resource->size = 0; |
| 255 | resource->align = align; |
| 256 | resource->gran = align; |
| 257 | resource->limit = 0xffffUL; |
| 258 | resource->flags = IORESOURCE_IO | IORESOURCE_BRIDGE; |
| 259 | } |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 260 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 261 | /* Initialize the prefetchable memory constraints on the current bus */ |
| 262 | resource = amdfam14_find_mempair(dev, nodeid, link); |
| 263 | if (resource) { |
| 264 | resource->base = 0; |
| 265 | resource->size = 0; |
| 266 | resource->align = log2(HT_MEM_HOST_ALIGN); |
| 267 | resource->gran = log2(HT_MEM_HOST_ALIGN); |
| 268 | resource->limit = 0xffffffffffULL; |
| 269 | resource->flags = IORESOURCE_MEM | IORESOURCE_PREFETCH; |
| 270 | resource->flags |= IORESOURCE_BRIDGE; |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 271 | } |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 272 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 273 | /* Initialize the memory constraints on the current bus */ |
| 274 | resource = amdfam14_find_mempair(dev, nodeid, link); |
| 275 | if (resource) { |
| 276 | resource->base = 0; |
| 277 | resource->size = 0; |
| 278 | resource->align = log2(HT_MEM_HOST_ALIGN); |
| 279 | resource->gran = log2(HT_MEM_HOST_ALIGN); |
| 280 | resource->limit = 0xffffffffffULL; |
| 281 | resource->flags = IORESOURCE_MEM | IORESOURCE_BRIDGE; |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 282 | } |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 283 | } |
| 284 | |
| 285 | static u32 my_find_pci_tolm(struct bus *bus, u32 tolm) |
| 286 | { |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 287 | struct resource *min; |
Furquan Shaikh | afaae8a | 2020-05-18 16:00:53 -0700 | [diff] [blame] | 288 | unsigned long mask_match = IORESOURCE_MEM | IORESOURCE_ASSIGNED; |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 289 | min = 0; |
Furquan Shaikh | afaae8a | 2020-05-18 16:00:53 -0700 | [diff] [blame] | 290 | search_bus_resources(bus, mask_match, mask_match, tolm_test, |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 291 | &min); |
| 292 | if (min && tolm > min->base) { |
| 293 | tolm = min->base; |
| 294 | } |
| 295 | return tolm; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 296 | } |
| 297 | |
| 298 | #if CONFIG_HW_MEM_HOLE_SIZEK != 0 |
| 299 | |
| 300 | struct hw_mem_hole_info { |
Subrata Banik | b1434fc | 2019-03-15 22:20:41 +0530 | [diff] [blame] | 301 | unsigned int hole_startk; |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 302 | int node_id; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 303 | }; |
| 304 | |
| 305 | static struct hw_mem_hole_info get_hw_mem_hole_info(void) |
| 306 | { |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 307 | struct hw_mem_hole_info mem_hole; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 308 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 309 | mem_hole.hole_startk = CONFIG_HW_MEM_HOLE_SIZEK; |
| 310 | mem_hole.node_id = -1; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 311 | |
Michał Żygowski | 88a0ce6 | 2021-05-05 09:52:59 +0200 | [diff] [blame] | 312 | resource_t basek, limitk; |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 313 | u32 hole; |
Michał Żygowski | 88a0ce6 | 2021-05-05 09:52:59 +0200 | [diff] [blame] | 314 | |
| 315 | if (get_dram_base_limit(0, &basek, &limitk)) { |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 316 | hole = pci_read_config32(__f1_dev[0], 0xf0); |
| 317 | if (hole & 1) { // we find the hole |
| 318 | mem_hole.hole_startk = (hole & (0xff << 24)) >> 10; |
| 319 | mem_hole.node_id = 0; // record the node No with hole |
| 320 | } |
| 321 | } |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 322 | return mem_hole; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 323 | } |
| 324 | #endif |
| 325 | |
Elyes HAOUAS | 0d7c7a8 | 2018-05-09 17:58:33 +0200 | [diff] [blame] | 326 | static void nb_read_resources(struct device *dev) |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 327 | { |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 328 | u32 nodeid; |
| 329 | struct bus *link; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 330 | |
Mike Loptien | 58089e8 | 2013-01-29 15:45:09 -0700 | [diff] [blame] | 331 | printk(BIOS_DEBUG, "\nFam14h - %s\n", __func__); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 332 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 333 | nodeid = amdfam14_nodeid(dev); |
| 334 | for (link = dev->link_list; link; link = link->next) { |
| 335 | if (link->children) { |
| 336 | amdfam14_link_read_bases(dev, nodeid, link->link_num); |
| 337 | } |
| 338 | } |
Marc Jones | d5c998b | 2013-01-16 17:14:24 -0700 | [diff] [blame] | 339 | |
| 340 | /* |
Stefan Reinauer | 4aff445 | 2013-02-12 14:17:15 -0800 | [diff] [blame] | 341 | * This MMCONF resource must be reserved in the PCI domain. |
Marc Jones | d5c998b | 2013-01-16 17:14:24 -0700 | [diff] [blame] | 342 | * 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] | 343 | * the CPU_CLUSTER. |
Marc Jones | d5c998b | 2013-01-16 17:14:24 -0700 | [diff] [blame] | 344 | */ |
Elyes HAOUAS | 400ce55 | 2018-10-12 10:54:30 +0200 | [diff] [blame] | 345 | mmconf_resource(dev, MMIO_CONF_BASE); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 346 | } |
| 347 | |
Elyes HAOUAS | 0d7c7a8 | 2018-05-09 17:58:33 +0200 | [diff] [blame] | 348 | static void set_resource(struct device *dev, struct resource *resource, |
| 349 | u32 nodeid) |
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 | resource_t rbase, rend; |
Subrata Banik | b1434fc | 2019-03-15 22:20:41 +0530 | [diff] [blame] | 352 | unsigned int reg, link_num; |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 353 | char buf[50]; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 354 | |
Mike Loptien | 58089e8 | 2013-01-29 15:45:09 -0700 | [diff] [blame] | 355 | printk(BIOS_DEBUG, "\nFam14h - %s\n", __func__); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 356 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 357 | /* Make certain the resource has actually been set */ |
| 358 | if (!(resource->flags & IORESOURCE_ASSIGNED)) { |
| 359 | return; |
| 360 | } |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 361 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 362 | /* If I have already stored this resource don't worry about it */ |
| 363 | if (resource->flags & IORESOURCE_STORED) { |
| 364 | return; |
| 365 | } |
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 | /* Only handle PCI memory and IO resources */ |
| 368 | if (!(resource->flags & (IORESOURCE_MEM | IORESOURCE_IO))) |
| 369 | return; |
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 | /* Ensure I am actually looking at a resource of function 1 */ |
| 372 | if ((resource->index & 0xffff) < 0x1000) { |
| 373 | return; |
| 374 | } |
| 375 | /* Get the base address */ |
| 376 | rbase = resource->base; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 377 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 378 | /* Get the limit (rounded up) */ |
| 379 | rend = resource_end(resource); |
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 | /* Get the register and link */ |
| 382 | reg = resource->index & 0xfff; // 4k |
| 383 | link_num = IOINDEX_LINK(resource->index); |
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 | if (resource->flags & IORESOURCE_IO) { |
| 386 | set_io_addr_reg(dev, nodeid, link_num, reg, rbase >> 8, |
| 387 | rend >> 8); |
| 388 | } else if (resource->flags & IORESOURCE_MEM) { |
| 389 | set_mmio_addr_reg(nodeid, link_num, reg, (resource->index >> 24), |
| 390 | rbase >> 8, rend >> 8, 1); // [39:8] |
| 391 | } |
| 392 | resource->flags |= IORESOURCE_STORED; |
Elyes HAOUAS | 0d4b11a | 2016-10-03 21:57:21 +0200 | [diff] [blame] | 393 | snprintf(buf, sizeof(buf), " <node %x link %x>", nodeid, link_num); |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 394 | report_resource_stored(dev, resource, buf); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 395 | } |
| 396 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 397 | #if CONFIG(CONSOLE_VGA_MULTI) |
Kyösti Mälkki | e2c2a4c | 2018-05-20 20:59:52 +0300 | [diff] [blame] | 398 | extern struct device *vga_pri; // the primary vga device, defined in device.c |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 399 | #endif |
| 400 | |
Subrata Banik | b1434fc | 2019-03-15 22:20:41 +0530 | [diff] [blame] | 401 | static void create_vga_resource(struct device *dev, unsigned int nodeid) |
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 | struct bus *link; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 404 | |
Mike Loptien | 58089e8 | 2013-01-29 15:45:09 -0700 | [diff] [blame] | 405 | printk(BIOS_DEBUG, "\nFam14h - %s\n", __func__); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 406 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 407 | /* find out which link the VGA card is connected, |
| 408 | * we only deal with the 'first' vga card */ |
| 409 | for (link = dev->link_list; link; link = link->next) { |
| 410 | if (link->bridge_ctrl & PCI_BRIDGE_CTL_VGA) { |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 411 | #if CONFIG(CONSOLE_VGA_MULTI) |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 412 | printk(BIOS_DEBUG, |
| 413 | "VGA: vga_pri bus num = %d bus range [%d,%d]\n", |
| 414 | vga_pri->bus->secondary, link->secondary, |
| 415 | link->subordinate); |
| 416 | /* We need to make sure the vga_pri is under the link */ |
| 417 | if ((vga_pri->bus->secondary >= link->secondary) && |
| 418 | (vga_pri->bus->secondary <= link->subordinate)) |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 419 | #endif |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 420 | break; |
| 421 | } |
| 422 | } |
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 | /* no VGA card installed */ |
| 425 | if (link == NULL) |
| 426 | return; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 427 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 428 | printk(BIOS_DEBUG, "VGA: %s (aka node %d) link %d has VGA device\n", |
| 429 | dev_path(dev), nodeid, link->link_num); |
| 430 | set_vga_enable_reg(nodeid, link->link_num); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 431 | } |
| 432 | |
Elyes HAOUAS | 0d7c7a8 | 2018-05-09 17:58:33 +0200 | [diff] [blame] | 433 | static void nb_set_resources(struct device *dev) |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 434 | { |
Subrata Banik | b1434fc | 2019-03-15 22:20:41 +0530 | [diff] [blame] | 435 | unsigned int nodeid; |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 436 | struct bus *bus; |
| 437 | struct resource *res; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 438 | |
Mike Loptien | 58089e8 | 2013-01-29 15:45:09 -0700 | [diff] [blame] | 439 | printk(BIOS_DEBUG, "\nFam14h - %s\n", __func__); |
efdesign98 | 05a89ab | 2011-06-20 17:38:49 -0700 | [diff] [blame] | 440 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 441 | /* Find the nodeid */ |
| 442 | nodeid = amdfam14_nodeid(dev); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 443 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 444 | create_vga_resource(dev, nodeid); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 445 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 446 | /* Set each resource we have found */ |
| 447 | for (res = dev->resource_list; res; res = res->next) { |
| 448 | set_resource(dev, res, nodeid); |
| 449 | } |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 450 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 451 | for (bus = dev->link_list; bus; bus = bus->next) { |
| 452 | if (bus->children) { |
| 453 | assign_resources(bus); |
| 454 | } |
| 455 | } |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 456 | } |
| 457 | |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 458 | /* Domain/Root Complex related code */ |
| 459 | |
Elyes HAOUAS | 0d7c7a8 | 2018-05-09 17:58:33 +0200 | [diff] [blame] | 460 | static void domain_read_resources(struct device *dev) |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 461 | { |
Subrata Banik | b1434fc | 2019-03-15 22:20:41 +0530 | [diff] [blame] | 462 | unsigned int reg; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 463 | |
Mike Loptien | 58089e8 | 2013-01-29 15:45:09 -0700 | [diff] [blame] | 464 | printk(BIOS_DEBUG, "\nFam14h - %s\n", __func__); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 465 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 466 | /* Find the already assigned resource pairs */ |
| 467 | get_fx_devs(); |
| 468 | for (reg = 0x80; reg <= 0xc0; reg += 0x08) { |
| 469 | u32 base, limit; |
| 470 | base = f1_read_config32(reg); |
| 471 | limit = f1_read_config32(reg + 0x04); |
| 472 | /* Is this register allocated? */ |
| 473 | if ((base & 3) != 0) { |
Subrata Banik | b1434fc | 2019-03-15 22:20:41 +0530 | [diff] [blame] | 474 | unsigned int nodeid, reg_link; |
Elyes HAOUAS | 0d7c7a8 | 2018-05-09 17:58:33 +0200 | [diff] [blame] | 475 | struct device *reg_dev; |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 476 | if (reg < 0xc0) { // mmio |
| 477 | nodeid = (limit & 0xf) + (base & 0x30); |
| 478 | } else { // io |
| 479 | nodeid = (limit & 0xf) + ((base >> 4) & 0x30); |
| 480 | } |
| 481 | reg_link = (limit >> 4) & 7; |
| 482 | reg_dev = __f0_dev[nodeid]; |
| 483 | if (reg_dev) { |
| 484 | /* Reserve the resource */ |
| 485 | struct resource *res; |
| 486 | res = |
| 487 | new_resource(reg_dev, |
| 488 | IOINDEX(0x1000 + reg, |
| 489 | reg_link)); |
| 490 | if (res) { |
| 491 | res->flags = 1; |
| 492 | } |
| 493 | } |
| 494 | } |
| 495 | } |
| 496 | /* FIXME: do we need to check extend conf space? |
| 497 | I don't believe that much preset value */ |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 498 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 499 | pci_domain_read_resources(dev); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 500 | } |
| 501 | |
Elyes HAOUAS | 0d7c7a8 | 2018-05-09 17:58:33 +0200 | [diff] [blame] | 502 | static void domain_set_resources(struct device *dev) |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 503 | { |
Mike Loptien | 58089e8 | 2013-01-29 15:45:09 -0700 | [diff] [blame] | 504 | printk(BIOS_DEBUG, "\nFam14h - %s\n", __func__); |
Stefan Reinauer | 29e6548 | 2015-06-18 01:18:09 -0700 | [diff] [blame] | 505 | printk(BIOS_DEBUG, " amsr - incoming dev = %p\n", dev); |
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 | unsigned long mmio_basek; |
| 508 | u32 pci_tolm; |
| 509 | int idx; |
| 510 | struct bus *link; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 511 | #if CONFIG_HW_MEM_HOLE_SIZEK != 0 |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 512 | struct hw_mem_hole_info mem_hole; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 513 | #endif |
| 514 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 515 | pci_tolm = 0xffffffffUL; |
| 516 | for (link = dev->link_list; link; link = link->next) { |
| 517 | pci_tolm = my_find_pci_tolm(link, pci_tolm); |
| 518 | } |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 519 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 520 | // FIXME handle interleaved nodes. If you fix this here, please fix |
| 521 | // amdk8, too. |
| 522 | mmio_basek = pci_tolm >> 10; |
| 523 | /* Round mmio_basek to something the processor can support */ |
| 524 | mmio_basek &= ~((1 << 6) - 1); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 525 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 526 | // FIXME improve mtrr.c so we don't use up all of the mtrrs with a 64M |
| 527 | // MMIO hole. If you fix this here, please fix amdk8, too. |
| 528 | /* Round the mmio hole to 64M */ |
| 529 | mmio_basek &= ~((64 * 1024) - 1); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 530 | |
| 531 | #if CONFIG_HW_MEM_HOLE_SIZEK != 0 |
| 532 | /* if the hw mem hole is already set in raminit stage, here we will compare |
| 533 | * mmio_basek and hole_basek. if mmio_basek is bigger that hole_basek and will |
| 534 | * use hole_basek as mmio_basek and we don't need to reset hole. |
| 535 | * otherwise We reset the hole to the mmio_basek |
| 536 | */ |
| 537 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 538 | mem_hole = get_hw_mem_hole_info(); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 539 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 540 | // Use hole_basek as mmio_basek, and we don't need to reset hole anymore |
Arthur Heymans | 99eab34 | 2022-03-23 21:34:20 +0100 | [diff] [blame] | 541 | if ((mem_hole.node_id != -1) && (mmio_basek > mem_hole.hole_startk)) |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 542 | mmio_basek = mem_hole.hole_startk; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 543 | #endif |
| 544 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 545 | idx = 0x10; |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 546 | resource_t basek, limitk, sizek; // 4 1T |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 547 | |
Michał Żygowski | 88a0ce6 | 2021-05-05 09:52:59 +0200 | [diff] [blame] | 548 | if (get_dram_base_limit(0, &basek, &limitk)) { |
| 549 | sizek = limitk - basek; |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 550 | |
Michał Żygowski | 88a0ce6 | 2021-05-05 09:52:59 +0200 | [diff] [blame] | 551 | printk(BIOS_DEBUG, "adsr: basek = %llx, limitk = %llx, sizek = %llx.\n", |
| 552 | basek, limitk, sizek); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 553 | |
Elyes Haouas | 5213b19 | 2022-02-25 18:13:03 +0100 | [diff] [blame] | 554 | /* See if we need a hole from 0xa0000 (640K) to 0xbffff (768K) */ |
Elyes Haouas | 9d8df30 | 2022-02-25 18:23:01 +0100 | [diff] [blame] | 555 | if (basek < 640 && sizek > 768) { |
Elyes Haouas | 3adfde9 | 2022-07-16 09:36:01 +0200 | [diff] [blame^] | 556 | printk(BIOS_DEBUG, "adsr - 0xa0000 to 0xbffff resource.\n"); |
Kyösti Mälkki | 27d6299 | 2022-05-24 20:25:58 +0300 | [diff] [blame] | 557 | ram_resource_kb(dev, (idx | 0), basek, 640 - basek); |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 558 | idx += 0x10; |
| 559 | basek = 768; |
Elyes Haouas | 9d8df30 | 2022-02-25 18:23:01 +0100 | [diff] [blame] | 560 | sizek = limitk - basek; |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 561 | } |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 562 | |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 563 | printk(BIOS_DEBUG, |
| 564 | "adsr: mmio_basek=%08lx, basek=%08llx, limitk=%08llx\n", |
| 565 | mmio_basek, basek, limitk); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 566 | |
Kyösti Mälkki | 26c6543 | 2014-06-26 05:30:54 +0300 | [diff] [blame] | 567 | /* split the region to accommodate pci memory space */ |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 568 | if ((basek < 4 * 1024 * 1024) && (limitk > mmio_basek)) { |
| 569 | if (basek <= mmio_basek) { |
Subrata Banik | b1434fc | 2019-03-15 22:20:41 +0530 | [diff] [blame] | 570 | unsigned int pre_sizek; |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 571 | pre_sizek = mmio_basek - basek; |
| 572 | if (pre_sizek > 0) { |
Kyösti Mälkki | 27d6299 | 2022-05-24 20:25:58 +0300 | [diff] [blame] | 573 | ram_resource_kb(dev, idx, basek, |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 574 | pre_sizek); |
| 575 | idx += 0x10; |
| 576 | sizek -= pre_sizek; |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 577 | } |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 578 | basek = mmio_basek; |
| 579 | } |
| 580 | if ((basek + sizek) <= 4 * 1024 * 1024) { |
| 581 | sizek = 0; |
| 582 | } else { |
| 583 | basek = 4 * 1024 * 1024; |
| 584 | sizek -= (4 * 1024 * 1024 - mmio_basek); |
| 585 | } |
| 586 | } |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 587 | |
Kyösti Mälkki | 27d6299 | 2022-05-24 20:25:58 +0300 | [diff] [blame] | 588 | ram_resource_kb(dev, (idx | 0), basek, sizek); |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 589 | idx += 0x10; |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 590 | printk(BIOS_DEBUG, |
| 591 | "%d: mmio_basek=%08lx, basek=%08llx, limitk=%08llx\n", 0, |
| 592 | mmio_basek, basek, limitk); |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 593 | } |
| 594 | printk(BIOS_DEBUG, " adsr - mmio_basek = %lx.\n", mmio_basek); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 595 | |
Kyösti Mälkki | 61be360 | 2017-04-15 20:07:53 +0300 | [diff] [blame] | 596 | add_uma_resource_below_tolm(dev, 7); |
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 | for (link = dev->link_list; link; link = link->next) { |
| 599 | if (link->children) { |
| 600 | assign_resources(link); |
| 601 | } |
| 602 | } |
| 603 | printk(BIOS_DEBUG, " adsr - leaving this lovely routine.\n"); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 604 | } |
| 605 | |
Aaron Durbin | aa090cb | 2017-09-13 16:01:52 -0600 | [diff] [blame] | 606 | static const char *domain_acpi_name(const struct device *dev) |
Tobias Diedrich | d8a2c1f | 2017-02-20 02:46:19 +0100 | [diff] [blame] | 607 | { |
| 608 | if (dev->path.type == DEVICE_PATH_DOMAIN) |
| 609 | return "PCI0"; |
| 610 | |
| 611 | return NULL; |
| 612 | } |
| 613 | |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 614 | /* Bus related code */ |
| 615 | |
Kyösti Mälkki | 580e722 | 2015-03-19 21:04:23 +0200 | [diff] [blame] | 616 | static void cpu_bus_scan(struct device *dev) |
zbao | f722373 | 2012-04-13 13:42:15 +0800 | [diff] [blame] | 617 | { |
Kyösti Mälkki | c33f1e9 | 2012-08-07 17:12:11 +0300 | [diff] [blame] | 618 | struct bus *cpu_bus = dev->link_list; |
Elyes HAOUAS | 0d7c7a8 | 2018-05-09 17:58:33 +0200 | [diff] [blame] | 619 | struct device *cpu; |
zbao | f722373 | 2012-04-13 13:42:15 +0800 | [diff] [blame] | 620 | int apic_id, cores_found; |
Scott Duplichan | 9ab3c6c | 2011-05-15 21:45:46 +0000 | [diff] [blame] | 621 | |
zbao | f722373 | 2012-04-13 13:42:15 +0800 | [diff] [blame] | 622 | /* There is only one node for fam14, but there may be multiple cores. */ |
Kyösti Mälkki | 4ad7f5b | 2018-05-22 01:15:17 +0300 | [diff] [blame] | 623 | cpu = pcidev_on_root(0x18, 0); |
zbao | f722373 | 2012-04-13 13:42:15 +0800 | [diff] [blame] | 624 | if (!cpu) |
Julius Werner | e966595 | 2022-01-21 17:06:20 -0800 | [diff] [blame] | 625 | printk(BIOS_ERR, "%02x:%02x.0 not found", 0, 0x18); |
Scott Duplichan | 9ab3c6c | 2011-05-15 21:45:46 +0000 | [diff] [blame] | 626 | |
Kyösti Mälkki | 4ad7f5b | 2018-05-22 01:15:17 +0300 | [diff] [blame] | 627 | cores_found = (pci_read_config32(pcidev_on_root(0x18, 0x3), |
| 628 | 0xe8) >> 12) & 3; |
zbao | f722373 | 2012-04-13 13:42:15 +0800 | [diff] [blame] | 629 | printk(BIOS_DEBUG, " AP siblings=%d\n", cores_found); |
| 630 | |
zbao | f722373 | 2012-04-13 13:42:15 +0800 | [diff] [blame] | 631 | for (apic_id = 0; apic_id <= cores_found; apic_id++) { |
Kyösti Mälkki | c33f1e9 | 2012-08-07 17:12:11 +0300 | [diff] [blame] | 632 | cpu = add_cpu_device(cpu_bus, apic_id, 1); |
| 633 | if (cpu) |
| 634 | amd_cpu_topology(cpu, 0, apic_id); |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 635 | } |
zbao | f722373 | 2012-04-13 13:42:15 +0800 | [diff] [blame] | 636 | } |
| 637 | |
Elyes HAOUAS | 0d7c7a8 | 2018-05-09 17:58:33 +0200 | [diff] [blame] | 638 | static void cpu_bus_init(struct device *dev) |
zbao | f722373 | 2012-04-13 13:42:15 +0800 | [diff] [blame] | 639 | { |
| 640 | initialize_cpus(dev->link_list); |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 641 | } |
| 642 | |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 643 | /* North Bridge Structures */ |
| 644 | |
Furquan Shaikh | 7536a39 | 2020-04-24 21:59:21 -0700 | [diff] [blame] | 645 | static void northbridge_fill_ssdt_generator(const struct device *device) |
Vladimir Serbinenko | 4ab588b | 2014-10-08 21:18:31 +0200 | [diff] [blame] | 646 | { |
| 647 | msr_t msr; |
| 648 | char pscope[] = "\\_SB.PCI0"; |
| 649 | |
| 650 | acpigen_write_scope(pscope); |
| 651 | msr = rdmsr(TOP_MEM); |
| 652 | acpigen_write_name_dword("TOM1", msr.lo); |
| 653 | msr = rdmsr(TOP_MEM2); |
| 654 | /* |
| 655 | * Since XP only implements parts of ACPI 2.0, we can't use a qword |
| 656 | * here. |
| 657 | * See http://www.acpi.info/presentations/S01USMOBS169_OS%2520new.ppt |
| 658 | * slide 22ff. |
| 659 | * Shift value right by 20 bit to make it fit into 32bit, |
| 660 | * giving us 1MB granularity and a limit of almost 4Exabyte of memory. |
| 661 | */ |
| 662 | acpigen_write_name_dword("TOM2", (msr.hi << 12) | msr.lo >> 20); |
| 663 | acpigen_pop_len(); |
| 664 | } |
| 665 | |
Vladimir Serbinenko | 807127f | 2014-11-09 13:36:18 +0100 | [diff] [blame] | 666 | static unsigned long acpi_fill_hest(acpi_hest_t *hest) |
Vladimir Serbinenko | 4ab588b | 2014-10-08 21:18:31 +0200 | [diff] [blame] | 667 | { |
| 668 | void *addr, *current; |
| 669 | |
| 670 | /* Skip the HEST header. */ |
| 671 | current = (void *)(hest + 1); |
| 672 | |
| 673 | addr = agesawrapper_getlateinitptr(PICK_WHEA_MCE); |
| 674 | if (addr != NULL) |
Stefan Reinauer | 29e6548 | 2015-06-18 01:18:09 -0700 | [diff] [blame] | 675 | current += acpi_create_hest_error_source(hest, current, 0, |
| 676 | addr + 2, *(UINT16 *)addr - 2); |
Vladimir Serbinenko | 4ab588b | 2014-10-08 21:18:31 +0200 | [diff] [blame] | 677 | |
| 678 | addr = agesawrapper_getlateinitptr(PICK_WHEA_CMC); |
| 679 | if (addr != NULL) |
Stefan Reinauer | 29e6548 | 2015-06-18 01:18:09 -0700 | [diff] [blame] | 680 | current += acpi_create_hest_error_source(hest, current, 1, |
| 681 | addr + 2, *(UINT16 *)addr - 2); |
Vladimir Serbinenko | 4ab588b | 2014-10-08 21:18:31 +0200 | [diff] [blame] | 682 | |
| 683 | return (unsigned long)current; |
| 684 | } |
| 685 | |
Michał Żygowski | 9550e97 | 2020-03-20 13:56:46 +0100 | [diff] [blame] | 686 | static void patch_ssdt_processor_scope(acpi_header_t *ssdt) |
| 687 | { |
| 688 | unsigned int len = ssdt->length - sizeof(acpi_header_t); |
| 689 | unsigned int i; |
| 690 | |
| 691 | for (i = sizeof(acpi_header_t); i < len; i++) { |
| 692 | /* Search for _PR_ scope and replace it with _SB_ */ |
| 693 | if (*(uint32_t *)((unsigned long)ssdt + i) == 0x5f52505f) |
| 694 | *(uint32_t *)((unsigned long)ssdt + i) = 0x5f42535f; |
| 695 | } |
| 696 | /* Recalculate checksum */ |
| 697 | ssdt->checksum = 0; |
| 698 | ssdt->checksum = acpi_checksum((void *)ssdt, ssdt->length); |
| 699 | } |
| 700 | |
Furquan Shaikh | 0f007d8 | 2020-04-24 06:41:18 -0700 | [diff] [blame] | 701 | static unsigned long agesa_write_acpi_tables(const struct device *device, |
Alexander Couzens | 83fc32f | 2015-04-12 22:28:37 +0200 | [diff] [blame] | 702 | unsigned long current, |
Vladimir Serbinenko | 4ab588b | 2014-10-08 21:18:31 +0200 | [diff] [blame] | 703 | acpi_rsdp_t *rsdp) |
| 704 | { |
| 705 | acpi_srat_t *srat; |
| 706 | acpi_slit_t *slit; |
| 707 | acpi_header_t *ssdt; |
| 708 | acpi_header_t *alib; |
| 709 | acpi_hest_t *hest; |
| 710 | |
| 711 | /* HEST */ |
| 712 | current = ALIGN(current, 8); |
| 713 | hest = (acpi_hest_t *)current; |
Arthur Heymans | cc66ff3 | 2022-03-23 21:33:15 +0100 | [diff] [blame] | 714 | acpi_write_hest(hest, acpi_fill_hest); |
| 715 | acpi_add_table(rsdp, hest); |
| 716 | current += hest->header.length; |
Vladimir Serbinenko | 4ab588b | 2014-10-08 21:18:31 +0200 | [diff] [blame] | 717 | |
| 718 | /* SRAT */ |
| 719 | current = ALIGN(current, 8); |
| 720 | printk(BIOS_DEBUG, "ACPI: * SRAT at %lx\n", current); |
Elyes Haouas | 3adfde9 | 2022-07-16 09:36:01 +0200 | [diff] [blame^] | 721 | srat = (acpi_srat_t *)agesawrapper_getlateinitptr(PICK_SRAT); |
Vladimir Serbinenko | 4ab588b | 2014-10-08 21:18:31 +0200 | [diff] [blame] | 722 | if (srat != NULL) { |
| 723 | memcpy((void *)current, srat, srat->header.length); |
Elyes Haouas | 3adfde9 | 2022-07-16 09:36:01 +0200 | [diff] [blame^] | 724 | srat = (acpi_srat_t *)current; |
Vladimir Serbinenko | 4ab588b | 2014-10-08 21:18:31 +0200 | [diff] [blame] | 725 | current += srat->header.length; |
| 726 | acpi_add_table(rsdp, srat); |
| 727 | } |
| 728 | else { |
| 729 | printk(BIOS_DEBUG, " AGESA SRAT table NULL. Skipping.\n"); |
| 730 | } |
| 731 | |
| 732 | /* SLIT */ |
| 733 | current = ALIGN(current, 8); |
| 734 | printk(BIOS_DEBUG, "ACPI: * SLIT at %lx\n", current); |
Elyes Haouas | 3adfde9 | 2022-07-16 09:36:01 +0200 | [diff] [blame^] | 735 | slit = (acpi_slit_t *)agesawrapper_getlateinitptr(PICK_SLIT); |
Vladimir Serbinenko | 4ab588b | 2014-10-08 21:18:31 +0200 | [diff] [blame] | 736 | if (slit != NULL) { |
| 737 | memcpy((void *)current, slit, slit->header.length); |
Elyes Haouas | 3adfde9 | 2022-07-16 09:36:01 +0200 | [diff] [blame^] | 738 | slit = (acpi_slit_t *)current; |
Vladimir Serbinenko | 4ab588b | 2014-10-08 21:18:31 +0200 | [diff] [blame] | 739 | current += slit->header.length; |
| 740 | acpi_add_table(rsdp, slit); |
| 741 | } |
| 742 | else { |
| 743 | printk(BIOS_DEBUG, " AGESA SLIT table NULL. Skipping.\n"); |
| 744 | } |
| 745 | |
| 746 | /* SSDT */ |
| 747 | current = ALIGN(current, 16); |
| 748 | printk(BIOS_DEBUG, "ACPI: * AGESA ALIB SSDT at %lx\n", current); |
Elyes Haouas | 3adfde9 | 2022-07-16 09:36:01 +0200 | [diff] [blame^] | 749 | alib = (acpi_header_t *)agesawrapper_getlateinitptr(PICK_ALIB); |
Vladimir Serbinenko | 4ab588b | 2014-10-08 21:18:31 +0200 | [diff] [blame] | 750 | if (alib != NULL) { |
| 751 | memcpy((void *)current, alib, alib->length); |
Elyes Haouas | 3adfde9 | 2022-07-16 09:36:01 +0200 | [diff] [blame^] | 752 | alib = (acpi_header_t *)current; |
Vladimir Serbinenko | 4ab588b | 2014-10-08 21:18:31 +0200 | [diff] [blame] | 753 | current += alib->length; |
| 754 | acpi_add_table(rsdp, (void *)alib); |
| 755 | } else { |
| 756 | printk(BIOS_DEBUG, " AGESA ALIB SSDT table NULL. Skipping.\n"); |
| 757 | } |
| 758 | |
| 759 | /* The DSDT needs additional work for the AGESA SSDT Pstate table */ |
| 760 | /* Keep the comment for a while. */ |
| 761 | current = ALIGN(current, 16); |
| 762 | printk(BIOS_DEBUG, "ACPI: * AGESA SSDT Pstate at %lx\n", current); |
Elyes Haouas | 3adfde9 | 2022-07-16 09:36:01 +0200 | [diff] [blame^] | 763 | ssdt = (acpi_header_t *)agesawrapper_getlateinitptr(PICK_PSTATE); |
Vladimir Serbinenko | 4ab588b | 2014-10-08 21:18:31 +0200 | [diff] [blame] | 764 | if (ssdt != NULL) { |
Michał Żygowski | 9550e97 | 2020-03-20 13:56:46 +0100 | [diff] [blame] | 765 | hexdump(ssdt, ssdt->length); |
| 766 | patch_ssdt_processor_scope(ssdt); |
| 767 | hexdump(ssdt, ssdt->length); |
Vladimir Serbinenko | 4ab588b | 2014-10-08 21:18:31 +0200 | [diff] [blame] | 768 | memcpy((void *)current, ssdt, ssdt->length); |
Elyes Haouas | 3adfde9 | 2022-07-16 09:36:01 +0200 | [diff] [blame^] | 769 | ssdt = (acpi_header_t *)current; |
Vladimir Serbinenko | 4ab588b | 2014-10-08 21:18:31 +0200 | [diff] [blame] | 770 | current += ssdt->length; |
Elyes Haouas | 3adfde9 | 2022-07-16 09:36:01 +0200 | [diff] [blame^] | 771 | acpi_add_table(rsdp, ssdt); |
Vladimir Serbinenko | 4ab588b | 2014-10-08 21:18:31 +0200 | [diff] [blame] | 772 | } else { |
| 773 | printk(BIOS_DEBUG, " AGESA SSDT Pstate table NULL. Skipping.\n"); |
| 774 | } |
| 775 | |
| 776 | return current; |
| 777 | } |
| 778 | |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 779 | static struct device_operations northbridge_operations = { |
Marc Jones | 8a49ac7 | 2013-01-16 17:02:20 -0700 | [diff] [blame] | 780 | .read_resources = nb_read_resources, |
| 781 | .set_resources = nb_set_resources, |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 782 | .enable_resources = pci_dev_enable_resources, |
Nico Huber | 68680dd | 2020-03-31 17:34:52 +0200 | [diff] [blame] | 783 | .acpi_fill_ssdt = northbridge_fill_ssdt_generator, |
Vladimir Serbinenko | 4ab588b | 2014-10-08 21:18:31 +0200 | [diff] [blame] | 784 | .write_acpi_tables = agesa_write_acpi_tables, |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 785 | .init = northbridge_init, |
Elyes Haouas | 3adfde9 | 2022-07-16 09:36:01 +0200 | [diff] [blame^] | 786 | .enable = 0, .ops_pci = 0, |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 787 | }; |
| 788 | |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 789 | static const struct pci_driver northbridge_driver __pci_driver = { |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 790 | .ops = &northbridge_operations, |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 791 | .vendor = PCI_VID_AMD, |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 792 | .device = 0x1510, |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 793 | }; |
| 794 | |
efdesign98 | 05a89ab | 2011-06-20 17:38:49 -0700 | [diff] [blame] | 795 | struct chip_operations northbridge_amd_agesa_family14_ops = { |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 796 | CHIP_NAME("AMD Family 14h Northbridge") |
| 797 | .enable_dev = 0, |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 798 | }; |
| 799 | |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 800 | /* Root Complex Structures */ |
| 801 | |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 802 | static struct device_operations pci_domain_ops = { |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 803 | .read_resources = domain_read_resources, |
| 804 | .set_resources = domain_set_resources, |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 805 | .scan_bus = pci_domain_scan_bus, |
Tobias Diedrich | d8a2c1f | 2017-02-20 02:46:19 +0100 | [diff] [blame] | 806 | .acpi_name = domain_acpi_name, |
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 | static struct device_operations cpu_bus_ops = { |
Nico Huber | 2f8ba69 | 2020-04-05 14:05:24 +0200 | [diff] [blame] | 810 | .read_resources = noop_read_resources, |
| 811 | .set_resources = noop_set_resources, |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 812 | .init = cpu_bus_init, |
zbao | f722373 | 2012-04-13 13:42:15 +0800 | [diff] [blame] | 813 | .scan_bus = cpu_bus_scan, |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 814 | }; |
| 815 | |
Kyösti Mälkki | 87213b6 | 2012-08-27 20:00:33 +0300 | [diff] [blame] | 816 | static void root_complex_enable_dev(struct device *dev) |
| 817 | { |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 818 | /* Set the operations if it is a special bus type */ |
Stefan Reinauer | 4aff445 | 2013-02-12 14:17:15 -0800 | [diff] [blame] | 819 | if (dev->path.type == DEVICE_PATH_DOMAIN) { |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 820 | dev->ops = &pci_domain_ops; |
Stefan Reinauer | 0aa37c4 | 2013-02-12 15:20:54 -0800 | [diff] [blame] | 821 | } else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER) { |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 822 | dev->ops = &cpu_bus_ops; |
| 823 | } |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 824 | } |
| 825 | |
efdesign98 | 05a89ab | 2011-06-20 17:38:49 -0700 | [diff] [blame] | 826 | struct chip_operations northbridge_amd_agesa_family14_root_complex_ops = { |
Marc Jones | 8d59569 | 2012-03-15 12:55:26 -0600 | [diff] [blame] | 827 | CHIP_NAME("AMD Family 14h Root Complex") |
| 828 | .enable_dev = root_complex_enable_dev, |
Frank Vibrans | 39fca80 | 2011-02-14 18:35:15 +0000 | [diff] [blame] | 829 | }; |
Kyösti Mälkki | 2b218e3 | 2019-01-15 11:14:28 +0200 | [diff] [blame] | 830 | |
| 831 | /******************************************************************** |
| 832 | * Change the vendor / device IDs to match the generic VBIOS header. |
| 833 | ********************************************************************/ |
| 834 | u32 map_oprom_vendev(u32 vendev) |
| 835 | { |
| 836 | u32 new_vendev = vendev; |
| 837 | |
| 838 | switch (vendev) { |
| 839 | case 0x10029809: |
| 840 | case 0x10029808: |
| 841 | case 0x10029807: |
| 842 | case 0x10029806: |
| 843 | case 0x10029805: |
| 844 | case 0x10029804: |
| 845 | case 0x10029803: |
| 846 | new_vendev = 0x10029802; |
| 847 | break; |
| 848 | } |
| 849 | |
| 850 | return new_vendev; |
| 851 | } |