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/gpio.h>
31 #include <asm/arch/clock.h>
32 #include <asm/arch/power.h>
33 #include <asm/arch/watchdog.h>
34 #include <asm/arch/interrupt.h>
40 * r7 has S5PC100 GPIO base, 0xE0300000
41 * r8 has real GPIO base, 0xE0300000, 0xE0200000 at S5PC100, S5PC110 repectively
51 /* r5 has always zero */
54 ldr r7, =S5PC100_GPIO_BASE(0)
55 ldr r8, =S5PC100_GPIO_BASE(0)
57 ldr r2, =S5PC1XX_PRO_ID
63 ldr r8, =S5PC110_GPIO_BASE(0)
65 /* Turn on KEY_LED_ON [GPJ4(1)] */
67 addeq r0, r8, #S5PC100_GPIO_J4_OFFSET
68 addne r0, r8, #S5PC110_GPIO_J4_OFFSET
69 ldr r1, [r0, #S5PC1XX_GPIO_CON_OFFSET]
70 bic r1, r1, #(0xf << 4) @ 1 * 4-bit
71 orr r1, r1, #(0x1 << 4)
72 str r1, [r0, #S5PC1XX_GPIO_CON_OFFSET]
74 ldr r1, [r0, #S5PC1XX_GPIO_DAT_OFFSET]
75 #ifdef CONFIG_ONENAND_IPL
77 orr r1, r1, #(1 << 1) @ 1 * 1-bit
82 str r1, [r0, #S5PC1XX_GPIO_DAT_OFFSET]
84 /* IO retension release */
85 ldreq r0, =S5PC100_OTHERS @0xE0108200
86 ldrne r0, =S5PC110_OTHERS @0xE010E000
88 ldreq r2, =(1 << 31) @IO_RET_REL
92 /* Disable Watchdog */
94 ldreq r0, =S5PC100_WATCHDOG_BASE @0xEA200000
95 ldrne r0, =S5PC110_WATCHDOG_BASE @0xE2700000
98 #ifndef CONFIG_ONENAND_IPL
101 ldreq r0, =S5PC100_SROMC_BASE
102 ldrne r0, =S5PC110_SROMC_BASE
107 /* 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
140 #ifdef CONFIG_ONENAND_IPL
141 /* init system clock */
149 /* Wakeup support. Don't know if it's going to be used, untested. */
150 ldreq r0, =S5PC100_RST_STAT
151 ldrne r0, =S5PC110_RST_STAT
154 bic r1, r1, #0xfffffff7
158 bic r1, r1, #0xfffeffff
168 #ifdef CONFIG_ONENAND_IPL
171 /* Turn on 7color [GPJ4(2)] at universal */
173 addeq r0, r8, #S5PC100_GPIO_J4_OFFSET
174 addne r0, r8, #S5PC110_GPIO_J4_OFFSET
175 ldr r1, [r0, #S5PC1XX_GPIO_CON_OFFSET]
176 bic r1, r1, #(0xf << 8) @ 2 * 4-bit
177 orr r1, r1, #(0x1 << 8)
178 str r1, [r0, #S5PC1XX_GPIO_CON_OFFSET]
180 ldr r1, [r0, #S5PC1XX_GPIO_DAT_OFFSET]
181 orr r1, r1, #(1 << 2) @ 2 * 1-bit
182 str r1, [r0, #S5PC1XX_GPIO_DAT_OFFSET]
184 /* Clear wakeup status register */
185 ldreq r0, =S5PC100_WAKEUP_STAT
186 ldrne r0, =S5PC110_WAKEUP_STAT
190 /* Load return address and jump to kernel */
191 ldreq r0, =S5PC100_INFORM0
192 ldrne r0, =S5PC110_INFORM0
194 /* r1 = physical address of s5pc100_cpu_resume function */
197 /* Jump to kernel (sleep-s5pc100.S) */
204 * system_clock_init: Initialize core clock and bus clock.
205 * void system_clock_init(void)
208 ldr r0, =S5PC1XX_CLOCK_BASE @ 0xE0100000
215 ldr r1, =0xe10 @ Locktime : 0xe10 = 3600
216 str r1, [r0, #0x000] @ S5PC100_APLL_LOCK
217 str r1, [r0, #0x004] @ S5PC100_MPLL_LOCK
218 str r1, [r0, #0x008] @ S5PC100_EPLL_LOCK
219 str r1, [r0, #0x00C] @ S5PC100_HPLL_LOCK
222 #ifdef CONFIG_CLK_667_166_83
223 ldr r1, =0x81bc0400 @ SDIV 0, PDIV 4, MDIV 444 (1333MHz)
224 #elif defined(CONFIG_CLK_666_166_66)
225 ldr r1, =0x814d0301 @ SDIV 1, PDIV 3, MDIV 333 (1333MHz)
226 #elif defined(CONFIG_CLK_600_150_75)
227 ldr r1, =0x812C0300 @ SDIV 0, PDIV 3, MDIV 300 (1200MHz)
228 #elif defined(CONFIG_CLK_533_133_66)
229 ldr r1, =0x810b0300 @ SDIV 0, PDIV 3, MDIV 267 (1066MHz)
230 #elif defined(CONFIG_CLK_500_166_66)
231 ldr r1, =0x81f40301 @ SDIV 1, PDIV 3, MDIV 500 (1000MHz)
232 #elif defined(CONFIG_CLK_467_117_59)
233 ldr r1, =0x826E0401 @ SDIV 1, PDIV 4, MDIV 622 (933MHz)
234 #elif defined(CONFIG_CLK_400_100_50)
235 ldr r1, =0x81900301 @ SDIV 1, PDIV 3, MDIV 400 (800MHz)
237 #error you should set the correct clock configuration
241 ldr r1, =0x80590201 @ SDIV 1, PDIV 2, MDIV 89 (267MHz)
244 ldr r1, =0x80870303 @ SDIV 3, PDIV 3, MDIV 135 (67.5MHz)
247 ldr r1, =0x80600603 @ SDIV 3, PDIV 6, MDIV 96
253 #ifdef CONFIG_CLK_800_166_66
255 #elif defined(CONFIG_CLK_500_166_66)
257 #elif defined(CONFIG_CLK_666_166_66)
271 /* Set Source Clock */
272 ldr r1, =0x00001111 @ A, M, E, HPLL Muxing
273 str r1, [r0, #0x200] @ S5PC1XX_CLK_SRC0
277 /* Set Clock divider */
278 ldr r1, =0x14131330 @ 1:1:4:4, 1:4:5
282 ldr r1, =0xe10 @ Locktime : 0xe10 = 3600
283 str r1, [r0, #0x000] @ S5PC110_APLL_LOCK
284 str r1, [r0, #0x010] @ S5PC110_MPLL_LOCK
285 str r1, [r0, #0x018] @ S5PC110_EPLL_LOCK
286 str r1, [r0, #0x020] @ S5PC110_VPLL_LOCK
288 /* S5PC110_APLL_CON */
289 ldr r1, =0x80C80601 @ 800MHz
291 /* S5PC110_MPLL_CON */
292 ldr r1, =0x829B0C01 @ 667MHz
294 /* S5PC110_EPLL_CON */
295 ldr r1, =0x80600602 @ 96MHz
297 /* S5PC110_VPLL_CON */
298 ldr r1, =0x806C0603 @ 54MHz
301 /* Set Source Clock */
302 ldr r1, =0x10001111 @ A, M, E, VPLL Muxing
303 str r1, [r0, #0x200] @ S5PC1XX_CLK_SRC0
305 /* OneDRAM(DMC0) clock setting */
315 /* wait at least 200us to stablize all clock */
322 #ifdef CONFIG_ONENAND_IPL
325 ldreq r0, =0xE3800000
326 ldrne r0, =0xF1500000
333 #ifndef CONFIG_ONENAND_IPL
335 * uart_asm_init: Initialize UART's pins
338 /* set GPIO to enable UART0-UART4 */
341 str r1, [r0, #S5PC100_GPIO_A0_OFFSET] @ GPA0_CON
343 str r1, [r0, #S5PC100_GPIO_A1_OFFSET] @ GPA1_CON
349 /* UART_SEL GPK0[5] at S5PC100 */
350 add r0, r8, #S5PC100_GPIO_K0_OFFSET
351 ldr r1, [r0, #S5PC1XX_GPIO_CON_OFFSET]
352 bic r1, r1, #(0xf << 20) @ 20 = 5 * 4-bit
353 orr r1, r1, #(0x1 << 20) @ Output
354 str r1, [r0, #S5PC1XX_GPIO_CON_OFFSET]
356 ldr r1, [r0, #S5PC1XX_GPIO_PULL_OFFSET]
357 bic r1, r1, #(0x3 << 10) @ 10 = 5 * 2-bit
358 orr r1, r1, #(0x2 << 10) @ Pull-up enabled
359 str r1, [r0, #S5PC1XX_GPIO_PULL_OFFSET]
361 ldr r1, [r0, #S5PC1XX_GPIO_DAT_OFFSET]
362 orr r1, r1, #(1 << 5) @ 5 = 5 * 1-bit
363 str r1, [r0, #S5PC1XX_GPIO_DAT_OFFSET]
367 * Note that the following address
368 * 0xE020'0360 is reserved address at S5PC100
370 /* UART_SEL MP0_5[7] at S5PC110 */
371 add r0, r8, #S5PC110_GPIO_MP0_5_OFFSET
372 ldr r1, [r0, #S5PC1XX_GPIO_CON_OFFSET]
373 bic r1, r1, #(0xf << 28) @ 28 = 7 * 4-bit
374 orr r1, r1, #(0x1 << 28) @ Output
375 str r1, [r0, #S5PC1XX_GPIO_CON_OFFSET]
377 ldr r1, [r0, #S5PC1XX_GPIO_PULL_OFFSET]
378 bic r1, r1, #(0x3 << 14) @ 14 = 7 * 2-bit
379 orr r1, r1, #(0x2 << 14) @ Pull-up enabled
380 str r1, [r0, #S5PC1XX_GPIO_PULL_OFFSET]
382 ldr r1, [r0, #S5PC1XX_GPIO_DAT_OFFSET]
383 orr r1, r1, #(1 << 7) @ 7 = 7 * 1-bit
384 str r1, [r0, #S5PC1XX_GPIO_DAT_OFFSET]
389 * dma_asm_init: Initialize DMA
393 ldreq r0, =0xE3800000 @ TZPC0
394 ldrne r0, =0xF1500000 @ TZPC0
402 ldreq r0, =0xE2800000 @ TZPC1
403 ldrne r0, =0xFAD00000 @ TZPC1
409 ldreq r0, =0xE2900000 @ TZPC2
410 ldrne r0, =0xE0600000 @ TZPC2