sdram_init.c 52 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702
  1. /*
  2. * (C) Copyright 2001
  3. * Josh Huber <huber@mclx.com>, Mission Critical Linux, Inc.
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  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.
  12. *
  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.
  17. *
  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,
  21. * MA 02111-1307 USA
  22. */
  23. /*************************************************************************
  24. * adaption for the Marvell DB64360 Board
  25. * Ingo Assmus (ingo.assmus@keymile.com)
  26. *
  27. * adaption for the cpci750 Board
  28. * Reinhard Arlt (reinhard.arlt@esd-electronics.com)
  29. *************************************************************************/
  30. /* sdram_init.c - automatic memory sizing */
  31. #include <common.h>
  32. #include <74xx_7xx.h>
  33. #include "../../Marvell/include/memory.h"
  34. #include "../../Marvell/include/pci.h"
  35. #include "../../Marvell/include/mv_gen_reg.h"
  36. #include <net.h>
  37. #include "eth.h"
  38. #include "mpsc.h"
  39. #include "../../Marvell/common/i2c.h"
  40. #include "64360.h"
  41. #include "mv_regs.h"
  42. DECLARE_GLOBAL_DATA_PTR;
  43. #undef DEBUG
  44. /* #define DEBUG */
  45. #ifdef CONFIG_PCI
  46. #define MAP_PCI
  47. #endif /* of CONFIG_PCI */
  48. #ifdef DEBUG
  49. #define DP(x) x
  50. #else
  51. #define DP(x)
  52. #endif
  53. int set_dfcdlInit(void); /* setup delay line of Mv64360 */
  54. /* ------------------------------------------------------------------------- */
  55. int
  56. memory_map_bank(unsigned int bankNo,
  57. unsigned int bankBase,
  58. unsigned int bankLength)
  59. {
  60. #ifdef MAP_PCI
  61. PCI_HOST host;
  62. #endif
  63. #ifdef DEBUG
  64. if (bankLength > 0) {
  65. printf("mapping bank %d at %08x - %08x\n",
  66. bankNo, bankBase, bankBase + bankLength - 1);
  67. } else {
  68. printf("unmapping bank %d\n", bankNo);
  69. }
  70. #endif
  71. memoryMapBank(bankNo, bankBase, bankLength);
  72. #ifdef MAP_PCI
  73. for (host=PCI_HOST0;host<=PCI_HOST1;host++) {
  74. const int features=
  75. PREFETCH_ENABLE |
  76. DELAYED_READ_ENABLE |
  77. AGGRESSIVE_PREFETCH |
  78. READ_LINE_AGGRESSIVE_PREFETCH |
  79. READ_MULTI_AGGRESSIVE_PREFETCH |
  80. MAX_BURST_4 |
  81. PCI_NO_SWAP;
  82. pciMapMemoryBank(host, bankNo, bankBase, bankLength);
  83. pciSetRegionSnoopMode(host, bankNo, PCI_SNOOP_WB, bankBase,
  84. bankLength);
  85. pciSetRegionFeatures(host, bankNo, features, bankBase, bankLength);
  86. }
  87. #endif
  88. return 0;
  89. }
  90. #define GB (1 << 30)
  91. /* much of this code is based on (or is) the code in the pip405 port */
  92. /* thanks go to the authors of said port - Josh */
  93. /* structure to store the relevant information about an sdram bank */
  94. typedef struct sdram_info {
  95. uchar drb_size;
  96. uchar registered, ecc;
  97. uchar tpar;
  98. uchar tras_clocks;
  99. uchar burst_len;
  100. uchar banks, slot;
  101. } sdram_info_t;
  102. /* Typedefs for 'gtAuxilGetDIMMinfo' function */
  103. typedef enum _memoryType {SDRAM, DDR} MEMORY_TYPE;
  104. typedef enum _voltageInterface {TTL_5V_TOLERANT, LVTTL, HSTL_1_5V,
  105. SSTL_3_3V, SSTL_2_5V, VOLTAGE_UNKNOWN,
  106. } VOLTAGE_INTERFACE;
  107. 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;
  108. 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;
  109. /* SDRAM/DDR information struct */
  110. typedef struct _gtMemoryDimmInfo {
  111. MEMORY_TYPE memoryType;
  112. unsigned int numOfRowAddresses;
  113. unsigned int numOfColAddresses;
  114. unsigned int numOfModuleBanks;
  115. unsigned int dataWidth;
  116. VOLTAGE_INTERFACE voltageInterface;
  117. unsigned int errorCheckType; /* ECC , PARITY.. */
  118. unsigned int sdramWidth; /* 4,8,16 or 32 */ ;
  119. unsigned int errorCheckDataWidth; /* 0 - no, 1 - Yes */
  120. unsigned int minClkDelay;
  121. unsigned int burstLengthSupported;
  122. unsigned int numOfBanksOnEachDevice;
  123. unsigned int suportedCasLatencies;
  124. unsigned int RefreshInterval;
  125. unsigned int maxCASlatencySupported_LoP; /* LoP left of point (measured in ns) */
  126. unsigned int maxCASlatencySupported_RoP; /* RoP right of point (measured in ns) */
  127. MAX_CL_SUPPORTED_DDR maxClSupported_DDR;
  128. MAX_CL_SUPPORTED_SD maxClSupported_SD;
  129. unsigned int moduleBankDensity;
  130. /* module attributes (true for yes) */
  131. bool bufferedAddrAndControlInputs;
  132. bool registeredAddrAndControlInputs;
  133. bool onCardPLL;
  134. bool bufferedDQMBinputs;
  135. bool registeredDQMBinputs;
  136. bool differentialClockInput;
  137. bool redundantRowAddressing;
  138. /* module general attributes */
  139. bool suportedAutoPreCharge;
  140. bool suportedPreChargeAll;
  141. bool suportedEarlyRasPreCharge;
  142. bool suportedWrite1ReadBurst;
  143. bool suported5PercentLowVCC;
  144. bool suported5PercentUpperVCC;
  145. /* module timing parameters */
  146. unsigned int minRasToCasDelay;
  147. unsigned int minRowActiveRowActiveDelay;
  148. unsigned int minRasPulseWidth;
  149. unsigned int minRowPrechargeTime; /* measured in ns */
  150. int addrAndCommandHoldTime; /* LoP left of point (measured in ns) */
  151. int addrAndCommandSetupTime; /* (measured in ns/100) */
  152. int dataInputSetupTime; /* LoP left of point (measured in ns) */
  153. int dataInputHoldTime; /* LoP left of point (measured in ns) */
  154. /* tAC times for highest 2nd and 3rd highest CAS Latency values */
  155. unsigned int clockToDataOut_LoP; /* LoP left of point (measured in ns) */
  156. unsigned int clockToDataOut_RoP; /* RoP right of point (measured in ns) */
  157. unsigned int clockToDataOutMinus1_LoP; /* LoP left of point (measured in ns) */
  158. unsigned int clockToDataOutMinus1_RoP; /* RoP right of point (measured in ns) */
  159. unsigned int clockToDataOutMinus2_LoP; /* LoP left of point (measured in ns) */
  160. unsigned int clockToDataOutMinus2_RoP; /* RoP right of point (measured in ns) */
  161. unsigned int minimumCycleTimeAtMaxCasLatancy_LoP; /* LoP left of point (measured in ns) */
  162. unsigned int minimumCycleTimeAtMaxCasLatancy_RoP; /* RoP right of point (measured in ns) */
  163. unsigned int minimumCycleTimeAtMaxCasLatancyMinus1_LoP; /* LoP left of point (measured in ns) */
  164. unsigned int minimumCycleTimeAtMaxCasLatancyMinus1_RoP; /* RoP right of point (measured in ns) */
  165. unsigned int minimumCycleTimeAtMaxCasLatancyMinus2_LoP; /* LoP left of point (measured in ns) */
  166. unsigned int minimumCycleTimeAtMaxCasLatancyMinus2_RoP; /* RoP right of point (measured in ns) */
  167. /* Parameters calculated from
  168. the extracted DIMM information */
  169. unsigned int size;
  170. unsigned int deviceDensity; /* 16,64,128,256 or 512 Mbit */
  171. unsigned int numberOfDevices;
  172. uchar drb_size; /* DRAM size in n*64Mbit */
  173. uchar slot; /* Slot Number this module is inserted in */
  174. uchar spd_raw_data[128]; /* Content of SPD-EEPROM copied 1:1 */
  175. #ifdef DEBUG
  176. uchar manufactura[8]; /* Content of SPD-EEPROM Byte 64-71 */
  177. uchar modul_id[18]; /* Content of SPD-EEPROM Byte 73-90 */
  178. uchar vendor_data[27]; /* Content of SPD-EEPROM Byte 99-125 */
  179. unsigned long modul_serial_no; /* Content of SPD-EEPROM Byte 95-98 */
  180. unsigned int manufac_date; /* Content of SPD-EEPROM Byte 93-94 */
  181. unsigned int modul_revision; /* Content of SPD-EEPROM Byte 91-92 */
  182. uchar manufac_place; /* Content of SPD-EEPROM Byte 72 */
  183. #endif
  184. } AUX_MEM_DIMM_INFO;
  185. /*
  186. * translate ns.ns/10 coding of SPD timing values
  187. * into 10 ps unit values
  188. */
  189. static inline unsigned short
  190. NS10to10PS(unsigned char spd_byte)
  191. {
  192. unsigned short ns, ns10;
  193. /* isolate upper nibble */
  194. ns = (spd_byte >> 4) & 0x0F;
  195. /* isolate lower nibble */
  196. ns10 = (spd_byte & 0x0F);
  197. return(ns*100 + ns10*10);
  198. }
  199. /*
  200. * translate ns coding of SPD timing values
  201. * into 10 ps unit values
  202. */
  203. static inline unsigned short
  204. NSto10PS(unsigned char spd_byte)
  205. {
  206. return(spd_byte*100);
  207. }
  208. /* This code reads the SPD chip on the sdram and populates
  209. * the array which is passed in with the relevant information */
  210. /* static int check_dimm(uchar slot, AUX_MEM_DIMM_INFO *info) */
  211. static int check_dimm (uchar slot, AUX_MEM_DIMM_INFO * dimmInfo)
  212. {
  213. unsigned long spd_checksum;
  214. uchar addr = slot == 0 ? DIMM0_I2C_ADDR : DIMM1_I2C_ADDR;
  215. int ret;
  216. unsigned int i, j, density = 1, devicesForErrCheck = 0;
  217. #ifdef DEBUG
  218. unsigned int k;
  219. #endif
  220. unsigned int rightOfPoint = 0, leftOfPoint = 0, mult, div, time_tmp;
  221. int sign = 1, shift, maskLeftOfPoint, maskRightOfPoint;
  222. uchar supp_cal, cal_val;
  223. ulong memclk, tmemclk;
  224. ulong tmp;
  225. uchar trp_clocks = 0, trcd_clocks, tras_clocks, trrd_clocks;
  226. uchar data[128];
  227. memclk = gd->bus_clk;
  228. tmemclk = 1000000000 / (memclk / 100); /* in 10 ps units */
  229. memset (data, 0, sizeof (data));
  230. ret = 0;
  231. DP (puts ("before i2c read\n"));
  232. ret = i2c_read (addr, 0, 2, data, 128);
  233. DP (puts ("after i2c read\n"));
  234. if ((data[64] != 'e') || (data[65] != 's') || (data[66] != 'd')
  235. || (data[67] != '-') || (data[68] != 'g') || (data[69] != 'm')
  236. || (data[70] != 'b') || (data[71] != 'h')) {
  237. ret = -1;
  238. }
  239. if ((ret != 0) && (slot == 0)) {
  240. memset (data, 0, sizeof (data));
  241. data[0] = 0x80;
  242. data[1] = 0x08;
  243. data[2] = 0x07;
  244. data[3] = 0x0c;
  245. data[4] = 0x09;
  246. data[5] = 0x01;
  247. data[6] = 0x48;
  248. data[7] = 0x00;
  249. data[8] = 0x04;
  250. data[9] = 0x75;
  251. data[10] = 0x80;
  252. data[11] = 0x02;
  253. data[12] = 0x80;
  254. data[13] = 0x10;
  255. data[14] = 0x08;
  256. data[15] = 0x01;
  257. data[16] = 0x0e;
  258. data[17] = 0x04;
  259. data[18] = 0x0c;
  260. data[19] = 0x01;
  261. data[20] = 0x02;
  262. data[21] = 0x20;
  263. data[22] = 0x00;
  264. data[23] = 0xa0;
  265. data[24] = 0x80;
  266. data[25] = 0x00;
  267. data[26] = 0x00;
  268. data[27] = 0x50;
  269. data[28] = 0x3c;
  270. data[29] = 0x50;
  271. data[30] = 0x32;
  272. data[31] = 0x10;
  273. data[32] = 0xb0;
  274. data[33] = 0xb0;
  275. data[34] = 0x60;
  276. data[35] = 0x60;
  277. data[64] = 'e';
  278. data[65] = 's';
  279. data[66] = 'd';
  280. data[67] = '-';
  281. data[68] = 'g';
  282. data[69] = 'm';
  283. data[70] = 'b';
  284. data[71] = 'h';
  285. ret = 0;
  286. }
  287. /* zero all the values */
  288. memset (dimmInfo, 0, sizeof (*dimmInfo));
  289. /* copy the SPD content 1:1 into the dimmInfo structure */
  290. for (i = 0; i <= 127; i++) {
  291. dimmInfo->spd_raw_data[i] = data[i];
  292. }
  293. if (ret) {
  294. DP (printf ("No DIMM in slot %d [err = %x]\n", slot, ret));
  295. return 0;
  296. } else
  297. dimmInfo->slot = slot; /* start to fill up dimminfo for this "slot" */
  298. #ifdef CFG_DISPLAY_DIMM_SPD_CONTENT
  299. for (i = 0; i <= 127; i++) {
  300. printf ("SPD-EEPROM Byte %3d = %3x (%3d)\n", i, data[i],
  301. data[i]);
  302. }
  303. #endif
  304. #ifdef DEBUG
  305. /* find Manufacturer of Dimm Module */
  306. for (i = 0; i < sizeof (dimmInfo->manufactura); i++) {
  307. dimmInfo->manufactura[i] = data[64 + i];
  308. }
  309. printf ("\nThis RAM-Module is produced by: %s\n",
  310. dimmInfo->manufactura);
  311. /* find Manul-ID of Dimm Module */
  312. for (i = 0; i < sizeof (dimmInfo->modul_id); i++) {
  313. dimmInfo->modul_id[i] = data[73 + i];
  314. }
  315. printf ("The Module-ID of this RAM-Module is: %s\n",
  316. dimmInfo->modul_id);
  317. /* find Vendor-Data of Dimm Module */
  318. for (i = 0; i < sizeof (dimmInfo->vendor_data); i++) {
  319. dimmInfo->vendor_data[i] = data[99 + i];
  320. }
  321. printf ("Vendor Data of this RAM-Module is: %s\n",
  322. dimmInfo->vendor_data);
  323. /* find modul_serial_no of Dimm Module */
  324. dimmInfo->modul_serial_no = (*((unsigned long *) (&data[95])));
  325. printf ("Serial No. of this RAM-Module is: %ld (%lx)\n",
  326. dimmInfo->modul_serial_no, dimmInfo->modul_serial_no);
  327. /* find Manufac-Data of Dimm Module */
  328. dimmInfo->manufac_date = (*((unsigned int *) (&data[93])));
  329. printf ("Manufactoring Date of this RAM-Module is: %d.%d\n", data[93], data[94]); /*dimmInfo->manufac_date */
  330. /* find modul_revision of Dimm Module */
  331. dimmInfo->modul_revision = (*((unsigned int *) (&data[91])));
  332. printf ("Module Revision of this RAM-Module is: %d.%d\n", data[91], data[92]); /* dimmInfo->modul_revision */
  333. /* find manufac_place of Dimm Module */
  334. dimmInfo->manufac_place = (*((unsigned char *) (&data[72])));
  335. printf ("manufac_place of this RAM-Module is: %d\n",
  336. dimmInfo->manufac_place);
  337. #endif
  338. /*------------------------------------------------------------------------------------------------------------------------------*/
  339. /* calculate SPD checksum */
  340. /*------------------------------------------------------------------------------------------------------------------------------*/
  341. spd_checksum = 0;
  342. #if 0 /* test-only */
  343. for (i = 0; i <= 62; i++) {
  344. spd_checksum += data[i];
  345. }
  346. if ((spd_checksum & 0xff) != data[63]) {
  347. printf ("### Error in SPD Checksum !!! Is_value: %2x should value %2x\n", (unsigned int) (spd_checksum & 0xff), data[63]);
  348. hang ();
  349. }
  350. else
  351. printf ("SPD Checksum ok!\n");
  352. #endif /* test-only */
  353. /*------------------------------------------------------------------------------------------------------------------------------*/
  354. for (i = 2; i <= 35; i++) {
  355. switch (i) {
  356. case 2: /* Memory type (DDR / SDRAM) */
  357. dimmInfo->memoryType = (data[i] == 0x7) ? DDR : SDRAM;
  358. #ifdef DEBUG
  359. if (dimmInfo->memoryType == 0)
  360. DP (printf
  361. ("Dram_type in slot %d is: SDRAM\n",
  362. dimmInfo->slot));
  363. if (dimmInfo->memoryType == 1)
  364. DP (printf
  365. ("Dram_type in slot %d is: DDRAM\n",
  366. dimmInfo->slot));
  367. #endif
  368. break;
  369. /*------------------------------------------------------------------------------------------------------------------------------*/
  370. case 3: /* Number Of Row Addresses */
  371. dimmInfo->numOfRowAddresses = data[i];
  372. DP (printf
  373. ("Module Number of row addresses: %d\n",
  374. dimmInfo->numOfRowAddresses));
  375. break;
  376. /*------------------------------------------------------------------------------------------------------------------------------*/
  377. case 4: /* Number Of Column Addresses */
  378. dimmInfo->numOfColAddresses = data[i];
  379. DP (printf
  380. ("Module Number of col addresses: %d\n",
  381. dimmInfo->numOfColAddresses));
  382. break;
  383. /*------------------------------------------------------------------------------------------------------------------------------*/
  384. case 5: /* Number Of Module Banks */
  385. dimmInfo->numOfModuleBanks = data[i];
  386. DP (printf
  387. ("Number of Banks on Mod. : %d\n",
  388. dimmInfo->numOfModuleBanks));
  389. break;
  390. /*------------------------------------------------------------------------------------------------------------------------------*/
  391. case 6: /* Data Width */
  392. dimmInfo->dataWidth = data[i];
  393. DP (printf
  394. ("Module Data Width: %d\n",
  395. dimmInfo->dataWidth));
  396. break;
  397. /*------------------------------------------------------------------------------------------------------------------------------*/
  398. case 8: /* Voltage Interface */
  399. switch (data[i]) {
  400. case 0x0:
  401. dimmInfo->voltageInterface = TTL_5V_TOLERANT;
  402. DP (printf
  403. ("Module is TTL_5V_TOLERANT\n"));
  404. break;
  405. case 0x1:
  406. dimmInfo->voltageInterface = LVTTL;
  407. DP (printf
  408. ("Module is LVTTL\n"));
  409. break;
  410. case 0x2:
  411. dimmInfo->voltageInterface = HSTL_1_5V;
  412. DP (printf
  413. ("Module is TTL_5V_TOLERANT\n"));
  414. break;
  415. case 0x3:
  416. dimmInfo->voltageInterface = SSTL_3_3V;
  417. DP (printf
  418. ("Module is HSTL_1_5V\n"));
  419. break;
  420. case 0x4:
  421. dimmInfo->voltageInterface = SSTL_2_5V;
  422. DP (printf
  423. ("Module is SSTL_2_5V\n"));
  424. break;
  425. default:
  426. dimmInfo->voltageInterface = VOLTAGE_UNKNOWN;
  427. DP (printf
  428. ("Module is VOLTAGE_UNKNOWN\n"));
  429. break;
  430. }
  431. break;
  432. /*------------------------------------------------------------------------------------------------------------------------------*/
  433. case 9: /* Minimum Cycle Time At Max CasLatancy */
  434. shift = (dimmInfo->memoryType == DDR) ? 4 : 2;
  435. mult = (dimmInfo->memoryType == DDR) ? 10 : 25;
  436. maskLeftOfPoint =
  437. (dimmInfo->memoryType == DDR) ? 0xf0 : 0xfc;
  438. maskRightOfPoint =
  439. (dimmInfo->memoryType == DDR) ? 0xf : 0x03;
  440. leftOfPoint = (data[i] & maskLeftOfPoint) >> shift;
  441. rightOfPoint = (data[i] & maskRightOfPoint) * mult;
  442. dimmInfo->minimumCycleTimeAtMaxCasLatancy_LoP =
  443. leftOfPoint;
  444. dimmInfo->minimumCycleTimeAtMaxCasLatancy_RoP =
  445. rightOfPoint;
  446. DP (printf
  447. ("Minimum Cycle Time At Max CasLatancy: %d.%d [ns]\n",
  448. leftOfPoint, rightOfPoint));
  449. break;
  450. /*------------------------------------------------------------------------------------------------------------------------------*/
  451. case 10: /* Clock To Data Out */
  452. div = (dimmInfo->memoryType == DDR) ? 100 : 10;
  453. time_tmp =
  454. (((data[i] & 0xf0) >> 4) * 10) +
  455. ((data[i] & 0x0f));
  456. leftOfPoint = time_tmp / div;
  457. rightOfPoint = time_tmp % div;
  458. dimmInfo->clockToDataOut_LoP = leftOfPoint;
  459. dimmInfo->clockToDataOut_RoP = rightOfPoint;
  460. DP (printf
  461. ("Clock To Data Out: %d.%2d [ns]\n",
  462. leftOfPoint, rightOfPoint));
  463. /*dimmInfo->clockToDataOut */
  464. break;
  465. /*------------------------------------------------------------------------------------------------------------------------------*/
  466. #ifdef CONFIG_ECC
  467. case 11: /* Error Check Type */
  468. dimmInfo->errorCheckType = data[i];
  469. DP (printf
  470. ("Error Check Type (0=NONE): %d\n",
  471. dimmInfo->errorCheckType));
  472. break;
  473. #endif
  474. /*------------------------------------------------------------------------------------------------------------------------------*/
  475. case 12: /* Refresh Interval */
  476. dimmInfo->RefreshInterval = data[i];
  477. DP (printf
  478. ("RefreshInterval (80= Self refresh Normal, 15.625us) : %x\n",
  479. dimmInfo->RefreshInterval));
  480. break;
  481. /*------------------------------------------------------------------------------------------------------------------------------*/
  482. case 13: /* Sdram Width */
  483. dimmInfo->sdramWidth = data[i];
  484. DP (printf
  485. ("Sdram Width: %d\n",
  486. dimmInfo->sdramWidth));
  487. break;
  488. /*------------------------------------------------------------------------------------------------------------------------------*/
  489. case 14: /* Error Check Data Width */
  490. dimmInfo->errorCheckDataWidth = data[i];
  491. DP (printf
  492. ("Error Check Data Width: %d\n",
  493. dimmInfo->errorCheckDataWidth));
  494. break;
  495. /*------------------------------------------------------------------------------------------------------------------------------*/
  496. case 15: /* Minimum Clock Delay */
  497. dimmInfo->minClkDelay = data[i];
  498. DP (printf
  499. ("Minimum Clock Delay: %d\n",
  500. dimmInfo->minClkDelay));
  501. break;
  502. /*------------------------------------------------------------------------------------------------------------------------------*/
  503. case 16: /* Burst Length Supported */
  504. /******-******-******-*******
  505. * bit3 | bit2 | bit1 | bit0 *
  506. *******-******-******-*******
  507. burst length = * 8 | 4 | 2 | 1 *
  508. *****************************
  509. If for example bit0 and bit2 are set, the burst
  510. length supported are 1 and 4. */
  511. dimmInfo->burstLengthSupported = data[i];
  512. #ifdef DEBUG
  513. DP (printf
  514. ("Burst Length Supported: "));
  515. if (dimmInfo->burstLengthSupported & 0x01)
  516. DP (printf ("1, "));
  517. if (dimmInfo->burstLengthSupported & 0x02)
  518. DP (printf ("2, "));
  519. if (dimmInfo->burstLengthSupported & 0x04)
  520. DP (printf ("4, "));
  521. if (dimmInfo->burstLengthSupported & 0x08)
  522. DP (printf ("8, "));
  523. DP (printf (" Bit \n"));
  524. #endif
  525. break;
  526. /*------------------------------------------------------------------------------------------------------------------------------*/
  527. case 17: /* Number Of Banks On Each Device */
  528. dimmInfo->numOfBanksOnEachDevice = data[i];
  529. DP (printf
  530. ("Number Of Banks On Each Chip: %d\n",
  531. dimmInfo->numOfBanksOnEachDevice));
  532. break;
  533. /*------------------------------------------------------------------------------------------------------------------------------*/
  534. case 18: /* Suported Cas Latencies */
  535. /* DDR:
  536. *******-******-******-******-******-******-******-*******
  537. * bit7 | bit6 | bit5 | bit4 | bit3 | bit2 | bit1 | bit0 *
  538. *******-******-******-******-******-******-******-*******
  539. CAS = * TBD | TBD | 3.5 | 3 | 2.5 | 2 | 1.5 | 1 *
  540. *********************************************************
  541. SDRAM:
  542. *******-******-******-******-******-******-******-*******
  543. * bit7 | bit6 | bit5 | bit4 | bit3 | bit2 | bit1 | bit0 *
  544. *******-******-******-******-******-******-******-*******
  545. CAS = * TBD | 7 | 6 | 5 | 4 | 3 | 2 | 1 *
  546. ********************************************************/
  547. dimmInfo->suportedCasLatencies = data[i];
  548. #ifdef DEBUG
  549. DP (printf
  550. ("Suported Cas Latencies: (CL) "));
  551. if (dimmInfo->memoryType == 0) { /* SDRAM */
  552. for (k = 0; k <= 7; k++) {
  553. if (dimmInfo->
  554. suportedCasLatencies & (1 << k))
  555. DP (printf
  556. ("%d, ",
  557. k + 1));
  558. }
  559. } else { /* DDR-RAM */
  560. if (dimmInfo->suportedCasLatencies & 1)
  561. DP (printf ("1, "));
  562. if (dimmInfo->suportedCasLatencies & 2)
  563. DP (printf ("1.5, "));
  564. if (dimmInfo->suportedCasLatencies & 4)
  565. DP (printf ("2, "));
  566. if (dimmInfo->suportedCasLatencies & 8)
  567. DP (printf ("2.5, "));
  568. if (dimmInfo->suportedCasLatencies & 16)
  569. DP (printf ("3, "));
  570. if (dimmInfo->suportedCasLatencies & 32)
  571. DP (printf ("3.5, "));
  572. }
  573. DP (printf ("\n"));
  574. #endif
  575. /* Calculating MAX CAS latency */
  576. for (j = 7; j > 0; j--) {
  577. if (((dimmInfo->
  578. suportedCasLatencies >> j) & 0x1) ==
  579. 1) {
  580. switch (dimmInfo->memoryType) {
  581. case DDR:
  582. /* CAS latency 1, 1.5, 2, 2.5, 3, 3.5 */
  583. switch (j) {
  584. case 7:
  585. DP (printf
  586. ("Max. Cas Latencies (DDR): ERROR !!!\n"));
  587. dimmInfo->
  588. maxClSupported_DDR
  589. =
  590. DDR_CL_FAULT;
  591. hang ();
  592. break;
  593. case 6:
  594. DP (printf
  595. ("Max. Cas Latencies (DDR): ERROR !!!\n"));
  596. dimmInfo->
  597. maxClSupported_DDR
  598. =
  599. DDR_CL_FAULT;
  600. hang ();
  601. break;
  602. case 5:
  603. DP (printf
  604. ("Max. Cas Latencies (DDR): 3.5 clk's\n"));
  605. dimmInfo->
  606. maxClSupported_DDR
  607. = DDR_CL_3_5;
  608. break;
  609. case 4:
  610. DP (printf
  611. ("Max. Cas Latencies (DDR): 3 clk's \n"));
  612. dimmInfo->
  613. maxClSupported_DDR
  614. = DDR_CL_3;
  615. break;
  616. case 3:
  617. DP (printf
  618. ("Max. Cas Latencies (DDR): 2.5 clk's \n"));
  619. dimmInfo->
  620. maxClSupported_DDR
  621. = DDR_CL_2_5;
  622. break;
  623. case 2:
  624. DP (printf
  625. ("Max. Cas Latencies (DDR): 2 clk's \n"));
  626. dimmInfo->
  627. maxClSupported_DDR
  628. = DDR_CL_2;
  629. break;
  630. case 1:
  631. DP (printf
  632. ("Max. Cas Latencies (DDR): 1.5 clk's \n"));
  633. dimmInfo->
  634. maxClSupported_DDR
  635. = DDR_CL_1_5;
  636. break;
  637. }
  638. dimmInfo->
  639. maxCASlatencySupported_LoP
  640. =
  641. 1 +
  642. (int) (5 * j / 10);
  643. if (((5 * j) % 10) != 0)
  644. dimmInfo->
  645. maxCASlatencySupported_RoP
  646. = 5;
  647. else
  648. dimmInfo->
  649. maxCASlatencySupported_RoP
  650. = 0;
  651. DP (printf
  652. ("Max. Cas Latencies (DDR LoP.RoP Notation): %d.%d \n",
  653. dimmInfo->
  654. maxCASlatencySupported_LoP,
  655. dimmInfo->
  656. maxCASlatencySupported_RoP));
  657. break;
  658. case SDRAM:
  659. /* CAS latency 1, 2, 3, 4, 5, 6, 7 */
  660. dimmInfo->maxClSupported_SD = j; /* Cas Latency DDR-RAM Coded */
  661. DP (printf
  662. ("Max. Cas Latencies (SD): %d\n",
  663. dimmInfo->
  664. maxClSupported_SD));
  665. dimmInfo->
  666. maxCASlatencySupported_LoP
  667. = j;
  668. dimmInfo->
  669. maxCASlatencySupported_RoP
  670. = 0;
  671. DP (printf
  672. ("Max. Cas Latencies (DDR LoP.RoP Notation): %d.%d \n",
  673. dimmInfo->
  674. maxCASlatencySupported_LoP,
  675. dimmInfo->
  676. maxCASlatencySupported_RoP));
  677. break;
  678. }
  679. break;
  680. }
  681. }
  682. break;
  683. /*------------------------------------------------------------------------------------------------------------------------------*/
  684. case 21: /* Buffered Address And Control Inputs */
  685. DP (printf ("\nModul Attributes (SPD Byte 21): \n"));
  686. dimmInfo->bufferedAddrAndControlInputs =
  687. data[i] & BIT0;
  688. dimmInfo->registeredAddrAndControlInputs =
  689. (data[i] & BIT1) >> 1;
  690. dimmInfo->onCardPLL = (data[i] & BIT2) >> 2;
  691. dimmInfo->bufferedDQMBinputs = (data[i] & BIT3) >> 3;
  692. dimmInfo->registeredDQMBinputs =
  693. (data[i] & BIT4) >> 4;
  694. dimmInfo->differentialClockInput =
  695. (data[i] & BIT5) >> 5;
  696. dimmInfo->redundantRowAddressing =
  697. (data[i] & BIT6) >> 6;
  698. #ifdef DEBUG
  699. if (dimmInfo->bufferedAddrAndControlInputs == 1)
  700. DP (printf
  701. (" - Buffered Address/Control Input: Yes \n"));
  702. else
  703. DP (printf
  704. (" - Buffered Address/Control Input: No \n"));
  705. if (dimmInfo->registeredAddrAndControlInputs == 1)
  706. DP (printf
  707. (" - Registered Address/Control Input: Yes \n"));
  708. else
  709. DP (printf
  710. (" - Registered Address/Control Input: No \n"));
  711. if (dimmInfo->onCardPLL == 1)
  712. DP (printf
  713. (" - On-Card PLL (clock): Yes \n"));
  714. else
  715. DP (printf
  716. (" - On-Card PLL (clock): No \n"));
  717. if (dimmInfo->bufferedDQMBinputs == 1)
  718. DP (printf
  719. (" - Bufferd DQMB Inputs: Yes \n"));
  720. else
  721. DP (printf
  722. (" - Bufferd DQMB Inputs: No \n"));
  723. if (dimmInfo->registeredDQMBinputs == 1)
  724. DP (printf
  725. (" - Registered DQMB Inputs: Yes \n"));
  726. else
  727. DP (printf
  728. (" - Registered DQMB Inputs: No \n"));
  729. if (dimmInfo->differentialClockInput == 1)
  730. DP (printf
  731. (" - Differential Clock Input: Yes \n"));
  732. else
  733. DP (printf
  734. (" - Differential Clock Input: No \n"));
  735. if (dimmInfo->redundantRowAddressing == 1)
  736. DP (printf
  737. (" - redundant Row Addressing: Yes \n"));
  738. else
  739. DP (printf
  740. (" - redundant Row Addressing: No \n"));
  741. #endif
  742. break;
  743. /*------------------------------------------------------------------------------------------------------------------------------*/
  744. case 22: /* Suported AutoPreCharge */
  745. DP (printf ("\nModul Attributes (SPD Byte 22): \n"));
  746. dimmInfo->suportedEarlyRasPreCharge = data[i] & BIT0;
  747. dimmInfo->suportedAutoPreCharge =
  748. (data[i] & BIT1) >> 1;
  749. dimmInfo->suportedPreChargeAll =
  750. (data[i] & BIT2) >> 2;
  751. dimmInfo->suportedWrite1ReadBurst =
  752. (data[i] & BIT3) >> 3;
  753. dimmInfo->suported5PercentLowVCC =
  754. (data[i] & BIT4) >> 4;
  755. dimmInfo->suported5PercentUpperVCC =
  756. (data[i] & BIT5) >> 5;
  757. #ifdef DEBUG
  758. if (dimmInfo->suportedEarlyRasPreCharge == 1)
  759. DP (printf
  760. (" - Early Ras Precharge: Yes \n"));
  761. else
  762. DP (printf
  763. (" - Early Ras Precharge: No \n"));
  764. if (dimmInfo->suportedAutoPreCharge == 1)
  765. DP (printf
  766. (" - AutoPreCharge: Yes \n"));
  767. else
  768. DP (printf
  769. (" - AutoPreCharge: No \n"));
  770. if (dimmInfo->suportedPreChargeAll == 1)
  771. DP (printf
  772. (" - Precharge All: Yes \n"));
  773. else
  774. DP (printf
  775. (" - Precharge All: No \n"));
  776. if (dimmInfo->suportedWrite1ReadBurst == 1)
  777. DP (printf
  778. (" - Write 1/ReadBurst: Yes \n"));
  779. else
  780. DP (printf
  781. (" - Write 1/ReadBurst: No \n"));
  782. if (dimmInfo->suported5PercentLowVCC == 1)
  783. DP (printf
  784. (" - lower VCC tolerance: 5 Percent \n"));
  785. else
  786. DP (printf
  787. (" - lower VCC tolerance: 10 Percent \n"));
  788. if (dimmInfo->suported5PercentUpperVCC == 1)
  789. DP (printf
  790. (" - upper VCC tolerance: 5 Percent \n"));
  791. else
  792. DP (printf
  793. (" - upper VCC tolerance: 10 Percent \n"));
  794. #endif
  795. break;
  796. /*------------------------------------------------------------------------------------------------------------------------------*/
  797. case 23: /* Minimum Cycle Time At Maximum Cas Latancy Minus 1 (2nd highest CL) */
  798. shift = (dimmInfo->memoryType == DDR) ? 4 : 2;
  799. mult = (dimmInfo->memoryType == DDR) ? 10 : 25;
  800. maskLeftOfPoint =
  801. (dimmInfo->memoryType == DDR) ? 0xf0 : 0xfc;
  802. maskRightOfPoint =
  803. (dimmInfo->memoryType == DDR) ? 0xf : 0x03;
  804. leftOfPoint = (data[i] & maskLeftOfPoint) >> shift;
  805. rightOfPoint = (data[i] & maskRightOfPoint) * mult;
  806. dimmInfo->minimumCycleTimeAtMaxCasLatancyMinus1_LoP =
  807. leftOfPoint;
  808. dimmInfo->minimumCycleTimeAtMaxCasLatancyMinus1_RoP =
  809. rightOfPoint;
  810. DP (printf
  811. ("Minimum Cycle Time At 2nd highest CasLatancy (0 = Not supported): %d.%d [ns]\n",
  812. leftOfPoint, rightOfPoint));
  813. /*dimmInfo->minimumCycleTimeAtMaxCasLatancy */
  814. break;
  815. /*------------------------------------------------------------------------------------------------------------------------------*/
  816. case 24: /* Clock To Data Out 2nd highest Cas Latency Value */
  817. div = (dimmInfo->memoryType == DDR) ? 100 : 10;
  818. time_tmp =
  819. (((data[i] & 0xf0) >> 4) * 10) +
  820. ((data[i] & 0x0f));
  821. leftOfPoint = time_tmp / div;
  822. rightOfPoint = time_tmp % div;
  823. dimmInfo->clockToDataOutMinus1_LoP = leftOfPoint;
  824. dimmInfo->clockToDataOutMinus1_RoP = rightOfPoint;
  825. DP (printf
  826. ("Clock To Data Out (2nd CL value): %d.%2d [ns]\n",
  827. leftOfPoint, rightOfPoint));
  828. break;
  829. /*------------------------------------------------------------------------------------------------------------------------------*/
  830. case 25: /* Minimum Cycle Time At Maximum Cas Latancy Minus 2 (3rd highest CL) */
  831. shift = (dimmInfo->memoryType == DDR) ? 4 : 2;
  832. mult = (dimmInfo->memoryType == DDR) ? 10 : 25;
  833. maskLeftOfPoint =
  834. (dimmInfo->memoryType == DDR) ? 0xf0 : 0xfc;
  835. maskRightOfPoint =
  836. (dimmInfo->memoryType == DDR) ? 0xf : 0x03;
  837. leftOfPoint = (data[i] & maskLeftOfPoint) >> shift;
  838. rightOfPoint = (data[i] & maskRightOfPoint) * mult;
  839. dimmInfo->minimumCycleTimeAtMaxCasLatancyMinus2_LoP =
  840. leftOfPoint;
  841. dimmInfo->minimumCycleTimeAtMaxCasLatancyMinus2_RoP =
  842. rightOfPoint;
  843. DP (printf
  844. ("Minimum Cycle Time At 3rd highest CasLatancy (0 = Not supported): %d.%d [ns]\n",
  845. leftOfPoint, rightOfPoint));
  846. /*dimmInfo->minimumCycleTimeAtMaxCasLatancy */
  847. break;
  848. /*------------------------------------------------------------------------------------------------------------------------------*/
  849. case 26: /* Clock To Data Out 3rd highest Cas Latency Value */
  850. div = (dimmInfo->memoryType == DDR) ? 100 : 10;
  851. time_tmp =
  852. (((data[i] & 0xf0) >> 4) * 10) +
  853. ((data[i] & 0x0f));
  854. leftOfPoint = time_tmp / div;
  855. rightOfPoint = time_tmp % div;
  856. dimmInfo->clockToDataOutMinus2_LoP = leftOfPoint;
  857. dimmInfo->clockToDataOutMinus2_RoP = rightOfPoint;
  858. DP (printf
  859. ("Clock To Data Out (3rd CL value): %d.%2d [ns]\n",
  860. leftOfPoint, rightOfPoint));
  861. break;
  862. /*------------------------------------------------------------------------------------------------------------------------------*/
  863. case 27: /* Minimum Row Precharge Time */
  864. shift = (dimmInfo->memoryType == DDR) ? 2 : 0;
  865. maskLeftOfPoint =
  866. (dimmInfo->memoryType == DDR) ? 0xfc : 0xff;
  867. maskRightOfPoint =
  868. (dimmInfo->memoryType == DDR) ? 0x03 : 0x00;
  869. leftOfPoint = ((data[i] & maskLeftOfPoint) >> shift);
  870. rightOfPoint = (data[i] & maskRightOfPoint) * 25;
  871. dimmInfo->minRowPrechargeTime = ((leftOfPoint * 100) + rightOfPoint); /* measured in n times 10ps Intervals */
  872. trp_clocks =
  873. (dimmInfo->minRowPrechargeTime +
  874. (tmemclk - 1)) / tmemclk;
  875. DP (printf
  876. ("*** 1 clock cycle = %ld 10ps intervalls = %ld.%ld ns****\n",
  877. tmemclk, tmemclk / 100, tmemclk % 100));
  878. DP (printf
  879. ("Minimum Row Precharge Time [ns]: %d.%2d = in Clk cycles %d\n",
  880. leftOfPoint, rightOfPoint, trp_clocks));
  881. break;
  882. /*------------------------------------------------------------------------------------------------------------------------------*/
  883. case 28: /* Minimum Row Active to Row Active Time */
  884. shift = (dimmInfo->memoryType == DDR) ? 2 : 0;
  885. maskLeftOfPoint =
  886. (dimmInfo->memoryType == DDR) ? 0xfc : 0xff;
  887. maskRightOfPoint =
  888. (dimmInfo->memoryType == DDR) ? 0x03 : 0x00;
  889. leftOfPoint = ((data[i] & maskLeftOfPoint) >> shift);
  890. rightOfPoint = (data[i] & maskRightOfPoint) * 25;
  891. dimmInfo->minRowActiveRowActiveDelay = ((leftOfPoint * 100) + rightOfPoint); /* measured in 100ns Intervals */
  892. trrd_clocks =
  893. (dimmInfo->minRowActiveRowActiveDelay +
  894. (tmemclk - 1)) / tmemclk;
  895. DP (printf
  896. ("Minimum Row Active -To- Row Active Delay [ns]: %d.%2d = in Clk cycles %d\n",
  897. leftOfPoint, rightOfPoint, trp_clocks));
  898. break;
  899. /*------------------------------------------------------------------------------------------------------------------------------*/
  900. case 29: /* Minimum Ras-To-Cas Delay */
  901. shift = (dimmInfo->memoryType == DDR) ? 2 : 0;
  902. maskLeftOfPoint =
  903. (dimmInfo->memoryType == DDR) ? 0xfc : 0xff;
  904. maskRightOfPoint =
  905. (dimmInfo->memoryType == DDR) ? 0x03 : 0x00;
  906. leftOfPoint = ((data[i] & maskLeftOfPoint) >> shift);
  907. rightOfPoint = (data[i] & maskRightOfPoint) * 25;
  908. dimmInfo->minRowActiveRowActiveDelay = ((leftOfPoint * 100) + rightOfPoint); /* measured in 100ns Intervals */
  909. trcd_clocks =
  910. (dimmInfo->minRowActiveRowActiveDelay +
  911. (tmemclk - 1)) / tmemclk;
  912. DP (printf
  913. ("Minimum Ras-To-Cas Delay [ns]: %d.%2d = in Clk cycles %d\n",
  914. leftOfPoint, rightOfPoint, trp_clocks));
  915. break;
  916. /*------------------------------------------------------------------------------------------------------------------------------*/
  917. case 30: /* Minimum Ras Pulse Width */
  918. dimmInfo->minRasPulseWidth = data[i];
  919. tras_clocks =
  920. (NSto10PS (data[i]) +
  921. (tmemclk - 1)) / tmemclk;
  922. DP (printf
  923. ("Minimum Ras Pulse Width [ns]: %d = in Clk cycles %d\n",
  924. dimmInfo->minRasPulseWidth, tras_clocks));
  925. break;
  926. /*------------------------------------------------------------------------------------------------------------------------------*/
  927. case 31: /* Module Bank Density */
  928. dimmInfo->moduleBankDensity = data[i];
  929. DP (printf
  930. ("Module Bank Density: %d\n",
  931. dimmInfo->moduleBankDensity));
  932. #ifdef DEBUG
  933. DP (printf
  934. ("*** Offered Densities (more than 1 = Multisize-Module): "));
  935. {
  936. if (dimmInfo->moduleBankDensity & 1)
  937. DP (printf ("4MB, "));
  938. if (dimmInfo->moduleBankDensity & 2)
  939. DP (printf ("8MB, "));
  940. if (dimmInfo->moduleBankDensity & 4)
  941. DP (printf ("16MB, "));
  942. if (dimmInfo->moduleBankDensity & 8)
  943. DP (printf ("32MB, "));
  944. if (dimmInfo->moduleBankDensity & 16)
  945. DP (printf ("64MB, "));
  946. if (dimmInfo->moduleBankDensity & 32)
  947. DP (printf ("128MB, "));
  948. if ((dimmInfo->moduleBankDensity & 64)
  949. || (dimmInfo->moduleBankDensity & 128)) {
  950. DP (printf ("ERROR, "));
  951. hang ();
  952. }
  953. }
  954. DP (printf ("\n"));
  955. #endif
  956. break;
  957. /*------------------------------------------------------------------------------------------------------------------------------*/
  958. case 32: /* Address And Command Setup Time (measured in ns/1000) */
  959. sign = 1;
  960. switch (dimmInfo->memoryType) {
  961. case DDR:
  962. time_tmp =
  963. (((data[i] & 0xf0) >> 4) * 10) +
  964. ((data[i] & 0x0f));
  965. leftOfPoint = time_tmp / 100;
  966. rightOfPoint = time_tmp % 100;
  967. break;
  968. case SDRAM:
  969. leftOfPoint = (data[i] & 0xf0) >> 4;
  970. if (leftOfPoint > 7) {
  971. leftOfPoint = data[i] & 0x70 >> 4;
  972. sign = -1;
  973. }
  974. rightOfPoint = (data[i] & 0x0f);
  975. break;
  976. }
  977. dimmInfo->addrAndCommandSetupTime =
  978. (leftOfPoint * 100 + rightOfPoint) * sign;
  979. DP (printf
  980. ("Address And Command Setup Time [ns]: %d.%d\n",
  981. sign * leftOfPoint, rightOfPoint));
  982. break;
  983. /*------------------------------------------------------------------------------------------------------------------------------*/
  984. case 33: /* Address And Command Hold Time */
  985. sign = 1;
  986. switch (dimmInfo->memoryType) {
  987. case DDR:
  988. time_tmp =
  989. (((data[i] & 0xf0) >> 4) * 10) +
  990. ((data[i] & 0x0f));
  991. leftOfPoint = time_tmp / 100;
  992. rightOfPoint = time_tmp % 100;
  993. break;
  994. case SDRAM:
  995. leftOfPoint = (data[i] & 0xf0) >> 4;
  996. if (leftOfPoint > 7) {
  997. leftOfPoint = data[i] & 0x70 >> 4;
  998. sign = -1;
  999. }
  1000. rightOfPoint = (data[i] & 0x0f);
  1001. break;
  1002. }
  1003. dimmInfo->addrAndCommandHoldTime =
  1004. (leftOfPoint * 100 + rightOfPoint) * sign;
  1005. DP (printf
  1006. ("Address And Command Hold Time [ns]: %d.%d\n",
  1007. sign * leftOfPoint, rightOfPoint));
  1008. break;
  1009. /*------------------------------------------------------------------------------------------------------------------------------*/
  1010. case 34: /* Data Input Setup Time */
  1011. sign = 1;
  1012. switch (dimmInfo->memoryType) {
  1013. case DDR:
  1014. time_tmp =
  1015. (((data[i] & 0xf0) >> 4) * 10) +
  1016. ((data[i] & 0x0f));
  1017. leftOfPoint = time_tmp / 100;
  1018. rightOfPoint = time_tmp % 100;
  1019. break;
  1020. case SDRAM:
  1021. leftOfPoint = (data[i] & 0xf0) >> 4;
  1022. if (leftOfPoint > 7) {
  1023. leftOfPoint = data[i] & 0x70 >> 4;
  1024. sign = -1;
  1025. }
  1026. rightOfPoint = (data[i] & 0x0f);
  1027. break;
  1028. }
  1029. dimmInfo->dataInputSetupTime =
  1030. (leftOfPoint * 100 + rightOfPoint) * sign;
  1031. DP (printf
  1032. ("Data Input Setup Time [ns]: %d.%d\n",
  1033. sign * leftOfPoint, rightOfPoint));
  1034. break;
  1035. /*------------------------------------------------------------------------------------------------------------------------------*/
  1036. case 35: /* Data Input Hold Time */
  1037. sign = 1;
  1038. switch (dimmInfo->memoryType) {
  1039. case DDR:
  1040. time_tmp =
  1041. (((data[i] & 0xf0) >> 4) * 10) +
  1042. ((data[i] & 0x0f));
  1043. leftOfPoint = time_tmp / 100;
  1044. rightOfPoint = time_tmp % 100;
  1045. break;
  1046. case SDRAM:
  1047. leftOfPoint = (data[i] & 0xf0) >> 4;
  1048. if (leftOfPoint > 7) {
  1049. leftOfPoint = data[i] & 0x70 >> 4;
  1050. sign = -1;
  1051. }
  1052. rightOfPoint = (data[i] & 0x0f);
  1053. break;
  1054. }
  1055. dimmInfo->dataInputHoldTime =
  1056. (leftOfPoint * 100 + rightOfPoint) * sign;
  1057. DP (printf
  1058. ("Data Input Hold Time [ns]: %d.%d\n\n",
  1059. sign * leftOfPoint, rightOfPoint));
  1060. break;
  1061. /*------------------------------------------------------------------------------------------------------------------------------*/
  1062. }
  1063. }
  1064. /* calculating the sdram density */
  1065. for (i = 0;
  1066. i < dimmInfo->numOfRowAddresses + dimmInfo->numOfColAddresses;
  1067. i++) {
  1068. density = density * 2;
  1069. }
  1070. dimmInfo->deviceDensity = density * dimmInfo->numOfBanksOnEachDevice *
  1071. dimmInfo->sdramWidth;
  1072. dimmInfo->numberOfDevices =
  1073. (dimmInfo->dataWidth / dimmInfo->sdramWidth) *
  1074. dimmInfo->numOfModuleBanks;
  1075. devicesForErrCheck =
  1076. (dimmInfo->dataWidth - 64) / dimmInfo->sdramWidth;
  1077. if ((dimmInfo->errorCheckType == 0x1)
  1078. || (dimmInfo->errorCheckType == 0x2)
  1079. || (dimmInfo->errorCheckType == 0x3)) {
  1080. dimmInfo->size =
  1081. (dimmInfo->deviceDensity / 8) *
  1082. (dimmInfo->numberOfDevices - devicesForErrCheck);
  1083. } else {
  1084. dimmInfo->size =
  1085. (dimmInfo->deviceDensity / 8) *
  1086. dimmInfo->numberOfDevices;
  1087. }
  1088. /* compute the module DRB size */
  1089. tmp = (1 <<
  1090. (dimmInfo->numOfRowAddresses + dimmInfo->numOfColAddresses));
  1091. tmp *= dimmInfo->numOfModuleBanks;
  1092. tmp *= dimmInfo->sdramWidth;
  1093. tmp = tmp >> 24; /* div by 0x4000000 (64M) */
  1094. dimmInfo->drb_size = (uchar) tmp;
  1095. DP (printf ("Module DRB size (n*64Mbit): %d\n", dimmInfo->drb_size));
  1096. /* try a CAS latency of 3 first... */
  1097. /* bit 1 is CL2, bit 2 is CL3 */
  1098. supp_cal = (dimmInfo->suportedCasLatencies & 0x1c) >> 1;
  1099. cal_val = 0;
  1100. if (supp_cal & 8) {
  1101. if (NS10to10PS (data[9]) <= tmemclk)
  1102. cal_val = 6;
  1103. }
  1104. if (supp_cal & 4) {
  1105. if (NS10to10PS (data[9]) <= tmemclk)
  1106. cal_val = 5;
  1107. }
  1108. /* then 2... */
  1109. if (supp_cal & 2) {
  1110. if (NS10to10PS (data[23]) <= tmemclk)
  1111. cal_val = 4;
  1112. }
  1113. DP (printf ("cal_val = %d\n", cal_val * 5));
  1114. /* bummer, did't work... */
  1115. if (cal_val == 0) {
  1116. DP (printf ("Couldn't find a good CAS latency\n"));
  1117. hang ();
  1118. return 0;
  1119. }
  1120. return true;
  1121. }
  1122. /* sets up the GT properly with information passed in */
  1123. int setup_sdram (AUX_MEM_DIMM_INFO * info)
  1124. {
  1125. ulong tmp;
  1126. ulong tmp_sdram_mode = 0; /* 0x141c */
  1127. ulong tmp_dunit_control_low = 0; /* 0x1404 */
  1128. int i;
  1129. /* sanity checking */
  1130. if (!info->numOfModuleBanks) {
  1131. printf ("setup_sdram called with 0 banks\n");
  1132. return 1;
  1133. }
  1134. /* delay line */
  1135. /* Program the GT with the discovered data */
  1136. if (info->registeredAddrAndControlInputs == true)
  1137. DP (printf
  1138. ("Module is registered, but we do not support registered Modules !!!\n"));
  1139. /* delay line */
  1140. set_dfcdlInit (); /* may be its not needed */
  1141. DP (printf ("Delay line set done\n"));
  1142. /* set SDRAM mode NOP */ /* To_do check it */
  1143. GT_REG_WRITE (SDRAM_OPERATION, 0x5);
  1144. while (GTREGREAD (SDRAM_OPERATION) != 0) {
  1145. DP (printf
  1146. ("\n*** SDRAM_OPERATION 1418: Module still busy ... please wait... ***\n"));
  1147. }
  1148. /* SDRAM configuration */
  1149. GT_REG_WRITE (SDRAM_CONFIG, 0x58200400);
  1150. DP (printf ("sdram_conf 0x1400: %08x\n", GTREGREAD (SDRAM_CONFIG)));
  1151. /* SDRAM open pages controll keep open as much as I can */
  1152. GT_REG_WRITE (SDRAM_OPEN_PAGES_CONTROL, 0x0);
  1153. DP (printf
  1154. ("sdram_open_pages_controll 0x1414: %08x\n",
  1155. GTREGREAD (SDRAM_OPEN_PAGES_CONTROL)));
  1156. /* SDRAM D_UNIT_CONTROL_LOW 0x1404 */
  1157. tmp = (GTREGREAD (D_UNIT_CONTROL_LOW) & 0x01); /* Clock Domain Sync from power on reset */
  1158. if (tmp == 0)
  1159. DP (printf ("Core Signals are sync (by HW-Setting)!!!\n"));
  1160. else
  1161. DP (printf
  1162. ("Core Signals syncs. are bypassed (by HW-Setting)!!!\n"));
  1163. /* SDRAM set CAS Lentency according to SPD information */
  1164. switch (info->memoryType) {
  1165. case SDRAM:
  1166. DP (printf ("### SD-RAM not supported yet !!!\n"));
  1167. hang ();
  1168. /* ToDo fill SD-RAM if needed !!!!! */
  1169. break;
  1170. case DDR:
  1171. DP (printf ("### SET-CL for DDR-RAM\n"));
  1172. switch (info->maxClSupported_DDR) {
  1173. case DDR_CL_3:
  1174. tmp_dunit_control_low = 0x3c000000; /* Read-Data sampled on falling edge of Clk */
  1175. tmp_sdram_mode = 0x32; /* CL=3 Burstlength = 4 */
  1176. DP (printf
  1177. ("Max. CL is 3 CLKs 0x141c= %08lx, 0x1404 = %08lx\n",
  1178. tmp_sdram_mode, tmp_dunit_control_low));
  1179. break;
  1180. case DDR_CL_2_5:
  1181. if (tmp == 1) { /* clocks sync */
  1182. tmp_dunit_control_low = 0x24000000; /* Read-Data sampled on falling edge of Clk */
  1183. tmp_sdram_mode = 0x62; /* CL=2,5 Burstlength = 4 */
  1184. DP (printf
  1185. ("Max. CL is 2,5s CLKs 0x141c= %08lx, 0x1404 = %08lx\n",
  1186. tmp_sdram_mode, tmp_dunit_control_low));
  1187. } else { /* clk sync. bypassed */
  1188. tmp_dunit_control_low = 0x03000000; /* Read-Data sampled on rising edge of Clk */
  1189. tmp_sdram_mode = 0x62; /* CL=2,5 Burstlength = 4 */
  1190. DP (printf
  1191. ("Max. CL is 2,5 CLKs 0x141c= %08lx, 0x1404 = %08lx\n",
  1192. tmp_sdram_mode, tmp_dunit_control_low));
  1193. }
  1194. break;
  1195. case DDR_CL_2:
  1196. if (tmp == 1) { /* Sync */
  1197. tmp_dunit_control_low = 0x03000000; /* Read-Data sampled on rising edge of Clk */
  1198. tmp_sdram_mode = 0x22; /* CL=2 Burstlength = 4 */
  1199. DP (printf
  1200. ("Max. CL is 2s CLKs 0x141c= %08lx, 0x1404 = %08lx\n",
  1201. tmp_sdram_mode, tmp_dunit_control_low));
  1202. } else { /* Not sync. */
  1203. tmp_dunit_control_low = 0x3b000000; /* Read-Data sampled on rising edge of Clk */
  1204. tmp_sdram_mode = 0x22; /* CL=2 Burstlength = 4 */
  1205. DP (printf
  1206. ("Max. CL is 2 CLKs 0x141c= %08lx, 0x1404 = %08lx\n",
  1207. tmp_sdram_mode, tmp_dunit_control_low));
  1208. }
  1209. break;
  1210. case DDR_CL_1_5:
  1211. if (tmp == 1) { /* Sync */
  1212. tmp_dunit_control_low = 0x23000000; /* Read-Data sampled on falling edge of Clk */
  1213. tmp_sdram_mode = 0x52; /* CL=1,5 Burstlength = 4 */
  1214. DP (printf
  1215. ("Max. CL is 1,5s CLKs 0x141c= %08lx, 0x1404 = %08lx\n",
  1216. tmp_sdram_mode, tmp_dunit_control_low));
  1217. } else { /* not sync */
  1218. tmp_dunit_control_low = 0x1a000000; /* Read-Data sampled on rising edge of Clk */
  1219. tmp_sdram_mode = 0x52; /* CL=1,5 Burstlength = 4 */
  1220. DP (printf
  1221. ("Max. CL is 1,5 CLKs 0x141c= %08lx, 0x1404 = %08lx\n",
  1222. tmp_sdram_mode, tmp_dunit_control_low));
  1223. }
  1224. break;
  1225. default:
  1226. printf ("Max. CL is out of range %d\n",
  1227. info->maxClSupported_DDR);
  1228. hang ();
  1229. break;
  1230. }
  1231. break;
  1232. }
  1233. /* Write results of CL detection procedure */
  1234. GT_REG_WRITE (SDRAM_MODE, tmp_sdram_mode);
  1235. /* set SDRAM mode SetCommand 0x1418 */
  1236. GT_REG_WRITE (SDRAM_OPERATION, 0x3);
  1237. while (GTREGREAD (SDRAM_OPERATION) != 0) {
  1238. DP (printf
  1239. ("\n*** SDRAM_OPERATION 1418 after SDRAM_MODE: Module still busy ... please wait... ***\n"));
  1240. }
  1241. /* SDRAM D_UNIT_CONTROL_LOW 0x1404 */
  1242. tmp = (GTREGREAD (D_UNIT_CONTROL_LOW) & 0x01); /* Clock Domain Sync from power on reset */
  1243. if (tmp != 1) { /*clocks are not sync */
  1244. /* asyncmode */
  1245. GT_REG_WRITE (D_UNIT_CONTROL_LOW,
  1246. (GTREGREAD (D_UNIT_CONTROL_LOW) & 0x7F) |
  1247. 0x18110780 | tmp_dunit_control_low);
  1248. } else {
  1249. /* syncmode */
  1250. GT_REG_WRITE (D_UNIT_CONTROL_LOW,
  1251. (GTREGREAD (D_UNIT_CONTROL_LOW) & 0x7F) |
  1252. 0x00110000 | tmp_dunit_control_low);
  1253. }
  1254. /* set SDRAM mode SetCommand 0x1418 */
  1255. GT_REG_WRITE (SDRAM_OPERATION, 0x3);
  1256. while (GTREGREAD (SDRAM_OPERATION) != 0) {
  1257. DP (printf
  1258. ("\n*** SDRAM_OPERATION 1418 after D_UNIT_CONTROL_LOW: Module still busy ... please wait... ***\n"));
  1259. }
  1260. /*------------------------------------------------------------------------------ */
  1261. /* bank parameters */
  1262. /* SDRAM address decode register */
  1263. /* program this with the default value */
  1264. tmp = 0x02;
  1265. DP (printf ("drb_size (n*64Mbit): %d\n", info->drb_size));
  1266. switch (info->drb_size) {
  1267. case 1: /* 64 Mbit */
  1268. case 2: /* 128 Mbit */
  1269. DP (printf ("RAM-Device_size 64Mbit or 128Mbit)\n"));
  1270. tmp |= (0x00 << 4);
  1271. break;
  1272. case 4: /* 256 Mbit */
  1273. case 8: /* 512 Mbit */
  1274. DP (printf ("RAM-Device_size 256Mbit or 512Mbit)\n"));
  1275. tmp |= (0x01 << 4);
  1276. break;
  1277. case 16: /* 1 Gbit */
  1278. case 32: /* 2 Gbit */
  1279. DP (printf ("RAM-Device_size 1Gbit or 2Gbit)\n"));
  1280. tmp |= (0x02 << 4);
  1281. break;
  1282. default:
  1283. printf ("Error in dram size calculation\n");
  1284. DP (printf ("Assume: RAM-Device_size 1Gbit or 2Gbit)\n"));
  1285. tmp |= (0x02 << 4);
  1286. return 1;
  1287. }
  1288. /* SDRAM bank parameters */
  1289. /* the param registers for slot 1 (banks 2+3) are offset by 0x8 */
  1290. DP (printf
  1291. ("setting up slot %d config with: %08lx \n", info->slot, tmp));
  1292. GT_REG_WRITE (SDRAM_ADDR_CONTROL, tmp);
  1293. /* ------------------------------------------------------------------------------ */
  1294. DP (printf
  1295. ("setting up sdram_timing_control_low with: %08x \n",
  1296. 0x11511220));
  1297. GT_REG_WRITE (SDRAM_TIMING_CONTROL_LOW, 0x11511220);
  1298. /* ------------------------------------------------------------------------------ */
  1299. /* SDRAM configuration */
  1300. tmp = GTREGREAD (SDRAM_CONFIG);
  1301. if (info->registeredAddrAndControlInputs
  1302. || info->registeredDQMBinputs) {
  1303. tmp |= (1 << 17);
  1304. DP (printf
  1305. ("SPD says: registered Addr. and Cont.: %d; registered DQMBinputs: %d\n",
  1306. info->registeredAddrAndControlInputs,
  1307. info->registeredDQMBinputs));
  1308. }
  1309. /* Use buffer 1 to return read data to the CPU
  1310. * Page 426 MV64360 */
  1311. tmp |= (1 << 26);
  1312. DP (printf
  1313. ("Before Buffer assignment - sdram_conf: %08x\n",
  1314. GTREGREAD (SDRAM_CONFIG)));
  1315. DP (printf
  1316. ("After Buffer assignment - sdram_conf: %08x\n",
  1317. GTREGREAD (SDRAM_CONFIG)));
  1318. /* SDRAM timing To_do: */
  1319. tmp = GTREGREAD (SDRAM_TIMING_CONTROL_HIGH);
  1320. DP (printf ("# sdram_timing_control_high is : %08lx \n", tmp));
  1321. /* SDRAM address decode register */
  1322. /* program this with the default value */
  1323. tmp = GTREGREAD (SDRAM_ADDR_CONTROL);
  1324. DP (printf
  1325. ("SDRAM address control (before: decode): %08x ",
  1326. GTREGREAD (SDRAM_ADDR_CONTROL)));
  1327. GT_REG_WRITE (SDRAM_ADDR_CONTROL, (tmp | 0x2));
  1328. DP (printf
  1329. ("SDRAM address control (after: decode): %08x\n",
  1330. GTREGREAD (SDRAM_ADDR_CONTROL)));
  1331. /* set the SDRAM configuration for each bank */
  1332. /* for (i = info->slot * 2; i < ((info->slot * 2) + info->banks); i++) */
  1333. {
  1334. int l, l1;
  1335. i = info->slot;
  1336. DP (printf
  1337. ("\n*** Running a MRS cycle for bank %d ***\n", i));
  1338. /* map the bank */
  1339. memory_map_bank (i, 0, GB / 4);
  1340. #if 1 /* test only */
  1341. tmp = GTREGREAD (SDRAM_MODE);
  1342. GT_REG_WRITE (EXTENDED_DRAM_MODE, 0x0);
  1343. GT_REG_WRITE (SDRAM_OPERATION, 0x4);
  1344. while (GTREGREAD (SDRAM_OPERATION) != 0) {
  1345. DP (printf
  1346. ("\n*** SDRAM_OPERATION 1418 after SDRAM_MODE: Module still busy ... please wait... ***\n"));
  1347. }
  1348. GT_REG_WRITE (SDRAM_MODE, tmp | 0x80);
  1349. GT_REG_WRITE (SDRAM_OPERATION, 0x3);
  1350. while (GTREGREAD (SDRAM_OPERATION) != 0) {
  1351. DP (printf
  1352. ("\n*** SDRAM_OPERATION 1418 after SDRAM_MODE: Module still busy ... please wait... ***\n"));
  1353. }
  1354. l1 = 0;
  1355. for (l=0;l<200;l++)
  1356. l1 += GTREGREAD (SDRAM_OPERATION);
  1357. GT_REG_WRITE (SDRAM_MODE, tmp);
  1358. GT_REG_WRITE (SDRAM_OPERATION, 0x3);
  1359. while (GTREGREAD (SDRAM_OPERATION) != 0) {
  1360. DP (printf
  1361. ("\n*** SDRAM_OPERATION 1418 after SDRAM_MODE: Module still busy ... please wait... ***\n"));
  1362. }
  1363. /* switch back to normal operation mode */
  1364. GT_REG_WRITE (SDRAM_OPERATION, 0x5);
  1365. while (GTREGREAD (SDRAM_OPERATION) != 0) {
  1366. DP (printf
  1367. ("\n*** SDRAM_OPERATION 1418 after SDRAM_MODE: Module still busy ... please wait... ***\n"));
  1368. }
  1369. #endif /* test only */
  1370. /* unmap the bank */
  1371. memory_map_bank (i, 0, 0);
  1372. }
  1373. return 0;
  1374. }
  1375. /*
  1376. * Check memory range for valid RAM. A simple memory test determines
  1377. * the actually available RAM size between addresses `base' and
  1378. * `base + maxsize'. Some (not all) hardware errors are detected:
  1379. * - short between address lines
  1380. * - short between data lines
  1381. */
  1382. long int
  1383. dram_size(long int *base, long int maxsize)
  1384. {
  1385. volatile long int *addr, *b=base;
  1386. long int cnt, val, save1, save2;
  1387. #define STARTVAL (1<<20) /* start test at 1M */
  1388. for (cnt = STARTVAL/sizeof(long); cnt < maxsize/sizeof(long); cnt <<= 1) {
  1389. addr = base + cnt; /* pointer arith! */
  1390. save1=*addr; /* save contents of addr */
  1391. save2=*b; /* save contents of base */
  1392. *addr=cnt; /* write cnt to addr */
  1393. *b=0; /* put null at base */
  1394. /* check at base address */
  1395. if ((*b) != 0) {
  1396. *addr=save1; /* restore *addr */
  1397. *b=save2; /* restore *b */
  1398. return (0);
  1399. }
  1400. val = *addr; /* read *addr */
  1401. val = *addr; /* read *addr */
  1402. *addr=save1;
  1403. *b=save2;
  1404. if (val != cnt) {
  1405. DP(printf("Found %08x at Address %08x (failure)\n", (unsigned int)val, (unsigned int) addr));
  1406. /* fix boundary condition.. STARTVAL means zero */
  1407. if(cnt==STARTVAL/sizeof(long)) cnt=0;
  1408. return (cnt * sizeof(long));
  1409. }
  1410. }
  1411. return maxsize;
  1412. }
  1413. /* ------------------------------------------------------------------------- */
  1414. /* ppcboot interface function to SDRAM init - this is where all the
  1415. * controlling logic happens */
  1416. phys_size_t
  1417. initdram(int board_type)
  1418. {
  1419. int s0 = 0, s1 = 0;
  1420. int checkbank[4] = { [0 ... 3] = 0 };
  1421. ulong bank_no, realsize, total, check;
  1422. AUX_MEM_DIMM_INFO dimmInfo1;
  1423. AUX_MEM_DIMM_INFO dimmInfo2;
  1424. int nhr;
  1425. /* first, use the SPD to get info about the SDRAM/ DDRRAM */
  1426. /* check the NHR bit and skip mem init if it's already done */
  1427. nhr = get_hid0() & (1 << 16);
  1428. if (nhr) {
  1429. printf("Skipping SD- DDRRAM setup due to NHR bit being set\n");
  1430. } else {
  1431. /* DIMM0 */
  1432. s0 = check_dimm(0, &dimmInfo1);
  1433. /* DIMM1 */
  1434. s1 = check_dimm(1, &dimmInfo2);
  1435. memory_map_bank(0, 0, 0);
  1436. memory_map_bank(1, 0, 0);
  1437. memory_map_bank(2, 0, 0);
  1438. memory_map_bank(3, 0, 0);
  1439. if (dimmInfo1.numOfModuleBanks && setup_sdram(&dimmInfo1)) {
  1440. printf("Setup for DIMM1 failed.\n");
  1441. }
  1442. if (dimmInfo2.numOfModuleBanks && setup_sdram(&dimmInfo2)) {
  1443. printf("Setup for DIMM2 failed.\n");
  1444. }
  1445. /* set the NHR bit */
  1446. set_hid0(get_hid0() | (1 << 16));
  1447. }
  1448. /* next, size the SDRAM banks */
  1449. realsize = total = 0;
  1450. check = GB/4;
  1451. if (dimmInfo1.numOfModuleBanks > 0) {checkbank[0] = 1; printf("-- DIMM1 has 1 bank\n");}
  1452. if (dimmInfo1.numOfModuleBanks > 1) {checkbank[1] = 1; printf("-- DIMM1 has 2 banks\n");}
  1453. if (dimmInfo1.numOfModuleBanks > 2)
  1454. printf("Error, SPD claims DIMM1 has >2 banks\n");
  1455. if (dimmInfo2.numOfModuleBanks > 0) {checkbank[2] = 1; printf("-- DIMM2 has 1 bank\n");}
  1456. if (dimmInfo2.numOfModuleBanks > 1) {checkbank[3] = 1; printf("-- DIMM2 has 2 banks\n");}
  1457. if (dimmInfo2.numOfModuleBanks > 2)
  1458. printf("Error, SPD claims DIMM2 has >2 banks\n");
  1459. for (bank_no = 0; bank_no < CFG_DRAM_BANKS; bank_no++) {
  1460. /* skip over banks that are not populated */
  1461. if (! checkbank[bank_no])
  1462. continue;
  1463. if ((total + check) > CFG_GT_REGS)
  1464. check = CFG_GT_REGS - total;
  1465. memory_map_bank(bank_no, total, check);
  1466. realsize = dram_size((long int *)total, check);
  1467. memory_map_bank(bank_no, total, realsize);
  1468. total += realsize;
  1469. }
  1470. /* Setup Ethernet DMA Adress window to DRAM Area */
  1471. return(total);
  1472. }
  1473. /* ***************************************************************************************
  1474. ! * SDRAM INIT *
  1475. ! * This procedure detect all Sdram types: 64, 128, 256, 512 Mbit, 1Gbit and 2Gb *
  1476. ! * This procedure fits only the Atlantis *
  1477. ! * *
  1478. ! *************************************************************************************** */
  1479. /* ***************************************************************************************
  1480. ! * DFCDL initialize MV643xx Design Considerations *
  1481. ! * *
  1482. ! *************************************************************************************** */
  1483. int set_dfcdlInit (void)
  1484. {
  1485. int i;
  1486. unsigned int dfcdl_word = 0x0000014f;
  1487. for (i = 0; i < 64; i++) {
  1488. GT_REG_WRITE (SRAM_DATA0, dfcdl_word);
  1489. }
  1490. GT_REG_WRITE (DFCDL_CONFIG0, 0x00300000); /* enable dynamic delay line updating */
  1491. return (0);
  1492. }