6 #include <asm/arch/s3c24x0-iomap.h>
8 .section ".text_bare_init.board_init_lowlevel","ax"
11 * To be able to setup the SDRAM interface correctly, we need some
12 * external information about the connected SDRAM devices.
14 * When we set GPH8, we can read at GPB:
15 * Bit 0..1: Memory device size -> 00=16M, 01=64M, 10=32M, 11=128M
18 * Some remarks: The CL setting seems useless. It always signals a CL3
19 * requirement, but the SDRAM types I found on the cards are supporting
20 * CL2 @ 100 MHz. But also these SDRAM types are only support 105 MHz max.
21 * So, we never need CL3 because we can't run the CPU at 533 MHz (which
22 * implies an 133 MHz SDRAM clock).
23 * All devices are connected via 32 bit databus
25 * Note: I was able to check the 32 MiB and 64 MiB configuration only. I didn't
26 * had access to a 16 MiB nor 128 MiB config.
32 * Read the configuration. After reset until any GPIO port is
33 * configured yet, these pins show external settings, to detect
40 ldr r1, =S3C24X0_MEMCTL_BASE
41 /* configure both SDRAM areas with 32 bit data bus width */
42 ldr r0, =((0x2 << 24) + (0x2 << 28))
43 str r0, [r1], #0x1c /* post add register offset for bank6 */
46 * With the configuration we simply need to calculate an offset into
47 * our table with the predefined SDRAM settings
50 mov r2, #6*4 /* # of bytes per table entry */
52 add r0, r0, r3 /* start address of the entry */
55 * store the table entry data into the registers
63 /* TODO: Check if the second bank is populated, and switch it off if not */
68 * we need 4 sets of memory settings per main CPU clock speed
71 * - 16 MiB in the first bank, maybe 16 MiB in the second bank (untested!)
72 * - 32 MiB in the first bank, maybe 32 MiB in the second bank (CL=2)
73 * - 64 MiB in the first bank, maybe 64 MiB in the second bank (CL=2)
74 * - 128 MiB in the first bank, maybe 128 MiB in the second bank (untested!)
76 * Note: SDRAM clock runs at 100MHz
80 /* --------------------------- 16 MiB @ 100MHz --------------------------- */
82 * - MT = 11 (= sync dram type)
84 * - SCAN = 00 (= 8 bit collumns)
86 .word ((0x3 << 15) + (0x1 << 2) + (0x0))
87 .word ((0x3 << 15) + (0x1 << 2) + (0x0))
89 * SDRAM refresh settings
90 * - REFEN = 1 (= refresh enabled)
91 * - TREFMD = 0 (= auto refresh)
92 * - Trp = 00 (= 2 RAS precharge clocks)
93 * - Tsrc = 11 (= 7 clocks -> row cycle time @100MHz 2+5=7 -> 70ns)
94 * - Refrsh = 2^11 + 1 - 100 * 15.6 = 2049 - 1560 = FIXME
96 .word ((0x1 << 23) + (0x0 << 22) + (0x0 << 20) + (0x3 << 18) + 468)
99 * - BURST_EN = 0 (= burst mode disabled)
100 * - SCKE_EN = 1 (= SDRAM SCKE enabled)
101 * - SCLK_EN = 1 (= clock active only during accesses)
102 * - BK67MAP = 010 (= 128MiB) FIXME?????
104 .word ((0 << 7) + (1 << 5) + (1 << 4) + 2)
106 * SDRAM mode register
107 * CL = 010 (= 2 clocks)
112 /* ------------- one or two banks with 64 MiB @ 100MHz -------------------- */
115 * - MT = 11 (= sync dram type)
116 * - Trcd = 00 (= CL2)
117 * - SCAN = 01 (= 9 bit collumns)
119 .word ((0x3 << 15) + (0x0 << 2) + (0x1))
120 .word ((0x3 << 15) + (0x0 << 2) + (0x1))
122 * SDRAM refresh settings
123 * - REFEN = 1 (= refresh enabled)
124 * - TREFMD = 0 (= auto refresh)
125 * - Trp = 00 (= 2 RAS precharge clocks)
126 * - Tsrc = 01 (= 5 clocks -> row cycle time @100MHz 2+5=7 -> 70ns)
127 * - Refrsh = 2^11 + 1 - 100 * 15.6 = 2049 - 1560 = 489
129 .word ((0x1 << 23) + (0x0 << 22) + (0x0 << 20) + (0x1 << 18) + 489)
132 * - BURST_EN = 1 (= burst mode enabled)
133 * - SCKE_EN = 1 (= SDRAM SCKE enabled)
134 * - SCLK_EN = 1 (= clock active only during accesses)
135 * - BK67MAP = 001 (= 64 MiB)
137 .word ((1 << 7) + (1 << 5) + (1 << 4) + 1)
139 * SDRAM mode register
140 * CL = 010 (= 2 clocks)
145 /* ------------- one or two banks with 32 MiB @ 100MHz -------------------- */
148 * - MT = 11 (= sync dram type)
149 * - Trcd = 00 (= CL2)
150 * - SCAN = 01 (= 9 bit collumns)
152 .word ((0x3 << 15) + (0x0 << 2) + (0x1))
153 .word ((0x3 << 15) + (0x0 << 2) + (0x1))
155 * SDRAM refresh settings
156 * - REFEN = 1 (= refresh enabled)
157 * - TREFMD = 0 (= auto refresh)
158 * - Trp = 00 (= 2 RAS precharge clocks)
159 * - Tsrc = 01 (= 5 clocks -> row cycle time @100MHz 2+5=7 -> 70ns)
160 * - Refrsh = 2^11 + 1 - 100 * 15.6 = 2049 - 1560 = 489
162 .word ((0x1 << 23) + (0x0 << 22) + (0x0 << 20) + (0x1 << 18) + 489)
165 * - BURST_EN = 1 (= burst mode enabled)
166 * - SCKE_EN = 1 (= SDRAM SCKE enabled)
167 * - SCLK_EN = 1 (= clock active only during accesses)
168 * - BK67MAP = 000 (= 32 MiB)
170 .word ((1 << 7) + (1 << 5) + (1 << 4) + 0)
172 * SDRAM mode register
173 * CL = 010 (= 2 clocks)
178 /* ------------ one or two banks with 128 MiB @ 100MHz -------------------- */
181 * - MT = 11 (= sync dram type)
182 * - Trcd = 00 (= CL2)
183 * - SCAN = 01 (= 9 bit collumns)
185 .word ((0x3 << 15) + (0x0 << 2) + (0x1))
186 .word ((0x3 << 15) + (0x0 << 2) + (0x1))
188 * SDRAM refresh settings
189 * - REFEN = 1 (= refresh enabled)
190 * - TREFMD = 0 (= auto refresh)
191 * - Trp = 00 (= 2 RAS precharge clocks)
192 * - Tsrc = 01 (= 5 clocks -> row cycle time @100MHz 2+5=7 -> 70ns)
193 * - Refrsh = 2^11 + 1 - 100 * 7.5 = 2049 - FIXME = 1259
195 .word ((0x1 << 23) + (0x0 << 22) + (0x1 << 20) + (0x3 << 18) + 1259)
198 * - BURST_EN = 0 (= burst mode disabled)
199 * - SCKE_EN = 1 (= SDRAM SCKE enabled)
200 * - SCLK_EN = 1 (= clock active only during accesses)
201 * - BK67MAP = 010 (= 128MiB)
205 * SDRAM mode register
206 * CL = 010 (= 2 clocks)
211 /* ------------------------------------------------------------------------ */
213 .globl board_init_lowlevel
216 mov r10, lr /* save the link register */
218 bl s3c24x0_disable_wd
220 /* skip everything here if we are already running from SDRAM */
221 cmp pc, #S3C24X0_SDRAM_BASE
223 cmp pc, #S3C24X0_SDRAM_END
228 /* we are running from NOR or NAND/SRAM memory. Do further initialisation */
234 #ifdef CONFIG_S3C24XX_NAND_BOOT
235 mov lr, r10 /* restore the link register */
236 /* up to here we are running from the internal SRAM area */
237 b s3c24x0_nand_boot /* does return directly to our caller into SDRAM */