spd_sdram.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  1. /*
  2. * (C) Copyright 2006 Freescale Semiconductor, Inc.
  3. *
  4. * (C) Copyright 2006
  5. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  6. *
  7. * Copyright 2004 Freescale Semiconductor.
  8. * (C) Copyright 2003 Motorola Inc.
  9. * Xianghua Xiao (X.Xiao@motorola.com)
  10. *
  11. * See file CREDITS for list of people who contributed to this
  12. * project.
  13. *
  14. * This program is free software; you can redistribute it and/or
  15. * modify it under the terms of the GNU General Public License as
  16. * published by the Free Software Foundation; either version 2 of
  17. * the License, or (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, write to the Free Software
  26. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  27. * MA 02111-1307 USA
  28. *
  29. * Change log:
  30. *
  31. * 20050101: Eran Liberty (liberty@freescale.com)
  32. * Initial file creating (porting from 85XX & 8260)
  33. * 20060601: Dave Liu (daveliu@freescale.com)
  34. * DDR ECC support
  35. * unify variable names for 83xx
  36. * code cleanup
  37. */
  38. #include <common.h>
  39. #include <asm/processor.h>
  40. #include <i2c.h>
  41. #include <spd.h>
  42. #include <asm/mmu.h>
  43. #include <spd_sdram.h>
  44. #ifdef CONFIG_SPD_EEPROM
  45. #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRC)
  46. extern void dma_init(void);
  47. extern uint dma_check(void);
  48. extern int dma_xfer(void *dest, uint count, void *src);
  49. #endif
  50. #ifndef CFG_READ_SPD
  51. #define CFG_READ_SPD i2c_read
  52. #endif
  53. /*
  54. * Convert picoseconds into clock cycles (rounding up if needed).
  55. */
  56. extern ulong get_ddr_clk(ulong dummy);
  57. int
  58. picos_to_clk(int picos)
  59. {
  60. unsigned int ddr_bus_clk;
  61. int clks;
  62. ddr_bus_clk = get_ddr_clk(0) >> 1;
  63. clks = picos / ((1000000000 / ddr_bus_clk) * 1000);
  64. if (picos % ((1000000000 / ddr_bus_clk) * 1000) !=0) {
  65. clks++;
  66. }
  67. return clks;
  68. }
  69. unsigned int banksize(unsigned char row_dens)
  70. {
  71. return ((row_dens >> 2) | ((row_dens & 3) << 6)) << 24;
  72. }
  73. int read_spd(uint addr)
  74. {
  75. return ((int) addr);
  76. }
  77. #undef SPD_DEBUG
  78. #ifdef SPD_DEBUG
  79. static void spd_debug(spd_eeprom_t *spd)
  80. {
  81. printf ("\nDIMM type: %-18.18s\n", spd->mpart);
  82. printf ("SPD size: %d\n", spd->info_size);
  83. printf ("EEPROM size: %d\n", 1 << spd->chip_size);
  84. printf ("Memory type: %d\n", spd->mem_type);
  85. printf ("Row addr: %d\n", spd->nrow_addr);
  86. printf ("Column addr: %d\n", spd->ncol_addr);
  87. printf ("# of rows: %d\n", spd->nrows);
  88. printf ("Row density: %d\n", spd->row_dens);
  89. printf ("# of banks: %d\n", spd->nbanks);
  90. printf ("Data width: %d\n",
  91. 256 * spd->dataw_msb + spd->dataw_lsb);
  92. printf ("Chip width: %d\n", spd->primw);
  93. printf ("Refresh rate: %02X\n", spd->refresh);
  94. printf ("CAS latencies: %02X\n", spd->cas_lat);
  95. printf ("Write latencies: %02X\n", spd->write_lat);
  96. printf ("tRP: %d\n", spd->trp);
  97. printf ("tRCD: %d\n", spd->trcd);
  98. printf ("\n");
  99. }
  100. #endif /* SPD_DEBUG */
  101. long int spd_sdram()
  102. {
  103. volatile immap_t *immap = (immap_t *)CFG_IMMRBAR;
  104. volatile ddr83xx_t *ddr = &immap->ddr;
  105. volatile law83xx_t *ecm = &immap->sysconf.ddrlaw[0];
  106. spd_eeprom_t spd;
  107. unsigned tmp;
  108. unsigned int memsize;
  109. unsigned int law_size;
  110. unsigned char caslat, caslat_ctrl;
  111. unsigned char burstlen;
  112. unsigned int max_bus_clk;
  113. unsigned int max_data_rate, effective_data_rate;
  114. unsigned int ddrc_clk;
  115. unsigned int refresh_clk;
  116. unsigned sdram_cfg;
  117. unsigned int ddrc_ecc_enable;
  118. /* Read SPD parameters with I2C */
  119. CFG_READ_SPD(SPD_EEPROM_ADDRESS, 0, 1, (uchar *) & spd, sizeof (spd));
  120. #ifdef SPD_DEBUG
  121. spd_debug(&spd);
  122. #endif
  123. /* Check the memory type */
  124. if (spd.mem_type != SPD_MEMTYPE_DDR) {
  125. printf("DDR: Module mem type is %02X\n", spd.mem_type);
  126. return 0;
  127. }
  128. /* Check the number of physical bank */
  129. if (spd.nrows > 2) {
  130. printf("DDR: The number of physical bank is %02X\n", spd.nrows);
  131. return 0;
  132. }
  133. /* Check if the number of row of the module is in the range of DDRC */
  134. if (spd.nrow_addr < 12 || spd.nrow_addr > 14) {
  135. printf("DDR: Row number is out of range of DDRC, row=%02X\n",
  136. spd.nrow_addr);
  137. return 0;
  138. }
  139. /* Check if the number of col of the module is in the range of DDRC */
  140. if (spd.ncol_addr < 8 || spd.ncol_addr > 11) {
  141. printf("DDR: Col number is out of range of DDRC, col=%02X\n",
  142. spd.ncol_addr);
  143. return 0;
  144. }
  145. /* Setup DDR chip select register */
  146. ddr->csbnds[2].csbnds = (banksize(spd.row_dens) >> 24) - 1;
  147. ddr->cs_config[2] = ( 1 << 31
  148. | (spd.nrow_addr - 12) << 8
  149. | (spd.ncol_addr - 8) );
  150. debug("\n");
  151. debug("cs2_bnds = 0x%08x\n",ddr->csbnds[2].csbnds);
  152. debug("cs2_config = 0x%08x\n",ddr->cs_config[2]);
  153. if (spd.nrows == 2) {
  154. ddr->csbnds[3].csbnds = ( (banksize(spd.row_dens) >> 8)
  155. | ((banksize(spd.row_dens) >> 23) - 1) );
  156. ddr->cs_config[3] = ( 1<<31
  157. | (spd.nrow_addr-12) << 8
  158. | (spd.ncol_addr-8) );
  159. debug("cs3_bnds = 0x%08x\n",ddr->csbnds[3].csbnds);
  160. debug("cs3_config = 0x%08x\n",ddr->cs_config[3]);
  161. }
  162. if (spd.mem_type != 0x07) {
  163. puts("No DDR module found!\n");
  164. return 0;
  165. }
  166. /*
  167. * Figure out memory size in Megabytes.
  168. */
  169. memsize = spd.nrows * banksize(spd.row_dens) / 0x100000;
  170. /*
  171. * First supported LAW size is 16M, at LAWAR_SIZE_16M == 23.
  172. */
  173. law_size = 19 + __ilog2(memsize);
  174. /*
  175. * Set up LAWBAR for all of DDR.
  176. */
  177. ecm->bar = ((CFG_DDR_SDRAM_BASE>>12) & 0xfffff);
  178. ecm->ar = (LAWAR_EN | LAWAR_TRGT_IF_DDR | (LAWAR_SIZE & law_size));
  179. debug("DDR:bar=0x%08x\n", ecm->bar);
  180. debug("DDR:ar=0x%08x\n", ecm->ar);
  181. /*
  182. * Find the largest CAS by locating the highest 1 bit
  183. * in the spd.cas_lat field. Translate it to a DDR
  184. * controller field value:
  185. *
  186. * CAS Lat DDR I Ctrl
  187. * Clocks SPD Bit Value
  188. * -------+--------+---------
  189. * 1.0 0 001
  190. * 1.5 1 010
  191. * 2.0 2 011
  192. * 2.5 3 100
  193. * 3.0 4 101
  194. * 3.5 5 110
  195. * 4.0 6 111
  196. */
  197. caslat = __ilog2(spd.cas_lat);
  198. if (caslat > 4 ) {
  199. printf("DDR: Invalid SPD CAS Latency, caslat=%02X\n", caslat);
  200. return 0;
  201. }
  202. max_bus_clk = 1000 *10 / (((spd.clk_cycle & 0xF0) >> 4) * 10
  203. + (spd.clk_cycle & 0x0f));
  204. max_data_rate = max_bus_clk * 2;
  205. debug("DDR:Module maximum data rate is: %dMhz\n", max_data_rate);
  206. ddrc_clk = get_ddr_clk(0) / 1000000;
  207. if (max_data_rate >= 390) { /* it is DDR 400 */
  208. printf("DDR: platform not support DDR 400\n");
  209. return 0;
  210. } else if (max_data_rate >= 323) { /* it is DDR 333 */
  211. if (ddrc_clk <= 350 && ddrc_clk > 280) {
  212. /* DDRC clk at 280~350 */
  213. effective_data_rate = 333; /* 6ns */
  214. caslat = caslat;
  215. } else if (ddrc_clk <= 280 && ddrc_clk > 230) {
  216. /* DDRC clk at 230~280 */
  217. if (spd.clk_cycle2 == 0x75) {
  218. effective_data_rate = 266; /* 7.5ns */
  219. caslat = caslat - 1;
  220. }
  221. } else if (ddrc_clk <= 230 && ddrc_clk > 90) {
  222. /* DDRC clk at 90~230 */
  223. if (spd.clk_cycle3 == 0xa0) {
  224. effective_data_rate = 200; /* 10ns */
  225. caslat = caslat - 2;
  226. }
  227. }
  228. } else if (max_data_rate >= 256) { /* it is DDR 266 */
  229. if (ddrc_clk <= 350 && ddrc_clk > 280) {
  230. /* DDRC clk at 280~350 */
  231. printf("DDR: DDR controller freq is more than "
  232. "max data rate of the module\n");
  233. return 0;
  234. } else if (ddrc_clk <= 280 && ddrc_clk > 230) {
  235. /* DDRC clk at 230~280 */
  236. effective_data_rate = 266; /* 7.5ns */
  237. caslat = caslat;
  238. } else if (ddrc_clk <= 230 && ddrc_clk > 90) {
  239. /* DDRC clk at 90~230 */
  240. if (spd.clk_cycle2 == 0xa0) {
  241. effective_data_rate = 200; /* 10ns */
  242. caslat = caslat - 1;
  243. }
  244. }
  245. } else if (max_data_rate >= 190) { /* it is DDR 200 */
  246. if (ddrc_clk <= 350 && ddrc_clk > 230) {
  247. /* DDRC clk at 230~350 */
  248. printf("DDR: DDR controller freq is more than "
  249. "max data rate of the module\n");
  250. return 0;
  251. } else if (ddrc_clk <= 230 && ddrc_clk > 90) {
  252. /* DDRC clk at 90~230 */
  253. effective_data_rate = 200; /* 10ns */
  254. caslat = caslat;
  255. }
  256. }
  257. /*
  258. * note: caslat must also be programmed into ddr->sdram_mode
  259. * register.
  260. *
  261. * note: WRREC(Twr) and WRTORD(Twtr) are not in SPD,
  262. * use conservative value here.
  263. */
  264. caslat_ctrl = (caslat + 1) & 0x07; /* see as above */
  265. ddr->timing_cfg_1 =
  266. (((picos_to_clk(spd.trp * 250) & 0x07) << 28 ) |
  267. ((picos_to_clk(spd.tras * 1000) & 0x0f ) << 24 ) |
  268. ((picos_to_clk(spd.trcd * 250) & 0x07) << 20 ) |
  269. ((caslat_ctrl & 0x07) << 16 ) |
  270. (((picos_to_clk(spd.trfc * 1000) - 8) & 0x0f) << 12 ) |
  271. ( 0x300 ) |
  272. ((picos_to_clk(spd.trrd * 250) & 0x07) << 4) | 1);
  273. ddr->timing_cfg_2 = 0x00000800;
  274. debug("DDR:timing_cfg_1=0x%08x\n", ddr->timing_cfg_1);
  275. debug("DDR:timing_cfg_2=0x%08x\n", ddr->timing_cfg_2);
  276. /* Setup init value, but not enable */
  277. ddr->sdram_cfg = 0x42000000;
  278. /* Check DIMM data bus width */
  279. if (spd.dataw_lsb == 0x20)
  280. {
  281. burstlen = 0x03; /* 32 bit data bus, burst len is 8 */
  282. printf("\n DDR DIMM: data bus width is 32 bit");
  283. }
  284. else
  285. {
  286. burstlen = 0x02; /* Others act as 64 bit bus, burst len is 4 */
  287. printf("\n DDR DIMM: data bus width is 64 bit");
  288. }
  289. /* Is this an ECC DDR chip? */
  290. if (spd.config == 0x02) {
  291. printf(" with ECC\n");
  292. }
  293. else
  294. printf(" without ECC\n");
  295. /* Burst length is always 4 for 64 bit data bus, 8 for 32 bit data bus,
  296. Burst type is sequential
  297. */
  298. switch(caslat) {
  299. case 1:
  300. ddr->sdram_mode = 0x50 | burstlen; /* CL=1.5 */
  301. break;
  302. case 2:
  303. ddr->sdram_mode = 0x20 | burstlen; /* CL=2.0 */
  304. break;
  305. case 3:
  306. ddr->sdram_mode = 0x60 | burstlen; /* CL=2.5 */
  307. break;
  308. case 4:
  309. ddr->sdram_mode = 0x30 | burstlen; /* CL=3.0 */
  310. break;
  311. default:
  312. printf("DDR:only CAS Latency 1.5, 2.0, 2.5, 3.0 "
  313. "is supported.\n");
  314. return 0;
  315. }
  316. debug("DDR:sdram_mode=0x%08x\n", ddr->sdram_mode);
  317. switch(spd.refresh) {
  318. case 0x00:
  319. case 0x80:
  320. tmp = picos_to_clk(15625000);
  321. break;
  322. case 0x01:
  323. case 0x81:
  324. tmp = picos_to_clk(3900000);
  325. break;
  326. case 0x02:
  327. case 0x82:
  328. tmp = picos_to_clk(7800000);
  329. break;
  330. case 0x03:
  331. case 0x83:
  332. tmp = picos_to_clk(31300000);
  333. break;
  334. case 0x04:
  335. case 0x84:
  336. tmp = picos_to_clk(62500000);
  337. break;
  338. case 0x05:
  339. case 0x85:
  340. tmp = picos_to_clk(125000000);
  341. break;
  342. default:
  343. tmp = 0x512;
  344. break;
  345. }
  346. /*
  347. * Set BSTOPRE to 0x100 for page mode
  348. * If auto-charge is used, set BSTOPRE = 0
  349. */
  350. ddr->sdram_interval = ((tmp & 0x3fff) << 16) | 0x100;
  351. debug("DDR:sdram_interval=0x%08x\n", ddr->sdram_interval);
  352. /* SS_EN = 0, source synchronous disable
  353. * CLK_ADJST = 0, MCK/MCK# is launched aligned with addr/cmd
  354. */
  355. ddr->sdram_clk_cntl = 0x00000000;
  356. debug("DDR:sdram_clk_cntl=0x%08x\n", ddr->sdram_clk_cntl);
  357. asm("sync;isync");
  358. udelay(600);
  359. /*
  360. * Figure out the settings for the sdram_cfg register. Build up
  361. * the entire register in 'tmp' before writing since the write into
  362. * the register will actually enable the memory controller, and all
  363. * settings must be done before enabling.
  364. *
  365. * sdram_cfg[0] = 1 (ddr sdram logic enable)
  366. * sdram_cfg[1] = 1 (self-refresh-enable)
  367. * sdram_cfg[6:7] = 2 (SDRAM type = DDR SDRAM)
  368. * sdram_cfg[12] = 0 (32_BE =0 , 64 bit bus mode)
  369. * sdram_cfg[13] = 0 (8_BE =0, 4-beat bursts)
  370. */
  371. sdram_cfg = 0xC2000000;
  372. /* sdram_cfg[3] = RD_EN - registered DIMM enable */
  373. if (spd.mod_attr & 0x02) {
  374. sdram_cfg |= 0x10000000;
  375. }
  376. /* The DIMM is 32bit width */
  377. if (spd.dataw_lsb == 0x20) {
  378. sdram_cfg |= 0x000C0000;
  379. }
  380. ddrc_ecc_enable = 0;
  381. #if defined(CONFIG_DDR_ECC)
  382. /* Enable ECC with sdram_cfg[2] */
  383. if (spd.config == 0x02) {
  384. sdram_cfg |= 0x20000000;
  385. ddrc_ecc_enable = 1;
  386. /* disable error detection */
  387. ddr->err_disable = ~ECC_ERROR_ENABLE;
  388. /* set single bit error threshold to maximum value,
  389. * reset counter to zero */
  390. ddr->err_sbe = (255 << ECC_ERROR_MAN_SBET_SHIFT) |
  391. (0 << ECC_ERROR_MAN_SBEC_SHIFT);
  392. }
  393. debug("DDR:err_disable=0x%08x\n", ddr->err_disable);
  394. debug("DDR:err_sbe=0x%08x\n", ddr->err_sbe);
  395. #endif
  396. printf(" DDRC ECC mode: %s", ddrc_ecc_enable ? "ON":"OFF");
  397. #if defined(CONFIG_DDR_2T_TIMING)
  398. /*
  399. * Enable 2T timing by setting sdram_cfg[16].
  400. */
  401. sdram_cfg |= SDRAM_CFG_2T_EN;
  402. #endif
  403. /* Enable controller, and GO! */
  404. ddr->sdram_cfg = sdram_cfg;
  405. asm("sync;isync");
  406. udelay(500);
  407. debug("DDR:sdram_cfg=0x%08x\n", ddr->sdram_cfg);
  408. return memsize; /*in MBytes*/
  409. }
  410. #endif /* CONFIG_SPD_EEPROM */
  411. #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRC)
  412. /*
  413. * Use timebase counter, get_timer() is not availabe
  414. * at this point of initialization yet.
  415. */
  416. static __inline__ unsigned long get_tbms (void)
  417. {
  418. unsigned long tbl;
  419. unsigned long tbu1, tbu2;
  420. unsigned long ms;
  421. unsigned long long tmp;
  422. ulong tbclk = get_tbclk();
  423. /* get the timebase ticks */
  424. do {
  425. asm volatile ("mftbu %0":"=r" (tbu1):);
  426. asm volatile ("mftb %0":"=r" (tbl):);
  427. asm volatile ("mftbu %0":"=r" (tbu2):);
  428. } while (tbu1 != tbu2);
  429. /* convert ticks to ms */
  430. tmp = (unsigned long long)(tbu1);
  431. tmp = (tmp << 32);
  432. tmp += (unsigned long long)(tbl);
  433. ms = tmp/(tbclk/1000);
  434. return ms;
  435. }
  436. /*
  437. * Initialize all of memory for ECC, then enable errors.
  438. */
  439. /* #define CONFIG_DDR_ECC_INIT_VIA_DMA */
  440. void ddr_enable_ecc(unsigned int dram_size)
  441. {
  442. uint *p;
  443. volatile immap_t *immap = (immap_t *)CFG_IMMRBAR;
  444. volatile ddr83xx_t *ddr= &immap->ddr;
  445. unsigned long t_start, t_end;
  446. #if defined(CONFIG_DDR_ECC_INIT_VIA_DMA)
  447. uint i;
  448. #endif
  449. debug("Initialize a Cachline in DRAM\n");
  450. icache_enable();
  451. #if defined(CONFIG_DDR_ECC_INIT_VIA_DMA)
  452. /* Initialise DMA for direct Transfers */
  453. dma_init();
  454. #endif
  455. t_start = get_tbms();
  456. #if !defined(CONFIG_DDR_ECC_INIT_VIA_DMA)
  457. debug("DDR init: Cache flush method\n");
  458. for (p = 0; p < (uint *)(dram_size); p++) {
  459. if (((unsigned int)p & 0x1f) == 0) {
  460. ppcDcbz((unsigned long) p);
  461. }
  462. /* write pattern to cache and flush */
  463. *p = (unsigned int)0xdeadbeef;
  464. if (((unsigned int)p & 0x1c) == 0x1c) {
  465. ppcDcbf((unsigned long) p);
  466. }
  467. }
  468. #else
  469. printf("DDR init: DMA method\n");
  470. for (p = 0; p < (uint *)(8 * 1024); p++) {
  471. /* zero one data cache line */
  472. if (((unsigned int)p & 0x1f) == 0) {
  473. ppcDcbz((unsigned long)p);
  474. }
  475. /* write pattern to it and flush */
  476. *p = (unsigned int)0xdeadbeef;
  477. if (((unsigned int)p & 0x1c) == 0x1c) {
  478. ppcDcbf((unsigned long)p);
  479. }
  480. }
  481. /* 8K */
  482. dma_xfer((uint *)0x2000, 0x2000, (uint *)0);
  483. /* 16K */
  484. dma_xfer((uint *)0x4000, 0x4000, (uint *)0);
  485. /* 32K */
  486. dma_xfer((uint *)0x8000, 0x8000, (uint *)0);
  487. /* 64K */
  488. dma_xfer((uint *)0x10000, 0x10000, (uint *)0);
  489. /* 128k */
  490. dma_xfer((uint *)0x20000, 0x20000, (uint *)0);
  491. /* 256k */
  492. dma_xfer((uint *)0x40000, 0x40000, (uint *)0);
  493. /* 512k */
  494. dma_xfer((uint *)0x80000, 0x80000, (uint *)0);
  495. /* 1M */
  496. dma_xfer((uint *)0x100000, 0x100000, (uint *)0);
  497. /* 2M */
  498. dma_xfer((uint *)0x200000, 0x200000, (uint *)0);
  499. /* 4M */
  500. dma_xfer((uint *)0x400000, 0x400000, (uint *)0);
  501. for (i = 1; i < dram_size / 0x800000; i++) {
  502. dma_xfer((uint *)(0x800000*i), 0x800000, (uint *)0);
  503. }
  504. #endif
  505. t_end = get_tbms();
  506. icache_disable();
  507. debug("\nREADY!!\n");
  508. debug("ddr init duration: %ld ms\n", t_end - t_start);
  509. /* Clear All ECC Errors */
  510. if ((ddr->err_detect & ECC_ERROR_DETECT_MME) == ECC_ERROR_DETECT_MME)
  511. ddr->err_detect |= ECC_ERROR_DETECT_MME;
  512. if ((ddr->err_detect & ECC_ERROR_DETECT_MBE) == ECC_ERROR_DETECT_MBE)
  513. ddr->err_detect |= ECC_ERROR_DETECT_MBE;
  514. if ((ddr->err_detect & ECC_ERROR_DETECT_SBE) == ECC_ERROR_DETECT_SBE)
  515. ddr->err_detect |= ECC_ERROR_DETECT_SBE;
  516. if ((ddr->err_detect & ECC_ERROR_DETECT_MSE) == ECC_ERROR_DETECT_MSE)
  517. ddr->err_detect |= ECC_ERROR_DETECT_MSE;
  518. /* Disable ECC-Interrupts */
  519. ddr->err_int_en &= ECC_ERR_INT_DISABLE;
  520. /* Enable errors for ECC */
  521. ddr->err_disable &= ECC_ERROR_ENABLE;
  522. __asm__ __volatile__ ("sync");
  523. __asm__ __volatile__ ("isync");
  524. }
  525. #endif /* CONFIG_DDR_ECC */