2 #include "arch/romcc_io.h"
3 #include "pc80/serial.c"
4 #include "arch/i386/lib/console.c"
5 #include "ram/ramtest.c"
8 static void sdram_set_registers(void)
10 static const unsigned int register_values[] = {
11 /* Routing Table Node i
20 * [ 0: 3] Request Route
21 * [0] Route to this node
25 * [11: 8] Response Route
26 * [0] Route to this node
30 * [19:16] Broadcast route
31 * [0] Route to this node
36 0xc040, 0xfff0f0f0, 0x00010101,
37 0xc044, 0xfff0f0f0, 0x00010101,
38 0xc048, 0xfff0f0f0, 0x00010101,
39 0xc04c, 0xfff0f0f0, 0x00010101,
40 0xc050, 0xfff0f0f0, 0x00010101,
41 0xc054, 0xfff0f0f0, 0x00010101,
42 0xc058, 0xfff0f0f0, 0x00010101,
43 0xc05c, 0xfff0f0f0, 0x00010101,
45 /* Hypetransport Transaction Control Register
47 * [ 0: 0] Disable read byte probe
49 * 1 = Probes not issued
50 * [ 1: 1] Disable Read Doubleword probe
52 * 1 = Probes not issued
53 * [ 2: 2] Disable write byte probes
55 * 1 = Probes not issued
56 * [ 3: 3] Disalbe Write Doubleword Probes
58 * 1 = Probes not issued.
59 * [ 4: 4] Disable Memroy Controller Target Start
60 * 0 = TgtStart packets are generated
61 * 1 = TgtStart packets are not generated.
63 * 0 = Second CPU disabled or not present
64 * 1 = Second CPU enabled.
65 * [ 6: 6] CPU Request PassPW
66 * 0 = CPU requests do not pass posted writes
67 * 1 = CPU requests pass posted writes.
68 * [ 7: 7] CPU read Respons PassPW
69 * 0 = CPU Responses do not pass posted writes
70 * 1 = CPU responses pass posted writes.
71 * [ 8: 8] Disable Probe Memory Cancel
72 * 0 = Probes may generate MemCancels
73 * 1 = Probes may not generate MemCancels
74 * [ 9: 9] Disable Remote Probe Memory Cancel.
75 * 0 = Probes hitting dirty blocks generate memory cancel packets
76 * 1 = Only probed caches on the same node as the memory controller
77 * generate cancel packets.
78 * [10:10] Disable Fill Probe
79 * 0 = Probes issued for cache fills
80 * 1 = Probes not issued for cache fills.
81 * [11:11] Response PassPw
82 * 0 = Downstream response PassPW based on original request
83 * 1 = Downstream response PassPW set to 1
84 * [12:12] Change ISOC to Ordered
85 * 0 = Bit 1 of coherent HT RdSz/WrSz command used for iosynchronous prioritization
86 * 1 = Bit 1 of coherent HT RdSz/WrSz command used for ordering.
87 * [14:13] Buffer Release Priority select
92 * [15:15] Limit Coherent HT Configuration Space Range
93 * 0 = No coherent HT configuration space restrictions
94 * 1 = Limit coherent HT configuration space based on node count
95 * [16:16] Local Interrupt Conversion Enable.
96 * 0 = ExtInt/NMI interrups unaffected.
97 * 1 = ExtInt/NMI broadcat interrupts converted to LINT0/1
98 * [17:17] APIC Extended Broadcast Enable.
99 * 0 = APIC broadcast is 0F
100 * 1 = APIC broadcast is FF
101 * [18:18] APIC Extended ID Enable
102 * 0 = APIC ID is 4 bits.
103 * 1 = APIC ID is 8 bits.
104 * [19:19] APIC Extended Spurious Vector Enable
105 * 0 = Lower 4 bits of spurious vector are read-only 1111
106 * 1 = Lower 4 bits of spurious vecotr are writeable.
107 * [20:20] Sequence ID Source Node Enable
108 * 0 = Normal operation
109 * 1 = Keep SeqID on routed packets for debugging.
110 * [22:21] Downstream non-posted request limit
116 * [25:24] Medium-Priority Bypass Count
117 * - Maximum # of times a medium priority access can pass a low
118 * priority access before Medium-Priority mode is disabled for one access.
119 * [27:26] High-Priority Bypass Count
120 * - Maximum # of times a high prioirty access can pass a medium or low
121 * priority access before High-prioirty mode is disabled for one access.
122 * [28:28] Enable High Priority CPU Reads
123 * 0 = Cpu reads are medium prioirty
124 * 1 = Cpu reads are high prioirty
125 * [29:29] Disable Low Priority Writes
126 * 0 = Non-isochronous writes are low priority
127 * 1 = Non-isochronous writes are medium prioirty
128 * [30:30] Disable High Priority Isochronous writes
129 * 0 = Isochronous writes are high priority
130 * 1 = Isochronous writes are medium priority
131 * [31:31] Disable Medium Priority Isochronous writes
132 * 0 = Isochronous writes are medium are high
133 * 1 = With bit 30 set makes Isochrouns writes low priority.
135 0xc068, 0x00800000, 0x0f00840f,
136 /* HT Initialization Control Register
138 * [ 0: 0] Routing Table Disable
139 * 0 = Packets are routed according to routing tables
140 * 1 = Packets are routed according to the default link field
141 * [ 1: 1] Request Disable (BSP should clear this)
142 * 0 = Request packets may be generated
143 * 1 = Request packets may not be generated.
144 * [ 3: 2] Default Link (Read-only)
148 * 11 = CPU on same node
150 * - Scratch bit cleared by a cold reset
151 * [ 5: 5] BIOS Reset Detect
152 * - Scratch bit cleared by a cold reset
153 * [ 6: 6] INIT Detect
154 * - Scratch bit cleared by a warm or cold reset not by an INIT
157 0xc06C, 0xffffff8c, 0x00000000,
158 /* LDTi Capabilities Registers
163 /* LDTi Link Control Registrs
167 * [ 1: 1] CRC Flood Enable
168 * 0 = Do not generate sync packets on CRC error
169 * 1 = Generate sync packets on CRC error
170 * [ 2: 2] CRC Start Test (Read-Only)
171 * [ 3: 3] CRC Force Frame Error
172 * 0 = Do not generate bad CRC
173 * 1 = Generate bad CRC
174 * [ 4: 4] Link Failure
175 * 0 = No link failure detected
176 * 1 = Link failure detected
177 * [ 5: 5] Initialization Complete
178 * 0 = Initialization not complete
179 * 1 = Initialization complete
180 * [ 6: 6] Receiver off
183 * [ 7: 7] Transmitter Off
185 * 1 = Transmitter off
188 * [0] = 1 Error on byte lane 0
189 * [1] = 1 Error on byte lane 1
190 * [12:12] Isochrnous Enable (Read-Only)
191 * [13:13] HT Stop Tristate Enable
192 * 0 = Driven during an LDTSTOP_L
193 * 1 = Tristated during and LDTSTOP_L
194 * [14:14] Extended CTL Time
195 * 0 = CTL is asserted for 16 bit times during link initialization
196 * 1 = CTL is asserted for 50us during link initialization
197 * [18:16] Max Link Width In (Read-Only?)
200 * [19:19] Doubleword Flow Control in (Read-Only)
201 * 0 = This link does not support doubleword flow control
202 * 1 = This link supports doubleword flow control
203 * [22:20] Max Link Width Out (Read-Only?)
206 * [23:23] Doubleworld Flow Control out (Read-Only)
207 * 0 = This link does not support doubleword flow control
208 * 1 = This link supports doubleworkd flow control
209 * [26:24] Link Width In
217 * 111 = Link physically not connected
218 * [27:27] Doubleword Flow Control In Enable
219 * 0 = Doubleword flow control disabled
220 * 1 = Doubleword flow control enabled (Not currently supported)
221 * [30:28] Link Width Out
229 * 111 = Link physically not connected
230 * [31:31] Doubleworld Flow Control Out Enable
231 * 0 = Doubleworld flow control disabled
232 * 1 = Doubleword flow control enabled (Not currently supported)
234 0xc084, 0x00009c05, 0x11110020,
235 /* LDTi Frequency/Revision Registers
239 * [ 4: 0] Minor Revision
240 * Contains the HT Minor revision
241 * [ 7: 5] Major Revision
242 * Contains the HT Major revision
243 * [11: 8] Link Frequency (Takes effect the next time the link is reconnected)
260 * [15:12] Error (Not currently Implemented)
261 * [31:16] Indicates the frequency capabilities of the link
262 * [16] = 1 encoding 0000 of freq supported
263 * [17] = 1 encoding 0001 of freq supported
264 * [18] = 1 encoding 0010 of freq supported
265 * [19] = 1 encoding 0011 of freq supported
266 * [20] = 1 encoding 0100 of freq supported
267 * [21] = 1 encoding 0101 of freq supported
268 * [22] = 1 encoding 0110 of freq supported
269 * [23] = 1 encoding 0111 of freq supported
270 * [24] = 1 encoding 1000 of freq supported
271 * [25] = 1 encoding 1001 of freq supported
272 * [26] = 1 encoding 1010 of freq supported
273 * [27] = 1 encoding 1011 of freq supported
274 * [28] = 1 encoding 1100 of freq supported
275 * [29] = 1 encoding 1101 of freq supported
276 * [30] = 1 encoding 1110 of freq supported
277 * [31] = 1 encoding 1111 of freq supported
279 0xC088, 0xfffff0ff, 0x00000200,
280 /* LDTi Feature Capability
285 /* LDTi Buffer Count Registers
290 /* LDTi Bus Number Registers
294 * For NonCoherent HT specifies the bus number downstream (behind the host bridge)
295 * [ 0: 7] Primary Bus Number
296 * [15: 8] Secondary Bus Number
297 * [23:15] Subordiante Bus Number
300 0xC094, 0xff000000, 0x00ff0000,
301 /* LDTi Type Registers
306 /* Careful set limit registers before base registers which contain the enables */
307 /* DRAM Limit i Registers
316 * [ 2: 0] Destination Node ID
326 * [10: 8] Interleave select
327 * specifies the values of A[14:12] to use with interleave enable.
329 * [31:16] DRAM Limit Address i Bits 39-24
330 * This field defines the upper address bits of a 40 bit address
331 * that define the end of the DRAM region.
333 0xC144, 0x0000f8f8, 0x003f0000,
334 0xC148, 0x0000f8f8, 0x00000001,
335 0xC154, 0x0000f8f8, 0x00000002,
336 0xC158, 0x0000f8f8, 0x00000003,
337 0xC164, 0x0000f8f8, 0x00000004,
338 0xC168, 0x0000f8f8, 0x00000005,
339 0xC174, 0x0000f8f8, 0x00000006,
340 0xC178, 0x0000f8f8, 0x00000007,
341 /* DRAM Base i Registers
350 * [ 0: 0] Read Enable
353 * [ 1: 1] Write Enable
354 * 0 = Writes Disabled
357 * [10: 8] Interleave Enable
358 * 000 = No interleave
359 * 001 = Interleave on A[12] (2 nodes)
361 * 011 = Interleave on A[12] and A[14] (4 nodes)
365 * 111 = Interleve on A[12] and A[13] and A[14] (8 nodes)
367 * [13:16] DRAM Base Address i Bits 39-24
368 * This field defines the upper address bits of a 40-bit address
369 * that define the start of the DRAM region.
371 0xC140, 0x0000f8fc, 0x00000003,
372 0xC148, 0x0000f8fc, 0x00400000,
373 0xC150, 0x0000f8fc, 0x00400000,
374 0xC158, 0x0000f8fc, 0x00400000,
375 0xC160, 0x0000f8fc, 0x00400000,
376 0xC168, 0x0000f8fc, 0x00400000,
377 0xC170, 0x0000f8fc, 0x00400000,
378 0xC178, 0x0000f8fc, 0x00400000,
380 /* Memory-Mapped I/O Limit i Registers
389 * [ 2: 0] Destination Node ID
399 * [ 5: 4] Destination Link ID
406 * 0 = CPU writes may be posted
407 * 1 = CPU writes must be non-posted
408 * [31: 8] Memory-Mapped I/O Limit Address i (39-16)
409 * This field defines the upp adddress bits of a 40-bit address that
410 * defines the end of a memory-mapped I/O region n
412 0xC184, 0x00000048, 0x00e1ff00,
413 0xC18C, 0x00000048, 0x00dfff00,
414 0xC194, 0x00000048, 0x00e3ff00,
415 0xC19C, 0x00000048, 0x00000000,
416 0xC1A4, 0x00000048, 0x00000000,
417 0xC1AC, 0x00000048, 0x00000000,
418 0xC1B4, 0x00000048, 0x00000b00,
421 /* Memory-Mapped I/O Base i Registers
430 * [ 0: 0] Read Enable
433 * [ 1: 1] Write Enable
434 * 0 = Writes disabled
436 * [ 2: 2] Cpu Disable
437 * 0 = Cpu can use this I/O range
438 * 1 = Cpu requests do not use this I/O range
440 * 0 = base/limit registers i are read/write
441 * 1 = base/limit registers i are read-only
443 * [31: 8] Memory-Mapped I/O Base Address i (39-16)
444 * This field defines the upper address bits of a 40bit address
445 * that defines the start of memory-mapped I/O region i
447 0xC1BC, 0x00000048, 0x00fe0b00,
448 0xC180, 0x000000f0, 0x00e00003,
449 0xC188, 0x000000f0, 0x00d80003,
450 0xC190, 0x000000f0, 0x00e20003,
451 0xC198, 0x000000f0, 0x00000000,
452 0xC1A0, 0x000000f0, 0x00000000,
453 0xC1A8, 0x000000f0, 0x00000000,
454 0xC1B0, 0x000000f0, 0x0000a003,
455 0xC1B8, 0x000000f0, 0x00400003,
457 /* PCI I/O Limit i Registers
462 * [ 2: 0] Destination Node ID
472 * [ 5: 4] Destination Link ID
478 * [24:12] PCI I/O Limit Address i
479 * This field defines the end of PCI I/O region n
482 0xC1C4, 0xFE000FC8, 0x0000d000,
483 0xC1CC, 0xFE000FC8, 0x000ff000,
484 0xC1D4, 0xFE000FC8, 0x00000000,
485 0xC1DC, 0xFE000FC8, 0x00000000,
487 /* PCI I/O Base i Registers
492 * [ 0: 0] Read Enable
495 * [ 1: 1] Write Enable
496 * 0 = Writes Disabled
500 * 0 = VGA matches Disabled
501 * 1 = matches all address < 64K and where A[9:0] is in the
502 * range 3B0-3BB or 3C0-3DF independen of the base & limit registers
504 * 0 = ISA matches Disabled
505 * 1 = Blocks address < 64K and in the last 768 bytes of eack 1K block
506 * from matching agains this base/limit pair
508 * [24:12] PCI I/O Base i
509 * This field defines the start of PCI I/O region n
512 0xC1C0, 0xFE000FCC, 0x0000d003,
513 0xC1C8, 0xFE000FCC, 0x00001013,
514 0xC1D0, 0xFE000FCC, 0x00000000,
515 0xC1D8, 0xFE000FCC, 0x00000000,
517 /* Config Base and Limit i Registers
522 * [ 0: 0] Read Enable
525 * [ 1: 1] Write Enable
526 * 0 = Writes Disabled
528 * [ 2: 2] Device Number Compare Enable
529 * 0 = The ranges are based on bus number
530 * 1 = The ranges are ranges of devices on bus 0
532 * [ 6: 4] Destination Node
542 * [ 9: 8] Destination Link
548 * [23:16] Bus Number Base i
549 * This field defines the lowest bus number in configuration region i
550 * [31:24] Bus Number Limit i
551 * This field defines the highest bus number in configuration regin i
553 0xC1E0, 0x0000FC88, 0xff000003,
554 0xC1E4, 0x0000FC88, 0x00000000,
555 0xC1E8, 0x0000FC88, 0x00000000,
556 0xC1EC, 0x0000FC88, 0x00000000,
558 /* DRAM CS Base Address i Registers
567 * [ 0: 0] Chip-Select Bank Enable
571 * [15: 9] Base Address (19-13)
572 * An optimization used when all DIMM are the same size...
574 * [31:21] Base Address (35-25)
575 * This field defines the top 11 addresses bit of a 40-bit
576 * address that define the memory address space. These
577 * bits decode 32-MByte blocks of memory.
579 0xC240, 0x001f01fe, 0x00000001,
580 0xC244, 0x001f01fe, 0x01000001,
581 0xC248, 0x001f01fe, 0x02000001,
582 0xC24C, 0x001f01fe, 0x03000001,
583 0xC250, 0x001f01fe, 0x00000000,
584 0xC254, 0x001f01fe, 0x00000000,
585 0xC258, 0x001f01fe, 0x00000000,
586 0xC25C, 0x001f01fe, 0x00000000,
587 /* DRAM CS Mask Address i Registers
596 * Select bits to exclude from comparison with the DRAM Base address register.
598 * [15: 9] Address Mask (19-13)
599 * Address to be excluded from the optimized case
601 * [29:21] Address Mask (33-25)
602 * The bits with an address mask of 1 are excluded from address comparison
606 0xC260, 0xC01f01ff, 0x00e0fe00,
607 0xC264, 0xC01f01ff, 0x00e0fe00,
608 0xC268, 0xC01f01ff, 0x00e0fe00,
609 0xC26C, 0xC01f01ff, 0x00e0fe00,
610 0xC270, 0xC01f01ff, 0x00000000,
611 0xC274, 0xC01f01ff, 0x00000000,
612 0xC278, 0xC01f01ff, 0x00000000,
613 0xC27C, 0xC01f01ff, 0x00000000,
614 /* DRAM Bank Address Mapping Register
616 * Specify the memory module size
621 * 000 = 32Mbyte (Rows = 12 & Col = 8)
622 * 001 = 64Mbyte (Rows = 12 & Col = 9)
623 * 010 = 128Mbyte (Rows = 13 & Col = 9)|(Rows = 12 & Col = 10)
624 * 011 = 256Mbyte (Rows = 13 & Col = 10)|(Rows = 12 & Col = 11)
625 * 100 = 512Mbyte (Rows = 13 & Col = 11)|(Rows = 14 & Col = 10)
626 * 101 = 1Gbyte (Rows = 14 & Col = 11)|(Rows = 13 & Col = 12)
627 * 110 = 2Gbyte (Rows = 14 & Col = 12)
634 0xC280, 0xffff8888, 0x00000033,
635 /* DRAM Timing Low Register
637 * [ 2: 0] Tcl (Cas# Latency, Cas# to read-data-valid)
647 * [ 7: 4] Trc (Row Cycle Time, Ras#-active to Ras#-active/bank auto refresh)
648 * 0000 = 7 bus clocks
649 * 0001 = 8 bus clocks
651 * 1110 = 21 bus clocks
652 * 1111 = 22 bus clocks
653 * [11: 8] Trfc (Row refresh Cycle time, Auto-refresh-active to RAS#-active or RAS#auto-refresh)
654 * 0000 = 9 bus clocks
655 * 0010 = 10 bus clocks
657 * 1110 = 23 bus clocks
658 * 1111 = 24 bus clocks
659 * [14:12] Trcd (Ras#-active to Case#-read/write Delay)
669 * [18:16] Trrd (Ras# to Ras# Delay)
679 * [23:20] Tras (Minmum Ras# Active Time)
680 * 0000 to 0100 = reserved
681 * 0101 = 5 bus clocks
683 * 1111 = 15 bus clocks
684 * [26:24] Trp (Row Precharge Time)
694 * [28:28] Twr (Write Recovery Time)
699 0xC288, 0xe8088008, 0x03623125,
700 /* DRAM Timing High Register
702 * [ 0: 0] Twtr (Write to Read Delay)
706 * [ 6: 4] Trwf (Read to Write Delay)
716 * [12: 8] Tref (Refresh Rate)
717 * 00000 = 100Mhz 4K rows
718 * 00001 = 133Mhz 4K rows
719 * 00010 = 166Mhz 4K rows
720 * 01000 = 100Mhz 8K/16K rows
721 * 01001 = 133Mhz 8K/16K rows
722 * 01010 = 166Mhz 8K/16K rows
724 * [22:20] Twcl (Write CAS Latency)
725 * 000 = 1 Mem clock after CAS# (Unbuffered Dimms)
726 * 001 = 2 Mem clocks after CAS# (Registered Dimms)
729 0xC28c, 0xff8fe08e, 0x00000930,
731 /* DRAM Config Low Register
733 * [ 0: 0] DLL Disable
742 * [ 3: 3] Disable DQS Hystersis (FIXME handle this one carefully)
743 * 0 = Enable DQS input filter
744 * 1 = Disable DQS input filtering
747 * 0 = Initialization done or not yet started.
748 * 1 = Initiate DRAM intialization sequence
749 * [ 9: 9] SO-Dimm Enable
751 * 1 = SO-Dimms present
753 * 0 = DRAM not enabled
754 * 1 = DRAM initialized and enabled
755 * [11:11] Memory Clear Status
756 * 0 = Memory Clear function has not completed
757 * 1 = Memory Clear function has completed
758 * [12:12] Exit Self-Refresh
759 * 0 = Exit from self-refresh done or not yet started
760 * 1 = DRAM exiting from self refresh
761 * [13:13] Self-Refresh Status
762 * 0 = Normal Operation
763 * 1 = Self-refresh mode active
764 * [15:14] Read/Write Queue Bypass Count
769 * [16:16] 128-bit/64-Bit
770 * 0 = 64bit Interface to DRAM
771 * 1 = 128bit Interface to DRAM
772 * [17:17] DIMM ECC Enable
773 * 0 = Some DIMMs do not have ECC
774 * 1 = ALL DIMMS have ECC bits
775 * [18:18] UnBuffered DIMMs
777 * 1 = Unbuffered DIMMS
778 * [19:19] Enable 32-Byte Granularity
779 * 0 = Optimize for 64byte bursts
780 * 1 = Optimize for 32byte bursts
781 * [20:20] DIMM 0 is x4
782 * [21:21] DIMM 1 is x4
783 * [22:22] DIMM 2 is x4
784 * [23:23] DIMM 3 is x4
786 * 1 = x4 DIMM present
787 * [24:24] Disable DRAM Receivers
788 * 0 = Receivers enabled
789 * 1 = Receivers disabled
791 * 000 = Arbiters chois is always respected
792 * 001 = Oldest entry in DCQ can be bypassed 1 time
793 * 010 = Oldest entry in DCQ can be bypassed 2 times
794 * 011 = Oldest entry in DCQ can be bypassed 3 times
795 * 100 = Oldest entry in DCQ can be bypassed 4 times
796 * 101 = Oldest entry in DCQ can be bypassed 5 times
797 * 110 = Oldest entry in DCQ can be bypassed 6 times
798 * 111 = Oldest entry in DCQ can be bypassed 7 times
803 (0 << 23)|(0 << 22)|(0 << 21)|(0 << 20)|
804 (1 << 19)|(1 << 18)|(0 << 17)|(0 << 16)|
805 (2 << 14)|(0 << 13)|(0 << 12)|
806 (0 << 11)|(0 << 10)|(0 << 9)|(0 << 8)|
807 (0 << 3) |(0 << 1) |(0 << 0),
808 /* DRAM Config High Register
810 * [ 0: 3] Maximum Asynchronous Latency
815 * [11: 8] Read Preamble
833 * [18:16] Idle Cycle Limit
842 * [19:19] Dynamic Idle Cycle Center Enable
843 * 0 = Use Idle Cycle Limit
844 * 1 = Generate a dynamic Idle cycle limit
845 * [22:20] DRAM MEMCLK Frequency
855 * [25:25] Memory Clock Ratio Valid (FIXME carefully enable memclk)
856 * 0 = Disable MemClks
858 * [26:26] Memory Clock 0 Enable
861 * [27:27] Memory Clock 1 Enable
864 * [28:28] Memory Clock 2 Enable
867 * [29:29] Memory Clock 3 Enable
872 0xC294, 0xc180f0f0, 0x0e2b0a05,
873 /* DRAM Delay Line Register
875 * Adjust the skew of the input DQS strobe relative to DATA
877 * [23:16] Delay Line Adjust
878 * Adjusts the DLL derived PDL delay by one or more delay stages
879 * in either the faster or slower direction.
880 * [24:24} Adjust Slower
882 * 1 = Adj is used to increase the PDL delay
883 * [25:25] Adjust Faster
885 * 1 = Adj is used to decrease the PDL delay
888 0xC298, 0xfc00ffff, 0x00000000,
889 /* DRAM Scrub Control Register
891 * [ 4: 0] DRAM Scrube Rate
893 * [12: 8] L2 Scrub Rate
895 * [20:16] Dcache Scrub
898 * 00000 = Do not scrub
920 * All Others = Reserved
922 0xC358, 0xffe0e0e0, 0x00000000,
923 /* DRAM Scrub Address Low Register
925 * [ 0: 0] DRAM Scrubber Redirect Enable
927 * 1 = Scrubber Corrects errors found in normal operation
929 * [31: 6] DRAM Scrub Address 31-6
931 0xC35C, 0x0000003e, 0x00000000,
932 /* DRAM Scrub Address High Register
934 * [ 7: 0] DRAM Scrubb Address 39-32
937 0xC360, 0xffffff00, 0x00000000,
941 print_debug("setting up northbridge registers\r\n");
942 max = sizeof(register_values)/sizeof(register_values[0]);
943 for(i = 0; i < max; i += 3) {
946 print_debug_hex32(register_values[i]);
948 print_debug_hex32(register_values[i+2]);
951 reg = pcibios_read_config_dword(
952 0, register_values[i] >> 8, register_values[i] & 0xff);
953 reg &= register_values[i+1];
954 reg |= register_values[i+2] & ~register_values[i+1];
955 pcibios_write_config_dword(
956 0, register_values[i] >> 8, register_values[i] & 0xff, reg);
958 print_debug("setting up northbridge registers done. hurray!\r\n");
961 #define PCI_DEVFN(slot,func) ((((slot) & 0x1f) << 3) | ((func) & 0x07))
963 #define DRAM_CONFIG_LOW 0x90
964 #define DCL_DLL_Disable (1<<0)
965 #define DCL_D_DRV (1<<1)
966 #define DCL_QFC_EN (1<<2)
967 #define DCL_DisDqsHys (1<<3)
968 #define DCL_DramInit (1<<8)
969 #define DCL_DramEnable (1<<10)
970 #define DCL_MemClrStatus (1<<11)
971 #define DCL_DimmEcEn (1<<17)
973 static void sdram_set_spd_registers(void)
976 dcl = pcibios_read_config_dword(0, PCI_DEVFN(0x18,2), DRAM_CONFIG_LOW);
977 /* Until I know what is going on disable ECC support */
978 dcl &= ~DCL_DimmEcEn;
979 pcibios_write_config_dword(0, PCI_DEVFN(0x18,2), DRAM_CONFIG_LOW, dcl);
982 #define TIMEOUT_LOOPS 300000
983 static void sdram_enable(void)
987 /* Toggle DisDqsHys to get it working */
988 dcl = pcibios_read_config_dword(0, PCI_DEVFN(0x18,2), DRAM_CONFIG_LOW);
989 print_debug("dcl: ");
990 print_debug_hex32(dcl);
992 dcl |= DCL_DisDqsHys;
993 pcibios_write_config_dword(0, PCI_DEVFN(0x18, 2), DRAM_CONFIG_LOW, dcl);
994 dcl &= ~DCL_DisDqsHys;
995 dcl &= ~DCL_DLL_Disable;
999 pcibios_write_config_dword(0, PCI_DEVFN(0x18, 2), DRAM_CONFIG_LOW, dcl);
1001 print_debug("Initializing memory: ");
1004 dcl = pcibios_read_config_dword(0, PCI_DEVFN(0x18, 2), DRAM_CONFIG_LOW);
1006 if ((loops & 1023) == 0) {
1008 print_debug_hex32(loops);
1010 } while(((dcl & DCL_DramInit) != 0) && (loops < TIMEOUT_LOOPS));
1011 if (loops >= TIMEOUT_LOOPS) {
1012 print_debug(" failed\r\n");
1014 print_debug(" done\r\n");
1018 print_debug("Clearing memory: ");
1021 dcl = pcibios_read_config_dword(0, PCI_DEVFN(0x18, 2), DRAM_CONFIG_LOW);
1023 if ((loops & 1023) == 0) {
1025 print_debug_hex32(loops);
1027 } while(((dcl & DCL_MemClrStatus) == 0) && (loops < TIMEOUT_LOOPS));
1028 if (loops >= TIMEOUT_LOOPS) {
1029 print_debug("failed\r\n");
1031 print_debug("done\r\n");
1036 static void sdram_first_normal_reference(void) {}
1037 static void sdram_enable_refresh(void) {}
1038 static void sdram_special_finishup(void) {}
1040 static int sdram_enabled(void)
1044 dcl = pcibios_read_config_dword(0, PCI_DEVFN(0x18, 2), DRAM_CONFIG_LOW);
1045 enabled = !!(dcl & DCL_DramEnable);
1047 print_debug("DRAM already enabled.");
1053 #include "sdram/generic_sdram.c"
1055 static void main(void)
1059 if (!sdram_enabled()) {
1062 ram_fill( 0x00100000, 0x00180000);
1063 ram_verify(0x00100000, 0x00180000);
1066 ram_fill( 0x00000000, 0x00001000);
1067 ram_verify(0x00000000, 0x00001000);