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