2 * @brief emif Driver Implementation File
\r
3 * @date 15.January.2012
\r
8 /* (c) Texas Instruments 2009-2012, All rights reserved. */
\r
12 #include "ti_drv_emif.h"
\r
14 /** @fn void emif_SDRAMInit()
\r
15 * @brief Initializes the emif Driver for SDRAM
\r
17 * This function initializes the emif driver for SDRAM (SDRAM initialization function).
\r
21 void emif_SDRAMInit()
\r
24 unsigned long saveif;
\r
27 * configure for SDRAM 64MB IS45S16320
\r
29 * 4 banks, 1024 rows and 8192 columns
\r
30 * 2 bits , 10 bits and 13 bits
\r
32 * full refresh 64 ms
\r
34 * self refresh exit time 67 ns
\r
37 saveif = _disable_IRQ();
\r
40 * From UM 4.3.3 Control of Special Multiplexed Options
\r
41 * Any application that requires the EMIF functionality
\r
42 * must set GPREG1[31]. This allows these 8 EMIF module
\r
43 * outputs to be driven on to the assigned balls.
\r
46 systemREG1->GPREG1 |= 0x80000000;
\r
48 emifREG->SDTIMR = ((9-1) << 27)| /* TRF_C REFR to REFR*/
\r
49 ((3-1) << 24)| /* T_RP PRE to ACTIV or REFR */
\r
51 ((3-1) << 20)| /* T_RCD ACTIV to RD/WR */
\r
53 ((2-1) << 16)| /* T_WR WRITE to PRE */
\r
54 ((6-1) << 12)| /* T_RAS ACTIV to PRE */
\r
55 ((9-1) << 8)| /* T_RC ACTIV to ACTIV */
\r
57 ((2-1) << 4)| /* T_RRD ACTIV to ACTIV other bank */
\r
60 /* configure refresh rate*/
\r
61 emifREG->SDSRETR = (5+3-1);
\r
63 /* 80e6 * 16e-3 / 8192 => less or equal to 156 */
\r
64 emifREG->SDRCR = 156;
\r
66 /** -general clearing of register
\r
67 * -for NM for setting 16 bit data bus
\r
69 * -BIT11_9CLOCK to allow the cl field to be written
\r
70 * -selecting the banks
\r
71 * -setting the pagesize
\r
73 emifREG->SDCR = (0 << 31)| /* SR self refresh mode */
\r
74 (0 << 30)| /* PD power down */
\r
75 (0 << 29)| /* PDWR refresh in PD */
\r
76 (1 << 14)| /* NM narrow mode */
\r
77 (3 << 9)| /* CAS latency */
\r
78 (1 << 8)| /* CAS latency lock */
\r
79 (2 << 4)| /* IBANK .. 4 banks */
\r
80 (2 << 0); /* PAGESIZE .. 10 bit / 1024ele */
\r
81 /* wait for a read to happen*/
\r
82 buffer = *(volatile uint32_t *)PTR;
\r
84 emifREG->SDRCR = 156;
\r
86 _restore_interrupts(saveif);
\r