#include "ecc.h"
#include "common.h"
#include "ddr.h"







#if 0

void ecc_init(void)
{

	ecc_ddr3_init();
	ecc_ocram_init();
}

void ecc_ddr3_init(void)
{
 uint32 memStart = 0x80000000;
 uint32 memSize = 0x01000000;
	uint32 i;


  /* Re-configure the DDR controller for an 8-bit port width */ 
  reg32_write(DDR_CR078, 0x0000010c);	// reduc = 1
  
  /* Enable ECC - reporting and correcting on */
  reg32_write(DDR_CR057, 0x03000000);	// ctrl_raw = 11
  
  /* Need to disable checking on partial writes while initializing the memory */ 
  reg32_write(DDR_CR058, 0x01000000);	// ctrl_raw = 11

  printf("Writing initial values to DDR3\n");
			
  for ( i=0; i<memSize; i=i+4 )
  {
    *(uint32 *) (memStart + i) = memStart + i;
  }
	
  /* Now that the entire memory has been initialized re-enable RMW checking */ 
  reg32_write(DDR_CR058, 0x00000000);	

  printf("SDRAM Initialization Complete!\n");      

}

void ecc_ocram_init(void)
{
 uint32 memStart = 0x3F040000;
 uint32 memSize = 0x040000;
	uint32 i;


  /* ste bit ER1BR & ERNCR */ 
  reg32_write(OCMECR, 0x00000101);	
  
  /*  */
  reg32_write(OCRMDR1, 0x00000001);	
  
 
  printf("Writing initial values to OCRAM\n");
			
  for ( i=0; i<memSize; i=i+4 )
  {
    *(uint32 *) (memStart + i) = memStart + i;
  }
	
   reg32_write(OCRMDR1, 0x00000003);

  printf("SDRAM Initialization Complete!\n");      

}

#endif

