zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; version 2 of the License. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 13 | */ |
| 14 | |
| 15 | #include <console/console.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 16 | #include <device/pci_ops.h> |
Kyösti Mälkki | 8ae16a4 | 2014-06-19 20:44:34 +0300 | [diff] [blame] | 17 | #include <arch/acpi.h> |
Vladimir Serbinenko | 56f46d8 | 2014-10-08 22:06:27 +0200 | [diff] [blame] | 18 | #include <arch/acpigen.h> |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 19 | #include <stdint.h> |
| 20 | #include <device/device.h> |
| 21 | #include <device/pci.h> |
| 22 | #include <device/pci_ids.h> |
| 23 | #include <device/hypertransport.h> |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 24 | #include <string.h> |
Ronald G. Minnich | 5079a0d | 2012-11-27 11:32:38 -0800 | [diff] [blame] | 25 | #include <lib.h> |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 26 | #include <cpu/cpu.h> |
Martin Roth | 73e86a8 | 2013-01-17 16:28:30 -0700 | [diff] [blame] | 27 | #include <AGESA.h> |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 28 | #include <cpu/x86/lapic.h> |
Elyes HAOUAS | 400ce55 | 2018-10-12 10:54:30 +0200 | [diff] [blame] | 29 | #include <cpu/amd/msr.h> |
Kyösti Mälkki | dbc4739 | 2012-08-05 12:11:40 +0300 | [diff] [blame] | 30 | #include <cpu/amd/mtrr.h> |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 31 | #include <Porting.h> |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 32 | #include <Options.h> |
| 33 | #include <Topology.h> |
Kyösti Mälkki | 3d3152e | 2019-01-10 09:05:30 +0200 | [diff] [blame] | 34 | #include <northbridge/amd/agesa/nb_common.h> |
Kyösti Mälkki | 28c4d2f | 2016-11-25 11:21:02 +0200 | [diff] [blame] | 35 | #include <northbridge/amd/agesa/state_machine.h> |
Kyösti Mälkki | d610c58 | 2017-03-05 06:28:18 +0200 | [diff] [blame] | 36 | #include <northbridge/amd/agesa/agesa_helper.h> |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 37 | |
Kyösti Mälkki | 113f670 | 2018-05-20 20:12:32 +0300 | [diff] [blame] | 38 | #define MAX_NODE_NUMS MAX_NODES |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 39 | |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 40 | typedef struct dram_base_mask { |
| 41 | u32 base; //[47:27] at [28:8] |
| 42 | u32 mask; //[47:27] at [28:8] and enable at bit 0 |
| 43 | } dram_base_mask_t; |
| 44 | |
Subrata Banik | b1434fc | 2019-03-15 22:20:41 +0530 | [diff] [blame] | 45 | static unsigned int node_nums; |
| 46 | static unsigned int sblink; |
Kyösti Mälkki | e2c2a4c | 2018-05-20 20:59:52 +0300 | [diff] [blame] | 47 | static struct device *__f0_dev[MAX_NODE_NUMS]; |
| 48 | static struct device *__f1_dev[MAX_NODE_NUMS]; |
| 49 | static struct device *__f2_dev[MAX_NODE_NUMS]; |
| 50 | static struct device *__f4_dev[MAX_NODE_NUMS]; |
Subrata Banik | b1434fc | 2019-03-15 22:20:41 +0530 | [diff] [blame] | 51 | static unsigned int fx_devs = 0; |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 52 | |
| 53 | static dram_base_mask_t get_dram_base_mask(u32 nodeid) |
| 54 | { |
Kyösti Mälkki | e2c2a4c | 2018-05-20 20:59:52 +0300 | [diff] [blame] | 55 | struct device *dev; |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 56 | dram_base_mask_t d; |
| 57 | dev = __f1_dev[0]; |
| 58 | u32 temp; |
| 59 | temp = pci_read_config32(dev, 0x44 + (nodeid << 3)); //[39:24] at [31:16] |
| 60 | d.mask = ((temp & 0xfff80000)>>(8+3)); // mask out DramMask [26:24] too |
| 61 | temp = pci_read_config32(dev, 0x144 + (nodeid <<3)) & 0xff; //[47:40] at [7:0] |
Elyes HAOUAS | 27e1801 | 2017-06-27 23:14:51 +0200 | [diff] [blame] | 62 | d.mask |= temp << 21; |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 63 | temp = pci_read_config32(dev, 0x40 + (nodeid << 3)); //[39:24] at [31:16] |
| 64 | d.mask |= (temp & 1); // enable bit |
| 65 | d.base = ((temp & 0xfff80000)>>(8+3)); // mask out DramBase [26:24) too |
| 66 | temp = pci_read_config32(dev, 0x140 + (nodeid <<3)) & 0xff; //[47:40] at [7:0] |
Elyes HAOUAS | 27e1801 | 2017-06-27 23:14:51 +0200 | [diff] [blame] | 67 | d.base |= temp << 21; |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 68 | return d; |
| 69 | } |
| 70 | |
Kyösti Mälkki | e2c2a4c | 2018-05-20 20:59:52 +0300 | [diff] [blame] | 71 | static void set_io_addr_reg(struct device *dev, u32 nodeid, u32 linkn, u32 reg, |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 72 | u32 io_min, u32 io_max) |
| 73 | { |
| 74 | u32 i; |
| 75 | u32 tempreg; |
| 76 | /* io range allocation */ |
Elyes HAOUAS | 27e1801 | 2017-06-27 23:14:51 +0200 | [diff] [blame] | 77 | tempreg = (nodeid&0xf) | ((nodeid & 0x30)<<(8-4)) | (linkn << 4) | ((io_max&0xf0)<<(12-4)); //limit |
Elyes HAOUAS | 1d8daa6 | 2016-09-18 08:50:54 +0200 | [diff] [blame] | 78 | for (i = 0; i < node_nums; i++) |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 79 | pci_write_config32(__f1_dev[i], reg+4, tempreg); |
Elyes HAOUAS | 27e1801 | 2017-06-27 23:14:51 +0200 | [diff] [blame] | 80 | tempreg = 3 /*| (3 << 4)*/ | ((io_min&0xf0)<<(12-4)); //base :ISA and VGA ? |
Elyes HAOUAS | 1d8daa6 | 2016-09-18 08:50:54 +0200 | [diff] [blame] | 81 | for (i = 0; i < node_nums; i++) |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 82 | pci_write_config32(__f1_dev[i], reg, tempreg); |
| 83 | } |
| 84 | |
| 85 | static void set_mmio_addr_reg(u32 nodeid, u32 linkn, u32 reg, u32 index, u32 mmio_min, u32 mmio_max, u32 nodes) |
| 86 | { |
| 87 | u32 i; |
| 88 | u32 tempreg; |
| 89 | /* io range allocation */ |
Elyes HAOUAS | 27e1801 | 2017-06-27 23:14:51 +0200 | [diff] [blame] | 90 | tempreg = (nodeid&0xf) | (linkn << 4) | (mmio_max&0xffffff00); //limit |
Elyes HAOUAS | 1d8daa6 | 2016-09-18 08:50:54 +0200 | [diff] [blame] | 91 | for (i = 0; i < nodes; i++) |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 92 | pci_write_config32(__f1_dev[i], reg+4, tempreg); |
| 93 | tempreg = 3 | (nodeid & 0x30) | (mmio_min&0xffffff00); |
Elyes HAOUAS | 1d8daa6 | 2016-09-18 08:50:54 +0200 | [diff] [blame] | 94 | for (i = 0; i < node_nums; i++) |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 95 | pci_write_config32(__f1_dev[i], reg, tempreg); |
| 96 | } |
| 97 | |
Kyösti Mälkki | e2c2a4c | 2018-05-20 20:59:52 +0300 | [diff] [blame] | 98 | static struct device *get_node_pci(u32 nodeid, u32 fn) |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 99 | { |
Kyösti Mälkki | 3d3152e | 2019-01-10 09:05:30 +0200 | [diff] [blame] | 100 | return pcidev_on_root(DEV_CDB + nodeid, fn); |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | static void get_fx_devs(void) |
| 104 | { |
| 105 | int i; |
| 106 | for (i = 0; i < MAX_NODE_NUMS; i++) { |
| 107 | __f0_dev[i] = get_node_pci(i, 0); |
| 108 | __f1_dev[i] = get_node_pci(i, 1); |
| 109 | __f2_dev[i] = get_node_pci(i, 2); |
| 110 | __f4_dev[i] = get_node_pci(i, 4); |
| 111 | if (__f0_dev[i] != NULL && __f1_dev[i] != NULL) |
| 112 | fx_devs = i+1; |
| 113 | } |
| 114 | if (__f1_dev[0] == NULL || __f0_dev[0] == NULL || fx_devs == 0) { |
| 115 | die("Cannot find 0:0x18.[0|1]\n"); |
| 116 | } |
| 117 | printk(BIOS_DEBUG, "fx_devs=0x%x\n", fx_devs); |
| 118 | } |
| 119 | |
Subrata Banik | b1434fc | 2019-03-15 22:20:41 +0530 | [diff] [blame] | 120 | static u32 f1_read_config32(unsigned int reg) |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 121 | { |
| 122 | if (fx_devs == 0) |
| 123 | get_fx_devs(); |
| 124 | return pci_read_config32(__f1_dev[0], reg); |
| 125 | } |
| 126 | |
Subrata Banik | b1434fc | 2019-03-15 22:20:41 +0530 | [diff] [blame] | 127 | static void f1_write_config32(unsigned int reg, u32 value) |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 128 | { |
| 129 | int i; |
| 130 | if (fx_devs == 0) |
| 131 | get_fx_devs(); |
Elyes HAOUAS | 5a7e72f | 2016-08-23 21:36:02 +0200 | [diff] [blame] | 132 | for (i = 0; i < fx_devs; i++) { |
Kyösti Mälkki | e2c2a4c | 2018-05-20 20:59:52 +0300 | [diff] [blame] | 133 | struct device *dev; |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 134 | dev = __f1_dev[i]; |
| 135 | if (dev && dev->enabled) { |
| 136 | pci_write_config32(dev, reg, value); |
| 137 | } |
| 138 | } |
| 139 | } |
| 140 | |
Kyösti Mälkki | 2900d4b | 2017-07-25 14:55:29 +0300 | [diff] [blame] | 141 | static u32 amdfam15_nodeid(struct device *dev) |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 142 | { |
Kyösti Mälkki | 3d3152e | 2019-01-10 09:05:30 +0200 | [diff] [blame] | 143 | return (dev->path.pci.devfn >> 3) - DEV_CDB; |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 144 | } |
| 145 | |
| 146 | static void set_vga_enable_reg(u32 nodeid, u32 linkn) |
| 147 | { |
| 148 | u32 val; |
| 149 | |
Elyes HAOUAS | 27e1801 | 2017-06-27 23:14:51 +0200 | [diff] [blame] | 150 | val = 1 | (nodeid << 4) | (linkn << 12); |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 151 | /* it will routing |
| 152 | * (1)mmio 0xa0000:0xbffff |
| 153 | * (2)io 0x3b0:0x3bb, 0x3c0:0x3df |
| 154 | */ |
| 155 | f1_write_config32(0xf4, val); |
| 156 | |
| 157 | } |
| 158 | |
| 159 | /** |
| 160 | * @return |
Elyes HAOUAS | 99b075a | 2019-12-30 14:29:31 +0100 | [diff] [blame] | 161 | * @retval 2 resource does not exist, usable |
Edward O'Callaghan | ae5fd34 | 2014-11-20 19:58:09 +1100 | [diff] [blame] | 162 | * @retval 0 resource exists, not usable |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 163 | * @retval 1 resource exist, resource has been allocated before |
| 164 | */ |
Subrata Banik | b1434fc | 2019-03-15 22:20:41 +0530 | [diff] [blame] | 165 | static int reg_useable(unsigned int reg, struct device *goal_dev, |
| 166 | unsigned int goal_nodeid, unsigned int goal_link) |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 167 | { |
| 168 | struct resource *res; |
Subrata Banik | b1434fc | 2019-03-15 22:20:41 +0530 | [diff] [blame] | 169 | unsigned int nodeid, link = 0; |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 170 | int result; |
| 171 | res = 0; |
| 172 | for (nodeid = 0; !res && (nodeid < fx_devs); nodeid++) { |
Kyösti Mälkki | 2900d4b | 2017-07-25 14:55:29 +0300 | [diff] [blame] | 173 | struct device *dev; |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 174 | dev = __f0_dev[nodeid]; |
| 175 | if (!dev) |
| 176 | continue; |
| 177 | for (link = 0; !res && (link < 8); link++) { |
| 178 | res = probe_resource(dev, IOINDEX(0x1000 + reg, link)); |
| 179 | } |
| 180 | } |
| 181 | result = 2; |
| 182 | if (res) { |
| 183 | result = 0; |
| 184 | if ((goal_link == (link - 1)) && |
| 185 | (goal_nodeid == (nodeid - 1)) && |
| 186 | (res->flags <= 1)) { |
| 187 | result = 1; |
| 188 | } |
| 189 | } |
| 190 | return result; |
| 191 | } |
| 192 | |
Subrata Banik | b1434fc | 2019-03-15 22:20:41 +0530 | [diff] [blame] | 193 | static struct resource *amdfam15_find_iopair(struct device *dev, |
| 194 | unsigned int nodeid, unsigned int link) |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 195 | { |
| 196 | struct resource *resource; |
| 197 | u32 free_reg, reg; |
| 198 | resource = 0; |
| 199 | free_reg = 0; |
| 200 | for (reg = 0xc0; reg <= 0xd8; reg += 0x8) { |
| 201 | int result; |
| 202 | result = reg_useable(reg, dev, nodeid, link); |
| 203 | if (result == 1) { |
| 204 | /* I have been allocated this one */ |
| 205 | break; |
| 206 | } |
| 207 | else if (result > 1) { |
| 208 | /* I have a free register pair */ |
| 209 | free_reg = reg; |
| 210 | } |
| 211 | } |
| 212 | if (reg > 0xd8) { |
| 213 | reg = free_reg; // if no free, the free_reg still be 0 |
| 214 | } |
| 215 | |
| 216 | resource = new_resource(dev, IOINDEX(0x1000 + reg, link)); |
| 217 | |
| 218 | return resource; |
| 219 | } |
| 220 | |
Kyösti Mälkki | 2900d4b | 2017-07-25 14:55:29 +0300 | [diff] [blame] | 221 | static struct resource *amdfam15_find_mempair(struct device *dev, u32 nodeid, u32 link) |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 222 | { |
| 223 | struct resource *resource; |
| 224 | u32 free_reg, reg; |
| 225 | resource = 0; |
| 226 | free_reg = 0; |
| 227 | for (reg = 0x80; reg <= 0xb8; reg += 0x8) { |
| 228 | int result; |
| 229 | result = reg_useable(reg, dev, nodeid, link); |
| 230 | if (result == 1) { |
| 231 | /* I have been allocated this one */ |
| 232 | break; |
| 233 | } |
| 234 | else if (result > 1) { |
| 235 | /* I have a free register pair */ |
| 236 | free_reg = reg; |
| 237 | } |
| 238 | } |
| 239 | if (reg > 0xb8) { |
| 240 | reg = free_reg; |
| 241 | } |
| 242 | |
| 243 | resource = new_resource(dev, IOINDEX(0x1000 + reg, link)); |
| 244 | return resource; |
| 245 | } |
| 246 | |
Kyösti Mälkki | 2900d4b | 2017-07-25 14:55:29 +0300 | [diff] [blame] | 247 | static void amdfam15_link_read_bases(struct device *dev, u32 nodeid, u32 link) |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 248 | { |
| 249 | struct resource *resource; |
| 250 | |
| 251 | /* Initialize the io space constraints on the current bus */ |
| 252 | resource = amdfam15_find_iopair(dev, nodeid, link); |
| 253 | if (resource) { |
| 254 | u32 align; |
| 255 | align = log2(HT_IO_HOST_ALIGN); |
| 256 | resource->base = 0; |
| 257 | resource->size = 0; |
| 258 | resource->align = align; |
| 259 | resource->gran = align; |
| 260 | resource->limit = 0xffffUL; |
| 261 | resource->flags = IORESOURCE_IO | IORESOURCE_BRIDGE; |
| 262 | } |
| 263 | |
| 264 | /* Initialize the prefetchable memory constraints on the current bus */ |
| 265 | resource = amdfam15_find_mempair(dev, nodeid, link); |
| 266 | if (resource) { |
| 267 | resource->base = 0; |
| 268 | resource->size = 0; |
| 269 | resource->align = log2(HT_MEM_HOST_ALIGN); |
| 270 | resource->gran = log2(HT_MEM_HOST_ALIGN); |
| 271 | resource->limit = 0xffffffffffULL; |
| 272 | resource->flags = IORESOURCE_MEM | IORESOURCE_PREFETCH; |
| 273 | resource->flags |= IORESOURCE_BRIDGE; |
| 274 | } |
| 275 | |
| 276 | /* Initialize the memory constraints on the current bus */ |
| 277 | resource = amdfam15_find_mempair(dev, nodeid, link); |
| 278 | if (resource) { |
| 279 | resource->base = 0; |
| 280 | resource->size = 0; |
| 281 | resource->align = log2(HT_MEM_HOST_ALIGN); |
| 282 | resource->gran = log2(HT_MEM_HOST_ALIGN); |
| 283 | resource->limit = 0xffffffffffULL; |
| 284 | resource->flags = IORESOURCE_MEM | IORESOURCE_BRIDGE; |
| 285 | } |
| 286 | |
| 287 | } |
| 288 | |
Kyösti Mälkki | 2900d4b | 2017-07-25 14:55:29 +0300 | [diff] [blame] | 289 | static void nb_read_resources(struct device *dev) |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 290 | { |
| 291 | u32 nodeid; |
| 292 | struct bus *link; |
| 293 | |
| 294 | nodeid = amdfam15_nodeid(dev); |
| 295 | for (link = dev->link_list; link; link = link->next) { |
| 296 | if (link->children) { |
| 297 | amdfam15_link_read_bases(dev, nodeid, link->link_num); |
| 298 | } |
| 299 | } |
Steven Sherk | 1cbabb0 | 2013-02-01 09:22:35 -0700 | [diff] [blame] | 300 | |
| 301 | /* |
Stefan Reinauer | 4aff445 | 2013-02-12 14:17:15 -0800 | [diff] [blame] | 302 | * This MMCONF resource must be reserved in the PCI domain. |
Steven Sherk | 1cbabb0 | 2013-02-01 09:22:35 -0700 | [diff] [blame] | 303 | * 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] | 304 | * the CPU_CLUSTER. |
Steven Sherk | 1cbabb0 | 2013-02-01 09:22:35 -0700 | [diff] [blame] | 305 | */ |
Elyes HAOUAS | 400ce55 | 2018-10-12 10:54:30 +0200 | [diff] [blame] | 306 | mmconf_resource(dev, MMIO_CONF_BASE); |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 307 | } |
| 308 | |
Kyösti Mälkki | 2900d4b | 2017-07-25 14:55:29 +0300 | [diff] [blame] | 309 | static void set_resource(struct device *dev, struct resource *resource, u32 nodeid) |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 310 | { |
| 311 | resource_t rbase, rend; |
Subrata Banik | b1434fc | 2019-03-15 22:20:41 +0530 | [diff] [blame] | 312 | unsigned int reg, link_num; |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 313 | char buf[50]; |
| 314 | |
| 315 | /* Make certain the resource has actually been set */ |
| 316 | if (!(resource->flags & IORESOURCE_ASSIGNED)) { |
| 317 | return; |
| 318 | } |
| 319 | |
| 320 | /* If I have already stored this resource don't worry about it */ |
| 321 | if (resource->flags & IORESOURCE_STORED) { |
| 322 | return; |
| 323 | } |
| 324 | |
| 325 | /* Only handle PCI memory and IO resources */ |
| 326 | if (!(resource->flags & (IORESOURCE_MEM | IORESOURCE_IO))) |
| 327 | return; |
| 328 | |
| 329 | /* Ensure I am actually looking at a resource of function 1 */ |
| 330 | if ((resource->index & 0xffff) < 0x1000) { |
| 331 | return; |
| 332 | } |
| 333 | /* Get the base address */ |
| 334 | rbase = resource->base; |
| 335 | |
| 336 | /* Get the limit (rounded up) */ |
| 337 | rend = resource_end(resource); |
| 338 | |
| 339 | /* Get the register and link */ |
| 340 | reg = resource->index & 0xfff; // 4k |
| 341 | link_num = IOINDEX_LINK(resource->index); |
| 342 | |
| 343 | if (resource->flags & IORESOURCE_IO) { |
| 344 | set_io_addr_reg(dev, nodeid, link_num, reg, rbase>>8, rend>>8); |
| 345 | } |
| 346 | else if (resource->flags & IORESOURCE_MEM) { |
Edward O'Callaghan | ae5fd34 | 2014-11-20 19:58:09 +1100 | [diff] [blame] | 347 | set_mmio_addr_reg(nodeid, link_num, reg, (resource->index >>24), rbase>>8, rend>>8, node_nums);// [39:8] |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 348 | } |
| 349 | resource->flags |= IORESOURCE_STORED; |
Elyes HAOUAS | 0d4b11a | 2016-10-03 21:57:21 +0200 | [diff] [blame] | 350 | snprintf(buf, sizeof(buf), " <node %x link %x>", |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 351 | nodeid, link_num); |
| 352 | report_resource_stored(dev, resource, buf); |
| 353 | } |
| 354 | |
| 355 | /** |
| 356 | * I tried to reuse the resource allocation code in set_resource() |
| 357 | * but it is too difficult to deal with the resource allocation magic. |
| 358 | */ |
| 359 | |
Subrata Banik | b1434fc | 2019-03-15 22:20:41 +0530 | [diff] [blame] | 360 | static void create_vga_resource(struct device *dev, unsigned int nodeid) |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 361 | { |
| 362 | struct bus *link; |
| 363 | |
| 364 | /* find out which link the VGA card is connected, |
| 365 | * we only deal with the 'first' vga card */ |
| 366 | for (link = dev->link_list; link; link = link->next) { |
| 367 | if (link->bridge_ctrl & PCI_BRIDGE_CTL_VGA) { |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 368 | #if CONFIG(MULTIPLE_VGA_ADAPTERS) |
Kyösti Mälkki | 2900d4b | 2017-07-25 14:55:29 +0300 | [diff] [blame] | 369 | extern struct device *vga_pri; // the primary vga device, defined in device.c |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 370 | printk(BIOS_DEBUG, "VGA: vga_pri bus num = %d bus range [%d,%d]\n", vga_pri->bus->secondary, |
| 371 | link->secondary,link->subordinate); |
| 372 | /* We need to make sure the vga_pri is under the link */ |
Elyes HAOUAS | 1d8daa6 | 2016-09-18 08:50:54 +0200 | [diff] [blame] | 373 | if ((vga_pri->bus->secondary >= link->secondary) && |
Kyösti Mälkki | 2900d4b | 2017-07-25 14:55:29 +0300 | [diff] [blame] | 374 | (vga_pri->bus->secondary <= link->subordinate)) |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 375 | #endif |
| 376 | break; |
| 377 | } |
| 378 | } |
| 379 | |
| 380 | /* no VGA card installed */ |
| 381 | if (link == NULL) |
| 382 | return; |
| 383 | |
| 384 | printk(BIOS_DEBUG, "VGA: %s (aka node %d) link %d has VGA device\n", dev_path(dev), nodeid, sblink); |
| 385 | set_vga_enable_reg(nodeid, sblink); |
| 386 | } |
| 387 | |
Kyösti Mälkki | 2900d4b | 2017-07-25 14:55:29 +0300 | [diff] [blame] | 388 | static void nb_set_resources(struct device *dev) |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 389 | { |
Subrata Banik | b1434fc | 2019-03-15 22:20:41 +0530 | [diff] [blame] | 390 | unsigned int nodeid; |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 391 | struct bus *bus; |
| 392 | struct resource *res; |
| 393 | |
| 394 | /* Find the nodeid */ |
| 395 | nodeid = amdfam15_nodeid(dev); |
| 396 | |
| 397 | create_vga_resource(dev, nodeid); //TODO: do we need this? |
| 398 | |
| 399 | /* Set each resource we have found */ |
| 400 | for (res = dev->resource_list; res; res = res->next) { |
| 401 | set_resource(dev, res, nodeid); |
| 402 | } |
| 403 | |
| 404 | for (bus = dev->link_list; bus; bus = bus->next) { |
| 405 | if (bus->children) { |
| 406 | assign_resources(bus); |
| 407 | } |
| 408 | } |
| 409 | } |
| 410 | |
Vladimir Serbinenko | 807127f | 2014-11-09 13:36:18 +0100 | [diff] [blame] | 411 | static unsigned long acpi_fill_hest(acpi_hest_t *hest) |
Vladimir Serbinenko | 56f46d8 | 2014-10-08 22:06:27 +0200 | [diff] [blame] | 412 | { |
| 413 | void *addr, *current; |
| 414 | |
| 415 | /* Skip the HEST header. */ |
| 416 | current = (void *)(hest + 1); |
| 417 | |
| 418 | addr = agesawrapper_getlateinitptr(PICK_WHEA_MCE); |
| 419 | if (addr != NULL) |
Stefan Reinauer | 77a1d1a | 2015-07-21 12:48:17 -0700 | [diff] [blame] | 420 | current += acpi_create_hest_error_source(hest, current, 0, |
| 421 | addr + 2, *(UINT16 *)addr - 2); |
Vladimir Serbinenko | 56f46d8 | 2014-10-08 22:06:27 +0200 | [diff] [blame] | 422 | |
| 423 | addr = agesawrapper_getlateinitptr(PICK_WHEA_CMC); |
| 424 | if (addr != NULL) |
Stefan Reinauer | 77a1d1a | 2015-07-21 12:48:17 -0700 | [diff] [blame] | 425 | current += acpi_create_hest_error_source(hest, current, 1, |
| 426 | addr + 2, *(UINT16 *)addr - 2); |
Vladimir Serbinenko | 56f46d8 | 2014-10-08 22:06:27 +0200 | [diff] [blame] | 427 | |
| 428 | return (unsigned long)current; |
| 429 | } |
| 430 | |
Kyösti Mälkki | e2c2a4c | 2018-05-20 20:59:52 +0300 | [diff] [blame] | 431 | static void northbridge_fill_ssdt_generator(struct device *device) |
Vladimir Serbinenko | 56f46d8 | 2014-10-08 22:06:27 +0200 | [diff] [blame] | 432 | { |
| 433 | msr_t msr; |
| 434 | char pscope[] = "\\_SB.PCI0"; |
| 435 | |
| 436 | acpigen_write_scope(pscope); |
| 437 | msr = rdmsr(TOP_MEM); |
| 438 | acpigen_write_name_dword("TOM1", msr.lo); |
| 439 | msr = rdmsr(TOP_MEM2); |
| 440 | /* |
| 441 | * Since XP only implements parts of ACPI 2.0, we can't use a qword |
| 442 | * here. |
| 443 | * See http://www.acpi.info/presentations/S01USMOBS169_OS%2520new.ppt |
| 444 | * slide 22ff. |
| 445 | * Shift value right by 20 bit to make it fit into 32bit, |
| 446 | * giving us 1MB granularity and a limit of almost 4Exabyte of memory. |
| 447 | */ |
| 448 | acpigen_write_name_dword("TOM2", (msr.hi << 12) | msr.lo >> 20); |
| 449 | acpigen_pop_len(); |
| 450 | } |
| 451 | |
Kyösti Mälkki | e2c2a4c | 2018-05-20 20:59:52 +0300 | [diff] [blame] | 452 | static unsigned long agesa_write_acpi_tables(struct device *device, |
Alexander Couzens | 83fc32f | 2015-04-12 22:28:37 +0200 | [diff] [blame] | 453 | unsigned long current, |
Vladimir Serbinenko | 56f46d8 | 2014-10-08 22:06:27 +0200 | [diff] [blame] | 454 | acpi_rsdp_t *rsdp) |
| 455 | { |
| 456 | acpi_srat_t *srat; |
| 457 | acpi_slit_t *slit; |
| 458 | acpi_header_t *ssdt; |
| 459 | acpi_header_t *alib; |
| 460 | acpi_header_t *ivrs; |
| 461 | acpi_hest_t *hest; |
| 462 | |
| 463 | /* HEST */ |
| 464 | current = ALIGN(current, 8); |
| 465 | hest = (acpi_hest_t *)current; |
Vladimir Serbinenko | 807127f | 2014-11-09 13:36:18 +0100 | [diff] [blame] | 466 | acpi_write_hest((void *)current, acpi_fill_hest); |
Vladimir Serbinenko | 56f46d8 | 2014-10-08 22:06:27 +0200 | [diff] [blame] | 467 | acpi_add_table(rsdp, (void *)current); |
| 468 | current += ((acpi_header_t *)current)->length; |
| 469 | |
| 470 | current = ALIGN(current, 8); |
| 471 | printk(BIOS_DEBUG, "ACPI: * IVRS at %lx\n", current); |
| 472 | ivrs = agesawrapper_getlateinitptr(PICK_IVRS); |
| 473 | if (ivrs != NULL) { |
| 474 | memcpy((void *)current, ivrs, ivrs->length); |
| 475 | ivrs = (acpi_header_t *) current; |
| 476 | current += ivrs->length; |
| 477 | acpi_add_table(rsdp, ivrs); |
| 478 | } else { |
| 479 | printk(BIOS_DEBUG, " AGESA IVRS table NULL. Skipping.\n"); |
| 480 | } |
| 481 | |
| 482 | /* SRAT */ |
| 483 | current = ALIGN(current, 8); |
| 484 | printk(BIOS_DEBUG, "ACPI: * SRAT at %lx\n", current); |
| 485 | srat = (acpi_srat_t *) agesawrapper_getlateinitptr (PICK_SRAT); |
| 486 | if (srat != NULL) { |
| 487 | memcpy((void *)current, srat, srat->header.length); |
| 488 | srat = (acpi_srat_t *) current; |
| 489 | current += srat->header.length; |
| 490 | acpi_add_table(rsdp, srat); |
| 491 | } else { |
| 492 | printk(BIOS_DEBUG, " AGESA SRAT table NULL. Skipping.\n"); |
| 493 | } |
| 494 | |
| 495 | /* SLIT */ |
| 496 | current = ALIGN(current, 8); |
| 497 | printk(BIOS_DEBUG, "ACPI: * SLIT at %lx\n", current); |
| 498 | slit = (acpi_slit_t *) agesawrapper_getlateinitptr (PICK_SLIT); |
| 499 | if (slit != NULL) { |
| 500 | memcpy((void *)current, slit, slit->header.length); |
| 501 | slit = (acpi_slit_t *) current; |
| 502 | current += slit->header.length; |
| 503 | acpi_add_table(rsdp, slit); |
| 504 | } else { |
| 505 | printk(BIOS_DEBUG, " AGESA SLIT table NULL. Skipping.\n"); |
| 506 | } |
| 507 | |
| 508 | /* ALIB */ |
| 509 | current = ALIGN(current, 16); |
| 510 | printk(BIOS_DEBUG, "ACPI: * AGESA ALIB SSDT at %lx\n", current); |
| 511 | alib = (acpi_header_t *)agesawrapper_getlateinitptr (PICK_ALIB); |
| 512 | if (alib != NULL) { |
| 513 | memcpy((void *)current, alib, alib->length); |
| 514 | alib = (acpi_header_t *) current; |
| 515 | current += alib->length; |
| 516 | acpi_add_table(rsdp, (void *)alib); |
| 517 | } |
| 518 | else { |
| 519 | printk(BIOS_DEBUG, " AGESA ALIB SSDT table NULL. Skipping.\n"); |
| 520 | } |
| 521 | |
| 522 | /* this pstate ssdt may cause Blue Screen: Fixed: Keep this comment for a while. */ |
| 523 | /* SSDT */ |
| 524 | current = ALIGN(current, 16); |
| 525 | printk(BIOS_DEBUG, "ACPI: * SSDT at %lx\n", current); |
| 526 | ssdt = (acpi_header_t *)agesawrapper_getlateinitptr (PICK_PSTATE); |
| 527 | if (ssdt != NULL) { |
| 528 | memcpy((void *)current, ssdt, ssdt->length); |
| 529 | ssdt = (acpi_header_t *) current; |
| 530 | current += ssdt->length; |
| 531 | } |
| 532 | else { |
| 533 | printk(BIOS_DEBUG, " AGESA PState table NULL. Skipping.\n"); |
| 534 | } |
| 535 | acpi_add_table(rsdp,ssdt); |
| 536 | |
| 537 | printk(BIOS_DEBUG, "ACPI: * SSDT for PState at %lx\n", current); |
| 538 | |
| 539 | return current; |
| 540 | } |
| 541 | |
| 542 | |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 543 | static struct device_operations northbridge_operations = { |
Steven Sherk | f434058 | 2013-01-29 16:13:35 -0700 | [diff] [blame] | 544 | .read_resources = nb_read_resources, |
| 545 | .set_resources = nb_set_resources, |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 546 | .enable_resources = pci_dev_enable_resources, |
Edward O'Callaghan | d994ef1 | 2014-11-21 02:22:33 +1100 | [diff] [blame] | 547 | .init = DEVICE_NOOP, |
Vladimir Serbinenko | 56f46d8 | 2014-10-08 22:06:27 +0200 | [diff] [blame] | 548 | .acpi_fill_ssdt_generator = northbridge_fill_ssdt_generator, |
| 549 | .write_acpi_tables = agesa_write_acpi_tables, |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 550 | .enable = 0, |
| 551 | .ops_pci = 0, |
| 552 | }; |
| 553 | |
| 554 | static const struct pci_driver family15_northbridge __pci_driver = { |
| 555 | .ops = &northbridge_operations, |
| 556 | .vendor = PCI_VENDOR_ID_AMD, |
Marshall Dawson | 463f46e | 2016-10-14 20:46:08 -0600 | [diff] [blame] | 557 | .device = PCI_DEVICE_ID_AMD_15H_MODEL_101F_NB_HT, |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 558 | }; |
| 559 | |
| 560 | static const struct pci_driver family10_northbridge __pci_driver = { |
| 561 | .ops = &northbridge_operations, |
| 562 | .vendor = PCI_VENDOR_ID_AMD, |
| 563 | .device = PCI_DEVICE_ID_AMD_10H_NB_HT, |
| 564 | }; |
| 565 | |
| 566 | struct chip_operations northbridge_amd_agesa_family15tn_ops = { |
| 567 | CHIP_NAME("AMD FAM15 Northbridge") |
| 568 | .enable_dev = 0, |
| 569 | }; |
| 570 | |
Kyösti Mälkki | 2900d4b | 2017-07-25 14:55:29 +0300 | [diff] [blame] | 571 | static void domain_read_resources(struct device *dev) |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 572 | { |
Subrata Banik | b1434fc | 2019-03-15 22:20:41 +0530 | [diff] [blame] | 573 | unsigned int reg; |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 574 | |
| 575 | /* Find the already assigned resource pairs */ |
| 576 | get_fx_devs(); |
| 577 | for (reg = 0x80; reg <= 0xd8; reg+= 0x08) { |
| 578 | u32 base, limit; |
| 579 | base = f1_read_config32(reg); |
| 580 | limit = f1_read_config32(reg + 0x04); |
| 581 | /* Is this register allocated? */ |
| 582 | if ((base & 3) != 0) { |
Subrata Banik | b1434fc | 2019-03-15 22:20:41 +0530 | [diff] [blame] | 583 | unsigned int nodeid, reg_link; |
Kyösti Mälkki | e2c2a4c | 2018-05-20 20:59:52 +0300 | [diff] [blame] | 584 | struct device *reg_dev; |
Elyes HAOUAS | 1d8daa6 | 2016-09-18 08:50:54 +0200 | [diff] [blame] | 585 | if (reg < 0xc0) { // mmio |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 586 | nodeid = (limit & 0xf) + (base&0x30); |
| 587 | } else { // io |
| 588 | nodeid = (limit & 0xf) + ((base>>4)&0x30); |
| 589 | } |
| 590 | reg_link = (limit >> 4) & 7; |
| 591 | reg_dev = __f0_dev[nodeid]; |
| 592 | if (reg_dev) { |
| 593 | /* Reserve the resource */ |
| 594 | struct resource *res; |
| 595 | res = new_resource(reg_dev, IOINDEX(0x1000 + reg, reg_link)); |
| 596 | if (res) { |
| 597 | res->flags = 1; |
| 598 | } |
| 599 | } |
| 600 | } |
| 601 | } |
| 602 | /* FIXME: do we need to check extend conf space? |
| 603 | I don't believe that much preset value */ |
| 604 | |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 605 | pci_domain_read_resources(dev); |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 606 | } |
| 607 | |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 608 | #if CONFIG_HW_MEM_HOLE_SIZEK != 0 |
| 609 | struct hw_mem_hole_info { |
Subrata Banik | b1434fc | 2019-03-15 22:20:41 +0530 | [diff] [blame] | 610 | unsigned int hole_startk; |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 611 | int node_id; |
| 612 | }; |
| 613 | static struct hw_mem_hole_info get_hw_mem_hole_info(void) |
| 614 | { |
| 615 | struct hw_mem_hole_info mem_hole; |
| 616 | int i; |
| 617 | mem_hole.hole_startk = CONFIG_HW_MEM_HOLE_SIZEK; |
| 618 | mem_hole.node_id = -1; |
| 619 | for (i = 0; i < node_nums; i++) { |
| 620 | dram_base_mask_t d; |
| 621 | u32 hole; |
| 622 | d = get_dram_base_mask(i); |
| 623 | if (!(d.mask & 1)) continue; // no memory on this node |
| 624 | hole = pci_read_config32(__f1_dev[i], 0xf0); |
| 625 | if (hole & 1) { // we find the hole |
Elyes HAOUAS | 27e1801 | 2017-06-27 23:14:51 +0200 | [diff] [blame] | 626 | mem_hole.hole_startk = (hole & (0xff << 24)) >> 10; |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 627 | mem_hole.node_id = i; // record the node No with hole |
| 628 | break; // only one hole |
| 629 | } |
| 630 | } |
Kyösti Mälkki | 2f9b3af | 2014-06-26 05:30:54 +0300 | [diff] [blame] | 631 | |
| 632 | /* We need to double check if there is special set on base reg and limit reg |
| 633 | * are not continuous instead of hole, it will find out its hole_startk. |
| 634 | */ |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 635 | if (mem_hole.node_id == -1) { |
| 636 | resource_t limitk_pri = 0; |
Elyes HAOUAS | 1d8daa6 | 2016-09-18 08:50:54 +0200 | [diff] [blame] | 637 | for (i = 0; i < node_nums; i++) { |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 638 | dram_base_mask_t d; |
| 639 | resource_t base_k, limit_k; |
| 640 | d = get_dram_base_mask(i); |
| 641 | if (!(d.base & 1)) continue; |
| 642 | base_k = ((resource_t)(d.base & 0x1fffff00)) <<9; |
| 643 | if (base_k > 4 *1024 * 1024) break; // don't need to go to check |
| 644 | if (limitk_pri != base_k) { // we find the hole |
Martin Roth | 468d02c | 2019-10-23 21:44:42 -0600 | [diff] [blame] | 645 | mem_hole.hole_startk = (unsigned int)limitk_pri; // must beblow 4G |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 646 | mem_hole.node_id = i; |
| 647 | break; //only one hole |
| 648 | } |
zbao | 15dc3cc | 2012-08-03 15:56:21 +0800 | [diff] [blame] | 649 | limit_k = ((resource_t)(((d.mask & ~1) + 0x000FF) & 0x1fffff00)) << 9; |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 650 | limitk_pri = limit_k; |
| 651 | } |
| 652 | } |
| 653 | return mem_hole; |
| 654 | } |
| 655 | #endif |
| 656 | |
Kyösti Mälkki | 2900d4b | 2017-07-25 14:55:29 +0300 | [diff] [blame] | 657 | static void domain_set_resources(struct device *dev) |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 658 | { |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 659 | unsigned long mmio_basek; |
| 660 | u32 pci_tolm; |
| 661 | int i, idx; |
| 662 | struct bus *link; |
| 663 | #if CONFIG_HW_MEM_HOLE_SIZEK != 0 |
| 664 | struct hw_mem_hole_info mem_hole; |
| 665 | u32 reset_memhole = 1; |
| 666 | #endif |
| 667 | |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 668 | pci_tolm = 0xffffffffUL; |
| 669 | for (link = dev->link_list; link; link = link->next) { |
| 670 | pci_tolm = find_pci_tolm(link); |
| 671 | } |
| 672 | |
| 673 | // FIXME handle interleaved nodes. If you fix this here, please fix |
| 674 | // amdk8, too. |
| 675 | mmio_basek = pci_tolm >> 10; |
| 676 | /* Round mmio_basek to something the processor can support */ |
| 677 | mmio_basek &= ~((1 << 6) -1); |
| 678 | |
| 679 | // FIXME improve mtrr.c so we don't use up all of the mtrrs with a 64M |
| 680 | // MMIO hole. If you fix this here, please fix amdk8, too. |
| 681 | /* Round the mmio hole to 64M */ |
| 682 | mmio_basek &= ~((64*1024) - 1); |
| 683 | |
| 684 | #if CONFIG_HW_MEM_HOLE_SIZEK != 0 |
| 685 | /* if the hw mem hole is already set in raminit stage, here we will compare |
| 686 | * mmio_basek and hole_basek. if mmio_basek is bigger that hole_basek and will |
| 687 | * use hole_basek as mmio_basek and we don't need to reset hole. |
| 688 | * otherwise We reset the hole to the mmio_basek |
| 689 | */ |
| 690 | |
| 691 | mem_hole = get_hw_mem_hole_info(); |
| 692 | |
| 693 | // Use hole_basek as mmio_basek, and we don't need to reset hole anymore |
| 694 | if ((mem_hole.node_id != -1) && (mmio_basek > mem_hole.hole_startk)) { |
| 695 | mmio_basek = mem_hole.hole_startk; |
| 696 | reset_memhole = 0; |
| 697 | } |
| 698 | #endif |
| 699 | |
| 700 | idx = 0x10; |
| 701 | for (i = 0; i < node_nums; i++) { |
| 702 | dram_base_mask_t d; |
| 703 | resource_t basek, limitk, sizek; // 4 1T |
| 704 | |
| 705 | d = get_dram_base_mask(i); |
| 706 | |
| 707 | if (!(d.mask & 1)) continue; |
| 708 | basek = ((resource_t)(d.base & 0x1fffff00)) << 9; // could overflow, we may lost 6 bit here |
Edward O'Callaghan | ae5fd34 | 2014-11-20 19:58:09 +1100 | [diff] [blame] | 709 | limitk = ((resource_t)(((d.mask & ~1) + 0x000FF) & 0x1fffff00)) << 9; |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 710 | |
| 711 | sizek = limitk - basek; |
| 712 | |
| 713 | /* see if we need a hole from 0xa0000 to 0xbffff */ |
| 714 | if ((basek < ((8*64)+(8*16))) && (sizek > ((8*64)+(16*16)))) { |
| 715 | ram_resource(dev, (idx | i), basek, ((8*64)+(8*16)) - basek); |
| 716 | idx += 0x10; |
| 717 | basek = (8*64)+(16*16); |
| 718 | sizek = limitk - ((8*64)+(16*16)); |
| 719 | |
| 720 | } |
| 721 | |
Kyösti Mälkki | 26c6543 | 2014-06-26 05:30:54 +0300 | [diff] [blame] | 722 | /* split the region to accommodate pci memory space */ |
Elyes HAOUAS | 1d8daa6 | 2016-09-18 08:50:54 +0200 | [diff] [blame] | 723 | if ((basek < 4*1024*1024) && (limitk > mmio_basek)) { |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 724 | if (basek <= mmio_basek) { |
Subrata Banik | b1434fc | 2019-03-15 22:20:41 +0530 | [diff] [blame] | 725 | unsigned int pre_sizek; |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 726 | pre_sizek = mmio_basek - basek; |
Elyes HAOUAS | 1d8daa6 | 2016-09-18 08:50:54 +0200 | [diff] [blame] | 727 | if (pre_sizek > 0) { |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 728 | ram_resource(dev, (idx | i), basek, pre_sizek); |
| 729 | idx += 0x10; |
| 730 | sizek -= pre_sizek; |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 731 | } |
| 732 | basek = mmio_basek; |
| 733 | } |
| 734 | if ((basek + sizek) <= 4*1024*1024) { |
| 735 | sizek = 0; |
| 736 | } |
| 737 | else { |
Siyuan Wang | 29840e2 | 2013-06-04 19:56:22 +0800 | [diff] [blame] | 738 | uint64_t topmem2 = bsp_topmem2(); |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 739 | basek = 4*1024*1024; |
Siyuan Wang | 29840e2 | 2013-06-04 19:56:22 +0800 | [diff] [blame] | 740 | sizek = topmem2/1024 - basek; |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 741 | } |
| 742 | } |
| 743 | |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 744 | ram_resource(dev, (idx | i), basek, sizek); |
| 745 | idx += 0x10; |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 746 | printk(BIOS_DEBUG, "node %d: mmio_basek=%08lx, basek=%08llx, limitk=%08llx\n", |
| 747 | i, mmio_basek, basek, limitk); |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 748 | } |
| 749 | |
Kyösti Mälkki | 61be360 | 2017-04-15 20:07:53 +0300 | [diff] [blame] | 750 | add_uma_resource_below_tolm(dev, 7); |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 751 | |
Elyes HAOUAS | 5a7e72f | 2016-08-23 21:36:02 +0200 | [diff] [blame] | 752 | for (link = dev->link_list; link; link = link->next) { |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 753 | if (link->children) { |
| 754 | assign_resources(link); |
| 755 | } |
| 756 | } |
| 757 | } |
| 758 | |
| 759 | static struct device_operations pci_domain_ops = { |
| 760 | .read_resources = domain_read_resources, |
| 761 | .set_resources = domain_set_resources, |
Edward O'Callaghan | e9e1d7a | 2015-01-02 15:11:49 +1100 | [diff] [blame] | 762 | .init = DEVICE_NOOP, |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 763 | .scan_bus = pci_domain_scan_bus, |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 764 | }; |
| 765 | |
Kyösti Mälkki | e2c2a4c | 2018-05-20 20:59:52 +0300 | [diff] [blame] | 766 | static void sysconf_init(struct device *dev) // first node |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 767 | { |
| 768 | sblink = (pci_read_config32(dev, 0x64)>>8) & 7; // don't forget sublink1 |
| 769 | node_nums = ((pci_read_config32(dev, 0x60)>>4) & 7) + 1; //NodeCnt[2:0] |
| 770 | } |
| 771 | |
Kyösti Mälkki | e2c2a4c | 2018-05-20 20:59:52 +0300 | [diff] [blame] | 772 | static void cpu_bus_scan(struct device *dev) |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 773 | { |
| 774 | struct bus *cpu_bus; |
Kyösti Mälkki | e2c2a4c | 2018-05-20 20:59:52 +0300 | [diff] [blame] | 775 | struct device *dev_mc; |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 776 | int i,j; |
| 777 | int coreid_bits; |
| 778 | int core_max = 0; |
Subrata Banik | b1434fc | 2019-03-15 22:20:41 +0530 | [diff] [blame] | 779 | unsigned int ApicIdCoreIdSize; |
| 780 | unsigned int core_nums; |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 781 | int siblings = 0; |
| 782 | unsigned int family; |
| 783 | |
Kyösti Mälkki | 3d3152e | 2019-01-10 09:05:30 +0200 | [diff] [blame] | 784 | dev_mc = pcidev_on_root(DEV_CDB, 0); |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 785 | if (!dev_mc) { |
Kyösti Mälkki | 3d3152e | 2019-01-10 09:05:30 +0200 | [diff] [blame] | 786 | printk(BIOS_ERR, "0:%02x.0 not found", DEV_CDB); |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 787 | die(""); |
| 788 | } |
| 789 | sysconf_init(dev_mc); |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 790 | |
| 791 | /* Get Max Number of cores(MNC) */ |
Kyösti Mälkki | d41feed | 2017-09-24 16:23:57 +0300 | [diff] [blame] | 792 | coreid_bits = (cpuid_ecx(0x80000008) & 0x0000F000) >> 12; |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 793 | core_max = 1 << (coreid_bits & 0x000F); //mnc |
| 794 | |
| 795 | ApicIdCoreIdSize = ((cpuid_ecx(0x80000008)>>12) & 0xF); |
| 796 | if (ApicIdCoreIdSize) { |
| 797 | core_nums = (1 << ApicIdCoreIdSize) - 1; |
| 798 | } else { |
| 799 | core_nums = 3; //quad core |
| 800 | } |
| 801 | |
| 802 | /* Find which cpus are present */ |
| 803 | cpu_bus = dev->link_list; |
| 804 | for (i = 0; i < node_nums; i++) { |
Kyösti Mälkki | e2c2a4c | 2018-05-20 20:59:52 +0300 | [diff] [blame] | 805 | struct device *cdb_dev; |
Subrata Banik | b1434fc | 2019-03-15 22:20:41 +0530 | [diff] [blame] | 806 | unsigned int devn; |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 807 | struct bus *pbus; |
| 808 | |
Kyösti Mälkki | 3d3152e | 2019-01-10 09:05:30 +0200 | [diff] [blame] | 809 | devn = DEV_CDB + i; |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 810 | pbus = dev_mc->bus; |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 811 | |
| 812 | /* Find the cpu's pci device */ |
Kyösti Mälkki | 4ad7f5b | 2018-05-22 01:15:17 +0300 | [diff] [blame] | 813 | cdb_dev = pcidev_on_root(devn, 0); |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 814 | if (!cdb_dev) { |
| 815 | /* If I am probing things in a weird order |
| 816 | * ensure all of the cpu's pci devices are found. |
| 817 | */ |
| 818 | int fn; |
Elyes HAOUAS | 5a7e72f | 2016-08-23 21:36:02 +0200 | [diff] [blame] | 819 | for (fn = 0; fn <= 5; fn++) { //FBDIMM? |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 820 | cdb_dev = pci_probe_dev(NULL, pbus, |
| 821 | PCI_DEVFN(devn, fn)); |
| 822 | } |
Kyösti Mälkki | 4ad7f5b | 2018-05-22 01:15:17 +0300 | [diff] [blame] | 823 | cdb_dev = pcidev_on_root(devn, 0); |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 824 | } else { |
| 825 | /* Ok, We need to set the links for that device. |
| 826 | * otherwise the device under it will not be scanned |
| 827 | */ |
Kyösti Mälkki | 2a2d613 | 2015-02-04 13:25:37 +0200 | [diff] [blame] | 828 | add_more_links(cdb_dev, 4); |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 829 | } |
| 830 | |
| 831 | family = cpuid_eax(1); |
| 832 | family = (family >> 20) & 0xFF; |
| 833 | if (family == 1) { //f10 |
| 834 | u32 dword; |
Kyösti Mälkki | 4ad7f5b | 2018-05-22 01:15:17 +0300 | [diff] [blame] | 835 | cdb_dev = pcidev_on_root(devn, 3); |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 836 | dword = pci_read_config32(cdb_dev, 0xe8); |
| 837 | siblings = ((dword & BIT15) >> 13) | ((dword & (BIT13 | BIT12)) >> 12); |
| 838 | } else if (family == 6) {//f15 |
Kyösti Mälkki | 4ad7f5b | 2018-05-22 01:15:17 +0300 | [diff] [blame] | 839 | cdb_dev = pcidev_on_root(devn, 5); |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 840 | if (cdb_dev && cdb_dev->enabled) { |
| 841 | siblings = pci_read_config32(cdb_dev, 0x84); |
| 842 | siblings &= 0xFF; |
| 843 | } |
| 844 | } else { |
| 845 | siblings = 0; //default one core |
| 846 | } |
Kyösti Mälkki | cd9fc1a | 2012-07-06 19:02:56 +0300 | [diff] [blame] | 847 | int enable_node = cdb_dev && cdb_dev->enabled; |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 848 | printk(BIOS_SPEW, "%s family%xh, core_max=0x%x, core_nums=0x%x, siblings=0x%x\n", |
| 849 | dev_path(cdb_dev), 0x0f + family, core_max, core_nums, siblings); |
| 850 | |
Elyes HAOUAS | 1d8daa6 | 2016-09-18 08:50:54 +0200 | [diff] [blame] | 851 | for (j = 0; j <= siblings; j++) { |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 852 | extern CONST OPTIONS_CONFIG_TOPOLOGY ROMDATA TopologyConfiguration; |
| 853 | u32 modules = TopologyConfiguration.PlatformNumberOfModules; |
| 854 | u32 lapicid_start = 0; |
| 855 | |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 856 | /* |
| 857 | * APIC ID calucation is tightly coupled with AGESA v5 code. |
| 858 | * This calculation MUST match the assignment calculation done |
| 859 | * in LocalApicInitializationAtEarly() function. |
| 860 | * And reference GetLocalApicIdForCore() |
| 861 | * |
Elyes HAOUAS | a5b0bc4 | 2020-02-20 20:04:29 +0100 | [diff] [blame] | 862 | * Apply APIC enumeration rules |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 863 | * For systems with >= 16 APICs, put the IO-APICs at 0..n and |
| 864 | * put the local-APICs at m..z |
| 865 | * |
| 866 | * This is needed because many IO-APIC devices only have 4 bits |
| 867 | * for their APIC id and therefore must reside at 0..15 |
Elyes HAOUAS | 6e8b3c1 | 2016-09-02 19:22:00 +0200 | [diff] [blame] | 868 | */ |
Kyösti Mälkki | 5003632 | 2016-05-18 13:35:21 +0300 | [diff] [blame] | 869 | |
Elyes HAOUAS | 6e8b3c1 | 2016-09-02 19:22:00 +0200 | [diff] [blame] | 870 | u8 plat_num_io_apics = 3; /* FIXME */ |
Kyösti Mälkki | 5003632 | 2016-05-18 13:35:21 +0300 | [diff] [blame] | 871 | |
| 872 | if ((node_nums * core_max) + plat_num_io_apics >= 0x10) { |
| 873 | lapicid_start = (plat_num_io_apics - 1) / core_max; |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 874 | lapicid_start = (lapicid_start + 1) * core_max; |
| 875 | printk(BIOS_SPEW, "lpaicid_start=0x%x ", lapicid_start); |
| 876 | } |
Kyösti Mälkki | c33f1e9 | 2012-08-07 17:12:11 +0300 | [diff] [blame] | 877 | u32 apic_id = (lapicid_start * (i/modules + 1)) + ((i % modules) ? (j + (siblings + 1)) : j); |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 878 | printk(BIOS_SPEW, "node 0x%x core 0x%x apicid=0x%x\n", |
Kyösti Mälkki | c33f1e9 | 2012-08-07 17:12:11 +0300 | [diff] [blame] | 879 | i, j, apic_id); |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 880 | |
Kyösti Mälkki | e2c2a4c | 2018-05-20 20:59:52 +0300 | [diff] [blame] | 881 | struct device *cpu = add_cpu_device(cpu_bus, apic_id, enable_node); |
Kyösti Mälkki | c33f1e9 | 2012-08-07 17:12:11 +0300 | [diff] [blame] | 882 | if (cpu) |
| 883 | amd_cpu_topology(cpu, i, j); |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 884 | } //j |
| 885 | } |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 886 | } |
| 887 | |
Kyösti Mälkki | 2900d4b | 2017-07-25 14:55:29 +0300 | [diff] [blame] | 888 | static void cpu_bus_init(struct device *dev) |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 889 | { |
| 890 | initialize_cpus(dev->link_list); |
| 891 | } |
| 892 | |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 893 | static struct device_operations cpu_bus_ops = { |
Edward O'Callaghan | 2837ab2 | 2014-11-06 08:57:40 +1100 | [diff] [blame] | 894 | .read_resources = DEVICE_NOOP, |
| 895 | .set_resources = DEVICE_NOOP, |
Edward O'Callaghan | 812d2a4 | 2014-10-31 08:17:23 +1100 | [diff] [blame] | 896 | .enable_resources = DEVICE_NOOP, |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 897 | .init = cpu_bus_init, |
| 898 | .scan_bus = cpu_bus_scan, |
| 899 | }; |
| 900 | |
| 901 | static void root_complex_enable_dev(struct device *dev) |
| 902 | { |
Kyösti Mälkki | 87213b6 | 2012-08-27 20:00:33 +0300 | [diff] [blame] | 903 | static int done = 0; |
| 904 | |
Kyösti Mälkki | 87213b6 | 2012-08-27 20:00:33 +0300 | [diff] [blame] | 905 | if (!done) { |
| 906 | setup_bsp_ramtop(); |
Kyösti Mälkki | 87213b6 | 2012-08-27 20:00:33 +0300 | [diff] [blame] | 907 | done = 1; |
| 908 | } |
| 909 | |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 910 | /* Set the operations if it is a special bus type */ |
Stefan Reinauer | 4aff445 | 2013-02-12 14:17:15 -0800 | [diff] [blame] | 911 | if (dev->path.type == DEVICE_PATH_DOMAIN) { |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 912 | dev->ops = &pci_domain_ops; |
Stefan Reinauer | 0aa37c4 | 2013-02-12 15:20:54 -0800 | [diff] [blame] | 913 | } else if (dev->path.type == DEVICE_PATH_CPU_CLUSTER) { |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 914 | dev->ops = &cpu_bus_ops; |
| 915 | } |
| 916 | } |
| 917 | |
| 918 | struct chip_operations northbridge_amd_agesa_family15tn_root_complex_ops = { |
Kyösti Mälkki | 2900d4b | 2017-07-25 14:55:29 +0300 | [diff] [blame] | 919 | CHIP_NAME("AMD Family 15tn Root Complex") |
zbao | 2c08f6a | 2012-07-02 15:32:58 +0800 | [diff] [blame] | 920 | .enable_dev = root_complex_enable_dev, |
| 921 | }; |
Dave Frodin | cbf3d40 | 2012-12-05 08:20:12 -0700 | [diff] [blame] | 922 | |
Edward O'Callaghan | ae5fd34 | 2014-11-20 19:58:09 +1100 | [diff] [blame] | 923 | /********************************************************************* |
| 924 | * Change the vendor / device IDs to match the generic VBIOS header. * |
| 925 | *********************************************************************/ |
Dave Frodin | cbf3d40 | 2012-12-05 08:20:12 -0700 | [diff] [blame] | 926 | u32 map_oprom_vendev(u32 vendev) |
| 927 | { |
Edward O'Callaghan | ae5fd34 | 2014-11-20 19:58:09 +1100 | [diff] [blame] | 928 | u32 new_vendev = vendev; |
Dave Frodin | cbf3d40 | 2012-12-05 08:20:12 -0700 | [diff] [blame] | 929 | |
Elyes HAOUAS | 0ce41f1 | 2018-11-13 10:03:31 +0100 | [diff] [blame] | 930 | switch (vendev) { |
Bruce Griffith | 42e11f5 | 2013-07-08 18:19:08 -0600 | [diff] [blame] | 931 | case 0x10029900: /* AMD Radeon HD 7660G (Trinity) */ |
| 932 | case 0x10029901: /* AMD Radeon HD 7660D (Trinity) */ |
| 933 | case 0x10029903: /* AMD Radeon HD 7640G (Trinity) */ |
| 934 | case 0x10029904: /* AMD Radeon HD 7560D (Trinity) */ |
| 935 | case 0x10029907: /* AMD Radeon HD 7620G (Trinity) */ |
| 936 | case 0x10029908: /* AMD Radeon HD 7600G (Trinity) */ |
| 937 | case 0x1002990A: /* AMD Radeon HD 7500G (Trinity) */ |
| 938 | case 0x1002990B: /* AMD Radeon HD 8650G (Richland) */ |
| 939 | case 0x1002990C: /* AMD Radeon HD 8670D (Richland) */ |
| 940 | case 0x1002990D: /* AMD Radeon HD 8550G (Richland) */ |
| 941 | case 0x1002990E: /* AMD Radeon HD 8570D (Richland) */ |
| 942 | case 0x1002990F: /* AMD Radeon HD 8610G (Richland) */ |
| 943 | case 0x10029910: /* AMD Radeon HD 7660G (Trinity) */ |
| 944 | case 0x10029913: /* AMD Radeon HD 7640G (Trinity) */ |
| 945 | case 0x10029917: /* AMD Radeon HD 7620G (Trinity) */ |
| 946 | case 0x10029918: /* AMD Radeon HD 7600G (Trinity) */ |
| 947 | case 0x10029919: /* AMD Radeon HD 7500G (Trinity) */ |
| 948 | case 0x10029990: /* AMD Radeon HD 7520G (Trinity) */ |
| 949 | case 0x10029991: /* AMD Radeon HD 7540D (Trinity) */ |
| 950 | case 0x10029992: /* AMD Radeon HD 7420G (Trinity) */ |
| 951 | case 0x10029993: /* AMD Radeon HD 7480D (Trinity) */ |
| 952 | case 0x10029994: /* AMD Radeon HD 7400G (Trinity) */ |
| 953 | case 0x10029995: /* AMD Radeon HD 8450G (Richland) */ |
| 954 | case 0x10029996: /* AMD Radeon HD 8470D (Richland) */ |
| 955 | case 0x10029997: /* AMD Radeon HD 8350G (Richland) */ |
| 956 | case 0x10029998: /* AMD Radeon HD 8370D (Richland) */ |
| 957 | case 0x10029999: /* AMD Radeon HD 8510G (Richland) */ |
| 958 | case 0x1002999A: /* AMD Radeon HD 8410G (Richland) */ |
| 959 | case 0x1002999B: /* AMD Radeon HD 8310G (Richland) */ |
| 960 | case 0x1002999C: /* AMD Radeon HD 8650D (Richland) */ |
| 961 | case 0x1002999D: /* AMD Radeon HD 8550D (Richland) */ |
| 962 | case 0x100299A0: /* AMD Radeon HD 7520G (Trinity) */ |
| 963 | case 0x100299A2: /* AMD Radeon HD 7420G (Trinity) */ |
| 964 | case 0x100299A4: /* AMD Radeon HD 7400G (Trinity) */ |
Edward O'Callaghan | ae5fd34 | 2014-11-20 19:58:09 +1100 | [diff] [blame] | 965 | new_vendev = 0x10029901; |
Dave Frodin | cbf3d40 | 2012-12-05 08:20:12 -0700 | [diff] [blame] | 966 | break; |
| 967 | } |
| 968 | |
| 969 | return new_vendev; |
| 970 | } |