3 * Josh Huber <huber@mclx.com>, Mission Critical Linux, Inc.
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
24 /*************************************************************************
25 * adaption for the Marvell DB64360 Board
26 * Ingo Assmus (ingo.assmus@keymile.com)
28 * adaption for the cpci750 Board
29 * Reinhard Arlt (reinhard.arlt@esd-electronics.com)
30 *************************************************************************/
33 /* sdram_init.c - automatic memory sizing */
37 #include "../../Marvell/include/memory.h"
38 #include "../../Marvell/include/pci.h"
39 #include "../../Marvell/include/mv_gen_reg.h"
44 #include "../../Marvell/common/i2c.h"
48 DECLARE_GLOBAL_DATA_PTR;
54 #endif /* of CONFIG_PCI */
62 int set_dfcdlInit(void); /* setup delay line of Mv64360 */
64 /* ------------------------------------------------------------------------- */
67 memory_map_bank(unsigned int bankNo,
68 unsigned int bankBase,
69 unsigned int bankLength)
78 printf("mapping bank %d at %08x - %08x\n",
79 bankNo, bankBase, bankBase + bankLength - 1);
81 printf("unmapping bank %d\n", bankNo);
85 memoryMapBank(bankNo, bankBase, bankLength);
88 for (host=PCI_HOST0;host<=PCI_HOST1;host++) {
93 READ_LINE_AGGRESSIVE_PREFETCH |
94 READ_MULTI_AGGRESSIVE_PREFETCH |
98 pciMapMemoryBank(host, bankNo, bankBase, bankLength);
100 pciSetRegionSnoopMode(host, bankNo, PCI_SNOOP_WB, bankBase,
103 pciSetRegionFeatures(host, bankNo, features, bankBase, bankLength);
111 /* much of this code is based on (or is) the code in the pip405 port */
112 /* thanks go to the authors of said port - Josh */
114 /* structure to store the relevant information about an sdram bank */
115 typedef struct sdram_info {
117 uchar registered, ecc;
124 /* Typedefs for 'gtAuxilGetDIMMinfo' function */
126 typedef enum _memoryType {SDRAM, DDR} MEMORY_TYPE;
128 typedef enum _voltageInterface {TTL_5V_TOLERANT, LVTTL, HSTL_1_5V,
129 SSTL_3_3V, SSTL_2_5V, VOLTAGE_UNKNOWN,
132 typedef enum _max_CL_supported_DDR {DDR_CL_1=1, DDR_CL_1_5=2, DDR_CL_2=4, DDR_CL_2_5=8, DDR_CL_3=16, DDR_CL_3_5=32, DDR_CL_FAULT} MAX_CL_SUPPORTED_DDR;
133 typedef enum _max_CL_supported_SD {SD_CL_1=1, SD_CL_2, SD_CL_3, SD_CL_4, SD_CL_5, SD_CL_6, SD_CL_7, SD_FAULT} MAX_CL_SUPPORTED_SD;
136 /* SDRAM/DDR information struct */
137 typedef struct _gtMemoryDimmInfo
139 MEMORY_TYPE memoryType;
140 unsigned int numOfRowAddresses;
141 unsigned int numOfColAddresses;
142 unsigned int numOfModuleBanks;
143 unsigned int dataWidth;
144 VOLTAGE_INTERFACE voltageInterface;
145 unsigned int errorCheckType; /* ECC , PARITY..*/
146 unsigned int sdramWidth; /* 4,8,16 or 32 */;
147 unsigned int errorCheckDataWidth; /* 0 - no, 1 - Yes */
148 unsigned int minClkDelay;
149 unsigned int burstLengthSupported;
150 unsigned int numOfBanksOnEachDevice;
151 unsigned int suportedCasLatencies;
152 unsigned int RefreshInterval;
153 unsigned int maxCASlatencySupported_LoP; /* LoP left of point (measured in ns) */
154 unsigned int maxCASlatencySupported_RoP; /* RoP right of point (measured in ns)*/
155 MAX_CL_SUPPORTED_DDR maxClSupported_DDR;
156 MAX_CL_SUPPORTED_SD maxClSupported_SD;
157 unsigned int moduleBankDensity;
158 /* module attributes (true for yes) */
159 bool bufferedAddrAndControlInputs;
160 bool registeredAddrAndControlInputs;
162 bool bufferedDQMBinputs;
163 bool registeredDQMBinputs;
164 bool differentialClockInput;
165 bool redundantRowAddressing;
167 /* module general attributes */
168 bool suportedAutoPreCharge;
169 bool suportedPreChargeAll;
170 bool suportedEarlyRasPreCharge;
171 bool suportedWrite1ReadBurst;
172 bool suported5PercentLowVCC;
173 bool suported5PercentUpperVCC;
174 /* module timing parameters */
175 unsigned int minRasToCasDelay;
176 unsigned int minRowActiveRowActiveDelay;
177 unsigned int minRasPulseWidth;
178 unsigned int minRowPrechargeTime; /* measured in ns */
180 int addrAndCommandHoldTime; /* LoP left of point (measured in ns) */
181 int addrAndCommandSetupTime; /* (measured in ns/100) */
182 int dataInputSetupTime; /* LoP left of point (measured in ns) */
183 int dataInputHoldTime; /* LoP left of point (measured in ns) */
184 /* tAC times for highest 2nd and 3rd highest CAS Latency values */
185 unsigned int clockToDataOut_LoP; /* LoP left of point (measured in ns) */
186 unsigned int clockToDataOut_RoP; /* RoP right of point (measured in ns)*/
187 unsigned int clockToDataOutMinus1_LoP; /* LoP left of point (measured in ns) */
188 unsigned int clockToDataOutMinus1_RoP; /* RoP right of point (measured in ns)*/
189 unsigned int clockToDataOutMinus2_LoP; /* LoP left of point (measured in ns) */
190 unsigned int clockToDataOutMinus2_RoP; /* RoP right of point (measured in ns)*/
192 unsigned int minimumCycleTimeAtMaxCasLatancy_LoP; /* LoP left of point (measured in ns) */
193 unsigned int minimumCycleTimeAtMaxCasLatancy_RoP; /* RoP right of point (measured in ns)*/
195 unsigned int minimumCycleTimeAtMaxCasLatancyMinus1_LoP; /* LoP left of point (measured in ns) */
196 unsigned int minimumCycleTimeAtMaxCasLatancyMinus1_RoP; /* RoP right of point (measured in ns)*/
198 unsigned int minimumCycleTimeAtMaxCasLatancyMinus2_LoP; /* LoP left of point (measured in ns) */
199 unsigned int minimumCycleTimeAtMaxCasLatancyMinus2_RoP; /* RoP right of point (measured in ns)*/
201 /* Parameters calculated from
202 the extracted DIMM information */
204 unsigned int deviceDensity; /* 16,64,128,256 or 512 Mbit */
205 unsigned int numberOfDevices;
206 uchar drb_size; /* DRAM size in n*64Mbit */
207 uchar slot; /* Slot Number this module is inserted in */
208 uchar spd_raw_data[128]; /* Content of SPD-EEPROM copied 1:1 */
210 uchar manufactura[8]; /* Content of SPD-EEPROM Byte 64-71 */
211 uchar modul_id[18]; /* Content of SPD-EEPROM Byte 73-90 */
212 uchar vendor_data[27]; /* Content of SPD-EEPROM Byte 99-125 */
213 unsigned long modul_serial_no; /* Content of SPD-EEPROM Byte 95-98 */
214 unsigned int manufac_date; /* Content of SPD-EEPROM Byte 93-94 */
215 unsigned int modul_revision; /* Content of SPD-EEPROM Byte 91-92 */
216 uchar manufac_place; /* Content of SPD-EEPROM Byte 72 */
223 * translate ns.ns/10 coding of SPD timing values
224 * into 10 ps unit values
226 static inline unsigned short
227 NS10to10PS(unsigned char spd_byte)
229 unsigned short ns, ns10;
231 /* isolate upper nibble */
232 ns = (spd_byte >> 4) & 0x0F;
233 /* isolate lower nibble */
234 ns10 = (spd_byte & 0x0F);
236 return(ns*100 + ns10*10);
240 * translate ns coding of SPD timing values
241 * into 10 ps unit values
243 static inline unsigned short
244 NSto10PS(unsigned char spd_byte)
246 return(spd_byte*100);
249 /* This code reads the SPD chip on the sdram and populates
250 * the array which is passed in with the relevant information */
251 /* static int check_dimm(uchar slot, AUX_MEM_DIMM_INFO *info) */
252 static int check_dimm (uchar slot, AUX_MEM_DIMM_INFO * dimmInfo)
254 unsigned long spd_checksum;
256 uchar addr = slot == 0 ? DIMM0_I2C_ADDR : DIMM1_I2C_ADDR;
258 unsigned int i, j, density = 1, devicesForErrCheck = 0;
263 unsigned int rightOfPoint = 0, leftOfPoint = 0, mult, div, time_tmp;
264 int sign = 1, shift, maskLeftOfPoint, maskRightOfPoint;
265 uchar supp_cal, cal_val;
266 ulong memclk, tmemclk;
268 uchar trp_clocks = 0, trcd_clocks, tras_clocks, trrd_clocks;
271 memclk = gd->bus_clk;
272 tmemclk = 1000000000 / (memclk / 100); /* in 10 ps units */
274 memset (data, 0, sizeof (data));
279 DP (puts ("before i2c read\n"));
281 ret = i2c_read (addr, 0, 2, data, 128);
283 DP (puts ("after i2c read\n"));
285 if ((data[64] != 'e') || (data[65] != 's') || (data[66] != 'd')
286 || (data[67] != '-') || (data[68] != 'g') || (data[69] != 'm')
287 || (data[70] != 'b') || (data[71] != 'h')) {
291 if ((ret != 0) && (slot == 0)) {
292 memset (data, 0, sizeof (data));
340 /* zero all the values */
341 memset (dimmInfo, 0, sizeof (*dimmInfo));
343 /* copy the SPD content 1:1 into the dimmInfo structure */
344 for (i = 0; i <= 127; i++) {
345 dimmInfo->spd_raw_data[i] = data[i];
349 DP (printf ("No DIMM in slot %d [err = %x]\n", slot, ret));
352 dimmInfo->slot = slot; /* start to fill up dimminfo for this "slot" */
354 #ifdef CFG_DISPLAY_DIMM_SPD_CONTENT
356 for (i = 0; i <= 127; i++) {
357 printf ("SPD-EEPROM Byte %3d = %3x (%3d)\n", i, data[i],
363 /* find Manufacturer of Dimm Module */
364 for (i = 0; i < sizeof (dimmInfo->manufactura); i++) {
365 dimmInfo->manufactura[i] = data[64 + i];
367 printf ("\nThis RAM-Module is produced by: %s\n",
368 dimmInfo->manufactura);
370 /* find Manul-ID of Dimm Module */
371 for (i = 0; i < sizeof (dimmInfo->modul_id); i++) {
372 dimmInfo->modul_id[i] = data[73 + i];
374 printf ("The Module-ID of this RAM-Module is: %s\n",
377 /* find Vendor-Data of Dimm Module */
378 for (i = 0; i < sizeof (dimmInfo->vendor_data); i++) {
379 dimmInfo->vendor_data[i] = data[99 + i];
381 printf ("Vendor Data of this RAM-Module is: %s\n",
382 dimmInfo->vendor_data);
384 /* find modul_serial_no of Dimm Module */
385 dimmInfo->modul_serial_no = (*((unsigned long *) (&data[95])));
386 printf ("Serial No. of this RAM-Module is: %ld (%lx)\n",
387 dimmInfo->modul_serial_no, dimmInfo->modul_serial_no);
389 /* find Manufac-Data of Dimm Module */
390 dimmInfo->manufac_date = (*((unsigned int *) (&data[93])));
391 printf ("Manufactoring Date of this RAM-Module is: %d.%d\n", data[93], data[94]); /*dimmInfo->manufac_date */
393 /* find modul_revision of Dimm Module */
394 dimmInfo->modul_revision = (*((unsigned int *) (&data[91])));
395 printf ("Module Revision of this RAM-Module is: %d.%d\n", data[91], data[92]); /* dimmInfo->modul_revision */
397 /* find manufac_place of Dimm Module */
398 dimmInfo->manufac_place = (*((unsigned char *) (&data[72])));
399 printf ("manufac_place of this RAM-Module is: %d\n",
400 dimmInfo->manufac_place);
403 /*------------------------------------------------------------------------------------------------------------------------------*/
404 /* calculate SPD checksum */
405 /*------------------------------------------------------------------------------------------------------------------------------*/
407 #if 0 /* test-only */
408 for (i = 0; i <= 62; i++) {
409 spd_checksum += data[i];
412 if ((spd_checksum & 0xff) != data[63]) {
413 printf ("### Error in SPD Checksum !!! Is_value: %2x should value %2x\n", (unsigned int) (spd_checksum & 0xff), data[63]);
418 printf ("SPD Checksum ok!\n");
419 #endif /* test-only */
421 /*------------------------------------------------------------------------------------------------------------------------------*/
422 for (i = 2; i <= 35; i++) {
424 case 2: /* Memory type (DDR / SDRAM) */
425 dimmInfo->memoryType = (data[i] == 0x7) ? DDR : SDRAM;
427 if (dimmInfo->memoryType == 0)
429 ("Dram_type in slot %d is: SDRAM\n",
431 if (dimmInfo->memoryType == 1)
433 ("Dram_type in slot %d is: DDRAM\n",
437 /*------------------------------------------------------------------------------------------------------------------------------*/
439 case 3: /* Number Of Row Addresses */
440 dimmInfo->numOfRowAddresses = data[i];
442 ("Module Number of row addresses: %d\n",
443 dimmInfo->numOfRowAddresses));
445 /*------------------------------------------------------------------------------------------------------------------------------*/
447 case 4: /* Number Of Column Addresses */
448 dimmInfo->numOfColAddresses = data[i];
450 ("Module Number of col addresses: %d\n",
451 dimmInfo->numOfColAddresses));
453 /*------------------------------------------------------------------------------------------------------------------------------*/
455 case 5: /* Number Of Module Banks */
456 dimmInfo->numOfModuleBanks = data[i];
458 ("Number of Banks on Mod. : %d\n",
459 dimmInfo->numOfModuleBanks));
461 /*------------------------------------------------------------------------------------------------------------------------------*/
463 case 6: /* Data Width */
464 dimmInfo->dataWidth = data[i];
466 ("Module Data Width: %d\n",
467 dimmInfo->dataWidth));
469 /*------------------------------------------------------------------------------------------------------------------------------*/
471 case 8: /* Voltage Interface */
474 dimmInfo->voltageInterface = TTL_5V_TOLERANT;
476 ("Module is TTL_5V_TOLERANT\n"));
479 dimmInfo->voltageInterface = LVTTL;
481 ("Module is LVTTL\n"));
484 dimmInfo->voltageInterface = HSTL_1_5V;
486 ("Module is TTL_5V_TOLERANT\n"));
489 dimmInfo->voltageInterface = SSTL_3_3V;
491 ("Module is HSTL_1_5V\n"));
494 dimmInfo->voltageInterface = SSTL_2_5V;
496 ("Module is SSTL_2_5V\n"));
499 dimmInfo->voltageInterface = VOLTAGE_UNKNOWN;
501 ("Module is VOLTAGE_UNKNOWN\n"));
505 /*------------------------------------------------------------------------------------------------------------------------------*/
507 case 9: /* Minimum Cycle Time At Max CasLatancy */
508 shift = (dimmInfo->memoryType == DDR) ? 4 : 2;
509 mult = (dimmInfo->memoryType == DDR) ? 10 : 25;
511 (dimmInfo->memoryType == DDR) ? 0xf0 : 0xfc;
513 (dimmInfo->memoryType == DDR) ? 0xf : 0x03;
514 leftOfPoint = (data[i] & maskLeftOfPoint) >> shift;
515 rightOfPoint = (data[i] & maskRightOfPoint) * mult;
516 dimmInfo->minimumCycleTimeAtMaxCasLatancy_LoP =
518 dimmInfo->minimumCycleTimeAtMaxCasLatancy_RoP =
521 ("Minimum Cycle Time At Max CasLatancy: %d.%d [ns]\n",
522 leftOfPoint, rightOfPoint));
524 /*------------------------------------------------------------------------------------------------------------------------------*/
526 case 10: /* Clock To Data Out */
527 div = (dimmInfo->memoryType == DDR) ? 100 : 10;
529 (((data[i] & 0xf0) >> 4) * 10) +
531 leftOfPoint = time_tmp / div;
532 rightOfPoint = time_tmp % div;
533 dimmInfo->clockToDataOut_LoP = leftOfPoint;
534 dimmInfo->clockToDataOut_RoP = rightOfPoint;
536 ("Clock To Data Out: %d.%2d [ns]\n",
537 leftOfPoint, rightOfPoint));
538 /*dimmInfo->clockToDataOut */
540 /*------------------------------------------------------------------------------------------------------------------------------*/
543 case 11: /* Error Check Type */
544 dimmInfo->errorCheckType = data[i];
546 ("Error Check Type (0=NONE): %d\n",
547 dimmInfo->errorCheckType));
550 /*------------------------------------------------------------------------------------------------------------------------------*/
552 case 12: /* Refresh Interval */
553 dimmInfo->RefreshInterval = data[i];
555 ("RefreshInterval (80= Self refresh Normal, 15.625us) : %x\n",
556 dimmInfo->RefreshInterval));
558 /*------------------------------------------------------------------------------------------------------------------------------*/
560 case 13: /* Sdram Width */
561 dimmInfo->sdramWidth = data[i];
563 ("Sdram Width: %d\n",
564 dimmInfo->sdramWidth));
566 /*------------------------------------------------------------------------------------------------------------------------------*/
568 case 14: /* Error Check Data Width */
569 dimmInfo->errorCheckDataWidth = data[i];
571 ("Error Check Data Width: %d\n",
572 dimmInfo->errorCheckDataWidth));
574 /*------------------------------------------------------------------------------------------------------------------------------*/
576 case 15: /* Minimum Clock Delay */
577 dimmInfo->minClkDelay = data[i];
579 ("Minimum Clock Delay: %d\n",
580 dimmInfo->minClkDelay));
582 /*------------------------------------------------------------------------------------------------------------------------------*/
584 case 16: /* Burst Length Supported */
585 /******-******-******-*******
586 * bit3 | bit2 | bit1 | bit0 *
587 *******-******-******-*******
588 burst length = * 8 | 4 | 2 | 1 *
589 *****************************
591 If for example bit0 and bit2 are set, the burst
592 length supported are 1 and 4. */
594 dimmInfo->burstLengthSupported = data[i];
597 ("Burst Length Supported: "));
598 if (dimmInfo->burstLengthSupported & 0x01)
600 if (dimmInfo->burstLengthSupported & 0x02)
602 if (dimmInfo->burstLengthSupported & 0x04)
604 if (dimmInfo->burstLengthSupported & 0x08)
606 DP (printf (" Bit \n"));
609 /*------------------------------------------------------------------------------------------------------------------------------*/
611 case 17: /* Number Of Banks On Each Device */
612 dimmInfo->numOfBanksOnEachDevice = data[i];
614 ("Number Of Banks On Each Chip: %d\n",
615 dimmInfo->numOfBanksOnEachDevice));
617 /*------------------------------------------------------------------------------------------------------------------------------*/
619 case 18: /* Suported Cas Latencies */
622 *******-******-******-******-******-******-******-*******
623 * bit7 | bit6 | bit5 | bit4 | bit3 | bit2 | bit1 | bit0 *
624 *******-******-******-******-******-******-******-*******
625 CAS = * TBD | TBD | 3.5 | 3 | 2.5 | 2 | 1.5 | 1 *
626 *********************************************************
628 *******-******-******-******-******-******-******-*******
629 * bit7 | bit6 | bit5 | bit4 | bit3 | bit2 | bit1 | bit0 *
630 *******-******-******-******-******-******-******-*******
631 CAS = * TBD | 7 | 6 | 5 | 4 | 3 | 2 | 1 *
632 ********************************************************/
633 dimmInfo->suportedCasLatencies = data[i];
636 ("Suported Cas Latencies: (CL) "));
637 if (dimmInfo->memoryType == 0) { /* SDRAM */
638 for (k = 0; k <= 7; k++) {
640 suportedCasLatencies & (1 << k))
646 } else { /* DDR-RAM */
648 if (dimmInfo->suportedCasLatencies & 1)
650 if (dimmInfo->suportedCasLatencies & 2)
651 DP (printf ("1.5, "));
652 if (dimmInfo->suportedCasLatencies & 4)
654 if (dimmInfo->suportedCasLatencies & 8)
655 DP (printf ("2.5, "));
656 if (dimmInfo->suportedCasLatencies & 16)
658 if (dimmInfo->suportedCasLatencies & 32)
659 DP (printf ("3.5, "));
664 /* Calculating MAX CAS latency */
665 for (j = 7; j > 0; j--) {
667 suportedCasLatencies >> j) & 0x1) ==
669 switch (dimmInfo->memoryType) {
671 /* CAS latency 1, 1.5, 2, 2.5, 3, 3.5 */
675 ("Max. Cas Latencies (DDR): ERROR !!!\n"));
684 ("Max. Cas Latencies (DDR): ERROR !!!\n"));
693 ("Max. Cas Latencies (DDR): 3.5 clk's\n"));
700 ("Max. Cas Latencies (DDR): 3 clk's \n"));
707 ("Max. Cas Latencies (DDR): 2.5 clk's \n"));
714 ("Max. Cas Latencies (DDR): 2 clk's \n"));
721 ("Max. Cas Latencies (DDR): 1.5 clk's \n"));
728 maxCASlatencySupported_LoP
732 if (((5 * j) % 10) != 0)
734 maxCASlatencySupported_RoP
738 maxCASlatencySupported_RoP
741 ("Max. Cas Latencies (DDR LoP.RoP Notation): %d.%d \n",
743 maxCASlatencySupported_LoP,
745 maxCASlatencySupported_RoP));
748 /* CAS latency 1, 2, 3, 4, 5, 6, 7 */
749 dimmInfo->maxClSupported_SD = j; /* Cas Latency DDR-RAM Coded */
751 ("Max. Cas Latencies (SD): %d\n",
755 maxCASlatencySupported_LoP
758 maxCASlatencySupported_RoP
761 ("Max. Cas Latencies (DDR LoP.RoP Notation): %d.%d \n",
763 maxCASlatencySupported_LoP,
765 maxCASlatencySupported_RoP));
772 /*------------------------------------------------------------------------------------------------------------------------------*/
774 case 21: /* Buffered Address And Control Inputs */
775 DP (printf ("\nModul Attributes (SPD Byte 21): \n"));
776 dimmInfo->bufferedAddrAndControlInputs =
778 dimmInfo->registeredAddrAndControlInputs =
779 (data[i] & BIT1) >> 1;
780 dimmInfo->onCardPLL = (data[i] & BIT2) >> 2;
781 dimmInfo->bufferedDQMBinputs = (data[i] & BIT3) >> 3;
782 dimmInfo->registeredDQMBinputs =
783 (data[i] & BIT4) >> 4;
784 dimmInfo->differentialClockInput =
785 (data[i] & BIT5) >> 5;
786 dimmInfo->redundantRowAddressing =
787 (data[i] & BIT6) >> 6;
789 if (dimmInfo->bufferedAddrAndControlInputs == 1)
791 (" - Buffered Address/Control Input: Yes \n"));
794 (" - Buffered Address/Control Input: No \n"));
796 if (dimmInfo->registeredAddrAndControlInputs == 1)
798 (" - Registered Address/Control Input: Yes \n"));
801 (" - Registered Address/Control Input: No \n"));
803 if (dimmInfo->onCardPLL == 1)
805 (" - On-Card PLL (clock): Yes \n"));
808 (" - On-Card PLL (clock): No \n"));
810 if (dimmInfo->bufferedDQMBinputs == 1)
812 (" - Bufferd DQMB Inputs: Yes \n"));
815 (" - Bufferd DQMB Inputs: No \n"));
817 if (dimmInfo->registeredDQMBinputs == 1)
819 (" - Registered DQMB Inputs: Yes \n"));
822 (" - Registered DQMB Inputs: No \n"));
824 if (dimmInfo->differentialClockInput == 1)
826 (" - Differential Clock Input: Yes \n"));
829 (" - Differential Clock Input: No \n"));
831 if (dimmInfo->redundantRowAddressing == 1)
833 (" - redundant Row Addressing: Yes \n"));
836 (" - redundant Row Addressing: No \n"));
840 /*------------------------------------------------------------------------------------------------------------------------------*/
842 case 22: /* Suported AutoPreCharge */
843 DP (printf ("\nModul Attributes (SPD Byte 22): \n"));
844 dimmInfo->suportedEarlyRasPreCharge = data[i] & BIT0;
845 dimmInfo->suportedAutoPreCharge =
846 (data[i] & BIT1) >> 1;
847 dimmInfo->suportedPreChargeAll =
848 (data[i] & BIT2) >> 2;
849 dimmInfo->suportedWrite1ReadBurst =
850 (data[i] & BIT3) >> 3;
851 dimmInfo->suported5PercentLowVCC =
852 (data[i] & BIT4) >> 4;
853 dimmInfo->suported5PercentUpperVCC =
854 (data[i] & BIT5) >> 5;
856 if (dimmInfo->suportedEarlyRasPreCharge == 1)
858 (" - Early Ras Precharge: Yes \n"));
861 (" - Early Ras Precharge: No \n"));
863 if (dimmInfo->suportedAutoPreCharge == 1)
865 (" - AutoPreCharge: Yes \n"));
868 (" - AutoPreCharge: No \n"));
870 if (dimmInfo->suportedPreChargeAll == 1)
872 (" - Precharge All: Yes \n"));
875 (" - Precharge All: No \n"));
877 if (dimmInfo->suportedWrite1ReadBurst == 1)
879 (" - Write 1/ReadBurst: Yes \n"));
882 (" - Write 1/ReadBurst: No \n"));
884 if (dimmInfo->suported5PercentLowVCC == 1)
886 (" - lower VCC tolerance: 5 Percent \n"));
889 (" - lower VCC tolerance: 10 Percent \n"));
891 if (dimmInfo->suported5PercentUpperVCC == 1)
893 (" - upper VCC tolerance: 5 Percent \n"));
896 (" - upper VCC tolerance: 10 Percent \n"));
900 /*------------------------------------------------------------------------------------------------------------------------------*/
902 case 23: /* Minimum Cycle Time At Maximum Cas Latancy Minus 1 (2nd highest CL) */
903 shift = (dimmInfo->memoryType == DDR) ? 4 : 2;
904 mult = (dimmInfo->memoryType == DDR) ? 10 : 25;
906 (dimmInfo->memoryType == DDR) ? 0xf0 : 0xfc;
908 (dimmInfo->memoryType == DDR) ? 0xf : 0x03;
909 leftOfPoint = (data[i] & maskLeftOfPoint) >> shift;
910 rightOfPoint = (data[i] & maskRightOfPoint) * mult;
911 dimmInfo->minimumCycleTimeAtMaxCasLatancyMinus1_LoP =
913 dimmInfo->minimumCycleTimeAtMaxCasLatancyMinus1_RoP =
916 ("Minimum Cycle Time At 2nd highest CasLatancy (0 = Not supported): %d.%d [ns]\n",
917 leftOfPoint, rightOfPoint));
918 /*dimmInfo->minimumCycleTimeAtMaxCasLatancy */
920 /*------------------------------------------------------------------------------------------------------------------------------*/
922 case 24: /* Clock To Data Out 2nd highest Cas Latency Value */
923 div = (dimmInfo->memoryType == DDR) ? 100 : 10;
925 (((data[i] & 0xf0) >> 4) * 10) +
927 leftOfPoint = time_tmp / div;
928 rightOfPoint = time_tmp % div;
929 dimmInfo->clockToDataOutMinus1_LoP = leftOfPoint;
930 dimmInfo->clockToDataOutMinus1_RoP = rightOfPoint;
932 ("Clock To Data Out (2nd CL value): %d.%2d [ns]\n",
933 leftOfPoint, rightOfPoint));
935 /*------------------------------------------------------------------------------------------------------------------------------*/
937 case 25: /* Minimum Cycle Time At Maximum Cas Latancy Minus 2 (3rd highest CL) */
938 shift = (dimmInfo->memoryType == DDR) ? 4 : 2;
939 mult = (dimmInfo->memoryType == DDR) ? 10 : 25;
941 (dimmInfo->memoryType == DDR) ? 0xf0 : 0xfc;
943 (dimmInfo->memoryType == DDR) ? 0xf : 0x03;
944 leftOfPoint = (data[i] & maskLeftOfPoint) >> shift;
945 rightOfPoint = (data[i] & maskRightOfPoint) * mult;
946 dimmInfo->minimumCycleTimeAtMaxCasLatancyMinus2_LoP =
948 dimmInfo->minimumCycleTimeAtMaxCasLatancyMinus2_RoP =
951 ("Minimum Cycle Time At 3rd highest CasLatancy (0 = Not supported): %d.%d [ns]\n",
952 leftOfPoint, rightOfPoint));
953 /*dimmInfo->minimumCycleTimeAtMaxCasLatancy */
955 /*------------------------------------------------------------------------------------------------------------------------------*/
957 case 26: /* Clock To Data Out 3rd highest Cas Latency Value */
958 div = (dimmInfo->memoryType == DDR) ? 100 : 10;
960 (((data[i] & 0xf0) >> 4) * 10) +
962 leftOfPoint = time_tmp / div;
963 rightOfPoint = time_tmp % div;
964 dimmInfo->clockToDataOutMinus2_LoP = leftOfPoint;
965 dimmInfo->clockToDataOutMinus2_RoP = rightOfPoint;
967 ("Clock To Data Out (3rd CL value): %d.%2d [ns]\n",
968 leftOfPoint, rightOfPoint));
970 /*------------------------------------------------------------------------------------------------------------------------------*/
972 case 27: /* Minimum Row Precharge Time */
973 shift = (dimmInfo->memoryType == DDR) ? 2 : 0;
975 (dimmInfo->memoryType == DDR) ? 0xfc : 0xff;
977 (dimmInfo->memoryType == DDR) ? 0x03 : 0x00;
978 leftOfPoint = ((data[i] & maskLeftOfPoint) >> shift);
979 rightOfPoint = (data[i] & maskRightOfPoint) * 25;
981 dimmInfo->minRowPrechargeTime = ((leftOfPoint * 100) + rightOfPoint); /* measured in n times 10ps Intervals */
983 (dimmInfo->minRowPrechargeTime +
984 (tmemclk - 1)) / tmemclk;
986 ("*** 1 clock cycle = %ld 10ps intervalls = %ld.%ld ns****\n",
987 tmemclk, tmemclk / 100, tmemclk % 100));
989 ("Minimum Row Precharge Time [ns]: %d.%2d = in Clk cycles %d\n",
990 leftOfPoint, rightOfPoint, trp_clocks));
992 /*------------------------------------------------------------------------------------------------------------------------------*/
994 case 28: /* Minimum Row Active to Row Active Time */
995 shift = (dimmInfo->memoryType == DDR) ? 2 : 0;
997 (dimmInfo->memoryType == DDR) ? 0xfc : 0xff;
999 (dimmInfo->memoryType == DDR) ? 0x03 : 0x00;
1000 leftOfPoint = ((data[i] & maskLeftOfPoint) >> shift);
1001 rightOfPoint = (data[i] & maskRightOfPoint) * 25;
1003 dimmInfo->minRowActiveRowActiveDelay = ((leftOfPoint * 100) + rightOfPoint); /* measured in 100ns Intervals */
1005 (dimmInfo->minRowActiveRowActiveDelay +
1006 (tmemclk - 1)) / tmemclk;
1008 ("Minimum Row Active -To- Row Active Delay [ns]: %d.%2d = in Clk cycles %d\n",
1009 leftOfPoint, rightOfPoint, trp_clocks));
1011 /*------------------------------------------------------------------------------------------------------------------------------*/
1013 case 29: /* Minimum Ras-To-Cas Delay */
1014 shift = (dimmInfo->memoryType == DDR) ? 2 : 0;
1016 (dimmInfo->memoryType == DDR) ? 0xfc : 0xff;
1018 (dimmInfo->memoryType == DDR) ? 0x03 : 0x00;
1019 leftOfPoint = ((data[i] & maskLeftOfPoint) >> shift);
1020 rightOfPoint = (data[i] & maskRightOfPoint) * 25;
1022 dimmInfo->minRowActiveRowActiveDelay = ((leftOfPoint * 100) + rightOfPoint); /* measured in 100ns Intervals */
1024 (dimmInfo->minRowActiveRowActiveDelay +
1025 (tmemclk - 1)) / tmemclk;
1027 ("Minimum Ras-To-Cas Delay [ns]: %d.%2d = in Clk cycles %d\n",
1028 leftOfPoint, rightOfPoint, trp_clocks));
1030 /*------------------------------------------------------------------------------------------------------------------------------*/
1032 case 30: /* Minimum Ras Pulse Width */
1033 dimmInfo->minRasPulseWidth = data[i];
1035 (NSto10PS (data[i]) +
1036 (tmemclk - 1)) / tmemclk;
1038 ("Minimum Ras Pulse Width [ns]: %d = in Clk cycles %d\n",
1039 dimmInfo->minRasPulseWidth, tras_clocks));
1042 /*------------------------------------------------------------------------------------------------------------------------------*/
1044 case 31: /* Module Bank Density */
1045 dimmInfo->moduleBankDensity = data[i];
1047 ("Module Bank Density: %d\n",
1048 dimmInfo->moduleBankDensity));
1051 ("*** Offered Densities (more than 1 = Multisize-Module): "));
1053 if (dimmInfo->moduleBankDensity & 1)
1054 DP (printf ("4MB, "));
1055 if (dimmInfo->moduleBankDensity & 2)
1056 DP (printf ("8MB, "));
1057 if (dimmInfo->moduleBankDensity & 4)
1058 DP (printf ("16MB, "));
1059 if (dimmInfo->moduleBankDensity & 8)
1060 DP (printf ("32MB, "));
1061 if (dimmInfo->moduleBankDensity & 16)
1062 DP (printf ("64MB, "));
1063 if (dimmInfo->moduleBankDensity & 32)
1064 DP (printf ("128MB, "));
1065 if ((dimmInfo->moduleBankDensity & 64)
1066 || (dimmInfo->moduleBankDensity & 128)) {
1067 DP (printf ("ERROR, "));
1074 /*------------------------------------------------------------------------------------------------------------------------------*/
1076 case 32: /* Address And Command Setup Time (measured in ns/1000) */
1078 switch (dimmInfo->memoryType) {
1081 (((data[i] & 0xf0) >> 4) * 10) +
1083 leftOfPoint = time_tmp / 100;
1084 rightOfPoint = time_tmp % 100;
1087 leftOfPoint = (data[i] & 0xf0) >> 4;
1088 if (leftOfPoint > 7) {
1089 leftOfPoint = data[i] & 0x70 >> 4;
1092 rightOfPoint = (data[i] & 0x0f);
1095 dimmInfo->addrAndCommandSetupTime =
1096 (leftOfPoint * 100 + rightOfPoint) * sign;
1098 ("Address And Command Setup Time [ns]: %d.%d\n",
1099 sign * leftOfPoint, rightOfPoint));
1101 /*------------------------------------------------------------------------------------------------------------------------------*/
1103 case 33: /* Address And Command Hold Time */
1105 switch (dimmInfo->memoryType) {
1108 (((data[i] & 0xf0) >> 4) * 10) +
1110 leftOfPoint = time_tmp / 100;
1111 rightOfPoint = time_tmp % 100;
1114 leftOfPoint = (data[i] & 0xf0) >> 4;
1115 if (leftOfPoint > 7) {
1116 leftOfPoint = data[i] & 0x70 >> 4;
1119 rightOfPoint = (data[i] & 0x0f);
1122 dimmInfo->addrAndCommandHoldTime =
1123 (leftOfPoint * 100 + rightOfPoint) * sign;
1125 ("Address And Command Hold Time [ns]: %d.%d\n",
1126 sign * leftOfPoint, rightOfPoint));
1128 /*------------------------------------------------------------------------------------------------------------------------------*/
1130 case 34: /* Data Input Setup Time */
1132 switch (dimmInfo->memoryType) {
1135 (((data[i] & 0xf0) >> 4) * 10) +
1137 leftOfPoint = time_tmp / 100;
1138 rightOfPoint = time_tmp % 100;
1141 leftOfPoint = (data[i] & 0xf0) >> 4;
1142 if (leftOfPoint > 7) {
1143 leftOfPoint = data[i] & 0x70 >> 4;
1146 rightOfPoint = (data[i] & 0x0f);
1149 dimmInfo->dataInputSetupTime =
1150 (leftOfPoint * 100 + rightOfPoint) * sign;
1152 ("Data Input Setup Time [ns]: %d.%d\n",
1153 sign * leftOfPoint, rightOfPoint));
1155 /*------------------------------------------------------------------------------------------------------------------------------*/
1157 case 35: /* Data Input Hold Time */
1159 switch (dimmInfo->memoryType) {
1162 (((data[i] & 0xf0) >> 4) * 10) +
1164 leftOfPoint = time_tmp / 100;
1165 rightOfPoint = time_tmp % 100;
1168 leftOfPoint = (data[i] & 0xf0) >> 4;
1169 if (leftOfPoint > 7) {
1170 leftOfPoint = data[i] & 0x70 >> 4;
1173 rightOfPoint = (data[i] & 0x0f);
1176 dimmInfo->dataInputHoldTime =
1177 (leftOfPoint * 100 + rightOfPoint) * sign;
1179 ("Data Input Hold Time [ns]: %d.%d\n\n",
1180 sign * leftOfPoint, rightOfPoint));
1182 /*------------------------------------------------------------------------------------------------------------------------------*/
1185 /* calculating the sdram density */
1187 i < dimmInfo->numOfRowAddresses + dimmInfo->numOfColAddresses;
1189 density = density * 2;
1191 dimmInfo->deviceDensity = density * dimmInfo->numOfBanksOnEachDevice *
1192 dimmInfo->sdramWidth;
1193 dimmInfo->numberOfDevices =
1194 (dimmInfo->dataWidth / dimmInfo->sdramWidth) *
1195 dimmInfo->numOfModuleBanks;
1196 devicesForErrCheck =
1197 (dimmInfo->dataWidth - 64) / dimmInfo->sdramWidth;
1198 if ((dimmInfo->errorCheckType == 0x1)
1199 || (dimmInfo->errorCheckType == 0x2)
1200 || (dimmInfo->errorCheckType == 0x3)) {
1202 (dimmInfo->deviceDensity / 8) *
1203 (dimmInfo->numberOfDevices - devicesForErrCheck);
1206 (dimmInfo->deviceDensity / 8) *
1207 dimmInfo->numberOfDevices;
1210 /* compute the module DRB size */
1212 (dimmInfo->numOfRowAddresses + dimmInfo->numOfColAddresses));
1213 tmp *= dimmInfo->numOfModuleBanks;
1214 tmp *= dimmInfo->sdramWidth;
1215 tmp = tmp >> 24; /* div by 0x4000000 (64M) */
1216 dimmInfo->drb_size = (uchar) tmp;
1217 DP (printf ("Module DRB size (n*64Mbit): %d\n", dimmInfo->drb_size));
1219 /* try a CAS latency of 3 first... */
1221 /* bit 1 is CL2, bit 2 is CL3 */
1222 supp_cal = (dimmInfo->suportedCasLatencies & 0x1c) >> 1;
1226 if (NS10to10PS (data[9]) <= tmemclk)
1230 if (NS10to10PS (data[9]) <= tmemclk)
1236 if (NS10to10PS (data[23]) <= tmemclk)
1240 DP (printf ("cal_val = %d\n", cal_val * 5));
1242 /* bummer, did't work... */
1244 DP (printf ("Couldn't find a good CAS latency\n"));
1252 /* sets up the GT properly with information passed in */
1253 int setup_sdram (AUX_MEM_DIMM_INFO * info)
1256 ulong tmp_sdram_mode = 0; /* 0x141c */
1257 ulong tmp_dunit_control_low = 0; /* 0x1404 */
1260 /* sanity checking */
1261 if (!info->numOfModuleBanks) {
1262 printf ("setup_sdram called with 0 banks\n");
1268 /* Program the GT with the discovered data */
1269 if (info->registeredAddrAndControlInputs == true)
1271 ("Module is registered, but we do not support registered Modules !!!\n"));
1275 set_dfcdlInit (); /* may be its not needed */
1276 DP (printf ("Delay line set done\n"));
1278 /* set SDRAM mode NOP */ /* To_do check it */
1279 GT_REG_WRITE (SDRAM_OPERATION, 0x5);
1280 while (GTREGREAD (SDRAM_OPERATION) != 0) {
1282 ("\n*** SDRAM_OPERATION 1418: Module still busy ... please wait... ***\n"));
1285 /* SDRAM configuration */
1286 GT_REG_WRITE (SDRAM_CONFIG, 0x58200400);
1287 DP (printf ("sdram_conf 0x1400: %08x\n", GTREGREAD (SDRAM_CONFIG)));
1289 /* SDRAM open pages controll keep open as much as I can */
1290 GT_REG_WRITE (SDRAM_OPEN_PAGES_CONTROL, 0x0);
1292 ("sdram_open_pages_controll 0x1414: %08x\n",
1293 GTREGREAD (SDRAM_OPEN_PAGES_CONTROL)));
1296 /* SDRAM D_UNIT_CONTROL_LOW 0x1404 */
1297 tmp = (GTREGREAD (D_UNIT_CONTROL_LOW) & 0x01); /* Clock Domain Sync from power on reset */
1299 DP (printf ("Core Signals are sync (by HW-Setting)!!!\n"));
1302 ("Core Signals syncs. are bypassed (by HW-Setting)!!!\n"));
1304 /* SDRAM set CAS Lentency according to SPD information */
1305 switch (info->memoryType) {
1307 DP (printf ("### SD-RAM not supported yet !!!\n"));
1309 /* ToDo fill SD-RAM if needed !!!!! */
1313 DP (printf ("### SET-CL for DDR-RAM\n"));
1315 switch (info->maxClSupported_DDR) {
1317 tmp_dunit_control_low = 0x3c000000; /* Read-Data sampled on falling edge of Clk */
1318 tmp_sdram_mode = 0x32; /* CL=3 Burstlength = 4 */
1320 ("Max. CL is 3 CLKs 0x141c= %08lx, 0x1404 = %08lx\n",
1321 tmp_sdram_mode, tmp_dunit_control_low));
1325 if (tmp == 1) { /* clocks sync */
1326 tmp_dunit_control_low = 0x24000000; /* Read-Data sampled on falling edge of Clk */
1327 tmp_sdram_mode = 0x62; /* CL=2,5 Burstlength = 4 */
1329 ("Max. CL is 2,5s CLKs 0x141c= %08lx, 0x1404 = %08lx\n",
1330 tmp_sdram_mode, tmp_dunit_control_low));
1331 } else { /* clk sync. bypassed */
1333 tmp_dunit_control_low = 0x03000000; /* Read-Data sampled on rising edge of Clk */
1334 tmp_sdram_mode = 0x62; /* CL=2,5 Burstlength = 4 */
1336 ("Max. CL is 2,5 CLKs 0x141c= %08lx, 0x1404 = %08lx\n",
1337 tmp_sdram_mode, tmp_dunit_control_low));
1342 if (tmp == 1) { /* Sync */
1343 tmp_dunit_control_low = 0x03000000; /* Read-Data sampled on rising edge of Clk */
1344 tmp_sdram_mode = 0x22; /* CL=2 Burstlength = 4 */
1346 ("Max. CL is 2s CLKs 0x141c= %08lx, 0x1404 = %08lx\n",
1347 tmp_sdram_mode, tmp_dunit_control_low));
1348 } else { /* Not sync. */
1350 tmp_dunit_control_low = 0x3b000000; /* Read-Data sampled on rising edge of Clk */
1351 tmp_sdram_mode = 0x22; /* CL=2 Burstlength = 4 */
1353 ("Max. CL is 2 CLKs 0x141c= %08lx, 0x1404 = %08lx\n",
1354 tmp_sdram_mode, tmp_dunit_control_low));
1359 if (tmp == 1) { /* Sync */
1360 tmp_dunit_control_low = 0x23000000; /* Read-Data sampled on falling edge of Clk */
1361 tmp_sdram_mode = 0x52; /* CL=1,5 Burstlength = 4 */
1363 ("Max. CL is 1,5s CLKs 0x141c= %08lx, 0x1404 = %08lx\n",
1364 tmp_sdram_mode, tmp_dunit_control_low));
1365 } else { /* not sync */
1367 tmp_dunit_control_low = 0x1a000000; /* Read-Data sampled on rising edge of Clk */
1368 tmp_sdram_mode = 0x52; /* CL=1,5 Burstlength = 4 */
1370 ("Max. CL is 1,5 CLKs 0x141c= %08lx, 0x1404 = %08lx\n",
1371 tmp_sdram_mode, tmp_dunit_control_low));
1376 printf ("Max. CL is out of range %d\n",
1377 info->maxClSupported_DDR);
1384 /* Write results of CL detection procedure */
1385 GT_REG_WRITE (SDRAM_MODE, tmp_sdram_mode);
1386 /* set SDRAM mode SetCommand 0x1418 */
1387 GT_REG_WRITE (SDRAM_OPERATION, 0x3);
1388 while (GTREGREAD (SDRAM_OPERATION) != 0) {
1390 ("\n*** SDRAM_OPERATION 1418 after SDRAM_MODE: Module still busy ... please wait... ***\n"));
1394 /* SDRAM D_UNIT_CONTROL_LOW 0x1404 */
1395 tmp = (GTREGREAD (D_UNIT_CONTROL_LOW) & 0x01); /* Clock Domain Sync from power on reset */
1396 if (tmp != 1) { /*clocks are not sync */
1398 GT_REG_WRITE (D_UNIT_CONTROL_LOW,
1399 (GTREGREAD (D_UNIT_CONTROL_LOW) & 0x7F) |
1400 0x18110780 | tmp_dunit_control_low);
1403 GT_REG_WRITE (D_UNIT_CONTROL_LOW,
1404 (GTREGREAD (D_UNIT_CONTROL_LOW) & 0x7F) |
1405 0x00110000 | tmp_dunit_control_low);
1408 /* set SDRAM mode SetCommand 0x1418 */
1409 GT_REG_WRITE (SDRAM_OPERATION, 0x3);
1410 while (GTREGREAD (SDRAM_OPERATION) != 0) {
1412 ("\n*** SDRAM_OPERATION 1418 after D_UNIT_CONTROL_LOW: Module still busy ... please wait... ***\n"));
1415 /*------------------------------------------------------------------------------ */
1418 /* bank parameters */
1419 /* SDRAM address decode register */
1420 /* program this with the default value */
1424 DP (printf ("drb_size (n*64Mbit): %d\n", info->drb_size));
1425 switch (info->drb_size) {
1426 case 1: /* 64 Mbit */
1427 case 2: /* 128 Mbit */
1428 DP (printf ("RAM-Device_size 64Mbit or 128Mbit)\n"));
1431 case 4: /* 256 Mbit */
1432 case 8: /* 512 Mbit */
1433 DP (printf ("RAM-Device_size 256Mbit or 512Mbit)\n"));
1436 case 16: /* 1 Gbit */
1437 case 32: /* 2 Gbit */
1438 DP (printf ("RAM-Device_size 1Gbit or 2Gbit)\n"));
1442 printf ("Error in dram size calculation\n");
1443 DP (printf ("Assume: RAM-Device_size 1Gbit or 2Gbit)\n"));
1448 /* SDRAM bank parameters */
1449 /* the param registers for slot 1 (banks 2+3) are offset by 0x8 */
1451 ("setting up slot %d config with: %08lx \n", info->slot, tmp));
1452 GT_REG_WRITE (SDRAM_ADDR_CONTROL, tmp);
1454 /* ------------------------------------------------------------------------------ */
1457 ("setting up sdram_timing_control_low with: %08x \n",
1459 GT_REG_WRITE (SDRAM_TIMING_CONTROL_LOW, 0x11511220);
1462 /* ------------------------------------------------------------------------------ */
1464 /* SDRAM configuration */
1465 tmp = GTREGREAD (SDRAM_CONFIG);
1467 if (info->registeredAddrAndControlInputs
1468 || info->registeredDQMBinputs) {
1471 ("SPD says: registered Addr. and Cont.: %d; registered DQMBinputs: %d\n",
1472 info->registeredAddrAndControlInputs,
1473 info->registeredDQMBinputs));
1476 /* Use buffer 1 to return read data to the CPU
1477 * Page 426 MV64360 */
1480 ("Before Buffer assignment - sdram_conf: %08x\n",
1481 GTREGREAD (SDRAM_CONFIG)));
1483 ("After Buffer assignment - sdram_conf: %08x\n",
1484 GTREGREAD (SDRAM_CONFIG)));
1486 /* SDRAM timing To_do: */
1489 tmp = GTREGREAD (SDRAM_TIMING_CONTROL_HIGH);
1490 DP (printf ("# sdram_timing_control_high is : %08lx \n", tmp));
1492 /* SDRAM address decode register */
1493 /* program this with the default value */
1494 tmp = GTREGREAD (SDRAM_ADDR_CONTROL);
1496 ("SDRAM address control (before: decode): %08x ",
1497 GTREGREAD (SDRAM_ADDR_CONTROL)));
1498 GT_REG_WRITE (SDRAM_ADDR_CONTROL, (tmp | 0x2));
1500 ("SDRAM address control (after: decode): %08x\n",
1501 GTREGREAD (SDRAM_ADDR_CONTROL)));
1503 /* set the SDRAM configuration for each bank */
1505 /* for (i = info->slot * 2; i < ((info->slot * 2) + info->banks); i++) */
1511 ("\n*** Running a MRS cycle for bank %d ***\n", i));
1514 memory_map_bank (i, 0, GB / 4);
1515 #if 1 /* test only */
1517 tmp = GTREGREAD (SDRAM_MODE);
1518 GT_REG_WRITE (EXTENDED_DRAM_MODE, 0x0);
1519 GT_REG_WRITE (SDRAM_OPERATION, 0x4);
1520 while (GTREGREAD (SDRAM_OPERATION) != 0) {
1522 ("\n*** SDRAM_OPERATION 1418 after SDRAM_MODE: Module still busy ... please wait... ***\n"));
1525 GT_REG_WRITE (SDRAM_MODE, tmp | 0x80);
1526 GT_REG_WRITE (SDRAM_OPERATION, 0x3);
1527 while (GTREGREAD (SDRAM_OPERATION) != 0) {
1529 ("\n*** SDRAM_OPERATION 1418 after SDRAM_MODE: Module still busy ... please wait... ***\n"));
1533 l1 += GTREGREAD (SDRAM_OPERATION);
1535 GT_REG_WRITE (SDRAM_MODE, tmp);
1536 GT_REG_WRITE (SDRAM_OPERATION, 0x3);
1537 while (GTREGREAD (SDRAM_OPERATION) != 0) {
1539 ("\n*** SDRAM_OPERATION 1418 after SDRAM_MODE: Module still busy ... please wait... ***\n"));
1542 /* switch back to normal operation mode */
1543 GT_REG_WRITE (SDRAM_OPERATION, 0x5);
1544 while (GTREGREAD (SDRAM_OPERATION) != 0) {
1546 ("\n*** SDRAM_OPERATION 1418 after SDRAM_MODE: Module still busy ... please wait... ***\n"));
1549 #endif /* test only */
1550 /* unmap the bank */
1551 memory_map_bank (i, 0, 0);
1558 * Check memory range for valid RAM. A simple memory test determines
1559 * the actually available RAM size between addresses `base' and
1560 * `base + maxsize'. Some (not all) hardware errors are detected:
1561 * - short between address lines
1562 * - short between data lines
1565 dram_size(long int *base, long int maxsize)
1567 volatile long int *addr, *b=base;
1568 long int cnt, val, save1, save2;
1570 #define STARTVAL (1<<20) /* start test at 1M */
1571 for (cnt = STARTVAL/sizeof(long); cnt < maxsize/sizeof(long); cnt <<= 1) {
1572 addr = base + cnt; /* pointer arith! */
1574 save1=*addr; /* save contents of addr */
1575 save2=*b; /* save contents of base */
1577 *addr=cnt; /* write cnt to addr */
1578 *b=0; /* put null at base */
1580 /* check at base address */
1582 *addr=save1; /* restore *addr */
1583 *b=save2; /* restore *b */
1586 val = *addr; /* read *addr */
1587 val = *addr; /* read *addr */
1593 DP(printf("Found %08x at Address %08x (failure)\n", (unsigned int)val, (unsigned int) addr));
1594 /* fix boundary condition.. STARTVAL means zero */
1595 if(cnt==STARTVAL/sizeof(long)) cnt=0;
1596 return (cnt * sizeof(long));
1602 /* ------------------------------------------------------------------------- */
1604 /* ppcboot interface function to SDRAM init - this is where all the
1605 * controlling logic happens */
1607 initdram(int board_type)
1610 int checkbank[4] = { [0 ... 3] = 0 };
1611 ulong bank_no, realsize, total, check;
1612 AUX_MEM_DIMM_INFO dimmInfo1;
1613 AUX_MEM_DIMM_INFO dimmInfo2;
1616 /* first, use the SPD to get info about the SDRAM/ DDRRAM */
1618 /* check the NHR bit and skip mem init if it's already done */
1619 nhr = get_hid0() & (1 << 16);
1622 printf("Skipping SD- DDRRAM setup due to NHR bit being set\n");
1625 s0 = check_dimm(0, &dimmInfo1);
1628 s1 = check_dimm(1, &dimmInfo2);
1630 memory_map_bank(0, 0, 0);
1631 memory_map_bank(1, 0, 0);
1632 memory_map_bank(2, 0, 0);
1633 memory_map_bank(3, 0, 0);
1635 if (dimmInfo1.numOfModuleBanks && setup_sdram(&dimmInfo1)) {
1636 printf("Setup for DIMM1 failed.\n");
1639 if (dimmInfo2.numOfModuleBanks && setup_sdram(&dimmInfo2)) {
1640 printf("Setup for DIMM2 failed.\n");
1643 /* set the NHR bit */
1644 set_hid0(get_hid0() | (1 << 16));
1646 /* next, size the SDRAM banks */
1648 realsize = total = 0;
1650 if (dimmInfo1.numOfModuleBanks > 0) {checkbank[0] = 1; printf("-- DIMM1 has 1 bank\n");}
1651 if (dimmInfo1.numOfModuleBanks > 1) {checkbank[1] = 1; printf("-- DIMM1 has 2 banks\n");}
1652 if (dimmInfo1.numOfModuleBanks > 2)
1653 printf("Error, SPD claims DIMM1 has >2 banks\n");
1655 if (dimmInfo2.numOfModuleBanks > 0) {checkbank[2] = 1; printf("-- DIMM2 has 1 bank\n");}
1656 if (dimmInfo2.numOfModuleBanks > 1) {checkbank[3] = 1; printf("-- DIMM2 has 2 banks\n");}
1657 if (dimmInfo2.numOfModuleBanks > 2)
1658 printf("Error, SPD claims DIMM2 has >2 banks\n");
1660 for (bank_no = 0; bank_no < CFG_DRAM_BANKS; bank_no++) {
1661 /* skip over banks that are not populated */
1662 if (! checkbank[bank_no])
1665 if ((total + check) > CFG_GT_REGS)
1666 check = CFG_GT_REGS - total;
1668 memory_map_bank(bank_no, total, check);
1669 realsize = dram_size((long int *)total, check);
1670 memory_map_bank(bank_no, total, realsize);
1675 /* Setup Ethernet DMA Adress window to DRAM Area */
1679 /* ***************************************************************************************
1681 ! * This procedure detect all Sdram types: 64, 128, 256, 512 Mbit, 1Gbit and 2Gb *
1682 ! * This procedure fits only the Atlantis *
1684 ! *************************************************************************************** */
1687 /* ***************************************************************************************
1688 ! * DFCDL initialize MV643xx Design Considerations *
1690 ! *************************************************************************************** */
1691 int set_dfcdlInit (void)
1694 unsigned int dfcdl_word = 0x0000014f;
1696 for (i = 0; i < 64; i++) {
1697 GT_REG_WRITE (SRAM_DATA0, dfcdl_word);
1699 GT_REG_WRITE (DFCDL_CONFIG0, 0x00300000); /* enable dynamic delay line updating */