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(DIMM0, SPD_NUM_BANKS_PER_SDRAM);
178 //print_val("Detecting Memory\nNumber of Banks ",b);
180 // Only supporting 4 bank chips just now
182 /* Read SPD byte 3, Number of row addresses. */
185 b = smbus_read_byte(DIMM0, SPD_NUM_ROWS);
186 //print_val("\nNumber of Rows ", b);
188 if( b >= 0x0d ){ // 256/512Mb
195 /* Read SPD byte 13, Primary DRAM width. */
196 b = smbus_read_byte(DIMM0, SPD_PRIMARY_SDRAM_WIDTH);
197 //print_val("\nPrimary DRAM width", b);
198 if( b != 4 ) // not 64/128Mb (x4)
202 /* Read SPD byte 4, Number of column addresses. */
203 b = smbus_read_byte(DIMM0, SPD_NUM_COLUMNS);
204 //print_val("\nNo Columns ",b);
205 if( b == 10 || b == 11 || b == 12) c |= 0x60; // 10/11 bit col addr
206 if( b == 9 ) c |= 0x40; // 9 bit col addr
207 if( b == 8 ) c |= 0x20; // 8 bit col addr
209 //print_val("\nMA type ", c);
210 pci_write_config8(ctrl.d0f3, 0x50, c);
214 /* Disable Upper Banks */
215 pci_write_config8(ctrl.d0f3, 0x51, 0x00);
219 die("DRAM module size is not supported by CN400\n");
224 DRAM bank size. See 4.3.1 pg 35
226 5a->5d set to end address for each bank. 1 bit == 32MB
229 5c = bank 0 + b1 + b2
230 5d = bank 0 + b1 + b2 + b3
233 // Read SPD byte 31 Module bank density
235 b = smbus_read_byte(DIMM0, SPD_DENSITY_OF_EACH_ROW_ON_MODULE);
244 if (bank == 0x48) bank |= 0x01;
250 if (bank == 0x44) bank |= 0x02;
255 if (bank == 0x44) bank |= 0x01;
261 if (bank == 0x40) bank |= 0x02;
268 else if( b & 0x08) c = 0x01; // 32MB
269 else c = 0x01; // Error, use default
271 // set bank zero size
272 pci_write_config8(ctrl.d0f3, 0x40, c);
274 // SPD byte 5 # of physical banks
275 b = smbus_read_byte(DIMM0, SPD_NUM_DIMM_BANKS);
277 //print_val("\nNo Physical Banks ",b);
285 die("Only a single DIMM is supported by EPIA-N(L)\n");
288 // set banks 1,2,3...
289 pci_write_config8(ctrl.d0f3, 0x41,c);
290 pci_write_config8(ctrl.d0f3, 0x42,c);
291 pci_write_config8(ctrl.d0f3, 0x43,c);
292 pci_write_config8(ctrl.d0f3, 0x44,c);
293 pci_write_config8(ctrl.d0f3, 0x45,c);
294 pci_write_config8(ctrl.d0f3, 0x46,c);
295 pci_write_config8(ctrl.d0f3, 0x47,c);
297 /* Top Rank Address Mirrored to the South Bridge */
299 pci_write_config8(ctrl.d0f7, 0x57, (c << 1));
303 /* Read SPD byte 18 CAS Latency */
304 b = smbus_read_byte(DIMM0, SPD_ACCEPTABLE_CAS_LATENCIES);
305 /* print_debug("\nCAS Supported ");
313 c = smbus_read_byte(DIMM0, SPD_MIN_CYCLE_TIME_AT_CAS_MAX);
314 print_val("\nCycle time at CL X (nS)", c);
315 c = smbus_read_byte(DIMM0, SPD_SDRAM_CYCLE_TIME_2ND);
316 print_val("\nCycle time at CL X-0.5 (nS)", c);
317 c = smbus_read_byte(DIMM0, SPD_SDRAM_CYCLE_TIME_3RD);
318 print_val("\nCycle time at CL X-1 (nS)", c);
320 /* Scaling of Cycle Time SPD data */
323 bank = smbus_read_byte(DIMM0, SPD_MIN_CYCLE_TIME_AT_CAS_MAX);
325 if( b & 0x10 ){ // DDR offering optional CAS 3
326 //print_debug("\nStarting at CAS 3");
328 /* see if we can better it */
329 if( b & 0x08 ){ // DDR mandatory CAS 2.5
330 if( smbus_read_byte(DIMM0, SPD_SDRAM_CYCLE_TIME_2ND) <= bank ){ // we can manage max MHz at CAS 2.5
331 //print_debug("\nWe can do CAS 2.5");
335 if( b & 0x04 ){ // DDR mandatory CAS 2
336 if( smbus_read_byte(DIMM0, SPD_SDRAM_CYCLE_TIME_3RD) <= bank ){ // we can manage max Mhz at CAS 2
337 //print_debug("\nWe can do CAS 2");
341 }else{ // no optional CAS values just 2 & 2.5
342 //print_debug("\nStarting at CAS 2.5");
343 c = 0x20; // assume CAS 2.5
344 if( b & 0x04){ // Should always happen
345 if( smbus_read_byte(DIMM0, SPD_SDRAM_CYCLE_TIME_2ND) <= bank){ // we can manage max Mhz at CAS 2
346 //print_debug("\nWe can do CAS 2");
352 /* Scale DRAM Cycle Time to tRP/tRCD */
355 if ( bank <= 0x50 ) bank = 0x14;
356 else if (bank <= 0x60) bank = 0x18;
360 DRAM Timing Device 0 Fn 3 Offset 56
362 RAS Pulse width 56[7,6]
364 Row pre-charge 56[1,0]
372 RAS/CAS delay 56[3,2]
374 Determine row pre-charge time (tRP)
377 Read SPD byte 27, min row pre-charge time.
380 b = smbus_read_byte(DIMM0, SPD_MIN_ROW_PRECHARGE_TIME);
382 //print_val("\ntRP ",b);
383 if ( b >= (5 * bank)) {
384 c |= 0x03; // set tRP = 5T
386 else if ( b >= (4 * bank)) {
387 c |= 0x02; // set tRP = 4T
389 else if ( b >= (3 * bank)) {
390 c |= 0x01; // set tRP = 3T
394 Determine RAS to CAS delay (tRCD)
396 Read SPD byte 29, min row pre-charge time.
399 b = smbus_read_byte(DIMM0, SPD_MIN_RAS_TO_CAS_DELAY);
400 //print_val("\ntRCD ",b);
402 if ( b >= (5 * bank)) c |= 0x0C; // set tRCD = 5T
403 else if ( b >= (4 * bank)) c |= 0x08; // set tRCD = 4T
404 else if ( b >= (3 * bank)) c |= 0x04; // set tRCD = 3T
407 Determine RAS pulse width (tRAS)
410 Read SPD byte 30, device min active to pre-charge time.
413 /* tRAS is in whole ns */
416 b = smbus_read_byte(DIMM0, SPD_MIN_ACTIVE_TO_PRECHARGE_DELAY);
417 //print_val("\ntRAS ",b);
418 //print_val("\nBank ", bank);
419 if ( b >= (9 * bank)) c |= 0xC0; // set tRAS = 9T
420 else if ( b >= (8 * bank)) c |= 0x80; // set tRAS = 8T
421 else if ( b >= (7 * bank)) c |= 0x40; // set tRAS = 7T
423 /* Write DRAM Timing All Banks I */
424 pci_write_config8(ctrl.d0f3, 0x56, c);
426 /* TWrite DRAM Timing All Banks II */
427 pci_write_config8(ctrl.d0f3, 0x57, 0x1a);
429 /* DRAM arbitration timer */
430 pci_write_config8(ctrl.d0f3, 0x65, 0x99);
433 DRAM Clock Device 0 Fn 3 Offset 68
435 bank = smbus_read_byte(DIMM0, SPD_MIN_CYCLE_TIME_AT_CAS_MAX);
437 /* Setup DRAM Cycle Time */
440 /* DRAM DDR Control Alert! Alert! See also c3_cpu_setup */
441 /* This sets to 133MHz FSB / DDR400. */
442 pci_write_config8(ctrl.d0f3, 0x68, 0x85);
444 else if (bank <= 0x60)
446 /* DRAM DDR Control Alert! Alert! This hardwires to */
447 /* 133MHz FSB / DDR333. See also c3_cpu_setup */
448 pci_write_config8(ctrl.d0f3, 0x68, 0x81);
452 /* DRAM DDR Control Alert! Alert! This hardwires to */
453 /* 133MHz FSB / DDR266. See also c3_cpu_setup */
454 pci_write_config8(ctrl.d0f3, 0x68, 0x80);
457 /* Delay >= 100ns after DRAM Frequency adjust, See 4.1.1.3 pg 15 */
461 Determine bank interleave
463 Read SPD byte 17, Number of banks on SDRAM device.
466 b = smbus_read_byte(DIMM0, SPD_NUM_BANKS_PER_SDRAM);
467 if( b == 4) c |= 0x80;
468 else if (b == 2) c |= 0x40;
470 /* 4-Way Interleave With Multi-Paging (From Running System)*/
471 pci_write_config8(ctrl.d0f3, 0x69, c);
473 /*DRAM Controller Internal Options */
474 pci_write_config8(ctrl.d0f3, 0x54, 0x01);
476 /* DRAM Arbitration Control */
477 pci_write_config8(ctrl.d0f3, 0x66, 0x82);
480 pci_write_config8(ctrl.d0f3, 0x6e, 0x80);
482 /* Disable refresh for now */
483 pci_write_config8(ctrl.d0f3, 0x6a, 0x00);
485 /* DDR Clock Gen Duty Cycle Control */
486 pci_write_config8(ctrl.d0f3, 0xEE, 0x01);
489 /* DRAM Clock Control */
490 pci_write_config8(ctrl.d0f3, 0x6c, 0x00);
492 /* DRAM Bus Turn-Around Setting */
493 pci_write_config8(ctrl.d0f3, 0x60, 0x01);
495 /* Disable DRAM refresh */
496 pci_write_config8(ctrl.d0f3,0x6a,0x0);
499 /* Memory Pads Driving and Range Select */
500 pci_write_config8(ctrl.d0f3, 0xe2, 0xAA);
501 pci_write_config8(ctrl.d0f3, 0xe3, 0x00);
502 pci_write_config8(ctrl.d0f3, 0xe4, 0x99);
504 /* DRAM signal timing control */
505 pci_write_config8(ctrl.d0f3, 0x74, 0x99);
506 pci_write_config8(ctrl.d0f3, 0x76, 0x09);
507 pci_write_config8(ctrl.d0f3, 0x77, 0x12);
509 pci_write_config8(ctrl.d0f3, 0xe0, 0xAA);
510 pci_write_config8(ctrl.d0f3, 0xe1, 0x00);
511 pci_write_config8(ctrl.d0f3, 0xe6, 0x00);
512 pci_write_config8(ctrl.d0f3, 0xe8, 0xEE);
513 pci_write_config8(ctrl.d0f3, 0xea, 0xEE);
516 /* SPD byte 5 # of physical banks */
517 b = smbus_read_byte(DIMM0, SPD_NUM_DIMM_BANKS) -1;
520 pci_write_config8(ctrl.d0f3, 0xb0, c);
522 /* Set RAM Decode method */
523 pci_write_config8(ctrl.d0f3, 0x55, 0x0a);
525 /* Enable DIMM Ranks */
526 pci_write_config8(ctrl.d0f3, 0x48, ma);
529 c = smbus_read_byte(DIMM0, SPD_SUPPORTED_BURST_LENGTHS);
533 print_debug("Setting Burst Length 8\n");
535 CPU Frequency Device 0 Function 2 Offset 54
537 CPU FSB Operating Frequency (bits 7:5)
538 000 : 100MHz 001 : 133MHz
544 Don't change Frequency from power up defaults
545 This seems to lockup the RAM interface
547 c = pci_read_config8(ctrl.d0f2, 0x54);
549 pci_write_config8(ctrl.d0f2, 0x54, c);
550 i = 0x008; // Used later to set SDRAM MSR
554 for( bank = 0 , bank_address=0; bank <= b ; bank++) {
556 DDR init described in Via VT8623 BIOS Porting Guide. Pg 28 (4.2.3.1)
559 /* NOP command enable */
560 c = pci_read_config8(ctrl.d0f3, DRAM_MISC_CTL);
561 c &= 0xf8; /* Clear bits 2-0. */
562 c |= RAM_COMMAND_NOP;
563 pci_write_config8(ctrl.d0f3, DRAM_MISC_CTL, c);
565 /* read a double word from any address of the dimm */
566 dimm_read(bank_address,0x1f000);
569 /* All bank precharge Command Enable */
570 c = pci_read_config8(ctrl.d0f3, DRAM_MISC_CTL);
571 c &= 0xf8; /* Clear bits 2-0. */
572 c |= RAM_COMMAND_PRECHARGE;
573 pci_write_config8(ctrl.d0f3, DRAM_MISC_CTL, c);
574 dimm_read(bank_address,0x1f000);
577 /* MSR Enable Low DIMM*/
578 c = pci_read_config8(ctrl.d0f3, DRAM_MISC_CTL);
579 c &= 0xf8; /* Clear bits 2-0. */
580 c |= RAM_COMMAND_MSR_LOW;
581 pci_write_config8(ctrl.d0f3, DRAM_MISC_CTL, c);
582 /* TODO: Bank Addressing for Different Numbers of Row Addresses */
583 dimm_read(bank_address,0x2000);
585 dimm_read(bank_address,0x800);
588 /* All banks precharge Command Enable */
589 c = pci_read_config8(ctrl.d0f3, DRAM_MISC_CTL);
590 c &= 0xf8; /* Clear bits 2-0. */
591 c |= RAM_COMMAND_PRECHARGE;
592 pci_write_config8(ctrl.d0f3, DRAM_MISC_CTL, c);
593 dimm_read(bank_address,0x1f200);
595 /* CBR Cycle Enable */
596 c = pci_read_config8(ctrl.d0f3, DRAM_MISC_CTL);
597 c &= 0xf8; /* Clear bits 2-0. */
598 c |= RAM_COMMAND_CBR;
599 pci_write_config8(ctrl.d0f3, DRAM_MISC_CTL, c);
603 dimm_read(bank_address,0x1f300);
608 c = pci_read_config8(ctrl.d0f3, DRAM_MISC_CTL);
609 c &= 0xf8; /* Clear bits 2-0. */
610 c |= RAM_COMMAND_MSR_LOW;
611 pci_write_config8(ctrl.d0f3, DRAM_MISC_CTL, c);
615 Mode Register Definition
616 with adjustement so that address calculation is correct - 64 bit technology, therefore
617 a0-a2 refer to byte within a 64 bit long word, and a3 is the first address line presented
618 to DIMM as a row or column address.
621 MR[6] Burst Type 0 = sequential, 1 = interleaved
622 MR[5-3] burst length 001 = 2, 010 = 4, 011 = 8, others reserved
635 CAS 2 0101011000 = 0x158
636 CAS 2.5 1101011000 = 0x358
637 CAS 3 0111011000 = 0x1d8
640 c = pci_read_config8(ctrl.d0f3, 0x56);
641 if( (c & 0x30) == 0x10 )
642 dimm_read(bank_address,(0x150 + i));
643 else if((c & 0x30) == 0x20 )
644 dimm_read(bank_address,(0x350 + i));
646 dimm_read(bank_address,(0x1d0 + i));
649 /* Normal SDRAM Mode */
650 c = pci_read_config8(ctrl.d0f3, DRAM_MISC_CTL);
651 c &= 0xf8; /* Clear bits 2-0. */
652 c |= RAM_COMMAND_NORMAL;
653 pci_write_config8(ctrl.d0f3, DRAM_MISC_CTL, c);
655 bank_address = pci_read_config8(ctrl.d0f3,0x40+bank) * 0x2000000;
656 } // end of for each bank
659 /* Set DRAM DQS Output Control */
660 pci_write_config8(ctrl.d0f3, 0x79, 0x11);
662 /* Set DQS A/B Input delay to defaults */
663 pci_write_config8(ctrl.d0f3, 0x7A, 0xA1);
664 pci_write_config8(ctrl.d0f3, 0x7B, 0x62);
666 /* DQS Duty Cycle Control */
667 pci_write_config8(ctrl.d0f3, 0xED, 0x11);
669 /* SPD byte 5 # of physical banks */
670 b = smbus_read_byte(DIMM0, SPD_NUM_DIMM_BANKS) -1;
672 /* determine low bond */
674 bank_address = pci_read_config8(ctrl.d0f3,0x40) * 0x2000000;
678 for(i = 0x30 ; i < 0x0ff; i++){
679 pci_write_config8(ctrl.d0f3,0x70,i);
681 *(volatile unsigned long*)(0x4000) = 0;
682 *(volatile unsigned long*)(0x4100+bank_address) = 0;
683 *(volatile unsigned long*)(0x4200) = 0;
684 *(volatile unsigned long*)(0x4300+bank_address) = 0;
685 *(volatile unsigned long*)(0x4400) = 0;
686 *(volatile unsigned long*)(0x4500+bank_address) = 0;
689 *(volatile unsigned long*)(0x4000) = 0x12345678;
690 *(volatile unsigned long*)(0x4100+bank_address) = 0x81234567;
691 *(volatile unsigned long*)(0x4200) = 0x78123456;
692 *(volatile unsigned long*)(0x4300+bank_address) = 0x67812345;
693 *(volatile unsigned long*)(0x4400) = 0x56781234;
694 *(volatile unsigned long*)(0x4500+bank_address) = 0x45678123;
697 if( *(volatile unsigned long*)(0x4000) != 0x12345678)
700 if( *(volatile unsigned long*)(0x4100+bank_address) != 0x81234567)
703 if( *(volatile unsigned long*)(0x4200) != 0x78123456)
706 if( *(volatile unsigned long*)(0x4300+bank_address) != 0x67812345)
709 if( *(volatile unsigned long*)(0x4400) != 0x56781234)
712 if( *(volatile unsigned long*)(0x4500+bank_address) != 0x45678123)
715 // if everything verified then found low bond
719 print_val("\nLow Bond ",i);
722 for( ; i <0xff ; i++){
723 pci_write_config8(ctrl.d0f3,0x70, i);
725 *(volatile unsigned long*)(0x8000) = 0;
726 *(volatile unsigned long*)(0x8100+bank_address) = 0;
727 *(volatile unsigned long*)(0x8200) = 0x0;
728 *(volatile unsigned long*)(0x8300+bank_address) = 0;
729 *(volatile unsigned long*)(0x8400) = 0x0;
730 *(volatile unsigned long*)(0x8500+bank_address) = 0;
733 *(volatile unsigned long*)(0x8000) = 0x12345678;
734 *(volatile unsigned long*)(0x8100+bank_address) = 0x81234567;
735 *(volatile unsigned long*)(0x8200) = 0x78123456;
736 *(volatile unsigned long*)(0x8300+bank_address) = 0x67812345;
737 *(volatile unsigned long*)(0x8400) = 0x56781234;
738 *(volatile unsigned long*)(0x8500+bank_address) = 0x45678123;
741 if( *(volatile unsigned long*)(0x8000) != 0x12345678)
744 if( *(volatile unsigned long*)(0x8100+bank_address) != 0x81234567)
747 if( *(volatile unsigned long*)(0x8200) != 0x78123456)
750 if( *(volatile unsigned long*)(0x8300+bank_address) != 0x67812345)
753 if( *(volatile unsigned long*)(0x8400) != 0x56781234)
756 if( *(volatile unsigned long*)(0x8500+bank_address) != 0x45678123)
760 print_val(" High Bond ",i);
761 c = ((i - c)<<1)/3 + c;
762 print_val(" Setting DQS delay",c);
764 pci_write_config8(ctrl.d0f3,0x70,c);
766 pci_write_config8(ctrl.d0f3,0x70,0x67);
769 /* Set DQS ChA Data Output Delay to the default */
770 pci_write_config8(ctrl.d0f3, 0x71, 0x65);
772 /* Set Ch B DQS Output Delays */
773 pci_write_config8(ctrl.d0f3, 0x72, 0x2a);
774 pci_write_config8(ctrl.d0f3, 0x73, 0x29);
776 pci_write_config8(ctrl.d0f3, 0x78, 0x03);
779 pci_write_config8(ctrl.d0f3, 0x67, 0x50);
781 /* Enable Toggle Limiting */
782 pci_write_config8(ctrl.d0f4, 0xA3, 0x80);
785 DRAM refresh rate Device 0 F3 Offset 6a
786 TODO :: Fix for different DRAM technologies
787 other than 512Mb and DRAM Freq
788 Units of 16 DRAM clock cycles - 1.
790 //c = pci_read_config8(ctrl.d0f3, 0x68);
792 //b = smbus_read_byte(DIMM0, SPD_REFRESH);
793 //print_val("SPD_REFRESH = ", b);
795 pci_write_config8(ctrl.d0f3,0x6a,0x65);
797 /* SMM and APIC decoding, we do not use SMM */
799 pci_write_config8(ctrl.d0f3, 0x86, b);
800 /* SMM and APIC decoding mirror */
801 pci_write_config8(ctrl.d0f7, 0xe6, b);
803 /* Open Up the Rest of the Shadow RAM */
804 pci_write_config8(ctrl.d0f3,0x80,0xff);
805 pci_write_config8(ctrl.d0f3,0x81,0xff);
808 pci_write_config8(ctrl.d0f7,0x70,0x82);
809 pci_write_config8(ctrl.d0f7,0x73,0x01);
810 pci_write_config8(ctrl.d0f7,0x76,0x50);
812 pci_write_config8(ctrl.d0f7,0x71,0xc8);
816 pci_write_config16(ctrl.d0f3, 0xa0, (1 << 15));
817 pci_write_config16(ctrl.d0f3, 0xa4, 0x0010);
818 print_debug("CN400 raminit.c done\n");