2 * Memory Setup stuff - taken from blob memsetup.S
4 * Copyright (C) 2009 Samsung Electronics
5 * Kyungmin Park <kyungmin.park@samsung.com>
7 * See file CREDITS for list of people who contributed to this
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of
13 * the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
28 #include <asm/arch/cpu.h>
29 #include <asm/arch/mem.h>
30 #include <asm/arch/clock.h>
31 #include <asm/arch/power.h>
32 #include <asm/arch/watchdog.h>
33 #include <asm/arch/interrupt.h>
42 * r7 has S5PC100 GPIO base, 0xE0300000
43 * r8 has real GPIO base, 0xE0300000, 0xE0200000 at S5PC100, S5PC110 repectively
53 /* r5 has always zero */
56 ldr r7, =S5PC100_GPIO_BASE
57 ldr r8, =S5PC100_GPIO_BASE
59 ldr r2, =S5PC1XX_PRO_ID
65 ldr r8, =S5PC110_GPIO_BASE
67 /* Turn on KEY_LED_ON [GPJ4(1)] XMSMWEN */
70 addeq r0, r8, #0x280 @S5PC100_GPIO_J4_OFFSET
71 addne r0, r8, #0x2C0 @S5PC110_GPIO_J4_OFFSET
72 ldr r1, [r0, #0x0] @S5PC1XX_GPIO_CON_OFFSET
73 bic r1, r1, #(0xf << 4) @ 1 * 4-bit
74 orr r1, r1, #(0x1 << 4)
75 str r1, [r0, #0x0] @S5PC1XX_GPIO_CON_OFFSET
77 ldr r1, [r0, #0x4] @S5PC1XX_GPIO_DAT_OFFSET
78 #ifdef CONFIG_ONENAND_IPL
79 orr r1, r1, #(1 << 1) @ 1 * 1-bit
83 str r1, [r0, #0x4] @S5PC1XX_GPIO_DAT_OFFSET
86 /* IO retension release */
87 ldreq r0, =S5PC100_OTHERS @0xE0108200
88 ldrne r0, =S5PC110_OTHERS @0xE010E000
90 ldreq r2, =(1 << 31) @IO_RET_REL
91 ldrne r2, =((1 << 31) | (1 << 29) | (1 << 28)) @ GPIO, UART_IO
95 #ifndef CONFIG_ONENAND_IPL
96 /* Disable Watchdog */
97 ldreq r0, =S5PC100_WATCHDOG_BASE @0xEA200000
98 ldrne r0, =S5PC110_WATCHDOG_BASE @0xE2700000
102 ldreq r0, =S5PC100_SROMC_BASE
103 ldrne r0, =S5PC110_SROMC_BASE
108 /* S5PC100 has 3 groups of interrupt sources */
109 ldreq r0, =S5PC100_VIC0_BASE @0xE4000000
110 ldrne r0, =S5PC110_VIC0_BASE @0xF2000000
111 add r1, r0, #0x00100000
112 add r2, r0, #0x00200000
114 /* Disable all interrupts (VIC0, VIC1 and VIC2) */
116 str r3, [r0, #VIC_INTENCLEAR_OFFSET]
117 str r3, [r1, #VIC_INTENCLEAR_OFFSET]
118 str r3, [r2, #VIC_INTENCLEAR_OFFSET]
120 #ifndef CONFIG_ONENAND_IPL
121 /* Set all interrupts as IRQ */
122 str r5, [r0, #VIC_INTSELECT_OFFSET]
123 str r5, [r1, #VIC_INTSELECT_OFFSET]
124 str r5, [r2, #VIC_INTSELECT_OFFSET]
126 /* Pending Interrupt Clear */
127 str r5, [r0, #VIC_INTADDRESS_OFFSET]
128 str r5, [r1, #VIC_INTADDRESS_OFFSET]
129 str r5, [r2, #VIC_INTADDRESS_OFFSET]
132 #ifndef CONFIG_ONENAND_IPL
139 #ifdef CONFIG_ONENAND_IPL
140 /* init system clock */
145 /* OneNAND Sync Read Support at S5PC110 only
147 * BRWL[14:12] : 7 CLK
148 * BL[11:9] : Continuous
149 * VHF[3] : Very High Frequency Enable (Over 83MHz)
150 * HF[2] : High Frequency Enable (Over 66MHz)
154 ldrne r0, =0xB001E442
157 ldrne r0, =0xB0600000
158 strne r1, [r0, #0x100] @ ONENAND_IF_CTRL
160 /* Wakeup support. Don't know if it's going to be used, untested. */
161 ldreq r0, =S5PC100_RST_STAT
162 ldrne r0, =S5PC110_RST_STAT
164 biceq r1, r1, #0xfffffff7
166 bicne r1, r1, #0xfffeffff
174 str r1, [r0, #0x0] @S5PC100_GPIO_A0_OFFSET
176 str r1, [r0, #0x20] @S5PC100_GPIO_A1_OFFSET
178 /* UART_SEL MP0_5[7] at S5PC110 */
179 add r0, r8, #0x360 @S5PC110_GPIO_MP0_5_OFFSET
180 ldr r1, [r0, #0x0] @S5PC1XX_GPIO_CON_OFFSET
181 bic r1, r1, #(0xf << 28) @ 28 = 7 * 4-bit
182 orr r1, r1, #(0x1 << 28) @ Output
183 str r1, [r0, #0x0] @S5PC1XX_GPIO_CON_OFFSET
185 ldr r1, [r0, #0x8] @S5PC1XX_GPIO_PULL_OFFSET
186 bic r1, r1, #(0x3 << 14) @ 14 = 7 * 2-bit
187 orr r1, r1, #(0x2 << 14) @ Pull-up enabled
188 str r1, [r0, #0x8] @S5PC1XX_GPIO_PULL_OFFSET
190 ldr r1, [r0, #0x4] @S5PC1XX_GPIO_DAT_OFFSET
191 orr r1, r1, #(1 << 7) @ 7 = 7 * 1-bit
192 str r1, [r0, #0x4] @S5PC1XX_GPIO_DAT_OFFSET
194 ldr r0, =0xE2900000 @ S5PC110_PA_UART
197 str r1, [r0, #0x000] @ ULCON
199 str r1, [r0, #0x004] @ UCON
201 str r1, [r0, #0x028] @ UBRDIV
203 str r1, [r0, #0x02C] @ UDIVSLOT
206 strb r2, [r0, #0x020] @ UTXH
208 ldrb r3, [r0, #0x010] @ UTRSTAT
213 /* turn off L2 cache */
220 /* invalidate L2 cache also */
223 /* turn on L2 cache */
227 /* Load return address and jump to kernel */
228 ldreq r0, =S5PC100_INFORM0
229 ldrne r0, =S5PC110_INFORM0
231 /* r1 = physical address of s5pc1xx_cpu_resume function */
234 /* Jump to kernel (sleep-s5pc1xx.S) */
240 /* Clear wakeup status register */
241 ldreq r0, =S5PC100_WAKEUP_STAT
242 ldrne r0, =S5PC110_WAKEUP_STAT
251 * system_clock_init: Initialize core clock and bus clock.
252 * void system_clock_init(void)
255 ldr r0, =S5PC1XX_CLOCK_BASE @ 0xE0100000
261 #ifndef DEBUG_PM_C110
263 ldr r1, =0xe10 @ Locktime : 0xe10 = 3600
264 str r1, [r0, #0x000] @ S5PC100_APLL_LOCK
265 str r1, [r0, #0x004] @ S5PC100_MPLL_LOCK
266 str r1, [r0, #0x008] @ S5PC100_EPLL_LOCK
267 str r1, [r0, #0x00C] @ S5PC100_HPLL_LOCK
270 #ifdef CONFIG_CLK_667_166_83
271 ldr r1, =0x81bc0400 @ SDIV 0, PDIV 4, MDIV 444 (1333MHz)
272 #elif defined(CONFIG_CLK_666_166_66)
273 ldr r1, =0x814d0301 @ SDIV 1, PDIV 3, MDIV 333 (1333MHz)
274 #elif defined(CONFIG_CLK_600_150_75)
275 ldr r1, =0x812C0300 @ SDIV 0, PDIV 3, MDIV 300 (1200MHz)
276 #elif defined(CONFIG_CLK_533_133_66)
277 ldr r1, =0x810b0300 @ SDIV 0, PDIV 3, MDIV 267 (1066MHz)
278 #elif defined(CONFIG_CLK_500_166_66)
279 ldr r1, =0x81f40301 @ SDIV 1, PDIV 3, MDIV 500 (1000MHz)
280 #elif defined(CONFIG_CLK_467_117_59)
281 ldr r1, =0x826E0401 @ SDIV 1, PDIV 4, MDIV 622 (933MHz)
282 #elif defined(CONFIG_CLK_400_100_50)
283 ldr r1, =0x81900301 @ SDIV 1, PDIV 3, MDIV 400 (800MHz)
285 #error you should set the correct clock configuration
289 ldr r1, =0x80590201 @ SDIV 1, PDIV 2, MDIV 89 (267MHz)
292 ldr r1, =0x80870303 @ SDIV 3, PDIV 3, MDIV 135 (67.5MHz)
295 ldr r1, =0x80600603 @ SDIV 3, PDIV 6, MDIV 96
301 #ifdef CONFIG_CLK_800_166_66
303 #elif defined(CONFIG_CLK_500_166_66)
305 #elif defined(CONFIG_CLK_666_166_66)
319 /* Set Source Clock */
320 ldr r1, =0x00001111 @ A, M, E, HPLL Muxing
321 str r1, [r0, #0x200] @ S5PC1XX_CLK_SRC0
325 /* Set Clock divider */
326 ldr r1, =0x14131330 @ 1:1:4:4, 1:4:5
328 ldr r1, =0x11110111 @ UART[3210]: MMC[3210]
332 ldr r1, =0xe10 @ Locktime : 0xe10 = 3600
333 str r1, [r0, #0x000] @ S5PC110_APLL_LOCK
334 str r1, [r0, #0x010] @ S5PC110_MPLL_LOCK
335 str r1, [r0, #0x018] @ S5PC110_EPLL_LOCK
336 str r1, [r0, #0x020] @ S5PC110_VPLL_LOCK
338 /* S5PC110_APLL_CON */
339 ldr r1, =0x80C80601 @ 800MHz
341 /* S5PC110_MPLL_CON */
342 ldr r1, =0x829B0C01 @ 667MHz
344 /* S5PC110_EPLL_CON */
345 ldr r1, =0x80600602 @ 96MHz VSEL 0 P 6 M 96 S 2
347 /* S5PC110_VPLL_CON */
348 ldr r1, =0x806C0603 @ 54MHz
351 /* Set Source Clock */
352 ldr r1, =0x10001111 @ A, M, E, VPLL Muxing
353 str r1, [r0, #0x200] @ S5PC1XX_CLK_SRC0
355 /* OneDRAM(DMC0) clock setting */
356 ldr r1, =0x01000000 @ ONEDRAM_SEL[25:24] 1 SCLKMPLL
357 str r1, [r0, #0x218] @ S5PC110_CLK_SRC6
358 ldr r1, =0x30000000 @ ONEDRAM_RATIO[31:28] 3 + 1
359 str r1, [r0, #0x318] @ S5PC110_CLK_DIV6
361 /* XCLKOUT = XUSBXTI 24MHz */
362 add r2, r0, #0xE000 @ S5PC110_OTHERS
364 orr r1, r1, #(0x3 << 8) @ CLKOUT[9:8] 3 XUSBXTI
368 /* wait at least 200us to stablize all clock */
375 #ifndef CONFIG_ONENAND_IPL
377 ldreq r0, =0xE3800000
378 ldrne r0, =0xF1500000
385 #ifndef CONFIG_ONENAND_IPL
387 * uart_asm_init: Initialize UART's pins
390 /* set GPIO to enable UART0-UART4 */
393 str r1, [r0, #0x0] @S5PC100_GPIO_A0_OFFSET
395 str r1, [r0, #0x20] @S5PC100_GPIO_A1_OFFSET
401 #ifndef DEBUG_PM_C110
402 /* UART_SEL GPK0[5] at S5PC100 */
403 add r0, r8, #0x2A0 @S5PC100_GPIO_K0_OFFSET
404 ldr r1, [r0, #0x0] @S5PC1XX_GPIO_CON_OFFSET
405 bic r1, r1, #(0xf << 20) @ 20 = 5 * 4-bit
406 orr r1, r1, #(0x1 << 20) @ Output
407 str r1, [r0, #0x0] @S5PC1XX_GPIO_CON_OFFSET
409 ldr r1, [r0, #0x8] @S5PC1XX_GPIO_PULL_OFFSET
410 bic r1, r1, #(0x3 << 10) @ 10 = 5 * 2-bit
411 orr r1, r1, #(0x2 << 10) @ Pull-up enabled
412 str r1, [r0, #0x8] @S5PC1XX_GPIO_PULL_OFFSET
414 ldr r1, [r0, #0x4] @S5PC1XX_GPIO_DAT_OFFSET
415 orr r1, r1, #(1 << 5) @ 5 = 5 * 1-bit
416 str r1, [r0, #0x4] @S5PC1XX_GPIO_DAT_OFFSET
421 * Note that the following address
422 * 0xE020'0360 is reserved address at S5PC100
424 /* UART_SEL MP0_5[7] at S5PC110 */
425 add r0, r8, #0x360 @S5PC110_GPIO_MP0_5_OFFSET
426 ldr r1, [r0, #0x0] @S5PC1XX_GPIO_CON_OFFSET
427 bic r1, r1, #(0xf << 28) @ 28 = 7 * 4-bit
428 orr r1, r1, #(0x1 << 28) @ Output
429 str r1, [r0, #0x0] @S5PC1XX_GPIO_CON_OFFSET
431 ldr r1, [r0, #0x8] @S5PC1XX_GPIO_PULL_OFFSET
432 bic r1, r1, #(0x3 << 14) @ 14 = 7 * 2-bit
433 orr r1, r1, #(0x2 << 14) @ Pull-up enabled
434 str r1, [r0, #0x8] @S5PC1XX_GPIO_PULL_OFFSET
436 ldr r1, [r0, #0x4] @S5PC1XX_GPIO_DAT_OFFSET
437 orr r1, r1, #(1 << 7) @ 7 = 7 * 1-bit
438 str r1, [r0, #0x4] @S5PC1XX_GPIO_DAT_OFFSET