2 * (C) Copyright 2005 Nick Barker <nick.barker9@btinternet.com>
3 * (C) Copyright 2009 Jon Harrison <bothlyn@blueyonder.co.uk
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of
9 * the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
23 Automatically detect and set up ddr dram on the CN400 chipset.
24 Assumes DDR400 memory as no attempt is made to clock
25 the chipset down if slower memory is installed.
27 512 Mb DDR400 4 Bank / 2 Rank (1GB) (i.e. double sided)
29 /* ported from Via VT8263 Code*/
32 #include <sdram_mode.h>
34 #include <cpu/x86/mtrr.h>
37 static void dimm_read(unsigned long bank,unsigned long x)
40 volatile unsigned long y;
42 y = * (volatile unsigned long *) (x+ bank) ;
47 static void print_val(char *str, int val)
50 print_debug_hex8(val);
54 * Configure the bus between the CPU and the northbridge. This might be able to
55 * be moved to post-ram code in the future. For the most part, these registers
56 * should not be messed around with. These are too complex to explain short of
57 * copying the datasheets into the comments, but most of these values are from
58 * the BIOS Porting Guide, so they should work on any board. If they don't,
59 * try the values from your factory BIOS.
61 * TODO: Changing the DRAM frequency doesn't work (hard lockup).
63 * @param dev The northbridge's CPU Host Interface (D0F2).
65 static void c3_cpu_setup(device_t dev)
67 /* Host bus interface registers (D0F2 0x50-0x67) */
68 /* Taken from CN700 and updated from running CN400 */
71 /* Host Bus I/O Circuit (see datasheet) */
72 /* Host Address Pullup/down Driving */
73 pci_write_config8(dev, 0x70, 0x33);
74 pci_write_config8(dev, 0x71, 0x44);
75 pci_write_config8(dev, 0x72, 0x33);
76 pci_write_config8(dev, 0x73, 0x44);
78 /* Output Delay Stagger Control */
79 pci_write_config8(dev, 0x74, 0x70);
81 /* AGTL+ I/O Circuit */
82 pci_write_config8(dev, 0x75, 0x08);
84 /* AGTL+ Compensation Status */
85 pci_write_config8(dev, 0x76, 0x74);
87 /* AGTL+ Auto Compensation Offest */
88 pci_write_config8(dev, 0x77, 0x00);
89 pci_write_config8(dev, 0x78, 0x94);
91 /* Request phase control */
92 pci_write_config8(dev, 0x50, 0xA8);
94 /* Line DRDY# Timing Control */
95 pci_write_config8(dev, 0x60, 0x00);
96 pci_write_config8(dev, 0x61, 0x00);
97 pci_write_config8(dev, 0x62, 0x00);
99 /* QW DRDY# Timing Control */
100 pci_write_config8(dev, 0x63, 0x00);
101 pci_write_config8(dev, 0x64, 0x00);
102 pci_write_config8(dev, 0x65, 0x00);
104 /* Read Line Burst DRDY# Timing Control */
105 pci_write_config8(dev, 0x66, 0x00);
106 pci_write_config8(dev, 0x67, 0x00);
108 /* CPU Interface Control */
109 pci_write_config8(dev, 0x51, 0xFE);
110 pci_write_config8(dev, 0x52, 0xEF);
113 pci_write_config8(dev, 0x53, 0x88);
115 /* Write Policy & Reorder Latecy */
116 pci_write_config8(dev, 0x56, 0x00);
118 /* Delivery-Trigger Control */
119 pci_write_config8(dev, 0x58, 0x00);
122 pci_write_config8(dev, 0x59, 0x30);
124 /* CPU Misc Control */
125 pci_write_config8(dev, 0x5C, 0x00);
128 pci_write_config8(dev, 0x5d, 0xb2);
130 /* Bandwidth Timer */
131 pci_write_config8(dev, 0x5e, 0x88);
133 /* CPU Miscellaneous Control */
134 pci_write_config8(dev, 0x5f, 0xc7);
136 /* CPU Miscellaneous Control */
137 pci_write_config8(dev, 0x55, 0x28);
138 pci_write_config8(dev, 0x57, 0x69);
140 /* CPU Host Bus Final Setup */
141 reg8 = pci_read_config8(dev, 0x54);
143 pci_write_config8(dev, 0x54, reg8);
147 static void ddr_ram_setup(void)
149 uint8_t b, c, bank, ma;
151 unsigned long bank_address;
154 print_debug("CN400 RAM init starting\r\n");
156 pci_write_config8(ctrl.d0f7, 0x75, 0x08);
159 /* No Interleaving or Multi Page */
160 pci_write_config8(ctrl.d0f3, 0x69, 0x00);
161 pci_write_config8(ctrl.d0f3, 0x6b, 0x10);
164 DRAM MA Map Type Device 0 Fn3 Offset 50-51
166 Determine memory addressing based on the module's memory technology and
167 arrangement. See Table 4-9 of Intel's 82443GX datasheet for details.
169 Bank 1/0 MA map type 50[7-5]
170 Bank 1/0 command rate 50[4]
171 Bank 3/2 MA map type 50[3-1]
172 Bank 3/2 command rate 50[0]
175 Read SPD byte 17, Number of banks on SDRAM device.
178 b = smbus_read_byte(0x50, SPD_NUM_BANKS_PER_SDRAM);
179 //print_val("Detecting Memory\r\nNumber of Banks ",b);
181 // Only supporting 4 bank chips just now
184 Read SPD byte 3, Number of row addresses.
188 b = smbus_read_byte(0x50, SPD_NUM_ROWS);
189 //print_val("\r\nNumber of Rows ", b);
191 if( b >= 0x0d ){ // 256/512Mb
199 Read SPD byte 13, Primary DRAM width.
201 b = smbus_read_byte(0x50, SPD_PRIMARY_SDRAM_WIDTH);
202 //print_val("\r\nPrimary DRAM width", b);
203 if( b != 4 ) // not 64/128Mb (x4)
208 Read SPD byte 4, Number of column addresses.
210 b = smbus_read_byte(0x50, SPD_NUM_COLUMNS);
211 //print_val("\r\nNo Columns ",b);
212 if( b == 10 || b == 11 || b == 12) c |= 0x60; // 10/11 bit col addr
213 if( b == 9 ) c |= 0x40; // 9 bit col addr
214 if( b == 8 ) c |= 0x20; // 8 bit col addr
216 //print_val("\r\nMA type ", c);
217 pci_write_config8(ctrl.d0f3, 0x50, c);
221 /* Disable Upper Banks */
222 pci_write_config8(ctrl.d0f3, 0x51, 0x00);
226 die("DRAM module size is not supported by CN400\r\n");
231 DRAM bank size. See 4.3.1 pg 35
233 5a->5d set to end address for each bank. 1 bit == 32MB
236 5c = bank 0 + b1 + b2
237 5d = bank 0 + b1 + b2 + b3
240 // Read SPD byte 31 Module bank density
242 b = smbus_read_byte(0x50, SPD_DENSITY_OF_EACH_ROW_ON_MODULE);
251 if (bank == 0x48) bank |= 0x01;
257 if (bank == 0x44) bank |= 0x02;
262 if (bank == 0x44) bank |= 0x01;
268 if (bank == 0x40) bank |= 0x02;
275 else if( b & 0x08) c = 0x01; // 32MB
276 else c = 0x01; // Error, use default
278 // set bank zero size
279 pci_write_config8(ctrl.d0f3, 0x40, c);
281 // SPD byte 5 # of physical banks
282 b = smbus_read_byte(0x50, SPD_NUM_DIMM_BANKS);
284 //print_val("\r\nNo Physical Banks ",b);
292 die("Only a single DIMM is supported by EPIA-N(L)\r\n");
295 // set banks 1,2,3...
296 pci_write_config8(ctrl.d0f3, 0x41,c);
297 pci_write_config8(ctrl.d0f3, 0x42,c);
298 pci_write_config8(ctrl.d0f3, 0x43,c);
299 pci_write_config8(ctrl.d0f3, 0x44,c);
300 pci_write_config8(ctrl.d0f3, 0x45,c);
301 pci_write_config8(ctrl.d0f3, 0x46,c);
302 pci_write_config8(ctrl.d0f3, 0x47,c);
304 /* Top Rank Address Mirrored to the South Bridge */
306 pci_write_config8(ctrl.d0f7, 0x57, (c << 1));
310 /* Read SPD byte 18 CAS Latency */
311 b = smbus_read_byte(0x50, SPD_ACCEPTABLE_CAS_LATENCIES);
312 /* print_debug("\r\nCAS Supported ");
320 c = smbus_read_byte(0x50, SPD_MIN_CYCLE_TIME_AT_CAS_MAX);
321 print_val("\r\nCycle time at CL X (nS)", c);
322 c = smbus_read_byte(0x50, SPD_SDRAM_CYCLE_TIME_2ND);
323 print_val("\r\nCycle time at CL X-0.5 (nS)", c);
324 c = smbus_read_byte(0x50, SPD_SDRAM_CYCLE_TIME_3RD);
325 print_val("\r\nCycle time at CL X-1 (nS)", c);
327 /* Scaling of Cycle Time SPD data */
330 bank = smbus_read_byte(0x50, SPD_MIN_CYCLE_TIME_AT_CAS_MAX);
332 if( b & 0x10 ){ // DDR offering optional CAS 3
333 //print_debug("\r\nStarting at CAS 3");
335 /* see if we can better it */
336 if( b & 0x08 ){ // DDR mandatory CAS 2.5
337 if( smbus_read_byte(0x50, SPD_SDRAM_CYCLE_TIME_2ND) <= bank ){ // we can manage max MHz at CAS 2.5
338 //print_debug("\r\nWe can do CAS 2.5");
342 if( b & 0x04 ){ // DDR mandatory CAS 2
343 if( smbus_read_byte(0x50, SPD_SDRAM_CYCLE_TIME_3RD) <= bank ){ // we can manage max Mhz at CAS 2
344 //print_debug("\r\nWe can do CAS 2");
348 }else{ // no optional CAS values just 2 & 2.5
349 //print_debug("\r\nStarting at CAS 2.5");
350 c = 0x20; // assume CAS 2.5
351 if( b & 0x04){ // Should always happen
352 if( smbus_read_byte(0x50, SPD_SDRAM_CYCLE_TIME_2ND) <= bank){ // we can manage max Mhz at CAS 2
353 //print_debug("\r\nWe can do CAS 2");
359 /* Scale DRAM Cycle Time to tRP/tRCD */
362 if ( bank <= 0x50 ) bank = 0x14;
363 else if (bank <= 0x60) bank = 0x18;
367 DRAM Timing Device 0 Fn 3 Offset 56
369 RAS Pulse width 56[7,6]
371 Row pre-charge 56[1,0]
379 RAS/CAS delay 56[3,2]
381 Determine row pre-charge time (tRP)
384 Read SPD byte 27, min row pre-charge time.
387 b = smbus_read_byte(0x50, SPD_MIN_ROW_PRECHARGE_TIME);
389 //print_val("\r\ntRP ",b);
390 if ( b >= (5 * bank)) {
391 c |= 0x03; // set tRP = 5T
393 else if ( b >= (4 * bank)) {
394 c |= 0x02; // set tRP = 4T
396 else if ( b >= (3 * bank)) {
397 c |= 0x01; // set tRP = 3T
401 Determine RAS to CAS delay (tRCD)
403 Read SPD byte 29, min row pre-charge time.
406 b = smbus_read_byte(0x50, SPD_MIN_RAS_TO_CAS_DELAY);
407 //print_val("\r\ntRCD ",b);
409 if ( b >= (5 * bank)) c |= 0x0C; // set tRCD = 5T
410 else if ( b >= (4 * bank)) c |= 0x08; // set tRCD = 4T
411 else if ( b >= (3 * bank)) c |= 0x04; // set tRCD = 3T
414 Determine RAS pulse width (tRAS)
417 Read SPD byte 30, device min active to pre-charge time.
420 /* tRAS is in whole ns */
423 b = smbus_read_byte(0x50, SPD_MIN_ACTIVE_TO_PRECHARGE_DELAY);
424 //print_val("\r\ntRAS ",b);
425 //print_val("\r\nBank ", bank);
426 if ( b >= (9 * bank)) c |= 0xC0; // set tRAS = 9T
427 else if ( b >= (8 * bank)) c |= 0x80; // set tRAS = 8T
428 else if ( b >= (7 * bank)) c |= 0x40; // set tRAS = 7T
430 /* Write DRAM Timing All Banks I */
431 pci_write_config8(ctrl.d0f3, 0x56, c);
433 /* TWrite DRAM Timing All Banks II */
434 pci_write_config8(ctrl.d0f3, 0x57, 0x1a);
436 /* DRAM arbitration timer */
437 pci_write_config8(ctrl.d0f3, 0x65, 0x99);
440 DRAM Clock Device 0 Fn 3 Offset 68
442 bank = smbus_read_byte(0x50, SPD_MIN_CYCLE_TIME_AT_CAS_MAX);
444 /* Setup DRAM Cycle Time */
447 /* DRAM DDR Control Alert! Alert! See also c3_cpu_setup */
448 /* This sets to 133MHz FSB / DDR400. */
449 pci_write_config8(ctrl.d0f3, 0x68, 0x85);
451 else if (bank <= 0x60)
453 /* DRAM DDR Control Alert! Alert! This hardwires to */
454 /* 133MHz FSB / DDR333. See also c3_cpu_setup */
455 pci_write_config8(ctrl.d0f3, 0x68, 0x81);
459 /* DRAM DDR Control Alert! Alert! This hardwires to */
460 /* 133MHz FSB / DDR266. See also c3_cpu_setup */
461 pci_write_config8(ctrl.d0f3, 0x68, 0x80);
464 /* Delay >= 100ns after DRAM Frequency adjust, See 4.1.1.3 pg 15 */
468 Determine bank interleave
470 Read SPD byte 17, Number of banks on SDRAM device.
473 b = smbus_read_byte(0x50, SPD_NUM_BANKS_PER_SDRAM);
474 if( b == 4) c |= 0x80;
475 else if (b == 2) c |= 0x40;
477 /* 4-Way Interleave With Multi-Paging (From Running System)*/
478 pci_write_config8(ctrl.d0f3, 0x69, c);
480 /*DRAM Controller Internal Options */
481 pci_write_config8(ctrl.d0f3, 0x54, 0x01);
483 /* DRAM Arbitration Control */
484 pci_write_config8(ctrl.d0f3, 0x66, 0x82);
487 pci_write_config8(ctrl.d0f3, 0x6e, 0x80);
489 /* Disable refresh for now */
490 pci_write_config8(ctrl.d0f3, 0x6a, 0x00);
492 /* DDR Clock Gen Duty Cycle Control */
493 pci_write_config8(ctrl.d0f3, 0xEE, 0x01);
496 /* DRAM Clock Control */
497 pci_write_config8(ctrl.d0f3, 0x6c, 0x00);
499 /* DRAM Bus Turn-Around Setting */
500 pci_write_config8(ctrl.d0f3, 0x60, 0x01);
502 /* Disable DRAM refresh */
503 pci_write_config8(ctrl.d0f3,0x6a,0x0);
506 /* Memory Pads Driving and Range Select */
507 pci_write_config8(ctrl.d0f3, 0xe2, 0xAA);
508 pci_write_config8(ctrl.d0f3, 0xe3, 0x00);
509 pci_write_config8(ctrl.d0f3, 0xe4, 0x99);
511 /* DRAM signal timing control */
512 pci_write_config8(ctrl.d0f3, 0x74, 0x99);
513 pci_write_config8(ctrl.d0f3, 0x76, 0x09);
514 pci_write_config8(ctrl.d0f3, 0x77, 0x12);
516 pci_write_config8(ctrl.d0f3, 0xe0, 0xAA);
517 pci_write_config8(ctrl.d0f3, 0xe1, 0x00);
518 pci_write_config8(ctrl.d0f3, 0xe6, 0x00);
519 pci_write_config8(ctrl.d0f3, 0xe8, 0xEE);
520 pci_write_config8(ctrl.d0f3, 0xea, 0xEE);
523 /* SPD byte 5 # of physical banks */
524 b = smbus_read_byte(0x50, SPD_NUM_DIMM_BANKS) -1;
527 pci_write_config8(ctrl.d0f3, 0xb0, c);
529 /* Set RAM Decode method */
530 pci_write_config8(ctrl.d0f3, 0x55, 0x0a);
532 /* Enable DIMM Ranks */
533 pci_write_config8(ctrl.d0f3, 0x48, ma);
536 c = smbus_read_byte(0x50, SPD_SUPPORTED_BURST_LENGTHS);
540 print_debug("Setting Burst Length 8\r\n");
542 CPU Frequency Device 0 Function 2 Offset 54
544 CPU FSB Operating Frequency (bits 7:5)
545 000 : 100MHz 001 : 133MHz
551 Don't change Frequency from power up defaults
552 This seems to lockup the RAM interface
554 c = pci_read_config8(ctrl.d0f2, 0x54);
556 pci_write_config8(ctrl.d0f2, 0x54, c);
557 i = 0x008; // Used later to set SDRAM MSR
561 for( bank = 0 , bank_address=0; bank <= b ; bank++) {
563 DDR init described in Via VT8623 BIOS Porting Guide. Pg 28 (4.2.3.1)
566 /* NOP command enable */
567 c = pci_read_config8(ctrl.d0f3, DRAM_MISC_CTL);
568 c &= 0xf8; /* Clear bits 2-0. */
569 c |= RAM_COMMAND_NOP;
570 pci_write_config8(ctrl.d0f3, DRAM_MISC_CTL, c);
572 /* read a double word from any address of the dimm */
573 dimm_read(bank_address,0x1f000);
576 /* All bank precharge Command Enable */
577 c = pci_read_config8(ctrl.d0f3, DRAM_MISC_CTL);
578 c &= 0xf8; /* Clear bits 2-0. */
579 c |= RAM_COMMAND_PRECHARGE;
580 pci_write_config8(ctrl.d0f3, DRAM_MISC_CTL, c);
581 dimm_read(bank_address,0x1f000);
584 /* MSR Enable Low DIMM*/
585 c = pci_read_config8(ctrl.d0f3, DRAM_MISC_CTL);
586 c &= 0xf8; /* Clear bits 2-0. */
587 c |= RAM_COMMAND_MSR_LOW;
588 pci_write_config8(ctrl.d0f3, DRAM_MISC_CTL, c);
589 /* TODO: Bank Addressing for Different Numbers of Row Addresses */
590 dimm_read(bank_address,0x2000);
592 dimm_read(bank_address,0x800);
595 /* All banks precharge Command Enable */
596 c = pci_read_config8(ctrl.d0f3, DRAM_MISC_CTL);
597 c &= 0xf8; /* Clear bits 2-0. */
598 c |= RAM_COMMAND_PRECHARGE;
599 pci_write_config8(ctrl.d0f3, DRAM_MISC_CTL, c);
600 dimm_read(bank_address,0x1f200);
602 /* CBR Cycle Enable */
603 c = pci_read_config8(ctrl.d0f3, DRAM_MISC_CTL);
604 c &= 0xf8; /* Clear bits 2-0. */
605 c |= RAM_COMMAND_CBR;
606 pci_write_config8(ctrl.d0f3, DRAM_MISC_CTL, c);
610 dimm_read(bank_address,0x1f300);
615 c = pci_read_config8(ctrl.d0f3, DRAM_MISC_CTL);
616 c &= 0xf8; /* Clear bits 2-0. */
617 c |= RAM_COMMAND_MSR_LOW;
618 pci_write_config8(ctrl.d0f3, DRAM_MISC_CTL, c);
622 Mode Register Definition
623 with adjustement so that address calculation is correct - 64 bit technology, therefore
624 a0-a2 refer to byte within a 64 bit long word, and a3 is the first address line presented
625 to DIMM as a row or column address.
628 MR[6] Burst Type 0 = sequential, 1 = interleaved
629 MR[5-3] burst length 001 = 2, 010 = 4, 011 = 8, others reserved
642 CAS 2 0101011000 = 0x158
643 CAS 2.5 1101011000 = 0x358
644 CAS 3 0111011000 = 0x1d8
647 c = pci_read_config8(ctrl.d0f3, 0x56);
648 if( (c & 0x30) == 0x10 )
649 dimm_read(bank_address,(0x150 + i));
650 else if((c & 0x30) == 0x20 )
651 dimm_read(bank_address,(0x350 + i));
653 dimm_read(bank_address,(0x1d0 + i));
656 /* Normal SDRAM Mode */
657 c = pci_read_config8(ctrl.d0f3, DRAM_MISC_CTL);
658 c &= 0xf8; /* Clear bits 2-0. */
659 c |= RAM_COMMAND_NORMAL;
660 pci_write_config8(ctrl.d0f3, DRAM_MISC_CTL, c);
662 bank_address = pci_read_config8(ctrl.d0f3,0x40+bank) * 0x2000000;
663 } // end of for each bank
666 /* Set DRAM DQS Output Control */
667 pci_write_config8(ctrl.d0f3, 0x79, 0x11);
669 /* Set DQS A/B Input delay to defaults */
670 pci_write_config8(ctrl.d0f3, 0x7A, 0xA1);
671 pci_write_config8(ctrl.d0f3, 0x7B, 0x62);
673 /* DQS Duty Cycle Control */
674 pci_write_config8(ctrl.d0f3, 0xED, 0x11);
676 /* SPD byte 5 # of physical banks */
677 b = smbus_read_byte(0x50, SPD_NUM_DIMM_BANKS) -1;
679 /* determine low bond */
681 bank_address = pci_read_config8(ctrl.d0f3,0x40) * 0x2000000;
685 for(i = 0x30 ; i < 0x0ff; i++){
686 pci_write_config8(ctrl.d0f3,0x70,i);
688 *(volatile unsigned long*)(0x4000) = 0;
689 *(volatile unsigned long*)(0x4100+bank_address) = 0;
690 *(volatile unsigned long*)(0x4200) = 0;
691 *(volatile unsigned long*)(0x4300+bank_address) = 0;
692 *(volatile unsigned long*)(0x4400) = 0;
693 *(volatile unsigned long*)(0x4500+bank_address) = 0;
696 *(volatile unsigned long*)(0x4000) = 0x12345678;
697 *(volatile unsigned long*)(0x4100+bank_address) = 0x81234567;
698 *(volatile unsigned long*)(0x4200) = 0x78123456;
699 *(volatile unsigned long*)(0x4300+bank_address) = 0x67812345;
700 *(volatile unsigned long*)(0x4400) = 0x56781234;
701 *(volatile unsigned long*)(0x4500+bank_address) = 0x45678123;
704 if( *(volatile unsigned long*)(0x4000) != 0x12345678)
707 if( *(volatile unsigned long*)(0x4100+bank_address) != 0x81234567)
710 if( *(volatile unsigned long*)(0x4200) != 0x78123456)
713 if( *(volatile unsigned long*)(0x4300+bank_address) != 0x67812345)
716 if( *(volatile unsigned long*)(0x4400) != 0x56781234)
719 if( *(volatile unsigned long*)(0x4500+bank_address) != 0x45678123)
722 // if everything verified then found low bond
726 print_val("\r\nLow Bond ",i);
729 for( ; i <0xff ; i++){
730 pci_write_config8(ctrl.d0f3,0x70, i);
732 *(volatile unsigned long*)(0x8000) = 0;
733 *(volatile unsigned long*)(0x8100+bank_address) = 0;
734 *(volatile unsigned long*)(0x8200) = 0x0;
735 *(volatile unsigned long*)(0x8300+bank_address) = 0;
736 *(volatile unsigned long*)(0x8400) = 0x0;
737 *(volatile unsigned long*)(0x8500+bank_address) = 0;
740 *(volatile unsigned long*)(0x8000) = 0x12345678;
741 *(volatile unsigned long*)(0x8100+bank_address) = 0x81234567;
742 *(volatile unsigned long*)(0x8200) = 0x78123456;
743 *(volatile unsigned long*)(0x8300+bank_address) = 0x67812345;
744 *(volatile unsigned long*)(0x8400) = 0x56781234;
745 *(volatile unsigned long*)(0x8500+bank_address) = 0x45678123;
748 if( *(volatile unsigned long*)(0x8000) != 0x12345678)
751 if( *(volatile unsigned long*)(0x8100+bank_address) != 0x81234567)
754 if( *(volatile unsigned long*)(0x8200) != 0x78123456)
757 if( *(volatile unsigned long*)(0x8300+bank_address) != 0x67812345)
760 if( *(volatile unsigned long*)(0x8400) != 0x56781234)
763 if( *(volatile unsigned long*)(0x8500+bank_address) != 0x45678123)
767 print_val(" High Bond ",i);
768 c = ((i - c)<<1)/3 + c;
769 print_val(" Setting DQS delay",c);
771 pci_write_config8(ctrl.d0f3,0x70,c);
773 pci_write_config8(ctrl.d0f3,0x70,0x67);
776 /* Set DQS ChA Data Output Delay to the default */
777 pci_write_config8(ctrl.d0f3, 0x71, 0x65);
779 /* Set Ch B DQS Output Delays */
780 pci_write_config8(ctrl.d0f3, 0x72, 0x2a);
781 pci_write_config8(ctrl.d0f3, 0x73, 0x29);
783 pci_write_config8(ctrl.d0f3, 0x78, 0x03);
786 pci_write_config8(ctrl.d0f3, 0x67, 0x50);
788 /* Enable Toggle Limiting */
789 pci_write_config8(ctrl.d0f4, 0xA3, 0x80);
792 DRAM refresh rate Device 0 F3 Offset 6a
793 TODO :: Fix for different DRAM technologies
794 other than 512Mb and DRAM Freq
795 Units of 16 DRAM clock cycles - 1.
797 //c = pci_read_config8(ctrl.d0f3, 0x68);
799 //b = smbus_read_byte(0x50, SPD_REFRESH);
800 //print_val("SPD_REFRESH = ", b);
802 pci_write_config8(ctrl.d0f3,0x6a,0x65);
804 /* SMM and APIC decoding, we do not use SMM */
806 pci_write_config8(ctrl.d0f3, 0x86, b);
807 /* SMM and APIC decoding mirror */
808 pci_write_config8(ctrl.d0f7, 0xe6, b);
810 /* Open Up the Rest of the Shadow RAM */
811 pci_write_config8(ctrl.d0f3,0x80,0xff);
812 pci_write_config8(ctrl.d0f3,0x81,0xff);
815 pci_write_config8(ctrl.d0f7,0x70,0x82);
816 pci_write_config8(ctrl.d0f7,0x73,0x01);
817 pci_write_config8(ctrl.d0f7,0x76,0x50);
819 pci_write_config8(ctrl.d0f7,0x71,0xc8);
823 pci_write_config16(ctrl.d0f3, 0xa0, (1 << 15));
824 pci_write_config16(ctrl.d0f3, 0xa4, 0x0010);
825 print_debug("CN400 raminit.c done\r\n");