Angel Pons | 4b42983 | 2020-04-02 23:48:50 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 2 | |
Elyes HAOUAS | ba9b504 | 2019-12-19 07:47:52 +0100 | [diff] [blame] | 3 | #include <commonlib/helpers.h> |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 4 | #include <stdint.h> |
| 5 | #include <arch/cpu.h> |
Kyösti Mälkki | 13f6650 | 2019-03-03 08:01:05 +0200 | [diff] [blame] | 6 | #include <device/mmio.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 7 | #include <device/pci_ops.h> |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 8 | #include <device/pci_def.h> |
Patrick Rudolph | 266a1f7 | 2016-06-09 18:13:34 +0200 | [diff] [blame] | 9 | #include <device/device.h> |
Kyösti Mälkki | 1a1b04e | 2020-01-07 22:34:33 +0200 | [diff] [blame] | 10 | #include <device/smbus_host.h> |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 11 | #include <spd.h> |
| 12 | #include <console/console.h> |
| 13 | #include <lib.h> |
Arthur Heymans | 10141c3 | 2016-10-27 00:31:41 +0200 | [diff] [blame] | 14 | #include <delay.h> |
Arthur Heymans | 049347f | 2017-05-12 11:54:08 +0200 | [diff] [blame] | 15 | #include <timestamp.h> |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 16 | #include "gm45.h" |
Patrick Rudolph | 266a1f7 | 2016-06-09 18:13:34 +0200 | [diff] [blame] | 17 | #include "chip.h" |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 18 | |
| 19 | static const gmch_gfx_t gmch_gfx_types[][5] = { |
| 20 | /* MAX_667MHz MAX_533MHz MAX_400MHz MAX_333MHz MAX_800MHz */ |
| 21 | { GMCH_UNKNOWN, GMCH_UNKNOWN, GMCH_UNKNOWN, GMCH_UNKNOWN, GMCH_UNKNOWN }, |
| 22 | { GMCH_GM47, GMCH_GM45, GMCH_UNKNOWN, GMCH_UNKNOWN, GMCH_GM49 }, |
| 23 | { GMCH_GE45, GMCH_GE45, GMCH_GE45, GMCH_GE45, GMCH_GE45 }, |
| 24 | { GMCH_UNKNOWN, GMCH_GL43, GMCH_GL40, GMCH_UNKNOWN, GMCH_UNKNOWN }, |
| 25 | { GMCH_UNKNOWN, GMCH_GS45, GMCH_GS40, GMCH_UNKNOWN, GMCH_UNKNOWN }, |
| 26 | { GMCH_UNKNOWN, GMCH_UNKNOWN, GMCH_UNKNOWN, GMCH_UNKNOWN, GMCH_UNKNOWN }, |
| 27 | { GMCH_UNKNOWN, GMCH_UNKNOWN, GMCH_UNKNOWN, GMCH_UNKNOWN, GMCH_UNKNOWN }, |
| 28 | { GMCH_PM45, GMCH_PM45, GMCH_PM45, GMCH_PM45, GMCH_PM45 }, |
| 29 | }; |
| 30 | |
| 31 | void get_gmch_info(sysinfo_t *sysinfo) |
| 32 | { |
| 33 | sysinfo->stepping = pci_read_config8(PCI_DEV(0, 0, 0), PCI_CLASS_REVISION); |
| 34 | if ((sysinfo->stepping > STEPPING_B3) && |
Elyes HAOUAS | 7503cd1 | 2022-01-29 09:33:08 +0100 | [diff] [blame] | 35 | (sysinfo->stepping != STEPPING_CONVERSION_A1)) |
| 36 | die("Unknown stepping.\n"); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 37 | if (sysinfo->stepping <= STEPPING_B3) |
| 38 | printk(BIOS_DEBUG, "Stepping %c%d\n", 'A' + sysinfo->stepping / 4, sysinfo->stepping % 4); |
| 39 | else |
| 40 | printk(BIOS_DEBUG, "Conversion stepping A1\n"); |
| 41 | |
| 42 | const u32 eax = cpuid_ext(0x04, 0).eax; |
| 43 | sysinfo->cores = ((eax >> 26) & 0x3f) + 1; |
| 44 | printk(BIOS_SPEW, "%d CPU cores\n", sysinfo->cores); |
| 45 | |
| 46 | u32 capid = pci_read_config16(PCI_DEV(0, 0, 0), D0F0_CAPID0+8); |
| 47 | if (!(capid & (1<<(79-64)))) { |
| 48 | printk(BIOS_SPEW, "iTPM enabled\n"); |
| 49 | } |
| 50 | |
| 51 | capid = pci_read_config32(PCI_DEV(0, 0, 0), D0F0_CAPID0+4); |
| 52 | if (!(capid & (1<<(57-32)))) { |
| 53 | printk(BIOS_SPEW, "ME enabled\n"); |
| 54 | } |
| 55 | |
| 56 | if (!(capid & (1<<(56-32)))) { |
| 57 | printk(BIOS_SPEW, "AMT enabled\n"); |
| 58 | } |
| 59 | |
| 60 | sysinfo->max_ddr2_mhz = (capid & (1<<(53-32)))?667:800; |
| 61 | printk(BIOS_SPEW, "capable of DDR2 of %d MHz or lower\n", sysinfo->max_ddr2_mhz); |
| 62 | |
| 63 | if (!(capid & (1<<(48-32)))) { |
| 64 | printk(BIOS_SPEW, "VT-d enabled\n"); |
| 65 | } |
| 66 | |
| 67 | const u32 gfx_variant = (capid>>(42-32)) & 0x7; |
| 68 | const u32 render_freq = ((capid>>(50-32) & 0x1) << 2) | ((capid>>(35-32)) & 0x3); |
| 69 | if (render_freq <= 4) |
| 70 | sysinfo->gfx_type = gmch_gfx_types[gfx_variant][render_freq]; |
| 71 | else |
| 72 | sysinfo->gfx_type = GMCH_UNKNOWN; |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 73 | switch (sysinfo->gfx_type) { |
| 74 | case GMCH_GM45: |
| 75 | printk(BIOS_SPEW, "GMCH: GM45\n"); |
| 76 | break; |
| 77 | case GMCH_GM47: |
| 78 | printk(BIOS_SPEW, "GMCH: GM47\n"); |
| 79 | break; |
| 80 | case GMCH_GM49: |
| 81 | printk(BIOS_SPEW, "GMCH: GM49\n"); |
| 82 | break; |
| 83 | case GMCH_GE45: |
| 84 | printk(BIOS_SPEW, "GMCH: GE45\n"); |
| 85 | break; |
| 86 | case GMCH_GL40: |
| 87 | printk(BIOS_SPEW, "GMCH: GL40\n"); |
| 88 | break; |
| 89 | case GMCH_GL43: |
| 90 | printk(BIOS_SPEW, "GMCH: GL43\n"); |
| 91 | break; |
| 92 | case GMCH_GS40: |
| 93 | printk(BIOS_SPEW, "GMCH: GS40\n"); |
| 94 | break; |
| 95 | case GMCH_GS45: |
Nico Huber | 5aaeb27 | 2015-12-30 00:17:27 +0100 | [diff] [blame] | 96 | printk(BIOS_SPEW, "GMCH: GS45, using %s-power mode\n", |
| 97 | sysinfo->gs45_low_power_mode ? "low" : "high"); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 98 | break; |
| 99 | case GMCH_PM45: |
| 100 | printk(BIOS_SPEW, "GMCH: PM45\n"); |
| 101 | break; |
| 102 | case GMCH_UNKNOWN: |
| 103 | printk(BIOS_SPEW, "unknown GMCH\n"); |
| 104 | break; |
| 105 | } |
| 106 | |
| 107 | sysinfo->txt_enabled = !(capid & (1 << (37-32))); |
| 108 | if (sysinfo->txt_enabled) { |
| 109 | printk(BIOS_SPEW, "TXT enabled\n"); |
| 110 | } |
| 111 | |
| 112 | switch (render_freq) { |
| 113 | case 4: |
| 114 | sysinfo->max_render_mhz = 800; |
| 115 | break; |
| 116 | case 0: |
| 117 | sysinfo->max_render_mhz = 667; |
| 118 | break; |
| 119 | case 1: |
| 120 | sysinfo->max_render_mhz = 533; |
| 121 | break; |
| 122 | case 2: |
| 123 | sysinfo->max_render_mhz = 400; |
| 124 | break; |
| 125 | case 3: |
| 126 | sysinfo->max_render_mhz = 333; |
| 127 | break; |
| 128 | default: |
| 129 | printk(BIOS_SPEW, "Unknown render frequency\n"); |
| 130 | sysinfo->max_render_mhz = 0; |
| 131 | break; |
| 132 | } |
| 133 | if (sysinfo->max_render_mhz != 0) { |
| 134 | printk(BIOS_SPEW, "Render frequency: %d MHz\n", sysinfo->max_render_mhz); |
| 135 | } |
| 136 | |
| 137 | if (!(capid & (1<<(33-32)))) { |
| 138 | printk(BIOS_SPEW, "IGD enabled\n"); |
| 139 | } |
| 140 | |
| 141 | if (!(capid & (1<<(32-32)))) { |
| 142 | printk(BIOS_SPEW, "PCIe-to-GMCH enabled\n"); |
| 143 | } |
| 144 | |
| 145 | capid = pci_read_config32(PCI_DEV(0, 0, 0), D0F0_CAPID0); |
| 146 | |
| 147 | u32 ddr_cap = capid>>30 & 0x3; |
| 148 | switch (ddr_cap) { |
| 149 | case 0: |
| 150 | sysinfo->max_ddr3_mt = 1067; |
| 151 | break; |
| 152 | case 1: |
| 153 | sysinfo->max_ddr3_mt = 800; |
| 154 | break; |
| 155 | case 2: |
| 156 | case 3: |
| 157 | printk(BIOS_SPEW, "GMCH not DDR3 capable\n"); |
| 158 | sysinfo->max_ddr3_mt = 0; |
| 159 | break; |
| 160 | } |
| 161 | if (sysinfo->max_ddr3_mt != 0) { |
| 162 | printk(BIOS_SPEW, "GMCH supports DDR3 with %d MT or less\n", sysinfo->max_ddr3_mt); |
| 163 | } |
| 164 | |
Martin Roth | 468d02c | 2019-10-23 21:44:42 -0600 | [diff] [blame] | 165 | const unsigned int max_fsb = (capid >> 28) & 0x3; |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 166 | switch (max_fsb) { |
| 167 | case 1: |
| 168 | sysinfo->max_fsb_mhz = 1067; |
| 169 | break; |
| 170 | case 2: |
| 171 | sysinfo->max_fsb_mhz = 800; |
| 172 | break; |
| 173 | case 3: |
| 174 | sysinfo->max_fsb_mhz = 667; |
| 175 | break; |
| 176 | default: |
| 177 | die("unknown FSB capability\n"); |
| 178 | break; |
| 179 | } |
| 180 | if (sysinfo->max_fsb_mhz != 0) { |
| 181 | printk(BIOS_SPEW, "GMCH supports FSB with up to %d MHz\n", sysinfo->max_fsb_mhz); |
| 182 | } |
| 183 | sysinfo->max_fsb = max_fsb - 1; |
| 184 | } |
| 185 | |
| 186 | /* |
| 187 | * Detect if the system went through an interrupted RAM init or is incon- |
| 188 | * sistent. If so, initiate a cold reboot. Otherwise mark the system to be |
Martin Roth | 128c104 | 2016-11-18 09:29:03 -0700 | [diff] [blame] | 189 | * in RAM init, so this function would detect it on an erroneous reboot. |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 190 | */ |
| 191 | void enter_raminit_or_reset(void) |
| 192 | { |
| 193 | /* Interrupted RAM init or inconsistent system? */ |
| 194 | u8 reg8 = pci_read_config8(PCI_DEV(0, 0x1f, 0), 0xa2); |
| 195 | |
| 196 | if (reg8 & (1 << 2)) { /* S4-assertion-width violation */ |
| 197 | /* Ignore S4-assertion-width violation like original BIOS. */ |
Julius Werner | e966595 | 2022-01-21 17:06:20 -0800 | [diff] [blame] | 198 | printk(BIOS_WARNING, "Ignoring S4-assertion-width violation.\n"); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 199 | /* Bit2 is R/WC, so it will clear itself below. */ |
| 200 | } |
| 201 | |
| 202 | if (reg8 & (1 << 7)) { /* interrupted RAM init */ |
| 203 | /* Don't enable S4-assertion stretch. Makes trouble on roda/rk9. |
| 204 | reg8 = pci_read_config8(PCI_DEV(0, 0x1f, 0), 0xa4); |
| 205 | pci_write_config8(PCI_DEV(0, 0x1f, 0), 0xa4, reg8 | 0x08); |
| 206 | */ |
| 207 | |
| 208 | /* Clear bit7. */ |
| 209 | pci_write_config8(PCI_DEV(0, 0x1f, 0), 0xa2, reg8 & ~(1 << 7)); |
| 210 | |
| 211 | printk(BIOS_INFO, "Interrupted RAM init, reset required.\n"); |
| 212 | gm45_early_reset(); |
| 213 | } |
| 214 | /* Mark system to be in RAM init. */ |
| 215 | pci_write_config8(PCI_DEV(0, 0x1f, 0), 0xa2, reg8 | (1 << 7)); |
| 216 | } |
| 217 | |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 218 | /* For a detected DIMM, test the value of an SPD byte to |
| 219 | match the expected value after masking some bits. */ |
Vladimir Serbinenko | c4d8948 | 2014-06-05 09:14:48 +0200 | [diff] [blame] | 220 | static int test_dimm(sysinfo_t *const sysinfo, |
| 221 | int dimm, int addr, int bitmask, int expected) |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 222 | { |
Vladimir Serbinenko | c4d8948 | 2014-06-05 09:14:48 +0200 | [diff] [blame] | 223 | return (smbus_read_byte(sysinfo->spd_map[dimm], addr) & bitmask) == expected; |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 224 | } |
| 225 | |
| 226 | /* This function dies if dimm is unsuitable for the chipset. */ |
Vladimir Serbinenko | c4d8948 | 2014-06-05 09:14:48 +0200 | [diff] [blame] | 227 | static void verify_ddr3_dimm(sysinfo_t *const sysinfo, int dimm) |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 228 | { |
Vladimir Serbinenko | c4d8948 | 2014-06-05 09:14:48 +0200 | [diff] [blame] | 229 | if (!test_dimm(sysinfo, dimm, 3, 15, 3)) |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 230 | die("Chipset only supports SO-DIMM\n"); |
| 231 | |
Vladimir Serbinenko | c4d8948 | 2014-06-05 09:14:48 +0200 | [diff] [blame] | 232 | if (!test_dimm(sysinfo, dimm, 8, 0x18, 0)) |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 233 | die("Chipset doesn't support ECC RAM\n"); |
| 234 | |
Vladimir Serbinenko | c4d8948 | 2014-06-05 09:14:48 +0200 | [diff] [blame] | 235 | if (!test_dimm(sysinfo, dimm, 7, 0x38, 0) && |
| 236 | !test_dimm(sysinfo, dimm, 7, 0x38, 8)) |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 237 | die("Chipset wants single or double sided DIMMs\n"); |
| 238 | |
Vladimir Serbinenko | c4d8948 | 2014-06-05 09:14:48 +0200 | [diff] [blame] | 239 | if (!test_dimm(sysinfo, dimm, 7, 7, 1) && |
| 240 | !test_dimm(sysinfo, dimm, 7, 7, 2)) |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 241 | die("Chipset requires x8 or x16 width\n"); |
| 242 | |
Vladimir Serbinenko | c4d8948 | 2014-06-05 09:14:48 +0200 | [diff] [blame] | 243 | if (!test_dimm(sysinfo, dimm, 4, 0x0f, 0) && |
| 244 | !test_dimm(sysinfo, dimm, 4, 0x0f, 1) && |
| 245 | !test_dimm(sysinfo, dimm, 4, 0x0f, 2) && |
| 246 | !test_dimm(sysinfo, dimm, 4, 0x0f, 3)) |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 247 | die("Chipset requires 256Mb, 512Mb, 1Gb or 2Gb chips."); |
| 248 | |
Vladimir Serbinenko | c4d8948 | 2014-06-05 09:14:48 +0200 | [diff] [blame] | 249 | if (!test_dimm(sysinfo, dimm, 4, 0x70, 0)) |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 250 | die("Chipset requires 8 banks on DDR3\n"); |
| 251 | |
| 252 | /* How to check if burst length is 8? |
| 253 | Other values are not supported, are they even possible? */ |
| 254 | |
Vladimir Serbinenko | c4d8948 | 2014-06-05 09:14:48 +0200 | [diff] [blame] | 255 | if (!test_dimm(sysinfo, dimm, 10, 0xff, 1)) |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 256 | die("Code assumes 1/8ns MTB\n"); |
| 257 | |
Vladimir Serbinenko | c4d8948 | 2014-06-05 09:14:48 +0200 | [diff] [blame] | 258 | if (!test_dimm(sysinfo, dimm, 11, 0xff, 8)) |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 259 | die("Code assumes 1/8ns MTB\n"); |
| 260 | |
Vladimir Serbinenko | c4d8948 | 2014-06-05 09:14:48 +0200 | [diff] [blame] | 261 | if (!test_dimm(sysinfo, dimm, 62, 0x9f, 0) && |
| 262 | !test_dimm(sysinfo, dimm, 62, 0x9f, 1) && |
| 263 | !test_dimm(sysinfo, dimm, 62, 0x9f, 2) && |
| 264 | !test_dimm(sysinfo, dimm, 62, 0x9f, 3) && |
| 265 | !test_dimm(sysinfo, dimm, 62, 0x9f, 5)) |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 266 | die("Only raw card types A, B, C, D and F are supported.\n"); |
| 267 | } |
| 268 | |
| 269 | /* For every detected DIMM, test if it's suitable for the chipset. */ |
Vladimir Serbinenko | c4d8948 | 2014-06-05 09:14:48 +0200 | [diff] [blame] | 270 | static void verify_ddr3(sysinfo_t *const sysinfo, int mask) |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 271 | { |
| 272 | int cur = 0; |
| 273 | while (mask) { |
| 274 | if (mask & 1) { |
Vladimir Serbinenko | c4d8948 | 2014-06-05 09:14:48 +0200 | [diff] [blame] | 275 | verify_ddr3_dimm(sysinfo, cur); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 276 | } |
| 277 | mask >>= 1; |
| 278 | cur++; |
| 279 | } |
| 280 | } |
| 281 | |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 282 | typedef struct { |
| 283 | int dimm_mask; |
| 284 | struct { |
| 285 | unsigned int rows; |
| 286 | unsigned int cols; |
| 287 | unsigned int chip_capacity; |
| 288 | unsigned int banks; |
| 289 | unsigned int ranks; |
| 290 | unsigned int cas_latencies; |
| 291 | unsigned int tAAmin; |
| 292 | unsigned int tCKmin; |
| 293 | unsigned int width; |
| 294 | unsigned int tRAS; |
| 295 | unsigned int tRP; |
| 296 | unsigned int tRCD; |
| 297 | unsigned int tWR; |
| 298 | unsigned int page_size; |
| 299 | unsigned int raw_card; |
| 300 | } channel[2]; |
| 301 | } spdinfo_t; |
| 302 | /* |
| 303 | * This function collects RAM characteristics from SPD, assuming that RAM |
| 304 | * is generally within chipset's requirements, since verify_ddr3() passed. |
| 305 | */ |
Vladimir Serbinenko | c4d8948 | 2014-06-05 09:14:48 +0200 | [diff] [blame] | 306 | static void collect_ddr3(sysinfo_t *const sysinfo, spdinfo_t *const config) |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 307 | { |
| 308 | int mask = config->dimm_mask; |
| 309 | int cur = 0; |
| 310 | while (mask != 0) { |
Vladimir Serbinenko | c4d8948 | 2014-06-05 09:14:48 +0200 | [diff] [blame] | 311 | /* FIXME: support several dimms on same channel. */ |
| 312 | if ((mask & 1) && sysinfo->spd_map[2 * cur]) { |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 313 | int tmp; |
Vladimir Serbinenko | c4d8948 | 2014-06-05 09:14:48 +0200 | [diff] [blame] | 314 | const int smb_addr = sysinfo->spd_map[2 * cur]; |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 315 | |
| 316 | config->channel[cur].rows = ((smbus_read_byte(smb_addr, 5) >> 3) & 7) + 12; |
| 317 | config->channel[cur].cols = (smbus_read_byte(smb_addr, 5) & 7) + 9; |
| 318 | |
| 319 | config->channel[cur].chip_capacity = smbus_read_byte(smb_addr, 4) & 0xf; |
| 320 | |
| 321 | config->channel[cur].banks = 8; /* GM45 only accepts this for DDR3. |
| 322 | verify_ddr3() fails for other values. */ |
| 323 | config->channel[cur].ranks = ((smbus_read_byte(smb_addr, 7) >> 3) & 7) + 1; |
| 324 | |
| 325 | config->channel[cur].cas_latencies = |
| 326 | ((smbus_read_byte(smb_addr, 15) << 8) | smbus_read_byte(smb_addr, 14)) |
| 327 | << 4; /* so bit x is CAS x */ |
| 328 | config->channel[cur].tAAmin = smbus_read_byte(smb_addr, 16); /* in MTB */ |
| 329 | config->channel[cur].tCKmin = smbus_read_byte(smb_addr, 12); /* in MTB */ |
| 330 | |
| 331 | config->channel[cur].width = smbus_read_byte(smb_addr, 7) & 7; |
| 332 | config->channel[cur].page_size = config->channel[cur].width * |
| 333 | (1 << config->channel[cur].cols); /* in Bytes */ |
| 334 | |
| 335 | tmp = smbus_read_byte(smb_addr, 21); |
| 336 | config->channel[cur].tRAS = smbus_read_byte(smb_addr, 22) | ((tmp & 0xf) << 8); |
| 337 | config->channel[cur].tRP = smbus_read_byte(smb_addr, 20); |
| 338 | config->channel[cur].tRCD = smbus_read_byte(smb_addr, 18); |
| 339 | config->channel[cur].tWR = smbus_read_byte(smb_addr, 17); |
| 340 | |
| 341 | config->channel[cur].raw_card = smbus_read_byte(smb_addr, 62) & 0x1f; |
| 342 | } |
| 343 | cur++; |
Vladimir Serbinenko | c4d8948 | 2014-06-05 09:14:48 +0200 | [diff] [blame] | 344 | mask >>= 2; |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 345 | } |
| 346 | } |
| 347 | |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 348 | static fsb_clock_t read_fsb_clock(void) |
| 349 | { |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 350 | switch (mchbar_read32(CLKCFG_MCHBAR) & CLKCFG_FSBCLK_MASK) { |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 351 | case 6: |
| 352 | return FSB_CLOCK_1067MHz; |
| 353 | case 2: |
| 354 | return FSB_CLOCK_800MHz; |
| 355 | case 3: |
| 356 | return FSB_CLOCK_667MHz; |
| 357 | default: |
| 358 | die("Unsupported FSB clock.\n"); |
| 359 | } |
| 360 | } |
| 361 | static mem_clock_t clock_index(const unsigned int clock) |
| 362 | { |
| 363 | switch (clock) { |
| 364 | case 533: return MEM_CLOCK_533MHz; |
| 365 | case 400: return MEM_CLOCK_400MHz; |
| 366 | case 333: return MEM_CLOCK_333MHz; |
| 367 | default: die("Unknown clock value.\n"); |
| 368 | } |
| 369 | return -1; /* Won't be reached. */ |
| 370 | } |
| 371 | static void normalize_clock(unsigned int *const clock) |
| 372 | { |
| 373 | if (*clock >= 533) |
| 374 | *clock = 533; |
| 375 | else if (*clock >= 400) |
| 376 | *clock = 400; |
| 377 | else if (*clock >= 333) |
| 378 | *clock = 333; |
| 379 | else |
| 380 | *clock = 0; |
| 381 | } |
| 382 | static void lower_clock(unsigned int *const clock) |
| 383 | { |
| 384 | --*clock; |
| 385 | normalize_clock(clock); |
| 386 | } |
| 387 | static unsigned int find_common_clock_cas(sysinfo_t *const sysinfo, |
| 388 | const spdinfo_t *const spdinfo) |
| 389 | { |
| 390 | /* various constraints must be fulfilled: |
| 391 | CAS * tCK < 20ns == 160MTB |
| 392 | tCK_max >= tCK >= tCK_min |
| 393 | CAS >= roundup(tAA_min/tCK) |
| 394 | CAS supported |
| 395 | Clock(MHz) = 1000 / tCK(ns) |
| 396 | Clock(MHz) = 8000 / tCK(MTB) |
| 397 | AND BTW: Clock(MT) = 2000 / tCK(ns) - intel uses MTs but calls them MHz |
| 398 | */ |
| 399 | int i; |
| 400 | |
| 401 | /* Calculate common cas_latencies mask, tCKmin and tAAmin. */ |
| 402 | unsigned int cas_latencies = (unsigned int)-1; |
| 403 | unsigned int tCKmin = 0, tAAmin = 0; |
| 404 | FOR_EACH_POPULATED_CHANNEL(sysinfo->dimms, i) { |
| 405 | cas_latencies &= spdinfo->channel[i].cas_latencies; |
| 406 | if (spdinfo->channel[i].tCKmin > tCKmin) |
| 407 | tCKmin = spdinfo->channel[i].tCKmin; |
| 408 | if (spdinfo->channel[i].tAAmin > tAAmin) |
| 409 | tAAmin = spdinfo->channel[i].tAAmin; |
| 410 | } |
| 411 | |
| 412 | /* Get actual value of fsb clock. */ |
| 413 | sysinfo->selected_timings.fsb_clock = read_fsb_clock(); |
| 414 | unsigned int fsb_mhz = 0; |
| 415 | switch (sysinfo->selected_timings.fsb_clock) { |
| 416 | case FSB_CLOCK_1067MHz: fsb_mhz = 1067; break; |
| 417 | case FSB_CLOCK_800MHz: fsb_mhz = 800; break; |
| 418 | case FSB_CLOCK_667MHz: fsb_mhz = 667; break; |
| 419 | } |
| 420 | |
| 421 | unsigned int clock = 8000 / tCKmin; |
| 422 | if ((clock > sysinfo->max_ddr3_mt / 2) || (clock > fsb_mhz / 2)) { |
Elyes HAOUAS | ba9b504 | 2019-12-19 07:47:52 +0100 | [diff] [blame] | 423 | int new_clock = MIN(sysinfo->max_ddr3_mt / 2, fsb_mhz / 2); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 424 | printk(BIOS_SPEW, "DIMMs support %d MHz, but chipset only runs at up to %d. Limiting...\n", |
| 425 | clock, new_clock); |
| 426 | clock = new_clock; |
| 427 | } |
| 428 | normalize_clock(&clock); |
| 429 | |
| 430 | /* Find compatible clock / CAS pair. */ |
| 431 | unsigned int tCKproposed; |
| 432 | unsigned int CAS; |
| 433 | while (1) { |
| 434 | if (!clock) |
| 435 | die("Couldn't find compatible clock / CAS settings.\n"); |
| 436 | tCKproposed = 8000 / clock; |
Elyes HAOUAS | 6df3b64 | 2018-11-26 22:53:49 +0100 | [diff] [blame] | 437 | CAS = DIV_ROUND_UP(tAAmin, tCKproposed); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 438 | printk(BIOS_SPEW, "Trying CAS %u, tCK %u.\n", CAS, tCKproposed); |
| 439 | for (; CAS <= DDR3_MAX_CAS; ++CAS) |
| 440 | if (cas_latencies & (1 << CAS)) |
| 441 | break; |
| 442 | if ((CAS <= DDR3_MAX_CAS) && (CAS * tCKproposed < 160)) { |
| 443 | /* Found good CAS. */ |
| 444 | printk(BIOS_SPEW, "Found compatible clock / CAS pair: %u / %u.\n", clock, CAS); |
| 445 | break; |
| 446 | } |
| 447 | lower_clock(&clock); |
| 448 | } |
| 449 | sysinfo->selected_timings.CAS = CAS; |
| 450 | sysinfo->selected_timings.mem_clock = clock_index(clock); |
| 451 | |
| 452 | return tCKproposed; |
| 453 | } |
| 454 | |
| 455 | static void calculate_derived_timings(sysinfo_t *const sysinfo, |
| 456 | const unsigned int tCLK, |
| 457 | const spdinfo_t *const spdinfo) |
| 458 | { |
| 459 | int i; |
| 460 | |
| 461 | /* Calculate common tRASmin, tRPmin, tRCDmin and tWRmin. */ |
| 462 | unsigned int tRASmin = 0, tRPmin = 0, tRCDmin = 0, tWRmin = 0; |
| 463 | FOR_EACH_POPULATED_CHANNEL(sysinfo->dimms, i) { |
| 464 | if (spdinfo->channel[i].tRAS > tRASmin) |
| 465 | tRASmin = spdinfo->channel[i].tRAS; |
| 466 | if (spdinfo->channel[i].tRP > tRPmin) |
| 467 | tRPmin = spdinfo->channel[i].tRP; |
| 468 | if (spdinfo->channel[i].tRCD > tRCDmin) |
| 469 | tRCDmin = spdinfo->channel[i].tRCD; |
| 470 | if (spdinfo->channel[i].tWR > tWRmin) |
| 471 | tWRmin = spdinfo->channel[i].tWR; |
| 472 | } |
Elyes HAOUAS | 6df3b64 | 2018-11-26 22:53:49 +0100 | [diff] [blame] | 473 | tRASmin = DIV_ROUND_UP(tRASmin, tCLK); |
| 474 | tRPmin = DIV_ROUND_UP(tRPmin, tCLK); |
| 475 | tRCDmin = DIV_ROUND_UP(tRCDmin, tCLK); |
| 476 | tWRmin = DIV_ROUND_UP(tWRmin, tCLK); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 477 | |
| 478 | /* Lookup tRFC and calculate common tRFCmin. */ |
| 479 | const unsigned int tRFC_from_clock_and_cap[][4] = { |
| 480 | /* CAP_256M CAP_512M CAP_1G CAP_2G */ |
| 481 | /* 533MHz */ { 40, 56, 68, 104 }, |
| 482 | /* 400MHz */ { 30, 42, 51, 78 }, |
| 483 | /* 333MHz */ { 25, 35, 43, 65 }, |
| 484 | }; |
| 485 | unsigned int tRFCmin = 0; |
| 486 | FOR_EACH_POPULATED_CHANNEL(sysinfo->dimms, i) { |
| 487 | const unsigned int tRFC = tRFC_from_clock_and_cap |
| 488 | [sysinfo->selected_timings.mem_clock][spdinfo->channel[i].chip_capacity]; |
| 489 | if (tRFC > tRFCmin) |
| 490 | tRFCmin = tRFC; |
| 491 | } |
| 492 | |
| 493 | /* Calculate common tRD from CAS and FSB and DRAM clocks. */ |
| 494 | unsigned int tRDmin = sysinfo->selected_timings.CAS; |
| 495 | switch (sysinfo->selected_timings.fsb_clock) { |
| 496 | case FSB_CLOCK_667MHz: |
| 497 | tRDmin += 1; |
| 498 | break; |
| 499 | case FSB_CLOCK_800MHz: |
| 500 | tRDmin += 2; |
| 501 | break; |
| 502 | case FSB_CLOCK_1067MHz: |
| 503 | tRDmin += 3; |
| 504 | if (sysinfo->selected_timings.mem_clock == MEM_CLOCK_1067MT) |
| 505 | tRDmin += 1; |
| 506 | break; |
| 507 | } |
| 508 | |
| 509 | /* Calculate common tRRDmin. */ |
| 510 | unsigned int tRRDmin = 0; |
| 511 | FOR_EACH_POPULATED_CHANNEL(sysinfo->dimms, i) { |
| 512 | unsigned int tRRD = 2 + (spdinfo->channel[i].page_size / 1024); |
| 513 | if (sysinfo->selected_timings.mem_clock == MEM_CLOCK_1067MT) |
| 514 | tRRD += (spdinfo->channel[i].page_size / 1024); |
| 515 | if (tRRD > tRRDmin) |
| 516 | tRRDmin = tRRD; |
| 517 | } |
| 518 | |
| 519 | /* Lookup and calculate common tFAWmin. */ |
| 520 | unsigned int tFAW_from_pagesize_and_clock[][3] = { |
| 521 | /* 533MHz 400MHz 333MHz */ |
| 522 | /* 1K */ { 20, 15, 13 }, |
| 523 | /* 2K */ { 27, 20, 17 }, |
| 524 | }; |
| 525 | unsigned int tFAWmin = 0; |
| 526 | FOR_EACH_POPULATED_CHANNEL(sysinfo->dimms, i) { |
| 527 | const unsigned int tFAW = tFAW_from_pagesize_and_clock |
| 528 | [spdinfo->channel[i].page_size / 1024 - 1] |
| 529 | [sysinfo->selected_timings.mem_clock]; |
| 530 | if (tFAW > tFAWmin) |
| 531 | tFAWmin = tFAW; |
| 532 | } |
| 533 | |
| 534 | /* Refresh rate is fixed. */ |
| 535 | unsigned int tWL; |
| 536 | if (sysinfo->selected_timings.mem_clock == MEM_CLOCK_1067MT) { |
| 537 | tWL = 6; |
| 538 | } else { |
| 539 | tWL = 5; |
| 540 | } |
| 541 | |
| 542 | printk(BIOS_SPEW, "Timing values:\n" |
| 543 | " tCLK: %3u\n" |
| 544 | " tRAS: %3u\n" |
| 545 | " tRP: %3u\n" |
| 546 | " tRCD: %3u\n" |
| 547 | " tRFC: %3u\n" |
| 548 | " tWR: %3u\n" |
| 549 | " tRD: %3u\n" |
| 550 | " tRRD: %3u\n" |
| 551 | " tFAW: %3u\n" |
| 552 | " tWL: %3u\n", |
| 553 | tCLK, tRASmin, tRPmin, tRCDmin, tRFCmin, tWRmin, tRDmin, tRRDmin, tFAWmin, tWL); |
| 554 | |
| 555 | sysinfo->selected_timings.tRAS = tRASmin; |
| 556 | sysinfo->selected_timings.tRP = tRPmin; |
| 557 | sysinfo->selected_timings.tRCD = tRCDmin; |
| 558 | sysinfo->selected_timings.tRFC = tRFCmin; |
| 559 | sysinfo->selected_timings.tWR = tWRmin; |
| 560 | sysinfo->selected_timings.tRD = tRDmin; |
| 561 | sysinfo->selected_timings.tRRD = tRRDmin; |
| 562 | sysinfo->selected_timings.tFAW = tFAWmin; |
| 563 | sysinfo->selected_timings.tWL = tWL; |
| 564 | } |
| 565 | |
| 566 | static void collect_dimm_config(sysinfo_t *const sysinfo) |
| 567 | { |
| 568 | int i; |
| 569 | spdinfo_t spdinfo; |
| 570 | |
| 571 | spdinfo.dimm_mask = 0; |
| 572 | sysinfo->spd_type = 0; |
| 573 | |
Vladimir Serbinenko | c4d8948 | 2014-06-05 09:14:48 +0200 | [diff] [blame] | 574 | for (i = 0; i < 4; i++) |
| 575 | if (sysinfo->spd_map[i]) { |
| 576 | const u8 spd = smbus_read_byte(sysinfo->spd_map[i], 2); |
| 577 | printk (BIOS_DEBUG, "%x:%x:%x\n", |
| 578 | i, sysinfo->spd_map[i], |
| 579 | spd); |
| 580 | if ((spd == 7) || (spd == 8) || (spd == 0xb)) { |
| 581 | spdinfo.dimm_mask |= 1 << i; |
| 582 | if (sysinfo->spd_type && sysinfo->spd_type != spd) { |
| 583 | die("Multiple types of DIMM installed in the system, don't do that!\n"); |
| 584 | } |
| 585 | sysinfo->spd_type = spd; |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 586 | } |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 587 | } |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 588 | if (spdinfo.dimm_mask == 0) { |
| 589 | die("Could not find any DIMM.\n"); |
| 590 | } |
| 591 | |
| 592 | /* Normalize spd_type to 1, 2, 3. */ |
| 593 | sysinfo->spd_type = (sysinfo->spd_type & 1) | ((sysinfo->spd_type & 8) >> 2); |
| 594 | printk(BIOS_SPEW, "DDR mask %x, DDR %d\n", spdinfo.dimm_mask, sysinfo->spd_type); |
| 595 | |
| 596 | if (sysinfo->spd_type == DDR2) { |
| 597 | die("DDR2 not supported at this time.\n"); |
| 598 | } else if (sysinfo->spd_type == DDR3) { |
Vladimir Serbinenko | c4d8948 | 2014-06-05 09:14:48 +0200 | [diff] [blame] | 599 | verify_ddr3(sysinfo, spdinfo.dimm_mask); |
| 600 | collect_ddr3(sysinfo, &spdinfo); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 601 | } else { |
| 602 | die("Will never support DDR1.\n"); |
| 603 | } |
| 604 | |
| 605 | for (i = 0; i < 2; i++) { |
| 606 | if ((spdinfo.dimm_mask >> (i*2)) & 1) { |
| 607 | printk(BIOS_SPEW, "Bank %d populated:\n" |
| 608 | " Raw card type: %4c\n" |
| 609 | " Row addr bits: %4u\n" |
| 610 | " Col addr bits: %4u\n" |
| 611 | " byte width: %4u\n" |
| 612 | " page size: %4u\n" |
| 613 | " banks: %4u\n" |
| 614 | " ranks: %4u\n" |
| 615 | " tAAmin: %3u\n" |
| 616 | " tCKmin: %3u\n" |
| 617 | " Max clock: %3u MHz\n" |
| 618 | " CAS: 0x%04x\n", |
| 619 | i, spdinfo.channel[i].raw_card + 'A', |
| 620 | spdinfo.channel[i].rows, spdinfo.channel[i].cols, |
| 621 | spdinfo.channel[i].width, spdinfo.channel[i].page_size, |
| 622 | spdinfo.channel[i].banks, spdinfo.channel[i].ranks, |
| 623 | spdinfo.channel[i].tAAmin, spdinfo.channel[i].tCKmin, |
| 624 | 8000 / spdinfo.channel[i].tCKmin, spdinfo.channel[i].cas_latencies); |
| 625 | } |
| 626 | } |
| 627 | |
| 628 | FOR_EACH_CHANNEL(i) { |
| 629 | sysinfo->dimms[i].card_type = |
| 630 | (spdinfo.dimm_mask & (1 << (i * 2))) ? spdinfo.channel[i].raw_card + 0xa : 0; |
| 631 | } |
| 632 | |
| 633 | /* Find common memory clock and CAS. */ |
| 634 | const unsigned int tCLK = find_common_clock_cas(sysinfo, &spdinfo); |
| 635 | |
| 636 | /* Calculate other timings from clock and CAS. */ |
| 637 | calculate_derived_timings(sysinfo, tCLK, &spdinfo); |
| 638 | |
| 639 | /* Initialize DIMM infos. */ |
| 640 | /* Always prefer interleaved over async channel mode. */ |
| 641 | FOR_EACH_CHANNEL(i) { |
| 642 | IF_CHANNEL_POPULATED(sysinfo->dimms, i) { |
| 643 | sysinfo->dimms[i].banks = spdinfo.channel[i].banks; |
| 644 | sysinfo->dimms[i].ranks = spdinfo.channel[i].ranks; |
| 645 | |
| 646 | /* .width is 1 for x8 or 2 for x16, bus width is 8 bytes. */ |
| 647 | const unsigned int chips_per_rank = 8 / spdinfo.channel[i].width; |
| 648 | |
| 649 | sysinfo->dimms[i].chip_width = spdinfo.channel[i].width; |
| 650 | sysinfo->dimms[i].chip_capacity = spdinfo.channel[i].chip_capacity; |
| 651 | sysinfo->dimms[i].page_size = spdinfo.channel[i].page_size * chips_per_rank; |
| 652 | sysinfo->dimms[i].rank_capacity_mb = |
| 653 | /* offset of chip_capacity is 8 (256M), therefore, add 8 |
| 654 | chip_capacity is in Mbit, we want MByte, therefore, subtract 3 */ |
| 655 | (1 << (spdinfo.channel[i].chip_capacity + 8 - 3)) * chips_per_rank; |
| 656 | } |
| 657 | } |
| 658 | if (CHANNEL_IS_POPULATED(sysinfo->dimms, 0) && |
| 659 | CHANNEL_IS_POPULATED(sysinfo->dimms, 1)) |
| 660 | sysinfo->selected_timings.channel_mode = CHANNEL_MODE_DUAL_INTERLEAVED; |
| 661 | else |
| 662 | sysinfo->selected_timings.channel_mode = CHANNEL_MODE_SINGLE; |
| 663 | } |
| 664 | |
| 665 | static void reset_on_bad_warmboot(void) |
| 666 | { |
| 667 | /* Check self refresh channel status. */ |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 668 | const u32 reg = mchbar_read32(PMSTS_MCHBAR); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 669 | /* Clear status bits. R/WC */ |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 670 | mchbar_write32(PMSTS_MCHBAR, reg); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 671 | if ((reg & PMSTS_WARM_RESET) && !(reg & PMSTS_BOTH_SELFREFRESH)) { |
| 672 | printk(BIOS_INFO, "DRAM was not in self refresh " |
| 673 | "during warm boot, reset required.\n"); |
| 674 | gm45_early_reset(); |
| 675 | } |
| 676 | } |
| 677 | |
| 678 | static void set_system_memory_frequency(const timings_t *const timings) |
| 679 | { |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 680 | mchbar_clrbits16(CLKCFG_MCHBAR + 0x60, 1 << 15); |
| 681 | mchbar_clrbits16(CLKCFG_MCHBAR + 0x48, 1 << 15); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 682 | |
| 683 | /* Calculate wanted frequency setting. */ |
| 684 | const int want_freq = 6 - timings->mem_clock; |
| 685 | |
| 686 | /* Read current memory frequency. */ |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 687 | const u32 clkcfg = mchbar_read32(CLKCFG_MCHBAR); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 688 | int cur_freq = (clkcfg & CLKCFG_MEMCLK_MASK) >> CLKCFG_MEMCLK_SHIFT; |
| 689 | if (0 == cur_freq) { |
| 690 | /* Try memory frequency from scratchpad. */ |
| 691 | printk(BIOS_DEBUG, "Reading current memory frequency from scratchpad.\n"); |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 692 | cur_freq = (mchbar_read16(SSKPD_MCHBAR) & SSKPD_CLK_MASK) >> SSKPD_CLK_SHIFT; |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 693 | } |
| 694 | |
| 695 | if (cur_freq != want_freq) { |
| 696 | printk(BIOS_DEBUG, "Changing memory frequency: old %x, new %x.\n", cur_freq, want_freq); |
| 697 | /* When writing new frequency setting, reset, then set update bit. */ |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 698 | mchbar_clrsetbits32(CLKCFG_MCHBAR, CLKCFG_UPDATE | CLKCFG_MEMCLK_MASK, |
| 699 | want_freq << CLKCFG_MEMCLK_SHIFT); |
| 700 | mchbar_clrsetbits32(CLKCFG_MCHBAR, CLKCFG_MEMCLK_MASK, |
| 701 | want_freq << CLKCFG_MEMCLK_SHIFT | CLKCFG_UPDATE); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 702 | /* Reset update bit. */ |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 703 | mchbar_clrbits32(CLKCFG_MCHBAR, CLKCFG_UPDATE); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 704 | } |
| 705 | |
| 706 | if ((timings->fsb_clock == FSB_CLOCK_1067MHz) && (timings->mem_clock == MEM_CLOCK_667MT)) { |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 707 | mchbar_write32(CLKCFG_MCHBAR + 0x16, 0x000030f0); |
| 708 | mchbar_write32(CLKCFG_MCHBAR + 0x64, 0x000050c1); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 709 | |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 710 | mchbar_clrsetbits32(CLKCFG_MCHBAR, 1 << 12, 1 << 17); |
| 711 | mchbar_setbits32(CLKCFG_MCHBAR, 1 << 17 | 1 << 12); |
| 712 | mchbar_clrbits32(CLKCFG_MCHBAR, 1 << 12); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 713 | |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 714 | mchbar_write32(CLKCFG_MCHBAR + 0x04, 0x9bad1f1f); |
| 715 | mchbar_write8(CLKCFG_MCHBAR + 0x08, 0xf4); |
| 716 | mchbar_write8(CLKCFG_MCHBAR + 0x0a, 0x43); |
| 717 | mchbar_write8(CLKCFG_MCHBAR + 0x0c, 0x10); |
| 718 | mchbar_write8(CLKCFG_MCHBAR + 0x0d, 0x80); |
| 719 | mchbar_write32(CLKCFG_MCHBAR + 0x50, 0x0b0e151b); |
| 720 | mchbar_write8(CLKCFG_MCHBAR + 0x54, 0xb4); |
| 721 | mchbar_write8(CLKCFG_MCHBAR + 0x55, 0x10); |
| 722 | mchbar_write8(CLKCFG_MCHBAR + 0x56, 0x08); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 723 | |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 724 | mchbar_setbits32(CLKCFG_MCHBAR, 1 << 10); |
| 725 | mchbar_setbits32(CLKCFG_MCHBAR, 1 << 11); |
| 726 | mchbar_clrbits32(CLKCFG_MCHBAR, 1 << 10); |
| 727 | mchbar_clrbits32(CLKCFG_MCHBAR, 1 << 11); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 728 | } |
| 729 | |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 730 | mchbar_setbits32(CLKCFG_MCHBAR + 0x48, 0x3f << 24); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 731 | } |
| 732 | |
| 733 | int raminit_read_vco_index(void) |
| 734 | { |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 735 | switch (mchbar_read8(HPLLVCO_MCHBAR) & 0x7) { |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 736 | case VCO_2666: |
| 737 | return 0; |
| 738 | case VCO_3200: |
| 739 | return 1; |
| 740 | case VCO_4000: |
| 741 | return 2; |
| 742 | case VCO_5333: |
| 743 | return 3; |
| 744 | default: |
| 745 | die("Unknown VCO frequency.\n"); |
| 746 | return 0; |
| 747 | } |
| 748 | } |
| 749 | static void set_igd_memory_frequencies(const sysinfo_t *const sysinfo) |
| 750 | { |
| 751 | const int gfx_idx = ((sysinfo->gfx_type == GMCH_GS45) && |
| 752 | !sysinfo->gs45_low_power_mode) |
| 753 | ? (GMCH_GS45 + 1) : sysinfo->gfx_type; |
| 754 | |
| 755 | /* Render and sampler frequency values seem to be some kind of factor. */ |
| 756 | const u16 render_freq_from_vco_and_gfxtype[][10] = { |
| 757 | /* GM45 GM47 GM49 GE45 GL40 GL43 GS40 GS45 (perf) */ |
| 758 | /* VCO 2666 */ { 0xd, 0xd, 0xe, 0xd, 0xb, 0xd, 0xb, 0xa, 0xd }, |
| 759 | /* VCO 3200 */ { 0xd, 0xe, 0xf, 0xd, 0xb, 0xd, 0xb, 0x9, 0xd }, |
| 760 | /* VCO 4000 */ { 0xc, 0xd, 0xf, 0xc, 0xa, 0xc, 0xa, 0x9, 0xc }, |
| 761 | /* VCO 5333 */ { 0xb, 0xc, 0xe, 0xb, 0x9, 0xb, 0x9, 0x8, 0xb }, |
| 762 | }; |
| 763 | const u16 sampler_freq_from_vco_and_gfxtype[][10] = { |
| 764 | /* GM45 GM47 GM49 GE45 GL40 GL43 GS40 GS45 (perf) */ |
| 765 | /* VCO 2666 */ { 0xc, 0xc, 0xd, 0xc, 0x9, 0xc, 0x9, 0x8, 0xc }, |
| 766 | /* VCO 3200 */ { 0xc, 0xd, 0xe, 0xc, 0x9, 0xc, 0x9, 0x8, 0xc }, |
| 767 | /* VCO 4000 */ { 0xa, 0xc, 0xd, 0xa, 0x8, 0xa, 0x8, 0x8, 0xa }, |
| 768 | /* VCO 5333 */ { 0xa, 0xa, 0xc, 0xa, 0x7, 0xa, 0x7, 0x6, 0xa }, |
| 769 | }; |
| 770 | const u16 display_clock_select_from_gfxtype[] = { |
| 771 | /* GM45 GM47 GM49 GE45 GL40 GL43 GS40 GS45 (perf) */ |
| 772 | 1, 1, 1, 1, 1, 1, 1, 0, 1 |
| 773 | }; |
| 774 | |
| 775 | if (pci_read_config16(GCFGC_PCIDEV, 0) != 0x8086) { |
| 776 | printk(BIOS_DEBUG, "Skipping IGD memory frequency setting.\n"); |
| 777 | return; |
| 778 | } |
| 779 | |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 780 | mchbar_write16(0x119e, 0xa800); |
| 781 | mchbar_clrsetbits16(0x11c0, 0xff << 8, 0x01 << 8); |
| 782 | mchbar_write16(0x119e, 0xb800); |
| 783 | mchbar_setbits8(0x0f10, 1 << 7); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 784 | |
| 785 | /* Read VCO. */ |
| 786 | const int vco_idx = raminit_read_vco_index(); |
| 787 | printk(BIOS_DEBUG, "Setting IGD memory frequencies for VCO #%d.\n", vco_idx); |
| 788 | |
| 789 | const u32 freqcfg = |
| 790 | ((render_freq_from_vco_and_gfxtype[vco_idx][gfx_idx] |
| 791 | << GCFGC_CR_SHIFT) & GCFGC_CR_MASK) | |
| 792 | ((sampler_freq_from_vco_and_gfxtype[vco_idx][gfx_idx] |
| 793 | << GCFGC_CS_SHIFT) & GCFGC_CS_MASK); |
| 794 | |
| 795 | /* Set frequencies, clear update bit. */ |
| 796 | u32 gcfgc = pci_read_config16(GCFGC_PCIDEV, GCFGC_OFFSET); |
| 797 | gcfgc &= ~(GCFGC_CS_MASK | GCFGC_UPDATE | GCFGC_CR_MASK); |
| 798 | gcfgc |= freqcfg; |
| 799 | pci_write_config16(GCFGC_PCIDEV, GCFGC_OFFSET, gcfgc); |
| 800 | |
| 801 | /* Set frequencies, set update bit. */ |
| 802 | gcfgc = pci_read_config16(GCFGC_PCIDEV, GCFGC_OFFSET); |
| 803 | gcfgc &= ~(GCFGC_CS_MASK | GCFGC_CR_MASK); |
| 804 | gcfgc |= freqcfg | GCFGC_UPDATE; |
| 805 | pci_write_config16(GCFGC_PCIDEV, GCFGC_OFFSET, gcfgc); |
| 806 | |
| 807 | /* Clear update bit. */ |
Angel Pons | b053583 | 2020-06-08 11:46:58 +0200 | [diff] [blame] | 808 | pci_and_config16(GCFGC_PCIDEV, GCFGC_OFFSET, ~GCFGC_UPDATE); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 809 | |
| 810 | /* Set display clock select bit. */ |
| 811 | pci_write_config16(GCFGC_PCIDEV, GCFGC_OFFSET, |
| 812 | (pci_read_config16(GCFGC_PCIDEV, GCFGC_OFFSET) & ~GCFGC_CD_MASK) | |
| 813 | (display_clock_select_from_gfxtype[gfx_idx] << GCFGC_CD_SHIFT)); |
| 814 | } |
| 815 | |
| 816 | static void configure_dram_control_mode(const timings_t *const timings, const dimminfo_t *const dimms) |
| 817 | { |
| 818 | int ch, r; |
| 819 | |
| 820 | FOR_EACH_CHANNEL(ch) { |
| 821 | unsigned int mchbar = CxDRC0_MCHBAR(ch); |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 822 | u32 cxdrc = mchbar_read32(mchbar); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 823 | cxdrc &= ~CxDRC0_RANKEN_MASK; |
| 824 | FOR_EACH_POPULATED_RANK_IN_CHANNEL(dimms, ch, r) |
| 825 | cxdrc |= CxDRC0_RANKEN(r); |
| 826 | cxdrc = (cxdrc & ~CxDRC0_RMS_MASK) | |
| 827 | /* Always 7.8us for DDR3: */ |
| 828 | CxDRC0_RMS_78US; |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 829 | mchbar_write32(mchbar, cxdrc); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 830 | |
| 831 | mchbar = CxDRC1_MCHBAR(ch); |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 832 | cxdrc = mchbar_read32(mchbar); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 833 | cxdrc |= CxDRC1_NOTPOP_MASK; |
| 834 | FOR_EACH_POPULATED_RANK_IN_CHANNEL(dimms, ch, r) |
| 835 | cxdrc &= ~CxDRC1_NOTPOP(r); |
| 836 | cxdrc |= CxDRC1_MUSTWR; |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 837 | mchbar_write32(mchbar, cxdrc); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 838 | |
| 839 | mchbar = CxDRC2_MCHBAR(ch); |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 840 | cxdrc = mchbar_read32(mchbar); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 841 | cxdrc |= CxDRC2_NOTPOP_MASK; |
| 842 | FOR_EACH_POPULATED_RANK_IN_CHANNEL(dimms, ch, r) |
| 843 | cxdrc &= ~CxDRC2_NOTPOP(r); |
| 844 | cxdrc |= CxDRC2_MUSTWR; |
| 845 | if (timings->mem_clock == MEM_CLOCK_1067MT) |
| 846 | cxdrc |= CxDRC2_CLK1067MT; |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 847 | mchbar_write32(mchbar, cxdrc); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 848 | } |
| 849 | } |
| 850 | |
| 851 | static void rcomp_initialization(const stepping_t stepping, const int sff) |
| 852 | { |
Elyes HAOUAS | 3d45000 | 2018-08-09 18:55:58 +0200 | [diff] [blame] | 853 | /* Program RCOMP codes. */ |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 854 | if (sff) |
| 855 | die("SFF platform unsupported in RCOMP initialization.\n"); |
| 856 | /* Values are for DDR3. */ |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 857 | mchbar_clrbits8(0x6ac, 0x0f); |
| 858 | mchbar_write8(0x6b0, 0x55); |
| 859 | mchbar_clrbits8(0x6ec, 0x0f); |
| 860 | mchbar_write8(0x6f0, 0x66); |
| 861 | mchbar_clrbits8(0x72c, 0x0f); |
| 862 | mchbar_write8(0x730, 0x66); |
| 863 | mchbar_clrbits8(0x76c, 0x0f); |
| 864 | mchbar_write8(0x770, 0x66); |
| 865 | mchbar_clrbits8(0x7ac, 0x0f); |
| 866 | mchbar_write8(0x7b0, 0x66); |
| 867 | mchbar_clrbits8(0x7ec, 0x0f); |
| 868 | mchbar_write8(0x7f0, 0x66); |
| 869 | mchbar_clrbits8(0x86c, 0x0f); |
| 870 | mchbar_write8(0x870, 0x55); |
| 871 | mchbar_clrbits8(0x8ac, 0x0f); |
| 872 | mchbar_write8(0x8b0, 0x66); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 873 | /* ODT multiplier bits. */ |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 874 | mchbar_clrsetbits32(0x04d0, 7 << 3 | 7 << 0, 2 << 3 | 2 << 0); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 875 | |
| 876 | /* Perform RCOMP calibration for DDR3. */ |
| 877 | raminit_rcomp_calibration(stepping); |
| 878 | |
| 879 | /* Run initial RCOMP. */ |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 880 | mchbar_setbits32(0x418, 1 << 17); |
| 881 | mchbar_clrbits32(0x40c, 1 << 23); |
| 882 | mchbar_clrbits32(0x41c, 1 << 7 | 1 << 3); |
| 883 | mchbar_setbits32(0x400, 1); |
| 884 | while (mchbar_read32(0x400) & 1) {} |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 885 | |
| 886 | /* Run second RCOMP. */ |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 887 | mchbar_setbits32(0x40c, 1 << 19); |
| 888 | mchbar_setbits32(0x400, 1); |
| 889 | while (mchbar_read32(0x400) & 1) {} |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 890 | |
| 891 | /* Cleanup and start periodic RCOMP. */ |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 892 | mchbar_clrbits32(0x40c, 1 << 19); |
| 893 | mchbar_setbits32(0x40c, 1 << 23); |
| 894 | mchbar_clrbits32(0x418, 1 << 17); |
| 895 | mchbar_setbits32(0x41c, 1 << 7 | 1 << 3); |
| 896 | mchbar_setbits32(0x400, 1 << 1); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 897 | } |
| 898 | |
| 899 | static void dram_powerup(const int resume) |
| 900 | { |
Arthur Heymans | 10141c3 | 2016-10-27 00:31:41 +0200 | [diff] [blame] | 901 | udelay(200); |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 902 | mchbar_clrsetbits32(CLKCFG_MCHBAR, 1 << 3, 3 << 21); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 903 | if (!resume) { |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 904 | mchbar_setbits32(0x1434, 1 << 10); |
Arthur Heymans | 10141c3 | 2016-10-27 00:31:41 +0200 | [diff] [blame] | 905 | udelay(1); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 906 | } |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 907 | mchbar_setbits32(0x1434, 1 << 6); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 908 | if (!resume) { |
Arthur Heymans | 10141c3 | 2016-10-27 00:31:41 +0200 | [diff] [blame] | 909 | udelay(1); |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 910 | mchbar_setbits32(0x1434, 1 << 9); |
| 911 | mchbar_clrbits32(0x1434, 1 << 10); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 912 | udelay(500); |
| 913 | } |
| 914 | } |
| 915 | static void dram_program_timings(const timings_t *const timings) |
| 916 | { |
| 917 | /* Values are for DDR3. */ |
| 918 | const int burst_length = 8; |
| 919 | const int tWTR = 4, tRTP = 1; |
| 920 | int i; |
| 921 | |
| 922 | FOR_EACH_CHANNEL(i) { |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 923 | u32 reg = mchbar_read32(CxDRT0_MCHBAR(i)); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 924 | const int btb_wtp = timings->tWL + burst_length/2 + timings->tWR; |
| 925 | const int btb_wtr = timings->tWL + burst_length/2 + tWTR; |
| 926 | reg = (reg & ~(CxDRT0_BtB_WtP_MASK | CxDRT0_BtB_WtR_MASK)) | |
| 927 | ((btb_wtp << CxDRT0_BtB_WtP_SHIFT) & CxDRT0_BtB_WtP_MASK) | |
| 928 | ((btb_wtr << CxDRT0_BtB_WtR_SHIFT) & CxDRT0_BtB_WtR_MASK); |
| 929 | if (timings->mem_clock != MEM_CLOCK_1067MT) { |
| 930 | reg = (reg & ~(0x7 << 15)) | ((9 - timings->CAS) << 15); |
| 931 | reg = (reg & ~(0xf << 10)) | ((timings->CAS - 3) << 10); |
| 932 | } else { |
| 933 | reg = (reg & ~(0x7 << 15)) | ((10 - timings->CAS) << 15); |
| 934 | reg = (reg & ~(0xf << 10)) | ((timings->CAS - 4) << 10); |
| 935 | } |
| 936 | reg = (reg & ~(0x7 << 5)) | (3 << 5); |
| 937 | reg = (reg & ~(0x7 << 0)) | (1 << 0); |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 938 | mchbar_write32(CxDRT0_MCHBAR(i), reg); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 939 | |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 940 | reg = mchbar_read32(CxDRT1_MCHBAR(i)); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 941 | reg = (reg & ~(0x03 << 28)) | ((tRTP & 0x03) << 28); |
| 942 | reg = (reg & ~(0x1f << 21)) | ((timings->tRAS & 0x1f) << 21); |
| 943 | reg = (reg & ~(0x07 << 10)) | (((timings->tRRD - 2) & 0x07) << 10); |
| 944 | reg = (reg & ~(0x07 << 5)) | (((timings->tRCD - 2) & 0x07) << 5); |
| 945 | reg = (reg & ~(0x07 << 0)) | (((timings->tRP - 2) & 0x07) << 0); |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 946 | mchbar_write32(CxDRT1_MCHBAR(i), reg); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 947 | |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 948 | reg = mchbar_read32(CxDRT2_MCHBAR(i)); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 949 | reg = (reg & ~(0x1f << 17)) | ((timings->tFAW & 0x1f) << 17); |
| 950 | if (timings->mem_clock != MEM_CLOCK_1067MT) { |
| 951 | reg = (reg & ~(0x7 << 12)) | (0x2 << 12); |
| 952 | reg = (reg & ~(0xf << 6)) | (0x9 << 6); |
| 953 | } else { |
| 954 | reg = (reg & ~(0x7 << 12)) | (0x3 << 12); |
| 955 | reg = (reg & ~(0xf << 6)) | (0xc << 6); |
| 956 | } |
| 957 | reg = (reg & ~(0x1f << 0)) | (0x13 << 0); |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 958 | mchbar_write32(CxDRT2_MCHBAR(i), reg); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 959 | |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 960 | reg = mchbar_read32(CxDRT3_MCHBAR(i)); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 961 | reg |= 0x3 << 28; |
| 962 | reg = (reg & ~(0x03 << 26)); |
| 963 | reg = (reg & ~(0x07 << 23)) | (((timings->CAS - 3) & 0x07) << 23); |
| 964 | reg = (reg & ~(0xff << 13)) | ((timings->tRFC & 0xff) << 13); |
| 965 | reg = (reg & ~(0x07 << 0)) | (((timings->tWL - 2) & 0x07) << 0); |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 966 | mchbar_write32(CxDRT3_MCHBAR(i), reg); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 967 | |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 968 | reg = mchbar_read32(CxDRT4_MCHBAR(i)); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 969 | static const u8 timings_by_clock[4][3] = { |
| 970 | /* 333MHz 400MHz 533MHz |
| 971 | 667MT 800MT 1067MT */ |
| 972 | { 0x07, 0x0a, 0x0d }, |
| 973 | { 0x3a, 0x46, 0x5d }, |
| 974 | { 0x0c, 0x0e, 0x18 }, |
| 975 | { 0x21, 0x28, 0x35 }, |
| 976 | }; |
| 977 | const int clk_idx = 2 - timings->mem_clock; |
| 978 | reg = (reg & ~(0x01f << 27)) | (timings_by_clock[0][clk_idx] << 27); |
| 979 | reg = (reg & ~(0x3ff << 17)) | (timings_by_clock[1][clk_idx] << 17); |
| 980 | reg = (reg & ~(0x03f << 10)) | (timings_by_clock[2][clk_idx] << 10); |
| 981 | reg = (reg & ~(0x1ff << 0)) | (timings_by_clock[3][clk_idx] << 0); |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 982 | mchbar_write32(CxDRT4_MCHBAR(i), reg); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 983 | |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 984 | reg = mchbar_read32(CxDRT5_MCHBAR(i)); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 985 | if (timings->mem_clock == MEM_CLOCK_1067MT) |
| 986 | reg = (reg & ~(0xf << 28)) | (0x8 << 28); |
| 987 | reg = (reg & ~(0x00f << 22)) | ((burst_length/2 + timings->CAS + 2) << 22); |
| 988 | reg = (reg & ~(0x3ff << 12)) | (0x190 << 12); |
| 989 | reg = (reg & ~(0x00f << 4)) | ((timings->CAS - 2) << 4); |
| 990 | reg = (reg & ~(0x003 << 2)) | (0x001 << 2); |
| 991 | reg = (reg & ~(0x003 << 0)); |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 992 | mchbar_write32(CxDRT5_MCHBAR(i), reg); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 993 | |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 994 | reg = mchbar_read32(CxDRT6_MCHBAR(i)); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 995 | reg = (reg & ~(0xffff << 16)) | (0x066a << 16); /* always 7.8us refresh rate for DDR3 */ |
| 996 | reg |= (1 << 2); |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 997 | mchbar_write32(CxDRT6_MCHBAR(i), reg); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 998 | } |
| 999 | } |
| 1000 | |
| 1001 | static void dram_program_banks(const dimminfo_t *const dimms) |
| 1002 | { |
| 1003 | int ch, r; |
| 1004 | |
| 1005 | FOR_EACH_CHANNEL(ch) { |
| 1006 | const int tRPALL = dimms[ch].banks == 8; |
| 1007 | |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1008 | u32 reg = mchbar_read32(CxDRT1_MCHBAR(ch)) & ~(0x01 << 15); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1009 | IF_CHANNEL_POPULATED(dimms, ch) |
| 1010 | reg |= tRPALL << 15; |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1011 | mchbar_write32(CxDRT1_MCHBAR(ch), reg); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1012 | |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1013 | reg = mchbar_read32(CxDRA_MCHBAR(ch)) & ~CxDRA_BANKS_MASK; |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1014 | FOR_EACH_POPULATED_RANK_IN_CHANNEL(dimms, ch, r) { |
| 1015 | reg |= CxDRA_BANKS(r, dimms[ch].banks); |
| 1016 | } |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1017 | mchbar_write32(CxDRA_MCHBAR(ch), reg); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1018 | } |
| 1019 | } |
| 1020 | |
| 1021 | static void odt_setup(const timings_t *const timings, const int sff) |
| 1022 | { |
| 1023 | /* Values are for DDR3. */ |
| 1024 | int ch; |
| 1025 | |
| 1026 | FOR_EACH_CHANNEL(ch) { |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1027 | u32 reg = mchbar_read32(CxODT_HIGH(ch)); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1028 | if (sff && (timings->mem_clock != MEM_CLOCK_1067MT)) |
| 1029 | reg &= ~(0x3 << (61 - 32)); |
| 1030 | else |
| 1031 | reg |= 0x3 << (61 - 32); |
| 1032 | reg = (reg & ~(0x3 << (52 - 32))) | (0x2 << (52 - 32)); |
| 1033 | reg = (reg & ~(0x7 << (48 - 32))) | ((timings->CAS - 3) << (48 - 32)); |
| 1034 | reg = (reg & ~(0xf << (44 - 32))) | (0x7 << (44 - 32)); |
| 1035 | if (timings->mem_clock != MEM_CLOCK_1067MT) { |
| 1036 | reg = (reg & ~(0xf << (40 - 32))) | ((12 - timings->CAS) << (40 - 32)); |
| 1037 | reg = (reg & ~(0xf << (36 - 32))) | (( 2 + timings->CAS) << (36 - 32)); |
| 1038 | } else { |
| 1039 | reg = (reg & ~(0xf << (40 - 32))) | ((13 - timings->CAS) << (40 - 32)); |
| 1040 | reg = (reg & ~(0xf << (36 - 32))) | (( 1 + timings->CAS) << (36 - 32)); |
| 1041 | } |
| 1042 | reg = (reg & ~(0xf << (32 - 32))) | (0x7 << (32 - 32)); |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1043 | mchbar_write32(CxODT_HIGH(ch), reg); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1044 | |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1045 | reg = mchbar_read32(CxODT_LOW(ch)); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1046 | reg = (reg & ~(0x7 << 28)) | (0x2 << 28); |
| 1047 | reg = (reg & ~(0x3 << 22)) | (0x2 << 22); |
| 1048 | reg = (reg & ~(0x7 << 12)) | (0x2 << 12); |
| 1049 | reg = (reg & ~(0x7 << 4)) | (0x2 << 4); |
| 1050 | switch (timings->mem_clock) { |
| 1051 | case MEM_CLOCK_667MT: |
| 1052 | reg = (reg & ~0x7); |
| 1053 | break; |
| 1054 | case MEM_CLOCK_800MT: |
| 1055 | reg = (reg & ~0x7) | 0x2; |
| 1056 | break; |
| 1057 | case MEM_CLOCK_1067MT: |
| 1058 | reg = (reg & ~0x7) | 0x5; |
| 1059 | break; |
| 1060 | } |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1061 | mchbar_write32(CxODT_LOW(ch), reg); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1062 | } |
| 1063 | } |
| 1064 | |
| 1065 | static void misc_settings(const timings_t *const timings, |
| 1066 | const stepping_t stepping) |
| 1067 | { |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1068 | mchbar_clrsetbits32(0x1260, 1 << 24 | 0x1f, timings->tRD); |
| 1069 | mchbar_clrsetbits32(0x1360, 1 << 24 | 0x1f, timings->tRD); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1070 | |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1071 | mchbar_clrsetbits8(0x1268, 0xf, timings->tWL); |
| 1072 | mchbar_clrsetbits8(0x1368, 0xf, timings->tWL); |
| 1073 | mchbar_clrsetbits8(0x12a0, 0xf, 0xa); |
| 1074 | mchbar_clrsetbits8(0x13a0, 0xf, 0xa); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1075 | |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1076 | mchbar_clrsetbits32(0x218, 7 << 29 | 7 << 25 | 3 << 22 | 3 << 10, |
| 1077 | 4 << 29 | 3 << 25 | 0 << 22 | 1 << 10); |
| 1078 | mchbar_clrsetbits32(0x220, 7 << 16, 1 << 21 | 1 << 16); |
| 1079 | mchbar_clrsetbits32(0x224, 7 << 8, 3 << 8); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1080 | if (stepping >= STEPPING_B1) |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1081 | mchbar_setbits8(0x234, 1 << 3); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1082 | } |
| 1083 | |
| 1084 | static void clock_crossing_setup(const fsb_clock_t fsb, |
| 1085 | const mem_clock_t ddr3clock, |
| 1086 | const dimminfo_t *const dimms) |
| 1087 | { |
| 1088 | int ch; |
| 1089 | |
| 1090 | static const u32 values_from_fsb_and_mem[][3][4] = { |
| 1091 | /* FSB 1067MHz */{ |
| 1092 | /* DDR3-1067 */ { 0x00000000, 0x00000000, 0x00180006, 0x00810060 }, |
| 1093 | /* DDR3-800 */ { 0x00000000, 0x00000000, 0x0000001c, 0x000300e0 }, |
| 1094 | /* DDR3-667 */ { 0x00000000, 0x00001c00, 0x03c00038, 0x0007e000 }, |
| 1095 | }, |
| 1096 | /* FSB 800MHz */{ |
| 1097 | /* DDR3-1067 */ { 0, 0, 0, 0 }, |
| 1098 | /* DDR3-800 */ { 0x00000000, 0x00000000, 0x0030000c, 0x000300c0 }, |
| 1099 | /* DDR3-667 */ { 0x00000000, 0x00000380, 0x0060001c, 0x00030c00 }, |
| 1100 | }, |
| 1101 | /* FSB 667MHz */{ |
| 1102 | /* DDR3-1067 */ { 0, 0, 0, 0 }, |
| 1103 | /* DDR3-800 */ { 0, 0, 0, 0 }, |
| 1104 | /* DDR3-667 */ { 0x00000000, 0x00000000, 0x0030000c, 0x000300c0 }, |
| 1105 | }, |
| 1106 | }; |
| 1107 | |
| 1108 | const u32 *data = values_from_fsb_and_mem[fsb][ddr3clock]; |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1109 | mchbar_write32(0x0208, data[3]); |
| 1110 | mchbar_write32(0x020c, data[2]); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1111 | if (((fsb == FSB_CLOCK_1067MHz) || (fsb == FSB_CLOCK_800MHz)) && (ddr3clock == MEM_CLOCK_667MT)) |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1112 | mchbar_write32(0x0210, data[1]); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1113 | |
| 1114 | static const u32 from_fsb_and_mem[][3] = { |
| 1115 | /* DDR3-1067 DDR3-800 DDR3-667 */ |
| 1116 | /* FSB 1067MHz */{ 0x40100401, 0x10040220, 0x08040110, }, |
| 1117 | /* FSB 800MHz */{ 0x00000000, 0x40100401, 0x00080201, }, |
| 1118 | /* FSB 667MHz */{ 0x00000000, 0x00000000, 0x40100401, }, |
| 1119 | }; |
| 1120 | FOR_EACH_CHANNEL(ch) { |
| 1121 | const unsigned int mchbar = 0x1258 + (ch * 0x0100); |
| 1122 | if ((fsb == FSB_CLOCK_1067MHz) && (ddr3clock == MEM_CLOCK_800MT) && CHANNEL_IS_CARDF(dimms, ch)) |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1123 | mchbar_write32(mchbar, 0x08040120); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1124 | else |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1125 | mchbar_write32(mchbar, from_fsb_and_mem[fsb][ddr3clock]); |
| 1126 | mchbar_write32(mchbar + 4, 0); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1127 | } |
| 1128 | } |
| 1129 | |
Angel Pons | 3e33be2 | 2020-09-16 12:50:59 +0200 | [diff] [blame] | 1130 | /* Program egress VC1 isoch timings. */ |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1131 | static void vc1_program_timings(const fsb_clock_t fsb) |
| 1132 | { |
| 1133 | const u32 timings_by_fsb[][2] = { |
| 1134 | /* FSB 1067MHz */ { 0x1a, 0x01380138 }, |
| 1135 | /* FSB 800MHz */ { 0x14, 0x00f000f0 }, |
| 1136 | /* FSB 667MHz */ { 0x10, 0x00c000c0 }, |
| 1137 | }; |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1138 | epbar_write8(EPVC1ITC, timings_by_fsb[fsb][0]); |
| 1139 | epbar_write32(EPVC1IST + 0, timings_by_fsb[fsb][1]); |
| 1140 | epbar_write32(EPVC1IST + 4, timings_by_fsb[fsb][1]); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1141 | } |
| 1142 | |
Patrick Rudolph | 266a1f7 | 2016-06-09 18:13:34 +0200 | [diff] [blame] | 1143 | #define DEFAULT_PCI_MMIO_SIZE 2048 |
| 1144 | #define HOST_BRIDGE PCI_DEVFN(0, 0) |
| 1145 | |
| 1146 | static unsigned int get_mmio_size(void) |
| 1147 | { |
| 1148 | const struct device *dev; |
| 1149 | const struct northbridge_intel_gm45_config *cfg = NULL; |
| 1150 | |
Kyösti Mälkki | e737755 | 2018-06-21 16:20:55 +0300 | [diff] [blame] | 1151 | dev = pcidev_path_on_root(HOST_BRIDGE); |
Patrick Rudolph | 266a1f7 | 2016-06-09 18:13:34 +0200 | [diff] [blame] | 1152 | if (dev) |
| 1153 | cfg = dev->chip_info; |
| 1154 | |
| 1155 | /* If this is zero, it just means devicetree.cb didn't set it */ |
| 1156 | if (!cfg || cfg->pci_mmio_size == 0) |
| 1157 | return DEFAULT_PCI_MMIO_SIZE; |
| 1158 | else |
| 1159 | return cfg->pci_mmio_size; |
| 1160 | } |
| 1161 | |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1162 | /* @prejedec if not zero, set rank size to 128MB and page size to 4KB. */ |
Vladimir Serbinenko | 56ae8a0 | 2014-08-16 10:59:02 +0200 | [diff] [blame] | 1163 | static void program_memory_map(const dimminfo_t *const dimms, const channel_mode_t mode, const int prejedec, u16 ggc) |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1164 | { |
| 1165 | int ch, r; |
| 1166 | |
| 1167 | /* Program rank boundaries (CxDRBy). */ |
| 1168 | unsigned int base = 0; /* start of next rank in MB */ |
| 1169 | unsigned int total_mb[2] = { 0, 0 }; /* total memory per channel in MB */ |
| 1170 | FOR_EACH_CHANNEL(ch) { |
| 1171 | if (mode == CHANNEL_MODE_DUAL_INTERLEAVED) |
| 1172 | /* In interleaved mode, start every channel from 0. */ |
| 1173 | base = 0; |
| 1174 | for (r = 0; r < RANKS_PER_CHANNEL; r += 2) { |
| 1175 | /* Fixed capacity for pre-jedec config. */ |
| 1176 | const unsigned int rank_capacity_mb = |
| 1177 | prejedec ? 128 : dimms[ch].rank_capacity_mb; |
| 1178 | u32 reg = 0; |
| 1179 | |
| 1180 | /* Program bounds in CxDRBy. */ |
| 1181 | IF_RANK_POPULATED(dimms, ch, r) { |
| 1182 | base += rank_capacity_mb; |
| 1183 | total_mb[ch] += rank_capacity_mb; |
| 1184 | } |
| 1185 | reg |= CxDRBy_BOUND_MB(r, base); |
| 1186 | IF_RANK_POPULATED(dimms, ch, r+1) { |
| 1187 | base += rank_capacity_mb; |
| 1188 | total_mb[ch] += rank_capacity_mb; |
| 1189 | } |
| 1190 | reg |= CxDRBy_BOUND_MB(r+1, base); |
| 1191 | |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1192 | mchbar_write32(CxDRBy_MCHBAR(ch, r), reg); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1193 | } |
| 1194 | } |
| 1195 | |
| 1196 | /* Program page size (CxDRA). */ |
| 1197 | FOR_EACH_CHANNEL(ch) { |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1198 | u32 reg = mchbar_read32(CxDRA_MCHBAR(ch)) & ~CxDRA_PAGESIZE_MASK; |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1199 | FOR_EACH_POPULATED_RANK_IN_CHANNEL(dimms, ch, r) { |
| 1200 | /* Fixed page size for pre-jedec config. */ |
| 1201 | const unsigned int page_size = /* dimm page size in bytes */ |
| 1202 | prejedec ? 4096 : dimms[ch].page_size; |
| 1203 | reg |= CxDRA_PAGESIZE(r, log2(page_size)); |
| 1204 | /* deferred to f5_27: reg |= CxDRA_BANKS(r, dimms[ch].banks); */ |
| 1205 | } |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1206 | mchbar_write32(CxDRA_MCHBAR(ch), reg); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1207 | } |
| 1208 | |
| 1209 | /* Calculate memory mapping, all values in MB. */ |
Vladimir Serbinenko | 56ae8a0 | 2014-08-16 10:59:02 +0200 | [diff] [blame] | 1210 | |
| 1211 | u32 uma_sizem = 0; |
| 1212 | if (!prejedec) { |
| 1213 | if (!(ggc & 2)) { |
| 1214 | printk(BIOS_DEBUG, "IGD decoded, subtracting "); |
| 1215 | |
| 1216 | /* Graphics memory */ |
| 1217 | const u32 gms_sizek = decode_igd_memory_size((ggc >> 4) & 0xf); |
| 1218 | printk(BIOS_DEBUG, "%uM UMA", gms_sizek >> 10); |
| 1219 | |
| 1220 | /* GTT Graphics Stolen Memory Size (GGMS) */ |
| 1221 | const u32 gsm_sizek = decode_igd_gtt_size((ggc >> 8) & 0xf); |
| 1222 | printk(BIOS_DEBUG, " and %uM GTT\n", gsm_sizek >> 10); |
| 1223 | |
| 1224 | uma_sizem = (gms_sizek + gsm_sizek) >> 10; |
Vladimir Serbinenko | 56ae8a0 | 2014-08-16 10:59:02 +0200 | [diff] [blame] | 1225 | } |
Arthur Heymans | d522db0 | 2018-08-06 15:50:54 +0200 | [diff] [blame] | 1226 | /* TSEG 2M, This amount can easily be covered by SMRR MTRR's, |
| 1227 | which requires to have TSEG_BASE aligned to TSEG_SIZE. */ |
Angel Pons | b053583 | 2020-06-08 11:46:58 +0200 | [diff] [blame] | 1228 | pci_update_config8(PCI_DEV(0, 0, 0), D0F0_ESMRAMC, ~0x07, (1 << 1) | (1 << 0)); |
Arthur Heymans | d522db0 | 2018-08-06 15:50:54 +0200 | [diff] [blame] | 1229 | uma_sizem += 2; |
Vladimir Serbinenko | 56ae8a0 | 2014-08-16 10:59:02 +0200 | [diff] [blame] | 1230 | } |
| 1231 | |
Patrick Rudolph | 266a1f7 | 2016-06-09 18:13:34 +0200 | [diff] [blame] | 1232 | const unsigned int mmio_size = get_mmio_size(); |
| 1233 | const unsigned int MMIOstart = 4096 - mmio_size + uma_sizem; |
Vladimir Serbinenko | 9907be4 | 2014-08-12 21:51:28 +0200 | [diff] [blame] | 1234 | const int me_active = pci_read_config8(PCI_DEV(0, 3, 0), PCI_CLASS_REVISION) != 0xff; |
| 1235 | const unsigned int ME_SIZE = prejedec || !me_active ? 0 : 32; |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1236 | const unsigned int usedMEsize = (total_mb[0] != total_mb[1]) ? ME_SIZE : 2 * ME_SIZE; |
| 1237 | const unsigned int claimCapable = |
| 1238 | !(pci_read_config32(PCI_DEV(0, 0, 0), D0F0_CAPID0 + 4) & (1 << (47 - 32))); |
| 1239 | |
| 1240 | const unsigned int TOM = total_mb[0] + total_mb[1]; |
| 1241 | unsigned int TOMminusME = TOM - usedMEsize; |
| 1242 | unsigned int TOLUD = (TOMminusME < MMIOstart) ? TOMminusME : MMIOstart; |
| 1243 | unsigned int TOUUD = TOMminusME; |
| 1244 | unsigned int REMAPbase = 0xffff, REMAPlimit = 0; |
| 1245 | |
| 1246 | if (claimCapable && (TOMminusME >= (MMIOstart + 64))) { |
| 1247 | /* 64MB alignment: We'll lose some MBs here, if ME is on. */ |
| 1248 | TOMminusME &= ~(64 - 1); |
| 1249 | /* 64MB alignment: Loss will be reclaimed. */ |
| 1250 | TOLUD &= ~(64 - 1); |
| 1251 | if (TOMminusME > 4096) { |
| 1252 | REMAPbase = TOMminusME; |
| 1253 | REMAPlimit = REMAPbase + (4096 - TOLUD); |
| 1254 | } else { |
| 1255 | REMAPbase = 4096; |
| 1256 | REMAPlimit = REMAPbase + (TOMminusME - TOLUD); |
| 1257 | } |
| 1258 | TOUUD = REMAPlimit; |
| 1259 | /* REMAPlimit is an inclusive bound, all others exclusive. */ |
| 1260 | REMAPlimit -= 64; |
| 1261 | } |
| 1262 | |
| 1263 | pci_write_config16(PCI_DEV(0, 0, 0), D0F0_TOM, (TOM >> 7) & 0x1ff); |
| 1264 | pci_write_config16(PCI_DEV(0, 0, 0), D0F0_TOLUD, TOLUD << 4); |
| 1265 | pci_write_config16(PCI_DEV(0, 0, 0), D0F0_TOUUD, TOUUD); |
| 1266 | pci_write_config16(PCI_DEV(0, 0, 0), D0F0_REMAPBASE, (REMAPbase >> 6) & 0x03ff); |
| 1267 | pci_write_config16(PCI_DEV(0, 0, 0), D0F0_REMAPLIMIT, (REMAPlimit >> 6) & 0x03ff); |
| 1268 | |
| 1269 | /* Program channel mode. */ |
| 1270 | switch (mode) { |
| 1271 | case CHANNEL_MODE_SINGLE: |
| 1272 | printk(BIOS_DEBUG, "Memory configured in single-channel mode.\n"); |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1273 | mchbar_clrbits32(DCC_MCHBAR, DCC_INTERLEAVED); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1274 | break; |
| 1275 | case CHANNEL_MODE_DUAL_ASYNC: |
Elyes HAOUAS | c9a717d | 2020-02-16 09:52:09 +0100 | [diff] [blame] | 1276 | printk(BIOS_DEBUG, "Memory configured in dual-channel asymmetric mode.\n"); |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1277 | mchbar_clrbits32(DCC_MCHBAR, DCC_INTERLEAVED); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1278 | break; |
| 1279 | case CHANNEL_MODE_DUAL_INTERLEAVED: |
| 1280 | printk(BIOS_DEBUG, "Memory configured in dual-channel interleaved mode.\n"); |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1281 | mchbar_clrbits32(DCC_MCHBAR, DCC_NO_CHANXOR | 1 << 9); |
| 1282 | mchbar_setbits32(DCC_MCHBAR, DCC_INTERLEAVED); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1283 | break; |
| 1284 | } |
| 1285 | |
| 1286 | printk(BIOS_SPEW, "Memory map:\n" |
| 1287 | "TOM = %5uMB\n" |
| 1288 | "TOLUD = %5uMB\n" |
| 1289 | "TOUUD = %5uMB\n" |
| 1290 | "REMAP:\t base = %5uMB\n" |
Vladimir Serbinenko | 9907be4 | 2014-08-12 21:51:28 +0200 | [diff] [blame] | 1291 | "\t limit = %5uMB\n" |
| 1292 | "usedMEsize: %dMB\n", |
| 1293 | TOM, TOLUD, TOUUD, REMAPbase, REMAPlimit, usedMEsize); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1294 | } |
| 1295 | static void prejedec_memory_map(const dimminfo_t *const dimms, channel_mode_t mode) |
| 1296 | { |
| 1297 | /* Never use dual-interleaved mode in pre-jedec config. */ |
| 1298 | if (CHANNEL_MODE_DUAL_INTERLEAVED == mode) |
| 1299 | mode = CHANNEL_MODE_DUAL_ASYNC; |
| 1300 | |
Vladimir Serbinenko | 56ae8a0 | 2014-08-16 10:59:02 +0200 | [diff] [blame] | 1301 | program_memory_map(dimms, mode, 1, 0); |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1302 | mchbar_setbits32(DCC_MCHBAR, DCC_NO_CHANXOR); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1303 | } |
| 1304 | |
| 1305 | static void ddr3_select_clock_mux(const mem_clock_t ddr3clock, |
| 1306 | const dimminfo_t *const dimms, |
| 1307 | const stepping_t stepping) |
| 1308 | { |
| 1309 | const int clk1067 = (ddr3clock == MEM_CLOCK_1067MT); |
| 1310 | const int cardF[] = { CHANNEL_IS_CARDF(dimms, 0), CHANNEL_IS_CARDF(dimms, 1) }; |
| 1311 | |
| 1312 | int ch; |
| 1313 | |
| 1314 | if (stepping < STEPPING_B1) |
| 1315 | die("Stepping <B1 unsupported in clock-multiplexer selection.\n"); |
| 1316 | |
| 1317 | FOR_EACH_POPULATED_CHANNEL(dimms, ch) { |
| 1318 | int mixed = 0; |
| 1319 | if ((1 == ch) && (!CHANNEL_IS_POPULATED(dimms, 0) || (cardF[0] != cardF[1]))) |
| 1320 | mixed = 4 << 11; |
| 1321 | const unsigned int b = 0x14b0 + (ch * 0x0100); |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1322 | mchbar_write32(b + 0x1c, (mchbar_read32(b + 0x1c) & ~(7 << 11)) | |
| 1323 | ((( cardF[ch])?1:0) << 11) | mixed); |
| 1324 | mchbar_write32(b + 0x18, (mchbar_read32(b + 0x18) & ~(7 << 11)) | mixed); |
| 1325 | mchbar_write32(b + 0x14, (mchbar_read32(b + 0x14) & ~(7 << 11)) | |
| 1326 | (((!clk1067 && !cardF[ch])?0:1) << 11) | mixed); |
| 1327 | mchbar_write32(b + 0x10, (mchbar_read32(b + 0x10) & ~(7 << 11)) | |
| 1328 | ((( clk1067 && !cardF[ch])?1:0) << 11) | mixed); |
| 1329 | mchbar_write32(b + 0x0c, (mchbar_read32(b + 0x0c) & ~(7 << 11)) | |
| 1330 | ((( cardF[ch])?3:2) << 11) | mixed); |
| 1331 | mchbar_write32(b + 0x08, (mchbar_read32(b + 0x08) & ~(7 << 11)) | |
| 1332 | (2 << 11) | mixed); |
| 1333 | mchbar_write32(b + 0x04, (mchbar_read32(b + 0x04) & ~(7 << 11)) | |
| 1334 | (((!clk1067 && !cardF[ch])?2:3) << 11) | mixed); |
| 1335 | mchbar_write32(b + 0x00, (mchbar_read32(b + 0x00) & ~(7 << 11)) | |
| 1336 | ((( clk1067 && !cardF[ch])?3:2) << 11) | mixed); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1337 | } |
| 1338 | } |
| 1339 | static void ddr3_write_io_init(const mem_clock_t ddr3clock, |
| 1340 | const dimminfo_t *const dimms, |
| 1341 | const stepping_t stepping, |
| 1342 | const int sff) |
| 1343 | { |
| 1344 | const int a1step = stepping >= STEPPING_CONVERSION_A1; |
| 1345 | const int cardF[] = { CHANNEL_IS_CARDF(dimms, 0), CHANNEL_IS_CARDF(dimms, 1) }; |
| 1346 | |
| 1347 | int ch; |
| 1348 | |
| 1349 | if (stepping < STEPPING_B1) |
| 1350 | die("Stepping <B1 unsupported in write i/o initialization.\n"); |
| 1351 | if (sff) |
| 1352 | die("SFF platform unsupported in write i/o initialization.\n"); |
| 1353 | |
| 1354 | static const u32 ddr3_667_800_by_stepping_ddr3_and_card[][2][2][4] = { |
| 1355 | { /* Stepping B3 and below */ |
| 1356 | { /* 667 MHz */ |
| 1357 | { 0xa3255008, 0x26888209, 0x26288208, 0x6188040f }, |
| 1358 | { 0x7524240b, 0xa5255608, 0x232b8508, 0x5528040f }, |
| 1359 | }, |
| 1360 | { /* 800 MHz */ |
| 1361 | { 0xa6255308, 0x26888209, 0x212b7508, 0x6188040f }, |
| 1362 | { 0x7524240b, 0xa6255708, 0x132b7508, 0x5528040f }, |
| 1363 | }, |
| 1364 | }, |
| 1365 | { /* Conversion stepping A1 and above */ |
| 1366 | { /* 667 MHz */ |
| 1367 | { 0xc5257208, 0x26888209, 0x26288208, 0x6188040f }, |
| 1368 | { 0x7524240b, 0xc5257608, 0x232b8508, 0x5528040f }, |
| 1369 | }, |
| 1370 | { /* 800 MHz */ |
| 1371 | { 0xb6256308, 0x26888209, 0x212b7508, 0x6188040f }, |
| 1372 | { 0x7524240b, 0xb6256708, 0x132b7508, 0x5528040f }, |
| 1373 | } |
| 1374 | }}; |
| 1375 | |
| 1376 | static const u32 ddr3_1067_by_channel_and_card[][2][4] = { |
| 1377 | { /* Channel A */ |
| 1378 | { 0xb2254708, 0x002b7408, 0x132b8008, 0x7228060f }, |
| 1379 | { 0xb0255008, 0xa4254108, 0x4528b409, 0x9428230f }, |
| 1380 | }, |
| 1381 | { /* Channel B */ |
| 1382 | { 0xa4254208, 0x022b6108, 0x132b8208, 0x9228210f }, |
| 1383 | { 0x6024140b, 0x92244408, 0x252ba409, 0x9328360c }, |
| 1384 | }, |
| 1385 | }; |
| 1386 | |
| 1387 | FOR_EACH_POPULATED_CHANNEL(dimms, ch) { |
| 1388 | if ((1 == ch) && CHANNEL_IS_POPULATED(dimms, 0) && (cardF[0] == cardF[1])) |
| 1389 | /* Only write if second channel population differs. */ |
| 1390 | continue; |
| 1391 | const u32 *const data = (ddr3clock != MEM_CLOCK_1067MT) |
| 1392 | ? ddr3_667_800_by_stepping_ddr3_and_card[a1step][2 - ddr3clock][cardF[ch]] |
| 1393 | : ddr3_1067_by_channel_and_card[ch][cardF[ch]]; |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1394 | mchbar_write32(CxWRTy_MCHBAR(ch, 0), data[0]); |
| 1395 | mchbar_write32(CxWRTy_MCHBAR(ch, 1), data[1]); |
| 1396 | mchbar_write32(CxWRTy_MCHBAR(ch, 2), data[2]); |
| 1397 | mchbar_write32(CxWRTy_MCHBAR(ch, 3), data[3]); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1398 | } |
| 1399 | |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1400 | mchbar_write32(0x1490, 0x00e70067); |
| 1401 | mchbar_write32(0x1494, 0x000d8000); |
| 1402 | mchbar_write32(0x1590, 0x00e70067); |
| 1403 | mchbar_write32(0x1594, 0x000d8000); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1404 | } |
| 1405 | static void ddr3_read_io_init(const mem_clock_t ddr3clock, |
| 1406 | const dimminfo_t *const dimms, |
| 1407 | const int sff) |
| 1408 | { |
| 1409 | int ch; |
| 1410 | |
| 1411 | FOR_EACH_POPULATED_CHANNEL(dimms, ch) { |
| 1412 | u32 addr, tmp; |
| 1413 | const unsigned int base = 0x14b0 + (ch * 0x0100); |
| 1414 | for (addr = base + 0x1c; addr >= base; addr -= 4) { |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1415 | tmp = mchbar_read32(addr); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1416 | tmp &= ~((3 << 25) | (1 << 8) | (7 << 16) | (0xf << 20) | (1 << 27)); |
| 1417 | tmp |= (1 << 27); |
| 1418 | switch (ddr3clock) { |
| 1419 | case MEM_CLOCK_667MT: |
| 1420 | tmp |= (1 << 16) | (4 << 20); |
| 1421 | break; |
| 1422 | case MEM_CLOCK_800MT: |
| 1423 | tmp |= (2 << 16) | (3 << 20); |
| 1424 | break; |
| 1425 | case MEM_CLOCK_1067MT: |
| 1426 | if (!sff) |
| 1427 | tmp |= (2 << 16) | (1 << 20); |
| 1428 | else |
| 1429 | tmp |= (2 << 16) | (2 << 20); |
| 1430 | break; |
| 1431 | default: |
| 1432 | die("Wrong clock"); |
| 1433 | } |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1434 | mchbar_write32(addr, tmp); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1435 | } |
| 1436 | } |
| 1437 | } |
| 1438 | |
| 1439 | static void memory_io_init(const mem_clock_t ddr3clock, |
| 1440 | const dimminfo_t *const dimms, |
| 1441 | const stepping_t stepping, |
| 1442 | const int sff) |
| 1443 | { |
| 1444 | u32 tmp; |
| 1445 | |
| 1446 | if (stepping < STEPPING_B1) |
| 1447 | die("Stepping <B1 unsupported in " |
| 1448 | "system-memory i/o initialization.\n"); |
| 1449 | |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1450 | tmp = mchbar_read32(0x1400); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1451 | tmp &= ~(3<<13); |
| 1452 | tmp |= (1<<9) | (1<<13); |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1453 | mchbar_write32(0x1400, tmp); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1454 | |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1455 | tmp = mchbar_read32(0x140c); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1456 | tmp &= ~(0xff | (1<<11) | (1<<12) | |
| 1457 | (1<<16) | (1<<18) | (1<<27) | (0xf<<28)); |
| 1458 | tmp |= (1<<7) | (1<<11) | (1<<16); |
| 1459 | switch (ddr3clock) { |
| 1460 | case MEM_CLOCK_667MT: |
| 1461 | tmp |= 9 << 28; |
| 1462 | break; |
| 1463 | case MEM_CLOCK_800MT: |
| 1464 | tmp |= 7 << 28; |
| 1465 | break; |
| 1466 | case MEM_CLOCK_1067MT: |
| 1467 | tmp |= 8 << 28; |
| 1468 | break; |
| 1469 | } |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1470 | mchbar_write32(0x140c, tmp); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1471 | |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1472 | mchbar_clrbits32(0x1440, 1); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1473 | |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1474 | tmp = mchbar_read32(0x1414); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1475 | tmp &= ~((1<<20) | (7<<11) | (0xf << 24) | (0xf << 16)); |
| 1476 | tmp |= (3<<11); |
| 1477 | switch (ddr3clock) { |
| 1478 | case MEM_CLOCK_667MT: |
| 1479 | tmp |= (2 << 24) | (10 << 16); |
| 1480 | break; |
| 1481 | case MEM_CLOCK_800MT: |
| 1482 | tmp |= (3 << 24) | (7 << 16); |
| 1483 | break; |
| 1484 | case MEM_CLOCK_1067MT: |
| 1485 | tmp |= (4 << 24) | (4 << 16); |
| 1486 | break; |
| 1487 | } |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1488 | mchbar_write32(0x1414, tmp); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1489 | |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1490 | mchbar_clrbits32(0x1418, 1 << 3 | 1 << 11 | 1 << 19 | 1 << 27); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1491 | |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1492 | mchbar_clrbits32(0x141c, 1 << 3 | 1 << 11 | 1 << 19 | 1 << 27); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1493 | |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1494 | mchbar_setbits32(0x1428, 1 << 14); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1495 | |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1496 | tmp = mchbar_read32(0x142c); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1497 | tmp &= ~((0xf << 8) | (0x7 << 20) | 0xf | (0xf << 24)); |
| 1498 | tmp |= (0x3 << 20) | (5 << 24); |
| 1499 | switch (ddr3clock) { |
| 1500 | case MEM_CLOCK_667MT: |
| 1501 | tmp |= (2 << 8) | 0xc; |
| 1502 | break; |
| 1503 | case MEM_CLOCK_800MT: |
| 1504 | tmp |= (3 << 8) | 0xa; |
| 1505 | break; |
| 1506 | case MEM_CLOCK_1067MT: |
| 1507 | tmp |= (4 << 8) | 0x7; |
| 1508 | break; |
| 1509 | } |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1510 | mchbar_write32(0x142c, tmp); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1511 | |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1512 | tmp = mchbar_read32(0x400); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1513 | tmp &= ~((3 << 4) | (3 << 16) | (3 << 30)); |
| 1514 | tmp |= (2 << 4) | (2 << 16); |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1515 | mchbar_write32(0x400, tmp); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1516 | |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1517 | mchbar_clrbits32(0x404, 0xf << 20); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1518 | |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1519 | mchbar_clrbits32(0x40c, 1 << 6); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1520 | |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1521 | tmp = mchbar_read32(0x410); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1522 | tmp &= ~(7 << 28); |
| 1523 | tmp |= 2 << 28; |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1524 | mchbar_write32(0x410, tmp); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1525 | |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1526 | tmp = mchbar_read32(0x41c); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1527 | tmp &= ~0x77; |
| 1528 | tmp |= 0x11; |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1529 | mchbar_write32(0x41c, tmp); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1530 | |
| 1531 | ddr3_select_clock_mux(ddr3clock, dimms, stepping); |
| 1532 | |
| 1533 | ddr3_write_io_init(ddr3clock, dimms, stepping, sff); |
| 1534 | |
| 1535 | ddr3_read_io_init(ddr3clock, dimms, sff); |
| 1536 | } |
| 1537 | |
| 1538 | static void jedec_init(const timings_t *const timings, |
| 1539 | const dimminfo_t *const dimms) |
| 1540 | { |
| 1541 | if ((timings->tWR < 5) || (timings->tWR > 12)) |
| 1542 | die("tWR value unsupported in Jedec initialization.\n"); |
| 1543 | |
| 1544 | /* Pre-jedec settings */ |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1545 | mchbar_setbits32(0x40, 1 << 1); |
| 1546 | mchbar_setbits32(0x230, 3 << 1); |
| 1547 | mchbar_setbits32(0x238, 3 << 24); |
| 1548 | mchbar_setbits32(0x23c, 3 << 24); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1549 | |
| 1550 | /* Normal write pointer operation */ |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1551 | mchbar_setbits32(0x14f0, 1 << 9); |
| 1552 | mchbar_setbits32(0x15f0, 1 << 9); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1553 | |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1554 | mchbar_clrsetbits32(DCC_MCHBAR, DCC_CMD_MASK, DCC_CMD_NOP); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1555 | |
Angel Pons | b053583 | 2020-06-08 11:46:58 +0200 | [diff] [blame] | 1556 | pci_and_config8(PCI_DEV(0, 0, 0), 0xf0, ~(1 << 2)); |
| 1557 | |
| 1558 | pci_or_config8(PCI_DEV(0, 0, 0), 0xf0, 1 << 2); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1559 | udelay(2); |
| 1560 | |
| 1561 | /* 5 6 7 8 9 10 11 12 */ |
| 1562 | static const u8 wr_lut[] = { 1, 2, 3, 4, 5, 5, 6, 6 }; |
| 1563 | |
| 1564 | const int WL = ((timings->tWL - 5) & 7) << 6; |
| 1565 | const int ODT_120OHMS = (1 << 9); |
| 1566 | const int ODS_34OHMS = (1 << 4); |
| 1567 | const int WR = (wr_lut[timings->tWR - 5] & 7) << 12; |
| 1568 | const int DLL1 = 1 << 11; |
| 1569 | const int CAS = ((timings->CAS - 4) & 7) << 7; |
| 1570 | const int INTERLEAVED = 1 << 6;/* This is READ Burst Type == interleaved. */ |
| 1571 | |
| 1572 | int ch, r; |
| 1573 | FOR_EACH_POPULATED_RANK(dimms, ch, r) { |
| 1574 | /* We won't do this in dual-interleaved mode, |
Felix Held | 7f9f3d0 | 2019-06-07 14:47:28 +0200 | [diff] [blame] | 1575 | so don't care about the offset. |
| 1576 | Mirrored ranks aren't taken into account here. */ |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1577 | const u32 rankaddr = raminit_get_rank_addr(ch, r); |
Nico Huber | 0624f92 | 2017-04-15 15:57:28 +0200 | [diff] [blame] | 1578 | printk(BIOS_DEBUG, "JEDEC init @0x%08x\n", rankaddr); |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1579 | mchbar_clrsetbits32(DCC_MCHBAR, DCC_SET_EREG_MASK, DCC_SET_EREGx(2)); |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 1580 | read32((u32 *)(rankaddr | WL)); |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1581 | mchbar_clrsetbits32(DCC_MCHBAR, DCC_SET_EREG_MASK, DCC_SET_EREGx(3)); |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 1582 | read32((u32 *)rankaddr); |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1583 | mchbar_clrsetbits32(DCC_MCHBAR, DCC_SET_EREG_MASK, DCC_SET_EREGx(1)); |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 1584 | read32((u32 *)(rankaddr | ODT_120OHMS | ODS_34OHMS)); |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1585 | mchbar_clrsetbits32(DCC_MCHBAR, DCC_CMD_MASK, DCC_SET_MREG); |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 1586 | read32((u32 *)(rankaddr | WR | DLL1 | CAS | INTERLEAVED)); |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1587 | mchbar_clrsetbits32(DCC_MCHBAR, DCC_CMD_MASK, DCC_SET_MREG); |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 1588 | read32((u32 *)(rankaddr | WR | CAS | INTERLEAVED)); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1589 | } |
| 1590 | } |
| 1591 | |
| 1592 | static void ddr3_calibrate_zq(void) { |
| 1593 | udelay(2); |
| 1594 | |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1595 | u32 tmp = mchbar_read32(DCC_MCHBAR); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1596 | tmp &= ~(7 << 16); |
| 1597 | tmp |= (5 << 16); /* ZQ calibration mode */ |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1598 | mchbar_write32(DCC_MCHBAR, tmp); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1599 | |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1600 | mchbar_setbits32(CxDRT6_MCHBAR(0), 1 << 3); |
| 1601 | mchbar_setbits32(CxDRT6_MCHBAR(1), 1 << 3); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1602 | |
| 1603 | udelay(1); |
| 1604 | |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1605 | mchbar_clrbits32(CxDRT6_MCHBAR(0), 1 << 3); |
| 1606 | mchbar_clrbits32(CxDRT6_MCHBAR(1), 1 << 3); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1607 | |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1608 | mchbar_setbits32(DCC_MCHBAR, 7 << 16); /* Normal operation */ |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1609 | } |
| 1610 | |
| 1611 | static void post_jedec_sequence(const int cores) { |
| 1612 | const int quadcore = cores == 4; |
| 1613 | |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1614 | mchbar_clrbits32(0x0040, 1 << 1); |
| 1615 | mchbar_clrbits32(0x0230, 3 << 1); |
| 1616 | mchbar_setbits32(0x0230, 1 << 15); |
| 1617 | mchbar_clrbits32(0x0230, 1 << 19); |
| 1618 | mchbar_write32(0x1250, 0x6c4); |
| 1619 | mchbar_write32(0x1350, 0x6c4); |
| 1620 | mchbar_write32(0x1254, 0x871a066d); |
| 1621 | mchbar_write32(0x1354, 0x871a066d); |
| 1622 | mchbar_setbits32(0x0238, 1 << 26); |
| 1623 | mchbar_clrbits32(0x0238, 3 << 24); |
| 1624 | mchbar_setbits32(0x0238, 1 << 23); |
| 1625 | mchbar_clrsetbits32(0x0238, 7 << 20, 3 << 20); |
| 1626 | mchbar_clrsetbits32(0x0238, 7 << 17, 6 << 17); |
| 1627 | mchbar_clrsetbits32(0x0238, 7 << 14, 6 << 14); |
| 1628 | mchbar_clrsetbits32(0x0238, 7 << 11, 6 << 11); |
| 1629 | mchbar_clrsetbits32(0x0238, 7 << 8, 6 << 8); |
| 1630 | mchbar_clrbits32(0x023c, 3 << 24); |
| 1631 | mchbar_clrbits32(0x023c, 1 << 23); |
| 1632 | mchbar_clrsetbits32(0x023c, 7 << 20, 3 << 20); |
| 1633 | mchbar_clrsetbits32(0x023c, 7 << 17, 6 << 17); |
| 1634 | mchbar_clrsetbits32(0x023c, 7 << 14, 6 << 14); |
| 1635 | mchbar_clrsetbits32(0x023c, 7 << 11, 6 << 11); |
| 1636 | mchbar_clrsetbits32(0x023c, 7 << 8, 6 << 8); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1637 | |
| 1638 | if (quadcore) { |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1639 | mchbar_setbits32(0xb14, 0xbfbf << 16); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1640 | } |
| 1641 | } |
| 1642 | |
| 1643 | static void dram_optimizations(const timings_t *const timings, |
| 1644 | const dimminfo_t *const dimms) |
| 1645 | { |
| 1646 | int ch; |
| 1647 | |
| 1648 | FOR_EACH_POPULATED_CHANNEL(dimms, ch) { |
| 1649 | const unsigned int mchbar = CxDRC1_MCHBAR(ch); |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1650 | u32 cxdrc1 = mchbar_read32(mchbar); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1651 | cxdrc1 &= ~CxDRC1_SSDS_MASK; |
| 1652 | if (dimms[ch].ranks == 1) |
| 1653 | cxdrc1 |= CxDRC1_SS; |
| 1654 | else |
| 1655 | cxdrc1 |= CxDRC1_DS; |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1656 | mchbar_write32(mchbar, cxdrc1); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1657 | } |
| 1658 | } |
| 1659 | |
| 1660 | u32 raminit_get_rank_addr(unsigned int channel, unsigned int rank) |
| 1661 | { |
| 1662 | if (!channel && !rank) |
| 1663 | return 0; /* Address of first rank */ |
| 1664 | |
| 1665 | /* Read the bound of the previous rank. */ |
| 1666 | if (rank > 0) { |
| 1667 | rank--; |
| 1668 | } else { |
| 1669 | rank = 3; /* Highest rank per channel */ |
| 1670 | channel--; |
| 1671 | } |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1672 | const u32 reg = mchbar_read32(CxDRBy_MCHBAR(channel, rank)); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1673 | /* Bound is in 32MB. */ |
| 1674 | return ((reg & CxDRBy_BOUND_MASK(rank)) >> CxDRBy_BOUND_SHIFT(rank)) << 25; |
| 1675 | } |
| 1676 | |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1677 | void raminit_reset_readwrite_pointers(void) |
| 1678 | { |
| 1679 | mchbar_setbits32(0x1234, 1 << 6); |
| 1680 | mchbar_clrbits32(0x1234, 1 << 6); |
| 1681 | mchbar_setbits32(0x1334, 1 << 6); |
| 1682 | mchbar_clrbits32(0x1334, 1 << 6); |
| 1683 | mchbar_clrbits32(0x14f0, 1 << 9); |
| 1684 | mchbar_setbits32(0x14f0, 1 << 9); |
| 1685 | mchbar_setbits32(0x14f0, 1 << 10); |
| 1686 | mchbar_clrbits32(0x15f0, 1 << 9); |
| 1687 | mchbar_setbits32(0x15f0, 1 << 9); |
| 1688 | mchbar_setbits32(0x15f0, 1 << 10); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1689 | } |
| 1690 | |
| 1691 | void raminit(sysinfo_t *const sysinfo, const int s3resume) |
| 1692 | { |
| 1693 | const dimminfo_t *const dimms = sysinfo->dimms; |
| 1694 | const timings_t *const timings = &sysinfo->selected_timings; |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1695 | |
| 1696 | int ch; |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1697 | |
Jakub Czapiga | ad6157e | 2022-02-15 11:50:31 +0100 | [diff] [blame] | 1698 | timestamp_add_now(TS_INITRAM_START); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1699 | |
| 1700 | /* Wait for some bit, maybe TXT clear. */ |
| 1701 | if (sysinfo->txt_enabled) { |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 1702 | while (!(read8((u8 *)0xfed40000) & (1 << 7))) {} |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1703 | } |
| 1704 | |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1705 | /* Collect information about DIMMs and find common settings. */ |
| 1706 | collect_dimm_config(sysinfo); |
| 1707 | |
| 1708 | /* Check for bad warm boot. */ |
| 1709 | reset_on_bad_warmboot(); |
| 1710 | |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1711 | /***** From now on, program according to collected infos: *****/ |
| 1712 | |
| 1713 | /* Program DRAM type. */ |
| 1714 | switch (sysinfo->spd_type) { |
| 1715 | case DDR2: |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1716 | mchbar_setbits8(0x1434, 1 << 7); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1717 | break; |
| 1718 | case DDR3: |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1719 | mchbar_setbits8(0x1434, 3 << 0); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1720 | break; |
| 1721 | } |
| 1722 | |
| 1723 | /* Program system memory frequency. */ |
| 1724 | set_system_memory_frequency(timings); |
| 1725 | /* Program IGD memory frequency. */ |
| 1726 | set_igd_memory_frequencies(sysinfo); |
| 1727 | |
| 1728 | /* Configure DRAM control mode for populated channels. */ |
| 1729 | configure_dram_control_mode(timings, dimms); |
| 1730 | |
| 1731 | /* Initialize RCOMP. */ |
Nico Huber | 5aaeb27 | 2015-12-30 00:17:27 +0100 | [diff] [blame] | 1732 | rcomp_initialization(sysinfo->stepping, sysinfo->sff); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1733 | |
| 1734 | /* Power-up DRAM. */ |
| 1735 | dram_powerup(s3resume); |
| 1736 | /* Program DRAM timings. */ |
| 1737 | dram_program_timings(timings); |
| 1738 | /* Program number of banks. */ |
| 1739 | dram_program_banks(dimms); |
| 1740 | /* Enable DRAM clock pairs for populated DIMMs. */ |
| 1741 | FOR_EACH_POPULATED_CHANNEL(dimms, ch) |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1742 | mchbar_setbits32(CxDCLKDIS_MCHBAR(ch), CxDCLKDIS_ENABLE); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1743 | |
| 1744 | /* Enable On-Die Termination. */ |
Nico Huber | 5aaeb27 | 2015-12-30 00:17:27 +0100 | [diff] [blame] | 1745 | odt_setup(timings, sysinfo->sff); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1746 | /* Miscellaneous settings. */ |
| 1747 | misc_settings(timings, sysinfo->stepping); |
| 1748 | /* Program clock crossing registers. */ |
| 1749 | clock_crossing_setup(timings->fsb_clock, timings->mem_clock, dimms); |
| 1750 | /* Program egress VC1 timings. */ |
| 1751 | vc1_program_timings(timings->fsb_clock); |
| 1752 | /* Perform system-memory i/o initialization. */ |
Nico Huber | 5aaeb27 | 2015-12-30 00:17:27 +0100 | [diff] [blame] | 1753 | memory_io_init(timings->mem_clock, dimms, |
| 1754 | sysinfo->stepping, sysinfo->sff); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1755 | |
| 1756 | /* Initialize memory map with dummy values of 128MB per rank with a |
| 1757 | page size of 4KB. This makes the JEDEC initialization code easier. */ |
| 1758 | prejedec_memory_map(dimms, timings->channel_mode); |
| 1759 | if (!s3resume) |
| 1760 | /* Perform JEDEC initialization of DIMMS. */ |
| 1761 | jedec_init(timings, dimms); |
| 1762 | /* Some programming steps after JEDEC initialization. */ |
| 1763 | post_jedec_sequence(sysinfo->cores); |
| 1764 | |
| 1765 | /* Announce normal operation, initialization completed. */ |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1766 | mchbar_setbits32(DCC_MCHBAR, 0x7 << 16 | 0x1 << 19); |
Angel Pons | b053583 | 2020-06-08 11:46:58 +0200 | [diff] [blame] | 1767 | |
| 1768 | pci_or_config8(PCI_DEV(0, 0, 0), 0xf0, 1 << 2); |
| 1769 | |
| 1770 | pci_and_config8(PCI_DEV(0, 0, 0), 0xf0, ~(1 << 2)); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1771 | |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1772 | /* Take a breath (the reader). */ |
| 1773 | |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1774 | /* Perform ZQ calibration for DDR3. */ |
Nico Huber | 4a86b3b | 2019-08-11 16:28:05 +0200 | [diff] [blame] | 1775 | if (sysinfo->spd_type == DDR3) |
| 1776 | ddr3_calibrate_zq(); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1777 | |
| 1778 | /* Perform receive-enable calibration. */ |
| 1779 | raminit_receive_enable_calibration(timings, dimms); |
| 1780 | /* Lend clock values from receive-enable calibration. */ |
Angel Pons | 3f1f8ef | 2021-03-27 13:52:43 +0100 | [diff] [blame] | 1781 | mchbar_clrsetbits32(CxDRT5_MCHBAR(0), 0xf0, |
| 1782 | (((mchbar_read32(CxDRT3_MCHBAR(0)) >> 7) - 1) & 0xf) << 4); |
| 1783 | mchbar_clrsetbits32(CxDRT5_MCHBAR(1), 0xf0, |
| 1784 | (((mchbar_read32(CxDRT3_MCHBAR(1)) >> 7) - 1) & 0xf) << 4); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1785 | |
| 1786 | /* Perform read/write training for high clock rate. */ |
| 1787 | if (timings->mem_clock == MEM_CLOCK_1067MT) { |
| 1788 | raminit_read_training(dimms, s3resume); |
| 1789 | raminit_write_training(timings->mem_clock, dimms, s3resume); |
| 1790 | } |
| 1791 | |
Vladimir Serbinenko | 56ae8a0 | 2014-08-16 10:59:02 +0200 | [diff] [blame] | 1792 | igd_compute_ggc(sysinfo); |
| 1793 | |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1794 | /* Program final memory map (with real values). */ |
Vladimir Serbinenko | 56ae8a0 | 2014-08-16 10:59:02 +0200 | [diff] [blame] | 1795 | program_memory_map(dimms, timings->channel_mode, 0, sysinfo->ggc); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1796 | |
| 1797 | /* Some last optimizations. */ |
| 1798 | dram_optimizations(timings, dimms); |
| 1799 | |
Elyes HAOUAS | 3d45000 | 2018-08-09 18:55:58 +0200 | [diff] [blame] | 1800 | /* Mark raminit being finished. :-) */ |
Angel Pons | b053583 | 2020-06-08 11:46:58 +0200 | [diff] [blame] | 1801 | pci_and_config8(PCI_DEV(0, 0x1f, 0), 0xa2, (u8)~(1 << 7)); |
Vladimir Serbinenko | 56ae8a0 | 2014-08-16 10:59:02 +0200 | [diff] [blame] | 1802 | |
| 1803 | raminit_thermal(sysinfo); |
| 1804 | init_igd(sysinfo); |
Arthur Heymans | 049347f | 2017-05-12 11:54:08 +0200 | [diff] [blame] | 1805 | |
Jakub Czapiga | ad6157e | 2022-02-15 11:50:31 +0100 | [diff] [blame] | 1806 | timestamp_add_now(TS_INITRAM_END); |
Patrick Georgi | 2efc880 | 2012-11-06 11:03:53 +0100 | [diff] [blame] | 1807 | } |