1 #define MEMORY_512MB 0 /* SuSE Solo configuration */
2 #define MEMORY_1024MB 1 /* LNXI Solo configuration */
4 static void sdram_set_registers(void)
6 static const unsigned int register_values[] = {
7 /* Careful set limit registers before base registers which contain the enables */
8 /* DRAM Limit i Registers
17 * [ 2: 0] Destination Node ID
27 * [10: 8] Interleave select
28 * specifies the values of A[14:12] to use with interleave enable.
30 * [31:16] DRAM Limit Address i Bits 39-24
31 * This field defines the upper address bits of a 40 bit address
32 * that define the end of the DRAM region.
35 PCI_ADDR(0, 0x18, 1, 0x44), 0x0000f8f8, 0x003f0000,
38 PCI_ADDR(0, 0x18, 1, 0x44), 0x0000f8f8, 0x001f0000,
40 PCI_ADDR(0, 0x18, 1, 0x4C), 0x0000f8f8, 0x00000001,
41 PCI_ADDR(0, 0x18, 1, 0x54), 0x0000f8f8, 0x00000002,
42 PCI_ADDR(0, 0x18, 1, 0x5C), 0x0000f8f8, 0x00000003,
43 PCI_ADDR(0, 0x18, 1, 0x64), 0x0000f8f8, 0x00000004,
44 PCI_ADDR(0, 0x18, 1, 0x6C), 0x0000f8f8, 0x00000005,
45 PCI_ADDR(0, 0x18, 1, 0x74), 0x0000f8f8, 0x00000006,
46 PCI_ADDR(0, 0x18, 1, 0x7C), 0x0000f8f8, 0x00000007,
47 /* DRAM Base i Registers
59 * [ 1: 1] Write Enable
63 * [10: 8] Interleave Enable
65 * 001 = Interleave on A[12] (2 nodes)
67 * 011 = Interleave on A[12] and A[14] (4 nodes)
71 * 111 = Interleve on A[12] and A[13] and A[14] (8 nodes)
73 * [13:16] DRAM Base Address i Bits 39-24
74 * This field defines the upper address bits of a 40-bit address
75 * that define the start of the DRAM region.
77 PCI_ADDR(0, 0x18, 1, 0x40), 0x0000f8fc, 0x00000003,
79 PCI_ADDR(0, 0x18, 1, 0x48), 0x0000f8fc, 0x00400000,
80 PCI_ADDR(0, 0x18, 1, 0x50), 0x0000f8fc, 0x00400000,
81 PCI_ADDR(0, 0x18, 1, 0x58), 0x0000f8fc, 0x00400000,
82 PCI_ADDR(0, 0x18, 1, 0x60), 0x0000f8fc, 0x00400000,
83 PCI_ADDR(0, 0x18, 1, 0x68), 0x0000f8fc, 0x00400000,
84 PCI_ADDR(0, 0x18, 1, 0x70), 0x0000f8fc, 0x00400000,
85 PCI_ADDR(0, 0x18, 1, 0x78), 0x0000f8fc, 0x00400000,
88 PCI_ADDR(0, 0x18, 1, 0x48), 0x0000f8fc, 0x00200000,
89 PCI_ADDR(0, 0x18, 1, 0x50), 0x0000f8fc, 0x00200000,
90 PCI_ADDR(0, 0x18, 1, 0x58), 0x0000f8fc, 0x00200000,
91 PCI_ADDR(0, 0x18, 1, 0x60), 0x0000f8fc, 0x00200000,
92 PCI_ADDR(0, 0x18, 1, 0x68), 0x0000f8fc, 0x00200000,
93 PCI_ADDR(0, 0x18, 1, 0x70), 0x0000f8fc, 0x00200000,
94 PCI_ADDR(0, 0x18, 1, 0x78), 0x0000f8fc, 0x00200000,
97 /* Memory-Mapped I/O Limit i Registers
106 * [ 2: 0] Destination Node ID
116 * [ 5: 4] Destination Link ID
123 * 0 = CPU writes may be posted
124 * 1 = CPU writes must be non-posted
125 * [31: 8] Memory-Mapped I/O Limit Address i (39-16)
126 * This field defines the upp adddress bits of a 40-bit address that
127 * defines the end of a memory-mapped I/O region n
129 PCI_ADDR(0, 0x18, 1, 0x84), 0x00000048, 0x00e1ff00,
130 PCI_ADDR(0, 0x18, 1, 0x8C), 0x00000048, 0x00dfff00,
131 PCI_ADDR(0, 0x18, 1, 0x94), 0x00000048, 0x00e3ff00,
132 PCI_ADDR(0, 0x18, 1, 0x9C), 0x00000048, 0x00000000,
133 PCI_ADDR(0, 0x18, 1, 0xA4), 0x00000048, 0x00000000,
134 PCI_ADDR(0, 0x18, 1, 0xAC), 0x00000048, 0x00000000,
135 PCI_ADDR(0, 0x18, 1, 0xB4), 0x00000048, 0x00000b00,
136 PCI_ADDR(0, 0x18, 1, 0xBC), 0x00000048, 0x00fe0b00,
138 /* Memory-Mapped I/O Base i Registers
147 * [ 0: 0] Read Enable
150 * [ 1: 1] Write Enable
151 * 0 = Writes disabled
153 * [ 2: 2] Cpu Disable
154 * 0 = Cpu can use this I/O range
155 * 1 = Cpu requests do not use this I/O range
157 * 0 = base/limit registers i are read/write
158 * 1 = base/limit registers i are read-only
160 * [31: 8] Memory-Mapped I/O Base Address i (39-16)
161 * This field defines the upper address bits of a 40bit address
162 * that defines the start of memory-mapped I/O region i
164 PCI_ADDR(0, 0x18, 1, 0x80), 0x000000f0, 0x00e00003,
165 PCI_ADDR(0, 0x18, 1, 0x88), 0x000000f0, 0x00d80003,
166 PCI_ADDR(0, 0x18, 1, 0x90), 0x000000f0, 0x00e20003,
167 PCI_ADDR(0, 0x18, 1, 0x98), 0x000000f0, 0x00000000,
168 PCI_ADDR(0, 0x18, 1, 0xA0), 0x000000f0, 0x00000000,
169 PCI_ADDR(0, 0x18, 1, 0xA8), 0x000000f0, 0x00000000,
170 PCI_ADDR(0, 0x18, 1, 0xB0), 0x000000f0, 0x00000a03,
172 PCI_ADDR(0, 0x18, 1, 0xB8), 0x000000f0, 0x00400003,
175 PCI_ADDR(0, 0x18, 1, 0xB8), 0x000000f0, 0x00200003,
178 /* PCI I/O Limit i Registers
183 * [ 2: 0] Destination Node ID
193 * [ 5: 4] Destination Link ID
199 * [24:12] PCI I/O Limit Address i
200 * This field defines the end of PCI I/O region n
203 PCI_ADDR(0, 0x18, 1, 0xC4), 0xFE000FC8, 0x0000d000,
204 PCI_ADDR(0, 0x18, 1, 0xCC), 0xFE000FC8, 0x000ff000,
205 PCI_ADDR(0, 0x18, 1, 0xD4), 0xFE000FC8, 0x00000000,
206 PCI_ADDR(0, 0x18, 1, 0xDC), 0xFE000FC8, 0x00000000,
208 /* PCI I/O Base i Registers
213 * [ 0: 0] Read Enable
216 * [ 1: 1] Write Enable
217 * 0 = Writes Disabled
221 * 0 = VGA matches Disabled
222 * 1 = matches all address < 64K and where A[9:0] is in the
223 * range 3B0-3BB or 3C0-3DF independen of the base & limit registers
225 * 0 = ISA matches Disabled
226 * 1 = Blocks address < 64K and in the last 768 bytes of eack 1K block
227 * from matching agains this base/limit pair
229 * [24:12] PCI I/O Base i
230 * This field defines the start of PCI I/O region n
233 PCI_ADDR(0, 0x18, 1, 0xC0), 0xFE000FCC, 0x0000d003,
234 PCI_ADDR(0, 0x18, 1, 0xC8), 0xFE000FCC, 0x00001013,
235 PCI_ADDR(0, 0x18, 1, 0xD0), 0xFE000FCC, 0x00000000,
236 PCI_ADDR(0, 0x18, 1, 0xD8), 0xFE000FCC, 0x00000000,
238 /* Config Base and Limit i Registers
243 * [ 0: 0] Read Enable
246 * [ 1: 1] Write Enable
247 * 0 = Writes Disabled
249 * [ 2: 2] Device Number Compare Enable
250 * 0 = The ranges are based on bus number
251 * 1 = The ranges are ranges of devices on bus 0
253 * [ 6: 4] Destination Node
263 * [ 9: 8] Destination Link
269 * [23:16] Bus Number Base i
270 * This field defines the lowest bus number in configuration region i
271 * [31:24] Bus Number Limit i
272 * This field defines the highest bus number in configuration regin i
274 PCI_ADDR(0, 0x18, 1, 0xE0), 0x0000FC88, 0xff000003,
275 PCI_ADDR(0, 0x18, 1, 0xE4), 0x0000FC88, 0x00000000,
276 PCI_ADDR(0, 0x18, 1, 0xE8), 0x0000FC88, 0x00000000,
277 PCI_ADDR(0, 0x18, 1, 0xEC), 0x0000FC88, 0x00000000,
279 /* DRAM CS Base Address i Registers
288 * [ 0: 0] Chip-Select Bank Enable
292 * [15: 9] Base Address (19-13)
293 * An optimization used when all DIMM are the same size...
295 * [31:21] Base Address (35-25)
296 * This field defines the top 11 addresses bit of a 40-bit
297 * address that define the memory address space. These
298 * bits decode 32-MByte blocks of memory.
300 PCI_ADDR(0, 0x18, 2, 0x40), 0x001f01fe, 0x00000001,
302 PCI_ADDR(0, 0x18, 2, 0x44), 0x001f01fe, 0x01000001,
303 PCI_ADDR(0, 0x18, 2, 0x48), 0x001f01fe, 0x02000001,
304 PCI_ADDR(0, 0x18, 2, 0x4C), 0x001f01fe, 0x03000001,
307 PCI_ADDR(0, 0x18, 2, 0x44), 0x001f01fe, 0x00800001,
308 PCI_ADDR(0, 0x18, 2, 0x48), 0x001f01fe, 0x01000001,
309 PCI_ADDR(0, 0x18, 2, 0x4C), 0x001f01fe, 0x01800001,
311 PCI_ADDR(0, 0x18, 2, 0x50), 0x001f01fe, 0x00000000,
312 PCI_ADDR(0, 0x18, 2, 0x54), 0x001f01fe, 0x00000000,
313 PCI_ADDR(0, 0x18, 2, 0x58), 0x001f01fe, 0x00000000,
314 PCI_ADDR(0, 0x18, 2, 0x5C), 0x001f01fe, 0x00000000,
315 /* DRAM CS Mask Address i Registers
324 * Select bits to exclude from comparison with the DRAM Base address register.
326 * [15: 9] Address Mask (19-13)
327 * Address to be excluded from the optimized case
329 * [29:21] Address Mask (33-25)
330 * The bits with an address mask of 1 are excluded from address comparison
335 PCI_ADDR(0, 0x18, 2, 0x60), 0xC01f01ff, 0x00e0fe00,
336 PCI_ADDR(0, 0x18, 2, 0x64), 0xC01f01ff, 0x00e0fe00,
337 PCI_ADDR(0, 0x18, 2, 0x68), 0xC01f01ff, 0x00e0fe00,
338 PCI_ADDR(0, 0x18, 2, 0x6C), 0xC01f01ff, 0x00e0fe00,
341 PCI_ADDR(0, 0x18, 2, 0x60), 0xC01f01ff, 0x0060fe00,
342 PCI_ADDR(0, 0x18, 2, 0x64), 0xC01f01ff, 0x0060fe00,
343 PCI_ADDR(0, 0x18, 2, 0x68), 0xC01f01ff, 0x0060fe00,
344 PCI_ADDR(0, 0x18, 2, 0x6C), 0xC01f01ff, 0x0060fe00,
346 PCI_ADDR(0, 0x18, 2, 0x70), 0xC01f01ff, 0x00000000,
347 PCI_ADDR(0, 0x18, 2, 0x74), 0xC01f01ff, 0x00000000,
348 PCI_ADDR(0, 0x18, 2, 0x78), 0xC01f01ff, 0x00000000,
349 PCI_ADDR(0, 0x18, 2, 0x7C), 0xC01f01ff, 0x00000000,
350 /* DRAM Bank Address Mapping Register
352 * Specify the memory module size
357 * 000 = 32Mbyte (Rows = 12 & Col = 8)
358 * 001 = 64Mbyte (Rows = 12 & Col = 9)
359 * 010 = 128Mbyte (Rows = 13 & Col = 9)|(Rows = 12 & Col = 10)
360 * 011 = 256Mbyte (Rows = 13 & Col = 10)|(Rows = 12 & Col = 11)
361 * 100 = 512Mbyte (Rows = 13 & Col = 11)|(Rows = 14 & Col = 10)
362 * 101 = 1Gbyte (Rows = 14 & Col = 11)|(Rows = 13 & Col = 12)
363 * 110 = 2Gbyte (Rows = 14 & Col = 12)
371 PCI_ADDR(0, 0x18, 2, 0x80), 0xffff8888, 0x00000033,
374 PCI_ADDR(0, 0x18, 2, 0x80), 0xffff8888, 0x00000022,
376 /* DRAM Timing Low Register
378 * [ 2: 0] Tcl (Cas# Latency, Cas# to read-data-valid)
388 * [ 7: 4] Trc (Row Cycle Time, Ras#-active to Ras#-active/bank auto refresh)
389 * 0000 = 7 bus clocks
390 * 0001 = 8 bus clocks
392 * 1110 = 21 bus clocks
393 * 1111 = 22 bus clocks
394 * [11: 8] Trfc (Row refresh Cycle time, Auto-refresh-active to RAS#-active or RAS#auto-refresh)
395 * 0000 = 9 bus clocks
396 * 0010 = 10 bus clocks
398 * 1110 = 23 bus clocks
399 * 1111 = 24 bus clocks
400 * [14:12] Trcd (Ras#-active to Case#-read/write Delay)
410 * [18:16] Trrd (Ras# to Ras# Delay)
420 * [23:20] Tras (Minmum Ras# Active Time)
421 * 0000 to 0100 = reserved
422 * 0101 = 5 bus clocks
424 * 1111 = 15 bus clocks
425 * [26:24] Trp (Row Precharge Time)
435 * [28:28] Twr (Write Recovery Time)
440 PCI_ADDR(0, 0x18, 2, 0x88), 0xe8088008, 0x03623125,
441 /* DRAM Timing High Register
443 * [ 0: 0] Twtr (Write to Read Delay)
447 * [ 6: 4] Trwf (Read to Write Delay)
457 * [12: 8] Tref (Refresh Rate)
458 * 00000 = 100Mhz 4K rows
459 * 00001 = 133Mhz 4K rows
460 * 00010 = 166Mhz 4K rows
461 * 01000 = 100Mhz 8K/16K rows
462 * 01001 = 133Mhz 8K/16K rows
463 * 01010 = 166Mhz 8K/16K rows
465 * [22:20] Twcl (Write CAS Latency)
466 * 000 = 1 Mem clock after CAS# (Unbuffered Dimms)
467 * 001 = 2 Mem clocks after CAS# (Registered Dimms)
471 PCI_ADDR(0, 0x18, 2, 0x8c), 0xff8fe08e, 0x00000930,
474 PCI_ADDR(0, 0x18, 2, 0x8c), 0xff8fe08e, 0x00000130,
477 /* DRAM Config Low Register
479 * [ 0: 0] DLL Disable
488 * [ 3: 3] Disable DQS Hystersis (FIXME handle this one carefully)
489 * 0 = Enable DQS input filter
490 * 1 = Disable DQS input filtering
493 * 0 = Initialization done or not yet started.
494 * 1 = Initiate DRAM intialization sequence
495 * [ 9: 9] SO-Dimm Enable
497 * 1 = SO-Dimms present
499 * 0 = DRAM not enabled
500 * 1 = DRAM initialized and enabled
501 * [11:11] Memory Clear Status
502 * 0 = Memory Clear function has not completed
503 * 1 = Memory Clear function has completed
504 * [12:12] Exit Self-Refresh
505 * 0 = Exit from self-refresh done or not yet started
506 * 1 = DRAM exiting from self refresh
507 * [13:13] Self-Refresh Status
508 * 0 = Normal Operation
509 * 1 = Self-refresh mode active
510 * [15:14] Read/Write Queue Bypass Count
515 * [16:16] 128-bit/64-Bit
516 * 0 = 64bit Interface to DRAM
517 * 1 = 128bit Interface to DRAM
518 * [17:17] DIMM ECC Enable
519 * 0 = Some DIMMs do not have ECC
520 * 1 = ALL DIMMS have ECC bits
521 * [18:18] UnBuffered DIMMs
523 * 1 = Unbuffered DIMMS
524 * [19:19] Enable 32-Byte Granularity
525 * 0 = Optimize for 64byte bursts
526 * 1 = Optimize for 32byte bursts
527 * [20:20] DIMM 0 is x4
528 * [21:21] DIMM 1 is x4
529 * [22:22] DIMM 2 is x4
530 * [23:23] DIMM 3 is x4
532 * 1 = x4 DIMM present
533 * [24:24] Disable DRAM Receivers
534 * 0 = Receivers enabled
535 * 1 = Receivers disabled
537 * 000 = Arbiters chois is always respected
538 * 001 = Oldest entry in DCQ can be bypassed 1 time
539 * 010 = Oldest entry in DCQ can be bypassed 2 times
540 * 011 = Oldest entry in DCQ can be bypassed 3 times
541 * 100 = Oldest entry in DCQ can be bypassed 4 times
542 * 101 = Oldest entry in DCQ can be bypassed 5 times
543 * 110 = Oldest entry in DCQ can be bypassed 6 times
544 * 111 = Oldest entry in DCQ can be bypassed 7 times
547 PCI_ADDR(0, 0x18, 2, 0x90), 0xf0000000,
549 (0 << 23)|(0 << 22)|(0 << 21)|(0 << 20)|
550 (1 << 19)|(1 << 18)|(0 << 17)|(0 << 16)|
551 (2 << 14)|(0 << 13)|(0 << 12)|
552 (0 << 11)|(0 << 10)|(0 << 9)|(0 << 8)|
553 (0 << 3) |(0 << 1) |(0 << 0),
554 /* DRAM Config High Register
556 * [ 0: 3] Maximum Asynchronous Latency
561 * [11: 8] Read Preamble
579 * [18:16] Idle Cycle Limit
588 * [19:19] Dynamic Idle Cycle Center Enable
589 * 0 = Use Idle Cycle Limit
590 * 1 = Generate a dynamic Idle cycle limit
591 * [22:20] DRAM MEMCLK Frequency
601 * [25:25] Memory Clock Ratio Valid (FIXME carefully enable memclk)
602 * 0 = Disable MemClks
604 * [26:26] Memory Clock 0 Enable
607 * [27:27] Memory Clock 1 Enable
610 * [28:28] Memory Clock 2 Enable
613 * [29:29] Memory Clock 3 Enable
619 PCI_ADDR(0, 0x18, 2, 0x94), 0xc180f0f0, 0x0e2b0a05,
622 PCI_ADDR(0, 0x18, 2, 0x94), 0xc180f0f0, 0x0e2b0a06,
624 /* DRAM Delay Line Register
626 * Adjust the skew of the input DQS strobe relative to DATA
628 * [23:16] Delay Line Adjust
629 * Adjusts the DLL derived PDL delay by one or more delay stages
630 * in either the faster or slower direction.
631 * [24:24} Adjust Slower
633 * 1 = Adj is used to increase the PDL delay
634 * [25:25] Adjust Faster
636 * 1 = Adj is used to decrease the PDL delay
639 PCI_ADDR(0, 0x18, 2, 0x98), 0xfc00ffff, 0x00000000,
640 /* DRAM Scrub Control Register
642 * [ 4: 0] DRAM Scrube Rate
644 * [12: 8] L2 Scrub Rate
646 * [20:16] Dcache Scrub
649 * 00000 = Do not scrub
671 * All Others = Reserved
673 PCI_ADDR(0, 0x18, 3, 0x58), 0xffe0e0e0, 0x00000000,
674 /* DRAM Scrub Address Low Register
676 * [ 0: 0] DRAM Scrubber Redirect Enable
678 * 1 = Scrubber Corrects errors found in normal operation
680 * [31: 6] DRAM Scrub Address 31-6
682 PCI_ADDR(0, 0x18, 3, 0x5C), 0x0000003e, 0x00000000,
683 /* DRAM Scrub Address High Register
685 * [ 7: 0] DRAM Scrubb Address 39-32
688 PCI_ADDR(0, 0x18, 3, 0x60), 0xffffff00, 0x00000000,
692 print_debug("setting up CPU0 northbridge registers\r\n");
693 max = sizeof(register_values)/sizeof(register_values[0]);
694 for(i = 0; i < max; i += 3) {
699 print_debug_hex32(register_values[i]);
701 print_debug_hex32(register_values[i+2]);
704 dev = register_values[i] & ~0xff;
705 where = register_values[i] & 0xff;
706 reg = pci_read_config32(dev, where);
707 reg &= register_values[i+1];
708 reg |= register_values[i+2];
709 pci_write_config32(dev, where, reg);
712 reg = pci_read_config32(register_values[i]);
713 reg &= register_values[i+1];
714 reg |= register_values[i+2];
715 pci_write_config32(register_values[i], reg);
718 print_debug("done.\r\n");
721 #define DRAM_CONFIG_LOW 0x90
722 #define DCL_DLL_Disable (1<<0)
723 #define DCL_D_DRV (1<<1)
724 #define DCL_QFC_EN (1<<2)
725 #define DCL_DisDqsHys (1<<3)
726 #define DCL_DramInit (1<<8)
727 #define DCL_DramEnable (1<<10)
728 #define DCL_MemClrStatus (1<<11)
729 #define DCL_DimmEcEn (1<<17)
732 #define HT_INIT_CONTROL 0x6c
734 #define HTIC_ColdR_Detect (1<<4)
735 #define HTIC_BIOSR_Detect (1<<5)
736 #define HTIC_INIT_Detect (1<<6)
738 static void sdram_set_spd_registers(void)
741 dcl = pci_read_config32(PCI_DEV(0, 0x18, 2), DRAM_CONFIG_LOW);
742 /* Until I know what is going on disable ECC support */
743 dcl &= ~DCL_DimmEcEn;
744 pci_write_config32(PCI_DEV(0, 0x18, 2), DRAM_CONFIG_LOW, dcl);
747 #define TIMEOUT_LOOPS 300000
748 static void sdram_enable(void)
752 /* Toggle DisDqsHys to get it working */
753 dcl = pci_read_config32(PCI_DEV(0, 0x18, 2), DRAM_CONFIG_LOW);
754 print_debug("dcl: ");
755 print_debug_hex32(dcl);
757 dcl |= DCL_DisDqsHys;
758 pci_write_config32(PCI_DEV(0, 0x18, 2), DRAM_CONFIG_LOW, dcl);
759 dcl &= ~DCL_DisDqsHys;
760 dcl &= ~DCL_DLL_Disable;
764 pci_write_config32(PCI_DEV(0, 0x18, 2), DRAM_CONFIG_LOW, dcl);
766 print_debug("Initializing memory: ");
769 dcl = pci_read_config32(PCI_DEV(0, 0x18, 2), DRAM_CONFIG_LOW);
771 if ((loops & 1023) == 0) {
774 } while(((dcl & DCL_DramInit) != 0) && (loops < TIMEOUT_LOOPS));
775 if (loops >= TIMEOUT_LOOPS) {
776 print_debug(" failed\r\n");
778 print_debug(" done\r\n");
782 print_debug("Clearing memory: ");
785 dcl = pci_read_config32(PCI_DEV(0, 0x18, 2), DRAM_CONFIG_LOW);
787 if ((loops & 1023) == 0) {
789 print_debug_hex32(loops);
791 } while(((dcl & DCL_MemClrStatus) == 0) && (loops < TIMEOUT_LOOPS));
792 if (loops >= TIMEOUT_LOOPS) {
793 print_debug("failed\r\n");
795 print_debug("done\r\n");
800 static void sdram_first_normal_reference(void) {}
801 static void sdram_enable_refresh(void) {}
802 static void sdram_special_finishup(void) {}