1 #include <cpu/k8/mtrr.h>
2 #define MEMORY_SUSE_SOLO 1 /* SuSE Solo configuration */
3 #define MEMORY_LNXI_SOLO 2 /* LNXI Solo configuration */
4 #define MEMORY_LNXI_HDAMA 3 /* LNXI HDAMA configuration */
8 #define MEMORY_CONFIG MEMORY_SUSE_SOLO
11 static void setup_resource_map(const unsigned int *register_values, int max)
14 print_debug("setting up resource map....\r\n");
15 for(i = 0; i < max; i += 3) {
20 print_debug_hex32(register_values[i]);
22 print_debug_hex32(register_values[i+2]);
25 dev = register_values[i] & ~0xff;
26 where = register_values[i] & 0xff;
27 reg = pci_read_config32(dev, where);
28 reg &= register_values[i+1];
29 reg |= register_values[i+2];
30 pci_write_config32(dev, where, reg);
32 reg = pci_read_config32(register_values[i]);
33 reg &= register_values[i+1];
34 reg |= register_values[i+2] & ~register_values[i+1];
35 pci_write_config32(register_values[i], reg);
38 print_debug("done.\r\n");
41 static void setup_default_resource_map(void)
43 static const unsigned int register_values[] = {
44 /* Careful set limit registers before base registers which contain the enables */
45 /* DRAM Limit i Registers
54 * [ 2: 0] Destination Node ID
64 * [10: 8] Interleave select
65 * specifies the values of A[14:12] to use with interleave enable.
67 * [31:16] DRAM Limit Address i Bits 39-24
68 * This field defines the upper address bits of a 40 bit address
69 * that define the end of the DRAM region.
71 PCI_ADDR(0, 0x18, 1, 0x44), 0x0000f8f8, 0x00000000,
72 PCI_ADDR(0, 0x18, 1, 0x4C), 0x0000f8f8, 0x00000001,
73 PCI_ADDR(0, 0x18, 1, 0x54), 0x0000f8f8, 0x00000002,
74 PCI_ADDR(0, 0x18, 1, 0x5C), 0x0000f8f8, 0x00000003,
75 PCI_ADDR(0, 0x18, 1, 0x64), 0x0000f8f8, 0x00000004,
76 PCI_ADDR(0, 0x18, 1, 0x6C), 0x0000f8f8, 0x00000005,
77 PCI_ADDR(0, 0x18, 1, 0x74), 0x0000f8f8, 0x00000006,
78 PCI_ADDR(0, 0x18, 1, 0x7C), 0x0000f8f8, 0x00000007,
79 /* DRAM Base i Registers
91 * [ 1: 1] Write Enable
95 * [10: 8] Interleave Enable
97 * 001 = Interleave on A[12] (2 nodes)
99 * 011 = Interleave on A[12] and A[14] (4 nodes)
103 * 111 = Interleve on A[12] and A[13] and A[14] (8 nodes)
105 * [13:16] DRAM Base Address i Bits 39-24
106 * This field defines the upper address bits of a 40-bit address
107 * that define the start of the DRAM region.
109 PCI_ADDR(0, 0x18, 1, 0x40), 0x0000f8fc, 0x00000000,
110 PCI_ADDR(0, 0x18, 1, 0x48), 0x0000f8fc, 0x00000000,
111 PCI_ADDR(0, 0x18, 1, 0x50), 0x0000f8fc, 0x00000000,
112 PCI_ADDR(0, 0x18, 1, 0x58), 0x0000f8fc, 0x00000000,
113 PCI_ADDR(0, 0x18, 1, 0x60), 0x0000f8fc, 0x00000000,
114 PCI_ADDR(0, 0x18, 1, 0x68), 0x0000f8fc, 0x00000000,
115 PCI_ADDR(0, 0x18, 1, 0x70), 0x0000f8fc, 0x00000000,
116 PCI_ADDR(0, 0x18, 1, 0x78), 0x0000f8fc, 0x00000000,
118 /* Memory-Mapped I/O Limit i Registers
127 * [ 2: 0] Destination Node ID
137 * [ 5: 4] Destination Link ID
144 * 0 = CPU writes may be posted
145 * 1 = CPU writes must be non-posted
146 * [31: 8] Memory-Mapped I/O Limit Address i (39-16)
147 * This field defines the upp adddress bits of a 40-bit address that
148 * defines the end of a memory-mapped I/O region n
150 PCI_ADDR(0, 0x18, 1, 0x84), 0x00000048, 0x00000000,
151 PCI_ADDR(0, 0x18, 1, 0x8C), 0x00000048, 0x00000000,
152 PCI_ADDR(0, 0x18, 1, 0x94), 0x00000048, 0x00000000,
153 PCI_ADDR(0, 0x18, 1, 0x9C), 0x00000048, 0x00000000,
154 PCI_ADDR(0, 0x18, 1, 0xA4), 0x00000048, 0x00000000,
155 PCI_ADDR(0, 0x18, 1, 0xAC), 0x00000048, 0x00000000,
156 PCI_ADDR(0, 0x18, 1, 0xB4), 0x00000048, 0x00000000,
157 PCI_ADDR(0, 0x18, 1, 0xBC), 0x00000048, 0x00000000,
159 /* Memory-Mapped I/O Base i Registers
168 * [ 0: 0] Read Enable
171 * [ 1: 1] Write Enable
172 * 0 = Writes disabled
174 * [ 2: 2] Cpu Disable
175 * 0 = Cpu can use this I/O range
176 * 1 = Cpu requests do not use this I/O range
178 * 0 = base/limit registers i are read/write
179 * 1 = base/limit registers i are read-only
181 * [31: 8] Memory-Mapped I/O Base Address i (39-16)
182 * This field defines the upper address bits of a 40bit address
183 * that defines the start of memory-mapped I/O region i
185 PCI_ADDR(0, 0x18, 1, 0x80), 0x000000f0, 0x00000000,
186 PCI_ADDR(0, 0x18, 1, 0x88), 0x000000f0, 0x00000000,
187 PCI_ADDR(0, 0x18, 1, 0x90), 0x000000f0, 0x00000000,
188 PCI_ADDR(0, 0x18, 1, 0x98), 0x000000f0, 0x00000000,
189 PCI_ADDR(0, 0x18, 1, 0xA0), 0x000000f0, 0x00000000,
190 PCI_ADDR(0, 0x18, 1, 0xA8), 0x000000f0, 0x00000000,
191 PCI_ADDR(0, 0x18, 1, 0xB0), 0x000000f0, 0x00000000,
192 PCI_ADDR(0, 0x18, 1, 0xB8), 0x000000f0, 0x00000000,
194 /* PCI I/O Limit i Registers
199 * [ 2: 0] Destination Node ID
209 * [ 5: 4] Destination Link ID
215 * [24:12] PCI I/O Limit Address i
216 * This field defines the end of PCI I/O region n
219 PCI_ADDR(0, 0x18, 1, 0xC4), 0xFE000FC8, 0x01fff000,
220 PCI_ADDR(0, 0x18, 1, 0xCC), 0xFE000FC8, 0x00000000,
221 PCI_ADDR(0, 0x18, 1, 0xD4), 0xFE000FC8, 0x00000000,
222 PCI_ADDR(0, 0x18, 1, 0xDC), 0xFE000FC8, 0x00000000,
224 /* PCI I/O Base i Registers
229 * [ 0: 0] Read Enable
232 * [ 1: 1] Write Enable
233 * 0 = Writes Disabled
237 * 0 = VGA matches Disabled
238 * 1 = matches all address < 64K and where A[9:0] is in the
239 * range 3B0-3BB or 3C0-3DF independen of the base & limit registers
241 * 0 = ISA matches Disabled
242 * 1 = Blocks address < 64K and in the last 768 bytes of eack 1K block
243 * from matching agains this base/limit pair
245 * [24:12] PCI I/O Base i
246 * This field defines the start of PCI I/O region n
249 PCI_ADDR(0, 0x18, 1, 0xC0), 0xFE000FCC, 0x00000003,
250 PCI_ADDR(0, 0x18, 1, 0xC8), 0xFE000FCC, 0x00000000,
251 PCI_ADDR(0, 0x18, 1, 0xD0), 0xFE000FCC, 0x00000000,
252 PCI_ADDR(0, 0x18, 1, 0xD8), 0xFE000FCC, 0x00000000,
254 /* Config Base and Limit i Registers
259 * [ 0: 0] Read Enable
262 * [ 1: 1] Write Enable
263 * 0 = Writes Disabled
265 * [ 2: 2] Device Number Compare Enable
266 * 0 = The ranges are based on bus number
267 * 1 = The ranges are ranges of devices on bus 0
269 * [ 6: 4] Destination Node
279 * [ 9: 8] Destination Link
285 * [23:16] Bus Number Base i
286 * This field defines the lowest bus number in configuration region i
287 * [31:24] Bus Number Limit i
288 * This field defines the highest bus number in configuration regin i
290 PCI_ADDR(0, 0x18, 1, 0xE0), 0x0000FC88, 0xff000003,
291 PCI_ADDR(0, 0x18, 1, 0xE4), 0x0000FC88, 0x00000000,
292 PCI_ADDR(0, 0x18, 1, 0xE8), 0x0000FC88, 0x00000000,
293 PCI_ADDR(0, 0x18, 1, 0xEC), 0x0000FC88, 0x00000000,
296 max = sizeof(register_values)/sizeof(register_values[0]);
297 setup_resource_map(register_values, max);
300 static void sdram_set_registers(void)
302 static const unsigned int register_values[] = {
304 /* Careful set limit registers before base registers which contain the enables */
305 /* DRAM Limit i Registers
314 * [ 2: 0] Destination Node ID
324 * [10: 8] Interleave select
325 * specifies the values of A[14:12] to use with interleave enable.
327 * [31:16] DRAM Limit Address i Bits 39-24
328 * This field defines the upper address bits of a 40 bit address
329 * that define the end of the DRAM region.
331 #if MEMORY_CONFIG == MEMORY_LNXI_SOLO
332 PCI_ADDR(0, 0x18, 1, 0x44), 0x0000f8f8, 0x003f0000,
333 PCI_ADDR(0, 0x18, 1, 0x4C), 0x0000f8f8, 0x00000001,
335 #if MEMORY_CONFIG == MEMORY_SUSE_SOLO
336 PCI_ADDR(0, 0x18, 1, 0x44), 0x0000f8f8, 0x001f0000,
337 PCI_ADDR(0, 0x18, 1, 0x4C), 0x0000f8f8, 0x00000001,
339 #if MEMORY_CONFIG == MEMORY_LNXI_HDAMA
340 PCI_ADDR(0, 0x18, 1, 0x44), 0x0000f8f8, 0x003f0000,
341 PCI_ADDR(0, 0x18, 1, 0x4C), 0x0000f8f8, 0x007f0001,
343 PCI_ADDR(0, 0x18, 1, 0x54), 0x0000f8f8, 0x00000002,
344 PCI_ADDR(0, 0x18, 1, 0x5C), 0x0000f8f8, 0x00000003,
345 PCI_ADDR(0, 0x18, 1, 0x64), 0x0000f8f8, 0x00000004,
346 PCI_ADDR(0, 0x18, 1, 0x6C), 0x0000f8f8, 0x00000005,
347 PCI_ADDR(0, 0x18, 1, 0x74), 0x0000f8f8, 0x00000006,
348 PCI_ADDR(0, 0x18, 1, 0x7C), 0x0000f8f8, 0x00000007,
349 /* DRAM Base i Registers
358 * [ 0: 0] Read Enable
361 * [ 1: 1] Write Enable
362 * 0 = Writes Disabled
365 * [10: 8] Interleave Enable
366 * 000 = No interleave
367 * 001 = Interleave on A[12] (2 nodes)
369 * 011 = Interleave on A[12] and A[14] (4 nodes)
373 * 111 = Interleve on A[12] and A[13] and A[14] (8 nodes)
375 * [13:16] DRAM Base Address i Bits 39-24
376 * This field defines the upper address bits of a 40-bit address
377 * that define the start of the DRAM region.
379 PCI_ADDR(0, 0x18, 1, 0x40), 0x0000f8fc, 0x00000003,
380 #if MEMORY_CONFIG == MEMORY_LNXI_SOLO
381 PCI_ADDR(0, 0x18, 1, 0x48), 0x0000f8fc, 0x00400000,
382 PCI_ADDR(0, 0x18, 1, 0x50), 0x0000f8fc, 0x00400000,
383 PCI_ADDR(0, 0x18, 1, 0x58), 0x0000f8fc, 0x00400000,
384 PCI_ADDR(0, 0x18, 1, 0x60), 0x0000f8fc, 0x00400000,
385 PCI_ADDR(0, 0x18, 1, 0x68), 0x0000f8fc, 0x00400000,
386 PCI_ADDR(0, 0x18, 1, 0x70), 0x0000f8fc, 0x00400000,
387 PCI_ADDR(0, 0x18, 1, 0x78), 0x0000f8fc, 0x00400000,
389 #if MEMORY_CONFIG == MEMORY_SUSE_SOLO
390 PCI_ADDR(0, 0x18, 1, 0x48), 0x0000f8fc, 0x00200000,
391 PCI_ADDR(0, 0x18, 1, 0x50), 0x0000f8fc, 0x00200000,
392 PCI_ADDR(0, 0x18, 1, 0x58), 0x0000f8fc, 0x00200000,
393 PCI_ADDR(0, 0x18, 1, 0x60), 0x0000f8fc, 0x00200000,
394 PCI_ADDR(0, 0x18, 1, 0x68), 0x0000f8fc, 0x00200000,
395 PCI_ADDR(0, 0x18, 1, 0x70), 0x0000f8fc, 0x00200000,
396 PCI_ADDR(0, 0x18, 1, 0x78), 0x0000f8fc, 0x00200000,
398 #if MEMORY_CONFIG == MEMORY_LNXI_HDAMA
399 PCI_ADDR(0, 0x18, 1, 0x48), 0x0000f8fc, 0x00400003,
400 PCI_ADDR(0, 0x18, 1, 0x50), 0x0000f8fc, 0x00800000,
401 PCI_ADDR(0, 0x18, 1, 0x58), 0x0000f8fc, 0x00800000,
402 PCI_ADDR(0, 0x18, 1, 0x60), 0x0000f8fc, 0x00800000,
403 PCI_ADDR(0, 0x18, 1, 0x68), 0x0000f8fc, 0x00800000,
404 PCI_ADDR(0, 0x18, 1, 0x70), 0x0000f8fc, 0x00800000,
405 PCI_ADDR(0, 0x18, 1, 0x78), 0x0000f8fc, 0x00800000,
406 PCI_ADDR(0, 0x18, 1, 0x78), 0x0000f8fc, 0x00800000,
409 /* Memory-Mapped I/O Limit i Registers
418 * [ 2: 0] Destination Node ID
428 * [ 5: 4] Destination Link ID
435 * 0 = CPU writes may be posted
436 * 1 = CPU writes must be non-posted
437 * [31: 8] Memory-Mapped I/O Limit Address i (39-16)
438 * This field defines the upp adddress bits of a 40-bit address that
439 * defines the end of a memory-mapped I/O region n
441 #if (MEMORY_CONFIG == MEMORY_LNXI_SOLO) || (MEMORY_CONFIG == MEMORY_SUSE_SOLO)
442 PCI_ADDR(0, 0x18, 1, 0x84), 0x00000048, 0x00e1ff00,
443 PCI_ADDR(0, 0x18, 1, 0x8C), 0x00000048, 0x00dfff00,
444 PCI_ADDR(0, 0x18, 1, 0x94), 0x00000048, 0x00e3ff00,
445 PCI_ADDR(0, 0x18, 1, 0x9C), 0x00000048, 0x00000000,
446 PCI_ADDR(0, 0x18, 1, 0xA4), 0x00000048, 0x00000000,
447 PCI_ADDR(0, 0x18, 1, 0xAC), 0x00000048, 0x00000000,
448 PCI_ADDR(0, 0x18, 1, 0xB4), 0x00000048, 0x00000b00,
449 PCI_ADDR(0, 0x18, 1, 0xBC), 0x00000048, 0x00fe0b00,
451 #if MEMORY_CONFIG == MEMORY_LNXI_HDAMA
452 PCI_ADDR(0, 0x18, 1, 0x84), 0x00000048, 0x00fe2f00,
453 PCI_ADDR(0, 0x18, 1, 0x8C), 0x00000048, 0x00000000,
454 PCI_ADDR(0, 0x18, 1, 0x94), 0x00000048, 0x00000000,
455 PCI_ADDR(0, 0x18, 1, 0x9C), 0x00000048, 0x00000000,
456 PCI_ADDR(0, 0x18, 1, 0xA4), 0x00000048, 0x00fec000,
457 PCI_ADDR(0, 0x18, 1, 0xAC), 0x00000048, 0x0000b000,
458 PCI_ADDR(0, 0x18, 1, 0xB4), 0x00000048, 0x00000000,
459 PCI_ADDR(0, 0x18, 1, 0xBC), 0x00000048, 0x00000000,
462 /* Memory-Mapped I/O Base i Registers
471 * [ 0: 0] Read Enable
474 * [ 1: 1] Write Enable
475 * 0 = Writes disabled
477 * [ 2: 2] Cpu Disable
478 * 0 = Cpu can use this I/O range
479 * 1 = Cpu requests do not use this I/O range
481 * 0 = base/limit registers i are read/write
482 * 1 = base/limit registers i are read-only
484 * [31: 8] Memory-Mapped I/O Base Address i (39-16)
485 * This field defines the upper address bits of a 40bit address
486 * that defines the start of memory-mapped I/O region i
488 #if (MEMORY_CONFIG == MEMORY_LNXI_SOLO) || (MEMORY_CONFIG == MEMORY_SUSE_SOLO)
489 PCI_ADDR(0, 0x18, 1, 0x80), 0x000000f0, 0x00e00003,
490 PCI_ADDR(0, 0x18, 1, 0x88), 0x000000f0, 0x00d80003,
491 PCI_ADDR(0, 0x18, 1, 0x90), 0x000000f0, 0x00e20003,
492 PCI_ADDR(0, 0x18, 1, 0x98), 0x000000f0, 0x00000000,
493 PCI_ADDR(0, 0x18, 1, 0xA0), 0x000000f0, 0x00000000,
494 PCI_ADDR(0, 0x18, 1, 0xA8), 0x000000f0, 0x00000000,
495 PCI_ADDR(0, 0x18, 1, 0xB0), 0x000000f0, 0x00000a03,
497 #if MEMORY_CONFIG == MEMORY_LNXI_SOLO
498 PCI_ADDR(0, 0x18, 1, 0xB8), 0x000000f0, 0x00400003,
500 #if MEMORY_CONFIG == MEMORY_SUSE_SOLO
501 PCI_ADDR(0, 0x18, 1, 0xB8), 0x000000f0, 0x00200003,
503 #if MEMORY_CONFIG == MEMORY_LNXI_HDAMA
504 PCI_ADDR(0, 0x18, 1, 0x80), 0x000000f0, 0x00fc0003,
505 PCI_ADDR(0, 0x18, 1, 0x88), 0x000000f0, 0x00000000,
506 PCI_ADDR(0, 0x18, 1, 0x90), 0x000000f0, 0x00000000,
507 PCI_ADDR(0, 0x18, 1, 0x98), 0x000000f0, 0x00000000,
508 PCI_ADDR(0, 0x18, 1, 0xA0), 0x000000f0, 0x00fec00e,
509 PCI_ADDR(0, 0x18, 1, 0xA8), 0x000000f0, 0x00000a03,
510 PCI_ADDR(0, 0x18, 1, 0xB0), 0x000000f0, 0x00000000,
511 PCI_ADDR(0, 0x18, 1, 0xB8), 0x000000f0, 0x00000000,
514 /* PCI I/O Limit i Registers
519 * [ 2: 0] Destination Node ID
529 * [ 5: 4] Destination Link ID
535 * [24:12] PCI I/O Limit Address i
536 * This field defines the end of PCI I/O region n
539 #if (MEMORY_CONFIG == MEMORY_LNXI_SOLO) || (MEMORY_CONFIG == MEMORY_SUSE_SOLO)
540 PCI_ADDR(0, 0x18, 1, 0xC4), 0xFE000FC8, 0x0000d000,
541 PCI_ADDR(0, 0x18, 1, 0xCC), 0xFE000FC8, 0x000ff000,
542 PCI_ADDR(0, 0x18, 1, 0xD4), 0xFE000FC8, 0x00000000,
543 PCI_ADDR(0, 0x18, 1, 0xDC), 0xFE000FC8, 0x00000000,
545 #if MEMORY_CONFIG == MEMORY_LNXI_HDAMA
546 PCI_ADDR(0, 0x18, 1, 0xC4), 0xFE000FC8, 0x01fff000,
547 PCI_ADDR(0, 0x18, 1, 0xCC), 0xFE000FC8, 0x00000000,
548 PCI_ADDR(0, 0x18, 1, 0xD4), 0xFE000FC8, 0x00000000,
549 PCI_ADDR(0, 0x18, 1, 0xDC), 0xFE000FC8, 0x00000000,
552 /* PCI I/O Base i Registers
557 * [ 0: 0] Read Enable
560 * [ 1: 1] Write Enable
561 * 0 = Writes Disabled
565 * 0 = VGA matches Disabled
566 * 1 = matches all address < 64K and where A[9:0] is in the
567 * range 3B0-3BB or 3C0-3DF independen of the base & limit registers
569 * 0 = ISA matches Disabled
570 * 1 = Blocks address < 64K and in the last 768 bytes of eack 1K block
571 * from matching agains this base/limit pair
573 * [24:12] PCI I/O Base i
574 * This field defines the start of PCI I/O region n
577 #if (MEMORY_CONFIG == MEMORY_LNXI_SOLO) || (MEMORY_CONFIG == MEMORY_SUSE_SOLO)
578 PCI_ADDR(0, 0x18, 1, 0xC0), 0xFE000FCC, 0x0000d003,
579 PCI_ADDR(0, 0x18, 1, 0xC8), 0xFE000FCC, 0x00001013,
580 PCI_ADDR(0, 0x18, 1, 0xD0), 0xFE000FCC, 0x00000000,
581 PCI_ADDR(0, 0x18, 1, 0xD8), 0xFE000FCC, 0x00000000,
583 #if MEMORY_CONFIG == MEMORY_LNXI_HDAMA
584 PCI_ADDR(0, 0x18, 1, 0xC0), 0xFE000FCC, 0x00000033,
585 PCI_ADDR(0, 0x18, 1, 0xC8), 0xFE000FCC, 0x00000000,
586 PCI_ADDR(0, 0x18, 1, 0xD0), 0xFE000FCC, 0x00000000,
587 PCI_ADDR(0, 0x18, 1, 0xD8), 0xFE000FCC, 0x00000000,
590 /* Config Base and Limit i Registers
595 * [ 0: 0] Read Enable
598 * [ 1: 1] Write Enable
599 * 0 = Writes Disabled
601 * [ 2: 2] Device Number Compare Enable
602 * 0 = The ranges are based on bus number
603 * 1 = The ranges are ranges of devices on bus 0
605 * [ 6: 4] Destination Node
615 * [ 9: 8] Destination Link
621 * [23:16] Bus Number Base i
622 * This field defines the lowest bus number in configuration region i
623 * [31:24] Bus Number Limit i
624 * This field defines the highest bus number in configuration regin i
626 #if (MEMORY_CONFIG == MEMORY_LNXI_SOLO) || (MEMORY_CONFIG == MEMORY_SUSE_SOLO)
627 PCI_ADDR(0, 0x18, 1, 0xE0), 0x0000FC88, 0xff000003,
628 PCI_ADDR(0, 0x18, 1, 0xE4), 0x0000FC88, 0x00000000,
629 PCI_ADDR(0, 0x18, 1, 0xE8), 0x0000FC88, 0x00000000,
630 PCI_ADDR(0, 0x18, 1, 0xEC), 0x0000FC88, 0x00000000,
632 #if MEMORY_CONFIG == MEMORY_LNXI_HDAMA
633 PCI_ADDR(0, 0x18, 1, 0xE0), 0x0000FC88, 0xff000003,
634 PCI_ADDR(0, 0x18, 1, 0xE4), 0x0000FC88, 0x00000000,
635 PCI_ADDR(0, 0x18, 1, 0xE8), 0x0000FC88, 0x00000000,
636 PCI_ADDR(0, 0x18, 1, 0xEC), 0x0000FC88, 0x00000000,
639 /* DRAM CS Base Address i Registers
648 * [ 0: 0] Chip-Select Bank Enable
652 * [15: 9] Base Address (19-13)
653 * An optimization used when all DIMM are the same size...
655 * [31:21] Base Address (35-25)
656 * This field defines the top 11 addresses bit of a 40-bit
657 * address that define the memory address space. These
658 * bits decode 32-MByte blocks of memory.
660 PCI_ADDR(0, 0x18, 2, 0x40), 0x001f01fe, 0x00000001,
661 #if MEMORY_CONFIG == MEMORY_LNXI_SOLO
662 PCI_ADDR(0, 0x18, 2, 0x44), 0x001f01fe, 0x01000001,
663 PCI_ADDR(0, 0x18, 2, 0x48), 0x001f01fe, 0x02000001,
664 PCI_ADDR(0, 0x18, 2, 0x4C), 0x001f01fe, 0x03000001,
666 #if MEMORY_CONFIG == MEMORY_SUSE_SOLO
667 PCI_ADDR(0, 0x18, 2, 0x44), 0x001f01fe, 0x00800001,
668 PCI_ADDR(0, 0x18, 2, 0x48), 0x001f01fe, 0x01000001,
669 PCI_ADDR(0, 0x18, 2, 0x4C), 0x001f01fe, 0x01800001,
671 #if MEMORY_CONFIG == MEMORY_LNXI_HDAMA
672 PCI_ADDR(0, 0x18, 2, 0x44), 0x001f01fe, 0x00001001,
673 PCI_ADDR(0, 0x18, 2, 0x48), 0x001f01fe, 0x00000000,
674 PCI_ADDR(0, 0x18, 2, 0x4C), 0x001f01fe, 0x00000000,
676 PCI_ADDR(0, 0x18, 2, 0x50), 0x001f01fe, 0x00000000,
677 PCI_ADDR(0, 0x18, 2, 0x54), 0x001f01fe, 0x00000000,
678 PCI_ADDR(0, 0x18, 2, 0x58), 0x001f01fe, 0x00000000,
679 PCI_ADDR(0, 0x18, 2, 0x5C), 0x001f01fe, 0x00000000,
680 /* DRAM CS Mask Address i Registers
689 * Select bits to exclude from comparison with the DRAM Base address register.
691 * [15: 9] Address Mask (19-13)
692 * Address to be excluded from the optimized case
694 * [29:21] Address Mask (33-25)
695 * The bits with an address mask of 1 are excluded from address comparison
699 #if MEMORY_CONFIG == MEMORY_LNXI_SOLO
700 PCI_ADDR(0, 0x18, 2, 0x60), 0xC01f01ff, 0x00e0fe00,
701 PCI_ADDR(0, 0x18, 2, 0x64), 0xC01f01ff, 0x00e0fe00,
702 PCI_ADDR(0, 0x18, 2, 0x68), 0xC01f01ff, 0x00e0fe00,
703 PCI_ADDR(0, 0x18, 2, 0x6C), 0xC01f01ff, 0x00e0fe00,
705 #if MEMORY_CONFIG == MEMORY_SUSE_SOLO
706 PCI_ADDR(0, 0x18, 2, 0x60), 0xC01f01ff, 0x0060fe00,
707 PCI_ADDR(0, 0x18, 2, 0x64), 0xC01f01ff, 0x0060fe00,
708 PCI_ADDR(0, 0x18, 2, 0x68), 0xC01f01ff, 0x0060fe00,
709 PCI_ADDR(0, 0x18, 2, 0x6C), 0xC01f01ff, 0x0060fe00,
711 #if MEMORY_CONFIG == MEMORY_LNXI_HDAMA
712 PCI_ADDR(0, 0x18, 2, 0x60), 0xC01f01ff, 0x03e0ee00,
713 PCI_ADDR(0, 0x18, 2, 0x64), 0xC01f01ff, 0x03e0ee00,
714 PCI_ADDR(0, 0x18, 2, 0x68), 0xC01f01ff, 0x00000000,
715 PCI_ADDR(0, 0x18, 2, 0x6C), 0xC01f01ff, 0x00000000,
717 PCI_ADDR(0, 0x18, 2, 0x70), 0xC01f01ff, 0x00000000,
718 PCI_ADDR(0, 0x18, 2, 0x74), 0xC01f01ff, 0x00000000,
719 PCI_ADDR(0, 0x18, 2, 0x78), 0xC01f01ff, 0x00000000,
720 PCI_ADDR(0, 0x18, 2, 0x7C), 0xC01f01ff, 0x00000000,
721 /* DRAM Bank Address Mapping Register
723 * Specify the memory module size
728 * 000 = 32Mbyte (Rows = 12 & Col = 8)
729 * 001 = 64Mbyte (Rows = 12 & Col = 9)
730 * 010 = 128Mbyte (Rows = 13 & Col = 9)|(Rows = 12 & Col = 10)
731 * 011 = 256Mbyte (Rows = 13 & Col = 10)|(Rows = 12 & Col = 11)
732 * 100 = 512Mbyte (Rows = 13 & Col = 11)|(Rows = 14 & Col = 10)
733 * 101 = 1Gbyte (Rows = 14 & Col = 11)|(Rows = 13 & Col = 12)
734 * 110 = 2Gbyte (Rows = 14 & Col = 12)
741 #if MEMORY_CONFIG == MEMORY_LNXI_SOLO
742 PCI_ADDR(0, 0x18, 2, 0x80), 0xffff8888, 0x00000033,
744 #if MEMORY_CONFIG == MEMORY_SUSE_SOLO
745 PCI_ADDR(0, 0x18, 2, 0x80), 0xffff8888, 0x00000022,
747 #if MEMORY_CONFIG == MEMORY_LNXI_HDAMA
748 PCI_ADDR(0, 0x18, 2, 0x80), 0xffff8888, 0x00000003,
750 /* DRAM Timing Low Register
752 * [ 2: 0] Tcl (Cas# Latency, Cas# to read-data-valid)
762 * [ 7: 4] Trc (Row Cycle Time, Ras#-active to Ras#-active/bank auto refresh)
763 * 0000 = 7 bus clocks
764 * 0001 = 8 bus clocks
766 * 1110 = 21 bus clocks
767 * 1111 = 22 bus clocks
768 * [11: 8] Trfc (Row refresh Cycle time, Auto-refresh-active to RAS#-active or RAS#auto-refresh)
769 * 0000 = 9 bus clocks
770 * 0010 = 10 bus clocks
772 * 1110 = 23 bus clocks
773 * 1111 = 24 bus clocks
774 * [14:12] Trcd (Ras#-active to Case#-read/write Delay)
784 * [18:16] Trrd (Ras# to Ras# Delay)
794 * [23:20] Tras (Minmum Ras# Active Time)
795 * 0000 to 0100 = reserved
796 * 0101 = 5 bus clocks
798 * 1111 = 15 bus clocks
799 * [26:24] Trp (Row Precharge Time)
809 * [28:28] Twr (Write Recovery Time)
814 #if (MEMORY_CONFIG == MEMORY_LNXI_SOLO) || (MEMORY_CONFIG == MEMORY_SUSE_SOLO)
815 PCI_ADDR(0, 0x18, 2, 0x88), 0xe8088008, 0x03623125,
817 #if MEMORY_CONFIG == MEMORY_LNXI_HDAMA
818 PCI_ADDR(0, 0x18, 2, 0x88), 0xe8088008, 0x13723335,
820 /* DRAM Timing High Register
822 * [ 0: 0] Twtr (Write to Read Delay)
826 * [ 6: 4] Trwf (Read to Write Delay)
836 * [12: 8] Tref (Refresh Rate)
837 * 00000 = 100Mhz 4K rows
838 * 00001 = 133Mhz 4K rows
839 * 00010 = 166Mhz 4K rows
840 * 01000 = 100Mhz 8K/16K rows
841 * 01001 = 133Mhz 8K/16K rows
842 * 01010 = 166Mhz 8K/16K rows
844 * [22:20] Twcl (Write CAS Latency)
845 * 000 = 1 Mem clock after CAS# (Unbuffered Dimms)
846 * 001 = 2 Mem clocks after CAS# (Registered Dimms)
849 #if MEMORY_CONFIG == MEMORY_LNXI_SOLO
850 PCI_ADDR(0, 0x18, 2, 0x8c), 0xff8fe08e, 0x00000930,
852 #if MEMORY_CONFIG == MEMORY_SUSE_SOLO
853 PCI_ADDR(0, 0x18, 2, 0x8c), 0xff8fe08e, 0x00000130,
855 #if MEMORY_CONFIG == MEMORY_LNXI_HDAMA
856 PCI_ADDR(0, 0x18, 2, 0x8c), 0xff8fe08e, 0x00100a20,
858 /* DRAM Config Low Register
860 * [ 0: 0] DLL Disable
869 * [ 3: 3] Disable DQS Hystersis (FIXME handle this one carefully)
870 * 0 = Enable DQS input filter
871 * 1 = Disable DQS input filtering
874 * 0 = Initialization done or not yet started.
875 * 1 = Initiate DRAM intialization sequence
876 * [ 9: 9] SO-Dimm Enable
878 * 1 = SO-Dimms present
880 * 0 = DRAM not enabled
881 * 1 = DRAM initialized and enabled
882 * [11:11] Memory Clear Status
883 * 0 = Memory Clear function has not completed
884 * 1 = Memory Clear function has completed
885 * [12:12] Exit Self-Refresh
886 * 0 = Exit from self-refresh done or not yet started
887 * 1 = DRAM exiting from self refresh
888 * [13:13] Self-Refresh Status
889 * 0 = Normal Operation
890 * 1 = Self-refresh mode active
891 * [15:14] Read/Write Queue Bypass Count
896 * [16:16] 128-bit/64-Bit
897 * 0 = 64bit Interface to DRAM
898 * 1 = 128bit Interface to DRAM
899 * [17:17] DIMM ECC Enable
900 * 0 = Some DIMMs do not have ECC
901 * 1 = ALL DIMMS have ECC bits
902 * [18:18] UnBuffered DIMMs
904 * 1 = Unbuffered DIMMS
905 * [19:19] Enable 32-Byte Granularity
906 * 0 = Optimize for 64byte bursts
907 * 1 = Optimize for 32byte bursts
908 * [20:20] DIMM 0 is x4
909 * [21:21] DIMM 1 is x4
910 * [22:22] DIMM 2 is x4
911 * [23:23] DIMM 3 is x4
913 * 1 = x4 DIMM present
914 * [24:24] Disable DRAM Receivers
915 * 0 = Receivers enabled
916 * 1 = Receivers disabled
918 * 000 = Arbiters chois is always respected
919 * 001 = Oldest entry in DCQ can be bypassed 1 time
920 * 010 = Oldest entry in DCQ can be bypassed 2 times
921 * 011 = Oldest entry in DCQ can be bypassed 3 times
922 * 100 = Oldest entry in DCQ can be bypassed 4 times
923 * 101 = Oldest entry in DCQ can be bypassed 5 times
924 * 110 = Oldest entry in DCQ can be bypassed 6 times
925 * 111 = Oldest entry in DCQ can be bypassed 7 times
928 #if (MEMORY_CONFIG == MEMORY_LNXI_SOLO) || (MEMORY_CONFIG == MEMORY_SUSE_SOLO)
929 PCI_ADDR(0, 0x18, 2, 0x90), 0xf0000000,
931 (0 << 23)|(0 << 22)|(0 << 21)|(0 << 20)|
932 (1 << 19)|(1 << 18)|(0 << 17)|(0 << 16)|
933 (2 << 14)|(0 << 13)|(0 << 12)|
934 (0 << 11)|(0 << 10)|(0 << 9)|(0 << 8)|
935 (0 << 3) |(0 << 1) |(0 << 0),
937 #if MEMORY_CONFIG == MEMORY_LNXI_HDAMA
938 PCI_ADDR(0, 0x18, 2, 0x90), 0xf0000000,
940 (0 << 23)|(0 << 22)|(0 << 21)|(0 << 20)|
941 (0 << 19)|(0 << 18)|(0 << 17)|(1 << 16)|
942 (2 << 14)|(0 << 13)|(0 << 12)|
943 (0 << 11)|(0 << 10)|(0 << 9)|(0 << 8)|
944 (0 << 3) |(0 << 1) |(0 << 0),
946 /* DRAM Config High Register
948 * [ 0: 3] Maximum Asynchronous Latency
953 * [11: 8] Read Preamble
971 * [18:16] Idle Cycle Limit
980 * [19:19] Dynamic Idle Cycle Center Enable
981 * 0 = Use Idle Cycle Limit
982 * 1 = Generate a dynamic Idle cycle limit
983 * [22:20] DRAM MEMCLK Frequency
993 * [25:25] Memory Clock Ratio Valid (FIXME carefully enable memclk)
994 * 0 = Disable MemClks
996 * [26:26] Memory Clock 0 Enable
999 * [27:27] Memory Clock 1 Enable
1002 * [28:28] Memory Clock 2 Enable
1005 * [29:29] Memory Clock 3 Enable
1010 #if MEMORY_CONFIG == MEMORY_LNXI_SOLO
1011 PCI_ADDR(0, 0x18, 2, 0x94), 0xc180f0f0, 0x0e2b0a05,
1013 #if MEMORY_CONFIG == MEMORY_SUSE_SOLO
1014 PCI_ADDR(0, 0x18, 2, 0x94), 0xc180f0f0, 0x0e2b0a06,
1016 #if MEMORY_CONFIG == MEMORY_LNXI_HDAMA
1017 PCI_ADDR(0, 0x18, 2, 0x94), 0xc180f0f0, 0x065b0b08,
1019 /* DRAM Delay Line Register
1021 * Adjust the skew of the input DQS strobe relative to DATA
1023 * [23:16] Delay Line Adjust
1024 * Adjusts the DLL derived PDL delay by one or more delay stages
1025 * in either the faster or slower direction.
1026 * [24:24} Adjust Slower
1028 * 1 = Adj is used to increase the PDL delay
1029 * [25:25] Adjust Faster
1031 * 1 = Adj is used to decrease the PDL delay
1034 PCI_ADDR(0, 0x18, 2, 0x98), 0xfc00ffff, 0x00000000,
1035 /* DRAM Scrub Control Register
1037 * [ 4: 0] DRAM Scrube Rate
1039 * [12: 8] L2 Scrub Rate
1041 * [20:16] Dcache Scrub
1044 * 00000 = Do not scrub
1066 * All Others = Reserved
1068 PCI_ADDR(0, 0x18, 3, 0x58), 0xffe0e0e0, 0x00000000,
1069 /* DRAM Scrub Address Low Register
1071 * [ 0: 0] DRAM Scrubber Redirect Enable
1073 * 1 = Scrubber Corrects errors found in normal operation
1075 * [31: 6] DRAM Scrub Address 31-6
1077 PCI_ADDR(0, 0x18, 3, 0x5C), 0x0000003e, 0x00000000,
1078 /* DRAM Scrub Address High Register
1080 * [ 7: 0] DRAM Scrubb Address 39-32
1083 PCI_ADDR(0, 0x18, 3, 0x60), 0xffffff00, 0x00000000,
1087 print_debug("setting up CPU0 northbridge registers\r\n");
1088 max = sizeof(register_values)/sizeof(register_values[0]);
1089 for(i = 0; i < max; i += 3) {
1094 print_debug_hex32(register_values[i]);
1096 print_debug_hex32(register_values[i+2]);
1097 print_debug("\r\n");
1099 dev = register_values[i] & ~0xff;
1100 where = register_values[i] & 0xff;
1101 reg = pci_read_config32(dev, where);
1102 reg &= register_values[i+1];
1103 reg |= register_values[i+2];
1104 pci_write_config32(dev, where, reg);
1107 reg = pci_read_config32(register_values[i]);
1108 reg &= register_values[i+1];
1109 reg |= register_values[i+2];
1110 pci_write_config32(register_values[i], reg);
1113 print_debug("done.\r\n");
1118 unsigned long side1;
1119 unsigned long side2;
1121 static struct dimm_size spd_get_dimm_size(unsigned device)
1123 /* Calculate the log base 2 size of a DIMM in bits */
1124 struct dimm_size sz;
1129 /* Note it might be easier to use byte 31 here, it has the DIMM size as
1130 * a multiple of 4MB. The way we do it now we can size both
1131 * sides of an assymetric dimm.
1133 value = smbus_read_byte(device, 3); /* rows */
1134 if (value < 0) return sz;
1135 sz.side1 += value & 0xf;
1137 value = smbus_read_byte(device, 4); /* columns */
1138 if (value < 0) return sz;
1139 sz.side1 += value & 0xf;
1141 value = smbus_read_byte(device, 17); /* banks */
1142 if (value < 0) return sz;
1143 sz.side1 += log2(value & 0xff);
1145 /* Get the module data widht and convert it to a power of two */
1146 value = smbus_read_byte(device, 7); /* (high byte) */
1147 if (value < 0) return sz;
1151 low = smbus_read_byte(device, 6); /* (low byte) */
1152 if (low < 0) return sz;
1153 value = value | (low & 0xff);
1154 sz.side1 += log2(value);
1157 value = smbus_read_byte(device, 5); /* number of physical banks */
1158 if (value <= 1) return sz;
1160 /* Start with the symmetrical case */
1161 sz.side2 = sz.side1;
1163 value = smbus_read_byte(device, 3); /* rows */
1164 if (value < 0) return sz;
1165 if ((value & 0xf0) == 0) return sz; /* If symmetrical we are done */
1166 sz.side2 -= (value & 0x0f); /* Subtract out rows on side 1 */
1167 sz.side2 += ((value >> 4) & 0x0f); /* Add in rows on side 2 */
1169 value = smbus_read_byte(device, 4); /* columns */
1170 if (value < 0) return sz;
1171 sz.side2 -= (value & 0x0f); /* Subtract out columns on side 1 */
1172 sz.side2 += ((value >> 4) & 0x0f); /* Add in columsn on side 2 */
1176 static unsigned spd_to_dimm_side0(unsigned device)
1178 return (device - SMBUS_MEM_DEVICE_START) << 1;
1181 static unsigned spd_to_dimm_side1(unsigned device)
1183 return ((device - SMBUS_MEM_DEVICE_START) << 1) + 1;
1186 static void set_dimm_size(unsigned long size, unsigned index)
1189 /* Make certain the dimm is at least 32MB */
1190 if (size >= (25 + 3)) {
1191 /* Place the dimm size in 32 MB quantities in the bits 31 - 21.
1192 * The initialize dimm size is in bits.
1193 * Set the base enable bit0.
1195 value = (1 << ((size - (25 + 3)) + 21)) | 1;
1197 /* Set the appropriate DIMM base address register */
1198 pci_write_config32(PCI_DEV(0, 0x18, 2), 0x40 + (index << 2), value);
1201 static void spd_set_ram_size(void)
1204 for(device = SMBUS_MEM_DEVICE_START;
1205 device <= SMBUS_MEM_DEVICE_END;
1206 device += SMBUS_MEM_DEVICE_INC)
1208 struct dimm_size sz;
1209 sz = spd_get_dimm_size(device);
1210 set_dimm_size(sz.side1, spd_to_dimm_side0(device));
1211 set_dimm_size(sz.side2, spd_to_dimm_side1(device));
1215 static void set_top_mem(unsigned tom_k)
1217 /* Error if I don't have memory */
1221 /* Now set top of memory */
1223 msr.lo = (tom_k & 0x003fffff) << 10;
1224 msr.hi = (tom_k & 0xffc00000) >> 22;
1225 wrmsr(TOP_MEM, msr);
1228 /* And report the amount of memory. (I run out of registers if i don't) */
1229 print_debug("RAM: 0x");
1230 print_debug_hex32(tom_k);
1231 print_debug(" KB\r\n");
1235 static void order_dimms(void)
1241 /* Remember which registers we have used in the high 8 bits of tom */
1244 /* Find the largest remaining canidate */
1246 uint32_t csbase, csmask;
1250 for(index = 0; index < 8; index++) {
1252 value = pci_read_config32(PCI_DEV(0, 0x18, 2), 0x40 + (index << 2));
1254 /* Is it enabled? */
1259 /* Is it greater? */
1260 if (value <= csbase) {
1264 /* Has it already been selected */
1265 if (tom & (1 << (index + 24))) {
1268 /* I have a new canidate */
1272 /* See if I have found a new canidate */
1277 /* Remember I have used this register */
1278 tom |= (1 << (canidate + 24));
1280 /* Remember the dimm size */
1281 size = csbase >> 21;
1283 /* Recompute the cs base register value */
1284 csbase = (tom << 21) | 1;
1286 /* Increment the top of memory */
1289 /* Compute the memory mask */
1290 csmask = ((size -1) << 21);
1291 csmask |= 0xfe00; /* For now don't optimize */
1293 /* Write the new base register */
1294 pci_write_config32(PCI_DEV(0, 0x18, 2), 0x40 + (canidate << 2), csbase);
1295 pci_write_config32(PCI_DEV(0, 0x18, 2), 0x60 + (canidate << 2), csmask);
1298 set_top_mem((tom & ~0xff000000) << 15);
1302 #define DRAM_CONFIG_LOW 0x90
1303 #define DCL_DLL_Disable (1<<0)
1304 #define DCL_D_DRV (1<<1)
1305 #define DCL_QFC_EN (1<<2)
1306 #define DCL_DisDqsHys (1<<3)
1307 #define DCL_DramInit (1<<8)
1308 #define DCL_DramEnable (1<<10)
1309 #define DCL_MemClrStatus (1<<11)
1310 #define DCL_DimmEcEn (1<<17)
1313 static void spd_set_ecc_mode(void)
1316 dcl = pci_read_config32(PCI_DEV(0, 0x18, 2), DRAM_CONFIG_LOW);
1317 /* Until I know what is going on disable ECC support */
1318 dcl &= ~DCL_DimmEcEn;
1319 pci_write_config32(PCI_DEV(0, 0x18, 2), DRAM_CONFIG_LOW, dcl);
1322 static void sdram_set_spd_registers(void)
1329 #define TIMEOUT_LOOPS 300000
1330 static void sdram_enable(void)
1334 /* Toggle DisDqsHys to get it working */
1335 dcl = pci_read_config32(PCI_DEV(0, 0x18, 2), DRAM_CONFIG_LOW);
1336 print_debug("dcl: ");
1337 print_debug_hex32(dcl);
1338 print_debug("\r\n");
1339 dcl |= DCL_DisDqsHys;
1340 pci_write_config32(PCI_DEV(0, 0x18, 2), DRAM_CONFIG_LOW, dcl);
1341 dcl &= ~DCL_DisDqsHys;
1342 dcl &= ~DCL_DLL_Disable;
1345 dcl |= DCL_DramInit;
1346 pci_write_config32(PCI_DEV(0, 0x18, 2), DRAM_CONFIG_LOW, dcl);
1348 print_debug("Initializing memory: ");
1351 dcl = pci_read_config32(PCI_DEV(0, 0x18, 2), DRAM_CONFIG_LOW);
1353 if ((loops & 1023) == 0) {
1356 } while(((dcl & DCL_DramInit) != 0) && (loops < TIMEOUT_LOOPS));
1357 if (loops >= TIMEOUT_LOOPS) {
1358 print_debug(" failed\r\n");
1360 print_debug(" done\r\n");
1364 print_debug("Clearing memory: ");
1367 dcl = pci_read_config32(PCI_DEV(0, 0x18, 2), DRAM_CONFIG_LOW);
1369 if ((loops & 1023) == 0) {
1371 print_debug_hex32(loops);
1373 } while(((dcl & DCL_MemClrStatus) == 0) && (loops < TIMEOUT_LOOPS));
1374 if (loops >= TIMEOUT_LOOPS) {
1375 print_debug("failed\r\n");
1377 print_debug("done\r\n");
1382 static void sdram_first_normal_reference(void) {}
1383 static void sdram_enable_refresh(void) {}
1384 static void sdram_special_finishup(void) {}