sdram_init.c 53 KB

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