2 * This file is part of the coreboot project.
4 * Copyright (C) 2005 Nick Barker <nick.barker9@btinternet.com>
5 * Copyright (C) 2009 Jon Harrison <bothlyn@blueyonder.co.uk
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
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*/
33 #include <cpu/x86/mtrr.h>
36 static void dimm_read(unsigned long bank,unsigned long x)
39 volatile unsigned long y;
41 y = * (volatile unsigned long *) (x+ bank) ;
46 static void print_val(char *str, int val)
49 print_debug_hex8(val);
53 * Configure the bus between the CPU and the northbridge. This might be able to
54 * be moved to post-ram code in the future. For the most part, these registers
55 * should not be messed around with. These are too complex to explain short of
56 * copying the datasheets into the comments, but most of these values are from
57 * the BIOS Porting Guide, so they should work on any board. If they don't,
58 * try the values from your factory BIOS.
60 * TODO: Changing the DRAM frequency doesn't work (hard lockup).
62 * @param dev The northbridge's CPU Host Interface (D0F2).
64 static void c3_cpu_setup(device_t dev)
66 /* Host bus interface registers (D0F2 0x50-0x67) */
67 /* Taken from CN700 and updated from running CN400 */
70 /* Host Bus I/O Circuit (see datasheet) */
71 /* Host Address Pullup/down Driving */
72 pci_write_config8(dev, 0x70, 0x33);
73 pci_write_config8(dev, 0x71, 0x44);
74 pci_write_config8(dev, 0x72, 0x33);
75 pci_write_config8(dev, 0x73, 0x44);
77 /* Output Delay Stagger Control */
78 pci_write_config8(dev, 0x74, 0x70);
80 /* AGTL+ I/O Circuit */
81 pci_write_config8(dev, 0x75, 0x08);
83 /* AGTL+ Compensation Status */
84 pci_write_config8(dev, 0x76, 0x74);
86 /* AGTL+ Auto Compensation Offest */
87 pci_write_config8(dev, 0x77, 0x00);
88 pci_write_config8(dev, 0x78, 0x94);
90 /* Request phase control */
91 pci_write_config8(dev, 0x50, 0xA8);
93 /* Line DRDY# Timing Control */
94 pci_write_config8(dev, 0x60, 0x00);
95 pci_write_config8(dev, 0x61, 0x00);
96 pci_write_config8(dev, 0x62, 0x00);
98 /* QW DRDY# Timing Control */
99 pci_write_config8(dev, 0x63, 0x00);
100 pci_write_config8(dev, 0x64, 0x00);
101 pci_write_config8(dev, 0x65, 0x00);
103 /* Read Line Burst DRDY# Timing Control */
104 pci_write_config8(dev, 0x66, 0x00);
105 pci_write_config8(dev, 0x67, 0x00);
107 /* CPU Interface Control */
108 pci_write_config8(dev, 0x51, 0xFE);
109 pci_write_config8(dev, 0x52, 0xEF);
112 pci_write_config8(dev, 0x53, 0x88);
114 /* Write Policy & Reorder Latecy */
115 pci_write_config8(dev, 0x56, 0x00);
117 /* Delivery-Trigger Control */
118 pci_write_config8(dev, 0x58, 0x00);
121 pci_write_config8(dev, 0x59, 0x30);
123 /* CPU Misc Control */
124 pci_write_config8(dev, 0x5C, 0x00);
127 pci_write_config8(dev, 0x5d, 0xb2);
129 /* Bandwidth Timer */
130 pci_write_config8(dev, 0x5e, 0x88);
132 /* CPU Miscellaneous Control */
133 pci_write_config8(dev, 0x5f, 0xc7);
135 /* CPU Miscellaneous Control */
136 pci_write_config8(dev, 0x55, 0x28);
137 pci_write_config8(dev, 0x57, 0x69);
139 /* CPU Host Bus Final Setup */
140 reg8 = pci_read_config8(dev, 0x54);
142 pci_write_config8(dev, 0x54, reg8);
146 static void ddr_ram_setup(void)
148 uint8_t b, c, bank, ma;
150 unsigned long bank_address;
153 print_debug("CN400 RAM init starting\n");
155 pci_write_config8(ctrl.d0f7, 0x75, 0x08);
158 /* No Interleaving or Multi Page */
159 pci_write_config8(ctrl.d0f3, 0x69, 0x00);
160 pci_write_config8(ctrl.d0f3, 0x6b, 0x10);
163 DRAM MA Map Type Device 0 Fn3 Offset 50-51
165 Determine memory addressing based on the module's memory technology and
166 arrangement. See Table 4-9 of Intel's 82443GX datasheet for details.
168 Bank 1/0 MA map type 50[7-5]
169 Bank 1/0 command rate 50[4]
170 Bank 3/2 MA map type 50[3-1]
171 Bank 3/2 command rate 50[0]
174 Read SPD byte 17, Number of banks on SDRAM device.
177 b = smbus_read_byte(0x50, SPD_NUM_BANKS_PER_SDRAM);
178 //print_val("Detecting Memory\nNumber of Banks ",b);
180 // Only supporting 4 bank chips just now
183 Read SPD byte 3, Number of row addresses.
187 b = smbus_read_byte(0x50, SPD_NUM_ROWS);
188 //print_val("\nNumber of Rows ", b);
190 if( b >= 0x0d ){ // 256/512Mb
198 Read SPD byte 13, Primary DRAM width.
200 b = smbus_read_byte(0x50, SPD_PRIMARY_SDRAM_WIDTH);
201 //print_val("\nPrimary DRAM width", b);
202 if( b != 4 ) // not 64/128Mb (x4)
207 Read SPD byte 4, Number of column addresses.
209 b = smbus_read_byte(0x50, SPD_NUM_COLUMNS);
210 //print_val("\nNo Columns ",b);
211 if( b == 10 || b == 11 || b == 12) c |= 0x60; // 10/11 bit col addr
212 if( b == 9 ) c |= 0x40; // 9 bit col addr
213 if( b == 8 ) c |= 0x20; // 8 bit col addr
215 //print_val("\nMA type ", c);
216 pci_write_config8(ctrl.d0f3, 0x50, c);
220 /* Disable Upper Banks */
221 pci_write_config8(ctrl.d0f3, 0x51, 0x00);
225 die("DRAM module size is not supported by CN400\n");
230 DRAM bank size. See 4.3.1 pg 35
232 5a->5d set to end address for each bank. 1 bit == 32MB
235 5c = bank 0 + b1 + b2
236 5d = bank 0 + b1 + b2 + b3
239 // Read SPD byte 31 Module bank density
241 b = smbus_read_byte(0x50, SPD_DENSITY_OF_EACH_ROW_ON_MODULE);
250 if (bank == 0x48) bank |= 0x01;
256 if (bank == 0x44) bank |= 0x02;
261 if (bank == 0x44) bank |= 0x01;
267 if (bank == 0x40) bank |= 0x02;
274 else if( b & 0x08) c = 0x01; // 32MB
275 else c = 0x01; // Error, use default
277 // set bank zero size
278 pci_write_config8(ctrl.d0f3, 0x40, c);
280 // SPD byte 5 # of physical banks
281 b = smbus_read_byte(0x50, SPD_NUM_DIMM_BANKS);
283 //print_val("\nNo Physical Banks ",b);
291 die("Only a single DIMM is supported by EPIA-N(L)\n");
294 // set banks 1,2,3...
295 pci_write_config8(ctrl.d0f3, 0x41,c);
296 pci_write_config8(ctrl.d0f3, 0x42,c);
297 pci_write_config8(ctrl.d0f3, 0x43,c);
298 pci_write_config8(ctrl.d0f3, 0x44,c);
299 pci_write_config8(ctrl.d0f3, 0x45,c);
300 pci_write_config8(ctrl.d0f3, 0x46,c);
301 pci_write_config8(ctrl.d0f3, 0x47,c);
303 /* Top Rank Address Mirrored to the South Bridge */
305 pci_write_config8(ctrl.d0f7, 0x57, (c << 1));
309 /* Read SPD byte 18 CAS Latency */
310 b = smbus_read_byte(0x50, SPD_ACCEPTABLE_CAS_LATENCIES);
311 /* print_debug("\nCAS Supported ");
319 c = smbus_read_byte(0x50, SPD_MIN_CYCLE_TIME_AT_CAS_MAX);
320 print_val("\nCycle time at CL X (nS)", c);
321 c = smbus_read_byte(0x50, SPD_SDRAM_CYCLE_TIME_2ND);
322 print_val("\nCycle time at CL X-0.5 (nS)", c);
323 c = smbus_read_byte(0x50, SPD_SDRAM_CYCLE_TIME_3RD);
324 print_val("\nCycle time at CL X-1 (nS)", c);
326 /* Scaling of Cycle Time SPD data */
329 bank = smbus_read_byte(0x50, SPD_MIN_CYCLE_TIME_AT_CAS_MAX);
331 if( b & 0x10 ){ // DDR offering optional CAS 3
332 //print_debug("\nStarting at CAS 3");
334 /* see if we can better it */
335 if( b & 0x08 ){ // DDR mandatory CAS 2.5
336 if( smbus_read_byte(0x50, SPD_SDRAM_CYCLE_TIME_2ND) <= bank ){ // we can manage max MHz at CAS 2.5
337 //print_debug("\nWe can do CAS 2.5");
341 if( b & 0x04 ){ // DDR mandatory CAS 2
342 if( smbus_read_byte(0x50, SPD_SDRAM_CYCLE_TIME_3RD) <= bank ){ // we can manage max Mhz at CAS 2
343 //print_debug("\nWe can do CAS 2");
347 }else{ // no optional CAS values just 2 & 2.5
348 //print_debug("\nStarting at CAS 2.5");
349 c = 0x20; // assume CAS 2.5
350 if( b & 0x04){ // Should always happen
351 if( smbus_read_byte(0x50, SPD_SDRAM_CYCLE_TIME_2ND) <= bank){ // we can manage max Mhz at CAS 2
352 //print_debug("\nWe can do CAS 2");
358 /* Scale DRAM Cycle Time to tRP/tRCD */
361 if ( bank <= 0x50 ) bank = 0x14;
362 else if (bank <= 0x60) bank = 0x18;
366 DRAM Timing Device 0 Fn 3 Offset 56
368 RAS Pulse width 56[7,6]
370 Row pre-charge 56[1,0]
378 RAS/CAS delay 56[3,2]
380 Determine row pre-charge time (tRP)
383 Read SPD byte 27, min row pre-charge time.
386 b = smbus_read_byte(0x50, SPD_MIN_ROW_PRECHARGE_TIME);
388 //print_val("\ntRP ",b);
389 if ( b >= (5 * bank)) {
390 c |= 0x03; // set tRP = 5T
392 else if ( b >= (4 * bank)) {
393 c |= 0x02; // set tRP = 4T
395 else if ( b >= (3 * bank)) {
396 c |= 0x01; // set tRP = 3T
400 Determine RAS to CAS delay (tRCD)
402 Read SPD byte 29, min row pre-charge time.
405 b = smbus_read_byte(0x50, SPD_MIN_RAS_TO_CAS_DELAY);
406 //print_val("\ntRCD ",b);
408 if ( b >= (5 * bank)) c |= 0x0C; // set tRCD = 5T
409 else if ( b >= (4 * bank)) c |= 0x08; // set tRCD = 4T
410 else if ( b >= (3 * bank)) c |= 0x04; // set tRCD = 3T
413 Determine RAS pulse width (tRAS)
416 Read SPD byte 30, device min active to pre-charge time.
419 /* tRAS is in whole ns */
422 b = smbus_read_byte(0x50, SPD_MIN_ACTIVE_TO_PRECHARGE_DELAY);
423 //print_val("\ntRAS ",b);
424 //print_val("\nBank ", bank);
425 if ( b >= (9 * bank)) c |= 0xC0; // set tRAS = 9T
426 else if ( b >= (8 * bank)) c |= 0x80; // set tRAS = 8T
427 else if ( b >= (7 * bank)) c |= 0x40; // set tRAS = 7T
429 /* Write DRAM Timing All Banks I */
430 pci_write_config8(ctrl.d0f3, 0x56, c);
432 /* TWrite DRAM Timing All Banks II */
433 pci_write_config8(ctrl.d0f3, 0x57, 0x1a);
435 /* DRAM arbitration timer */
436 pci_write_config8(ctrl.d0f3, 0x65, 0x99);
439 DRAM Clock Device 0 Fn 3 Offset 68
441 bank = smbus_read_byte(0x50, SPD_MIN_CYCLE_TIME_AT_CAS_MAX);
443 /* Setup DRAM Cycle Time */
446 /* DRAM DDR Control Alert! Alert! See also c3_cpu_setup */
447 /* This sets to 133MHz FSB / DDR400. */
448 pci_write_config8(ctrl.d0f3, 0x68, 0x85);
450 else if (bank <= 0x60)
452 /* DRAM DDR Control Alert! Alert! This hardwires to */
453 /* 133MHz FSB / DDR333. See also c3_cpu_setup */
454 pci_write_config8(ctrl.d0f3, 0x68, 0x81);
458 /* DRAM DDR Control Alert! Alert! This hardwires to */
459 /* 133MHz FSB / DDR266. See also c3_cpu_setup */
460 pci_write_config8(ctrl.d0f3, 0x68, 0x80);
463 /* Delay >= 100ns after DRAM Frequency adjust, See 4.1.1.3 pg 15 */
467 Determine bank interleave
469 Read SPD byte 17, Number of banks on SDRAM device.
472 b = smbus_read_byte(0x50, SPD_NUM_BANKS_PER_SDRAM);
473 if( b == 4) c |= 0x80;
474 else if (b == 2) c |= 0x40;
476 /* 4-Way Interleave With Multi-Paging (From Running System)*/
477 pci_write_config8(ctrl.d0f3, 0x69, c);
479 /*DRAM Controller Internal Options */
480 pci_write_config8(ctrl.d0f3, 0x54, 0x01);
482 /* DRAM Arbitration Control */
483 pci_write_config8(ctrl.d0f3, 0x66, 0x82);
486 pci_write_config8(ctrl.d0f3, 0x6e, 0x80);
488 /* Disable refresh for now */
489 pci_write_config8(ctrl.d0f3, 0x6a, 0x00);
491 /* DDR Clock Gen Duty Cycle Control */
492 pci_write_config8(ctrl.d0f3, 0xEE, 0x01);
495 /* DRAM Clock Control */
496 pci_write_config8(ctrl.d0f3, 0x6c, 0x00);
498 /* DRAM Bus Turn-Around Setting */
499 pci_write_config8(ctrl.d0f3, 0x60, 0x01);
501 /* Disable DRAM refresh */
502 pci_write_config8(ctrl.d0f3,0x6a,0x0);
505 /* Memory Pads Driving and Range Select */
506 pci_write_config8(ctrl.d0f3, 0xe2, 0xAA);
507 pci_write_config8(ctrl.d0f3, 0xe3, 0x00);
508 pci_write_config8(ctrl.d0f3, 0xe4, 0x99);
510 /* DRAM signal timing control */
511 pci_write_config8(ctrl.d0f3, 0x74, 0x99);
512 pci_write_config8(ctrl.d0f3, 0x76, 0x09);
513 pci_write_config8(ctrl.d0f3, 0x77, 0x12);
515 pci_write_config8(ctrl.d0f3, 0xe0, 0xAA);
516 pci_write_config8(ctrl.d0f3, 0xe1, 0x00);
517 pci_write_config8(ctrl.d0f3, 0xe6, 0x00);
518 pci_write_config8(ctrl.d0f3, 0xe8, 0xEE);
519 pci_write_config8(ctrl.d0f3, 0xea, 0xEE);
522 /* SPD byte 5 # of physical banks */
523 b = smbus_read_byte(0x50, SPD_NUM_DIMM_BANKS) -1;
526 pci_write_config8(ctrl.d0f3, 0xb0, c);
528 /* Set RAM Decode method */
529 pci_write_config8(ctrl.d0f3, 0x55, 0x0a);
531 /* Enable DIMM Ranks */
532 pci_write_config8(ctrl.d0f3, 0x48, ma);
535 c = smbus_read_byte(0x50, SPD_SUPPORTED_BURST_LENGTHS);
539 print_debug("Setting Burst Length 8\n");
541 CPU Frequency Device 0 Function 2 Offset 54
543 CPU FSB Operating Frequency (bits 7:5)
544 000 : 100MHz 001 : 133MHz
550 Don't change Frequency from power up defaults
551 This seems to lockup the RAM interface
553 c = pci_read_config8(ctrl.d0f2, 0x54);
555 pci_write_config8(ctrl.d0f2, 0x54, c);
556 i = 0x008; // Used later to set SDRAM MSR
560 for( bank = 0 , bank_address=0; bank <= b ; bank++) {
562 DDR init described in Via VT8623 BIOS Porting Guide. Pg 28 (4.2.3.1)
565 /* NOP command enable */
566 c = pci_read_config8(ctrl.d0f3, DRAM_MISC_CTL);
567 c &= 0xf8; /* Clear bits 2-0. */
568 c |= RAM_COMMAND_NOP;
569 pci_write_config8(ctrl.d0f3, DRAM_MISC_CTL, c);
571 /* read a double word from any address of the dimm */
572 dimm_read(bank_address,0x1f000);
575 /* All bank precharge Command Enable */
576 c = pci_read_config8(ctrl.d0f3, DRAM_MISC_CTL);
577 c &= 0xf8; /* Clear bits 2-0. */
578 c |= RAM_COMMAND_PRECHARGE;
579 pci_write_config8(ctrl.d0f3, DRAM_MISC_CTL, c);
580 dimm_read(bank_address,0x1f000);
583 /* MSR Enable Low DIMM*/
584 c = pci_read_config8(ctrl.d0f3, DRAM_MISC_CTL);
585 c &= 0xf8; /* Clear bits 2-0. */
586 c |= RAM_COMMAND_MSR_LOW;
587 pci_write_config8(ctrl.d0f3, DRAM_MISC_CTL, c);
588 /* TODO: Bank Addressing for Different Numbers of Row Addresses */
589 dimm_read(bank_address,0x2000);
591 dimm_read(bank_address,0x800);
594 /* All banks precharge Command Enable */
595 c = pci_read_config8(ctrl.d0f3, DRAM_MISC_CTL);
596 c &= 0xf8; /* Clear bits 2-0. */
597 c |= RAM_COMMAND_PRECHARGE;
598 pci_write_config8(ctrl.d0f3, DRAM_MISC_CTL, c);
599 dimm_read(bank_address,0x1f200);
601 /* CBR Cycle Enable */
602 c = pci_read_config8(ctrl.d0f3, DRAM_MISC_CTL);
603 c &= 0xf8; /* Clear bits 2-0. */
604 c |= RAM_COMMAND_CBR;
605 pci_write_config8(ctrl.d0f3, DRAM_MISC_CTL, c);
609 dimm_read(bank_address,0x1f300);
614 c = pci_read_config8(ctrl.d0f3, DRAM_MISC_CTL);
615 c &= 0xf8; /* Clear bits 2-0. */
616 c |= RAM_COMMAND_MSR_LOW;
617 pci_write_config8(ctrl.d0f3, DRAM_MISC_CTL, c);
621 Mode Register Definition
622 with adjustement so that address calculation is correct - 64 bit technology, therefore
623 a0-a2 refer to byte within a 64 bit long word, and a3 is the first address line presented
624 to DIMM as a row or column address.
627 MR[6] Burst Type 0 = sequential, 1 = interleaved
628 MR[5-3] burst length 001 = 2, 010 = 4, 011 = 8, others reserved
641 CAS 2 0101011000 = 0x158
642 CAS 2.5 1101011000 = 0x358
643 CAS 3 0111011000 = 0x1d8
646 c = pci_read_config8(ctrl.d0f3, 0x56);
647 if( (c & 0x30) == 0x10 )
648 dimm_read(bank_address,(0x150 + i));
649 else if((c & 0x30) == 0x20 )
650 dimm_read(bank_address,(0x350 + i));
652 dimm_read(bank_address,(0x1d0 + i));
655 /* Normal SDRAM Mode */
656 c = pci_read_config8(ctrl.d0f3, DRAM_MISC_CTL);
657 c &= 0xf8; /* Clear bits 2-0. */
658 c |= RAM_COMMAND_NORMAL;
659 pci_write_config8(ctrl.d0f3, DRAM_MISC_CTL, c);
661 bank_address = pci_read_config8(ctrl.d0f3,0x40+bank) * 0x2000000;
662 } // end of for each bank
665 /* Set DRAM DQS Output Control */
666 pci_write_config8(ctrl.d0f3, 0x79, 0x11);
668 /* Set DQS A/B Input delay to defaults */
669 pci_write_config8(ctrl.d0f3, 0x7A, 0xA1);
670 pci_write_config8(ctrl.d0f3, 0x7B, 0x62);
672 /* DQS Duty Cycle Control */
673 pci_write_config8(ctrl.d0f3, 0xED, 0x11);
675 /* SPD byte 5 # of physical banks */
676 b = smbus_read_byte(0x50, SPD_NUM_DIMM_BANKS) -1;
678 /* determine low bond */
680 bank_address = pci_read_config8(ctrl.d0f3,0x40) * 0x2000000;
684 for(i = 0x30 ; i < 0x0ff; i++){
685 pci_write_config8(ctrl.d0f3,0x70,i);
687 *(volatile unsigned long*)(0x4000) = 0;
688 *(volatile unsigned long*)(0x4100+bank_address) = 0;
689 *(volatile unsigned long*)(0x4200) = 0;
690 *(volatile unsigned long*)(0x4300+bank_address) = 0;
691 *(volatile unsigned long*)(0x4400) = 0;
692 *(volatile unsigned long*)(0x4500+bank_address) = 0;
695 *(volatile unsigned long*)(0x4000) = 0x12345678;
696 *(volatile unsigned long*)(0x4100+bank_address) = 0x81234567;
697 *(volatile unsigned long*)(0x4200) = 0x78123456;
698 *(volatile unsigned long*)(0x4300+bank_address) = 0x67812345;
699 *(volatile unsigned long*)(0x4400) = 0x56781234;
700 *(volatile unsigned long*)(0x4500+bank_address) = 0x45678123;
703 if( *(volatile unsigned long*)(0x4000) != 0x12345678)
706 if( *(volatile unsigned long*)(0x4100+bank_address) != 0x81234567)
709 if( *(volatile unsigned long*)(0x4200) != 0x78123456)
712 if( *(volatile unsigned long*)(0x4300+bank_address) != 0x67812345)
715 if( *(volatile unsigned long*)(0x4400) != 0x56781234)
718 if( *(volatile unsigned long*)(0x4500+bank_address) != 0x45678123)
721 // if everything verified then found low bond
725 print_val("\nLow Bond ",i);
728 for( ; i <0xff ; i++){
729 pci_write_config8(ctrl.d0f3,0x70, i);
731 *(volatile unsigned long*)(0x8000) = 0;
732 *(volatile unsigned long*)(0x8100+bank_address) = 0;
733 *(volatile unsigned long*)(0x8200) = 0x0;
734 *(volatile unsigned long*)(0x8300+bank_address) = 0;
735 *(volatile unsigned long*)(0x8400) = 0x0;
736 *(volatile unsigned long*)(0x8500+bank_address) = 0;
739 *(volatile unsigned long*)(0x8000) = 0x12345678;
740 *(volatile unsigned long*)(0x8100+bank_address) = 0x81234567;
741 *(volatile unsigned long*)(0x8200) = 0x78123456;
742 *(volatile unsigned long*)(0x8300+bank_address) = 0x67812345;
743 *(volatile unsigned long*)(0x8400) = 0x56781234;
744 *(volatile unsigned long*)(0x8500+bank_address) = 0x45678123;
747 if( *(volatile unsigned long*)(0x8000) != 0x12345678)
750 if( *(volatile unsigned long*)(0x8100+bank_address) != 0x81234567)
753 if( *(volatile unsigned long*)(0x8200) != 0x78123456)
756 if( *(volatile unsigned long*)(0x8300+bank_address) != 0x67812345)
759 if( *(volatile unsigned long*)(0x8400) != 0x56781234)
762 if( *(volatile unsigned long*)(0x8500+bank_address) != 0x45678123)
766 print_val(" High Bond ",i);
767 c = ((i - c)<<1)/3 + c;
768 print_val(" Setting DQS delay",c);
770 pci_write_config8(ctrl.d0f3,0x70,c);
772 pci_write_config8(ctrl.d0f3,0x70,0x67);
775 /* Set DQS ChA Data Output Delay to the default */
776 pci_write_config8(ctrl.d0f3, 0x71, 0x65);
778 /* Set Ch B DQS Output Delays */
779 pci_write_config8(ctrl.d0f3, 0x72, 0x2a);
780 pci_write_config8(ctrl.d0f3, 0x73, 0x29);
782 pci_write_config8(ctrl.d0f3, 0x78, 0x03);
785 pci_write_config8(ctrl.d0f3, 0x67, 0x50);
787 /* Enable Toggle Limiting */
788 pci_write_config8(ctrl.d0f4, 0xA3, 0x80);
791 DRAM refresh rate Device 0 F3 Offset 6a
792 TODO :: Fix for different DRAM technologies
793 other than 512Mb and DRAM Freq
794 Units of 16 DRAM clock cycles - 1.
796 //c = pci_read_config8(ctrl.d0f3, 0x68);
798 //b = smbus_read_byte(0x50, SPD_REFRESH);
799 //print_val("SPD_REFRESH = ", b);
801 pci_write_config8(ctrl.d0f3,0x6a,0x65);
803 /* SMM and APIC decoding, we do not use SMM */
805 pci_write_config8(ctrl.d0f3, 0x86, b);
806 /* SMM and APIC decoding mirror */
807 pci_write_config8(ctrl.d0f7, 0xe6, b);
809 /* Open Up the Rest of the Shadow RAM */
810 pci_write_config8(ctrl.d0f3,0x80,0xff);
811 pci_write_config8(ctrl.d0f3,0x81,0xff);
814 pci_write_config8(ctrl.d0f7,0x70,0x82);
815 pci_write_config8(ctrl.d0f7,0x73,0x01);
816 pci_write_config8(ctrl.d0f7,0x76,0x50);
818 pci_write_config8(ctrl.d0f7,0x71,0xc8);
822 pci_write_config16(ctrl.d0f3, 0xa0, (1 << 15));
823 pci_write_config16(ctrl.d0f3, 0xa4, 0x0010);
824 print_debug("CN400 raminit.c done\n");