#define rSYSCFG  (0x87FFFF90)
#define SYSCFG  (0x3FF0000+0x0000)

#define ExtIOBase (0x360<<0)
#define VSF  (0x1<<15)
#define REN  (0x1<<16)
#define tCHR  (0x0<<17)
#define tCSR  (0x0<<20)
#define fMCLK 50
#define RefCountValue ((2048+1-(16*fMCLK))<<21)
#define rREFEXTCON (RefCountValue|tCSR|tCHR|REN|VSF|ExtIOBase)

#define PMC0  (0x0<<0)
#define tPA0  (0x0<<2)
#define tACC0  (0x6<<4)
#define ROM_BASE0_R ((0x00000000>>16)<<10)
#define ROM_NEXT0_R ((0x00200000>>16)<<20)
#define rROMCON0_R (ROM_NEXT0_R|ROM_BASE0_R|tACC0|tPA0|PMC0)

#define StRC0  (0x1<<7)
#define StRP0  (0x1<<8)
#define SDRAM_BASE0_R ((0x01000000>>16)<<10)
#define SDRAM_NEXT0_R ((0x01800000>>16)<<20)
#define SCAN0  (0x0<<30)
#define rSDRAMCON0_R (SCAN0|SDRAM_NEXT0_R|SDRAM_BASE0_R|StRP0|StRC0)
#define SYS_INIT_BASE (0x3ff0000+0x3010)

        .align
        .text
        .global _init_ram,hardware_init_hook
hardware_init_hook:
_init_ram:              
  ldr r0, =SYSCFG
  ldr r1, =rSYSCFG
  str r1, [r0]

  /* set  reset memory map */
  adr r0, SDRAM_SYSINIT_RESET
  ldmia r0, {r1-r12}
  ldr r0, =SYS_INIT_BASE
  stmia r0, {r1-r12}
  mov pc,lr                     /*  return to caller */

SDRAM_SYSINIT_RESET: 
  .word 0x0ffffffa
  .word rROMCON0_R
  .word 0x0
  .word 0x0
  .word 0x0
  .word 0x0
  .word 0x0
  .word rSDRAMCON0_R
  .word 0x0
  .word 0x0
  .word 0x0
  .word rREFEXTCON
