Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 1 | /* |
Stefan Reinauer | 7e61e45 | 2008-01-18 10:35:56 +0000 | [diff] [blame] | 2 | * This file is part of the coreboot project. |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 3 | * |
Timothy Pearson | 88d213a | 2015-01-23 20:28:13 -0600 | [diff] [blame] | 4 | * Copyright (C) 2015 Timothy Pearson <tpearson@raptorengineeringinc.com>, Raptor Engineering |
Marc Jones | da4ce6b | 2008-04-22 22:11:31 +0000 | [diff] [blame] | 5 | * Copyright (C) 2007-2008 Advanced Micro Devices, Inc. |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; version 2 of the License. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 15 | */ |
| 16 | |
Patrick Georgi | 3d5bb23 | 2010-05-09 21:15:13 +0000 | [diff] [blame] | 17 | #include <cpu/x86/msr.h> |
| 18 | #include <console/console.h> |
| 19 | #include <northbridge/amd/amdfam10/amdfam10.h> |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 20 | |
Timothy Pearson | 1c4508e | 2015-09-05 17:50:29 -0500 | [diff] [blame] | 21 | #include "ht_wrapper.h" |
| 22 | |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 23 | /*---------------------------------------------------------------------------- |
| 24 | * TYPEDEFS, DEFINITIONS AND MACROS |
| 25 | * |
| 26 | *---------------------------------------------------------------------------- |
| 27 | */ |
| 28 | |
| 29 | /* Single CPU system? */ |
Timothy Pearson | 88d213a | 2015-01-23 20:28:13 -0600 | [diff] [blame] | 30 | #if (CONFIG_MAX_PHYSICAL_CPUS == 1) |
| 31 | /* FIXME |
| 32 | * This #define is used by other #included .c files |
| 33 | * When set, multiprocessor support is completely disabled |
| 34 | */ |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 35 | #define HT_BUILD_NC_ONLY 1 |
| 36 | #endif |
| 37 | |
| 38 | /* Debugging Options */ |
| 39 | #define AMD_DEBUG 1 |
| 40 | //#define AMD_DEBUG_ERROR_STOP 1 |
| 41 | |
| 42 | /*---------------------------------------------------------------------------- |
| 43 | * MODULES USED |
| 44 | * |
| 45 | *---------------------------------------------------------------------------- |
| 46 | */ |
| 47 | |
| 48 | #undef FILECODE |
| 49 | #define FILECODE 0xFF01 |
| 50 | #include "comlib.h" |
| 51 | #include "h3gtopo.h" |
| 52 | #include "h3finit.h" |
| 53 | |
| 54 | /* include the main HT source file */ |
| 55 | #include "h3finit.c" |
| 56 | |
| 57 | |
| 58 | /*---------------------------------------------------------------------------- |
| 59 | * LOCAL FUNCTIONS |
| 60 | * |
| 61 | *---------------------------------------------------------------------------- |
| 62 | */ |
| 63 | |
| 64 | /* FIXME: Find a better place for these pre-ram functions. */ |
| 65 | #define NODE_HT(x) NODE_PCI(x,0) |
| 66 | #define NODE_MP(x) NODE_PCI(x,1) |
| 67 | #define NODE_MC(x) NODE_PCI(x,3) |
| 68 | #define NODE_LC(x) NODE_PCI(x,4) |
Marc Jones | da4ce6b | 2008-04-22 22:11:31 +0000 | [diff] [blame] | 69 | |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 70 | static u32 get_nodes(void) |
| 71 | { |
| 72 | device_t dev; |
| 73 | u32 nodes; |
| 74 | |
Stefan Reinauer | 0867062 | 2009-06-30 15:17:49 +0000 | [diff] [blame] | 75 | dev = PCI_DEV(CONFIG_CBB, CONFIG_CDB, 0); |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 76 | nodes = ((pci_read_config32(dev, 0x60)>>4) & 7) ; |
| 77 | #if CONFIG_MAX_PHYSICAL_CPUS > 8 |
| 78 | nodes += (((pci_read_config32(dev, 0x160)>>4) & 7)<<3); |
| 79 | #endif |
| 80 | nodes++; |
| 81 | |
| 82 | return nodes; |
| 83 | } |
| 84 | |
Timothy Pearson | 0122afb | 2015-07-30 14:07:15 -0500 | [diff] [blame] | 85 | static const char * event_class_string_decodes[] = { |
| 86 | [HT_EVENT_CLASS_CRITICAL] = "CRITICAL", |
| 87 | [HT_EVENT_CLASS_ERROR] = "ERROR", |
| 88 | [HT_EVENT_CLASS_HW_FAULT] = "HARDWARE FAULT", |
| 89 | [HT_EVENT_CLASS_WARNING] = "WARNING", |
| 90 | [HT_EVENT_CLASS_INFO] = "INFO" |
| 91 | }; |
| 92 | |
Timothy Pearson | 69056d9 | 2015-11-16 11:48:38 -0600 | [diff] [blame] | 93 | typedef struct { |
| 94 | uint32_t code; |
| 95 | const char * string; |
| 96 | } event_string_decode_t; |
| 97 | |
| 98 | static const event_string_decode_t event_string_decodes[] = { |
| 99 | { HT_EVENT_COH_EVENTS, "HT_EVENT_COH_EVENTS" }, |
| 100 | { HT_EVENT_COH_NO_TOPOLOGY, "HT_EVENT_COH_NO_TOPOLOGY" }, |
| 101 | { HT_EVENT_COH_LINK_EXCEED, "HT_EVENT_COH_LINK_EXCEED" }, |
| 102 | { HT_EVENT_COH_FAMILY_FEUD, "HT_EVENT_COH_FAMILY_FEUD" }, |
| 103 | { HT_EVENT_COH_NODE_DISCOVERED, "HT_EVENT_COH_NODE_DISCOVERED" }, |
| 104 | { HT_EVENT_COH_MPCAP_MISMATCH, "HT_EVENT_COH_MPCAP_MISMATCH" }, |
| 105 | { HT_EVENT_NCOH_EVENTS, "HT_EVENT_NCOH_EVENTS" }, |
| 106 | { HT_EVENT_NCOH_BUID_EXCEED, "HT_EVENT_NCOH_BUID_EXCEED" }, |
| 107 | { HT_EVENT_NCOH_LINK_EXCEED, "HT_EVENT_NCOH_LINK_EXCEED" }, |
| 108 | { HT_EVENT_NCOH_BUS_MAX_EXCEED, "HT_EVENT_NCOH_BUS_MAX_EXCEED" }, |
| 109 | { HT_EVENT_NCOH_CFG_MAP_EXCEED, "HT_EVENT_NCOH_CFG_MAP_EXCEED" }, |
| 110 | { HT_EVENT_NCOH_DEVICE_FAILED, "HT_EVENT_NCOH_DEVICE_FAILED" }, |
| 111 | { HT_EVENT_NCOH_AUTO_DEPTH, "HT_EVENT_NCOH_AUTO_DEPTH" }, |
| 112 | { HT_EVENT_OPT_EVENTS, "HT_EVENT_OPT_EVENTS" }, |
| 113 | { HT_EVENT_OPT_REQUIRED_CAP_RETRY, "HT_EVENT_OPT_REQUIRED_CAP_RETRY" }, |
| 114 | { HT_EVENT_OPT_REQUIRED_CAP_GEN3, "HT_EVENT_OPT_REQUIRED_CAP_GEN3" }, |
| 115 | { HT_EVENT_HW_EVENTS, "HT_EVENT_HW_EVENTS" }, |
| 116 | { HT_EVENT_HW_SYNCHFLOOD, "HT_EVENT_HW_SYNCHFLOOD" }, |
| 117 | { HT_EVENT_HW_HTCRC, "HT_EVENT_HW_HTCRC" } |
Timothy Pearson | 0122afb | 2015-07-30 14:07:15 -0500 | [diff] [blame] | 118 | }; |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 119 | |
Timothy Pearson | 69056d9 | 2015-11-16 11:48:38 -0600 | [diff] [blame] | 120 | static const char * event_string_decode(uint32_t event) { |
| 121 | uint32_t i; |
| 122 | for (i = 0; i < ARRAY_SIZE(event_string_decodes); i++) |
| 123 | if (event_string_decodes[i].code == event) |
| 124 | break; |
| 125 | if (i == ARRAY_SIZE(event_string_decodes)) |
| 126 | return "ERROR: Unmatched event code! " |
| 127 | "Did you forget to update event_string_decodes[]?"; |
| 128 | return event_string_decodes[i].string; |
| 129 | } |
| 130 | |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 131 | /** |
| 132 | * void AMD_CB_EventNotify (u8 evtClass, u16 event, const u8 *pEventData0) |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 133 | */ |
Myles Watson | 075fbe8 | 2010-04-15 05:19:29 +0000 | [diff] [blame] | 134 | static void AMD_CB_EventNotify (u8 evtClass, u16 event, const u8 *pEventData0) |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 135 | { |
Timothy Pearson | 0122afb | 2015-07-30 14:07:15 -0500 | [diff] [blame] | 136 | uint8_t i; |
| 137 | uint8_t log_level; |
| 138 | uint8_t dump_event_detail; |
Marc Jones | eafcedd | 2008-07-17 19:54:06 +0000 | [diff] [blame] | 139 | |
Timothy Pearson | 0122afb | 2015-07-30 14:07:15 -0500 | [diff] [blame] | 140 | printk(BIOS_DEBUG, "AMD_CB_EventNotify(): "); |
Marc Jones | eafcedd | 2008-07-17 19:54:06 +0000 | [diff] [blame] | 141 | |
Timothy Pearson | 0122afb | 2015-07-30 14:07:15 -0500 | [diff] [blame] | 142 | /* Decode event */ |
| 143 | dump_event_detail = 1; |
| 144 | switch (evtClass) { |
| 145 | case HT_EVENT_CLASS_CRITICAL: |
| 146 | case HT_EVENT_CLASS_ERROR: |
| 147 | case HT_EVENT_CLASS_HW_FAULT: |
| 148 | case HT_EVENT_CLASS_WARNING: |
| 149 | case HT_EVENT_CLASS_INFO: |
| 150 | log_level = BIOS_DEBUG; |
| 151 | printk(log_level, event_class_string_decodes[evtClass]); |
| 152 | break; |
| 153 | default: |
| 154 | log_level = BIOS_DEBUG; |
| 155 | printk(log_level, "UNKNOWN"); |
| 156 | break; |
Marc Jones | eafcedd | 2008-07-17 19:54:06 +0000 | [diff] [blame] | 157 | } |
Timothy Pearson | 0122afb | 2015-07-30 14:07:15 -0500 | [diff] [blame] | 158 | printk(log_level, ": "); |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 159 | |
Timothy Pearson | 0122afb | 2015-07-30 14:07:15 -0500 | [diff] [blame] | 160 | switch(event) { |
| 161 | case HT_EVENT_COH_EVENTS: |
| 162 | case HT_EVENT_COH_NO_TOPOLOGY: |
| 163 | case HT_EVENT_COH_LINK_EXCEED: |
| 164 | case HT_EVENT_COH_FAMILY_FEUD: |
Timothy Pearson | 69056d9 | 2015-11-16 11:48:38 -0600 | [diff] [blame] | 165 | printk(log_level, event_string_decode(event)); |
Timothy Pearson | 0122afb | 2015-07-30 14:07:15 -0500 | [diff] [blame] | 166 | break; |
| 167 | case HT_EVENT_COH_NODE_DISCOVERED: |
| 168 | { |
| 169 | printk(log_level, "HT_EVENT_COH_NODE_DISCOVERED"); |
| 170 | sHtEventCohNodeDiscovered *evt = (sHtEventCohNodeDiscovered*)pEventData0; |
| 171 | printk(log_level, ": node %d link %d new node: %d", |
| 172 | evt->node, evt->link, evt->newNode); |
| 173 | dump_event_detail = 0; |
| 174 | break; |
| 175 | } |
| 176 | case HT_EVENT_COH_MPCAP_MISMATCH: |
| 177 | case HT_EVENT_NCOH_EVENTS: |
| 178 | case HT_EVENT_NCOH_BUID_EXCEED: |
| 179 | case HT_EVENT_NCOH_LINK_EXCEED: |
| 180 | case HT_EVENT_NCOH_BUS_MAX_EXCEED: |
| 181 | case HT_EVENT_NCOH_CFG_MAP_EXCEED: |
Timothy Pearson | 69056d9 | 2015-11-16 11:48:38 -0600 | [diff] [blame] | 182 | printk(log_level, event_string_decode(event)); |
Timothy Pearson | 0122afb | 2015-07-30 14:07:15 -0500 | [diff] [blame] | 183 | break; |
| 184 | case HT_EVENT_NCOH_DEVICE_FAILED: |
| 185 | { |
Timothy Pearson | 69056d9 | 2015-11-16 11:48:38 -0600 | [diff] [blame] | 186 | printk(log_level, event_string_decode(event)); |
Timothy Pearson | 0122afb | 2015-07-30 14:07:15 -0500 | [diff] [blame] | 187 | sHtEventNcohDeviceFailed *evt = (sHtEventNcohDeviceFailed*)pEventData0; |
| 188 | printk(log_level, ": node %d link %d depth: %d attemptedBUID: %d", |
| 189 | evt->node, evt->link, evt->depth, evt->attemptedBUID); |
| 190 | dump_event_detail = 0; |
| 191 | break; |
| 192 | } |
| 193 | case HT_EVENT_NCOH_AUTO_DEPTH: |
| 194 | { |
Timothy Pearson | 69056d9 | 2015-11-16 11:48:38 -0600 | [diff] [blame] | 195 | printk(log_level, event_string_decode(event)); |
Timothy Pearson | 0122afb | 2015-07-30 14:07:15 -0500 | [diff] [blame] | 196 | sHtEventNcohAutoDepth *evt = (sHtEventNcohAutoDepth*)pEventData0; |
| 197 | printk(log_level, ": node %d link %d depth: %d", |
| 198 | evt->node, evt->link, evt->depth); |
| 199 | dump_event_detail = 0; |
| 200 | break; |
| 201 | } |
| 202 | case HT_EVENT_OPT_EVENTS: |
| 203 | case HT_EVENT_OPT_REQUIRED_CAP_RETRY: |
| 204 | case HT_EVENT_OPT_REQUIRED_CAP_GEN3: |
| 205 | case HT_EVENT_HW_EVENTS: |
| 206 | case HT_EVENT_HW_SYNCHFLOOD: |
| 207 | case HT_EVENT_HW_HTCRC: |
Timothy Pearson | 69056d9 | 2015-11-16 11:48:38 -0600 | [diff] [blame] | 208 | printk(log_level, event_string_decode(event)); |
Timothy Pearson | 0122afb | 2015-07-30 14:07:15 -0500 | [diff] [blame] | 209 | break; |
| 210 | default: |
| 211 | printk(log_level, "HT_EVENT_UNKNOWN"); |
| 212 | break; |
| 213 | } |
| 214 | printk(log_level, "\n"); |
| 215 | |
| 216 | if (dump_event_detail) { |
| 217 | printk(BIOS_DEBUG, " event class: %02x\n event: %04x\n data: ", evtClass, event); |
| 218 | |
| 219 | for (i = 0; i < *pEventData0; i++) { |
| 220 | printk(BIOS_DEBUG, " %02x ", *(pEventData0 + i)); |
| 221 | } |
| 222 | printk(BIOS_DEBUG, "\n"); |
| 223 | } |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 224 | } |
| 225 | |
| 226 | /** |
| 227 | * void getAmdTopolist(u8 ***p) |
| 228 | * |
| 229 | * point to the stock topo list array |
| 230 | * |
| 231 | */ |
| 232 | void getAmdTopolist(u8 ***p) |
| 233 | { |
| 234 | *p = (u8 **)amd_topo_list; |
| 235 | } |
| 236 | |
Timothy Pearson | 1c4508e | 2015-09-05 17:50:29 -0500 | [diff] [blame] | 237 | /** |
| 238 | * BOOL AMD_CB_IgnoreLink(u8 Node, u8 Link) |
| 239 | * Description: |
| 240 | * This routine is used to ignore connected yet faulty HT links, |
| 241 | * such as those present in a G34 processor package. |
| 242 | * |
| 243 | * Parameters: |
| 244 | * @param[in] node = The node on which this chain is located |
| 245 | * @param[in] link = The link on the host for this chain |
| 246 | */ |
| 247 | static BOOL AMD_CB_IgnoreLink (u8 node, u8 link) |
| 248 | { |
| 249 | return 0; |
| 250 | } |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 251 | |
| 252 | /** |
| 253 | * void amd_ht_init(struct sys_info *sysinfo) |
| 254 | * |
Stefan Reinauer | f8ee180 | 2008-01-18 15:08:58 +0000 | [diff] [blame] | 255 | * AMD HT init coreboot wrapper |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 256 | * |
| 257 | */ |
Myles Watson | 075fbe8 | 2010-04-15 05:19:29 +0000 | [diff] [blame] | 258 | static void amd_ht_init(struct sys_info *sysinfo) |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 259 | { |
Marc Jones | eafcedd | 2008-07-17 19:54:06 +0000 | [diff] [blame] | 260 | |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 261 | AMD_HTBLOCK ht_wrapper = { |
| 262 | NULL, // u8 **topolist; |
| 263 | 0, // u8 AutoBusStart; |
| 264 | 32, // u8 AutoBusMax; |
| 265 | 6, // u8 AutoBusIncrement; |
Timothy Pearson | 1c4508e | 2015-09-05 17:50:29 -0500 | [diff] [blame] | 266 | AMD_CB_IgnoreLink, // BOOL (*AMD_CB_IgnoreLink)(); |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 267 | NULL, // BOOL (*AMD_CB_OverrideBusNumbers)(); |
Marc Jones | eafcedd | 2008-07-17 19:54:06 +0000 | [diff] [blame] | 268 | AMD_CB_ManualBUIDSwapList, // BOOL (*AMD_CB_ManualBUIDSwapList)(); |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 269 | NULL, // void (*AMD_CB_DeviceCapOverride)(); |
| 270 | NULL, // void (*AMD_CB_Cpu2CpuPCBLimits)(); |
| 271 | NULL, // void (*AMD_CB_IOPCBLimits)(); |
| 272 | NULL, // BOOL (*AMD_CB_SkipRegang)(); |
| 273 | NULL, // BOOL (*AMD_CB_CustomizeTrafficDistribution)(); |
| 274 | NULL, // BOOL (*AMD_CB_CustomizeBuffers)(); |
| 275 | NULL, // void (*AMD_CB_OverrideDevicePort)(); |
| 276 | NULL, // void (*AMD_CB_OverrideCpuPort)(); |
Timothy Pearson | 586d6e2 | 2015-02-16 14:57:06 -0600 | [diff] [blame] | 277 | AMD_CB_EventNotify, // void (*AMD_CB_EventNotify) (); |
| 278 | &sysinfo->ht_link_cfg // struct ht_link_config* |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 279 | }; |
| 280 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 281 | printk(BIOS_DEBUG, "Enter amd_ht_init()\n"); |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 282 | amdHtInitialize(&ht_wrapper); |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 283 | printk(BIOS_DEBUG, "Exit amd_ht_init()\n"); |
Timothy Pearson | 1c4508e | 2015-09-05 17:50:29 -0500 | [diff] [blame] | 284 | } |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 285 | |
Timothy Pearson | 1c4508e | 2015-09-05 17:50:29 -0500 | [diff] [blame] | 286 | /** |
| 287 | * void amd_ht_fixup(struct sys_info *sysinfo) |
| 288 | * |
| 289 | * AMD HT fixup |
| 290 | * |
| 291 | */ |
| 292 | void amd_ht_fixup(struct sys_info *sysinfo) { |
| 293 | printk(BIOS_DEBUG, "amd_ht_fixup()\n"); |
| 294 | if (IS_ENABLED(CONFIG_CPU_AMD_MODEL_10XXX)) { |
| 295 | uint8_t rev_gte_d = 0; |
Timothy Pearson | 730a043 | 2015-10-16 13:51:51 -0500 | [diff] [blame] | 296 | uint8_t fam15h = 0; |
Timothy Pearson | 1c4508e | 2015-09-05 17:50:29 -0500 | [diff] [blame] | 297 | uint8_t dual_node = 0; |
| 298 | uint32_t f3xe8; |
| 299 | uint32_t family; |
| 300 | uint32_t model; |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 301 | |
Timothy Pearson | 1c4508e | 2015-09-05 17:50:29 -0500 | [diff] [blame] | 302 | family = model = cpuid_eax(0x80000001); |
Timothy Pearson | 730a043 | 2015-10-16 13:51:51 -0500 | [diff] [blame] | 303 | model = ((model & 0xf0000) >> 12) | ((model & 0xf0) >> 4); |
| 304 | family = ((family & 0xf00000) >> 16) | ((family & 0xf00) >> 8); |
Timothy Pearson | 1c4508e | 2015-09-05 17:50:29 -0500 | [diff] [blame] | 305 | |
Timothy Pearson | 730a043 | 2015-10-16 13:51:51 -0500 | [diff] [blame] | 306 | if (family >= 0x6f) |
| 307 | /* Family 15h or later */ |
| 308 | fam15h = 1; |
| 309 | |
| 310 | if ((model >= 0x8) || fam15h) |
| 311 | /* Family 10h Revision D or later */ |
Timothy Pearson | 1c4508e | 2015-09-05 17:50:29 -0500 | [diff] [blame] | 312 | rev_gte_d = 1; |
| 313 | |
| 314 | if (rev_gte_d) { |
| 315 | f3xe8 = pci_read_config32(NODE_PCI(0, 3), 0xe8); |
| 316 | |
| 317 | /* Check for dual node capability */ |
| 318 | if (f3xe8 & 0x20000000) |
| 319 | dual_node = 1; |
| 320 | |
| 321 | if (dual_node) { |
| 322 | /* Each G34 processor contains a defective HT link. |
Timothy Pearson | 730a043 | 2015-10-16 13:51:51 -0500 | [diff] [blame] | 323 | * See the Family 10h BKDG Rev 3.62 section 2.7.1.5 for details |
| 324 | * For Family 15h see the BKDG Rev. 3.14 section 2.12.1.5 for details. |
Timothy Pearson | 1c4508e | 2015-09-05 17:50:29 -0500 | [diff] [blame] | 325 | */ |
| 326 | uint8_t node; |
| 327 | uint8_t node_count = get_nodes(); |
| 328 | uint32_t dword; |
| 329 | for (node = 0; node < node_count; node++) { |
| 330 | f3xe8 = pci_read_config32(NODE_PCI(node, 3), 0xe8); |
| 331 | uint8_t internal_node_number = ((f3xe8 & 0xc0000000) >> 30); |
Timothy Pearson | 0122afb | 2015-07-30 14:07:15 -0500 | [diff] [blame] | 332 | printk(BIOS_DEBUG, "amd_ht_fixup(): node %d (internal node ID %d): disabling defective HT link", node, internal_node_number); |
Timothy Pearson | 1c4508e | 2015-09-05 17:50:29 -0500 | [diff] [blame] | 333 | if (internal_node_number == 0) { |
Timothy Pearson | 730a043 | 2015-10-16 13:51:51 -0500 | [diff] [blame] | 334 | uint8_t package_link_3_connected = pci_read_config32(NODE_PCI(node, 0), (fam15h)?0x98:0xd8) & 0x1; |
Timothy Pearson | 0122afb | 2015-07-30 14:07:15 -0500 | [diff] [blame] | 335 | printk(BIOS_DEBUG, " (L3 connected: %d)\n", package_link_3_connected); |
Timothy Pearson | 1c4508e | 2015-09-05 17:50:29 -0500 | [diff] [blame] | 336 | if (package_link_3_connected) { |
| 337 | /* Set WidthIn and WidthOut to 0 */ |
Timothy Pearson | 730a043 | 2015-10-16 13:51:51 -0500 | [diff] [blame] | 338 | dword = pci_read_config32(NODE_PCI(node, 0), (fam15h)?0x84:0xc4); |
Timothy Pearson | 1c4508e | 2015-09-05 17:50:29 -0500 | [diff] [blame] | 339 | dword &= ~0x77000000; |
Timothy Pearson | 730a043 | 2015-10-16 13:51:51 -0500 | [diff] [blame] | 340 | pci_write_config32(NODE_PCI(node, 0), (fam15h)?0x84:0xc4, dword); |
Timothy Pearson | 1c4508e | 2015-09-05 17:50:29 -0500 | [diff] [blame] | 341 | /* Set Ganged to 1 */ |
Timothy Pearson | 730a043 | 2015-10-16 13:51:51 -0500 | [diff] [blame] | 342 | dword = pci_read_config32(NODE_PCI(node, 0), (fam15h)?0x170:0x178); |
Timothy Pearson | 1c4508e | 2015-09-05 17:50:29 -0500 | [diff] [blame] | 343 | dword |= 0x00000001; |
Timothy Pearson | 730a043 | 2015-10-16 13:51:51 -0500 | [diff] [blame] | 344 | pci_write_config32(NODE_PCI(node, 0), (fam15h)?0x170:0x178, dword); |
Timothy Pearson | 1c4508e | 2015-09-05 17:50:29 -0500 | [diff] [blame] | 345 | } else { |
| 346 | /* Set ConnDly to 1 */ |
| 347 | dword = pci_read_config32(NODE_PCI(node, 0), 0x16c); |
| 348 | dword |= 0x00000100; |
| 349 | pci_write_config32(NODE_PCI(node, 0), 0x16c, dword); |
| 350 | /* Set TransOff and EndOfChain to 1 */ |
Timothy Pearson | 730a043 | 2015-10-16 13:51:51 -0500 | [diff] [blame] | 351 | dword = pci_read_config32(NODE_PCI(node, 4), (fam15h)?0x84:0xc4); |
Timothy Pearson | 1c4508e | 2015-09-05 17:50:29 -0500 | [diff] [blame] | 352 | dword |= 0x000000c0; |
Timothy Pearson | 730a043 | 2015-10-16 13:51:51 -0500 | [diff] [blame] | 353 | pci_write_config32(NODE_PCI(node, 4), (fam15h)?0x84:0xc4, dword); |
Timothy Pearson | 1c4508e | 2015-09-05 17:50:29 -0500 | [diff] [blame] | 354 | } |
| 355 | } else if (internal_node_number == 1) { |
Timothy Pearson | 730a043 | 2015-10-16 13:51:51 -0500 | [diff] [blame] | 356 | uint8_t package_link_3_connected = pci_read_config32(NODE_PCI(node, 0), (fam15h)?0xf8:0xb8) & 0x1; |
Timothy Pearson | 0122afb | 2015-07-30 14:07:15 -0500 | [diff] [blame] | 357 | printk(BIOS_DEBUG, " (L3 connected: %d)\n", package_link_3_connected); |
Timothy Pearson | 1c4508e | 2015-09-05 17:50:29 -0500 | [diff] [blame] | 358 | if (package_link_3_connected) { |
| 359 | /* Set WidthIn and WidthOut to 0 */ |
Timothy Pearson | 730a043 | 2015-10-16 13:51:51 -0500 | [diff] [blame] | 360 | dword = pci_read_config32(NODE_PCI(node, 0), (fam15h)?0xe4:0xa4); |
Timothy Pearson | 1c4508e | 2015-09-05 17:50:29 -0500 | [diff] [blame] | 361 | dword &= ~0x77000000; |
Timothy Pearson | 730a043 | 2015-10-16 13:51:51 -0500 | [diff] [blame] | 362 | pci_write_config32(NODE_PCI(node, 0), (fam15h)?0xe4:0xa4, dword); |
Timothy Pearson | 1c4508e | 2015-09-05 17:50:29 -0500 | [diff] [blame] | 363 | /* Set Ganged to 1 */ |
Timothy Pearson | 0122afb | 2015-07-30 14:07:15 -0500 | [diff] [blame] | 364 | /* WARNING |
| 365 | * The Family 15h BKDG states that 0x18c should be set, |
| 366 | * however this is in error. 0x17c is the correct control |
| 367 | * register (sublink 0) for these processors... |
| 368 | */ |
| 369 | dword = pci_read_config32(NODE_PCI(node, 0), (fam15h)?0x17c:0x174); |
Timothy Pearson | 1c4508e | 2015-09-05 17:50:29 -0500 | [diff] [blame] | 370 | dword |= 0x00000001; |
Timothy Pearson | 0122afb | 2015-07-30 14:07:15 -0500 | [diff] [blame] | 371 | pci_write_config32(NODE_PCI(node, 0), (fam15h)?0x17c:0x174, dword); |
Timothy Pearson | 1c4508e | 2015-09-05 17:50:29 -0500 | [diff] [blame] | 372 | } else { |
| 373 | /* Set ConnDly to 1 */ |
| 374 | dword = pci_read_config32(NODE_PCI(node, 0), 0x16c); |
| 375 | dword |= 0x00000100; |
| 376 | pci_write_config32(NODE_PCI(node, 0), 0x16c, dword); |
| 377 | /* Set TransOff and EndOfChain to 1 */ |
Timothy Pearson | 730a043 | 2015-10-16 13:51:51 -0500 | [diff] [blame] | 378 | dword = pci_read_config32(NODE_PCI(node, 4), (fam15h)?0xe4:0xa4); |
Timothy Pearson | 1c4508e | 2015-09-05 17:50:29 -0500 | [diff] [blame] | 379 | dword |= 0x000000c0; |
Timothy Pearson | 730a043 | 2015-10-16 13:51:51 -0500 | [diff] [blame] | 380 | pci_write_config32(NODE_PCI(node, 4), (fam15h)?0xe4:0xa4, dword); |
Timothy Pearson | 1c4508e | 2015-09-05 17:50:29 -0500 | [diff] [blame] | 381 | } |
| 382 | } |
| 383 | } |
| 384 | } |
| 385 | } |
| 386 | } |
Marc Jones | 8ae8c88 | 2007-12-19 01:32:08 +0000 | [diff] [blame] | 387 | } |