1 /* This was originally for the e7500, modified for e7501
2 * The primary differences are that 7501 apparently can
3 * support single channel RAM (i haven't tested),
4 * CAS1.5 is no longer supported, The ECC scrubber
5 * now supports a mode to zero RAM and init ECC in one step
6 * and the undocumented registers at 0x80 require new
7 * (undocumented) values determined by guesswork and
8 * comparison w/ OEM BIOS values.
9 * Steven James 02/06/2003
12 /* converted to C 6/2004 yhlu */
16 #include <sdram_mode.h>
20 // Uncomment this to enable run-time checking of DIMM parameters
21 // for dual-channel operation
22 // Unfortunately the code seems to chew up several K of space.
23 //#define VALIDATE_DIMM_COMPATIBILITY
25 // Uncomment this to enable local debugging messages
26 //#define DEBUG_RAM_CONFIG
28 #if defined(DEBUG_RAM_CONFIG)
29 #define RAM_DEBUG_MESSAGE(x) print_debug(x)
30 #define RAM_DEBUG_HEX32(x) print_debug_hex32(x)
31 #define RAM_DEBUG_HEX8(x) print_debug_hex8(x)
32 #define DUMPNORTH() dump_pci_device(PCI_DEV(0, 0, 0))
34 #define RAM_DEBUG_MESSAGE(x)
35 #define RAM_DEBUG_HEX32(x)
36 #define RAM_DEBUG_HEX8(x)
40 #define E7501_SDRAM_MODE (SDRAM_BURST_INTERLEAVED | SDRAM_BURST_4)
41 #define SPD_ERROR "Error reading SPD info\r\n"
43 // NOTE: This used to be 0x100000.
44 // That doesn't work on systems where A20M# is asserted, because
45 // attempts to access 0x1000NN end up accessing 0x0000NN.
46 #define RCOMP_MMIO 0x200000
53 /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
55 /**********************************************************************************/
57 static const uint32_t refresh_frequency[]= {
58 /* Relative frequency (array value) of each E7501 Refresh Mode Select
59 * (RMS) value (array index)
60 * 0 == least frequent refresh (longest interval between refreshes)
70 0, 2, 3, 1, 0, 0, 0, 4 };
72 static const uint32_t refresh_rate_map[] = {
73 /* Map the JEDEC spd refresh rates (array index) to E7501 Refresh Mode
74 * Select values (array value)
75 * These are all the rates defined by JESD21-C Appendix D, Rev. 1.0
76 * The E7501 supports only 15.6 us (1), 7.8 us (2), 64 us (3), and
77 * 64 clock (481 ns) (7) refresh.
78 * [0] == 15.625 us -> 15.6 us
79 * [1] == 3.9 us -> 481 ns
80 * [2] == 7.8 us -> 7.8 us
81 * [3] == 31.3 us -> 15.6 us
82 * [4] == 62.5 us -> 15.6 us
83 * [5] == 125 us -> 64 us
87 #define MAX_SPD_REFRESH_RATE ((sizeof(refresh_rate_map) / sizeof(uint32_t)) - 1)
90 // SPD parameters that must match for dual-channel operation
91 static const uint8_t dual_channel_parameters[] = {
97 SPD_PRIMARY_SDRAM_WIDTH,
98 SPD_NUM_BANKS_PER_SDRAM
102 * Table: constant_register_values
104 static const long constant_register_values[] = {
105 /* SVID - Subsystem Vendor Identification Register
107 * [15:00] Subsytem Vendor ID (Indicates system board vendor)
109 /* SID - Subsystem Identification Register
111 * [15:00] Subsystem ID
113 // Not everyone wants to be Super Micro Computer, Inc.
114 // The mainboard should set this if desired.
115 // 0x2c, 0, (0x15d9 << 0) | (0x3580 << 16),
118 * (DRAM Read Timing Control, if similar to 855PM?)
120 * This register has something to do with CAS latencies,
121 * possibily this is the real chipset control.
122 * At 0x00 CAS latency 1.5 works.
123 * At 0x06 CAS latency 2.5 works.
124 * At 0x01 CAS latency 2.0 works.
126 /* This is still undocumented in e7501, but with different values
127 * CAS 2.0 values taken from Intel BIOS settings, others are a guess
128 * and may be terribly wrong. Old values preserved as comments until I
129 * figure this out for sure.
130 * e7501 docs claim that CAS1.5 is unsupported, so it may or may not
132 * Steven James 02/06/2003
134 /* NOTE: values now configured in configure_e7501_cas_latency() based
135 * on SPD info and total number of DIMMs (per Intel)
138 /* FDHC - Fixed DRAM Hole Control
141 * 0 == No memory Hole
142 * 1 == Memory Hole from 15MB to 16MB
145 * PAM - Programmable Attribute Map
146 * 0x59 [1:0] Reserved
147 * 0x59 [5:4] 0xF0000 - 0xFFFFF
148 * 0x5A [1:0] 0xC0000 - 0xC3FFF
149 * 0x5A [5:4] 0xC4000 - 0xC7FFF
150 * 0x5B [1:0] 0xC8000 - 0xCBFFF
151 * 0x5B [5:4] 0xCC000 - 0xCFFFF
152 * 0x5C [1:0] 0xD0000 - 0xD3FFF
153 * 0x5C [5:4] 0xD4000 - 0xD7FFF
154 * 0x5D [1:0] 0xD8000 - 0xDBFFF
155 * 0x5D [5:4] 0xDC000 - 0xDFFFF
156 * 0x5E [1:0] 0xE0000 - 0xE3FFF
157 * 0x5E [5:4] 0xE4000 - 0xE7FFF
158 * 0x5F [1:0] 0xE8000 - 0xEBFFF
159 * 0x5F [5:4] 0xEC000 - 0xEFFFF
160 * 00 == DRAM Disabled (All Access go to memory mapped I/O space)
161 * 01 == Read Only (Reads to DRAM, Writes to memory mapped I/O space)
162 * 10 == Write Only (Writes to DRAM, Reads to memory mapped I/O space)
163 * 11 == Normal (All Access go to DRAM)
166 // Map all legacy ranges to DRAM
167 0x58, 0xcccccf7f, (0x00 << 0) | (0x30 << 8) | (0x33 << 16) | (0x33 << 24),
168 0x5C, 0xcccccccc, (0x33 << 0) | (0x33 << 8) | (0x33 << 16) | (0x33 << 24),
170 /* DRB - DRAM Row Boundary Registers
172 * An array of 8 byte registers, which hold the ending
173 * memory address assigned to each pair of DIMMS, in 64MB
176 // Conservatively say each row has 64MB of ram, we will fix this up later
177 // NOTE: These defaults allow us to prime all of the DIMMs on the board
178 // without jumping through 36-bit adddressing hoops, even if the
179 // total memory is > 4 GB. Changing these values may break do_ram_command()!
180 0x60, 0x00000000, (0x01 << 0) | (0x02 << 8) | (0x03 << 16) | (0x04 << 24),
181 0x64, 0x00000000, (0x05 << 0) | (0x06 << 8) | (0x07 << 16) | (0x08 << 24),
183 /* DRA - DRAM Row Attribute Register
188 * [7:7] Device width for Odd numbered rows
189 * 0 == 8 bits wide x8
190 * 1 == 4 bits wide x4
191 * [6:4] Row Attributes for Odd numbered rows
192 * 010 == 8KB (for dual-channel)
193 * 011 == 16KB (for dual-channel)
194 * 100 == 32KB (for dual-channel)
195 * 101 == 64KB (for dual-channel)
197 * [3:3] Device width for Even numbered rows
198 * 0 == 8 bits wide x8
199 * 1 == 4 bits wide x4
200 * [2:0] Row Attributes for Even numbered rows
201 * 010 == 8KB (for dual-channel)
202 * 011 == 16KB (for dual-channel)
203 * 100 == 32KB (for dual-channel)
204 * 101 == 64KB (This page size appears broken)
207 // NOTE: overridden by configure_e7501_row_attributes(), later
210 /* DRT - DRAM Timing Register
213 * [29:29] Back to Back Write-Read Turn Around
214 * 0 == 3 clocks between WR-RD commands
215 * 1 == 2 clocks between WR-RD commands
216 * [28:28] Back to Back Read-Write Turn Around
217 * 0 == 5 clocks between RD-WR commands
218 * 1 == 4 clocks between RD-WR commands
219 * [27:27] Back to Back Read Turn Around
220 * 0 == 4 clocks between RD commands
221 * 1 == 3 clocks between RD commands
222 * [26:24] Read Delay (tRD)
228 * [18:16] DRAM idle timer
230 * 011 == 16 dram clocks
233 * [10:09] Active to Precharge (tRAS)
239 * [05:04] Cas Latency (tCL)
242 * 10 == Reserved (was 1.5 Clocks for E7500)
244 * [03:03] Write Ras# to Cas# Delay (tRCD)
247 * [02:01] Read RAS# to CAS# Delay (tRCD)
250 * 10 == 3 DRAM Clocks
251 * 11 == 2 DRAM Clocks
252 * [00:00] DRAM RAS# to Precharge (tRP)
257 // Some earlier settings:
258 /* Most aggressive settings possible */
259 // 0x78, 0xc0fff8c4, (1<<29)|(1<<28)|(1<<27)|(2<<24)|(2<<9)|CAS_LATENCY|(1<<3)|(1<<1)|(1<<0),
260 // 0x78, 0xc0f8f8c0, (1<<29)|(1<<28)|(1<<27)|(1<<24)|(1<<16)|(2<<9)|CAS_LATENCY|(1<<3)|(3<<1)|(1<<0),
261 // 0x78, 0xc0f8f9c0, (1<<29)|(1<<28)|(1<<27)|(1<<24)|(1<<16)|(2<<9)|CAS_LATENCY|(1<<3)|(3<<1)|(1<<0),
263 // The only things we need to set here are DRAM idle timer, Back-to-Back Read Turnaround, and
264 // Back-to-Back Write-Read Turnaround. All others are configured based on SPD.
265 0x78, 0xD7F8FFFF, (1<<29)|(1<<27)|(1<<16),
267 /* FIXME why was I attempting to set a reserved bit? */
270 /* DRC - DRAM Contoller Mode Register
273 * [29:29] Initialization Complete
278 * 0 == Single channel
280 * [21:20] DRAM Data Integrity Mode
281 * 00 == Disabled, no ECC
283 * 10 == Error checking, using chip-kill, with correction
285 * [19:18] DRB Granularity (Read-Only)
286 * 00 == 32 MB quantities (single channel mode)
287 * 01 == 64 MB quantities (dual-channel mode)
290 * [17:17] (Intel Undocumented) should always be set to 1 (SJM: comment inconsistent with current setting, below)
291 * [16:16] Command Per Clock - Address/Control Assertion Rule (CPC)
295 * [10:08] Refresh mode select
296 * 000 == Refresh disabled
297 * 001 == Refresh interval 15.6 usec
298 * 010 == Refresh interval 7.8 usec
299 * 011 == Refresh interval 64 usec
300 * 111 == Refresh every 64 clocks (fast refresh)
302 * [06:04] Mode Select (SMS)
303 * 000 == Reserved (was Self Refresh Mode in E7500)
305 * 010 == All Banks Precharge
306 * 011 == Mode Register Set
307 * 100 == Extended Mode Register Set
310 * 111 == Normal Operation
313 // .long 0x7c, 0xffcefcff, (1<<22)|(2 << 20)|(1 << 16)| (0 << 8),
314 // .long 0x7c, 0xff8cfcff, (1<<22)|(2 << 20)|(1 << 17)|(1 << 16)| (0 << 8),
315 // .long 0x7c, 0xff80fcff, (1<<22)|(2 << 20)|(1 << 18)|(1 << 17)|(1 << 16)| (0 << 8),
317 // Default to dual-channel mode, ECC, 1-clock address/cmd hold
318 // NOTE: configure_e7501_dram_controller_mode() configures further
319 0x7c, 0xff8ef8ff, (1<<22)|(2<<20)|(1<<16)|(0<<8),
321 /* Another Intel undocumented register
323 * [31:31] Purpose unknown
324 * [26:26] Master DLL Reset?
325 * 0 == Normal operation?
327 * [07:07] Periodic memory recalibration?
330 * [04:04] Receive FIFO RE-Sync?
331 * 0 == Normal operation?
334 // NOTE: Some factory BIOSs don't do this.
335 // Doesn't seem to matter either way.
336 0x88, 0xffffff00, 0x80,
338 /* CLOCK_DIS - CK/CK# Disable Register
340 * [7:7] DDR Frequency
341 * 0 == 100 MHz (200 MHz data rate)
342 * 1 == 133 MHz (266 MHz data rate)
357 // NOTE: Disable all clocks initially; turn ones we need back on
358 // in enable_e7501_clocks()
359 0x8C, 0xfffffff0, 0xf,
361 /* TOLM - Top of Low Memory Register
363 * [15:11] Top of low memory (TOLM)
364 * The address below 4GB that should be treated as RAM,
365 * on a 128MB granularity.
368 /* REMAPBASE - Remap Base Address Regsiter
371 * [09:00] Remap Base Address [35:26] 64M aligned
372 * Bits [25:0] are assumed to be 0.
375 // NOTE: TOLM overridden by configure_e7501_ram_addresses()
376 0xc4, 0xfc0007ff, (0x2000 << 0) | (0x3ff << 16),
378 /* REMAPLIMIT - Remap Limit Address Register
381 * [09:00] Remap Limit Address [35:26] 64M aligned
382 * When remaplimit < remapbase the remap window is disabled.
386 /* DVNP - Device Not Present Register
389 * [04:04] Device 4 Function 1 Present
392 * [03:03] Device 3 Function 1 Present
395 * [02:02] Device 2 Function 1 Present
399 * [00:00] Device 0 Function 1 Present
404 // Enable D0:D1, disable D2:F1, D3:F1, D4:F1
405 0xe0, 0xffffffe2, (1<<4)|(1<<3)|(1<<2)|(0<<0),
408 0xd8, 0xffff9fff, 0x00000000,
410 // Undocumented - this is pure conjecture based on similarity to 855PM
411 /* MCHTST - MCH Test Register
413 * [31:31] Purpose unknown
414 * [30:30] Purpose unknown
415 * [29:23] Unknown - not used?
416 * [22:22] System Memory MMR Enable
417 * 0 == Disable: mem space and BAR at 0x14 are not accessible
418 * 1 == Enable: mem space and BAR at 0x14 are accessible
419 * [21:20] Purpose unknown
420 * [19:02] Unknown - not used?
421 * [01:01] D6EN (Device #6 enable)
424 * [00:00] Unknown - not used?
427 0xf4, 0x3f8ffffd, 0x40300002,
429 #ifdef SUSPICIOUS_LOOKING_CODE
430 // SJM: Undocumented.
431 // This will access D2:F0:0x50, is this correct??
432 0x1050, 0xffffffcf, 0x00000030,
436 /* DDR RECOMP tables */
438 // Slew table for 1x drive?
439 static const uint32_t maybe_1x_slew_table[] = {
440 0x44332211, 0xc9776655, 0xffffffff, 0xffffffff,
441 0x22111111, 0x55444332, 0xfffca876, 0xffffffff,
444 // Slew table for 2x drive?
445 static const uint32_t maybe_2x_slew_table[] = {
446 0x00000000, 0x76543210, 0xffffeca8, 0xffffffff,
447 0x21000000, 0xa8765432, 0xffffffec, 0xffffffff,
450 // Pull Up / Pull Down offset table, if analogous to IXP2800?
451 static const uint32_t maybe_pull_updown_offset_table[] = {
452 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
453 0x88888888, 0x88888888, 0x88888888, 0x88888888,
456 /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
458 /**********************************************************************************/
459 #define SLOW_DOWN_IO inb(0x80);
460 //#define SLOW_DOWN_IO udelay(40);
462 /* Estimate that SLOW_DOWN_IO takes about 50&76us*/
463 /* delay for 200us */
466 static void do_delay(void)
469 for(i = 0; i < 16; i++) { SLOW_DOWN_IO }
471 #define DO_DELAY do_delay();
477 #define EXTRA_DELAY DO_DELAY
480 /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
481 /* DELAY FUNCTIONS */
482 /**********************************************************************************/
484 static void die_on_spd_error(int spd_return_value)
486 if (spd_return_value < 0)
487 die("Error reading SPD info\r\n");
490 //----------------------------------------------------------------------------------
491 // Function: sdram_spd_get_page_size
492 // Parameters: dimm_socket_address - SMBus address of DIMM socket to interrogate
493 // Return Value: struct dimm_size - log2(page size) for each side of the DIMM.
494 // Description: Calculate the page size for each physical bank of the DIMM:
495 // log2(page size) = (# columns) + log2(data width)
497 // NOTE: page size is the total number of data bits in a row.
499 static struct dimm_size sdram_spd_get_page_size(uint16_t dimm_socket_address)
501 uint16_t module_data_width;
503 struct dimm_size pgsz;
509 value = spd_read_byte(dimm_socket_address, SPD_NUM_COLUMNS);
510 if (value < 0) goto hw_err;
511 pgsz.side1 = value & 0xf; // # columns in bank 1
513 /* Get the module data width and convert it to a power of two */
514 value = spd_read_byte(dimm_socket_address, SPD_MODULE_DATA_WIDTH_MSB);
515 if (value < 0) goto hw_err;
516 module_data_width = (value & 0xff) << 8;
518 value = spd_read_byte(dimm_socket_address, SPD_MODULE_DATA_WIDTH_LSB);
519 if (value < 0) goto hw_err;
520 module_data_width |= (value & 0xff);
522 pgsz.side1 += log2(module_data_width);
525 value = spd_read_byte(dimm_socket_address, SPD_NUM_DIMM_BANKS);
526 if (value < 0) goto hw_err;
528 die("Bad SPD value\r\n");
531 pgsz.side2 = pgsz.side1; // Assume symmetric banks until we know differently
532 value = spd_read_byte(dimm_socket_address, SPD_NUM_COLUMNS);
533 if (value < 0) goto hw_err;
534 if ((value & 0xf0) != 0) {
536 pgsz.side2 -= value & 0xf; /* Subtract out columns on side 1 */
537 pgsz.side2 += (value>>4) & 0xf; /* Add in columns on side 2 */
545 return pgsz; // Never reached
549 //----------------------------------------------------------------------------------
550 // Function: sdram_spd_get_width
551 // Parameters: dimm_socket_address - SMBus address of DIMM socket to interrogate
552 // Return Value: dimm_size - width in bits of each DIMM side's DRAMs.
553 // Description: Read the width in bits of each DIMM side's DRAMs via SPD.
556 static struct dimm_size sdram_spd_get_width(uint16_t dimm_socket_address)
559 struct dimm_size width;
564 value = spd_read_byte(dimm_socket_address, SPD_PRIMARY_SDRAM_WIDTH);
565 die_on_spd_error(value);
567 width.side1 = value & 0x7f; // Mask off bank 2 flag
570 width.side2 = width.side1 << 1; // Bank 2 exists and is double-width
572 // If bank 2 exists, it's the same width as bank 1
573 value = spd_read_byte(dimm_socket_address, SPD_NUM_DIMM_BANKS);
574 die_on_spd_error(value);
576 #ifdef ROMCC_IF_BUG_FIXED
578 width.side2 = width.side1;
582 width.side2 = width.side1;
594 //----------------------------------------------------------------------------------
595 // Function: spd_get_dimm_size
596 // Parameters: dimm_socket_address - SMBus address of DIMM socket to interrogate
597 // Return Value: dimm_size - log2(number of bits) for each side of the DIMM
598 // Description: Calculate the log base 2 size in bits of both DIMM sides.
599 // log2(# bits) = (# columns) + log2(data width) +
600 // (# rows) + log2(banks per SDRAM)
602 // Note that it might be easier to use SPD byte 31 here, it has the
603 // DIMM size as a multiple of 4MB. The way we do it now we can size
604 // both sides of an asymmetric dimm.
606 static struct dimm_size spd_get_dimm_size(unsigned dimm_socket_address)
610 // Start with log2(page size)
611 struct dimm_size sz = sdram_spd_get_page_size(dimm_socket_address);
615 value = spd_read_byte(dimm_socket_address, SPD_NUM_ROWS);
616 die_on_spd_error(value);
618 sz.side1 += value & 0xf;
624 sz.side2 += value >> 4; // Asymmetric
626 sz.side2 += value; // Symmetric
629 value = spd_read_byte(dimm_socket_address, SPD_NUM_BANKS_PER_SDRAM);
630 die_on_spd_error(value);
641 //----------------------------------------------------------------------------------
642 // Function: are_spd_values_equal
643 // Parameters: spd_byte_number -
644 // dimmN_address - SMBus addresses of DIMM sockets to interrogate
645 // Return Value: 1 if both DIMM sockets report the same value for the specified
646 // SPD parameter; 0 if the values differed or an error occurred.
647 // Description: Determine whether two DIMMs have the same value for a SPD parameter.
649 static uint8_t are_spd_values_equal(uint8_t spd_byte_number, uint16_t dimm0_address,
650 uint16_t dimm1_address)
654 int dimm0_value = spd_read_byte(dimm0_address, spd_byte_number);
655 int dimm1_value = spd_read_byte(dimm1_address, spd_byte_number);
657 if ((dimm0_value >= 0) && (dimm1_value >= 0) && (dimm0_value == dimm1_value))
663 //----------------------------------------------------------------------------------
664 // Function: spd_get_supported_dimms
665 // Parameters: ctrl - PCI addresses of memory controller functions, and
666 // SMBus addresses of DIMM slots on the mainboard
667 // Return Value: uint8_t - a bitmask indicating which of the possible sockets
668 // for each channel was found to contain a compatible DIMM.
669 // Bit 0 corresponds to the closest socket for channel 0,
670 // Bit 1 to the next socket for channel 0,
672 // Bit MAX_DIMM_SOCKETS_PER_CHANNEL-1 to the last socket for channel 0,
673 // Bit MAX_DIMM_SOCKETS_PER_CHANNEL is the closest socket for channel 1,
675 // Bit 2*MAX_DIMM_SOCKETS_PER_CHANNEL-1 is the last socket for channel 1
676 // Description: Scan for compatible DIMMs.
677 // The code in this module only supports dual-channel operation,
678 // so we test that compatible DIMMs are paired.
680 static uint8_t spd_get_supported_dimms(const struct mem_controller *ctrl)
683 uint8_t dimm_mask = 0;
685 // Have to increase size of dimm_mask if this assertion is violated
686 ASSERT(MAX_DIMM_SOCKETS_PER_CHANNEL <= 4);
688 // Find DIMMs we can support on channel 0.
689 // Then see if the corresponding channel 1 DIMM has the same parameters,
690 // since we only support dual-channel.
692 for (i = 0; i < MAX_DIMM_SOCKETS_PER_CHANNEL; i++) {
694 uint16_t channel0_dimm = ctrl->channel0[i];
695 uint16_t channel1_dimm = ctrl->channel1[i];
696 uint8_t bDualChannel = 1;
697 struct dimm_size page_size;
698 struct dimm_size sdram_width;
702 if (channel0_dimm == 0)
703 continue; // No such socket on this mainboard
705 if (spd_read_byte(channel0_dimm, SPD_MEMORY_TYPE) != SPD_MEMORY_TYPE_SDRAM_DDR)
708 #ifdef VALIDATE_DIMM_COMPATIBILITY
709 if (spd_read_byte(channel0_dimm, SPD_MODULE_VOLTAGE) != SPD_VOLTAGE_SSTL2)
710 continue; // Unsupported voltage
712 // E7501 does not support unregistered DIMMs
713 spd_value = spd_read_byte(channel0_dimm, SPD_MODULE_ATTRIBUTES);
714 if (!(spd_value & MODULE_REGISTERED) || (spd_value < 0))
717 // Must support burst = 4 for dual-channel operation on E7501
718 // NOTE: for single-channel, burst = 8 is required
719 spd_value = spd_read_byte(channel0_dimm, SPD_SUPPORTED_BURST_LENGTHS);
720 if (!(spd_value & SPD_BURST_LENGTH_4) || (spd_value < 0))
723 page_size = sdram_spd_get_page_size(channel0_dimm);
724 sdram_width = sdram_spd_get_width(channel0_dimm);
726 // Validate DIMM page size
727 // The E7501 only supports page sizes of 4, 8, 16, or 32 KB per channel
728 // NOTE: 4 KB = 32 Kb = 2^15
729 // 32 KB = 262 Kb = 2^18
731 if ((page_size.side1 < 15) || (page_size.side1 > 18))
734 // If DIMM is double-sided, verify side2 page size
735 if (page_size.side2 != 0) {
736 if ((page_size.side2 < 15) || (page_size.side2 > 18))
740 // Validate SDRAM width
741 // The E7501 only supports x4 and x8 devices
743 if ((sdram_width.side1 != 4) && (sdram_width.side1 != 8))
746 // If DIMM is double-sided, verify side2 width
747 if (sdram_width.side2 != 0) {
748 if ((sdram_width.side2 != 4) && (sdram_width.side2 != 8))
752 // Channel 0 DIMM looks compatible.
753 // Now see if it is paired with the proper DIMM on channel 1.
755 ASSERT(channel1_dimm != 0); // No such socket on this mainboard??
757 // NOTE: unpopulated DIMMs cause read to fail
758 spd_value = spd_read_byte(channel1_dimm, SPD_MODULE_ATTRIBUTES);
759 if (!(spd_value & MODULE_REGISTERED) || (spd_value < 0)) {
761 print_debug("Skipping un-matched DIMMs - only dual-channel operation supported\r\n");
765 #ifdef VALIDATE_DIMM_COMPATIBILITY
766 spd_value = spd_read_byte(channel1_dimm, SPD_SUPPORTED_BURST_LENGTHS);
767 if (!(spd_value & SPD_BURST_LENGTH_4) || (spd_value < 0))
770 for (j=0; j<sizeof(dual_channel_parameters); ++j) {
771 if (!are_spd_values_equal(dual_channel_parameters[j], channel0_dimm, channel1_dimm)) {
779 // Code around ROMCC bug in optimization of "if" statements
780 #ifdef ROMCC_IF_BUG_FIXED
782 // Made it through all the checks, this DIMM pair is usable
783 dimm_mask |= ((1<<i) | (1<<(MAX_DIMM_SOCKETS_PER_CHANNEL + i)));
786 print_debug("Skipping un-matched DIMMs - only dual-channel operation supported\r\n");
788 switch (bDualChannel) {
790 print_debug("Skipping un-matched DIMMs - only dual-channel operation supported\r\n");
794 // Made it through all the checks, this DIMM pair is usable
795 dimm_mask |= (1<<i) | (1<<(MAX_DIMM_SOCKETS_PER_CHANNEL + i));
804 /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
805 /* SPD (SERIAL PRESENCE DETECT) FUNCTIONS */
806 /**********************************************************************************/
808 //----------------------------------------------------------------------------------
809 // Function: do_ram_command
810 // Parameters: ctrl - PCI addresses of memory controller functions, and
811 // SMBus addresses of DIMM slots on the mainboard
812 // command - specifies the command to be sent to the DIMMs:
813 // RAM_COMMAND_NOP - No Operation
814 // RAM_COMMAND_PRECHARGE - Precharge all banks
815 // RAM_COMMAND_MRS - Load Mode Register
816 // RAM_COMMAND_EMRS - Load Extended Mode Register
817 // RAM_COMMAND_CBR - Auto Refresh ("CAS-before-RAS")
818 // RAM_COMMAND_NORMAL - Normal operation
819 // jedec_mode_bits - for mode register set & extended mode register set
820 // commands, bits 0-12 contain the register value in JEDEC format.
821 // Return Value: None
822 // Description: Send the specified command to all DIMMs.
824 static void do_ram_command(const struct mem_controller *ctrl, uint8_t command,
825 uint16_t jedec_mode_bits)
828 uint32_t dram_controller_mode;
829 uint8_t dimm_start_64M_multiple = 0;
830 uint16_t e7501_mode_bits = jedec_mode_bits;
832 // Configure the RAM command
833 dram_controller_mode = pci_read_config32(ctrl->d0, DRC);
834 dram_controller_mode &= 0xFFFFFF8F;
835 dram_controller_mode |= command;
836 pci_write_config32(ctrl->d0, DRC, dram_controller_mode);
838 // RAM_COMMAND_NORMAL is an exception.
839 // It affects only the memory controller and does not need to be "sent" to the DIMMs.
841 if (command != RAM_COMMAND_NORMAL) {
843 // Send the command to all DIMMs by accessing a memory location within each
844 // NOTE: for mode select commands, some of the location address bits
845 // are part of the command
847 // Map JEDEC mode bits to E7501
848 if (command == RAM_COMMAND_MRS) {
849 // Host address lines [15:5] map to DIMM address lines [12:11, 9:1]
850 // The E7501 hard-sets DIMM address lines 10 & 0 to zero
852 ASSERT(!(jedec_mode_bits & 0x0401));
854 e7501_mode_bits = ((jedec_mode_bits & 0x1800) << (15-12)) | // JEDEC bits 11-12 move to bits 14-15
855 ((jedec_mode_bits & 0x03FE) << (13-9)); // JEDEC bits 1-9 move to bits 5-13
857 } else if (command == RAM_COMMAND_EMRS) {
858 // Host address lines [15:3] map to DIMM address lines [12:0]
859 e7501_mode_bits = jedec_mode_bits <<= 3;
861 ASSERT(jedec_mode_bits == 0);
864 dimm_start_64M_multiple = 0;
866 for (i = 0; i < (MAX_NUM_CHANNELS * MAX_DIMM_SOCKETS_PER_CHANNEL); ++i) {
868 uint8_t dimm_end_64M_multiple = pci_read_config8(ctrl->d0, DRB_ROW_0 + i);
869 if (dimm_end_64M_multiple > dimm_start_64M_multiple) {
871 // This code assumes DRAM row boundaries are all set below 4 GB
872 // NOTE: 0x40 * 64 MB == 4 GB
873 ASSERT(dimm_start_64M_multiple < 0x40);
875 // NOTE: 2^26 == 64 MB
877 uint32_t dimm_start_address = dimm_start_64M_multiple << 26;
879 RAM_DEBUG_MESSAGE(" Sending RAM command to 0x");
880 RAM_DEBUG_HEX32(dimm_start_address + e7501_mode_bits);
881 RAM_DEBUG_MESSAGE("\r\n");
882 read32(dimm_start_address + e7501_mode_bits);
884 // Set the start of the next DIMM
885 dimm_start_64M_multiple = dimm_end_64M_multiple;
891 //----------------------------------------------------------------------------------
892 // Function: set_ram_mode
893 // Parameters: ctrl - PCI addresses of memory controller functions, and
894 // SMBus addresses of DIMM slots on the mainboard
895 // jedec_mode_bits - for mode register set & extended mode register set
896 // commands, bits 0-12 contain the register value in JEDEC format.
897 // Return Value: None
898 // Description: Set the mode register of all DIMMs. The proper CAS# latency
899 // setting is added to the mode bits specified by the caller.
901 static void set_ram_mode(const struct mem_controller *ctrl, uint16_t jedec_mode_bits)
903 ASSERT(!(jedec_mode_bits & SDRAM_CAS_MASK));
905 uint32_t dram_cas_latency = pci_read_config32(ctrl->d0, DRT) & DRT_CAS_MASK;
907 switch (dram_cas_latency) {
909 jedec_mode_bits |= SDRAM_CAS_2_5;
913 jedec_mode_bits |= SDRAM_CAS_2_0;
921 do_ram_command(ctrl, RAM_COMMAND_MRS, jedec_mode_bits);
924 /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
925 /* SDRAM CONFIGURATION FUNCTIONS */
926 /**********************************************************************************/
928 //----------------------------------------------------------------------------------
929 // Function: configure_dimm_row_boundaries
930 // Parameters: ctrl - PCI addresses of memory controller functions, and
931 // SMBus addresses of DIMM slots on the mainboard
932 // dimm_log2_num_bits - log2(number of bits) for each side of the DIMM
933 // total_dram_64M_multiple - total DRAM in the system (as a
934 // multiple of 64 MB) for DIMMs < dimm_index
935 // dimm_index - which DIMM pair is being processed
936 // (0..MAX_DIMM_SOCKETS_PER_CHANNEL)
937 // Return Value: New multiple of 64 MB total DRAM in the system
938 // Description: Configure the E7501's DRAM Row Boundary registers for the memory
939 // present in the specified DIMM.
941 static uint8_t configure_dimm_row_boundaries(const struct mem_controller *ctrl,
942 struct dimm_size dimm_log2_num_bits,
943 uint8_t total_dram_64M_multiple,
948 ASSERT(dimm_index < MAX_DIMM_SOCKETS_PER_CHANNEL);
950 // DIMM sides must be at least 32 MB
951 ASSERT(dimm_log2_num_bits.side1 >= 28);
952 ASSERT((dimm_log2_num_bits.side2 == 0) || (dimm_log2_num_bits.side2 >= 28));
954 // In dual-channel mode, we are called only once for each pair of DIMMs.
955 // Each time we process twice the capacity of a single DIMM.
957 // Convert single DIMM capacity to paired DIMM capacity
958 // (multiply by two ==> add 1 to log2)
959 dimm_log2_num_bits.side1++;
960 if (dimm_log2_num_bits.side2 > 0)
961 dimm_log2_num_bits.side2++;
963 // Add the capacity of side 1 this DIMM pair (as a multiple of 64 MB)
964 // to the total capacity of the system
965 // NOTE: 64 MB == 512 Mb, and log2(512 Mb) == 29
967 total_dram_64M_multiple += (1 << (dimm_log2_num_bits.side1 - 29));
969 // Configure the boundary address for the row on side 1
970 pci_write_config8(ctrl->d0, DRB_ROW_0+(dimm_index<<1), total_dram_64M_multiple);
972 // If the DIMMs are double-sided, add the capacity of side 2 this DIMM pair
973 // (as a multiple of 64 MB) to the total capacity of the system
974 if (dimm_log2_num_bits.side2 >= 29)
975 total_dram_64M_multiple += (1 << (dimm_log2_num_bits.side2 - 29));
977 // Configure the boundary address for the row (if any) on side 2
978 pci_write_config8(ctrl->d0, DRB_ROW_1+(dimm_index<<1), total_dram_64M_multiple);
980 // Update boundaries for rows subsequent to these.
981 // These settings will be overridden by a subsequent call if a populated physical slot exists
983 for(i=dimm_index+1; i<MAX_DIMM_SOCKETS_PER_CHANNEL; i++) {
984 pci_write_config8(ctrl->d0, DRB_ROW_0+(i<<1), total_dram_64M_multiple);
985 pci_write_config8(ctrl->d0, DRB_ROW_1+(i<<1), total_dram_64M_multiple);
988 return total_dram_64M_multiple;
991 //----------------------------------------------------------------------------------
992 // Function: configure_e7501_ram_addresses
993 // Parameters: ctrl - PCI addresses of memory controller functions, and
994 // SMBus addresses of DIMM slots on the mainboard
995 // dimm_mask - bitmask of populated DIMMs on the board - see
996 // spd_get_supported_dimms()
997 // Return Value: None
998 // Description: Program the E7501's DRAM row boundary addresses and its Top Of
999 // Low Memory (TOLM). If necessary, set up a remap window so we
1000 // don't waste DRAM that ordinarily would lie behind addresses
1001 // reserved for memory-mapped I/O.
1003 static void configure_e7501_ram_addresses(const struct mem_controller *ctrl,
1007 uint8_t total_dram_64M_multiple = 0;
1009 // Configure the E7501's DRAM row boundaries
1010 // Start by zeroing out the temporary initial configuration
1011 pci_write_config32(ctrl->d0, DRB_ROW_0, 0);
1012 pci_write_config32(ctrl->d0, DRB_ROW_4, 0);
1014 for(i = 0; i < MAX_DIMM_SOCKETS_PER_CHANNEL; i++) {
1016 uint16_t dimm_socket_address = ctrl->channel0[i];
1017 struct dimm_size sz;
1019 if (!(dimm_mask & (1 << i)))
1020 continue; // This DIMM not present
1022 sz = spd_get_dimm_size(dimm_socket_address);
1024 RAM_DEBUG_MESSAGE("dimm size =");
1025 RAM_DEBUG_HEX32(sz.side1);
1026 RAM_DEBUG_MESSAGE(" ");
1027 RAM_DEBUG_HEX32(sz.side2);
1028 RAM_DEBUG_MESSAGE("\r\n");
1031 die("Bad SPD value\r\n");
1033 total_dram_64M_multiple = configure_dimm_row_boundaries(ctrl, sz, total_dram_64M_multiple, i);
1036 // Configure the Top Of Low Memory (TOLM) in the E7501
1037 // This address must be a multiple of 128 MB that is less than 4 GB.
1038 // NOTE: 16-bit wide TOLM register stores only the highest 5 bits of a 32-bit address
1039 // in the highest 5 bits.
1041 // We set TOLM to the smaller of 0xC0000000 (3 GB) or the total DRAM in the system.
1042 // This reserves addresses from 0xC0000000 - 0xFFFFFFFF for non-DRAM purposes
1043 // such as flash and memory-mapped I/O.
1045 // If there is more than 3 GB of DRAM, we define a remap window which
1046 // makes the DRAM "behind" the reserved region available above the top of physical
1049 // NOTE: 0xC0000000 / (64 MB) == 0x30
1051 if (total_dram_64M_multiple <= 0x30) {
1053 // <= 3 GB total RAM
1055 /* I should really adjust all of this in C after I have resources
1056 * to all of the pci devices.
1059 // Round up to 128MB granularity
1060 // SJM: Is "missing" 64 MB of memory a potential issue? Should this round down?
1062 uint8_t total_dram_128M_multiple = (total_dram_64M_multiple + 1) >> 1;
1064 // Convert to high 16 bits of address
1065 uint16_t top_of_low_memory = total_dram_128M_multiple << 11;
1067 pci_write_config16(ctrl->d0, TOLM, top_of_low_memory);
1073 // Set defaults for > 4 GB DRAM, i.e. remap a 1 GB (= 0x10 * 64 MB) range of memory
1074 uint16_t remap_base = total_dram_64M_multiple; // A[25:0] == 0
1075 uint16_t remap_limit = total_dram_64M_multiple + 0x10 - 1; // A[25:0] == 0xF
1079 pci_write_config16(ctrl->d0, TOLM, 0xc000);
1081 // Define a remap window to make the RAM that would appear from 3 GB - 4 GB
1082 // visible just beyond 4 GB or the end of physical memory, whichever is larger
1083 // NOTE: 16-bit wide REMAP registers store only the highest 10 bits of a 36-bit address,
1084 // (i.e. a multiple of 64 MB) in the lowest 10 bits.
1085 // NOTE: 0x100000000 / (64 MB) == 0x40
1087 if (total_dram_64M_multiple < 0x40) {
1088 remap_base = 0x40; // 0x100000000
1089 remap_limit = 0x40 + (total_dram_64M_multiple - 0x30) - 1;
1092 pci_write_config16(ctrl->d0, REMAPBASE, remap_base);
1093 pci_write_config16(ctrl->d0, REMAPLIMIT, remap_limit);
1097 //----------------------------------------------------------------------------------
1098 // Function: initialize_ecc
1099 // Parameters: ctrl - PCI addresses of memory controller functions, and
1100 // SMBus addresses of DIMM slots on the mainboard
1101 // Return Value: None
1102 // Description: If we're configured to use ECC, initialize the SDRAM and
1103 // clear the E7501's ECC error flags.
1105 static void initialize_ecc(const struct mem_controller *ctrl)
1107 uint32_t dram_controller_mode;
1109 /* Test to see if ECC support is enabled */
1110 dram_controller_mode = pci_read_config32(ctrl->d0, DRC);
1111 dram_controller_mode >>= 20;
1112 dram_controller_mode &= 3;
1113 if (dram_controller_mode == 2) {
1117 RAM_DEBUG_MESSAGE("Initializing ECC state...\r\n");
1118 /* Initialize ECC bits , use ECC zero mode (new to 7501)*/
1119 pci_write_config8(ctrl->d0, MCHCFGNS, 0x06);
1120 pci_write_config8(ctrl->d0, MCHCFGNS, 0x07);
1122 // Wait for scrub cycle to complete
1124 byte = pci_read_config8(ctrl->d0, MCHCFGNS);
1126 } while ( (byte & 0x08 ) == 0);
1128 pci_write_config8(ctrl->d0, MCHCFGNS, byte & 0xfc);
1129 RAM_DEBUG_MESSAGE("ECC state initialized.\r\n");
1131 /* Clear the ECC error bits */
1132 pci_write_config8(ctrl->d0f1, DRAM_FERR, 0x03);
1133 pci_write_config8(ctrl->d0f1, DRAM_NERR, 0x03);
1135 // Clear DRAM Interface error bits (write-one-clear)
1136 pci_write_config32(ctrl->d0f1, FERR_GLOBAL, 1<<18);
1137 pci_write_config32(ctrl->d0f1, NERR_GLOBAL, 1<<18);
1139 // Start normal ECC scrub
1140 pci_write_config8(ctrl->d0, MCHCFGNS, 5);
1145 //----------------------------------------------------------------------------------
1146 // Function: configure_e7501_dram_timing
1147 // Parameters: ctrl - PCI addresses of memory controller functions, and
1148 // SMBus addresses of DIMM slots on the mainboard
1149 // dimm_mask - bitmask of populated DIMMs on the board - see
1150 // spd_get_supported_dimms()
1151 // Return Value: None
1152 // Description: Program the DRAM Timing register of the E7501 (except for CAS#
1153 // latency, which is assumed to have been programmed already), based
1154 // on the parameters of the various installed DIMMs.
1156 static void configure_e7501_dram_timing(const struct mem_controller *ctrl, uint8_t dimm_mask)
1159 uint32_t dram_timing;
1161 uint8_t slowest_row_precharge = 0;
1162 uint8_t slowest_ras_cas_delay = 0;
1163 uint8_t slowest_active_to_precharge_delay = 0;
1164 uint32_t current_cas_latency = pci_read_config32(ctrl->d0, DRT) & DRT_CAS_MASK;
1166 // CAS# latency must be programmed beforehand
1167 ASSERT((current_cas_latency == DRT_CAS_2_0) || (current_cas_latency == DRT_CAS_2_5));
1169 // Each timing parameter is determined by the slowest DIMM
1171 for (i = 0; i < MAX_DIMM_SOCKETS; i++) {
1173 uint16_t dimm_socket_address;
1175 if (!(dimm_mask & (1 << i)))
1176 continue; // This DIMM not present
1178 if (i < MAX_DIMM_SOCKETS_PER_CHANNEL)
1179 dimm_socket_address = ctrl->channel0[i];
1181 dimm_socket_address = ctrl->channel1[i - MAX_DIMM_SOCKETS_PER_CHANNEL];
1183 value = spd_read_byte(dimm_socket_address, SPD_MIN_ROW_PRECHARGE_TIME);
1184 if (value < 0) goto hw_err;
1185 if (value > slowest_row_precharge)
1186 slowest_row_precharge = value;
1188 value = spd_read_byte(dimm_socket_address, SPD_MIN_RAS_TO_CAS_DELAY);
1189 if(value < 0 ) goto hw_err;
1190 if (value > slowest_ras_cas_delay)
1191 slowest_ras_cas_delay = value;
1193 value = spd_read_byte(dimm_socket_address, SPD_MIN_ACTIVE_TO_PRECHARGE_DELAY);
1194 if(value < 0 ) goto hw_err;
1195 if (value > slowest_active_to_precharge_delay)
1196 slowest_active_to_precharge_delay = value;
1199 // NOTE for timing parameters:
1200 // At 133 MHz, 1 clock == 7.52 ns
1202 /* Read the initial state */
1203 dram_timing = pci_read_config32(ctrl->d0, DRT);
1207 // E7501 supports only 2 or 3 clocks for tRP
1208 if (slowest_row_precharge > ((22<<2) | (2<<0)))
1209 die("unsupported DIMM tRP"); // > 22.5 ns: 4 or more clocks
1210 else if (slowest_row_precharge > (15<<2))
1211 dram_timing &= ~(1<<0); // > 15.0 ns: 3 clocks
1213 dram_timing |= (1<<0); // <= 15.0 ns: 2 clocks
1217 // E7501 supports only 2 or 3 clocks for tRCD
1218 // Use the same value for both read & write
1219 dram_timing &= ~((1<<3)|(3<<1));
1220 if (slowest_ras_cas_delay > ((22<<2) | (2<<0)))
1221 die("unsupported DIMM tRCD"); // > 22.5 ns: 4 or more clocks
1222 else if (slowest_ras_cas_delay > (15<<2))
1223 dram_timing |= (2<<1); // > 15.0 ns: 3 clocks
1225 dram_timing |= ((1<<3) | (3<<1)); // <= 15.0 ns: 2 clocks
1229 // E7501 supports only 5, 6, or 7 clocks for tRAS
1230 // 5 clocks ~= 37.6 ns, 6 clocks ~= 45.1 ns, 7 clocks ~= 52.6 ns
1231 dram_timing &= ~(3<<9);
1233 if (slowest_active_to_precharge_delay > 52)
1234 die("unsupported DIMM tRAS"); // > 52 ns: 8 or more clocks
1235 else if (slowest_active_to_precharge_delay > 45)
1236 dram_timing |= (0<<9); // 46-52 ns: 7 clocks
1237 else if (slowest_active_to_precharge_delay > 37)
1238 dram_timing |= (1<<9); // 38-45 ns: 6 clocks
1240 dram_timing |= (2<<9); // < 38 ns: 5 clocks
1245 /* Set to a 7 clock read delay. This is for 133Mhz
1246 * with a CAS latency of 2.5 if 2.0 a 6 clock
1249 dram_timing &= ~(7<<24); // 7 clocks
1250 if (current_cas_latency == DRT_CAS_2_0)
1251 dram_timing |= (1<<24); // 6 clocks
1254 * Back to Back Read-Write Turn Around
1256 /* Set to a 5 clock back to back read to write turn around.
1257 * 4 is a good delay if the CAS latency is 2.0 */
1259 dram_timing &= ~(1<<28); // 5 clocks
1260 if (current_cas_latency == DRT_CAS_2_0)
1261 dram_timing |= (1<<28); // 4 clocks
1263 pci_write_config32(ctrl->d0, DRT, dram_timing);
1271 //----------------------------------------------------------------------------------
1272 // Function: configure_e7501_cas_latency
1273 // Parameters: ctrl - PCI addresses of memory controller functions, and
1274 // SMBus addresses of DIMM slots on the mainboard
1275 // dimm_mask - bitmask of populated DIMMs on the board - see
1276 // spd_get_supported_dimms()
1277 // Return Value: None
1278 // Description: Determine the shortest CAS# latency that the E7501 and all DIMMs
1279 // have in common, and program the E7501 to use it.
1281 static void configure_e7501_cas_latency(const struct mem_controller *ctrl, uint8_t dimm_mask)
1285 uint32_t dram_timing;
1286 uint16_t maybe_dram_read_timing;
1289 // CAS# latency bitmasks in SPD_ACCEPTABLE_CAS_LATENCIES format
1290 // NOTE: E7501 supports only 2.0 and 2.5
1291 uint32_t system_compatible_cas_latencies = SPD_CAS_LATENCY_2_0 | SPD_CAS_LATENCY_2_5;
1292 uint32_t current_cas_latency;
1293 uint32_t dimm_compatible_cas_latencies;
1295 for (i = 0; i < MAX_DIMM_SOCKETS; i++) {
1297 uint16_t dimm_socket_address;
1299 if (!(dimm_mask & (1 << i)))
1300 continue; // This DIMM not usable
1302 if (i < MAX_DIMM_SOCKETS_PER_CHANNEL)
1303 dimm_socket_address = ctrl->channel0[i];
1305 dimm_socket_address = ctrl->channel1[i - MAX_DIMM_SOCKETS_PER_CHANNEL];
1307 value = spd_read_byte(dimm_socket_address, SPD_ACCEPTABLE_CAS_LATENCIES);
1308 if (value < 0) goto hw_err;
1310 dimm_compatible_cas_latencies = value & 0x7f; // Start with all supported by DIMM
1311 current_cas_latency = 1 << log2(dimm_compatible_cas_latencies); // Max supported by DIMM
1313 // Can we support the highest CAS# latency?
1315 value = spd_read_byte(dimm_socket_address, SPD_MIN_CYCLE_TIME_AT_CAS_MAX);
1316 if (value < 0) goto hw_err;
1318 // NOTE: At 133 MHz, 1 clock == 7.52 ns
1320 // Our bus is too fast for this CAS# latency
1321 // Remove it from the bitmask of those supported by the DIMM that are compatible
1322 dimm_compatible_cas_latencies &= ~current_cas_latency;
1325 // Can we support the next-highest CAS# latency (max - 0.5)?
1327 current_cas_latency >>= 1;
1328 if (current_cas_latency != 0) {
1329 value = spd_read_byte(dimm_socket_address, SPD_SDRAM_CYCLE_TIME_2ND);
1330 if(value < 0 ) goto hw_err;
1332 dimm_compatible_cas_latencies &= ~current_cas_latency;
1335 // Can we support the next-highest CAS# latency (max - 1.0)?
1336 current_cas_latency >>= 1;
1337 if (current_cas_latency != 0) {
1338 value = spd_read_byte(dimm_socket_address, SPD_SDRAM_CYCLE_TIME_3RD);
1339 if(value < 0 ) goto hw_err;
1341 dimm_compatible_cas_latencies &= ~current_cas_latency;
1344 // Restrict the system to CAS# latencies compatible with this DIMM
1345 system_compatible_cas_latencies &= dimm_compatible_cas_latencies;
1347 /* go to the next DIMM */
1350 /* After all of the arduous calculation setup with the fastest
1351 * cas latency I can use.
1354 dram_timing = pci_read_config32(ctrl->d0, DRT);
1355 dram_timing &= ~(DRT_CAS_MASK);
1357 maybe_dram_read_timing = pci_read_config16(ctrl->d0, MAYBE_DRDCTL);
1358 maybe_dram_read_timing &= 0xF00C;
1360 if (system_compatible_cas_latencies & SPD_CAS_LATENCY_2_0) {
1361 dram_timing |= DRT_CAS_2_0;
1362 maybe_dram_read_timing |= 0xBB1;
1364 else if (system_compatible_cas_latencies & SPD_CAS_LATENCY_2_5) {
1366 uint32_t dram_row_attributes = pci_read_config32(ctrl->d0, DRA);
1368 dram_timing |= DRT_CAS_2_5;
1370 // At CAS# 2.5, DRAM Read Timing (if that's what it its) appears to need a slightly
1371 // different value if all DIMM slots are populated
1373 if ((dram_row_attributes & 0xff) && (dram_row_attributes & 0xff00) &&
1374 (dram_row_attributes & 0xff0000) && (dram_row_attributes & 0xff000000)) {
1376 // All slots populated
1377 maybe_dram_read_timing |= 0x0882;
1380 // Some unpopulated slots
1381 maybe_dram_read_timing |= 0x0662;
1385 die("No CAS# latencies compatible with all DIMMs!!\r\n");
1387 pci_write_config32(ctrl->d0, DRT, dram_timing);
1389 /* set master DLL reset */
1390 dword = pci_read_config32(ctrl->d0, 0x88);
1392 pci_write_config32(ctrl->d0, 0x88, dword);
1394 dword &= 0x0c0007ff; /* patch try register 88 is undocumented tnz */
1395 dword |= 0xd2109800;
1397 pci_write_config32(ctrl->d0, 0x88, dword);
1400 pci_write_config16(ctrl->d0, MAYBE_DRDCTL, maybe_dram_read_timing);
1402 dword = pci_read_config32(ctrl->d0, 0x88); /* reset master DLL reset */
1404 pci_write_config32(ctrl->d0, 0x88, dword);
1412 //----------------------------------------------------------------------------------
1413 // Function: configure_e7501_dram_controller_mode
1414 // Parameters: ctrl - PCI addresses of memory controller functions, and
1415 // SMBus addresses of DIMM slots on the mainboard
1416 // dimm_mask - bitmask of populated DIMMs on the board - see
1417 // spd_get_supported_dimms()
1418 // Return Value: None
1419 // Description: Configure the refresh interval so that we refresh no more often
1420 // than required by the "most needy" DIMM. Also disable ECC if any
1421 // of the DIMMs don't support it.
1423 static void configure_e7501_dram_controller_mode(const struct mem_controller *ctrl,
1429 uint32_t controller_mode = pci_read_config32(ctrl->d0, DRC);
1430 uint32_t system_refresh_mode = (controller_mode >> 8) & 7;
1432 // Code below assumes that most aggressive settings are in
1433 // force when we are called, either via E7501 reset defaults
1434 // or by sdram_set_registers():
1438 ASSERT((controller_mode & (3<<20)) == (2<<20)); // ECC
1439 ASSERT(!(controller_mode & (7 << 8))); // Refresh
1441 /* Walk through _all_ dimms and find the least-common denominator for:
1446 for (i = 0; i < MAX_DIMM_SOCKETS; i++) {
1448 uint32_t dimm_refresh_mode;
1450 uint16_t dimm_socket_address;
1452 if (!(dimm_mask & (1 << i))) {
1453 continue; // This DIMM not usable
1456 if (i < MAX_DIMM_SOCKETS_PER_CHANNEL)
1457 dimm_socket_address = ctrl->channel0[i];
1459 dimm_socket_address = ctrl->channel1[i - MAX_DIMM_SOCKETS_PER_CHANNEL];
1461 // Disable ECC mode if any one of the DIMMs does not support ECC
1462 // SJM: Should we just die here? E7501 datasheet says non-ECC DIMMs aren't supported.
1464 value = spd_read_byte(dimm_socket_address, SPD_DIMM_CONFIG_TYPE);
1465 die_on_spd_error(value);
1466 if (value != ERROR_SCHEME_ECC) {
1467 controller_mode &= ~(3 << 20);
1470 value = spd_read_byte(dimm_socket_address, SPD_REFRESH);
1471 die_on_spd_error(value);
1472 value &= 0x7f; // Mask off self-refresh bit
1473 if(value > MAX_SPD_REFRESH_RATE) {
1474 print_err("unsupported refresh rate\r\n");
1478 // Get the appropriate E7501 refresh mode for this DIMM
1479 dimm_refresh_mode = refresh_rate_map[value];
1480 if (dimm_refresh_mode > 7) {
1481 print_err("unsupported refresh rate\r\n");
1485 // If this DIMM requires more frequent refresh than others,
1486 // update the system setting
1487 if (refresh_frequency[dimm_refresh_mode] > refresh_frequency[system_refresh_mode])
1488 system_refresh_mode = dimm_refresh_mode;
1490 #ifdef SUSPICIOUS_LOOKING_CODE
1491 // SJM NOTE: This code doesn't look right. SPD values are an order of magnitude smaller
1492 // than the clock period of the memory controller. Also, no other northbridge
1493 // looks at SPD_CMD_SIGNAL_INPUT_HOLD_TIME.
1495 // Switch to 2 clocks for address/command if required by any one of the DIMMs
1496 // NOTE: At 133 MHz, 1 clock == 7.52 ns
1497 value = spd_read_byte(dimm_socket_address, SPD_CMD_SIGNAL_INPUT_HOLD_TIME);
1498 die_on_spd_error(value);
1499 if(value >= 0xa0) { /* At 133MHz this constant should be 0x75 */
1500 controller_mode &= ~(1<<16); /* Use two clock cyles instead of one */
1504 /* go to the next DIMM */
1507 controller_mode |= (system_refresh_mode << 8);
1509 // Configure the E7501
1510 pci_write_config32(ctrl->d0, DRC, controller_mode);
1513 //----------------------------------------------------------------------------------
1514 // Function: configure_e7501_row_attributes
1515 // Parameters: ctrl - PCI addresses of memory controller functions, and
1516 // SMBus addresses of DIMM slots on the mainboard
1517 // dimm_mask - bitmask of populated DIMMs on the board - see
1518 // spd_get_supported_dimms()
1519 // Return Value: None
1520 // Description: Configure the E7501's DRAM Row Attributes (DRA) registers
1521 // based on DIMM parameters read via SPD. This tells the controller
1522 // the width of the SDRAM chips on each DIMM side (x4 or x8) and
1523 // the page size of each DIMM side (4, 8, 16, or 32 KB).
1525 static void configure_e7501_row_attributes(const struct mem_controller *ctrl,
1529 uint32_t row_attributes = 0;
1531 for (i = 0; i < MAX_DIMM_SOCKETS_PER_CHANNEL; i++) {
1533 uint16_t dimm_socket_address = ctrl->channel0[i];
1534 struct dimm_size page_size;
1535 struct dimm_size sdram_width;
1537 if (!(dimm_mask & (1 << i)))
1538 continue; // This DIMM not usable
1540 // Get the relevant parameters via SPD
1541 page_size = sdram_spd_get_page_size(dimm_socket_address);
1542 sdram_width = sdram_spd_get_width(dimm_socket_address);
1544 // Update the DRAM Row Attributes.
1545 // Page size is encoded as log2(page size in bits) - log2(8 Kb)
1546 // NOTE: 8 Kb = 2^13
1547 row_attributes |= (page_size.side1 - 13) << (i<<3); // Side 1 of each DIMM is an EVEN row
1549 if (sdram_width.side2 > 0)
1550 row_attributes |= (page_size.side2 - 13) << ((i<<3) + 4); // Side 2 is ODD
1552 // Set x4 flags if appropriate
1553 if (sdram_width.side1 == 4) {
1554 row_attributes |= 0x08 << (i<<3);
1557 if (sdram_width.side2 == 4) {
1558 row_attributes |= 0x08 << ((i<<3) + 4);
1561 /* go to the next DIMM */
1564 /* Write the new row attributes register */
1565 pci_write_config32(ctrl->d0, DRA, row_attributes);
1568 //----------------------------------------------------------------------------------
1569 // Function: enable_e7501_clocks
1570 // Parameters: ctrl - PCI addresses of memory controller functions, and
1571 // SMBus addresses of DIMM slots on the mainboard
1572 // dimm_mask - bitmask of populated DIMMs on the board - see
1573 // spd_get_supported_dimms()
1574 // Return Value: None
1575 // Description: Enable clock signals for populated DIMM sockets and disable them
1576 // for unpopulated sockets (to reduce EMI).
1578 static void enable_e7501_clocks(const struct mem_controller *ctrl, uint8_t dimm_mask)
1581 uint8_t clock_disable = pci_read_config8(ctrl->d0, CKDIS);
1583 for (i = 0; i < MAX_DIMM_SOCKETS_PER_CHANNEL; i++) {
1585 uint8_t socket_mask = 1 << i;
1587 if (dimm_mask & socket_mask)
1588 clock_disable &= ~socket_mask; // DIMM present, enable clock
1590 clock_disable |= socket_mask; // DIMM absent, disable clock
1593 pci_write_config8(ctrl->d0, CKDIS, clock_disable);
1597 /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
1598 /* DIMM-DEDEPENDENT CONFIGURATION FUNCTIONS */
1599 /**********************************************************************************/
1601 //----------------------------------------------------------------------------------
1602 // Function: RAM_RESET_DDR_PTR
1603 // Parameters: ctrl - PCI addresses of memory controller functions, and
1604 // SMBus addresses of DIMM slots on the mainboard
1605 // Return Value: None
1606 // Description: DDR Receive FIFO RE-Sync (?)
1608 static void RAM_RESET_DDR_PTR(const struct mem_controller *ctrl)
1611 byte = pci_read_config8(ctrl->d0, 0x88);
1613 pci_write_config8(ctrl->d0, 0x88, byte);
1615 byte = pci_read_config8(ctrl->d0, 0x88);
1617 pci_write_config8(ctrl->d0, 0x88, byte);
1620 //----------------------------------------------------------------------------------
1621 // Function: ram_set_d0f0_regs
1622 // Parameters: ctrl - PCI addresses of memory controller functions, and
1623 // SMBus addresses of DIMM slots on the mainboard
1624 // Return Value: None
1625 // Description: Set E7501 registers that are either independent of DIMM specifics,
1626 // or establish default settings that will be overridden when we
1627 // learn the specifics.
1628 // This sets PCI configuration registers to known good values based
1629 // on the table 'constant_register_values', which are a triple of
1630 // configuration register offset, mask, and bits to set.
1632 static void ram_set_d0f0_regs(const struct mem_controller *ctrl)
1635 int num_values = ARRAY_SIZE(constant_register_values);
1637 ASSERT((num_values % 3) == 0); // Bad table?
1639 for(i = 0; i < num_values; i += 3) {
1641 uint32_t register_offset = constant_register_values[i];
1642 uint32_t bits_to_mask = constant_register_values[i+1];
1643 uint32_t bits_to_set = constant_register_values[i+2];
1644 uint32_t register_value;
1646 // It's theoretically possible to set values for something other than D0:F0,
1647 // but it's not typically done here
1648 ASSERT(!(register_offset & 0xFFFFFF00));
1650 // bits_to_mask and bits_to_set should not reference the same bits
1651 // Again, not strictly an error, but flagged as a potential bug
1652 ASSERT((bits_to_mask & bits_to_set) == 0);
1654 register_value = pci_read_config32(ctrl->d0, register_offset);
1655 register_value &= bits_to_mask;
1656 register_value |= bits_to_set;
1658 pci_write_config32(ctrl->d0, register_offset, register_value);
1662 //----------------------------------------------------------------------------------
1663 // Function: write_8dwords
1664 // Parameters: src_addr
1666 // Return Value: None
1667 // Description: Copy 64 bytes from one location to another.
1669 static void write_8dwords(uint32_t* src_addr, uint32_t dst_addr)
1672 for (i=0; i<8; i++) {
1673 write32(dst_addr, *src_addr);
1675 dst_addr += sizeof(uint32_t);
1679 //----------------------------------------------------------------------------------
1680 // Function: ram_set_rcomp_regs
1681 // Parameters: ctrl - PCI addresses of memory controller functions, and
1682 // SMBus addresses of DIMM slots on the mainboard
1683 // Return Value: None
1684 // Description: Set the E7501's (undocumented) RCOMP registers.
1685 // Per the 855PM datasheet and IXP2800 HW Initialization Reference
1686 // Manual, RCOMP registers appear to affect drive strength,
1687 // pullup/pulldown offset, and slew rate of various signal groups.
1688 // Comments below are conjecture based on apparent similarity
1689 // between the E7501 and these two chips.
1691 static void ram_set_rcomp_regs(const struct mem_controller *ctrl)
1694 uint8_t maybe_strength_control;
1696 RAM_DEBUG_MESSAGE("Setting RCOMP registers.\r\n");
1698 /*enable access to the rcomp bar*/
1699 dword = pci_read_config32(ctrl->d0, MAYBE_MCHTST);
1701 pci_write_config32(ctrl->d0, MAYBE_MCHTST, dword);
1704 // Set the RCOMP MMIO base address
1705 pci_write_config32(ctrl->d0, MAYBE_SMRBASE, RCOMP_MMIO);
1707 // Block RCOMP updates while we configure the registers
1708 dword = read32(RCOMP_MMIO + MAYBE_SMRCTL);
1710 write32(RCOMP_MMIO + MAYBE_SMRCTL, dword);
1713 /* Begin to write the RCOMP registers */
1715 // Set CMD and DQ/DQS strength to 2x (?)
1716 maybe_strength_control = read8(RCOMP_MMIO + MAYBE_DQCMDSTR) & 0x88;
1717 maybe_strength_control |= 0x44;
1718 write8(RCOMP_MMIO + MAYBE_DQCMDSTR, maybe_strength_control);
1720 write_8dwords(maybe_2x_slew_table, RCOMP_MMIO + 0x80);
1721 write16(RCOMP_MMIO + 0x42, 0);
1723 write_8dwords(maybe_1x_slew_table, RCOMP_MMIO + 0x60);
1725 // NOTE: some factory BIOS set 0x9088 here. Seems to work either way.
1726 write16(RCOMP_MMIO + 0x40, 0);
1729 // Set RCVEnOut# strength to 2x (?)
1730 maybe_strength_control = read8(RCOMP_MMIO + MAYBE_RCVENSTR) & 0xF8;
1731 maybe_strength_control |= 4;
1732 write8(RCOMP_MMIO + MAYBE_RCVENSTR, maybe_strength_control);
1734 write_8dwords(maybe_2x_slew_table, RCOMP_MMIO + 0x1c0);
1735 write16(RCOMP_MMIO + 0x50, 0);
1737 // Set CS# strength for x4 SDRAM to 2x (?)
1738 maybe_strength_control = read8(RCOMP_MMIO + MAYBE_CSBSTR) & 0xF8;
1739 maybe_strength_control |= 4;
1740 write8(RCOMP_MMIO + MAYBE_CSBSTR, maybe_strength_control);
1742 write_8dwords(maybe_2x_slew_table, RCOMP_MMIO + 0x140);
1743 write16(RCOMP_MMIO + 0x48, 0);
1745 // Set CKE strength for x4 SDRAM to 2x (?)
1746 maybe_strength_control = read8(RCOMP_MMIO + MAYBE_CKESTR) & 0xF8;
1747 maybe_strength_control |= 4;
1748 write8(RCOMP_MMIO + MAYBE_CKESTR, maybe_strength_control);
1750 write_8dwords(maybe_2x_slew_table, RCOMP_MMIO + 0xa0);
1751 write16(RCOMP_MMIO + 0x44, 0);
1753 // Set CK strength for x4 SDRAM to 1x (?)
1754 maybe_strength_control = read8(RCOMP_MMIO + MAYBE_CKSTR) & 0xF8;
1755 maybe_strength_control |= 1;
1756 write8(RCOMP_MMIO + MAYBE_CKSTR, maybe_strength_control);
1758 write_8dwords(maybe_pull_updown_offset_table, RCOMP_MMIO + 0x180);
1759 write16(RCOMP_MMIO + 0x4c, 0);
1761 write8(RCOMP_MMIO + 0x2c, 0xff);
1764 // Set the digital filter length to 8 (?)
1765 dword = read32(RCOMP_MMIO + MAYBE_SMRCTL);
1767 // NOTE: Some factory BIOS don't do this.
1768 // Doesn't seem to matter either way.
1772 write32(RCOMP_MMIO + MAYBE_SMRCTL, dword);
1777 /* unblock updates */
1778 dword = read32(RCOMP_MMIO + MAYBE_SMRCTL);
1780 write32(RCOMP_MMIO + MAYBE_SMRCTL, dword);
1782 // Force a RCOMP measurement cycle?
1784 write32(RCOMP_MMIO + MAYBE_SMRCTL, dword);
1786 write32(RCOMP_MMIO + MAYBE_SMRCTL, dword);
1791 /*disable access to the rcomp bar */
1792 dword = pci_read_config32(ctrl->d0, MAYBE_MCHTST);
1794 pci_write_config32(ctrl->d0, MAYBE_MCHTST, dword);
1798 /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
1799 /* DIMM-INDEPENDENT CONFIGURATION FUNCTIONS */
1800 /**********************************************************************************/
1802 //----------------------------------------------------------------------------------
1803 // Function: sdram_enable
1804 // Parameters: controllers - not used
1805 // ctrl - PCI addresses of memory controller functions, and
1806 // SMBus addresses of DIMM slots on the mainboard
1807 // Return Value: None
1808 // Description: Go through the JEDEC initialization sequence for all DIMMs,
1809 // then enable refresh and initialize ECC and memory to zero.
1810 // Upon exit, SDRAM is up and running.
1812 static void sdram_enable(int controllers, const struct mem_controller *ctrl)
1814 uint8_t dimm_mask = pci_read_config16(ctrl->d0, SKPD);
1815 uint32_t dram_controller_mode;
1820 /* 1 & 2 Power up and start clocks */
1821 RAM_DEBUG_MESSAGE("Ram Enable 1\r\n");
1822 RAM_DEBUG_MESSAGE("Ram Enable 2\r\n");
1824 /* A 200us delay is needed */
1830 RAM_DEBUG_MESSAGE("Ram Enable 3\r\n");
1831 do_ram_command(ctrl, RAM_COMMAND_NOP, 0);
1834 /* 4 Precharge all */
1835 RAM_DEBUG_MESSAGE("Ram Enable 4\r\n");
1836 do_ram_command(ctrl, RAM_COMMAND_PRECHARGE, 0);
1839 /* wait until the all banks idle state... */
1840 /* 5. Issue EMRS to enable DLL */
1841 RAM_DEBUG_MESSAGE("Ram Enable 5\r\n");
1842 do_ram_command(ctrl, RAM_COMMAND_EMRS, SDRAM_EXTMODE_DLL_ENABLE | SDRAM_EXTMODE_DRIVE_NORMAL);
1846 RAM_DEBUG_MESSAGE("Ram Enable 6\r\n");
1847 set_ram_mode(ctrl, E7501_SDRAM_MODE | SDRAM_MODE_DLL_RESET);
1850 /* Ensure a 200us delay between the DLL reset in step 6 and the final
1851 * mode register set in step 9.
1852 * Infineon needs this before any other command is sent to the ram.
1857 /* 7 Precharge all */
1858 RAM_DEBUG_MESSAGE("Ram Enable 7\r\n");
1859 do_ram_command(ctrl, RAM_COMMAND_PRECHARGE, 0);
1862 /* 8 Now we need 2 AUTO REFRESH / CBR cycles to be performed */
1863 RAM_DEBUG_MESSAGE("Ram Enable 8\r\n");
1864 do_ram_command(ctrl, RAM_COMMAND_CBR, 0);
1866 do_ram_command(ctrl, RAM_COMMAND_CBR, 0);
1868 /* And for good luck 6 more CBRs */
1869 do_ram_command(ctrl, RAM_COMMAND_CBR, 0);
1871 do_ram_command(ctrl, RAM_COMMAND_CBR, 0);
1873 do_ram_command(ctrl, RAM_COMMAND_CBR, 0);
1875 do_ram_command(ctrl, RAM_COMMAND_CBR, 0);
1877 do_ram_command(ctrl, RAM_COMMAND_CBR, 0);
1879 do_ram_command(ctrl, RAM_COMMAND_CBR, 0);
1882 /* 9 mode register set */
1883 RAM_DEBUG_MESSAGE("Ram Enable 9\r\n");
1884 set_ram_mode(ctrl, E7501_SDRAM_MODE | SDRAM_MODE_NORMAL);
1887 /* 10 DDR Receive FIFO RE-Sync */
1888 RAM_DEBUG_MESSAGE("Ram Enable 10\r\n");
1889 RAM_RESET_DDR_PTR(ctrl);
1892 /* 11 normal operation */
1893 RAM_DEBUG_MESSAGE("Ram Enable 11\r\n");
1894 do_ram_command(ctrl, RAM_COMMAND_NORMAL, 0);
1897 // Reconfigure the row boundaries and Top of Low Memory
1898 // to match the true size of the DIMMs
1899 configure_e7501_ram_addresses(ctrl, dimm_mask);
1901 /* Finally enable refresh */
1902 dram_controller_mode = pci_read_config32(ctrl->d0, DRC);
1903 dram_controller_mode |= (1 << 29);
1904 pci_write_config32(ctrl->d0, DRC, dram_controller_mode);
1907 initialize_ecc(ctrl);
1909 dram_controller_mode = pci_read_config32(ctrl->d0, DRC); /* FCS_EN */
1910 dram_controller_mode |= (1<<17); // NOTE: undocumented reserved bit
1911 pci_write_config32(ctrl->d0, DRC, dram_controller_mode);
1913 RAM_DEBUG_MESSAGE("Northbridge following SDRAM init:\r\n");
1919 //----------------------------------------------------------------------------------
1920 // Function: sdram_set_spd_registers
1921 // Parameters: ctrl - PCI addresses of memory controller functions, and
1922 // SMBus addresses of DIMM slots on the mainboard
1923 // Return Value: None
1924 // Description: Configure SDRAM controller parameters that depend on
1925 // characteristics of the DIMMs installed in the system. These
1926 // characteristics are read from the DIMMs via the standard Serial
1927 // Presence Detect (SPD) interface.
1929 static void sdram_set_spd_registers(const struct mem_controller *ctrl)
1933 RAM_DEBUG_MESSAGE("Reading SPD data...\r\n");
1935 //activate_spd_rom(ctrl); Not necessary for this chipset
1937 dimm_mask = spd_get_supported_dimms(ctrl);
1939 if (dimm_mask == 0) {
1940 print_debug("No usable memory for this controller\r\n");
1943 enable_e7501_clocks(ctrl, dimm_mask);
1945 RAM_DEBUG_MESSAGE("setting based on SPD data...\r\n");
1947 configure_e7501_row_attributes(ctrl, dimm_mask);
1948 configure_e7501_dram_controller_mode(ctrl, dimm_mask);
1949 configure_e7501_cas_latency(ctrl, dimm_mask);
1950 RAM_RESET_DDR_PTR(ctrl);
1952 configure_e7501_dram_timing(ctrl, dimm_mask);
1954 RAM_DEBUG_MESSAGE("done\r\n");
1957 // NOTE: configure_e7501_ram_addresses() is NOT called here.
1958 // We want to keep the default 64 MB/row mapping until sdram_enable() is called,
1959 // even though the default mapping is almost certainly incorrect.
1960 // The default mapping makes it easy to initialize all of the DIMMs
1961 // even if the total system memory is > 4 GB.
1963 // Save the dimm_mask for when sdram_enable is called, so it can call
1964 // configure_e7501_ram_addresses() without having to regenerate the bitmask
1966 pci_write_config16(ctrl->d0, SKPD, dimm_mask);
1969 //----------------------------------------------------------------------------------
1970 // Function: sdram_set_registers
1971 // Parameters: ctrl - PCI addresses of memory controller functions, and
1972 // SMBus addresses of DIMM slots on the mainboard
1973 // Return Value: None
1974 // Description: Do basic ram setup that does NOT depend on serial presence detect
1975 // information (i.e. independent of DIMM specifics).
1977 static void sdram_set_registers(const struct mem_controller *ctrl)
1979 RAM_DEBUG_MESSAGE("Northbridge prior to SDRAM init:\r\n");
1982 ram_set_rcomp_regs(ctrl);
1983 ram_set_d0f0_regs(ctrl);
1986 /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
1987 /* PUBLIC INTERFACE */
1988 /**********************************************************************************/