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 #if MEMORY_CONFIG == MEMORY_LNXI_SOLO
661 PCI_ADDR(0, 0x18, 2, 0x40), 0x001f01fe, 0x00000000,
662 PCI_ADDR(0, 0x18, 2, 0x44), 0x001f01fe, 0x00000000,
663 PCI_ADDR(0, 0x18, 2, 0x48), 0x001f01fe, 0x00000000,
664 PCI_ADDR(0, 0x18, 2, 0x4C), 0x001f01fe, 0x00000000,
666 #if MEMORY_CONFIG == MEMORY_SUSE_SOLO
667 PCI_ADDR(0, 0x18, 2, 0x40), 0x001f01fe, 0x00000001,
668 PCI_ADDR(0, 0x18, 2, 0x44), 0x001f01fe, 0x00800001,
669 PCI_ADDR(0, 0x18, 2, 0x48), 0x001f01fe, 0x01000001,
670 PCI_ADDR(0, 0x18, 2, 0x4C), 0x001f01fe, 0x01800001,
672 #if MEMORY_CONFIG == MEMORY_LNXI_HDAMA
673 PCI_ADDR(0, 0x18, 2, 0x40), 0x001f01fe, 0x00000001,
674 PCI_ADDR(0, 0x18, 2, 0x44), 0x001f01fe, 0x00001001,
675 PCI_ADDR(0, 0x18, 2, 0x48), 0x001f01fe, 0x00000000,
676 PCI_ADDR(0, 0x18, 2, 0x4C), 0x001f01fe, 0x00000000,
678 PCI_ADDR(0, 0x18, 2, 0x50), 0x001f01fe, 0x00000000,
679 PCI_ADDR(0, 0x18, 2, 0x54), 0x001f01fe, 0x00000000,
680 PCI_ADDR(0, 0x18, 2, 0x58), 0x001f01fe, 0x00000000,
681 PCI_ADDR(0, 0x18, 2, 0x5C), 0x001f01fe, 0x00000000,
682 /* DRAM CS Mask Address i Registers
691 * Select bits to exclude from comparison with the DRAM Base address register.
693 * [15: 9] Address Mask (19-13)
694 * Address to be excluded from the optimized case
696 * [29:21] Address Mask (33-25)
697 * The bits with an address mask of 1 are excluded from address comparison
701 #if MEMORY_CONFIG == MEMORY_LNXI_SOLO
702 PCI_ADDR(0, 0x18, 2, 0x60), 0xC01f01ff, 0x00000000,
703 PCI_ADDR(0, 0x18, 2, 0x64), 0xC01f01ff, 0x00000000,
704 PCI_ADDR(0, 0x18, 2, 0x68), 0xC01f01ff, 0x00000000,
705 PCI_ADDR(0, 0x18, 2, 0x6C), 0xC01f01ff, 0x00000000,
707 #if MEMORY_CONFIG == MEMORY_SUSE_SOLO
708 PCI_ADDR(0, 0x18, 2, 0x60), 0xC01f01ff, 0x0060fe00,
709 PCI_ADDR(0, 0x18, 2, 0x64), 0xC01f01ff, 0x0060fe00,
710 PCI_ADDR(0, 0x18, 2, 0x68), 0xC01f01ff, 0x0060fe00,
711 PCI_ADDR(0, 0x18, 2, 0x6C), 0xC01f01ff, 0x0060fe00,
713 #if MEMORY_CONFIG == MEMORY_LNXI_HDAMA
714 PCI_ADDR(0, 0x18, 2, 0x60), 0xC01f01ff, 0x03e0ee00,
715 PCI_ADDR(0, 0x18, 2, 0x64), 0xC01f01ff, 0x03e0ee00,
716 PCI_ADDR(0, 0x18, 2, 0x68), 0xC01f01ff, 0x00000000,
717 PCI_ADDR(0, 0x18, 2, 0x6C), 0xC01f01ff, 0x00000000,
719 PCI_ADDR(0, 0x18, 2, 0x70), 0xC01f01ff, 0x00000000,
720 PCI_ADDR(0, 0x18, 2, 0x74), 0xC01f01ff, 0x00000000,
721 PCI_ADDR(0, 0x18, 2, 0x78), 0xC01f01ff, 0x00000000,
722 PCI_ADDR(0, 0x18, 2, 0x7C), 0xC01f01ff, 0x00000000,
723 /* DRAM Bank Address Mapping Register
725 * Specify the memory module size
730 * 000 = 32Mbyte (Rows = 12 & Col = 8)
731 * 001 = 64Mbyte (Rows = 12 & Col = 9)
732 * 010 = 128Mbyte (Rows = 13 & Col = 9)|(Rows = 12 & Col = 10)
733 * 011 = 256Mbyte (Rows = 13 & Col = 10)|(Rows = 12 & Col = 11)
734 * 100 = 512Mbyte (Rows = 13 & Col = 11)|(Rows = 14 & Col = 10)
735 * 101 = 1Gbyte (Rows = 14 & Col = 11)|(Rows = 13 & Col = 12)
736 * 110 = 2Gbyte (Rows = 14 & Col = 12)
743 #if MEMORY_CONFIG == MEMORY_LNXI_SOLO
744 PCI_ADDR(0, 0x18, 2, 0x80), 0xffff8888, 0x00000000,
746 #if MEMORY_CONFIG == MEMORY_SUSE_SOLO
747 PCI_ADDR(0, 0x18, 2, 0x80), 0xffff8888, 0x00000022,
749 #if MEMORY_CONFIG == MEMORY_LNXI_HDAMA
750 PCI_ADDR(0, 0x18, 2, 0x80), 0xffff8888, 0x00000003,
752 /* DRAM Timing Low Register
754 * [ 2: 0] Tcl (Cas# Latency, Cas# to read-data-valid)
764 * [ 7: 4] Trc (Row Cycle Time, Ras#-active to Ras#-active/bank auto refresh)
765 * 0000 = 7 bus clocks
766 * 0001 = 8 bus clocks
768 * 1110 = 21 bus clocks
769 * 1111 = 22 bus clocks
770 * [11: 8] Trfc (Row refresh Cycle time, Auto-refresh-active to RAS#-active or RAS#auto-refresh)
771 * 0000 = 9 bus clocks
772 * 0010 = 10 bus clocks
774 * 1110 = 23 bus clocks
775 * 1111 = 24 bus clocks
776 * [14:12] Trcd (Ras#-active to Case#-read/write Delay)
786 * [18:16] Trrd (Ras# to Ras# Delay)
796 * [23:20] Tras (Minmum Ras# Active Time)
797 * 0000 to 0100 = reserved
798 * 0101 = 5 bus clocks
800 * 1111 = 15 bus clocks
801 * [26:24] Trp (Row Precharge Time)
811 * [28:28] Twr (Write Recovery Time)
816 #if (MEMORY_CONFIG == MEMORY_LNXI_SOLO) || (MEMORY_CONFIG == MEMORY_SUSE_SOLO)
817 PCI_ADDR(0, 0x18, 2, 0x88), 0xe8088008, 0x03623125,
819 #if MEMORY_CONFIG == MEMORY_LNXI_HDAMA
820 PCI_ADDR(0, 0x18, 2, 0x88), 0xe8088008, 0x13723335,
822 /* DRAM Timing High Register
824 * [ 0: 0] Twtr (Write to Read Delay)
828 * [ 6: 4] Trwf (Read to Write Delay)
838 * [12: 8] Tref (Refresh Rate)
839 * 00000 = 100Mhz 4K rows
840 * 00001 = 133Mhz 4K rows
841 * 00010 = 166Mhz 4K rows
842 * 01000 = 100Mhz 8K/16K rows
843 * 01001 = 133Mhz 8K/16K rows
844 * 01010 = 166Mhz 8K/16K rows
846 * [22:20] Twcl (Write CAS Latency)
847 * 000 = 1 Mem clock after CAS# (Unbuffered Dimms)
848 * 001 = 2 Mem clocks after CAS# (Registered Dimms)
851 #if MEMORY_CONFIG == MEMORY_LNXI_SOLO
852 PCI_ADDR(0, 0x18, 2, 0x8c), 0xff8fe08e, 0x00000930,
854 #if MEMORY_CONFIG == MEMORY_SUSE_SOLO
855 PCI_ADDR(0, 0x18, 2, 0x8c), 0xff8fe08e, 0x00000130,
857 #if MEMORY_CONFIG == MEMORY_LNXI_HDAMA
858 PCI_ADDR(0, 0x18, 2, 0x8c), 0xff8fe08e, 0x00100a20,
860 /* DRAM Config Low Register
862 * [ 0: 0] DLL Disable
871 * [ 3: 3] Disable DQS Hystersis (FIXME handle this one carefully)
872 * 0 = Enable DQS input filter
873 * 1 = Disable DQS input filtering
876 * 0 = Initialization done or not yet started.
877 * 1 = Initiate DRAM intialization sequence
878 * [ 9: 9] SO-Dimm Enable
880 * 1 = SO-Dimms present
882 * 0 = DRAM not enabled
883 * 1 = DRAM initialized and enabled
884 * [11:11] Memory Clear Status
885 * 0 = Memory Clear function has not completed
886 * 1 = Memory Clear function has completed
887 * [12:12] Exit Self-Refresh
888 * 0 = Exit from self-refresh done or not yet started
889 * 1 = DRAM exiting from self refresh
890 * [13:13] Self-Refresh Status
891 * 0 = Normal Operation
892 * 1 = Self-refresh mode active
893 * [15:14] Read/Write Queue Bypass Count
898 * [16:16] 128-bit/64-Bit
899 * 0 = 64bit Interface to DRAM
900 * 1 = 128bit Interface to DRAM
901 * [17:17] DIMM ECC Enable
902 * 0 = Some DIMMs do not have ECC
903 * 1 = ALL DIMMS have ECC bits
904 * [18:18] UnBuffered DIMMs
906 * 1 = Unbuffered DIMMS
907 * [19:19] Enable 32-Byte Granularity
908 * 0 = Optimize for 64byte bursts
909 * 1 = Optimize for 32byte bursts
910 * [20:20] DIMM 0 is x4
911 * [21:21] DIMM 1 is x4
912 * [22:22] DIMM 2 is x4
913 * [23:23] DIMM 3 is x4
915 * 1 = x4 DIMM present
916 * [24:24] Disable DRAM Receivers
917 * 0 = Receivers enabled
918 * 1 = Receivers disabled
920 * 000 = Arbiters chois is always respected
921 * 001 = Oldest entry in DCQ can be bypassed 1 time
922 * 010 = Oldest entry in DCQ can be bypassed 2 times
923 * 011 = Oldest entry in DCQ can be bypassed 3 times
924 * 100 = Oldest entry in DCQ can be bypassed 4 times
925 * 101 = Oldest entry in DCQ can be bypassed 5 times
926 * 110 = Oldest entry in DCQ can be bypassed 6 times
927 * 111 = Oldest entry in DCQ can be bypassed 7 times
930 #if (MEMORY_CONFIG == MEMORY_LNXI_SOLO) || (MEMORY_CONFIG == MEMORY_SUSE_SOLO)
931 PCI_ADDR(0, 0x18, 2, 0x90), 0xf0000000,
933 (0 << 23)|(0 << 22)|(0 << 21)|(0 << 20)|
934 (1 << 19)|(1 << 18)|(0 << 17)|(0 << 16)|
935 (2 << 14)|(0 << 13)|(0 << 12)|
936 (0 << 11)|(0 << 10)|(0 << 9)|(0 << 8)|
937 (0 << 3) |(0 << 1) |(0 << 0),
939 #if MEMORY_CONFIG == MEMORY_LNXI_HDAMA
940 PCI_ADDR(0, 0x18, 2, 0x90), 0xf0000000,
942 (0 << 23)|(0 << 22)|(0 << 21)|(0 << 20)|
943 (0 << 19)|(0 << 18)|(0 << 17)|(1 << 16)|
944 (2 << 14)|(0 << 13)|(0 << 12)|
945 (0 << 11)|(0 << 10)|(0 << 9)|(0 << 8)|
946 (0 << 3) |(0 << 1) |(0 << 0),
948 /* DRAM Config High Register
950 * [ 0: 3] Maximum Asynchronous Latency
955 * [11: 8] Read Preamble
973 * [18:16] Idle Cycle Limit
982 * [19:19] Dynamic Idle Cycle Center Enable
983 * 0 = Use Idle Cycle Limit
984 * 1 = Generate a dynamic Idle cycle limit
985 * [22:20] DRAM MEMCLK Frequency
995 * [25:25] Memory Clock Ratio Valid (FIXME carefully enable memclk)
996 * 0 = Disable MemClks
998 * [26:26] Memory Clock 0 Enable
1001 * [27:27] Memory Clock 1 Enable
1004 * [28:28] Memory Clock 2 Enable
1007 * [29:29] Memory Clock 3 Enable
1012 #if MEMORY_CONFIG == MEMORY_LNXI_SOLO
1013 PCI_ADDR(0, 0x18, 2, 0x94), 0xc180f0f0, 0x0e2b0a05,
1015 #if MEMORY_CONFIG == MEMORY_SUSE_SOLO
1016 PCI_ADDR(0, 0x18, 2, 0x94), 0xc180f0f0, 0x0e2b0a06,
1018 #if MEMORY_CONFIG == MEMORY_LNXI_HDAMA
1019 PCI_ADDR(0, 0x18, 2, 0x94), 0xc180f0f0, 0x065b0b08,
1021 /* DRAM Delay Line Register
1023 * Adjust the skew of the input DQS strobe relative to DATA
1025 * [23:16] Delay Line Adjust
1026 * Adjusts the DLL derived PDL delay by one or more delay stages
1027 * in either the faster or slower direction.
1028 * [24:24} Adjust Slower
1030 * 1 = Adj is used to increase the PDL delay
1031 * [25:25] Adjust Faster
1033 * 1 = Adj is used to decrease the PDL delay
1036 PCI_ADDR(0, 0x18, 2, 0x98), 0xfc00ffff, 0x00000000,
1037 /* DRAM Scrub Control Register
1039 * [ 4: 0] DRAM Scrube Rate
1041 * [12: 8] L2 Scrub Rate
1043 * [20:16] Dcache Scrub
1046 * 00000 = Do not scrub
1068 * All Others = Reserved
1070 PCI_ADDR(0, 0x18, 3, 0x58), 0xffe0e0e0, 0x00000000,
1071 /* DRAM Scrub Address Low Register
1073 * [ 0: 0] DRAM Scrubber Redirect Enable
1075 * 1 = Scrubber Corrects errors found in normal operation
1077 * [31: 6] DRAM Scrub Address 31-6
1079 PCI_ADDR(0, 0x18, 3, 0x5C), 0x0000003e, 0x00000000,
1080 /* DRAM Scrub Address High Register
1082 * [ 7: 0] DRAM Scrubb Address 39-32
1085 PCI_ADDR(0, 0x18, 3, 0x60), 0xffffff00, 0x00000000,
1089 print_debug("setting up CPU0 northbridge registers\r\n");
1090 max = sizeof(register_values)/sizeof(register_values[0]);
1091 for(i = 0; i < max; i += 3) {
1096 print_debug_hex32(register_values[i]);
1098 print_debug_hex32(register_values[i+2]);
1099 print_debug("\r\n");
1101 dev = register_values[i] & ~0xff;
1102 where = register_values[i] & 0xff;
1103 reg = pci_read_config32(dev, where);
1104 reg &= register_values[i+1];
1105 reg |= register_values[i+2];
1106 pci_write_config32(dev, where, reg);
1109 reg = pci_read_config32(register_values[i]);
1110 reg &= register_values[i+1];
1111 reg |= register_values[i+2];
1112 pci_write_config32(register_values[i], reg);
1115 print_debug("done.\r\n");
1120 unsigned long side1;
1121 unsigned long side2;
1123 static struct dimm_size spd_get_dimm_size(unsigned device)
1125 /* Calculate the log base 2 size of a DIMM in bits */
1126 struct dimm_size sz;
1131 /* Note it might be easier to use byte 31 here, it has the DIMM size as
1132 * a multiple of 4MB. The way we do it now we can size both
1133 * sides of an assymetric dimm.
1135 value = smbus_read_byte(device, 3); /* rows */
1136 if (value < 0) return sz;
1137 sz.side1 += value & 0xf;
1139 value = smbus_read_byte(device, 4); /* columns */
1140 if (value < 0) return sz;
1141 sz.side1 += value & 0xf;
1143 value = smbus_read_byte(device, 17); /* banks */
1144 if (value < 0) return sz;
1145 sz.side1 += log2(value & 0xff);
1147 /* Get the module data widht and convert it to a power of two */
1148 value = smbus_read_byte(device, 7); /* (high byte) */
1149 if (value < 0) return sz;
1153 low = smbus_read_byte(device, 6); /* (low byte) */
1154 if (low < 0) return sz;
1155 value = value | (low & 0xff);
1156 sz.side1 += log2(value);
1159 value = smbus_read_byte(device, 5); /* number of physical banks */
1160 if (value <= 1) return sz;
1162 /* Start with the symmetrical case */
1163 sz.side2 = sz.side1;
1165 value = smbus_read_byte(device, 3); /* rows */
1166 if (value < 0) return sz;
1167 if ((value & 0xf0) == 0) return sz; /* If symmetrical we are done */
1168 sz.side2 -= (value & 0x0f); /* Subtract out rows on side 1 */
1169 sz.side2 += ((value >> 4) & 0x0f); /* Add in rows on side 2 */
1171 value = smbus_read_byte(device, 4); /* columns */
1172 if (value < 0) return sz;
1173 sz.side2 -= (value & 0x0f); /* Subtract out columns on side 1 */
1174 sz.side2 += ((value >> 4) & 0x0f); /* Add in columsn on side 2 */
1178 static unsigned spd_to_dimm(unsigned device)
1180 return (device - SMBUS_MEM_DEVICE_START);
1183 static void set_dimm_size(struct dimm_size sz, unsigned index)
1185 uint32_t base0, base1, map;
1188 print_debug("set_dimm_size: (");
1189 print_debug_hex32(sz.side1);
1190 print_debug_char(',');
1191 print_debug_hex32(sz.side2);
1192 print_debug_char(',');
1193 print_debug_hex32(index);
1194 print_debug(")\r\n");
1196 if (sz.side1 != sz.side2) {
1199 map = pci_read_config32(PCI_DEV(0, 0x18, 2), 0x80);
1200 map &= ~(0xf << (index + 4));
1202 /* For each base register.
1203 * Place the dimm size in 32 MB quantities in the bits 31 - 21.
1204 * The initialize dimm size is in bits.
1205 * Set the base enable bit0.
1210 /* Make certain side1 of the dimm is at least 32MB */
1211 if (sz.side1 >= (25 + 3)) {
1212 base0 = (1 << ((sz.side1 - (25 + 3)) + 21)) | 1;
1213 map |= (sz.side1 - (25 + 3)) << (index *4);
1216 /* Make certain side2 of the dimm is at least 32MB */
1217 if (sz.side2 >= (25 + 3)) {
1218 base1 = (1 << ((sz.side2 - (25 + 3)) + 21)) | 1;
1221 /* Set the appropriate DIMM base address register */
1222 pci_write_config32(PCI_DEV(0, 0x18, 2), 0x40 + (((index << 1)+0)<<2), base0);
1223 pci_write_config32(PCI_DEV(0, 0x18, 2), 0x40 + (((index << 1)+1)<<2), base1);
1224 pci_write_config32(PCI_DEV(0, 0x18, 2), 0x80, map);
1227 static void spd_set_ram_size(void)
1230 for(device = SMBUS_MEM_DEVICE_START;
1231 device <= SMBUS_MEM_DEVICE_END;
1232 device += SMBUS_MEM_DEVICE_INC)
1234 struct dimm_size sz;
1235 sz = spd_get_dimm_size(device);
1236 set_dimm_size(sz, spd_to_dimm(device));
1240 static void set_top_mem(unsigned tom_k)
1242 /* Error if I don't have memory */
1246 /* Now set top of memory */
1248 msr.lo = (tom_k & 0x003fffff) << 10;
1249 msr.hi = (tom_k & 0xffc00000) >> 22;
1250 wrmsr(TOP_MEM, msr);
1253 /* And report the amount of memory. (I run out of registers if i don't) */
1254 print_debug("RAM: 0x");
1255 print_debug_hex32(tom_k);
1256 print_debug(" KB\r\n");
1260 static void order_dimms(void)
1264 /* Remember which registers we have used in the high 8 bits of tom */
1267 /* Find the largest remaining canidate */
1268 unsigned index, canidate;
1269 uint32_t csbase, csmask;
1273 for(index = 0; index < 8; index++) {
1275 value = pci_read_config32(PCI_DEV(0, 0x18, 2), 0x40 + (index << 2));
1277 /* Is it enabled? */
1282 /* Is it greater? */
1283 if (value <= csbase) {
1287 /* Has it already been selected */
1288 if (tom & (1 << (index + 24))) {
1291 /* I have a new canidate */
1295 /* See if I have found a new canidate */
1300 /* Remember I have used this register */
1301 tom |= (1 << (canidate + 24));
1303 /* Remember the dimm size */
1304 size = csbase >> 21;
1306 /* Recompute the cs base register value */
1307 csbase = (tom << 21) | 1;
1309 /* Increment the top of memory */
1312 /* Compute the memory mask */
1313 csmask = ((size -1) << 21);
1314 csmask |= 0xfe00; /* For now don't optimize */
1316 /* Write the new base register */
1317 pci_write_config32(PCI_DEV(0, 0x18, 2), 0x40 + (canidate << 2), csbase);
1318 /* Write the new mask register */
1319 pci_write_config32(PCI_DEV(0, 0x18, 2), 0x60 + (canidate << 2), csmask);
1322 set_top_mem((tom & ~0xff000000) << 15);
1325 static void spd_set_dram_timing(void)
1330 #define DRAM_CONFIG_LOW 0x90
1331 #define DCL_DLL_Disable (1<<0)
1332 #define DCL_D_DRV (1<<1)
1333 #define DCL_QFC_EN (1<<2)
1334 #define DCL_DisDqsHys (1<<3)
1335 #define DCL_DramInit (1<<8)
1336 #define DCL_DramEnable (1<<10)
1337 #define DCL_MemClrStatus (1<<11)
1338 #define DCL_DimmEcEn (1<<17)
1341 static void spd_set_ecc_mode(void)
1344 dcl = pci_read_config32(PCI_DEV(0, 0x18, 2), DRAM_CONFIG_LOW);
1345 /* Until I know what is going on disable ECC support */
1346 dcl &= ~DCL_DimmEcEn;
1347 pci_write_config32(PCI_DEV(0, 0x18, 2), DRAM_CONFIG_LOW, dcl);
1350 static void sdram_set_spd_registers(void)
1353 spd_set_dram_timing();
1358 #define TIMEOUT_LOOPS 300000
1359 static void sdram_enable(void)
1363 /* Toggle DisDqsHys to get it working */
1364 dcl = pci_read_config32(PCI_DEV(0, 0x18, 2), DRAM_CONFIG_LOW);
1365 print_debug("dcl: ");
1366 print_debug_hex32(dcl);
1367 print_debug("\r\n");
1368 dcl |= DCL_DisDqsHys;
1369 pci_write_config32(PCI_DEV(0, 0x18, 2), DRAM_CONFIG_LOW, dcl);
1370 dcl &= ~DCL_DisDqsHys;
1371 dcl &= ~DCL_DLL_Disable;
1374 dcl |= DCL_DramInit;
1375 pci_write_config32(PCI_DEV(0, 0x18, 2), DRAM_CONFIG_LOW, dcl);
1377 print_debug("Initializing memory: ");
1380 dcl = pci_read_config32(PCI_DEV(0, 0x18, 2), DRAM_CONFIG_LOW);
1382 if ((loops & 1023) == 0) {
1385 } while(((dcl & DCL_DramInit) != 0) && (loops < TIMEOUT_LOOPS));
1386 if (loops >= TIMEOUT_LOOPS) {
1387 print_debug(" failed\r\n");
1389 print_debug(" done\r\n");
1393 print_debug("Clearing memory: ");
1396 dcl = pci_read_config32(PCI_DEV(0, 0x18, 2), DRAM_CONFIG_LOW);
1398 if ((loops & 1023) == 0) {
1400 print_debug_hex32(loops);
1402 } while(((dcl & DCL_MemClrStatus) == 0) && (loops < TIMEOUT_LOOPS));
1403 if (loops >= TIMEOUT_LOOPS) {
1404 print_debug("failed\r\n");
1406 print_debug("done\r\n");
1411 static void sdram_first_normal_reference(void) {}
1412 static void sdram_enable_refresh(void) {}
1413 static void sdram_special_finishup(void) {}