]> rtime.felk.cvut.cz Git - pes-rpp/rpp-test-sw.git/blob - rpp/lib/rpp/src/sys/ti_drv_emif.c
2e2d554529d2784b10d6c52b7d398e58da546187
[pes-rpp/rpp-test-sw.git] / rpp / lib / rpp / src / sys / ti_drv_emif.c
1 /** @file emif.c
2 *   @brief emif Driver Implementation File
3 *   @date 15.January.2012
4 *   @version 03.01.00
5 *
6 */
7
8 /* (c) Texas Instruments 2009-2012, All rights reserved. */
9
10
11 #include "sys/system.h"
12 #include "sys/ti_drv_emif.h"
13
14 /** @fn void emif_SDRAMInit()
15 *   @brief Initializes the emif Driver for SDRAM
16 *
17 *   This function initializes the emif driver for SDRAM (SDRAM initialization function).
18 */
19
20
21 void emif_SDRAMInit()
22 {
23    uint32_t buffer;
24    unsigned long saveif;
25
26    /*
27     * configure for SDRAM 64MB IS45S16320
28     *
29     * 4 banks, 1024 rows and 8192 columns
30     * 2 bits , 10 bits   and   13 bits
31     * CL = 2/3
32     * full refresh 64 ms
33     *    for 80 degC 16 ms
34     * self refresh exit time 67 ns
35     */
36
37    saveif = _disable_IRQ();
38
39    /*
40     * From UM 4.3.3 Control of Special Multiplexed Options
41     * Any application that requires the EMIF functionality
42     * must set GPREG1[31]. This allows these 8 EMIF module
43     * outputs to be driven on to the assigned balls.
44     */
45
46    systemREG1->GPREG1 |= 0x80000000;
47
48    emifREG->SDTIMR  = ((9-1) << 27)|    /* TRF_C REFR to REFR*/
49                       ((3-1) << 24)|    /* T_RP PRE to ACTIV or REFR */
50                       (0 << 23)|
51                       ((3-1) << 20)|    /* T_RCD ACTIV to RD/WR */
52                       (0 << 19)|
53                       ((2-1) << 16)|    /* T_WR WRITE to PRE */
54                       ((6-1) << 12)|    /* T_RAS ACTIV to PRE */
55                       ((9-1) << 8)| /* T_RC ACTIV to ACTIV */
56                       (0 << 7)|
57                       ((2-1) << 4)| /* T_RRD ACTIV to ACTIV other bank */
58                       (0 << 3);
59
60  /* configure refresh rate*/
61    emifREG->SDSRETR = (5+3-1);
62
63    /* 80e6 * 16e-3 / 8192 => less or equal to 156 */
64    emifREG->SDRCR   = 156;
65
66 /**  -general clearing of register
67 *    -for NM for setting 16 bit data bus
68 *    -cas latency
69 *    -BIT11_9CLOCK to allow the cl field to be written
70 *    -selecting the banks
71 *    -setting the pagesize
72 */
73     emifREG->SDCR    = (0 << 31)|   /* SR self refresh mode */
74                       (0 << 30)|    /* PD power down */
75                       (0 << 29)|    /* PDWR refresh in PD */
76                       (1 << 14)|    /* NM narrow mode */
77                       (3 << 9)|     /* CAS latency */
78                       (1 << 8)|     /* CAS latency lock */
79                       (2 << 4)|     /* IBANK .. 4 banks */
80                       (2 << 0);     /* PAGESIZE .. 10 bit / 1024ele */
81 /* wait for a read to happen*/
82    buffer             = *(volatile uint32_t *)PTR;
83    buffer             = buffer;
84    emifREG->SDRCR     = 156;
85
86    _restore_interrupts(saveif);
87 }
88
89
90
91
92
93
94