Angel Pons | 4b42983 | 2020-04-02 23:48:50 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2 | |
Patrick Georgi | d083595 | 2010-10-05 09:07:10 +0000 | [diff] [blame] | 3 | #include <console/console.h> |
Kyösti Mälkki | 7fbed22 | 2019-07-11 08:14:07 +0300 | [diff] [blame] | 4 | #include <delay.h> |
Arthur Heymans | 885c289 | 2016-10-03 17:16:48 +0200 | [diff] [blame] | 5 | #include <device/pci_def.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 6 | #include <device/pci_ops.h> |
Kyösti Mälkki | 1a1b04e | 2020-01-07 22:34:33 +0200 | [diff] [blame] | 7 | #include <device/smbus_host.h> |
Elyes HAOUAS | 420d7e0 | 2019-04-21 18:39:34 +0200 | [diff] [blame] | 8 | #include <cf9_reset.h> |
Kyösti Mälkki | 13f6650 | 2019-03-03 08:01:05 +0200 | [diff] [blame] | 9 | #include <device/mmio.h> |
Arthur Heymans | 885c289 | 2016-10-03 17:16:48 +0200 | [diff] [blame] | 10 | #include <device/device.h> |
Julius Werner | 7a8a4ab | 2015-05-22 16:26:40 -0700 | [diff] [blame] | 11 | #include <lib.h> |
Edwin Beasant | eb50c7d | 2010-07-06 21:05:04 +0000 | [diff] [blame] | 12 | #include <pc80/mc146818rtc.h> |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 13 | #include <spd.h> |
Patrick Georgi | d083595 | 2010-10-05 09:07:10 +0000 | [diff] [blame] | 14 | #include <string.h> |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 15 | #include "raminit.h" |
| 16 | #include "i945.h" |
Arthur Heymans | 885c289 | 2016-10-03 17:16:48 +0200 | [diff] [blame] | 17 | #include "chip.h" |
Arthur Heymans | 0ab4904 | 2017-02-06 22:40:14 +0100 | [diff] [blame] | 18 | #include <device/dram/ddr2.h> |
Patrick Georgi | 771328f | 2015-07-13 19:24:07 +0200 | [diff] [blame] | 19 | #include <timestamp.h> |
Rudolf Marek | c436953 | 2010-12-13 19:59:13 +0000 | [diff] [blame] | 20 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 21 | /* Debugging macros. */ |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 22 | #if CONFIG(DEBUG_RAM_SETUP) |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 23 | #define PRINTK_DEBUG(x...) printk(BIOS_DEBUG, x) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 24 | #else |
| 25 | #define PRINTK_DEBUG(x...) |
| 26 | #endif |
| 27 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 28 | #define RAM_INITIALIZATION_COMPLETE (1 << 19) |
| 29 | |
| 30 | #define RAM_COMMAND_SELF_REFRESH (0x0 << 16) |
| 31 | #define RAM_COMMAND_NOP (0x1 << 16) |
| 32 | #define RAM_COMMAND_PRECHARGE (0x2 << 16) |
| 33 | #define RAM_COMMAND_MRS (0x3 << 16) |
| 34 | #define RAM_COMMAND_EMRS (0x4 << 16) |
| 35 | #define RAM_COMMAND_CBR (0x6 << 16) |
| 36 | #define RAM_COMMAND_NORMAL (0x7 << 16) |
| 37 | |
| 38 | #define RAM_EMRS_1 (0x0 << 21) |
| 39 | #define RAM_EMRS_2 (0x1 << 21) |
| 40 | #define RAM_EMRS_3 (0x2 << 21) |
| 41 | |
Arthur Heymans | 885c289 | 2016-10-03 17:16:48 +0200 | [diff] [blame] | 42 | #define DEFAULT_PCI_MMIO_SIZE 768 |
Sven Schnelle | 541269b | 2011-02-21 09:39:17 +0000 | [diff] [blame] | 43 | static int get_dimm_spd_address(struct sys_info *sysinfo, int device) |
| 44 | { |
| 45 | if (sysinfo->spd_addresses) |
| 46 | return sysinfo->spd_addresses[device]; |
| 47 | else |
| 48 | return DIMM0 + device; |
| 49 | |
| 50 | } |
| 51 | |
Stefan Reinauer | bc8613e | 2010-08-25 18:35:42 +0000 | [diff] [blame] | 52 | static __attribute__((noinline)) void do_ram_command(u32 command) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 53 | { |
| 54 | u32 reg32; |
| 55 | |
| 56 | reg32 = MCHBAR32(DCC); |
Angel Pons | 3049257 | 2020-06-11 13:24:54 +0200 | [diff] [blame] | 57 | reg32 &= ~((3 << 21) | (1 << 20) | (1 << 19) | (7 << 16)); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 58 | reg32 |= command; |
| 59 | |
| 60 | /* Also set Init Complete */ |
| 61 | if (command == RAM_COMMAND_NORMAL) |
| 62 | reg32 |= RAM_INITIALIZATION_COMPLETE; |
| 63 | |
| 64 | PRINTK_DEBUG(" Sending RAM command 0x%08x", reg32); |
| 65 | |
Elyes HAOUAS | 95cdd9f | 2020-03-26 12:20:38 +0100 | [diff] [blame] | 66 | MCHBAR32(DCC) = reg32; /* This is the actual magic */ |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 67 | |
Stefan Reinauer | 779b3e3 | 2008-11-10 15:43:37 +0000 | [diff] [blame] | 68 | PRINTK_DEBUG("...done\n"); |
Stefan Reinauer | d058ad1 | 2010-08-26 12:43:58 +0000 | [diff] [blame] | 69 | |
| 70 | udelay(1); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 71 | } |
| 72 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 73 | static void ram_read32(u32 offset) |
| 74 | { |
Elyes HAOUAS | 15279a9 | 2016-07-28 21:05:26 +0200 | [diff] [blame] | 75 | PRINTK_DEBUG(" RAM read: %08x\n", offset); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 76 | |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 77 | read32((void *)offset); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 78 | } |
| 79 | |
Stefan Reinauer | 3c0bfaf | 2010-12-27 11:34:57 +0000 | [diff] [blame] | 80 | void sdram_dump_mchbar_registers(void) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 81 | { |
| 82 | int i; |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 83 | printk(BIOS_DEBUG, "Dumping MCHBAR Registers\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 84 | |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 85 | for (i = 0; i < 0xfff; i += 4) { |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 86 | if (MCHBAR32(i) == 0) |
| 87 | continue; |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 88 | printk(BIOS_DEBUG, "0x%04x: 0x%08x\n", i, MCHBAR32(i)); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 89 | } |
| 90 | } |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 91 | |
Stefan Reinauer | 24b4df5 | 2010-01-17 13:47:35 +0000 | [diff] [blame] | 92 | static int memclk(void) |
| 93 | { |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 94 | int offset = CONFIG(NORTHBRIDGE_INTEL_SUBTYPE_I945GM) ? 1 : 0; |
Elyes HAOUAS | c9848a8 | 2016-10-09 20:24:20 +0200 | [diff] [blame] | 95 | |
Stefan Reinauer | 24b4df5 | 2010-01-17 13:47:35 +0000 | [diff] [blame] | 96 | switch (((MCHBAR32(CLKCFG) >> 4) & 7) - offset) { |
| 97 | case 1: return 400; |
| 98 | case 2: return 533; |
| 99 | case 3: return 667; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 100 | default: |
Elyes HAOUAS | 3cd4327 | 2020-03-05 22:01:17 +0100 | [diff] [blame] | 101 | printk(BIOS_DEBUG, "%s: unknown register value %x\n", __func__, |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 102 | ((MCHBAR32(CLKCFG) >> 4) & 7) - offset); |
Stefan Reinauer | 24b4df5 | 2010-01-17 13:47:35 +0000 | [diff] [blame] | 103 | } |
| 104 | return -1; |
| 105 | } |
| 106 | |
Peter Stuge | 76d9143 | 2010-10-01 10:02:33 +0000 | [diff] [blame] | 107 | static u16 fsbclk(void) |
Stefan Reinauer | 24b4df5 | 2010-01-17 13:47:35 +0000 | [diff] [blame] | 108 | { |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 109 | if (CONFIG(NORTHBRIDGE_INTEL_SUBTYPE_I945GM)) { |
Elyes HAOUAS | c9848a8 | 2016-10-09 20:24:20 +0200 | [diff] [blame] | 110 | switch (MCHBAR32(CLKCFG) & 7) { |
| 111 | case 0: return 400; |
| 112 | case 1: return 533; |
| 113 | case 3: return 667; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 114 | default: |
Elyes HAOUAS | 3cd4327 | 2020-03-05 22:01:17 +0100 | [diff] [blame] | 115 | printk(BIOS_DEBUG, "%s: unknown register value %x\n", __func__, |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 116 | MCHBAR32(CLKCFG) & 7); |
Elyes HAOUAS | c9848a8 | 2016-10-09 20:24:20 +0200 | [diff] [blame] | 117 | } |
| 118 | return 0xffff; |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 119 | } else if (CONFIG(NORTHBRIDGE_INTEL_SUBTYPE_I945GC)) { |
Elyes HAOUAS | c9848a8 | 2016-10-09 20:24:20 +0200 | [diff] [blame] | 120 | switch (MCHBAR32(CLKCFG) & 7) { |
| 121 | case 0: return 1066; |
| 122 | case 1: return 533; |
| 123 | case 2: return 800; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 124 | default: |
Elyes HAOUAS | 3cd4327 | 2020-03-05 22:01:17 +0100 | [diff] [blame] | 125 | printk(BIOS_DEBUG, "%s: unknown register value %x\n", __func__, |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 126 | MCHBAR32(CLKCFG) & 7); |
Elyes HAOUAS | c9848a8 | 2016-10-09 20:24:20 +0200 | [diff] [blame] | 127 | } |
| 128 | return 0xffff; |
Stefan Reinauer | 24b4df5 | 2010-01-17 13:47:35 +0000 | [diff] [blame] | 129 | } |
Stefan Reinauer | 24b4df5 | 2010-01-17 13:47:35 +0000 | [diff] [blame] | 130 | } |
Stefan Reinauer | 24b4df5 | 2010-01-17 13:47:35 +0000 | [diff] [blame] | 131 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 132 | static int sdram_capabilities_max_supported_memory_frequency(void) |
| 133 | { |
| 134 | u32 reg32; |
| 135 | |
Patrick Georgi | 77d6683 | 2010-10-01 08:02:45 +0000 | [diff] [blame] | 136 | #if CONFIG_MAXIMUM_SUPPORTED_FREQUENCY |
| 137 | return CONFIG_MAXIMUM_SUPPORTED_FREQUENCY; |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 138 | #endif |
| 139 | |
Angel Pons | 3580d81 | 2020-06-11 14:13:33 +0200 | [diff] [blame] | 140 | reg32 = pci_read_config32(HOST_BRIDGE, 0xe4); /* CAPID0 + 4 */ |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 141 | reg32 &= (7 << 0); |
| 142 | |
| 143 | switch (reg32) { |
| 144 | case 4: return 400; |
| 145 | case 3: return 533; |
| 146 | case 2: return 667; |
| 147 | } |
| 148 | /* Newer revisions of this chipset rather support faster memory clocks, |
| 149 | * so if it's a reserved value, return the fastest memory clock that we |
| 150 | * know of and can handle |
| 151 | */ |
| 152 | return 667; |
| 153 | } |
| 154 | |
| 155 | /** |
| 156 | * @brief determine whether chipset is capable of dual channel interleaved mode |
| 157 | * |
| 158 | * @return 1 if interleaving is supported, 0 otherwise |
| 159 | */ |
| 160 | static int sdram_capabilities_interleave(void) |
| 161 | { |
| 162 | u32 reg32; |
| 163 | |
Angel Pons | 3580d81 | 2020-06-11 14:13:33 +0200 | [diff] [blame] | 164 | reg32 = pci_read_config32(HOST_BRIDGE, 0xe4); /* CAPID0 + 4 */ |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 165 | reg32 >>= 25; |
| 166 | reg32 &= 1; |
| 167 | |
| 168 | return (!reg32); |
| 169 | } |
| 170 | |
| 171 | /** |
| 172 | * @brief determine whether chipset is capable of two memory channels |
| 173 | * |
| 174 | * @return 1 if dual channel operation is supported, 0 otherwise |
| 175 | */ |
| 176 | static int sdram_capabilities_dual_channel(void) |
| 177 | { |
| 178 | u32 reg32; |
| 179 | |
Angel Pons | 3580d81 | 2020-06-11 14:13:33 +0200 | [diff] [blame] | 180 | reg32 = pci_read_config32(HOST_BRIDGE, 0xe4); /* CAPID0 + 4 */ |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 181 | reg32 >>= 24; |
| 182 | reg32 &= 1; |
| 183 | |
| 184 | return (!reg32); |
| 185 | } |
| 186 | |
| 187 | static int sdram_capabilities_enhanced_addressing_xor(void) |
| 188 | { |
| 189 | u8 reg8; |
| 190 | |
Angel Pons | 3580d81 | 2020-06-11 14:13:33 +0200 | [diff] [blame] | 191 | reg8 = pci_read_config8(HOST_BRIDGE, 0xe5); /* CAPID0 + 5 */ |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 192 | reg8 &= (1 << 7); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 193 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 194 | return (!reg8); |
| 195 | } |
| 196 | |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 197 | #define GFX_FREQUENCY_CAP_166MHZ 0x04 |
| 198 | #define GFX_FREQUENCY_CAP_200MHZ 0x03 |
| 199 | #define GFX_FREQUENCY_CAP_250MHZ 0x02 |
| 200 | #define GFX_FREQUENCY_CAP_ALL 0x00 |
| 201 | |
| 202 | static int sdram_capabilities_core_frequencies(void) |
| 203 | { |
| 204 | u8 reg8; |
| 205 | |
Angel Pons | 3580d81 | 2020-06-11 14:13:33 +0200 | [diff] [blame] | 206 | reg8 = pci_read_config8(HOST_BRIDGE, 0xe5); /* CAPID0 + 5 */ |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 207 | reg8 &= (1 << 3) | (1 << 2) | (1 << 1); |
| 208 | reg8 >>= 1; |
| 209 | |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 210 | return reg8; |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 211 | } |
| 212 | |
Stefan Reinauer | bf264e9 | 2010-05-14 19:09:20 +0000 | [diff] [blame] | 213 | static void sdram_detect_errors(struct sys_info *sysinfo) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 214 | { |
| 215 | u8 reg8; |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 216 | u8 do_reset = 0; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 217 | |
Elyes HAOUAS | 32b9a99 | 2019-01-21 14:54:31 +0100 | [diff] [blame] | 218 | reg8 = pci_read_config8(PCI_DEV(0, 0x1f, 0), GEN_PMCON_2); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 219 | |
Angel Pons | 3049257 | 2020-06-11 13:24:54 +0200 | [diff] [blame] | 220 | if (reg8 & ((1 << 7) | (1 << 2))) { |
| 221 | if (reg8 & (1 << 2)) { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 222 | printk(BIOS_DEBUG, "SLP S4# Assertion Width Violation.\n"); |
Stefan Reinauer | f98ad3a | 2010-03-05 18:25:19 +0000 | [diff] [blame] | 223 | /* Write back clears bit 2 */ |
Elyes HAOUAS | 32b9a99 | 2019-01-21 14:54:31 +0100 | [diff] [blame] | 224 | pci_write_config8(PCI_DEV(0, 0x1f, 0), GEN_PMCON_2, reg8); |
Stefan Reinauer | f98ad3a | 2010-03-05 18:25:19 +0000 | [diff] [blame] | 225 | do_reset = 1; |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 226 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 227 | } |
| 228 | |
Angel Pons | 3049257 | 2020-06-11 13:24:54 +0200 | [diff] [blame] | 229 | if (reg8 & (1 << 7)) { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 230 | printk(BIOS_DEBUG, "DRAM initialization was interrupted.\n"); |
Angel Pons | 3049257 | 2020-06-11 13:24:54 +0200 | [diff] [blame] | 231 | reg8 &= ~(1 << 7); |
Elyes HAOUAS | 32b9a99 | 2019-01-21 14:54:31 +0100 | [diff] [blame] | 232 | pci_write_config8(PCI_DEV(0, 0x1f, 0), GEN_PMCON_2, reg8); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 233 | do_reset = 1; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 234 | } |
| 235 | |
| 236 | /* Set SLP_S3# Assertion Stretch Enable */ |
Elyes HAOUAS | 32b9a99 | 2019-01-21 14:54:31 +0100 | [diff] [blame] | 237 | reg8 = pci_read_config8(PCI_DEV(0, 0x1f, 0), GEN_PMCON_3); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 238 | reg8 |= (1 << 3); |
Elyes HAOUAS | 32b9a99 | 2019-01-21 14:54:31 +0100 | [diff] [blame] | 239 | pci_write_config8(PCI_DEV(0, 0x1f, 0), GEN_PMCON_3, reg8); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 240 | |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 241 | if (do_reset) { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 242 | printk(BIOS_DEBUG, "Reset required.\n"); |
Elyes HAOUAS | 420d7e0 | 2019-04-21 18:39:34 +0200 | [diff] [blame] | 243 | full_reset(); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 244 | } |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 245 | } |
| 246 | |
| 247 | /* Set DRAM initialization bit in ICH7 */ |
Angel Pons | e3c68d2 | 2020-06-08 12:09:03 +0200 | [diff] [blame] | 248 | pci_or_config8(PCI_DEV(0, 0x1f, 0), GEN_PMCON_2, 1 << 7); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 249 | |
Peter Stuge | 751508a | 2012-01-27 22:17:09 +0100 | [diff] [blame] | 250 | /* clear self refresh status if check is disabled or not a resume */ |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 251 | if (!CONFIG(CHECK_SLFRCS_ON_RESUME) || sysinfo->boot_path != BOOT_PATH_RESUME) { |
Patrick Georgi | 86a1110 | 2013-03-15 14:11:37 +0100 | [diff] [blame] | 252 | MCHBAR8(SLFRCS) |= 3; |
Stefan Reinauer | bf264e9 | 2010-05-14 19:09:20 +0000 | [diff] [blame] | 253 | } else { |
| 254 | /* Validate self refresh config */ |
| 255 | if (((sysinfo->dimm[0] != SYSINFO_DIMM_NOT_POPULATED) || |
| 256 | (sysinfo->dimm[1] != SYSINFO_DIMM_NOT_POPULATED)) && |
Angel Pons | 3049257 | 2020-06-11 13:24:54 +0200 | [diff] [blame] | 257 | !(MCHBAR8(SLFRCS) & (1 << 0))) { |
Stefan Reinauer | bf264e9 | 2010-05-14 19:09:20 +0000 | [diff] [blame] | 258 | do_reset = 1; |
| 259 | } |
| 260 | if (((sysinfo->dimm[2] != SYSINFO_DIMM_NOT_POPULATED) || |
| 261 | (sysinfo->dimm[3] != SYSINFO_DIMM_NOT_POPULATED)) && |
Angel Pons | 3049257 | 2020-06-11 13:24:54 +0200 | [diff] [blame] | 262 | !(MCHBAR8(SLFRCS) & (1 << 1))) { |
Stefan Reinauer | bf264e9 | 2010-05-14 19:09:20 +0000 | [diff] [blame] | 263 | do_reset = 1; |
| 264 | } |
| 265 | } |
| 266 | |
| 267 | if (do_reset) { |
| 268 | printk(BIOS_DEBUG, "Reset required.\n"); |
Elyes HAOUAS | 420d7e0 | 2019-04-21 18:39:34 +0200 | [diff] [blame] | 269 | full_reset(); |
Stefan Reinauer | bf264e9 | 2010-05-14 19:09:20 +0000 | [diff] [blame] | 270 | } |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 271 | } |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 272 | |
Arthur Heymans | 0ab4904 | 2017-02-06 22:40:14 +0100 | [diff] [blame] | 273 | struct timings { |
| 274 | u32 min_tCLK_cas[8]; |
| 275 | u32 min_tRAS; |
| 276 | u32 min_tRP; |
| 277 | u32 min_tRCD; |
| 278 | u32 min_tWR; |
| 279 | u32 min_tRFC; |
| 280 | u32 max_tRR; |
| 281 | u8 cas_mask; |
| 282 | }; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 283 | |
Arthur Heymans | 0ab4904 | 2017-02-06 22:40:14 +0100 | [diff] [blame] | 284 | /** |
| 285 | * @brief loop over dimms and save maximal timings |
| 286 | */ |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 287 | static void gather_common_timing(struct sys_info *sysinfo, struct timings *saved_timings) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 288 | { |
Arthur Heymans | 0ab4904 | 2017-02-06 22:40:14 +0100 | [diff] [blame] | 289 | |
| 290 | int i, j; |
| 291 | u8 raw_spd[SPD_SIZE_MAX_DDR2]; |
| 292 | u8 dimm_mask = 0; |
| 293 | |
| 294 | memset(saved_timings, 0, sizeof(*saved_timings)); |
| 295 | saved_timings->max_tRR = UINT32_MAX; |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 296 | saved_timings->cas_mask = SPD_CAS_LATENCY_DDR2_3 | SPD_CAS_LATENCY_DDR2_4 |
| 297 | | SPD_CAS_LATENCY_DDR2_5; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 298 | |
| 299 | /** |
| 300 | * i945 supports two DIMMs, in two configurations: |
| 301 | * |
Uwe Hermann | d773fd3 | 2010-11-20 20:23:08 +0000 | [diff] [blame] | 302 | * - single channel with two DIMMs |
| 303 | * - dual channel with one DIMM per channel |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 304 | * |
Uwe Hermann | d773fd3 | 2010-11-20 20:23:08 +0000 | [diff] [blame] | 305 | * In practice dual channel mainboards have their SPD at 0x50/0x52 |
| 306 | * whereas single channel configurations have their SPD at 0x50/0x51. |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 307 | * |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 308 | * The capability register knows a lot about the channel configuration |
Uwe Hermann | d773fd3 | 2010-11-20 20:23:08 +0000 | [diff] [blame] | 309 | * but for now we stick with the information we gather via SPD. |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 310 | */ |
| 311 | |
Arthur Heymans | 0ab4904 | 2017-02-06 22:40:14 +0100 | [diff] [blame] | 312 | printk(BIOS_DEBUG, "This mainboard supports "); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 313 | if (sdram_capabilities_dual_channel()) { |
| 314 | sysinfo->dual_channel = 1; |
Arthur Heymans | 0ab4904 | 2017-02-06 22:40:14 +0100 | [diff] [blame] | 315 | printk(BIOS_DEBUG, "Dual Channel Operation.\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 316 | } else { |
| 317 | sysinfo->dual_channel = 0; |
Arthur Heymans | 0ab4904 | 2017-02-06 22:40:14 +0100 | [diff] [blame] | 318 | printk(BIOS_DEBUG, "only Single Channel Operation.\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 319 | } |
| 320 | |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 321 | for (i = 0; i < (2 * DIMM_SOCKETS); i++) { |
Arthur Heymans | 0ab4904 | 2017-02-06 22:40:14 +0100 | [diff] [blame] | 322 | int device = get_dimm_spd_address(sysinfo, i), bytes_read; |
Arthur Heymans | fc31e44 | 2018-02-12 15:12:34 +0100 | [diff] [blame] | 323 | struct dimm_attr_ddr2_st dimm_info; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 324 | |
| 325 | /* Initialize the socket information with a sane value */ |
| 326 | sysinfo->dimm[i] = SYSINFO_DIMM_NOT_POPULATED; |
| 327 | |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 328 | /* Dual Channel not supported, but Channel 1? Bail out */ |
| 329 | if (!sdram_capabilities_dual_channel() && (i >> 1)) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 330 | continue; |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 331 | |
Kyösti Mälkki | bd65985 | 2020-01-05 20:00:18 +0200 | [diff] [blame] | 332 | if (smbus_read_byte(device, SPD_MEMORY_TYPE) != |
Arthur Heymans | 0ab4904 | 2017-02-06 22:40:14 +0100 | [diff] [blame] | 333 | SPD_MEMORY_TYPE_SDRAM_DDR2) { |
| 334 | printk(BIOS_DEBUG, "DDR II Channel %d Socket %d: N/A\n", |
| 335 | (i >> 1), (i & 1)); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 336 | continue; |
| 337 | } |
| 338 | |
Arthur Heymans | 0ab4904 | 2017-02-06 22:40:14 +0100 | [diff] [blame] | 339 | /* |
| 340 | * spd_decode_ddr2() needs a 128-byte sized array but |
| 341 | * only the first 64 bytes contain data needed for raminit. |
| 342 | */ |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 343 | |
Kyösti Mälkki | c01a505 | 2019-01-30 09:39:23 +0200 | [diff] [blame] | 344 | bytes_read = i2c_eeprom_read(device, 0, 64, raw_spd); |
Arthur Heymans | 0ab4904 | 2017-02-06 22:40:14 +0100 | [diff] [blame] | 345 | printk(BIOS_DEBUG, "Reading SPD using i2c block operation.\n"); |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 346 | if (CONFIG(DEBUG_RAM_SETUP) && bytes_read > 0) |
Arthur Heymans | 0ab4904 | 2017-02-06 22:40:14 +0100 | [diff] [blame] | 347 | hexdump(raw_spd, bytes_read); |
Arthur Heymans | 5661945 | 2017-09-21 09:12:42 +0200 | [diff] [blame] | 348 | if (bytes_read != 64) { |
Arthur Heymans | 0ab4904 | 2017-02-06 22:40:14 +0100 | [diff] [blame] | 349 | /* Try again with SMBUS byte read */ |
| 350 | printk(BIOS_DEBUG, "i2c block operation failed," |
Paul Menzel | 105e368 | 2017-09-21 08:11:05 +0200 | [diff] [blame] | 351 | " trying smbus byte operation.\n"); |
Arthur Heymans | 0ab4904 | 2017-02-06 22:40:14 +0100 | [diff] [blame] | 352 | for (j = 0; j < 64; j++) |
Kyösti Mälkki | bd65985 | 2020-01-05 20:00:18 +0200 | [diff] [blame] | 353 | raw_spd[j] = smbus_read_byte(device, j); |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 354 | if (CONFIG(DEBUG_RAM_SETUP)) |
Arthur Heymans | 0ab4904 | 2017-02-06 22:40:14 +0100 | [diff] [blame] | 355 | hexdump(raw_spd, 64); |
Arthur Heymans | 0ab4904 | 2017-02-06 22:40:14 +0100 | [diff] [blame] | 356 | } |
Arthur Heymans | 5661945 | 2017-09-21 09:12:42 +0200 | [diff] [blame] | 357 | |
| 358 | if (spd_decode_ddr2(&dimm_info, raw_spd) != SPD_STATUS_OK) { |
| 359 | printk(BIOS_WARNING, "Encountered problems with SPD, " |
| 360 | "skipping this DIMM.\n"); |
| 361 | continue; |
| 362 | } |
| 363 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 364 | if (CONFIG(DEBUG_RAM_SETUP)) |
Arthur Heymans | 0ab4904 | 2017-02-06 22:40:14 +0100 | [diff] [blame] | 365 | dram_print_spd_ddr2(&dimm_info); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 366 | |
Arthur Heymans | 0ab4904 | 2017-02-06 22:40:14 +0100 | [diff] [blame] | 367 | if (dimm_info.flags.is_ecc) |
| 368 | die("\nError: ECC memory not supported by this chipset\n"); |
| 369 | |
| 370 | if (spd_dimm_is_registered_ddr2(dimm_info.dimm_type)) |
| 371 | die("\nError: Registered memory not supported by this chipset\n"); |
| 372 | |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 373 | printk(BIOS_DEBUG, "DDR II Channel %d Socket %d: ", (i >> 1), (i & 1)); |
Arthur Heymans | 0ab4904 | 2017-02-06 22:40:14 +0100 | [diff] [blame] | 374 | /** |
| 375 | * There are 5 different possible populations for a DIMM socket: |
| 376 | * 0. x16 double ranked (X16DS) |
| 377 | * 1. x8 double ranked (X8DS) |
| 378 | * 2. x16 single ranked (X16SS) |
| 379 | * 3. x8 double stacked (X8DDS) |
| 380 | * 4. Unpopulated |
| 381 | */ |
| 382 | switch (dimm_info.width) { |
| 383 | case 8: |
| 384 | switch (dimm_info.ranks) { |
| 385 | case 2: |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 386 | printk(BIOS_DEBUG, "x8DDS\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 387 | sysinfo->dimm[i] = SYSINFO_DIMM_X8DDS; |
| 388 | break; |
Arthur Heymans | 0ab4904 | 2017-02-06 22:40:14 +0100 | [diff] [blame] | 389 | case 1: |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 390 | printk(BIOS_DEBUG, "x8DS\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 391 | sysinfo->dimm[i] = SYSINFO_DIMM_X8DS; |
| 392 | break; |
| 393 | default: |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 394 | printk(BIOS_DEBUG, "Unsupported.\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 395 | } |
| 396 | break; |
Arthur Heymans | 0ab4904 | 2017-02-06 22:40:14 +0100 | [diff] [blame] | 397 | case 16: |
| 398 | switch (dimm_info.ranks) { |
| 399 | case 2: |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 400 | printk(BIOS_DEBUG, "x16DS\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 401 | sysinfo->dimm[i] = SYSINFO_DIMM_X16DS; |
| 402 | break; |
Arthur Heymans | 0ab4904 | 2017-02-06 22:40:14 +0100 | [diff] [blame] | 403 | case 1: |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 404 | printk(BIOS_DEBUG, "x16SS\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 405 | sysinfo->dimm[i] = SYSINFO_DIMM_X16SS; |
| 406 | break; |
| 407 | default: |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 408 | printk(BIOS_DEBUG, "Unsupported.\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 409 | } |
| 410 | break; |
| 411 | default: |
Stefan Reinauer | 779b3e3 | 2008-11-10 15:43:37 +0000 | [diff] [blame] | 412 | die("Unsupported DDR-II memory width.\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 413 | } |
| 414 | |
Arthur Heymans | 0ab4904 | 2017-02-06 22:40:14 +0100 | [diff] [blame] | 415 | /* Is the current DIMM a stacked DIMM? */ |
| 416 | if (dimm_info.flags.stacked) |
| 417 | sysinfo->package = SYSINFO_PACKAGE_STACKED; |
| 418 | |
| 419 | if (!dimm_info.flags.bl8) |
Elyes HAOUAS | 95cdd9f | 2020-03-26 12:20:38 +0100 | [diff] [blame] | 420 | die("Only DDR-II RAM with burst length 8 is supported.\n"); |
Arthur Heymans | 0ab4904 | 2017-02-06 22:40:14 +0100 | [diff] [blame] | 421 | |
| 422 | if (dimm_info.ranksize_mb < 128) |
| 423 | die("DDR-II rank size smaller than 128MB is not supported.\n"); |
| 424 | |
| 425 | sysinfo->banksize[i * 2] = dimm_info.ranksize_mb / 32; |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 426 | printk(BIOS_DEBUG, "DIMM %d side 0 = %d MB\n", i, sysinfo->banksize[i * 2] * 32); |
Arthur Heymans | 0ab4904 | 2017-02-06 22:40:14 +0100 | [diff] [blame] | 427 | if (dimm_info.ranks == 2) { |
| 428 | sysinfo->banksize[(i * 2) + 1] = |
| 429 | dimm_info.ranksize_mb / 32; |
| 430 | printk(BIOS_DEBUG, "DIMM %d side 1 = %d MB\n", |
| 431 | i, sysinfo->banksize[(i * 2) + 1] * 32); |
| 432 | } |
| 433 | |
Arthur Heymans | 0ab4904 | 2017-02-06 22:40:14 +0100 | [diff] [blame] | 434 | sysinfo->rows[i] = dimm_info.row_bits; |
| 435 | sysinfo->cols[i] = dimm_info.col_bits; |
| 436 | sysinfo->banks[i] = dimm_info.banks; |
| 437 | |
| 438 | /* int min_tRAS, min_tRP, min_tRCD, min_tWR, min_tRFC; */ |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 439 | saved_timings->min_tRAS = MAX(saved_timings->min_tRAS, dimm_info.tRAS); |
| 440 | saved_timings->min_tRP = MAX(saved_timings->min_tRP, dimm_info.tRP); |
| 441 | saved_timings->min_tRCD = MAX(saved_timings->min_tRCD, dimm_info.tRCD); |
| 442 | saved_timings->min_tWR = MAX(saved_timings->min_tWR, dimm_info.tWR); |
| 443 | saved_timings->min_tRFC = MAX(saved_timings->min_tRFC, dimm_info.tRFC); |
| 444 | saved_timings->max_tRR = MIN(saved_timings->max_tRR, dimm_info.tRR); |
Arthur Heymans | 0ab4904 | 2017-02-06 22:40:14 +0100 | [diff] [blame] | 445 | saved_timings->cas_mask &= dimm_info.cas_supported; |
| 446 | for (j = 0; j < 8; j++) { |
| 447 | if (!(saved_timings->cas_mask & (1 << j))) |
| 448 | saved_timings->min_tCLK_cas[j] = 0; |
| 449 | else |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 450 | saved_timings->min_tCLK_cas[j] = MAX(dimm_info.cycle_time[j], |
Arthur Heymans | 0ab4904 | 2017-02-06 22:40:14 +0100 | [diff] [blame] | 451 | saved_timings->min_tCLK_cas[j]); |
| 452 | } |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 453 | dimm_mask |= (1 << i); |
| 454 | } |
Elyes HAOUAS | 9749a85 | 2018-05-09 19:06:46 +0200 | [diff] [blame] | 455 | if (!dimm_mask) |
Stefan Reinauer | 779b3e3 | 2008-11-10 15:43:37 +0000 | [diff] [blame] | 456 | die("No memory installed.\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 457 | |
Elyes HAOUAS | 9749a85 | 2018-05-09 19:06:46 +0200 | [diff] [blame] | 458 | if (!(dimm_mask & ((1 << DIMM_SOCKETS) - 1))) |
Elyes HAOUAS | 95cdd9f | 2020-03-26 12:20:38 +0100 | [diff] [blame] | 459 | /* FIXME: Possibly does not boot in this case */ |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 460 | printk(BIOS_INFO, "Channel 0 has no memory populated.\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 461 | } |
| 462 | |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 463 | static void choose_tclk(struct sys_info *sysinfo, struct timings *saved_timings) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 464 | { |
Arthur Heymans | 0ab4904 | 2017-02-06 22:40:14 +0100 | [diff] [blame] | 465 | u32 ctrl_min_tclk; |
| 466 | int try_cas; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 467 | |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 468 | ctrl_min_tclk = 2 * 256 * 1000 / sdram_capabilities_max_supported_memory_frequency(); |
Arthur Heymans | 0ab4904 | 2017-02-06 22:40:14 +0100 | [diff] [blame] | 469 | normalize_tck(&ctrl_min_tclk); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 470 | |
Arthur Heymans | 0ab4904 | 2017-02-06 22:40:14 +0100 | [diff] [blame] | 471 | try_cas = spd_get_msbs(saved_timings->cas_mask); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 472 | |
Arthur Heymans | 0ab4904 | 2017-02-06 22:40:14 +0100 | [diff] [blame] | 473 | while (saved_timings->cas_mask & (1 << try_cas) && try_cas > 0) { |
| 474 | sysinfo->cas = try_cas; |
| 475 | sysinfo->tclk = saved_timings->min_tCLK_cas[try_cas]; |
| 476 | if (sysinfo->tclk >= ctrl_min_tclk && |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 477 | saved_timings->min_tCLK_cas[try_cas] != |
| 478 | saved_timings->min_tCLK_cas[try_cas - 1]) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 479 | break; |
Arthur Heymans | 0ab4904 | 2017-02-06 22:40:14 +0100 | [diff] [blame] | 480 | try_cas--; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 481 | } |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 482 | |
Arthur Heymans | 0ab4904 | 2017-02-06 22:40:14 +0100 | [diff] [blame] | 483 | normalize_tck(&sysinfo->tclk); |
| 484 | |
| 485 | if ((sysinfo->cas < 3) || (sysinfo->tclk == 0)) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 486 | die("Could not find common memory frequency and CAS\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 487 | |
Arthur Heymans | 0ab4904 | 2017-02-06 22:40:14 +0100 | [diff] [blame] | 488 | /* |
| 489 | * The loop can still results in a timing too fast for the |
| 490 | * memory controller. |
| 491 | */ |
| 492 | if (sysinfo->tclk < ctrl_min_tclk) |
| 493 | sysinfo->tclk = ctrl_min_tclk; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 494 | |
Arthur Heymans | 0ab4904 | 2017-02-06 22:40:14 +0100 | [diff] [blame] | 495 | switch (sysinfo->tclk) { |
| 496 | case TCK_200MHZ: |
| 497 | sysinfo->memory_frequency = 400; |
| 498 | break; |
| 499 | case TCK_266MHZ: |
| 500 | sysinfo->memory_frequency = 533; |
| 501 | break; |
| 502 | case TCK_333MHZ: |
| 503 | sysinfo->memory_frequency = 667; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 504 | break; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 505 | } |
| 506 | |
Arthur Heymans | 0ab4904 | 2017-02-06 22:40:14 +0100 | [diff] [blame] | 507 | printk(BIOS_DEBUG, |
| 508 | "Memory will be driven at %dMT with CAS=%d clocks\n", |
| 509 | sysinfo->memory_frequency, sysinfo->cas); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 510 | } |
| 511 | |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 512 | static void derive_timings(struct sys_info *sysinfo, struct timings *saved_timings) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 513 | { |
Arthur Heymans | 0ab4904 | 2017-02-06 22:40:14 +0100 | [diff] [blame] | 514 | sysinfo->tras = DIV_ROUND_UP(saved_timings->min_tRAS, sysinfo->tclk); |
| 515 | if (sysinfo->tras > 0x18) |
| 516 | die("DDR-II Module does not support this frequency (tRAS error)\n"); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 517 | |
Arthur Heymans | 0ab4904 | 2017-02-06 22:40:14 +0100 | [diff] [blame] | 518 | sysinfo->trp = DIV_ROUND_UP(saved_timings->min_tRP, sysinfo->tclk); |
| 519 | if (sysinfo->trp > 6) |
| 520 | die("DDR-II Module does not support this frequency (tRP error)\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 521 | |
Arthur Heymans | 0ab4904 | 2017-02-06 22:40:14 +0100 | [diff] [blame] | 522 | sysinfo->trcd = DIV_ROUND_UP(saved_timings->min_tRCD, sysinfo->tclk); |
| 523 | if (sysinfo->trcd > 6) |
| 524 | die("DDR-II Module does not support this frequency (tRCD error)\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 525 | |
Arthur Heymans | 0ab4904 | 2017-02-06 22:40:14 +0100 | [diff] [blame] | 526 | sysinfo->twr = DIV_ROUND_UP(saved_timings->min_tWR, sysinfo->tclk); |
| 527 | if (sysinfo->twr > 5) |
| 528 | die("DDR-II Module does not support this frequency (tWR error)\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 529 | |
Arthur Heymans | 0ab4904 | 2017-02-06 22:40:14 +0100 | [diff] [blame] | 530 | sysinfo->trfc = DIV_ROUND_UP(saved_timings->min_tRFC, sysinfo->tclk); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 531 | |
Arthur Heymans | 0ab4904 | 2017-02-06 22:40:14 +0100 | [diff] [blame] | 532 | printk(BIOS_DEBUG, "tRAS = %d cycles\n", sysinfo->tras); |
| 533 | printk(BIOS_DEBUG, "tRP = %d cycles\n", sysinfo->trp); |
| 534 | printk(BIOS_DEBUG, "tRCD = %d cycles\n", sysinfo->trcd); |
| 535 | printk(BIOS_DEBUG, "tWR = %d cycles\n", sysinfo->twr); |
| 536 | printk(BIOS_DEBUG, "tRFC = %d cycles\n", sysinfo->trfc); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 537 | |
Arthur Heymans | 0ab4904 | 2017-02-06 22:40:14 +0100 | [diff] [blame] | 538 | /* Refresh is slower than 15.6us, use 15.6us */ |
| 539 | /* tRR is decoded in units of 1/256us */ |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 540 | |
Arthur Heymans | 0ab4904 | 2017-02-06 22:40:14 +0100 | [diff] [blame] | 541 | #define T_RR_7_8US 2000000 |
| 542 | #define T_RR_15_6US 4000000 |
| 543 | #define REFRESH_7_8US 1 |
| 544 | #define REFRESH_15_6US 0 |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 545 | |
Arthur Heymans | 0ab4904 | 2017-02-06 22:40:14 +0100 | [diff] [blame] | 546 | if (saved_timings->max_tRR < T_RR_7_8US) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 547 | die("DDR-II module has unsupported refresh value\n"); |
Arthur Heymans | 0ab4904 | 2017-02-06 22:40:14 +0100 | [diff] [blame] | 548 | else if (saved_timings->max_tRR < T_RR_15_6US) |
| 549 | sysinfo->refresh = REFRESH_7_8US; |
| 550 | else |
| 551 | sysinfo->refresh = REFRESH_15_6US; |
Angel Pons | 3049257 | 2020-06-11 13:24:54 +0200 | [diff] [blame] | 552 | printk(BIOS_DEBUG, "Refresh: %s\n", sysinfo->refresh ? "7.8us" : "15.6us"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 553 | } |
| 554 | |
Arthur Heymans | 0ab4904 | 2017-02-06 22:40:14 +0100 | [diff] [blame] | 555 | /** |
| 556 | * @brief Get generic DIMM parameters. |
| 557 | * @param sysinfo Central memory controller information structure |
| 558 | * |
| 559 | * This function gathers several pieces of information for each system DIMM: |
| 560 | * o DIMM width (x8 / x16) |
| 561 | * o DIMM rank (single ranked / dual ranked) |
| 562 | * |
| 563 | * Also, some non-supported scenarios are detected. |
| 564 | */ |
| 565 | |
| 566 | static void sdram_get_dram_configuration(struct sys_info *sysinfo) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 567 | { |
Arthur Heymans | 0ab4904 | 2017-02-06 22:40:14 +0100 | [diff] [blame] | 568 | struct timings saved_timings; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 569 | |
Arthur Heymans | 0ab4904 | 2017-02-06 22:40:14 +0100 | [diff] [blame] | 570 | gather_common_timing(sysinfo, &saved_timings); |
| 571 | choose_tclk(sysinfo, &saved_timings); |
| 572 | derive_timings(sysinfo, &saved_timings); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 573 | } |
| 574 | |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 575 | static void sdram_program_dram_width(struct sys_info *sysinfo) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 576 | { |
Elyes HAOUAS | 0a15fe9 | 2016-09-17 19:12:27 +0200 | [diff] [blame] | 577 | u16 c0dramw = 0, c1dramw = 0; |
Elyes HAOUAS | a4fc7be | 2018-06-30 10:39:24 +0200 | [diff] [blame] | 578 | int i, idx; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 579 | |
| 580 | if (sysinfo->dual_channel) |
| 581 | idx = 2; |
| 582 | else |
| 583 | idx = 1; |
| 584 | |
Elyes HAOUAS | a4fc7be | 2018-06-30 10:39:24 +0200 | [diff] [blame] | 585 | for (i = 0; i < DIMM_SOCKETS; i++) { /* Channel 0 */ |
| 586 | switch (sysinfo->dimm[i]) { |
| 587 | case SYSINFO_DIMM_X16DS: |
Angel Pons | 3049257 | 2020-06-11 13:24:54 +0200 | [diff] [blame] | 588 | c0dramw |= (0x0000) << 4 * (i % 2); |
Elyes HAOUAS | a4fc7be | 2018-06-30 10:39:24 +0200 | [diff] [blame] | 589 | break; |
| 590 | case SYSINFO_DIMM_X8DS: |
Angel Pons | 3049257 | 2020-06-11 13:24:54 +0200 | [diff] [blame] | 591 | c0dramw |= (0x0001) << 4 * (i % 2); |
Elyes HAOUAS | a4fc7be | 2018-06-30 10:39:24 +0200 | [diff] [blame] | 592 | break; |
| 593 | case SYSINFO_DIMM_X16SS: |
Angel Pons | 3049257 | 2020-06-11 13:24:54 +0200 | [diff] [blame] | 594 | c0dramw |= (0x0000) << 4 * (i % 2); |
Elyes HAOUAS | a4fc7be | 2018-06-30 10:39:24 +0200 | [diff] [blame] | 595 | break; |
| 596 | case SYSINFO_DIMM_X8DDS: |
Angel Pons | 3049257 | 2020-06-11 13:24:54 +0200 | [diff] [blame] | 597 | c0dramw |= (0x0005) << 4 * (i % 2); |
Elyes HAOUAS | a4fc7be | 2018-06-30 10:39:24 +0200 | [diff] [blame] | 598 | break; |
| 599 | case SYSINFO_DIMM_NOT_POPULATED: |
Angel Pons | 3049257 | 2020-06-11 13:24:54 +0200 | [diff] [blame] | 600 | c0dramw |= (0x0000) << 4 * (i % 2); |
Elyes HAOUAS | a4fc7be | 2018-06-30 10:39:24 +0200 | [diff] [blame] | 601 | break; |
| 602 | } |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 603 | } |
Elyes HAOUAS | a4fc7be | 2018-06-30 10:39:24 +0200 | [diff] [blame] | 604 | for (i = DIMM_SOCKETS; i < idx * DIMM_SOCKETS; i++) { /* Channel 1 */ |
| 605 | switch (sysinfo->dimm[i]) { |
| 606 | case SYSINFO_DIMM_X16DS: |
Angel Pons | 3049257 | 2020-06-11 13:24:54 +0200 | [diff] [blame] | 607 | c1dramw |= (0x0000) << 4 * (i % 2); |
Elyes HAOUAS | a4fc7be | 2018-06-30 10:39:24 +0200 | [diff] [blame] | 608 | break; |
| 609 | case SYSINFO_DIMM_X8DS: |
Angel Pons | 3049257 | 2020-06-11 13:24:54 +0200 | [diff] [blame] | 610 | c1dramw |= (0x0010) << 4 * (i % 2); |
Elyes HAOUAS | a4fc7be | 2018-06-30 10:39:24 +0200 | [diff] [blame] | 611 | break; |
| 612 | case SYSINFO_DIMM_X16SS: |
Angel Pons | 3049257 | 2020-06-11 13:24:54 +0200 | [diff] [blame] | 613 | c1dramw |= (0x0000) << 4 * (i % 2); |
Elyes HAOUAS | a4fc7be | 2018-06-30 10:39:24 +0200 | [diff] [blame] | 614 | break; |
| 615 | case SYSINFO_DIMM_X8DDS: |
Angel Pons | 3049257 | 2020-06-11 13:24:54 +0200 | [diff] [blame] | 616 | c1dramw |= (0x0050) << 4 * (i % 2); |
Elyes HAOUAS | a4fc7be | 2018-06-30 10:39:24 +0200 | [diff] [blame] | 617 | break; |
| 618 | case SYSINFO_DIMM_NOT_POPULATED: |
Angel Pons | 3049257 | 2020-06-11 13:24:54 +0200 | [diff] [blame] | 619 | c1dramw |= (0x0000) << 4 * (i % 2); |
Elyes HAOUAS | a4fc7be | 2018-06-30 10:39:24 +0200 | [diff] [blame] | 620 | break; |
| 621 | } |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 622 | } |
| 623 | |
| 624 | MCHBAR16(C0DRAMW) = c0dramw; |
| 625 | MCHBAR16(C1DRAMW) = c1dramw; |
| 626 | } |
| 627 | |
| 628 | static void sdram_write_slew_rates(u32 offset, const u32 *slew_rate_table) |
| 629 | { |
| 630 | int i; |
| 631 | |
Elyes HAOUAS | 0a15fe9 | 2016-09-17 19:12:27 +0200 | [diff] [blame] | 632 | for (i = 0; i < 16; i++) |
Angel Pons | 3049257 | 2020-06-11 13:24:54 +0200 | [diff] [blame] | 633 | MCHBAR32(offset+(i * 4)) = slew_rate_table[i]; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 634 | } |
| 635 | |
Stefan Reinauer | 24b4df5 | 2010-01-17 13:47:35 +0000 | [diff] [blame] | 636 | static const u32 dq2030[] = { |
| 637 | 0x08070706, 0x0a090908, 0x0d0c0b0a, 0x12100f0e, |
| 638 | 0x1a181614, 0x22201e1c, 0x2a282624, 0x3934302d, |
| 639 | 0x0a090908, 0x0c0b0b0a, 0x0e0d0d0c, 0x1211100f, |
| 640 | 0x19171513, 0x211f1d1b, 0x2d292623, 0x3f393531 |
| 641 | }; |
| 642 | |
| 643 | static const u32 dq2330[] = { |
| 644 | 0x08070706, 0x0a090908, 0x0d0c0b0a, 0x12100f0e, |
| 645 | 0x1a181614, 0x22201e1c, 0x2a282624, 0x3934302d, |
| 646 | 0x0a090908, 0x0c0b0b0a, 0x0e0d0d0c, 0x1211100f, |
| 647 | 0x19171513, 0x211f1d1b, 0x2d292623, 0x3f393531 |
| 648 | }; |
| 649 | |
| 650 | static const u32 cmd2710[] = { |
| 651 | 0x07060605, 0x0f0d0b09, 0x19171411, 0x1f1f1d1b, |
| 652 | 0x1f1f1f1f, 0x1f1f1f1f, 0x1f1f1f1f, 0x1f1f1f1f, |
| 653 | 0x1110100f, 0x0f0d0b09, 0x19171411, 0x1f1f1d1b, |
| 654 | 0x1f1f1f1f, 0x1f1f1f1f, 0x1f1f1f1f, 0x1f1f1f1f |
| 655 | }; |
| 656 | |
| 657 | static const u32 cmd3210[] = { |
| 658 | 0x0f0d0b0a, 0x17151311, 0x1f1d1b19, 0x1f1f1f1f, |
| 659 | 0x1f1f1f1f, 0x1f1f1f1f, 0x1f1f1f1f, 0x1f1f1f1f, |
| 660 | 0x18171615, 0x1f1f1c1a, 0x1f1f1f1f, 0x1f1f1f1f, |
| 661 | 0x1f1f1f1f, 0x1f1f1f1f, 0x1f1f1f1f, 0x1f1f1f1f |
| 662 | }; |
| 663 | |
| 664 | static const u32 clk2030[] = { |
| 665 | 0x0e0d0d0c, 0x100f0f0e, 0x100f0e0d, 0x15131211, |
| 666 | 0x1d1b1917, 0x2523211f, 0x2a282927, 0x32302e2c, |
| 667 | 0x17161514, 0x1b1a1918, 0x1f1e1d1c, 0x23222120, |
| 668 | 0x27262524, 0x2d2b2928, 0x3533312f, 0x3d3b3937 |
| 669 | }; |
| 670 | |
| 671 | static const u32 ctl3215[] = { |
| 672 | 0x01010000, 0x03020101, 0x07060504, 0x0b0a0908, |
| 673 | 0x100f0e0d, 0x14131211, 0x18171615, 0x1c1b1a19, |
| 674 | 0x05040403, 0x07060605, 0x0a090807, 0x0f0d0c0b, |
| 675 | 0x14131211, 0x18171615, 0x1c1b1a19, 0x201f1e1d |
| 676 | }; |
| 677 | |
| 678 | static const u32 ctl3220[] = { |
| 679 | 0x05040403, 0x07060505, 0x0e0c0a08, 0x1a171411, |
| 680 | 0x2825221f, 0x35322f2b, 0x3e3e3b38, 0x3e3e3e3e, |
| 681 | 0x09080807, 0x0b0a0a09, 0x0f0d0c0b, 0x1b171311, |
| 682 | 0x2825221f, 0x35322f2b, 0x3e3e3b38, 0x3e3e3e3e |
| 683 | }; |
| 684 | |
| 685 | static const u32 nc[] = { |
| 686 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, |
| 687 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, |
| 688 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, |
| 689 | 0x00000000, 0x00000000, 0x00000000, 0x00000000 |
| 690 | }; |
| 691 | |
| 692 | enum { |
| 693 | DQ2030, |
| 694 | DQ2330, |
| 695 | CMD2710, |
| 696 | CMD3210, |
| 697 | CLK2030, |
| 698 | CTL3215, |
| 699 | CTL3220, |
| 700 | NC, |
| 701 | }; |
| 702 | |
| 703 | static const u8 dual_channel_slew_group_lookup[] = { |
| 704 | DQ2030, CMD3210, CTL3215, CTL3215, CLK2030, CLK2030, DQ2030, CMD3210, |
| 705 | DQ2030, CMD3210, CTL3215, CTL3215, CLK2030, CLK2030, DQ2030, CMD3210, |
| 706 | DQ2030, CMD3210, NC, CTL3215, NC, CLK2030, DQ2030, CMD3210, |
| 707 | DQ2030, CMD3210, CTL3215, CTL3215, CLK2030, CLK2030, DQ2030, CMD2710, |
| 708 | DQ2030, CMD3210, NC, CTL3215, NC, CLK2030, NC, NC, |
| 709 | |
| 710 | DQ2030, CMD3210, CTL3215, CTL3215, CLK2030, CLK2030, DQ2030, CMD3210, |
| 711 | DQ2030, CMD3210, CTL3215, NC, CLK2030, NC, DQ2030, CMD3210, |
| 712 | DQ2030, CMD3210, CTL3215, CTL3215, CLK2030, CLK2030, DQ2030, CMD3210, |
| 713 | DQ2030, CMD3210, CTL3215, NC, CLK2030, NC, DQ2030, CMD2710, |
| 714 | DQ2030, CMD3210, CTL3215, NC, CLK2030, NC, NC, NC, |
| 715 | |
| 716 | DQ2030, CMD3210, NC, CTL3215, NC, CLK2030, DQ2030, CMD3210, |
| 717 | DQ2030, CMD3210, CTL3215, CTL3215, CLK2030, CLK2030, DQ2030, CMD3210, |
| 718 | DQ2030, CMD3210, NC, CTL3215, NC, CLK2030, DQ2030, CMD3210, |
| 719 | DQ2030, CMD3210, CTL3215, CTL3215, CLK2030, CLK2030, DQ2030, CMD2710, |
| 720 | DQ2030, CMD3210, NC, CTL3215, NC, CLK2030, NC, NC, |
| 721 | |
| 722 | DQ2030, CMD2710, CTL3215, CTL3215, CLK2030, CLK2030, DQ2030, CMD3210, |
| 723 | DQ2030, CMD2710, CTL3215, NC, CLK2030, NC, DQ2030, CMD3210, |
| 724 | DQ2030, CMD2710, CTL3215, CTL3215, CLK2030, CLK2030, DQ2030, CMD3210, |
| 725 | DQ2030, CMD2710, CTL3215, NC, CLK2030, NC, DQ2030, CMD2710, |
| 726 | DQ2030, CMD2710, CTL3215, NC, CLK2030, NC, NC, NC, |
| 727 | |
| 728 | NC, NC, NC, CTL3215, NC, CLK2030, DQ2030, CMD3210, |
| 729 | NC, NC, CTL3215, NC, CLK2030, NC, DQ2030, CMD3210, |
| 730 | NC, NC, NC, CTL3215, NC, CLK2030, DQ2030, CMD3210, |
| 731 | NC, NC, CTL3215, NC, CLK2030, CLK2030, DQ2030, CMD2710 |
| 732 | }; |
| 733 | |
| 734 | static const u8 single_channel_slew_group_lookup[] = { |
| 735 | DQ2330, CMD3210, CTL3215, CTL3215, CLK2030, CLK2030, DQ2330, CMD3210, |
| 736 | DQ2330, CMD3210, CTL3215, CTL3215, CLK2030, CLK2030, DQ2330, CMD3210, |
| 737 | DQ2330, CMD3210, NC, CTL3215, NC, CLK2030, DQ2330, CMD3210, |
| 738 | DQ2330, CMD3210, CTL3215, CTL3215, CLK2030, CLK2030, DQ2330, CMD3210, |
| 739 | DQ2330, CMD3210, NC, CTL3215, NC, CLK2030, NC, NC, |
| 740 | |
| 741 | DQ2330, CMD3210, CTL3215, CTL3215, CLK2030, CLK2030, DQ2330, CMD3210, |
| 742 | DQ2330, CMD3210, CTL3215, NC, CLK2030, NC, DQ2330, CMD3210, |
| 743 | DQ2330, CMD3210, CTL3215, CTL3215, CLK2030, CLK2030, DQ2330, CMD3210, |
| 744 | DQ2330, CMD3210, CTL3215, NC, CLK2030, NC, DQ2330, CMD3210, |
| 745 | DQ2330, CMD3210, CTL3215, NC, CLK2030, NC, NC, NC, |
| 746 | |
| 747 | DQ2330, CMD3210, NC, CTL3215, NC, CLK2030, DQ2330, CMD3210, |
| 748 | DQ2330, CMD3210, CTL3215, CTL3215, CLK2030, CLK2030, DQ2330, CMD3210, |
| 749 | DQ2330, CMD3210, NC, CTL3215, NC, CLK2030, DQ2330, CMD3210, |
| 750 | DQ2330, CMD3210, CTL3215, CTL3215, CLK2030, CLK2030, DQ2330, CMD3210, |
| 751 | DQ2330, CMD3210, NC, CTL3215, NC, CLK2030, NC, NC, |
| 752 | |
| 753 | DQ2330, CMD3210, CTL3215, CTL3215, CLK2030, CLK2030, DQ2330, CMD3210, |
| 754 | DQ2330, CMD3210, CTL3215, NC, CLK2030, NC, DQ2330, CMD3210, |
| 755 | DQ2330, CMD3210, CTL3215, CTL3215, CLK2030, CLK2030, DQ2330, CMD3210, |
| 756 | DQ2330, CMD3210, CTL3215, NC, CLK2030, NC, DQ2330, CMD3210, |
| 757 | DQ2330, CMD3210, CTL3215, NC, CLK2030, NC, NC, NC, |
| 758 | |
| 759 | DQ2330, NC, NC, CTL3215, NC, CLK2030, DQ2030, CMD3210, |
| 760 | DQ2330, NC, CTL3215, NC, CLK2030, NC, DQ2030, CMD3210, |
| 761 | DQ2330, NC, NC, CTL3215, NC, CLK2030, DQ2030, CMD3210, |
| 762 | DQ2330, NC, CTL3215, NC, CLK2030, CLK2030, DQ2030, CMD3210 |
| 763 | }; |
| 764 | |
| 765 | static const u32 *slew_group_lookup(int dual_channel, int index) |
| 766 | { |
| 767 | const u8 *slew_group; |
| 768 | /* Dual Channel needs different tables. */ |
| 769 | if (dual_channel) |
Elyes HAOUAS | 95cdd9f | 2020-03-26 12:20:38 +0100 | [diff] [blame] | 770 | slew_group = dual_channel_slew_group_lookup; |
Stefan Reinauer | 24b4df5 | 2010-01-17 13:47:35 +0000 | [diff] [blame] | 771 | else |
Elyes HAOUAS | 95cdd9f | 2020-03-26 12:20:38 +0100 | [diff] [blame] | 772 | slew_group = single_channel_slew_group_lookup; |
Stefan Reinauer | 24b4df5 | 2010-01-17 13:47:35 +0000 | [diff] [blame] | 773 | |
| 774 | switch (slew_group[index]) { |
| 775 | case DQ2030: return dq2030; |
| 776 | case DQ2330: return dq2330; |
| 777 | case CMD2710: return cmd2710; |
| 778 | case CMD3210: return cmd3210; |
| 779 | case CLK2030: return clk2030; |
| 780 | case CTL3215: return ctl3215; |
| 781 | case CTL3220: return ctl3220; |
| 782 | case NC: return nc; |
| 783 | } |
| 784 | |
| 785 | return nc; |
| 786 | } |
| 787 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 788 | #if CONFIG(NORTHBRIDGE_INTEL_SUBTYPE_I945GM) |
Stefan Reinauer | 24b4df5 | 2010-01-17 13:47:35 +0000 | [diff] [blame] | 789 | /* Strength multiplier tables */ |
| 790 | static const u8 dual_channel_strength_multiplier[] = { |
| 791 | 0x44, 0x11, 0x11, 0x11, 0x44, 0x44, 0x44, 0x11, |
| 792 | 0x44, 0x11, 0x11, 0x11, 0x44, 0x44, 0x44, 0x11, |
| 793 | 0x44, 0x11, 0x00, 0x11, 0x00, 0x44, 0x44, 0x11, |
| 794 | 0x44, 0x11, 0x11, 0x11, 0x44, 0x44, 0x44, 0x22, |
| 795 | 0x44, 0x11, 0x00, 0x11, 0x00, 0x44, 0x00, 0x00, |
| 796 | 0x44, 0x11, 0x11, 0x11, 0x44, 0x44, 0x44, 0x11, |
| 797 | 0x44, 0x11, 0x11, 0x00, 0x44, 0x00, 0x44, 0x11, |
| 798 | 0x44, 0x11, 0x11, 0x11, 0x44, 0x44, 0x44, 0x11, |
| 799 | 0x44, 0x11, 0x11, 0x00, 0x44, 0x00, 0x44, 0x22, |
| 800 | 0x44, 0x11, 0x11, 0x00, 0x44, 0x00, 0x00, 0x00, |
| 801 | 0x44, 0x11, 0x00, 0x11, 0x00, 0x44, 0x44, 0x11, |
| 802 | 0x44, 0x11, 0x11, 0x11, 0x44, 0x44, 0x44, 0x11, |
| 803 | 0x44, 0x11, 0x00, 0x11, 0x00, 0x44, 0x44, 0x11, |
| 804 | 0x44, 0x11, 0x11, 0x11, 0x44, 0x44, 0x44, 0x22, |
| 805 | 0x44, 0x11, 0x00, 0x11, 0x00, 0x44, 0x00, 0x00, |
| 806 | 0x44, 0x22, 0x11, 0x11, 0x44, 0x44, 0x44, 0x11, |
| 807 | 0x44, 0x22, 0x11, 0x00, 0x44, 0x00, 0x44, 0x11, |
| 808 | 0x44, 0x22, 0x11, 0x11, 0x44, 0x44, 0x44, 0x11, |
| 809 | 0x44, 0x22, 0x11, 0x00, 0x44, 0x00, 0x44, 0x22, |
| 810 | 0x44, 0x22, 0x11, 0x00, 0x44, 0x00, 0x00, 0x00, |
| 811 | 0x00, 0x00, 0x00, 0x11, 0x00, 0x44, 0x44, 0x11, |
| 812 | 0x00, 0x00, 0x11, 0x00, 0x44, 0x00, 0x44, 0x11, |
| 813 | 0x00, 0x00, 0x00, 0x11, 0x00, 0x44, 0x44, 0x11, |
| 814 | 0x00, 0x00, 0x11, 0x00, 0x44, 0x44, 0x44, 0x22 |
| 815 | }; |
| 816 | |
| 817 | static const u8 single_channel_strength_multiplier[] = { |
| 818 | 0x33, 0x11, 0x11, 0x11, 0x44, 0x44, 0x33, 0x11, |
| 819 | 0x33, 0x11, 0x11, 0x11, 0x44, 0x44, 0x33, 0x11, |
| 820 | 0x33, 0x11, 0x00, 0x11, 0x00, 0x44, 0x33, 0x11, |
| 821 | 0x33, 0x11, 0x11, 0x11, 0x44, 0x44, 0x33, 0x11, |
| 822 | 0x33, 0x11, 0x00, 0x11, 0x00, 0x44, 0x00, 0x00, |
| 823 | 0x33, 0x11, 0x11, 0x11, 0x44, 0x44, 0x33, 0x11, |
| 824 | 0x33, 0x11, 0x11, 0x00, 0x44, 0x00, 0x33, 0x11, |
| 825 | 0x33, 0x11, 0x11, 0x11, 0x44, 0x44, 0x33, 0x11, |
| 826 | 0x33, 0x11, 0x11, 0x00, 0x44, 0x00, 0x33, 0x11, |
| 827 | 0x33, 0x11, 0x11, 0x00, 0x44, 0x00, 0x00, 0x00, |
| 828 | 0x33, 0x11, 0x00, 0x11, 0x00, 0x44, 0x33, 0x11, |
| 829 | 0x33, 0x11, 0x11, 0x11, 0x44, 0x44, 0x33, 0x11, |
| 830 | 0x33, 0x11, 0x00, 0x11, 0x00, 0x44, 0x33, 0x11, |
| 831 | 0x33, 0x11, 0x11, 0x11, 0x44, 0x44, 0x33, 0x11, |
| 832 | 0x33, 0x11, 0x00, 0x11, 0x00, 0x44, 0x00, 0x00, |
| 833 | 0x33, 0x11, 0x11, 0x11, 0x44, 0x44, 0x33, 0x11, |
| 834 | 0x33, 0x11, 0x11, 0x00, 0x44, 0x00, 0x33, 0x11, |
| 835 | 0x33, 0x11, 0x11, 0x11, 0x44, 0x44, 0x33, 0x11, |
| 836 | 0x33, 0x11, 0x11, 0x00, 0x44, 0x00, 0x33, 0x11, |
| 837 | 0x33, 0x11, 0x11, 0x00, 0x44, 0x00, 0x00, 0x00, |
| 838 | 0x33, 0x00, 0x00, 0x11, 0x00, 0x44, 0x33, 0x11, |
| 839 | 0x33, 0x00, 0x11, 0x00, 0x44, 0x00, 0x33, 0x11, |
| 840 | 0x33, 0x00, 0x00, 0x11, 0x00, 0x44, 0x33, 0x11, |
| 841 | 0x33, 0x00, 0x11, 0x00, 0x44, 0x44, 0x33, 0x11 |
| 842 | }; |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 843 | #elif CONFIG(NORTHBRIDGE_INTEL_SUBTYPE_I945GC) |
Stefan Reinauer | 24b4df5 | 2010-01-17 13:47:35 +0000 | [diff] [blame] | 844 | static const u8 dual_channel_strength_multiplier[] = { |
| 845 | 0x44, 0x22, 0x00, 0x00, 0x44, 0x44, 0x44, 0x22, |
| 846 | 0x44, 0x22, 0x00, 0x00, 0x44, 0x44, 0x44, 0x22, |
| 847 | 0x44, 0x22, 0x00, 0x00, 0x44, 0x44, 0x44, 0x22, |
| 848 | 0x44, 0x22, 0x00, 0x00, 0x44, 0x44, 0x44, 0x33, |
| 849 | 0x44, 0x22, 0x00, 0x00, 0x44, 0x44, 0x44, 0x00, |
| 850 | 0x44, 0x22, 0x00, 0x00, 0x44, 0x44, 0x44, 0x22, |
| 851 | 0x44, 0x22, 0x00, 0x00, 0x44, 0x44, 0x44, 0x22, |
| 852 | 0x44, 0x22, 0x00, 0x00, 0x44, 0x44, 0x44, 0x22, |
| 853 | 0x44, 0x22, 0x00, 0x00, 0x44, 0x44, 0x44, 0x33, |
| 854 | 0x44, 0x22, 0x00, 0x00, 0x44, 0x44, 0x44, 0x00, |
| 855 | 0x44, 0x22, 0x00, 0x00, 0x44, 0x44, 0x44, 0x22, |
| 856 | 0x44, 0x22, 0x00, 0x00, 0x44, 0x44, 0x44, 0x22, |
| 857 | 0x44, 0x22, 0x00, 0x00, 0x44, 0x44, 0x44, 0x22, |
| 858 | 0x44, 0x22, 0x00, 0x00, 0x44, 0x44, 0x44, 0x33, |
| 859 | 0x44, 0x22, 0x00, 0x00, 0x44, 0x44, 0x44, 0x00, |
| 860 | 0x44, 0x33, 0x00, 0x00, 0x44, 0x44, 0x44, 0x22, |
| 861 | 0x44, 0x33, 0x00, 0x00, 0x44, 0x44, 0x44, 0x22, |
| 862 | 0x44, 0x33, 0x00, 0x00, 0x44, 0x44, 0x44, 0x22, |
| 863 | 0x44, 0x33, 0x00, 0x00, 0x44, 0x44, 0x44, 0x33, |
| 864 | 0x44, 0x33, 0x00, 0x00, 0x44, 0x44, 0x44, 0x00, |
| 865 | 0x44, 0x00, 0x00, 0x00, 0x44, 0x44, 0x44, 0x22, |
| 866 | 0x44, 0x00, 0x00, 0x00, 0x44, 0x44, 0x44, 0x22, |
| 867 | 0x44, 0x00, 0x00, 0x00, 0x44, 0x44, 0x44, 0x22, |
| 868 | 0x44, 0x00, 0x00, 0x00, 0x44, 0x44, 0x44, 0x33 |
| 869 | }; |
| 870 | |
| 871 | static const u8 single_channel_strength_multiplier[] = { |
| 872 | 0x44, 0x33, 0x00, 0x00, 0x44, 0x44, 0x44, 0x00, |
| 873 | 0x44, 0x44, 0x00, 0x00, 0x44, 0x44, 0x44, 0x00, |
| 874 | 0x44, 0x33, 0x00, 0x00, 0x44, 0x44, 0x44, 0x00, |
| 875 | 0x44, 0x55, 0x00, 0x00, 0x44, 0x44, 0x44, 0x00, |
| 876 | 0x44, 0x22, 0x00, 0x00, 0x44, 0x44, 0x44, 0x00, |
| 877 | 0x44, 0x44, 0x00, 0x00, 0x44, 0x44, 0x44, 0x00, |
| 878 | 0x44, 0x55, 0x00, 0x00, 0x44, 0x44, 0x44, 0x00, |
| 879 | 0x44, 0x44, 0x00, 0x00, 0x44, 0x44, 0x44, 0x00, |
| 880 | 0x44, 0x88, 0x00, 0x00, 0x44, 0x44, 0x44, 0x00, |
| 881 | 0x44, 0x22, 0x00, 0x00, 0x44, 0x44, 0x44, 0x00, |
| 882 | 0x44, 0x33, 0x00, 0x00, 0x44, 0x44, 0x44, 0x00, |
| 883 | 0x44, 0x44, 0x00, 0x00, 0x44, 0x44, 0x44, 0x00, |
| 884 | 0x44, 0x33, 0x00, 0x00, 0x44, 0x44, 0x44, 0x00, |
| 885 | 0x44, 0x55, 0x00, 0x00, 0x44, 0x44, 0x44, 0x00, |
| 886 | 0x44, 0x22, 0x00, 0x00, 0x44, 0x44, 0x44, 0x00, |
| 887 | 0x44, 0x55, 0x00, 0x00, 0x44, 0x44, 0x44, 0x00, |
| 888 | 0x44, 0x88, 0x00, 0x00, 0x44, 0x44, 0x44, 0x00, |
| 889 | 0x44, 0x55, 0x00, 0x00, 0x44, 0x44, 0x44, 0x00, |
| 890 | 0x44, 0x88, 0x00, 0x00, 0x44, 0x44, 0x44, 0x00, |
| 891 | 0x44, 0x33, 0x00, 0x00, 0x44, 0x44, 0x44, 0x00, |
| 892 | 0x44, 0x22, 0x00, 0x00, 0x44, 0x44, 0x44, 0x00, |
| 893 | 0x44, 0x22, 0x00, 0x00, 0x44, 0x44, 0x44, 0x00, |
| 894 | 0x44, 0x22, 0x00, 0x00, 0x44, 0x44, 0x44, 0x00, |
| 895 | 0x44, 0x33, 0x00, 0x00, 0x44, 0x44, 0x44, 0x00 |
| 896 | }; |
| 897 | #endif |
| 898 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 899 | static void sdram_rcomp_buffer_strength_and_slew(struct sys_info *sysinfo) |
| 900 | { |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 901 | const u8 *strength_multiplier; |
Stefan Reinauer | 24b4df5 | 2010-01-17 13:47:35 +0000 | [diff] [blame] | 902 | int idx, dual_channel; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 903 | |
| 904 | /* Set Strength Multipliers */ |
| 905 | |
| 906 | /* Dual Channel needs different tables. */ |
| 907 | if (sdram_capabilities_dual_channel()) { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 908 | printk(BIOS_DEBUG, "Programming Dual Channel RCOMP\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 909 | strength_multiplier = dual_channel_strength_multiplier; |
Stefan Reinauer | 24b4df5 | 2010-01-17 13:47:35 +0000 | [diff] [blame] | 910 | dual_channel = 1; |
Elyes HAOUAS | 95cdd9f | 2020-03-26 12:20:38 +0100 | [diff] [blame] | 911 | idx = 5 * sysinfo->dimm[0] + sysinfo->dimm[2]; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 912 | } else { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 913 | printk(BIOS_DEBUG, "Programming Single Channel RCOMP\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 914 | strength_multiplier = single_channel_strength_multiplier; |
Stefan Reinauer | 24b4df5 | 2010-01-17 13:47:35 +0000 | [diff] [blame] | 915 | dual_channel = 0; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 916 | idx = 5 * sysinfo->dimm[0] + sysinfo->dimm[1]; |
| 917 | } |
| 918 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 919 | printk(BIOS_DEBUG, "Table Index: %d\n", idx); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 920 | |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 921 | MCHBAR8(G1SC) = strength_multiplier[idx * 8 + 0]; |
| 922 | MCHBAR8(G2SC) = strength_multiplier[idx * 8 + 1]; |
| 923 | MCHBAR8(G3SC) = strength_multiplier[idx * 8 + 2]; |
| 924 | MCHBAR8(G4SC) = strength_multiplier[idx * 8 + 3]; |
| 925 | MCHBAR8(G5SC) = strength_multiplier[idx * 8 + 4]; |
| 926 | MCHBAR8(G6SC) = strength_multiplier[idx * 8 + 5]; |
| 927 | MCHBAR8(G7SC) = strength_multiplier[idx * 8 + 6]; |
| 928 | MCHBAR8(G8SC) = strength_multiplier[idx * 8 + 7]; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 929 | |
| 930 | /* Channel 0 */ |
Stefan Reinauer | 24b4df5 | 2010-01-17 13:47:35 +0000 | [diff] [blame] | 931 | sdram_write_slew_rates(G1SRPUT, slew_group_lookup(dual_channel, idx * 8 + 0)); |
| 932 | sdram_write_slew_rates(G2SRPUT, slew_group_lookup(dual_channel, idx * 8 + 1)); |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 933 | if ((slew_group_lookup(dual_channel, idx * 8 + 2) != nc) && |
| 934 | (sysinfo->package == SYSINFO_PACKAGE_STACKED)) |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 935 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 936 | sdram_write_slew_rates(G3SRPUT, ctl3220); |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 937 | else |
Stefan Reinauer | 24b4df5 | 2010-01-17 13:47:35 +0000 | [diff] [blame] | 938 | sdram_write_slew_rates(G3SRPUT, slew_group_lookup(dual_channel, idx * 8 + 2)); |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 939 | |
Stefan Reinauer | 24b4df5 | 2010-01-17 13:47:35 +0000 | [diff] [blame] | 940 | sdram_write_slew_rates(G4SRPUT, slew_group_lookup(dual_channel, idx * 8 + 3)); |
| 941 | sdram_write_slew_rates(G5SRPUT, slew_group_lookup(dual_channel, idx * 8 + 4)); |
| 942 | sdram_write_slew_rates(G6SRPUT, slew_group_lookup(dual_channel, idx * 8 + 5)); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 943 | |
| 944 | /* Channel 1 */ |
| 945 | if (sysinfo->dual_channel) { |
Stefan Reinauer | 24b4df5 | 2010-01-17 13:47:35 +0000 | [diff] [blame] | 946 | sdram_write_slew_rates(G7SRPUT, slew_group_lookup(dual_channel, idx * 8 + 6)); |
| 947 | sdram_write_slew_rates(G8SRPUT, slew_group_lookup(dual_channel, idx * 8 + 7)); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 948 | } else { |
| 949 | sdram_write_slew_rates(G7SRPUT, nc); |
| 950 | sdram_write_slew_rates(G8SRPUT, nc); |
| 951 | } |
| 952 | } |
| 953 | |
| 954 | static void sdram_enable_rcomp(void) |
| 955 | { |
| 956 | u32 reg32; |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 957 | /* Enable Global Periodic RCOMP */ |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 958 | udelay(300); |
| 959 | reg32 = MCHBAR32(GBRCOMPCTL); |
| 960 | reg32 &= ~(1 << 23); |
| 961 | MCHBAR32(GBRCOMPCTL) = reg32; |
| 962 | } |
| 963 | |
| 964 | static void sdram_program_dll_timings(struct sys_info *sysinfo) |
| 965 | { |
Elyes HAOUAS | 44a3066 | 2017-02-23 13:14:44 +0100 | [diff] [blame] | 966 | u32 channeldll = 0; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 967 | int i; |
| 968 | |
Elyes HAOUAS | 3842498 | 2016-08-21 12:01:04 +0200 | [diff] [blame] | 969 | printk(BIOS_DEBUG, "Programming DLL Timings...\n"); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 970 | |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 971 | MCHBAR16(DQSMT) &= ~((3 << 12) | (1 << 10) | (0xf << 0)); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 972 | MCHBAR16(DQSMT) |= (1 << 13) | (0xc << 0); |
| 973 | |
| 974 | /* We drive both channels with the same speed */ |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 975 | if (CONFIG(NORTHBRIDGE_INTEL_SUBTYPE_I945GM)) { |
Elyes HAOUAS | 39bfc6c | 2016-10-31 10:49:33 +0100 | [diff] [blame] | 976 | switch (sysinfo->memory_frequency) { |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 977 | case 400: |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 978 | channeldll = 0x26262626; |
| 979 | break; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 980 | case 533: |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 981 | channeldll = 0x22222222; |
| 982 | break; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 983 | case 667: |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 984 | channeldll = 0x11111111; |
| 985 | break; |
Elyes HAOUAS | 39bfc6c | 2016-10-31 10:49:33 +0100 | [diff] [blame] | 986 | } |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 987 | } else if (CONFIG(NORTHBRIDGE_INTEL_SUBTYPE_I945GC)) { |
Elyes HAOUAS | 39bfc6c | 2016-10-31 10:49:33 +0100 | [diff] [blame] | 988 | switch (sysinfo->memory_frequency) { |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 989 | case 400: |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 990 | channeldll = 0x33333333; |
| 991 | break; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 992 | case 533: |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 993 | channeldll = 0x24242424; |
| 994 | break; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 995 | case 667: |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 996 | channeldll = 0x25252525; |
| 997 | break; |
Elyes HAOUAS | 39bfc6c | 2016-10-31 10:49:33 +0100 | [diff] [blame] | 998 | } |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 999 | } |
| 1000 | |
Elyes HAOUAS | 0a15fe9 | 2016-09-17 19:12:27 +0200 | [diff] [blame] | 1001 | for (i = 0; i < 4; i++) { |
Elyes HAOUAS | 44a3066 | 2017-02-23 13:14:44 +0100 | [diff] [blame] | 1002 | MCHBAR32(C0R0B00DQST + (i * 0x10) + 0) = channeldll; |
| 1003 | MCHBAR32(C0R0B00DQST + (i * 0x10) + 4) = channeldll; |
| 1004 | MCHBAR32(C1R0B00DQST + (i * 0x10) + 0) = channeldll; |
| 1005 | MCHBAR32(C1R0B00DQST + (i * 0x10) + 4) = channeldll; |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 1006 | if (CONFIG(NORTHBRIDGE_INTEL_SUBTYPE_I945GC)) { |
Elyes HAOUAS | 44a3066 | 2017-02-23 13:14:44 +0100 | [diff] [blame] | 1007 | MCHBAR8(C0R0B00DQST + (i * 0x10) + 8) = channeldll & 0xff; |
| 1008 | MCHBAR8(C1R0B00DQST + (i * 0x10) + 8) = channeldll & 0xff; |
Paul Menzel | bce7e33 | 2017-02-22 18:46:27 +0100 | [diff] [blame] | 1009 | } |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1010 | } |
| 1011 | } |
| 1012 | |
| 1013 | static void sdram_force_rcomp(void) |
| 1014 | { |
| 1015 | u32 reg32; |
| 1016 | u8 reg8; |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1017 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1018 | reg32 = MCHBAR32(ODTC); |
| 1019 | reg32 |= (1 << 28); |
| 1020 | MCHBAR32(ODTC) = reg32; |
| 1021 | |
| 1022 | reg32 = MCHBAR32(SMSRCTL); |
| 1023 | reg32 |= (1 << 0); |
| 1024 | MCHBAR32(SMSRCTL) = reg32; |
| 1025 | |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1026 | /* Start initial RCOMP */ |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1027 | reg32 = MCHBAR32(GBRCOMPCTL); |
| 1028 | reg32 |= (1 << 8); |
| 1029 | MCHBAR32(GBRCOMPCTL) = reg32; |
| 1030 | |
| 1031 | reg8 = i945_silicon_revision(); |
| 1032 | if ((reg8 == 0 && (MCHBAR32(DCC) & (3 << 0)) == 0) || (reg8 == 1)) { |
| 1033 | reg32 = MCHBAR32(GBRCOMPCTL); |
| 1034 | reg32 |= (3 << 5); |
| 1035 | MCHBAR32(GBRCOMPCTL) = reg32; |
| 1036 | } |
| 1037 | } |
| 1038 | |
| 1039 | static void sdram_initialize_system_memory_io(struct sys_info *sysinfo) |
| 1040 | { |
| 1041 | u8 reg8; |
| 1042 | u32 reg32; |
| 1043 | |
Elyes HAOUAS | 3842498 | 2016-08-21 12:01:04 +0200 | [diff] [blame] | 1044 | printk(BIOS_DEBUG, "Initializing System Memory IO...\n"); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1045 | /* Enable Data Half Clock Pushout */ |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1046 | reg8 = MCHBAR8(C0HCTC); |
| 1047 | reg8 &= ~0x1f; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1048 | reg8 |= (1 << 0); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1049 | MCHBAR8(C0HCTC) = reg8; |
| 1050 | |
| 1051 | reg8 = MCHBAR8(C1HCTC); |
| 1052 | reg8 &= ~0x1f; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1053 | reg8 |= (1 << 0); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1054 | MCHBAR8(C1HCTC) = reg8; |
| 1055 | |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1056 | MCHBAR16(WDLLBYPMODE) &= ~((1 << 9) | (1 << 6) | (1 << 4) | (1 << 3) | (1 << 1)); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1057 | MCHBAR16(WDLLBYPMODE) |= (1 << 8) | (1 << 7) | (1 << 5) | (1 << 2) | (1 << 0); |
| 1058 | |
| 1059 | MCHBAR8(C0WDLLCMC) = 0; |
| 1060 | MCHBAR8(C1WDLLCMC) = 0; |
| 1061 | |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1062 | /* Program RCOMP Settings */ |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1063 | sdram_program_dram_width(sysinfo); |
| 1064 | |
| 1065 | sdram_rcomp_buffer_strength_and_slew(sysinfo); |
| 1066 | |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1067 | /* Indicate that RCOMP programming is done */ |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1068 | reg32 = MCHBAR32(GBRCOMPCTL); |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1069 | reg32 &= ~((1 << 29) | (1 << 26) | (3 << 21) | (3 << 2)); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1070 | reg32 |= (3 << 27) | (3 << 0); |
| 1071 | MCHBAR32(GBRCOMPCTL) = reg32; |
| 1072 | |
| 1073 | MCHBAR32(GBRCOMPCTL) |= (1 << 10); |
| 1074 | |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1075 | /* Program DLL Timings */ |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1076 | sdram_program_dll_timings(sysinfo); |
| 1077 | |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1078 | /* Force RCOMP cycle */ |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1079 | sdram_force_rcomp(); |
| 1080 | } |
| 1081 | |
| 1082 | static void sdram_enable_system_memory_io(struct sys_info *sysinfo) |
| 1083 | { |
| 1084 | u32 reg32; |
| 1085 | |
Elyes HAOUAS | 3842498 | 2016-08-21 12:01:04 +0200 | [diff] [blame] | 1086 | printk(BIOS_DEBUG, "Enabling System Memory IO...\n"); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1087 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1088 | reg32 = MCHBAR32(RCVENMT); |
| 1089 | reg32 &= ~(0x3f << 6); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1090 | MCHBAR32(RCVENMT) = reg32; /* [11:6] = 0 */ |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1091 | |
| 1092 | reg32 |= (1 << 11) | (1 << 9); |
| 1093 | MCHBAR32(RCVENMT) = reg32; |
| 1094 | |
| 1095 | reg32 = MCHBAR32(DRTST); |
| 1096 | reg32 |= (1 << 3) | (1 << 2); |
| 1097 | MCHBAR32(DRTST) = reg32; |
| 1098 | |
| 1099 | reg32 = MCHBAR32(DRTST); |
| 1100 | reg32 |= (1 << 6) | (1 << 4); |
| 1101 | MCHBAR32(DRTST) = reg32; |
| 1102 | |
Stefan Reinauer | bf264e9 | 2010-05-14 19:09:20 +0000 | [diff] [blame] | 1103 | asm volatile ("nop; nop;" ::: "memory"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1104 | |
| 1105 | reg32 = MCHBAR32(DRTST); |
| 1106 | |
| 1107 | /* Is channel 0 populated? */ |
| 1108 | if (sysinfo->dimm[0] != SYSINFO_DIMM_NOT_POPULATED || |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 1109 | sysinfo->dimm[1] != SYSINFO_DIMM_NOT_POPULATED) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1110 | reg32 |= (1 << 7) | (1 << 5); |
| 1111 | else |
| 1112 | reg32 |= (1 << 31); |
| 1113 | |
| 1114 | /* Is channel 1 populated? */ |
| 1115 | if (sysinfo->dimm[2] != SYSINFO_DIMM_NOT_POPULATED || |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 1116 | sysinfo->dimm[3] != SYSINFO_DIMM_NOT_POPULATED) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1117 | reg32 |= (1 << 9) | (1 << 8); |
| 1118 | else |
| 1119 | reg32 |= (1 << 30); |
| 1120 | |
| 1121 | MCHBAR32(DRTST) = reg32; |
| 1122 | |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1123 | /* Activate DRAM Channel IO Buffers */ |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1124 | if (sysinfo->dimm[0] != SYSINFO_DIMM_NOT_POPULATED || |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 1125 | sysinfo->dimm[1] != SYSINFO_DIMM_NOT_POPULATED) { |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1126 | reg32 = MCHBAR32(C0DRC1); |
| 1127 | reg32 |= (1 << 8); |
| 1128 | MCHBAR32(C0DRC1) = reg32; |
| 1129 | } |
| 1130 | if (sysinfo->dimm[2] != SYSINFO_DIMM_NOT_POPULATED || |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 1131 | sysinfo->dimm[3] != SYSINFO_DIMM_NOT_POPULATED) { |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1132 | reg32 = MCHBAR32(C1DRC1); |
| 1133 | reg32 |= (1 << 8); |
| 1134 | MCHBAR32(C1DRC1) = reg32; |
| 1135 | } |
| 1136 | } |
| 1137 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1138 | static int sdram_program_row_boundaries(struct sys_info *sysinfo) |
| 1139 | { |
| 1140 | int i; |
Arthur Heymans | 885c289 | 2016-10-03 17:16:48 +0200 | [diff] [blame] | 1141 | int cum0, cum1, tolud, tom, pci_mmio_size; |
| 1142 | const struct device *dev; |
| 1143 | const struct northbridge_intel_i945_config *cfg = NULL; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1144 | |
Paul Menzel | 84283bc | 2014-07-17 08:16:04 +0200 | [diff] [blame] | 1145 | printk(BIOS_DEBUG, "Setting RAM size...\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1146 | |
| 1147 | cum0 = 0; |
Elyes HAOUAS | 12df950 | 2016-08-23 21:29:48 +0200 | [diff] [blame] | 1148 | for (i = 0; i < 2 * DIMM_SOCKETS; i++) { |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1149 | cum0 += sysinfo->banksize[i]; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1150 | MCHBAR8(C0DRB0+i) = cum0; |
| 1151 | } |
| 1152 | |
| 1153 | /* Assume we continue in Channel 1 where we stopped in Channel 0 */ |
| 1154 | cum1 = cum0; |
| 1155 | |
| 1156 | /* Exception: Interleaved starts from the beginning */ |
| 1157 | if (sysinfo->interleaved) |
| 1158 | cum1 = 0; |
| 1159 | |
Elyes HAOUAS | 12df950 | 2016-08-23 21:29:48 +0200 | [diff] [blame] | 1160 | for (i = 0; i < 2 * DIMM_SOCKETS; i++) { |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1161 | cum1 += sysinfo->banksize[i + 4]; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1162 | MCHBAR8(C1DRB0+i) = cum1; |
| 1163 | } |
| 1164 | |
| 1165 | /* Set TOLUD Top Of Low Usable DRAM */ |
| 1166 | if (sysinfo->interleaved) |
| 1167 | tolud = (cum0 + cum1) << 1; |
| 1168 | else |
Elyes HAOUAS | 95cdd9f | 2020-03-26 12:20:38 +0100 | [diff] [blame] | 1169 | tolud = (cum1 ? cum1 : cum0) << 1; |
Stefan Reinauer | 779b3e3 | 2008-11-10 15:43:37 +0000 | [diff] [blame] | 1170 | |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1171 | /* The TOM register has a different format */ |
| 1172 | tom = tolud >> 3; |
| 1173 | |
| 1174 | /* Limit the value of TOLUD to leave some space for PCI memory. */ |
Kyösti Mälkki | c70eed1 | 2018-05-22 02:18:00 +0300 | [diff] [blame] | 1175 | dev = pcidev_on_root(0, 0); |
Arthur Heymans | 885c289 | 2016-10-03 17:16:48 +0200 | [diff] [blame] | 1176 | if (dev) |
| 1177 | cfg = dev->chip_info; |
| 1178 | |
| 1179 | /* Don't use pci mmio sizes smaller than 768M */ |
| 1180 | if (!cfg || cfg->pci_mmio_size <= DEFAULT_PCI_MMIO_SIZE) |
| 1181 | pci_mmio_size = DEFAULT_PCI_MMIO_SIZE; |
| 1182 | else |
| 1183 | pci_mmio_size = cfg->pci_mmio_size; |
| 1184 | |
| 1185 | tolud = MIN(((4096 - pci_mmio_size) / 128) << 3, tolud); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1186 | |
Angel Pons | 3580d81 | 2020-06-11 14:13:33 +0200 | [diff] [blame] | 1187 | pci_write_config8(HOST_BRIDGE, TOLUD, tolud); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1188 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 1189 | printk(BIOS_DEBUG, "C0DRB = 0x%08x\n", MCHBAR32(C0DRB0)); |
| 1190 | printk(BIOS_DEBUG, "C1DRB = 0x%08x\n", MCHBAR32(C1DRB0)); |
Angel Pons | 3580d81 | 2020-06-11 14:13:33 +0200 | [diff] [blame] | 1191 | printk(BIOS_DEBUG, "TOLUD = 0x%04x\n", pci_read_config8(HOST_BRIDGE, TOLUD)); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1192 | |
Angel Pons | 3580d81 | 2020-06-11 14:13:33 +0200 | [diff] [blame] | 1193 | pci_write_config16(HOST_BRIDGE, TOM, tom); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1194 | |
| 1195 | return 0; |
| 1196 | } |
| 1197 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1198 | static int sdram_set_row_attributes(struct sys_info *sysinfo) |
| 1199 | { |
Arthur Heymans | 0ab4904 | 2017-02-06 22:40:14 +0100 | [diff] [blame] | 1200 | int i; |
Elyes HAOUAS | 0a15fe9 | 2016-09-17 19:12:27 +0200 | [diff] [blame] | 1201 | u16 dra0 = 0, dra1 = 0, dra = 0; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1202 | |
Elyes HAOUAS | 3842498 | 2016-08-21 12:01:04 +0200 | [diff] [blame] | 1203 | printk(BIOS_DEBUG, "Setting row attributes...\n"); |
Elyes HAOUAS | 0a15fe9 | 2016-09-17 19:12:27 +0200 | [diff] [blame] | 1204 | for (i = 0; i < 2 * DIMM_SOCKETS; i++) { |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1205 | u8 columnsrows; |
| 1206 | |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1207 | if (sysinfo->dimm[i] == SYSINFO_DIMM_NOT_POPULATED) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1208 | continue; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1209 | |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 1210 | columnsrows = (sysinfo->rows[i] & 0x0f) | (sysinfo->cols[i] & 0xf) << 4; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1211 | |
| 1212 | switch (columnsrows) { |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1213 | case 0x9d: |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 1214 | dra = 2; |
| 1215 | break; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1216 | case 0xad: |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 1217 | dra = 3; |
| 1218 | break; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1219 | case 0xbd: |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 1220 | dra = 4; |
| 1221 | break; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1222 | case 0xae: |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 1223 | dra = 3; |
| 1224 | break; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1225 | case 0xbe: |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 1226 | dra = 4; |
| 1227 | break; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1228 | default: |
| 1229 | die("Unsupported Rows/Columns. (DRA)"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1230 | } |
| 1231 | |
| 1232 | /* Double Sided DIMMs? */ |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1233 | if (sysinfo->banksize[(2 * i) + 1] != 0) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1234 | dra = (dra << 4) | dra; |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1235 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1236 | if (i < DIMM_SOCKETS) |
Angel Pons | 3049257 | 2020-06-11 13:24:54 +0200 | [diff] [blame] | 1237 | dra0 |= (dra << (i * 8)); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1238 | else |
Angel Pons | 3049257 | 2020-06-11 13:24:54 +0200 | [diff] [blame] | 1239 | dra1 |= (dra << ((i - DIMM_SOCKETS) * 8)); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1240 | } |
| 1241 | |
| 1242 | MCHBAR16(C0DRA0) = dra0; |
| 1243 | MCHBAR16(C1DRA0) = dra1; |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1244 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 1245 | printk(BIOS_DEBUG, "C0DRA = 0x%04x\n", dra0); |
| 1246 | printk(BIOS_DEBUG, "C1DRA = 0x%04x\n", dra1); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1247 | |
| 1248 | return 0; |
| 1249 | } |
| 1250 | |
| 1251 | static void sdram_set_bank_architecture(struct sys_info *sysinfo) |
| 1252 | { |
| 1253 | u32 off32; |
| 1254 | int i; |
| 1255 | |
| 1256 | MCHBAR16(C1BNKARC) &= 0xff00; |
| 1257 | MCHBAR16(C0BNKARC) &= 0xff00; |
| 1258 | |
| 1259 | off32 = C0BNKARC; |
Elyes HAOUAS | 0a15fe9 | 2016-09-17 19:12:27 +0200 | [diff] [blame] | 1260 | for (i = 0; i < 2 * DIMM_SOCKETS; i++) { |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1261 | /* Switch to second channel */ |
| 1262 | if (i == DIMM_SOCKETS) |
| 1263 | off32 = C1BNKARC; |
| 1264 | |
| 1265 | if (sysinfo->dimm[i] == SYSINFO_DIMM_NOT_POPULATED) |
| 1266 | continue; |
| 1267 | |
| 1268 | if (sysinfo->banks[i] != 8) |
| 1269 | continue; |
| 1270 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 1271 | printk(BIOS_SPEW, "DIMM%d has 8 banks.\n", i); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1272 | |
| 1273 | if (i & 1) |
| 1274 | MCHBAR16(off32) |= 0x50; |
| 1275 | else |
| 1276 | MCHBAR16(off32) |= 0x05; |
| 1277 | } |
| 1278 | } |
| 1279 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1280 | static void sdram_program_refresh_rate(struct sys_info *sysinfo) |
| 1281 | { |
| 1282 | u32 reg32; |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1283 | |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1284 | if (sysinfo->refresh == REFRESH_7_8US) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1285 | reg32 = (2 << 8); /* Refresh enabled at 7.8us */ |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1286 | else |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1287 | reg32 = (1 << 8); /* Refresh enabled at 15.6us */ |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1288 | |
| 1289 | MCHBAR32(C0DRC0) &= ~(7 << 8); |
| 1290 | MCHBAR32(C0DRC0) |= reg32; |
| 1291 | |
| 1292 | MCHBAR32(C1DRC0) &= ~(7 << 8); |
| 1293 | MCHBAR32(C1DRC0) |= reg32; |
| 1294 | } |
| 1295 | |
| 1296 | static void sdram_program_cke_tristate(struct sys_info *sysinfo) |
| 1297 | { |
| 1298 | u32 reg32; |
| 1299 | int i; |
| 1300 | |
| 1301 | reg32 = MCHBAR32(C0DRC1); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1302 | |
Elyes HAOUAS | 0a15fe9 | 2016-09-17 19:12:27 +0200 | [diff] [blame] | 1303 | for (i = 0; i < 4; i++) { |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1304 | if (sysinfo->banksize[i] == 0) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1305 | reg32 |= (1 << (16 + i)); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1306 | } |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1307 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1308 | reg32 |= (1 << 12); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1309 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1310 | reg32 |= (1 << 11); |
| 1311 | MCHBAR32(C0DRC1) = reg32; |
| 1312 | |
Elyes HAOUAS | 95cdd9f | 2020-03-26 12:20:38 +0100 | [diff] [blame] | 1313 | /* Do we have to do this if we're in Single Channel Mode? */ |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1314 | reg32 = MCHBAR32(C1DRC1); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1315 | |
Elyes HAOUAS | 0a15fe9 | 2016-09-17 19:12:27 +0200 | [diff] [blame] | 1316 | for (i = 4; i < 8; i++) { |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1317 | if (sysinfo->banksize[i] == 0) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1318 | reg32 |= (1 << (12 + i)); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1319 | } |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1320 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1321 | reg32 |= (1 << 12); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1322 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1323 | reg32 |= (1 << 11); |
| 1324 | MCHBAR32(C1DRC1) = reg32; |
| 1325 | } |
| 1326 | |
| 1327 | static void sdram_program_odt_tristate(struct sys_info *sysinfo) |
| 1328 | { |
| 1329 | u32 reg32; |
| 1330 | int i; |
| 1331 | |
| 1332 | reg32 = MCHBAR32(C0DRC2); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1333 | |
Elyes HAOUAS | 0a15fe9 | 2016-09-17 19:12:27 +0200 | [diff] [blame] | 1334 | for (i = 0; i < 4; i++) { |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1335 | if (sysinfo->banksize[i] == 0) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1336 | reg32 |= (1 << (24 + i)); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1337 | } |
| 1338 | MCHBAR32(C0DRC2) = reg32; |
| 1339 | |
| 1340 | reg32 = MCHBAR32(C1DRC2); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1341 | |
Elyes HAOUAS | 0a15fe9 | 2016-09-17 19:12:27 +0200 | [diff] [blame] | 1342 | for (i = 4; i < 8; i++) { |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1343 | if (sysinfo->banksize[i] == 0) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1344 | reg32 |= (1 << (20 + i)); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1345 | } |
| 1346 | MCHBAR32(C1DRC2) = reg32; |
| 1347 | } |
| 1348 | |
| 1349 | static void sdram_set_timing_and_control(struct sys_info *sysinfo) |
| 1350 | { |
Arthur Heymans | 2502723 | 2017-02-12 23:34:39 +0100 | [diff] [blame] | 1351 | u32 reg32, tRD_min; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1352 | u32 tWTR; |
| 1353 | u32 temp_drt; |
| 1354 | int i, page_size; |
| 1355 | |
Edward O'Callaghan | 2f237c1 | 2014-05-25 06:24:39 +1000 | [diff] [blame] | 1356 | static const u8 cas_table[] = { |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1357 | 2, 1, 0, 3 |
| 1358 | }; |
| 1359 | |
| 1360 | reg32 = MCHBAR32(C0DRC0); |
| 1361 | reg32 |= (1 << 2); /* Burst Length 8 */ |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1362 | reg32 &= ~((1 << 13) | (1 << 12)); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1363 | MCHBAR32(C0DRC0) = reg32; |
| 1364 | |
| 1365 | reg32 = MCHBAR32(C1DRC0); |
| 1366 | reg32 |= (1 << 2); /* Burst Length 8 */ |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1367 | reg32 &= ~((1 << 13) | (1 << 12)); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1368 | MCHBAR32(C1DRC0) = reg32; |
| 1369 | |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 1370 | if (!sysinfo->dual_channel && sysinfo->dimm[1] != SYSINFO_DIMM_NOT_POPULATED) { |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1371 | reg32 = MCHBAR32(C0DRC0); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1372 | reg32 |= (1 << 15); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1373 | MCHBAR32(C0DRC0) = reg32; |
| 1374 | } |
| 1375 | |
| 1376 | sdram_program_refresh_rate(sysinfo); |
| 1377 | |
| 1378 | sdram_program_cke_tristate(sysinfo); |
| 1379 | |
| 1380 | sdram_program_odt_tristate(sysinfo); |
| 1381 | |
| 1382 | /* Calculate DRT0 */ |
| 1383 | |
| 1384 | temp_drt = 0; |
| 1385 | |
| 1386 | /* B2B Write Precharge (same bank) = CL-1 + BL/2 + tWR */ |
| 1387 | reg32 = (sysinfo->cas - 1) + (BURSTLENGTH / 2) + sysinfo->twr; |
| 1388 | temp_drt |= (reg32 << 28); |
| 1389 | |
| 1390 | /* Write Auto Precharge (same bank) = CL-1 + BL/2 + tWR + tRP */ |
| 1391 | reg32 += sysinfo->trp; |
| 1392 | temp_drt |= (reg32 << 4); |
| 1393 | |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1394 | if (sysinfo->memory_frequency == 667) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1395 | tWTR = 3; /* 667MHz */ |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1396 | else |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1397 | tWTR = 2; /* 400 and 533 */ |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1398 | |
| 1399 | /* B2B Write to Read Command Spacing */ |
| 1400 | reg32 = (sysinfo->cas - 1) + (BURSTLENGTH / 2) + tWTR; |
| 1401 | temp_drt |= (reg32 << 24); |
| 1402 | |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1403 | /* CxDRT0 [23:22], [21:20], [19:18] [16] have fixed values */ |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1404 | temp_drt |= ((1 << 22) | (3 << 20) | (1 << 18) | (0 << 16)); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1405 | |
Arthur Heymans | 2502723 | 2017-02-12 23:34:39 +0100 | [diff] [blame] | 1406 | /* |
| 1407 | * tRD is the delay the memory controller is waiting on the FSB, |
| 1408 | * in mclk domain. |
| 1409 | * This parameter is important for stability and performance. |
| 1410 | * Those values might not be optimal but seem stable. |
| 1411 | */ |
| 1412 | tRD_min = sysinfo->cas; |
Arthur Heymans | e189761 | 2016-10-15 23:29:18 +0200 | [diff] [blame] | 1413 | switch (sysinfo->fsb_frequency) { |
Elyes HAOUAS | 95cdd9f | 2020-03-26 12:20:38 +0100 | [diff] [blame] | 1414 | case 533: |
Arthur Heymans | e189761 | 2016-10-15 23:29:18 +0200 | [diff] [blame] | 1415 | break; |
Elyes HAOUAS | 95cdd9f | 2020-03-26 12:20:38 +0100 | [diff] [blame] | 1416 | case 667: |
| 1417 | tRD_min += 1; |
Arthur Heymans | e189761 | 2016-10-15 23:29:18 +0200 | [diff] [blame] | 1418 | break; |
Elyes HAOUAS | 95cdd9f | 2020-03-26 12:20:38 +0100 | [diff] [blame] | 1419 | case 800: |
| 1420 | tRD_min += 2; |
| 1421 | break; |
| 1422 | case 1066: |
| 1423 | tRD_min += 3; |
Arthur Heymans | e189761 | 2016-10-15 23:29:18 +0200 | [diff] [blame] | 1424 | break; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1425 | } |
Arthur Heymans | e189761 | 2016-10-15 23:29:18 +0200 | [diff] [blame] | 1426 | |
Arthur Heymans | 2502723 | 2017-02-12 23:34:39 +0100 | [diff] [blame] | 1427 | temp_drt |= (tRD_min << 11); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1428 | |
| 1429 | /* Read Auto Precharge to Activate */ |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1430 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1431 | temp_drt |= (8 << 0); |
| 1432 | |
| 1433 | MCHBAR32(C0DRT0) = temp_drt; |
| 1434 | MCHBAR32(C1DRT0) = temp_drt; |
| 1435 | |
| 1436 | /* Calculate DRT1 */ |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1437 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1438 | temp_drt = MCHBAR32(C0DRT1) & 0x00020088; |
| 1439 | |
| 1440 | /* DRAM RASB Precharge */ |
| 1441 | temp_drt |= (sysinfo->trp - 2) << 0; |
| 1442 | |
| 1443 | /* DRAM RASB to CASB Delay */ |
| 1444 | temp_drt |= (sysinfo->trcd - 2) << 4; |
| 1445 | |
| 1446 | /* CASB Latency */ |
| 1447 | temp_drt |= (cas_table[sysinfo->cas - 3]) << 8; |
| 1448 | |
| 1449 | /* Refresh Cycle Time */ |
| 1450 | temp_drt |= (sysinfo->trfc) << 10; |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1451 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1452 | /* Pre-All to Activate Delay */ |
| 1453 | temp_drt |= (0 << 16); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1454 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1455 | /* Precharge to Precharge Delay stays at 1 clock */ |
| 1456 | temp_drt |= (0 << 18); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1457 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1458 | /* Activate to Precharge Delay */ |
| 1459 | temp_drt |= (sysinfo->tras << 19); |
| 1460 | |
| 1461 | /* Read to Precharge (tRTP) */ |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1462 | if (sysinfo->memory_frequency == 667) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1463 | temp_drt |= (1 << 28); |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1464 | else |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1465 | temp_drt |= (0 << 28); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1466 | |
| 1467 | /* Determine page size */ |
| 1468 | reg32 = 0; |
| 1469 | page_size = 1; /* Default: 1k pagesize */ |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1470 | for (i = 0; i < 2*DIMM_SOCKETS; i++) { |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1471 | if (sysinfo->dimm[i] == SYSINFO_DIMM_X16DS || |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 1472 | sysinfo->dimm[i] == SYSINFO_DIMM_X16SS) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1473 | page_size = 2; /* 2k pagesize */ |
| 1474 | } |
| 1475 | |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1476 | if (sysinfo->memory_frequency == 533 && page_size == 2) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1477 | reg32 = 1; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1478 | if (sysinfo->memory_frequency == 667) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1479 | reg32 = page_size; |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1480 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1481 | temp_drt |= (reg32 << 30); |
| 1482 | |
| 1483 | MCHBAR32(C0DRT1) = temp_drt; |
| 1484 | MCHBAR32(C1DRT1) = temp_drt; |
| 1485 | |
| 1486 | /* Program DRT2 */ |
| 1487 | reg32 = MCHBAR32(C0DRT2); |
| 1488 | reg32 &= ~(1 << 8); |
| 1489 | MCHBAR32(C0DRT2) = reg32; |
| 1490 | |
| 1491 | reg32 = MCHBAR32(C1DRT2); |
| 1492 | reg32 &= ~(1 << 8); |
| 1493 | MCHBAR32(C1DRT2) = reg32; |
| 1494 | |
| 1495 | /* Calculate DRT3 */ |
| 1496 | temp_drt = MCHBAR32(C0DRT3) & ~0x07ffffff; |
| 1497 | |
| 1498 | /* Get old tRFC value */ |
| 1499 | reg32 = MCHBAR32(C0DRT1) >> 10; |
| 1500 | reg32 &= 0x3f; |
| 1501 | |
| 1502 | /* 788nS - tRFC */ |
| 1503 | switch (sysinfo->memory_frequency) { |
| 1504 | case 400: /* 5nS */ |
| 1505 | reg32 = ((78800 / 500) - reg32) & 0x1ff; |
| 1506 | reg32 |= (0x8c << 16) | (0x0c << 10); /* 1 us */ |
| 1507 | break; |
| 1508 | case 533: /* 3.75nS */ |
| 1509 | reg32 = ((78800 / 375) - reg32) & 0x1ff; |
| 1510 | reg32 |= (0xba << 16) | (0x10 << 10); /* 1 us */ |
| 1511 | break; |
| 1512 | case 667: /* 3nS */ |
| 1513 | reg32 = ((78800 / 300) - reg32) & 0x1ff; |
| 1514 | reg32 |= (0xe9 << 16) | (0x14 << 10); /* 1 us */ |
| 1515 | break; |
| 1516 | } |
| 1517 | |
| 1518 | temp_drt |= reg32; |
| 1519 | |
| 1520 | MCHBAR32(C0DRT3) = temp_drt; |
| 1521 | MCHBAR32(C1DRT3) = temp_drt; |
| 1522 | } |
| 1523 | |
| 1524 | static void sdram_set_channel_mode(struct sys_info *sysinfo) |
| 1525 | { |
| 1526 | u32 reg32; |
| 1527 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 1528 | printk(BIOS_DEBUG, "Setting mode of operation for memory channels..."); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1529 | |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1530 | if (sdram_capabilities_interleave() && |
Elyes HAOUAS | 95cdd9f | 2020-03-26 12:20:38 +0100 | [diff] [blame] | 1531 | ((sysinfo->banksize[0] + sysinfo->banksize[1] + |
| 1532 | sysinfo->banksize[2] + sysinfo->banksize[3]) == |
| 1533 | (sysinfo->banksize[4] + sysinfo->banksize[5] + |
| 1534 | sysinfo->banksize[6] + sysinfo->banksize[7]))) { |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1535 | /* Both channels equipped with DIMMs of the same size */ |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1536 | sysinfo->interleaved = 1; |
| 1537 | } else { |
| 1538 | sysinfo->interleaved = 0; |
| 1539 | } |
| 1540 | |
| 1541 | reg32 = MCHBAR32(DCC); |
| 1542 | reg32 &= ~(7 << 0); |
| 1543 | |
Elyes HAOUAS | 12df950 | 2016-08-23 21:29:48 +0200 | [diff] [blame] | 1544 | if (sysinfo->interleaved) { |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1545 | /* Dual Channel Interleaved */ |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 1546 | printk(BIOS_DEBUG, "Dual Channel Interleaved.\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1547 | reg32 |= (1 << 1); |
| 1548 | } else if (sysinfo->dimm[0] == SYSINFO_DIMM_NOT_POPULATED && |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 1549 | sysinfo->dimm[1] == SYSINFO_DIMM_NOT_POPULATED) { |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1550 | /* Channel 1 only */ |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 1551 | printk(BIOS_DEBUG, "Single Channel 1 only.\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1552 | reg32 |= (1 << 2); |
Elyes HAOUAS | 75da1fb | 2017-02-16 18:59:13 +0100 | [diff] [blame] | 1553 | } else if (sdram_capabilities_dual_channel() && |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 1554 | (sysinfo->dimm[2] != SYSINFO_DIMM_NOT_POPULATED || |
| 1555 | sysinfo->dimm[3] != SYSINFO_DIMM_NOT_POPULATED)) { |
Martin Roth | 128c104 | 2016-11-18 09:29:03 -0700 | [diff] [blame] | 1556 | /* Dual Channel Asymmetric */ |
| 1557 | printk(BIOS_DEBUG, "Dual Channel Asymmetric.\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1558 | reg32 |= (1 << 0); |
| 1559 | } else { |
| 1560 | /* All bits 0 means Single Channel 0 operation */ |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 1561 | printk(BIOS_DEBUG, "Single Channel 0 only.\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1562 | } |
| 1563 | |
Stefan Reinauer | bf264e9 | 2010-05-14 19:09:20 +0000 | [diff] [blame] | 1564 | /* Now disable channel XORing */ |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1565 | reg32 |= (1 << 10); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1566 | |
| 1567 | MCHBAR32(DCC) = reg32; |
| 1568 | |
Elyes HAOUAS | 0a15fe9 | 2016-09-17 19:12:27 +0200 | [diff] [blame] | 1569 | PRINTK_DEBUG("DCC = 0x%08x\n", MCHBAR32(DCC)); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1570 | } |
| 1571 | |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1572 | static void sdram_program_pll_settings(struct sys_info *sysinfo) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1573 | { |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1574 | MCHBAR32(PLLMON) = 0x80800000; |
| 1575 | |
Stefan Reinauer | 24b4df5 | 2010-01-17 13:47:35 +0000 | [diff] [blame] | 1576 | sysinfo->fsb_frequency = fsbclk(); |
Peter Stuge | 76d9143 | 2010-10-01 10:02:33 +0000 | [diff] [blame] | 1577 | if (sysinfo->fsb_frequency == 0xffff) |
Stefan Reinauer | 24b4df5 | 2010-01-17 13:47:35 +0000 | [diff] [blame] | 1578 | die("Unsupported FSB speed"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1579 | |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1580 | /* Program CPCTL according to FSB speed */ |
| 1581 | /* Only write the lower byte */ |
| 1582 | switch (sysinfo->fsb_frequency) { |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1583 | case 400: |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 1584 | MCHBAR8(CPCTL) = 0x90; |
| 1585 | break; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1586 | case 533: |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 1587 | MCHBAR8(CPCTL) = 0x95; |
| 1588 | break; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1589 | case 667: |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 1590 | MCHBAR8(CPCTL) = 0x8d; |
| 1591 | break; |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1592 | } |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1593 | |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1594 | MCHBAR16(CPCTL) &= ~(1 << 11); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1595 | |
Paul Menzel | 0ce5ebf | 2013-10-21 21:22:09 +0200 | [diff] [blame] | 1596 | MCHBAR16(CPCTL); /* Read back register to activate settings */ |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1597 | } |
| 1598 | |
| 1599 | static void sdram_program_graphics_frequency(struct sys_info *sysinfo) |
| 1600 | { |
Elyes HAOUAS | 95cdd9f | 2020-03-26 12:20:38 +0100 | [diff] [blame] | 1601 | u8 reg8; |
Elyes HAOUAS | 95cdd9f | 2020-03-26 12:20:38 +0100 | [diff] [blame] | 1602 | u8 freq, second_vco, voltage; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1603 | |
| 1604 | #define CRCLK_166MHz 0x00 |
| 1605 | #define CRCLK_200MHz 0x01 |
| 1606 | #define CRCLK_250MHz 0x03 |
| 1607 | #define CRCLK_400MHz 0x05 |
| 1608 | |
| 1609 | #define CDCLK_200MHz 0x00 |
| 1610 | #define CDCLK_320MHz 0x40 |
| 1611 | |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1612 | #define VOLTAGE_1_05 0x00 |
| 1613 | #define VOLTAGE_1_50 0x01 |
| 1614 | |
Paul Menzel | daf9e50 | 2014-07-15 23:49:16 +0200 | [diff] [blame] | 1615 | printk(BIOS_DEBUG, "Setting Graphics Frequency...\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1616 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 1617 | printk(BIOS_DEBUG, "FSB: %d MHz ", sysinfo->fsb_frequency); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1618 | |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1619 | voltage = VOLTAGE_1_05; |
| 1620 | if (MCHBAR32(DFT_STRAP1) & (1 << 20)) |
| 1621 | voltage = VOLTAGE_1_50; |
Angel Pons | 3049257 | 2020-06-11 13:24:54 +0200 | [diff] [blame] | 1622 | printk(BIOS_DEBUG, "Voltage: %s ", (voltage == VOLTAGE_1_05) ? "1.05V" : "1.5V"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1623 | |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1624 | /* Gate graphics hardware for frequency change */ |
Angel Pons | 3049257 | 2020-06-11 13:24:54 +0200 | [diff] [blame] | 1625 | reg8 = (1 << 3) | (1 << 1); /* disable crclk, gate cdclk */ |
Angel Pons | 3580d81 | 2020-06-11 14:13:33 +0200 | [diff] [blame] | 1626 | pci_write_config8(IGD_DEV, GCFC + 1, reg8); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1627 | |
| 1628 | /* Get graphics frequency capabilities */ |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1629 | reg8 = sdram_capabilities_core_frequencies(); |
| 1630 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1631 | freq = CRCLK_250MHz; |
| 1632 | switch (reg8) { |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1633 | case GFX_FREQUENCY_CAP_ALL: |
| 1634 | if (voltage == VOLTAGE_1_05) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1635 | freq = CRCLK_250MHz; |
| 1636 | else |
Stefan Reinauer | bf264e9 | 2010-05-14 19:09:20 +0000 | [diff] [blame] | 1637 | freq = CRCLK_400MHz; /* 1.5V requires 400MHz */ |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1638 | break; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1639 | case GFX_FREQUENCY_CAP_250MHZ: |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 1640 | freq = CRCLK_250MHz; |
| 1641 | break; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1642 | case GFX_FREQUENCY_CAP_200MHZ: |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 1643 | freq = CRCLK_200MHz; |
| 1644 | break; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1645 | case GFX_FREQUENCY_CAP_166MHZ: |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 1646 | freq = CRCLK_166MHz; |
| 1647 | break; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1648 | } |
| 1649 | |
| 1650 | if (freq != CRCLK_400MHz) { |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1651 | /* What chipset are we? Force 166MHz for GMS */ |
Angel Pons | 3580d81 | 2020-06-11 14:13:33 +0200 | [diff] [blame] | 1652 | reg8 = (pci_read_config8(HOST_BRIDGE, 0xe7) & 0x70) >> 4; |
Elyes HAOUAS | 0a15fe9 | 2016-09-17 19:12:27 +0200 | [diff] [blame] | 1653 | if (reg8 == 2) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1654 | freq = CRCLK_166MHz; |
| 1655 | } |
| 1656 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 1657 | printk(BIOS_DEBUG, "Render: "); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1658 | switch (freq) { |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1659 | case CRCLK_166MHz: |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 1660 | printk(BIOS_DEBUG, "166MHz"); |
| 1661 | break; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1662 | case CRCLK_200MHz: |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 1663 | printk(BIOS_DEBUG, "200MHz"); |
| 1664 | break; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1665 | case CRCLK_250MHz: |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 1666 | printk(BIOS_DEBUG, "250MHz"); |
| 1667 | break; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1668 | case CRCLK_400MHz: |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 1669 | printk(BIOS_DEBUG, "400MHz"); |
| 1670 | break; |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1671 | } |
| 1672 | |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1673 | if (i945_silicon_revision() == 0) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1674 | sysinfo->mvco4x = 1; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1675 | else |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1676 | sysinfo->mvco4x = 0; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1677 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1678 | second_vco = 0; |
| 1679 | |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1680 | if (voltage == VOLTAGE_1_50) { |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1681 | second_vco = 1; |
Elyes HAOUAS | 95cdd9f | 2020-03-26 12:20:38 +0100 | [diff] [blame] | 1682 | } else if ((i945_silicon_revision() > 0) && (freq == CRCLK_250MHz)) { |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1683 | u16 mem = sysinfo->memory_frequency; |
| 1684 | u16 fsb = sysinfo->fsb_frequency; |
| 1685 | |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1686 | if ((fsb == 667 && mem == 533) || |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 1687 | (fsb == 533 && mem == 533) || |
| 1688 | (fsb == 533 && mem == 400)) { |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1689 | second_vco = 1; |
| 1690 | } |
| 1691 | |
| 1692 | if (fsb == 667 && mem == 533) |
| 1693 | sysinfo->mvco4x = 1; |
| 1694 | } |
| 1695 | |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1696 | if (second_vco) |
Elyes HAOUAS | 0a15fe9 | 2016-09-17 19:12:27 +0200 | [diff] [blame] | 1697 | sysinfo->clkcfg_bit7 = 1; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1698 | else |
Elyes HAOUAS | 0a15fe9 | 2016-09-17 19:12:27 +0200 | [diff] [blame] | 1699 | sysinfo->clkcfg_bit7 = 0; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1700 | |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1701 | /* Graphics Core Render Clock */ |
Angel Pons | 3580d81 | 2020-06-11 14:13:33 +0200 | [diff] [blame] | 1702 | pci_update_config16(IGD_DEV, GCFC, ~((7 << 0) | (1 << 13)), freq); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1703 | |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1704 | /* Graphics Core Display Clock */ |
Angel Pons | 3580d81 | 2020-06-11 14:13:33 +0200 | [diff] [blame] | 1705 | reg8 = pci_read_config8(IGD_DEV, GCFC); |
Angel Pons | e3c68d2 | 2020-06-08 12:09:03 +0200 | [diff] [blame] | 1706 | reg8 &= ~((1 << 7) | (7 << 4)); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1707 | |
| 1708 | if (voltage == VOLTAGE_1_05) { |
| 1709 | reg8 |= CDCLK_200MHz; |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 1710 | printk(BIOS_DEBUG, " Display: 200MHz\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1711 | } else { |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1712 | reg8 |= CDCLK_320MHz; |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 1713 | printk(BIOS_DEBUG, " Display: 320MHz\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1714 | } |
Angel Pons | 3580d81 | 2020-06-11 14:13:33 +0200 | [diff] [blame] | 1715 | pci_write_config8(IGD_DEV, GCFC, reg8); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1716 | |
Angel Pons | 3580d81 | 2020-06-11 14:13:33 +0200 | [diff] [blame] | 1717 | reg8 = pci_read_config8(IGD_DEV, GCFC + 1); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1718 | |
Angel Pons | e3c68d2 | 2020-06-08 12:09:03 +0200 | [diff] [blame] | 1719 | reg8 |= (1 << 3) | (1 << 1); |
Angel Pons | 3580d81 | 2020-06-11 14:13:33 +0200 | [diff] [blame] | 1720 | pci_write_config8(IGD_DEV, GCFC + 1, reg8); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1721 | |
| 1722 | reg8 |= 0x0f; |
Angel Pons | 3580d81 | 2020-06-11 14:13:33 +0200 | [diff] [blame] | 1723 | pci_write_config8(IGD_DEV, GCFC + 1, reg8); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1724 | |
| 1725 | /* Ungate core render and display clocks */ |
| 1726 | reg8 &= 0xf0; |
Angel Pons | 3580d81 | 2020-06-11 14:13:33 +0200 | [diff] [blame] | 1727 | pci_write_config8(IGD_DEV, GCFC + 1, reg8); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1728 | } |
| 1729 | |
| 1730 | static void sdram_program_memory_frequency(struct sys_info *sysinfo) |
| 1731 | { |
| 1732 | u32 clkcfg; |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 1733 | u8 offset = CONFIG(NORTHBRIDGE_INTEL_SUBTYPE_I945GM) ? 1 : 0; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1734 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 1735 | printk(BIOS_DEBUG, "Setting Memory Frequency... "); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1736 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1737 | clkcfg = MCHBAR32(CLKCFG); |
| 1738 | |
Elyes HAOUAS | 0a15fe9 | 2016-09-17 19:12:27 +0200 | [diff] [blame] | 1739 | printk(BIOS_DEBUG, "CLKCFG = 0x%08x, ", clkcfg); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1740 | |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1741 | clkcfg &= ~((1 << 12) | (1 << 7) | (7 << 4)); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1742 | |
| 1743 | if (sysinfo->mvco4x) { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 1744 | printk(BIOS_DEBUG, "MVCO 4x, "); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1745 | clkcfg &= ~(1 << 12); |
| 1746 | } |
| 1747 | |
| 1748 | if (sysinfo->clkcfg_bit7) { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 1749 | printk(BIOS_DEBUG, "second VCO, "); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1750 | clkcfg |= (1 << 7); |
| 1751 | } |
| 1752 | |
| 1753 | switch (sysinfo->memory_frequency) { |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1754 | case 400: |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 1755 | clkcfg |= ((1 + offset) << 4); |
| 1756 | break; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1757 | case 533: |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 1758 | clkcfg |= ((2 + offset) << 4); |
| 1759 | break; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1760 | case 667: |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 1761 | clkcfg |= ((3 + offset) << 4); |
| 1762 | break; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1763 | default: |
| 1764 | die("Target Memory Frequency Error"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1765 | } |
| 1766 | |
| 1767 | if (MCHBAR32(CLKCFG) == clkcfg) { |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 1768 | printk(BIOS_DEBUG, "ok (unchanged)\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1769 | return; |
| 1770 | } |
| 1771 | |
| 1772 | MCHBAR32(CLKCFG) = clkcfg; |
| 1773 | |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 1774 | /* Make sure the following code is in the cache before we execute it. */ |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1775 | goto cache_code; |
| 1776 | vco_update: |
Angel Pons | e3c68d2 | 2020-06-08 12:09:03 +0200 | [diff] [blame] | 1777 | pci_and_config8(PCI_DEV(0, 0x1f, 0), GEN_PMCON_2, (u8)~(1 << 7)); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1778 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1779 | clkcfg &= ~(1 << 10); |
| 1780 | MCHBAR32(CLKCFG) = clkcfg; |
| 1781 | clkcfg |= (1 << 10); |
| 1782 | MCHBAR32(CLKCFG) = clkcfg; |
| 1783 | |
Stefan Reinauer | bf264e9 | 2010-05-14 19:09:20 +0000 | [diff] [blame] | 1784 | asm volatile ( |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1785 | " movl $0x100, %%ecx\n" |
| 1786 | "delay_update:\n" |
| 1787 | " nop\n" |
| 1788 | " nop\n" |
| 1789 | " nop\n" |
| 1790 | " nop\n" |
| 1791 | " loop delay_update\n" |
| 1792 | : /* No outputs */ |
| 1793 | : /* No inputs */ |
Stefan Reinauer | bf264e9 | 2010-05-14 19:09:20 +0000 | [diff] [blame] | 1794 | : "%ecx", "memory" |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1795 | ); |
| 1796 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1797 | clkcfg &= ~(1 << 10); |
| 1798 | MCHBAR32(CLKCFG) = clkcfg; |
| 1799 | |
| 1800 | goto out; |
| 1801 | cache_code: |
| 1802 | goto vco_update; |
| 1803 | out: |
| 1804 | |
Elyes HAOUAS | 0a15fe9 | 2016-09-17 19:12:27 +0200 | [diff] [blame] | 1805 | printk(BIOS_DEBUG, "CLKCFG = 0x%08x, ", MCHBAR32(CLKCFG)); |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 1806 | printk(BIOS_DEBUG, "ok\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1807 | } |
| 1808 | |
| 1809 | static void sdram_program_clock_crossing(void) |
| 1810 | { |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1811 | int idx = 0; |
| 1812 | |
| 1813 | /** |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1814 | * We add the indices according to our clocks from CLKCFG. |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1815 | */ |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 1816 | #if CONFIG(NORTHBRIDGE_INTEL_SUBTYPE_I945GM) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1817 | static const u32 data_clock_crossing[] = { |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1818 | 0x00100401, 0x00000000, /* DDR400 FSB400 */ |
Martin Roth | 2ed0aa2 | 2016-01-05 20:58:58 -0700 | [diff] [blame] | 1819 | 0xffffffff, 0xffffffff, /* nonexistent */ |
| 1820 | 0xffffffff, 0xffffffff, /* nonexistent */ |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1821 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1822 | 0x08040120, 0x00000000, /* DDR400 FSB533 */ |
| 1823 | 0x00100401, 0x00000000, /* DDR533 FSB533 */ |
Stefan Reinauer | bf264e9 | 2010-05-14 19:09:20 +0000 | [diff] [blame] | 1824 | 0x00010402, 0x00000000, /* DDR667 FSB533 - fake values */ |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1825 | |
| 1826 | 0x04020120, 0x00000010, /* DDR400 FSB667 */ |
| 1827 | 0x10040280, 0x00000040, /* DDR533 FSB667 */ |
Stefan Reinauer | 24b4df5 | 2010-01-17 13:47:35 +0000 | [diff] [blame] | 1828 | 0x00100401, 0x00000000, /* DDR667 FSB667 */ |
| 1829 | |
Martin Roth | 2ed0aa2 | 2016-01-05 20:58:58 -0700 | [diff] [blame] | 1830 | 0xffffffff, 0xffffffff, /* nonexistent */ |
| 1831 | 0xffffffff, 0xffffffff, /* nonexistent */ |
| 1832 | 0xffffffff, 0xffffffff, /* nonexistent */ |
Stefan Reinauer | 24b4df5 | 2010-01-17 13:47:35 +0000 | [diff] [blame] | 1833 | |
Martin Roth | 2ed0aa2 | 2016-01-05 20:58:58 -0700 | [diff] [blame] | 1834 | 0xffffffff, 0xffffffff, /* nonexistent */ |
| 1835 | 0xffffffff, 0xffffffff, /* nonexistent */ |
| 1836 | 0xffffffff, 0xffffffff, /* nonexistent */ |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1837 | }; |
| 1838 | |
| 1839 | static const u32 command_clock_crossing[] = { |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1840 | 0x04020208, 0x00000000, /* DDR400 FSB400 */ |
Martin Roth | 2ed0aa2 | 2016-01-05 20:58:58 -0700 | [diff] [blame] | 1841 | 0xffffffff, 0xffffffff, /* nonexistent */ |
| 1842 | 0xffffffff, 0xffffffff, /* nonexistent */ |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1843 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1844 | 0x00060108, 0x00000000, /* DDR400 FSB533 */ |
| 1845 | 0x04020108, 0x00000000, /* DDR533 FSB533 */ |
Martin Roth | 2ed0aa2 | 2016-01-05 20:58:58 -0700 | [diff] [blame] | 1846 | 0xffffffff, 0xffffffff, /* nonexistent */ |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1847 | |
| 1848 | 0x00040318, 0x00000000, /* DDR400 FSB667 */ |
| 1849 | 0x04020118, 0x00000000, /* DDR533 FSB667 */ |
Stefan Reinauer | 24b4df5 | 2010-01-17 13:47:35 +0000 | [diff] [blame] | 1850 | 0x02010804, 0x00000000, /* DDR667 FSB667 */ |
| 1851 | |
Martin Roth | 2ed0aa2 | 2016-01-05 20:58:58 -0700 | [diff] [blame] | 1852 | 0xffffffff, 0xffffffff, /* nonexistent */ |
| 1853 | 0xffffffff, 0xffffffff, /* nonexistent */ |
| 1854 | 0xffffffff, 0xffffffff, /* nonexistent */ |
Stefan Reinauer | 24b4df5 | 2010-01-17 13:47:35 +0000 | [diff] [blame] | 1855 | |
Martin Roth | 2ed0aa2 | 2016-01-05 20:58:58 -0700 | [diff] [blame] | 1856 | 0xffffffff, 0xffffffff, /* nonexistent */ |
| 1857 | 0xffffffff, 0xffffffff, /* nonexistent */ |
| 1858 | 0xffffffff, 0xffffffff, /* nonexistent */ |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1859 | }; |
| 1860 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 1861 | #elif CONFIG(NORTHBRIDGE_INTEL_SUBTYPE_I945GC) |
Stefan Reinauer | 24b4df5 | 2010-01-17 13:47:35 +0000 | [diff] [blame] | 1862 | /* i945 G/P */ |
| 1863 | static const u32 data_clock_crossing[] = { |
Martin Roth | 2ed0aa2 | 2016-01-05 20:58:58 -0700 | [diff] [blame] | 1864 | 0xffffffff, 0xffffffff, /* nonexistent */ |
| 1865 | 0xffffffff, 0xffffffff, /* nonexistent */ |
| 1866 | 0xffffffff, 0xffffffff, /* nonexistent */ |
Stefan Reinauer | 24b4df5 | 2010-01-17 13:47:35 +0000 | [diff] [blame] | 1867 | |
| 1868 | 0x10080201, 0x00000000, /* DDR400 FSB533 */ |
| 1869 | 0x00100401, 0x00000000, /* DDR533 FSB533 */ |
Patrick Georgi | 682ea3c | 2010-04-20 15:52:57 +0000 | [diff] [blame] | 1870 | 0x00010402, 0x00000000, /* DDR667 FSB533 - fake values */ |
Stefan Reinauer | 24b4df5 | 2010-01-17 13:47:35 +0000 | [diff] [blame] | 1871 | |
Martin Roth | 2ed0aa2 | 2016-01-05 20:58:58 -0700 | [diff] [blame] | 1872 | 0xffffffff, 0xffffffff, /* nonexistent */ |
| 1873 | 0xffffffff, 0xffffffff, /* nonexistent */ |
| 1874 | 0xffffffff, 0xffffffff, /* nonexistent */ |
Stefan Reinauer | 24b4df5 | 2010-01-17 13:47:35 +0000 | [diff] [blame] | 1875 | |
| 1876 | 0x04020108, 0x00000000, /* DDR400 FSB800 */ |
| 1877 | 0x00020108, 0x00000000, /* DDR533 FSB800 */ |
| 1878 | 0x00080201, 0x00000000, /* DDR667 FSB800 */ |
| 1879 | |
| 1880 | 0x00010402, 0x00000000, /* DDR400 FSB1066 */ |
| 1881 | 0x04020108, 0x00000000, /* DDR533 FSB1066 */ |
| 1882 | 0x08040110, 0x00000000, /* DDR667 FSB1066 */ |
| 1883 | }; |
| 1884 | |
| 1885 | static const u32 command_clock_crossing[] = { |
Martin Roth | 2ed0aa2 | 2016-01-05 20:58:58 -0700 | [diff] [blame] | 1886 | 0xffffffff, 0xffffffff, /* nonexistent */ |
| 1887 | 0xffffffff, 0xffffffff, /* nonexistent */ |
| 1888 | 0xffffffff, 0xffffffff, /* nonexistent */ |
Stefan Reinauer | 24b4df5 | 2010-01-17 13:47:35 +0000 | [diff] [blame] | 1889 | |
| 1890 | 0x00010800, 0x00000402, /* DDR400 FSB533 */ |
| 1891 | 0x01000400, 0x00000200, /* DDR533 FSB533 */ |
Patrick Georgi | 682ea3c | 2010-04-20 15:52:57 +0000 | [diff] [blame] | 1892 | 0x00020904, 0x00000000, /* DDR667 FSB533 - fake values */ |
Stefan Reinauer | 24b4df5 | 2010-01-17 13:47:35 +0000 | [diff] [blame] | 1893 | |
Martin Roth | 2ed0aa2 | 2016-01-05 20:58:58 -0700 | [diff] [blame] | 1894 | 0xffffffff, 0xffffffff, /* nonexistent */ |
| 1895 | 0xffffffff, 0xffffffff, /* nonexistent */ |
| 1896 | 0xffffffff, 0xffffffff, /* nonexistent */ |
Stefan Reinauer | 24b4df5 | 2010-01-17 13:47:35 +0000 | [diff] [blame] | 1897 | |
| 1898 | 0x02010804, 0x00000000, /* DDR400 FSB800 */ |
| 1899 | 0x00010402, 0x00000000, /* DDR533 FSB800 */ |
Arthur Heymans | 8b6df62 | 2016-10-16 10:58:01 +0200 | [diff] [blame] | 1900 | 0x04020130, 0x00000008, /* DDR667 FSB800 */ |
Stefan Reinauer | 24b4df5 | 2010-01-17 13:47:35 +0000 | [diff] [blame] | 1901 | |
| 1902 | 0x00020904, 0x00000000, /* DDR400 FSB1066 */ |
| 1903 | 0x02010804, 0x00000000, /* DDR533 FSB1066 */ |
| 1904 | 0x180601c0, 0x00000020, /* DDR667 FSB1066 */ |
| 1905 | }; |
| 1906 | #endif |
| 1907 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 1908 | printk(BIOS_DEBUG, "Programming Clock Crossing..."); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1909 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 1910 | printk(BIOS_DEBUG, "MEM="); |
Stefan Reinauer | 24b4df5 | 2010-01-17 13:47:35 +0000 | [diff] [blame] | 1911 | switch (memclk()) { |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1912 | case 400: |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 1913 | printk(BIOS_DEBUG, "400"); |
| 1914 | idx += 0; |
| 1915 | break; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1916 | case 533: |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 1917 | printk(BIOS_DEBUG, "533"); |
| 1918 | idx += 2; |
| 1919 | break; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1920 | case 667: |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 1921 | printk(BIOS_DEBUG, "667"); |
| 1922 | idx += 4; |
| 1923 | break; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1924 | default: |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 1925 | printk(BIOS_DEBUG, "RSVD %x", memclk()); |
| 1926 | return; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1927 | } |
| 1928 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 1929 | printk(BIOS_DEBUG, " FSB="); |
Stefan Reinauer | 24b4df5 | 2010-01-17 13:47:35 +0000 | [diff] [blame] | 1930 | switch (fsbclk()) { |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1931 | case 400: |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 1932 | printk(BIOS_DEBUG, "400"); |
| 1933 | idx += 0; |
| 1934 | break; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1935 | case 533: |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 1936 | printk(BIOS_DEBUG, "533"); |
| 1937 | idx += 6; |
| 1938 | break; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1939 | case 667: |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 1940 | printk(BIOS_DEBUG, "667"); |
| 1941 | idx += 12; |
| 1942 | break; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1943 | case 800: |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 1944 | printk(BIOS_DEBUG, "800"); |
| 1945 | idx += 18; |
| 1946 | break; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1947 | case 1066: |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 1948 | printk(BIOS_DEBUG, "1066"); |
| 1949 | idx += 24; |
| 1950 | break; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1951 | default: |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 1952 | printk(BIOS_DEBUG, "RSVD %x\n", fsbclk()); |
| 1953 | return; |
Stefan Reinauer | 24b4df5 | 2010-01-17 13:47:35 +0000 | [diff] [blame] | 1954 | } |
| 1955 | |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 1956 | if (command_clock_crossing[idx] == 0xffffffff) |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 1957 | printk(BIOS_DEBUG, "Invalid MEM/FSB combination!\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1958 | |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1959 | MCHBAR32(CCCFT + 0) = command_clock_crossing[idx]; |
| 1960 | MCHBAR32(CCCFT + 4) = command_clock_crossing[idx + 1]; |
| 1961 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1962 | MCHBAR32(C0DCCFT + 0) = data_clock_crossing[idx]; |
| 1963 | MCHBAR32(C0DCCFT + 4) = data_clock_crossing[idx + 1]; |
| 1964 | MCHBAR32(C1DCCFT + 0) = data_clock_crossing[idx]; |
| 1965 | MCHBAR32(C1DCCFT + 4) = data_clock_crossing[idx + 1]; |
| 1966 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 1967 | printk(BIOS_DEBUG, "... ok\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1968 | } |
| 1969 | |
| 1970 | static void sdram_disable_fast_dispatch(void) |
| 1971 | { |
| 1972 | u32 reg32; |
| 1973 | |
| 1974 | reg32 = MCHBAR32(FSBPMC3); |
| 1975 | reg32 |= (1 << 1); |
| 1976 | MCHBAR32(FSBPMC3) = reg32; |
| 1977 | |
| 1978 | reg32 = MCHBAR32(SBTEST); |
| 1979 | reg32 |= (3 << 1); |
| 1980 | MCHBAR32(SBTEST) = reg32; |
| 1981 | } |
| 1982 | |
| 1983 | static void sdram_pre_jedec_initialization(void) |
| 1984 | { |
| 1985 | u32 reg32; |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 1986 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 1987 | reg32 = MCHBAR32(WCC); |
| 1988 | reg32 &= 0x113ff3ff; |
| 1989 | reg32 |= (4 << 29) | (3 << 25) | (1 << 10); |
| 1990 | MCHBAR32(WCC) = reg32; |
| 1991 | |
| 1992 | MCHBAR32(SMVREFC) |= (1 << 6); |
| 1993 | |
| 1994 | MCHBAR32(MMARB0) &= ~(3 << 17); |
| 1995 | MCHBAR32(MMARB0) |= (1 << 21) | (1 << 16); |
| 1996 | |
| 1997 | MCHBAR32(MMARB1) &= ~(7 << 8); |
| 1998 | MCHBAR32(MMARB1) |= (3 << 8); |
| 1999 | |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 2000 | /* Adaptive Idle Timer Control */ |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2001 | MCHBAR32(C0AIT) = 0x000006c4; |
| 2002 | MCHBAR32(C0AIT+4) = 0x871a066d; |
| 2003 | |
| 2004 | MCHBAR32(C1AIT) = 0x000006c4; |
| 2005 | MCHBAR32(C1AIT+4) = 0x871a066d; |
| 2006 | } |
| 2007 | |
| 2008 | #define EA_DUALCHANNEL_XOR_BANK_RANK_MODE (0xd4 << 24) |
| 2009 | #define EA_DUALCHANNEL_XOR_BANK_MODE (0xf4 << 24) |
| 2010 | #define EA_DUALCHANNEL_BANK_RANK_MODE (0xc2 << 24) |
| 2011 | #define EA_DUALCHANNEL_BANK_MODE (0xe2 << 24) |
| 2012 | #define EA_SINGLECHANNEL_XOR_BANK_RANK_MODE (0x91 << 24) |
| 2013 | #define EA_SINGLECHANNEL_XOR_BANK_MODE (0xb1 << 24) |
| 2014 | #define EA_SINGLECHANNEL_BANK_RANK_MODE (0x80 << 24) |
| 2015 | #define EA_SINGLECHANNEL_BANK_MODE (0xa0 << 24) |
| 2016 | |
| 2017 | static void sdram_enhanced_addressing_mode(struct sys_info *sysinfo) |
| 2018 | { |
| 2019 | u32 chan0 = 0, chan1 = 0; |
Paul Menzel | d789b658 | 2020-03-14 11:50:34 +0100 | [diff] [blame] | 2020 | bool chan0_dualsided, chan1_dualsided, chan0_populated, chan1_populated; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2021 | |
Paul Menzel | 842dd33 | 2020-03-14 10:37:40 +0100 | [diff] [blame] | 2022 | chan0_populated = (sysinfo->dimm[0] != SYSINFO_DIMM_NOT_POPULATED || |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 2023 | sysinfo->dimm[1] != SYSINFO_DIMM_NOT_POPULATED); |
Elyes HAOUAS | 308aeff | 2017-02-24 12:53:07 +0100 | [diff] [blame] | 2024 | chan1_populated = (sysinfo->dimm[2] != SYSINFO_DIMM_NOT_POPULATED || |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 2025 | sysinfo->dimm[3] != SYSINFO_DIMM_NOT_POPULATED); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2026 | chan0_dualsided = (sysinfo->banksize[1] || sysinfo->banksize[3]); |
| 2027 | chan1_dualsided = (sysinfo->banksize[5] || sysinfo->banksize[7]); |
| 2028 | |
| 2029 | if (sdram_capabilities_enhanced_addressing_xor()) { |
| 2030 | if (!sysinfo->interleaved) { |
Martin Roth | 128c104 | 2016-11-18 09:29:03 -0700 | [diff] [blame] | 2031 | /* Single Channel & Dual Channel Asymmetric */ |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2032 | if (chan0_populated) { |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 2033 | if (chan0_dualsided) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2034 | chan0 = EA_SINGLECHANNEL_XOR_BANK_RANK_MODE; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 2035 | else |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2036 | chan0 = EA_SINGLECHANNEL_XOR_BANK_MODE; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2037 | } |
| 2038 | if (chan1_populated) { |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 2039 | if (chan1_dualsided) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2040 | chan1 = EA_SINGLECHANNEL_XOR_BANK_RANK_MODE; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 2041 | else |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2042 | chan1 = EA_SINGLECHANNEL_XOR_BANK_MODE; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2043 | } |
| 2044 | } else { |
| 2045 | /* Interleaved has always both channels populated */ |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 2046 | if (chan0_dualsided) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2047 | chan0 = EA_DUALCHANNEL_XOR_BANK_RANK_MODE; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 2048 | else |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2049 | chan0 = EA_DUALCHANNEL_XOR_BANK_MODE; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2050 | |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 2051 | if (chan1_dualsided) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2052 | chan1 = EA_DUALCHANNEL_XOR_BANK_RANK_MODE; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 2053 | else |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2054 | chan1 = EA_DUALCHANNEL_XOR_BANK_MODE; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2055 | } |
| 2056 | } else { |
| 2057 | if (!sysinfo->interleaved) { |
Martin Roth | 128c104 | 2016-11-18 09:29:03 -0700 | [diff] [blame] | 2058 | /* Single Channel & Dual Channel Asymmetric */ |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2059 | if (chan0_populated) { |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 2060 | if (chan0_dualsided) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2061 | chan0 = EA_SINGLECHANNEL_BANK_RANK_MODE; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 2062 | else |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2063 | chan0 = EA_SINGLECHANNEL_BANK_MODE; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2064 | } |
| 2065 | if (chan1_populated) { |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 2066 | if (chan1_dualsided) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2067 | chan1 = EA_SINGLECHANNEL_BANK_RANK_MODE; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 2068 | else |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2069 | chan1 = EA_SINGLECHANNEL_BANK_MODE; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2070 | } |
| 2071 | } else { |
| 2072 | /* Interleaved has always both channels populated */ |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 2073 | if (chan0_dualsided) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2074 | chan0 = EA_DUALCHANNEL_BANK_RANK_MODE; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 2075 | else |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2076 | chan0 = EA_DUALCHANNEL_BANK_MODE; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2077 | |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 2078 | if (chan1_dualsided) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2079 | chan1 = EA_DUALCHANNEL_BANK_RANK_MODE; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 2080 | else |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2081 | chan1 = EA_DUALCHANNEL_BANK_MODE; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2082 | } |
| 2083 | } |
| 2084 | |
| 2085 | MCHBAR32(C0DRC1) &= 0x00ffffff; |
| 2086 | MCHBAR32(C0DRC1) |= chan0; |
| 2087 | MCHBAR32(C1DRC1) &= 0x00ffffff; |
| 2088 | MCHBAR32(C1DRC1) |= chan1; |
| 2089 | } |
| 2090 | |
| 2091 | static void sdram_post_jedec_initialization(struct sys_info *sysinfo) |
| 2092 | { |
| 2093 | u32 reg32; |
| 2094 | |
| 2095 | /* Enable Channel XORing for Dual Channel Interleave */ |
| 2096 | if (sysinfo->interleaved) { |
| 2097 | reg32 = MCHBAR32(DCC); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2098 | reg32 &= ~(1 << 10); |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 2099 | reg32 |= (1 << 9); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2100 | MCHBAR32(DCC) = reg32; |
| 2101 | } |
| 2102 | |
| 2103 | /* DRAM mode optimizations */ |
| 2104 | sdram_enhanced_addressing_mode(sysinfo); |
| 2105 | |
| 2106 | reg32 = MCHBAR32(FSBPMC3); |
| 2107 | reg32 &= ~(1 << 1); |
| 2108 | MCHBAR32(FSBPMC3) = reg32; |
| 2109 | |
| 2110 | reg32 = MCHBAR32(SBTEST); |
| 2111 | reg32 &= ~(1 << 2); |
| 2112 | MCHBAR32(SBTEST) = reg32; |
| 2113 | |
| 2114 | reg32 = MCHBAR32(SBOCC); |
| 2115 | reg32 &= 0xffbdb6ff; |
| 2116 | reg32 |= (0xbdb6 << 8) | (1 << 0); |
| 2117 | MCHBAR32(SBOCC) = reg32; |
| 2118 | } |
| 2119 | |
| 2120 | static void sdram_power_management(struct sys_info *sysinfo) |
| 2121 | { |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2122 | u16 reg16; |
| 2123 | u32 reg32; |
| 2124 | int integrated_graphics = 1; |
| 2125 | int i; |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 2126 | |
Elyes HAOUAS | 8f20b12 | 2021-02-14 13:22:10 +0100 | [diff] [blame] | 2127 | if (!(pci_read_config8(HOST_BRIDGE, DEVEN) & (DEVEN_D2F0 | DEVEN_D2F1))) |
| 2128 | integrated_graphics = false; |
| 2129 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2130 | reg32 = MCHBAR32(C0DRT2); |
| 2131 | reg32 &= 0xffffff00; |
| 2132 | /* Idle timer = 8 clocks, CKE idle timer = 16 clocks */ |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 2133 | reg32 |= (1 << 5) | (1 << 4); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2134 | MCHBAR32(C0DRT2) = reg32; |
| 2135 | |
| 2136 | reg32 = MCHBAR32(C1DRT2); |
| 2137 | reg32 &= 0xffffff00; |
| 2138 | /* Idle timer = 8 clocks, CKE idle timer = 16 clocks */ |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 2139 | reg32 |= (1 << 5) | (1 << 4); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2140 | MCHBAR32(C1DRT2) = reg32; |
| 2141 | |
| 2142 | reg32 = MCHBAR32(C0DRC1); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 2143 | |
| 2144 | reg32 |= (1 << 12) | (1 << 11); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2145 | MCHBAR32(C0DRC1) = reg32; |
| 2146 | |
| 2147 | reg32 = MCHBAR32(C1DRC1); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 2148 | |
| 2149 | reg32 |= (1 << 12) | (1 << 11); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2150 | MCHBAR32(C1DRC1) = reg32; |
| 2151 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 2152 | if (CONFIG(NORTHBRIDGE_INTEL_SUBTYPE_I945GM)) { |
Arthur Heymans | 2f6b52e | 2017-03-02 23:51:09 +0100 | [diff] [blame] | 2153 | if (i945_silicon_revision() > 1) { |
| 2154 | /* FIXME bits 5 and 0 only if PCIe graphics is disabled */ |
| 2155 | u16 peg_bits = (1 << 5) | (1 << 0); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 2156 | |
Arthur Heymans | 2f6b52e | 2017-03-02 23:51:09 +0100 | [diff] [blame] | 2157 | MCHBAR16(UPMC1) = 0x1010 | peg_bits; |
| 2158 | } else { |
| 2159 | /* FIXME bits 5 and 0 only if PCIe graphics is disabled */ |
| 2160 | u16 peg_bits = (1 << 5) | (1 << 0); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 2161 | |
Arthur Heymans | 2f6b52e | 2017-03-02 23:51:09 +0100 | [diff] [blame] | 2162 | /* Rev 0 and 1 */ |
| 2163 | MCHBAR16(UPMC1) = 0x0010 | peg_bits; |
| 2164 | } |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2165 | } |
| 2166 | |
| 2167 | reg16 = MCHBAR16(UPMC2); |
| 2168 | reg16 &= 0xfc00; |
| 2169 | reg16 |= 0x0100; |
| 2170 | MCHBAR16(UPMC2) = reg16; |
| 2171 | |
| 2172 | MCHBAR32(UPMC3) = 0x000f06ff; |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 2173 | |
Elyes HAOUAS | 0a15fe9 | 2016-09-17 19:12:27 +0200 | [diff] [blame] | 2174 | for (i = 0; i < 5; i++) { |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2175 | MCHBAR32(UPMC3) &= ~(1 << 16); |
| 2176 | MCHBAR32(UPMC3) |= (1 << 16); |
| 2177 | } |
| 2178 | |
| 2179 | MCHBAR32(GIPMC1) = 0x8000000c; |
| 2180 | |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 2181 | reg16 = MCHBAR16(CPCTL); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2182 | reg16 &= ~(7 << 11); |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 2183 | if (i945_silicon_revision() > 2) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2184 | reg16 |= (6 << 11); |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 2185 | else |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2186 | reg16 |= (4 << 11); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2187 | MCHBAR16(CPCTL) = reg16; |
| 2188 | |
Angel Pons | 3580d81 | 2020-06-11 14:13:33 +0200 | [diff] [blame] | 2189 | #if 0 |
| 2190 | if ((MCHBAR32(ECO) & (1 << 16)) != 0) { |
| 2191 | #else |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 2192 | if (i945_silicon_revision() != 0) { |
Angel Pons | 3580d81 | 2020-06-11 14:13:33 +0200 | [diff] [blame] | 2193 | #endif |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2194 | switch (sysinfo->fsb_frequency) { |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 2195 | case 667: |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 2196 | MCHBAR32(HGIPMC2) = 0x0d590d59; |
| 2197 | break; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 2198 | case 533: |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 2199 | MCHBAR32(HGIPMC2) = 0x155b155b; |
| 2200 | break; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2201 | } |
| 2202 | } else { |
| 2203 | switch (sysinfo->fsb_frequency) { |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 2204 | case 667: |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 2205 | MCHBAR32(HGIPMC2) = 0x09c409c4; |
| 2206 | break; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 2207 | case 533: |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 2208 | MCHBAR32(HGIPMC2) = 0x0fa00fa0; |
| 2209 | break; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2210 | } |
| 2211 | } |
| 2212 | |
| 2213 | MCHBAR32(FSBPMC1) = 0x8000000c; |
| 2214 | |
| 2215 | reg32 = MCHBAR32(C2C3TT); |
| 2216 | reg32 &= 0xffff0000; |
| 2217 | switch (sysinfo->fsb_frequency) { |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 2218 | case 667: |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 2219 | reg32 |= 0x0600; |
| 2220 | break; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 2221 | case 533: |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 2222 | reg32 |= 0x0480; |
| 2223 | break; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2224 | } |
| 2225 | MCHBAR32(C2C3TT) = reg32; |
| 2226 | |
| 2227 | reg32 = MCHBAR32(C3C4TT); |
| 2228 | reg32 &= 0xffff0000; |
| 2229 | switch (sysinfo->fsb_frequency) { |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 2230 | case 667: |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 2231 | reg32 |= 0x0b80; |
| 2232 | break; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 2233 | case 533: |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 2234 | reg32 |= 0x0980; |
| 2235 | break; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2236 | } |
| 2237 | MCHBAR32(C3C4TT) = reg32; |
| 2238 | |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 2239 | if (i945_silicon_revision() == 0) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2240 | MCHBAR32(ECO) &= ~(1 << 16); |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 2241 | else |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2242 | MCHBAR32(ECO) |= (1 << 16); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2243 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2244 | MCHBAR32(FSBPMC3) &= ~(1 << 29); |
| 2245 | |
| 2246 | MCHBAR32(FSBPMC3) |= (1 << 21); |
| 2247 | |
| 2248 | MCHBAR32(FSBPMC3) &= ~(1 << 19); |
| 2249 | |
| 2250 | MCHBAR32(FSBPMC3) &= ~(1 << 13); |
| 2251 | |
| 2252 | reg32 = MCHBAR32(FSBPMC4); |
| 2253 | reg32 &= ~(3 << 24); |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 2254 | reg32 |= (2 << 24); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2255 | MCHBAR32(FSBPMC4) = reg32; |
| 2256 | |
| 2257 | MCHBAR32(FSBPMC4) |= (1 << 21); |
| 2258 | |
| 2259 | MCHBAR32(FSBPMC4) |= (1 << 5); |
| 2260 | |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 2261 | if ((i945_silicon_revision() < 2)) { /* || cpuid() = 0x6e8 */ |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 2262 | /* stepping 0 and 1 or CPUID 6e8 */ |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2263 | MCHBAR32(FSBPMC4) &= ~(1 << 4); |
| 2264 | } else { |
Stefan Reinauer | 30140a5 | 2009-03-11 16:20:39 +0000 | [diff] [blame] | 2265 | MCHBAR32(FSBPMC4) |= (1 << 4); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2266 | } |
| 2267 | |
Angel Pons | 3580d81 | 2020-06-11 14:13:33 +0200 | [diff] [blame] | 2268 | pci_or_config8(HOST_BRIDGE, 0xfc, 1 << 4); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2269 | |
Angel Pons | 3580d81 | 2020-06-11 14:13:33 +0200 | [diff] [blame] | 2270 | pci_or_config8(IGD_DEV, 0xc1, 1 << 2); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2271 | |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 2272 | if (integrated_graphics) { |
| 2273 | MCHBAR16(MIPMC4) = 0x04f8; |
| 2274 | MCHBAR16(MIPMC5) = 0x04fc; |
| 2275 | MCHBAR16(MIPMC6) = 0x04fc; |
| 2276 | } else { |
| 2277 | MCHBAR16(MIPMC4) = 0x64f8; |
| 2278 | MCHBAR16(MIPMC5) = 0x64fc; |
| 2279 | MCHBAR16(MIPMC6) = 0x64fc; |
| 2280 | } |
| 2281 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2282 | reg32 = MCHBAR32(PMCFG); |
| 2283 | reg32 &= ~(3 << 17); |
| 2284 | reg32 |= (2 << 17); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2285 | MCHBAR32(PMCFG) = reg32; |
| 2286 | |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 2287 | MCHBAR32(PMCFG) |= (1 << 4); |
| 2288 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2289 | reg32 = MCHBAR32(0xc30); |
| 2290 | reg32 &= 0xffffff00; |
| 2291 | reg32 |= 0x01; |
| 2292 | MCHBAR32(0xc30) = reg32; |
| 2293 | |
| 2294 | MCHBAR32(0xb18) &= ~(1 << 21); |
| 2295 | } |
| 2296 | |
| 2297 | static void sdram_thermal_management(void) |
| 2298 | { |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2299 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2300 | MCHBAR8(TCO1) = 0x00; |
| 2301 | MCHBAR8(TCO0) = 0x00; |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 2302 | |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 2303 | /* The Thermal Sensors for DIMMs at 0x50, 0x52 are at I2C addr 0x30/0x32. */ |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 2304 | |
Stefan Reinauer | bf264e9 | 2010-05-14 19:09:20 +0000 | [diff] [blame] | 2305 | /* TODO This is not implemented yet. Volunteers? */ |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 2306 | } |
| 2307 | |
| 2308 | static void sdram_save_receive_enable(void) |
| 2309 | { |
| 2310 | int i; |
| 2311 | u32 reg32; |
| 2312 | u8 values[4]; |
| 2313 | |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 2314 | /* The following values are stored to an unused CMOS area and restored instead of |
| 2315 | * recalculated in case of an S3 resume. |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 2316 | * |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 2317 | * C0WL0REOST [7:0] -> 8 bit |
| 2318 | * C1WL0REOST [7:0] -> 8 bit |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 2319 | * RCVENMT [11:8] [3:0] -> 8 bit |
| 2320 | * C0DRT1 [27:24] -> 4 bit |
| 2321 | * C1DRT1 [27:24] -> 4 bit |
| 2322 | */ |
| 2323 | |
| 2324 | values[0] = MCHBAR8(C0WL0REOST); |
| 2325 | values[1] = MCHBAR8(C1WL0REOST); |
| 2326 | |
| 2327 | reg32 = MCHBAR32(RCVENMT); |
| 2328 | values[2] = (u8)((reg32 >> (8 - 4)) & 0xf0) | (reg32 & 0x0f); |
| 2329 | |
| 2330 | reg32 = MCHBAR32(C0DRT1); |
| 2331 | values[3] = (reg32 >> 24) & 0x0f; |
| 2332 | reg32 = MCHBAR32(C1DRT1); |
| 2333 | values[3] |= (reg32 >> (24 - 4)) & 0xf0; |
| 2334 | |
| 2335 | /* coreboot only uses bytes 0 - 127 for its CMOS values so far |
Edwin Beasant | eb50c7d | 2010-07-06 21:05:04 +0000 | [diff] [blame] | 2336 | * so we grab bytes 128 - 131 to save the receive enable values |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 2337 | */ |
| 2338 | |
Elyes HAOUAS | 0a15fe9 | 2016-09-17 19:12:27 +0200 | [diff] [blame] | 2339 | for (i = 0; i < 4; i++) |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 2340 | cmos_write(values[i], 128 + i); |
| 2341 | } |
| 2342 | |
| 2343 | static void sdram_recover_receive_enable(void) |
| 2344 | { |
| 2345 | int i; |
| 2346 | u32 reg32; |
| 2347 | u8 values[4]; |
| 2348 | |
Elyes HAOUAS | 0a15fe9 | 2016-09-17 19:12:27 +0200 | [diff] [blame] | 2349 | for (i = 0; i < 4; i++) |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 2350 | values[i] = cmos_read(128 + i); |
| 2351 | |
| 2352 | MCHBAR8(C0WL0REOST) = values[0]; |
| 2353 | MCHBAR8(C1WL0REOST) = values[1]; |
| 2354 | |
| 2355 | reg32 = MCHBAR32(RCVENMT); |
| 2356 | reg32 &= ~((0x0f << 8) | (0x0f << 0)); |
| 2357 | reg32 |= ((u32)(values[2] & 0xf0) << (8 - 4)) | (values[2] & 0x0f); |
| 2358 | MCHBAR32(RCVENMT) = reg32; |
| 2359 | |
| 2360 | reg32 = MCHBAR32(C0DRT1) & ~(0x0f << 24); |
| 2361 | reg32 |= (u32)(values[3] & 0x0f) << 24; |
| 2362 | MCHBAR32(C0DRT1) = reg32; |
| 2363 | |
| 2364 | reg32 = MCHBAR32(C1DRT1) & ~(0x0f << 24); |
| 2365 | reg32 |= (u32)(values[3] & 0xf0) << (24 - 4); |
| 2366 | MCHBAR32(C1DRT1) = reg32; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2367 | } |
| 2368 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2369 | static void sdram_program_receive_enable(struct sys_info *sysinfo) |
| 2370 | { |
| 2371 | MCHBAR32(REPC) |= (1 << 0); |
| 2372 | |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 2373 | /* Program Receive Enable Timings */ |
| 2374 | if (sysinfo->boot_path == BOOT_PATH_RESUME) { |
| 2375 | sdram_recover_receive_enable(); |
| 2376 | } else { |
| 2377 | receive_enable_adjust(sysinfo); |
| 2378 | sdram_save_receive_enable(); |
| 2379 | } |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2380 | |
| 2381 | MCHBAR32(C0DRC1) |= (1 << 6); |
| 2382 | MCHBAR32(C1DRC1) |= (1 << 6); |
| 2383 | MCHBAR32(C0DRC1) &= ~(1 << 6); |
| 2384 | MCHBAR32(C1DRC1) &= ~(1 << 6); |
| 2385 | |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 2386 | MCHBAR32(MIPMC3) |= (0x0f << 0); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2387 | } |
| 2388 | |
| 2389 | /** |
| 2390 | * @brief Enable On-Die Termination for DDR2. |
| 2391 | * |
| 2392 | */ |
| 2393 | |
| 2394 | static void sdram_on_die_termination(struct sys_info *sysinfo) |
| 2395 | { |
| 2396 | static const u32 odt[] = { |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 2397 | 0x00024911, 0xe0010000, |
| 2398 | 0x00049211, 0xe0020000, |
| 2399 | 0x0006db11, 0xe0030000, |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2400 | }; |
| 2401 | |
| 2402 | u32 reg32; |
| 2403 | int cas; |
| 2404 | |
| 2405 | reg32 = MCHBAR32(ODTC); |
| 2406 | reg32 &= ~(3 << 16); |
| 2407 | reg32 |= (1 << 14) | (1 << 6) | (2 << 16); |
| 2408 | MCHBAR32(ODTC) = reg32; |
| 2409 | |
Paul Menzel | b4d9f22 | 2020-03-14 10:34:29 +0100 | [diff] [blame] | 2410 | if (sysinfo->dimm[0] == SYSINFO_DIMM_NOT_POPULATED || |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 2411 | sysinfo->dimm[1] == SYSINFO_DIMM_NOT_POPULATED) { |
Elyes HAOUAS | 3842498 | 2016-08-21 12:01:04 +0200 | [diff] [blame] | 2412 | printk(BIOS_DEBUG, "one dimm per channel config..\n"); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 2413 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2414 | reg32 = MCHBAR32(C0ODT); |
| 2415 | reg32 &= ~(7 << 28); |
| 2416 | MCHBAR32(C0ODT) = reg32; |
| 2417 | reg32 = MCHBAR32(C1ODT); |
| 2418 | reg32 &= ~(7 << 28); |
| 2419 | MCHBAR32(C1ODT) = reg32; |
| 2420 | } |
| 2421 | |
| 2422 | cas = sysinfo->cas; |
| 2423 | |
| 2424 | reg32 = MCHBAR32(C0ODT) & 0xfff00000; |
Angel Pons | 3049257 | 2020-06-11 13:24:54 +0200 | [diff] [blame] | 2425 | reg32 |= odt[(cas - 3) * 2]; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2426 | MCHBAR32(C0ODT) = reg32; |
| 2427 | |
| 2428 | reg32 = MCHBAR32(C1ODT) & 0xfff00000; |
Angel Pons | 3049257 | 2020-06-11 13:24:54 +0200 | [diff] [blame] | 2429 | reg32 |= odt[(cas - 3) * 2]; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2430 | MCHBAR32(C1ODT) = reg32; |
| 2431 | |
| 2432 | reg32 = MCHBAR32(C0ODT + 4) & 0x1fc8ffff; |
Angel Pons | 3049257 | 2020-06-11 13:24:54 +0200 | [diff] [blame] | 2433 | reg32 |= odt[((cas - 3) * 2) + 1]; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2434 | MCHBAR32(C0ODT + 4) = reg32; |
| 2435 | |
| 2436 | reg32 = MCHBAR32(C1ODT + 4) & 0x1fc8ffff; |
Angel Pons | 3049257 | 2020-06-11 13:24:54 +0200 | [diff] [blame] | 2437 | reg32 |= odt[((cas - 3) * 2) + 1]; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2438 | MCHBAR32(C1ODT + 4) = reg32; |
| 2439 | } |
| 2440 | |
| 2441 | /** |
| 2442 | * @brief Enable clocks to populated sockets |
| 2443 | */ |
| 2444 | |
| 2445 | static void sdram_enable_memory_clocks(struct sys_info *sysinfo) |
| 2446 | { |
| 2447 | u8 clocks[2] = { 0, 0 }; |
| 2448 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 2449 | #if CONFIG(NORTHBRIDGE_INTEL_SUBTYPE_I945GM) |
Stefan Reinauer | 24b4df5 | 2010-01-17 13:47:35 +0000 | [diff] [blame] | 2450 | #define CLOCKS_WIDTH 2 |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 2451 | #elif CONFIG(NORTHBRIDGE_INTEL_SUBTYPE_I945GC) |
Stefan Reinauer | 24b4df5 | 2010-01-17 13:47:35 +0000 | [diff] [blame] | 2452 | #define CLOCKS_WIDTH 3 |
| 2453 | #endif |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2454 | if (sysinfo->dimm[0] != SYSINFO_DIMM_NOT_POPULATED) |
Angel Pons | 3049257 | 2020-06-11 13:24:54 +0200 | [diff] [blame] | 2455 | clocks[0] |= (1 << CLOCKS_WIDTH) - 1; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2456 | |
| 2457 | if (sysinfo->dimm[1] != SYSINFO_DIMM_NOT_POPULATED) |
Angel Pons | 3049257 | 2020-06-11 13:24:54 +0200 | [diff] [blame] | 2458 | clocks[0] |= ((1 << CLOCKS_WIDTH) - 1) << CLOCKS_WIDTH; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2459 | |
| 2460 | if (sysinfo->dimm[2] != SYSINFO_DIMM_NOT_POPULATED) |
Angel Pons | 3049257 | 2020-06-11 13:24:54 +0200 | [diff] [blame] | 2461 | clocks[1] |= (1 << CLOCKS_WIDTH) - 1; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2462 | |
| 2463 | if (sysinfo->dimm[3] != SYSINFO_DIMM_NOT_POPULATED) |
Angel Pons | 3049257 | 2020-06-11 13:24:54 +0200 | [diff] [blame] | 2464 | clocks[1] |= ((1 << CLOCKS_WIDTH) - 1) << CLOCKS_WIDTH; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2465 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 2466 | #if CONFIG(OVERRIDE_CLOCK_DISABLE) |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 2467 | /* Usually system firmware turns off system memory clock signals to unused SO-DIMM slots |
| 2468 | * to reduce EMI and power consumption. |
| 2469 | * However, the Kontron 986LCD-M does not like unused clock signals to be disabled. |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 2470 | */ |
| 2471 | |
| 2472 | clocks[0] = 0xf; /* force all clock gate pairs to enable */ |
| 2473 | clocks[1] = 0xf; /* force all clock gate pairs to enable */ |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2474 | #endif |
| 2475 | |
| 2476 | MCHBAR8(C0DCLKDIS) = clocks[0]; |
| 2477 | MCHBAR8(C1DCLKDIS) = clocks[1]; |
| 2478 | } |
| 2479 | |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 2480 | #define RTT_ODT_NONE 0 |
Elyes HAOUAS | 95cdd9f | 2020-03-26 12:20:38 +0100 | [diff] [blame] | 2481 | #define RTT_ODT_50_OHM ((1 << 9) | (1 << 5)) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2482 | #define RTT_ODT_75_OHM (1 << 5) |
| 2483 | #define RTT_ODT_150_OHM (1 << 9) |
| 2484 | |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 2485 | #define EMRS_OCD_DEFAULT ((1 << 12) | (1 << 11) | (1 << 10)) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2486 | |
| 2487 | #define MRS_CAS_3 (3 << 7) |
| 2488 | #define MRS_CAS_4 (4 << 7) |
| 2489 | #define MRS_CAS_5 (5 << 7) |
| 2490 | |
| 2491 | #define MRS_TWR_3 (2 << 12) |
| 2492 | #define MRS_TWR_4 (3 << 12) |
| 2493 | #define MRS_TWR_5 (4 << 12) |
| 2494 | |
| 2495 | #define MRS_BT (1 << 6) |
| 2496 | |
| 2497 | #define MRS_BL4 (2 << 3) |
| 2498 | #define MRS_BL8 (3 << 3) |
| 2499 | |
| 2500 | static void sdram_jedec_enable(struct sys_info *sysinfo) |
| 2501 | { |
| 2502 | int i, nonzero; |
| 2503 | u32 bankaddr = 0, tmpaddr, mrsaddr = 0; |
| 2504 | |
| 2505 | for (i = 0, nonzero = -1; i < 8; i++) { |
Elyes HAOUAS | 0191220 | 2019-01-19 16:36:38 +0100 | [diff] [blame] | 2506 | if (sysinfo->banksize[i] == 0) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2507 | continue; |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 2508 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 2509 | printk(BIOS_DEBUG, "jedec enable sequence: bank %d\n", i); |
Elyes HAOUAS | 0191220 | 2019-01-19 16:36:38 +0100 | [diff] [blame] | 2510 | |
| 2511 | if (nonzero != -1) { |
| 2512 | if (sysinfo->interleaved && nonzero < 4 && i >= 4) { |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2513 | bankaddr = 0x40; |
Elyes HAOUAS | 0191220 | 2019-01-19 16:36:38 +0100 | [diff] [blame] | 2514 | } else { |
Elyes HAOUAS | 95cdd9f | 2020-03-26 12:20:38 +0100 | [diff] [blame] | 2515 | printk(BIOS_DEBUG, "bankaddr from bank size of rank %d\n", |
| 2516 | nonzero); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 2517 | bankaddr += sysinfo->banksize[nonzero] << |
| 2518 | (sysinfo->interleaved ? 26 : 25); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2519 | } |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2520 | } |
| 2521 | |
Elyes HAOUAS | 95cdd9f | 2020-03-26 12:20:38 +0100 | [diff] [blame] | 2522 | /* |
| 2523 | * We have a bank with a non-zero size... Remember it |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2524 | * for the next offset we have to calculate |
| 2525 | */ |
| 2526 | nonzero = i; |
| 2527 | |
| 2528 | /* Get CAS latency set up */ |
| 2529 | switch (sysinfo->cas) { |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 2530 | case 5: |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 2531 | mrsaddr = MRS_CAS_5; |
| 2532 | break; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 2533 | case 4: |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 2534 | mrsaddr = MRS_CAS_4; |
| 2535 | break; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 2536 | case 3: |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 2537 | mrsaddr = MRS_CAS_3; |
| 2538 | break; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 2539 | default: |
| 2540 | die("Jedec Error (CAS).\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2541 | } |
| 2542 | |
| 2543 | /* Get tWR set */ |
| 2544 | switch (sysinfo->twr) { |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 2545 | case 5: |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 2546 | mrsaddr |= MRS_TWR_5; |
| 2547 | break; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 2548 | case 4: |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 2549 | mrsaddr |= MRS_TWR_4; |
| 2550 | break; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 2551 | case 3: |
Elyes HAOUAS | 3dff32c | 2020-03-30 17:16:51 +0200 | [diff] [blame] | 2552 | mrsaddr |= MRS_TWR_3; |
| 2553 | break; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 2554 | default: |
| 2555 | die("Jedec Error (tWR).\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2556 | } |
| 2557 | |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 2558 | /* Set "Burst Type" */ |
| 2559 | mrsaddr |= MRS_BT; |
| 2560 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2561 | /* Interleaved */ |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 2562 | if (sysinfo->interleaved) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2563 | mrsaddr = mrsaddr << 1; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2564 | |
| 2565 | /* Only burst length 8 supported */ |
| 2566 | mrsaddr |= MRS_BL8; |
| 2567 | |
| 2568 | /* Apply NOP */ |
Stefan Reinauer | 779b3e3 | 2008-11-10 15:43:37 +0000 | [diff] [blame] | 2569 | PRINTK_DEBUG("Apply NOP\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2570 | do_ram_command(RAM_COMMAND_NOP); |
| 2571 | ram_read32(bankaddr); |
| 2572 | |
| 2573 | /* Precharge all banks */ |
Stefan Reinauer | 779b3e3 | 2008-11-10 15:43:37 +0000 | [diff] [blame] | 2574 | PRINTK_DEBUG("All Banks Precharge\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2575 | do_ram_command(RAM_COMMAND_PRECHARGE); |
| 2576 | ram_read32(bankaddr); |
| 2577 | |
| 2578 | /* Extended Mode Register Set (2) */ |
Stefan Reinauer | 779b3e3 | 2008-11-10 15:43:37 +0000 | [diff] [blame] | 2579 | PRINTK_DEBUG("Extended Mode Register Set(2)\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2580 | do_ram_command(RAM_COMMAND_EMRS | RAM_EMRS_2); |
| 2581 | ram_read32(bankaddr); |
| 2582 | |
| 2583 | /* Extended Mode Register Set (3) */ |
Stefan Reinauer | 779b3e3 | 2008-11-10 15:43:37 +0000 | [diff] [blame] | 2584 | PRINTK_DEBUG("Extended Mode Register Set(3)\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2585 | do_ram_command(RAM_COMMAND_EMRS | RAM_EMRS_3); |
| 2586 | ram_read32(bankaddr); |
| 2587 | |
| 2588 | /* Extended Mode Register Set */ |
Stefan Reinauer | 779b3e3 | 2008-11-10 15:43:37 +0000 | [diff] [blame] | 2589 | PRINTK_DEBUG("Extended Mode Register Set\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2590 | do_ram_command(RAM_COMMAND_EMRS | RAM_EMRS_1); |
| 2591 | tmpaddr = bankaddr; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 2592 | if (!sdram_capabilities_dual_channel()) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2593 | tmpaddr |= RTT_ODT_75_OHM; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 2594 | else if (sysinfo->interleaved) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2595 | tmpaddr |= (RTT_ODT_150_OHM << 1); |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 2596 | else |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2597 | tmpaddr |= RTT_ODT_150_OHM; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2598 | ram_read32(tmpaddr); |
| 2599 | |
| 2600 | /* Mode Register Set: Reset DLLs */ |
Stefan Reinauer | 779b3e3 | 2008-11-10 15:43:37 +0000 | [diff] [blame] | 2601 | PRINTK_DEBUG("MRS: Reset DLLs\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2602 | do_ram_command(RAM_COMMAND_MRS); |
| 2603 | tmpaddr = bankaddr; |
| 2604 | tmpaddr |= mrsaddr; |
| 2605 | /* Set DLL reset bit */ |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 2606 | if (sysinfo->interleaved) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2607 | tmpaddr |= (1 << 12); |
| 2608 | else |
| 2609 | tmpaddr |= (1 << 11); |
| 2610 | ram_read32(tmpaddr); |
| 2611 | |
| 2612 | /* Precharge all banks */ |
Stefan Reinauer | 779b3e3 | 2008-11-10 15:43:37 +0000 | [diff] [blame] | 2613 | PRINTK_DEBUG("All Banks Precharge\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2614 | do_ram_command(RAM_COMMAND_PRECHARGE); |
| 2615 | ram_read32(bankaddr); |
| 2616 | |
| 2617 | /* CAS before RAS Refresh */ |
Stefan Reinauer | 779b3e3 | 2008-11-10 15:43:37 +0000 | [diff] [blame] | 2618 | PRINTK_DEBUG("CAS before RAS\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2619 | do_ram_command(RAM_COMMAND_CBR); |
| 2620 | |
| 2621 | /* CBR wants two READs */ |
| 2622 | ram_read32(bankaddr); |
| 2623 | ram_read32(bankaddr); |
| 2624 | |
| 2625 | /* Mode Register Set: Enable DLLs */ |
Stefan Reinauer | 779b3e3 | 2008-11-10 15:43:37 +0000 | [diff] [blame] | 2626 | PRINTK_DEBUG("MRS: Enable DLLs\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2627 | do_ram_command(RAM_COMMAND_MRS); |
| 2628 | |
| 2629 | tmpaddr = bankaddr; |
| 2630 | tmpaddr |= mrsaddr; |
| 2631 | ram_read32(tmpaddr); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 2632 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2633 | /* Extended Mode Register Set */ |
Stefan Reinauer | 779b3e3 | 2008-11-10 15:43:37 +0000 | [diff] [blame] | 2634 | PRINTK_DEBUG("Extended Mode Register Set: ODT/OCD\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2635 | do_ram_command(RAM_COMMAND_EMRS | RAM_EMRS_1); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 2636 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2637 | tmpaddr = bankaddr; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 2638 | if (!sdram_capabilities_dual_channel()) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2639 | tmpaddr |= RTT_ODT_75_OHM | EMRS_OCD_DEFAULT; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 2640 | else if (sysinfo->interleaved) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2641 | tmpaddr |= ((RTT_ODT_150_OHM | EMRS_OCD_DEFAULT) << 1); |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 2642 | else |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2643 | tmpaddr |= RTT_ODT_150_OHM | EMRS_OCD_DEFAULT; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2644 | ram_read32(tmpaddr); |
| 2645 | |
| 2646 | /* Extended Mode Register Set */ |
Stefan Reinauer | 779b3e3 | 2008-11-10 15:43:37 +0000 | [diff] [blame] | 2647 | PRINTK_DEBUG("Extended Mode Register Set: OCD Exit\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2648 | do_ram_command(RAM_COMMAND_EMRS | RAM_EMRS_1); |
| 2649 | |
| 2650 | tmpaddr = bankaddr; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 2651 | if (!sdram_capabilities_dual_channel()) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2652 | tmpaddr |= RTT_ODT_75_OHM; |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 2653 | else if (sysinfo->interleaved) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2654 | tmpaddr |= (RTT_ODT_150_OHM << 1); |
Arthur Heymans | 70a8e34 | 2017-03-09 11:30:23 +0100 | [diff] [blame] | 2655 | else |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2656 | tmpaddr |= RTT_ODT_150_OHM; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2657 | ram_read32(tmpaddr); |
| 2658 | } |
| 2659 | } |
| 2660 | |
| 2661 | static void sdram_init_complete(void) |
| 2662 | { |
Stefan Reinauer | 779b3e3 | 2008-11-10 15:43:37 +0000 | [diff] [blame] | 2663 | PRINTK_DEBUG("Normal Operation\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2664 | do_ram_command(RAM_COMMAND_NORMAL); |
| 2665 | } |
| 2666 | |
| 2667 | static void sdram_setup_processor_side(void) |
| 2668 | { |
| 2669 | if (i945_silicon_revision() == 0) |
| 2670 | MCHBAR32(FSBPMC3) |= (1 << 2); |
| 2671 | |
| 2672 | MCHBAR8(0xb00) |= 1; |
| 2673 | |
| 2674 | if (i945_silicon_revision() == 0) |
| 2675 | MCHBAR32(SLPCTL) |= (1 << 8); |
| 2676 | } |
| 2677 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2678 | /** |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 2679 | * @param boot_path: 0 = normal, 1 = reset, 2 = resume from s3 |
Martin Roth | f4cb412 | 2015-01-06 10:27:39 -0700 | [diff] [blame] | 2680 | * @param spd_addresses pointer to a list of SPD addresses |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2681 | */ |
Sven Schnelle | 541269b | 2011-02-21 09:39:17 +0000 | [diff] [blame] | 2682 | void sdram_initialize(int boot_path, const u8 *spd_addresses) |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2683 | { |
| 2684 | struct sys_info sysinfo; |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2685 | |
Patrick Georgi | 771328f | 2015-07-13 19:24:07 +0200 | [diff] [blame] | 2686 | timestamp_add_now(TS_BEFORE_INITRAM); |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 2687 | printk(BIOS_DEBUG, "Setting up RAM controller.\n"); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2688 | |
| 2689 | memset(&sysinfo, 0, sizeof(sysinfo)); |
| 2690 | |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 2691 | sysinfo.boot_path = boot_path; |
Sven Schnelle | 541269b | 2011-02-21 09:39:17 +0000 | [diff] [blame] | 2692 | sysinfo.spd_addresses = spd_addresses; |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 2693 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2694 | /* Look at the type of DIMMs and verify all DIMMs are x8 or x16 width */ |
| 2695 | sdram_get_dram_configuration(&sysinfo); |
| 2696 | |
Stefan Reinauer | bf264e9 | 2010-05-14 19:09:20 +0000 | [diff] [blame] | 2697 | /* If error, do cold boot */ |
| 2698 | sdram_detect_errors(&sysinfo); |
| 2699 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2700 | /* Program PLL settings */ |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 2701 | sdram_program_pll_settings(&sysinfo); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2702 | |
Arthur Heymans | 1853781 | 2016-12-28 21:20:45 +0100 | [diff] [blame] | 2703 | /* |
| 2704 | * Program Graphics Frequency |
| 2705 | * Set core display and render clock on 945GC to the max |
| 2706 | */ |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 2707 | if (CONFIG(NORTHBRIDGE_INTEL_SUBTYPE_I945GM)) |
Arthur Heymans | 1853781 | 2016-12-28 21:20:45 +0100 | [diff] [blame] | 2708 | sdram_program_graphics_frequency(&sysinfo); |
| 2709 | else |
Angel Pons | 3580d81 | 2020-06-11 14:13:33 +0200 | [diff] [blame] | 2710 | pci_write_config16(IGD_DEV, GCFC, 0x0534); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2711 | |
| 2712 | /* Program System Memory Frequency */ |
| 2713 | sdram_program_memory_frequency(&sysinfo); |
| 2714 | |
| 2715 | /* Determine Mode of Operation (Interleaved etc) */ |
| 2716 | sdram_set_channel_mode(&sysinfo); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 2717 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2718 | /* Program Clock Crossing values */ |
| 2719 | sdram_program_clock_crossing(); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 2720 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2721 | /* Disable fast dispatch */ |
| 2722 | sdram_disable_fast_dispatch(); |
| 2723 | |
| 2724 | /* Enable WIODLL Power Down in ACPI states */ |
| 2725 | MCHBAR32(C0DMC) |= (1 << 24); |
| 2726 | MCHBAR32(C1DMC) |= (1 << 24); |
| 2727 | |
| 2728 | /* Program DRAM Row Boundary/Attribute Registers */ |
| 2729 | |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 2730 | /* program row size DRB and set TOLUD */ |
| 2731 | sdram_program_row_boundaries(&sysinfo); |
| 2732 | |
| 2733 | /* program page size DRA */ |
| 2734 | sdram_set_row_attributes(&sysinfo); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2735 | |
| 2736 | /* Program CxBNKARC */ |
| 2737 | sdram_set_bank_architecture(&sysinfo); |
| 2738 | |
| 2739 | /* Program DRAM Timing and Control registers based on SPD */ |
| 2740 | sdram_set_timing_and_control(&sysinfo); |
| 2741 | |
| 2742 | /* On-Die Termination Adjustment */ |
| 2743 | sdram_on_die_termination(&sysinfo); |
| 2744 | |
| 2745 | /* Pre Jedec Initialization */ |
| 2746 | sdram_pre_jedec_initialization(); |
| 2747 | |
| 2748 | /* Perform System Memory IO Initialization */ |
| 2749 | sdram_initialize_system_memory_io(&sysinfo); |
| 2750 | |
| 2751 | /* Perform System Memory IO Buffer Enable */ |
| 2752 | sdram_enable_system_memory_io(&sysinfo); |
| 2753 | |
| 2754 | /* Enable System Memory Clocks */ |
| 2755 | sdram_enable_memory_clocks(&sysinfo); |
| 2756 | |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 2757 | if (boot_path == BOOT_PATH_NORMAL) { |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2758 | /* Jedec Initialization sequence */ |
| 2759 | sdram_jedec_enable(&sysinfo); |
| 2760 | } |
| 2761 | |
| 2762 | /* Program Power Management Registers */ |
| 2763 | sdram_power_management(&sysinfo); |
| 2764 | |
| 2765 | /* Post Jedec Init */ |
| 2766 | sdram_post_jedec_initialization(&sysinfo); |
| 2767 | |
| 2768 | /* Program DRAM Throttling */ |
| 2769 | sdram_thermal_management(); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 2770 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2771 | /* Normal Operations */ |
Stefan Reinauer | aca6ec6 | 2009-10-26 17:12:21 +0000 | [diff] [blame] | 2772 | sdram_init_complete(); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2773 | |
| 2774 | /* Program Receive Enable Timings */ |
| 2775 | sdram_program_receive_enable(&sysinfo); |
| 2776 | |
| 2777 | /* Enable Periodic RCOMP */ |
| 2778 | sdram_enable_rcomp(); |
| 2779 | |
| 2780 | /* Tell ICH7 that we're done */ |
Angel Pons | e3c68d2 | 2020-06-08 12:09:03 +0200 | [diff] [blame] | 2781 | pci_and_config8(PCI_DEV(0, 0x1f, 0), GEN_PMCON_2, (u8)~(1 << 7)); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2782 | |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 2783 | printk(BIOS_DEBUG, "RAM initialization finished.\n"); |
Stefan Reinauer | 71a3d96 | 2009-07-21 21:44:24 +0000 | [diff] [blame] | 2784 | |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2785 | sdram_setup_processor_side(); |
Patrick Georgi | 771328f | 2015-07-13 19:24:07 +0200 | [diff] [blame] | 2786 | timestamp_add_now(TS_AFTER_INITRAM); |
Stefan Reinauer | 278534d | 2008-10-29 04:51:07 +0000 | [diff] [blame] | 2787 | } |