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>
43 * r7 has S5PC100 GPIO base, 0xE0300000
44 * r8 has real GPIO base, 0xE0300000, 0xE0200000 at S5PC100, S5PC110 repectively
54 /* r5 has always zero */
57 ldr r7, =S5PC100_GPIO_BASE(0)
58 ldr r8, =S5PC100_GPIO_BASE(0)
60 ldr r2, =S5PC1XX_PRO_ID
66 ldr r8, =S5PC110_GPIO_BASE(0)
68 /* Turn on KEY_LED_ON [GPJ4(1)] XMSMWEN */
71 addeq r0, r8, #S5PC100_GPIO_J4_OFFSET
72 addne r0, r8, #S5PC110_GPIO_J4_OFFSET
73 ldr r1, [r0, #S5PC1XX_GPIO_CON_OFFSET]
74 bic r1, r1, #(0xf << 4) @ 1 * 4-bit
75 orr r1, r1, #(0x1 << 4)
76 str r1, [r0, #S5PC1XX_GPIO_CON_OFFSET]
78 ldr r1, [r0, #S5PC1XX_GPIO_DAT_OFFSET]
79 #ifdef CONFIG_ONENAND_IPL
80 orr r1, r1, #(1 << 1) @ 1 * 1-bit
84 str r1, [r0, #S5PC1XX_GPIO_DAT_OFFSET]
87 /* IO retension release */
88 ldreq r0, =S5PC100_OTHERS @0xE0108200
89 ldrne r0, =S5PC110_OTHERS @0xE010E000
91 ldreq r2, =(1 << 31) @IO_RET_REL
92 ldrne r2, =((1 << 31) | (1 << 29) | (1 << 28)) @ GPIO, UART_IO
96 #ifndef CONFIG_ONENAND_IPL
97 /* Disable Watchdog */
98 ldreq r0, =S5PC100_WATCHDOG_BASE @0xEA200000
99 ldrne r0, =S5PC110_WATCHDOG_BASE @0xE2700000
103 ldreq r0, =S5PC100_SROMC_BASE
104 ldrne r0, =S5PC110_SROMC_BASE
109 /* S5PC100 has 3 groups of interrupt sources */
110 ldreq r0, =S5PC100_VIC0_BASE @0xE4000000
111 ldrne r0, =S5PC110_VIC0_BASE @0xF2000000
112 add r1, r0, #0x00100000
113 add r2, r0, #0x00200000
115 /* Disable all interrupts (VIC0, VIC1 and VIC2) */
117 str r3, [r0, #VIC_INTENCLEAR_OFFSET]
118 str r3, [r1, #VIC_INTENCLEAR_OFFSET]
119 str r3, [r2, #VIC_INTENCLEAR_OFFSET]
121 #ifndef CONFIG_ONENAND_IPL
122 /* Set all interrupts as IRQ */
123 str r5, [r0, #VIC_INTSELECT_OFFSET]
124 str r5, [r1, #VIC_INTSELECT_OFFSET]
125 str r5, [r2, #VIC_INTSELECT_OFFSET]
127 /* Pending Interrupt Clear */
128 str r5, [r0, #VIC_INTADDRESS_OFFSET]
129 str r5, [r1, #VIC_INTADDRESS_OFFSET]
130 str r5, [r2, #VIC_INTADDRESS_OFFSET]
133 #ifndef CONFIG_ONENAND_IPL
143 #ifdef CONFIG_ONENAND_IPL
144 /* init system clock */
149 /* OneNAND Sync Read Support at S5PC110 only
151 * BRWL[14:12] : 7 CLK
152 * BL[11:9] : Continuous
153 * VHF[3] : Very High Frequency Enable (Over 83MHz)
154 * HF[2] : High Frequency Enable (Over 66MHz)
158 ldrne r0, =0xB001E442
161 ldrne r0, =0xB0600000
162 strne r1, [r0, #0x100] @ ONENAND_IF_CTRL
164 /* Wakeup support. Don't know if it's going to be used, untested. */
165 ldreq r0, =S5PC100_RST_STAT
166 ldrne r0, =S5PC110_RST_STAT
168 biceq r1, r1, #0xfffffff7
170 bicne r1, r1, #0xfffeffff
176 /* Clear wakeup status register */
177 ldreq r0, =S5PC100_WAKEUP_STAT
178 ldrne r0, =S5PC110_WAKEUP_STAT
185 str r1, [r0, #S5PC100_GPIO_A0_OFFSET] @ GPA0_CON
187 str r1, [r0, #S5PC100_GPIO_A1_OFFSET] @ GPA1_CON
189 /* UART_SEL MP0_5[7] at S5PC110 */
190 add r0, r8, #S5PC110_GPIO_MP0_5_OFFSET
191 ldr r1, [r0, #S5PC1XX_GPIO_CON_OFFSET]
192 bic r1, r1, #(0xf << 28) @ 28 = 7 * 4-bit
193 orr r1, r1, #(0x1 << 28) @ Output
194 str r1, [r0, #S5PC1XX_GPIO_CON_OFFSET]
196 ldr r1, [r0, #S5PC1XX_GPIO_PULL_OFFSET]
197 bic r1, r1, #(0x3 << 14) @ 14 = 7 * 2-bit
198 orr r1, r1, #(0x2 << 14) @ Pull-up enabled
199 str r1, [r0, #S5PC1XX_GPIO_PULL_OFFSET]
201 ldr r1, [r0, #S5PC1XX_GPIO_DAT_OFFSET]
202 orr r1, r1, #(1 << 7) @ 7 = 7 * 1-bit
203 str r1, [r0, #S5PC1XX_GPIO_DAT_OFFSET]
205 ldr r0, =0xE2900000 @ S5PC110_PA_UART
208 str r1, [r0, #0x000] @ ULCON
210 str r1, [r0, #0x004] @ UCON
212 str r1, [r0, #0x028] @ UBRDIV
214 str r1, [r0, #0x02C] @ UDIVSLOT
217 strb r2, [r0, #0x020] @ UTXH
219 ldrb r3, [r0, #0x010] @ UTRSTAT
225 /* Load return address and jump to kernel */
226 ldreq r0, =S5PC100_INFORM0
227 ldrne r0, =S5PC110_INFORM0
229 /* r1 = physical address of s5pc1xx_cpu_resume function */
232 /* Jump to kernel (sleep-s5pc1xx.S) */
242 * system_clock_init: Initialize core clock and bus clock.
243 * void system_clock_init(void)
246 ldr r0, =S5PC1XX_CLOCK_BASE @ 0xE0100000
252 #ifndef DEBUG_PM_C110
254 ldr r1, =0xe10 @ Locktime : 0xe10 = 3600
255 str r1, [r0, #0x000] @ S5PC100_APLL_LOCK
256 str r1, [r0, #0x004] @ S5PC100_MPLL_LOCK
257 str r1, [r0, #0x008] @ S5PC100_EPLL_LOCK
258 str r1, [r0, #0x00C] @ S5PC100_HPLL_LOCK
261 #ifdef CONFIG_CLK_667_166_83
262 ldr r1, =0x81bc0400 @ SDIV 0, PDIV 4, MDIV 444 (1333MHz)
263 #elif defined(CONFIG_CLK_666_166_66)
264 ldr r1, =0x814d0301 @ SDIV 1, PDIV 3, MDIV 333 (1333MHz)
265 #elif defined(CONFIG_CLK_600_150_75)
266 ldr r1, =0x812C0300 @ SDIV 0, PDIV 3, MDIV 300 (1200MHz)
267 #elif defined(CONFIG_CLK_533_133_66)
268 ldr r1, =0x810b0300 @ SDIV 0, PDIV 3, MDIV 267 (1066MHz)
269 #elif defined(CONFIG_CLK_500_166_66)
270 ldr r1, =0x81f40301 @ SDIV 1, PDIV 3, MDIV 500 (1000MHz)
271 #elif defined(CONFIG_CLK_467_117_59)
272 ldr r1, =0x826E0401 @ SDIV 1, PDIV 4, MDIV 622 (933MHz)
273 #elif defined(CONFIG_CLK_400_100_50)
274 ldr r1, =0x81900301 @ SDIV 1, PDIV 3, MDIV 400 (800MHz)
276 #error you should set the correct clock configuration
280 ldr r1, =0x80590201 @ SDIV 1, PDIV 2, MDIV 89 (267MHz)
283 ldr r1, =0x80870303 @ SDIV 3, PDIV 3, MDIV 135 (67.5MHz)
286 ldr r1, =0x80600603 @ SDIV 3, PDIV 6, MDIV 96
292 #ifdef CONFIG_CLK_800_166_66
294 #elif defined(CONFIG_CLK_500_166_66)
296 #elif defined(CONFIG_CLK_666_166_66)
310 /* Set Source Clock */
311 ldr r1, =0x00001111 @ A, M, E, HPLL Muxing
312 str r1, [r0, #0x200] @ S5PC1XX_CLK_SRC0
316 /* Set Clock divider */
317 ldr r1, =0x14131330 @ 1:1:4:4, 1:4:5
319 ldr r1, =0x11110111 @ UART[3210]: MMC[3210]
323 ldr r1, =0xe10 @ Locktime : 0xe10 = 3600
324 str r1, [r0, #0x000] @ S5PC110_APLL_LOCK
325 str r1, [r0, #0x010] @ S5PC110_MPLL_LOCK
326 str r1, [r0, #0x018] @ S5PC110_EPLL_LOCK
327 str r1, [r0, #0x020] @ S5PC110_VPLL_LOCK
329 /* S5PC110_APLL_CON */
330 ldr r1, =0x80C80601 @ 800MHz
332 /* S5PC110_MPLL_CON */
333 ldr r1, =0x829B0C01 @ 667MHz
335 /* S5PC110_EPLL_CON */
336 ldr r1, =0x80600602 @ 96MHz
338 /* S5PC110_VPLL_CON */
339 ldr r1, =0x806C0603 @ 54MHz
342 /* Set Source Clock */
343 ldr r1, =0x10001111 @ A, M, E, VPLL Muxing
344 str r1, [r0, #0x200] @ S5PC1XX_CLK_SRC0
346 /* OneDRAM(DMC0) clock setting */
347 ldr r1, =0x01000000 @ ONEDRAM_SEL[25:24] 1 SCLKMPLL
348 str r1, [r0, #0x218] @ S5PC110_CLK_SRC6
349 ldr r1, =0x30000000 @ ONEDRAM_RATIO[31:28] 3 + 1
350 str r1, [r0, #0x318] @ S5PC110_CLK_DIV6
352 ldr r1, =0x00909000 @ DIV=10 MCLKSYS
353 str r1, [r0, #0x500] @ S5PC110_CLK_OUT
356 /* wait at least 200us to stablize all clock */
363 #ifndef CONFIG_ONENAND_IPL
365 ldreq r0, =0xE3800000
366 ldrne r0, =0xF1500000
373 #ifndef CONFIG_ONENAND_IPL
375 * uart_asm_init: Initialize UART's pins
378 /* set GPIO to enable UART0-UART4 */
381 str r1, [r0, #S5PC100_GPIO_A0_OFFSET] @ GPA0_CON
383 str r1, [r0, #S5PC100_GPIO_A1_OFFSET] @ GPA1_CON
389 #ifndef DEBUG_PM_C110
390 /* UART_SEL GPK0[5] at S5PC100 */
391 add r0, r8, #S5PC100_GPIO_K0_OFFSET
392 ldr r1, [r0, #S5PC1XX_GPIO_CON_OFFSET]
393 bic r1, r1, #(0xf << 20) @ 20 = 5 * 4-bit
394 orr r1, r1, #(0x1 << 20) @ Output
395 str r1, [r0, #S5PC1XX_GPIO_CON_OFFSET]
397 ldr r1, [r0, #S5PC1XX_GPIO_PULL_OFFSET]
398 bic r1, r1, #(0x3 << 10) @ 10 = 5 * 2-bit
399 orr r1, r1, #(0x2 << 10) @ Pull-up enabled
400 str r1, [r0, #S5PC1XX_GPIO_PULL_OFFSET]
402 ldr r1, [r0, #S5PC1XX_GPIO_DAT_OFFSET]
403 orr r1, r1, #(1 << 5) @ 5 = 5 * 1-bit
404 str r1, [r0, #S5PC1XX_GPIO_DAT_OFFSET]
409 * Note that the following address
410 * 0xE020'0360 is reserved address at S5PC100
412 /* UART_SEL MP0_5[7] at S5PC110 */
413 add r0, r8, #S5PC110_GPIO_MP0_5_OFFSET
414 ldr r1, [r0, #S5PC1XX_GPIO_CON_OFFSET]
415 bic r1, r1, #(0xf << 28) @ 28 = 7 * 4-bit
416 orr r1, r1, #(0x1 << 28) @ Output
417 str r1, [r0, #S5PC1XX_GPIO_CON_OFFSET]
419 ldr r1, [r0, #S5PC1XX_GPIO_PULL_OFFSET]
420 bic r1, r1, #(0x3 << 14) @ 14 = 7 * 2-bit
421 orr r1, r1, #(0x2 << 14) @ Pull-up enabled
422 str r1, [r0, #S5PC1XX_GPIO_PULL_OFFSET]
424 ldr r1, [r0, #S5PC1XX_GPIO_DAT_OFFSET]
425 orr r1, r1, #(1 << 7) @ 7 = 7 * 1-bit
426 str r1, [r0, #S5PC1XX_GPIO_DAT_OFFSET]
431 * tzpc_asm_init: Initialize TZPC
435 ldreq r0, =0xE3800000 @ TZPC0
436 ldrne r0, =0xF1500000 @ TZPC0
444 ldreq r0, =0xE2800000 @ TZPC1
445 ldrne r0, =0xFAD00000 @ TZPC1
450 ldreq r0, =0xE2900000 @ TZPC2
451 ldrne r0, =0xE0600000 @ TZPC2
457 ldrne r0, =0xE1C00000 @ TZPC3 S5PC110 only
458 strne r1, [r0, #0x804]
459 strne r1, [r0, #0x810]
460 strne r1, [r0, #0x81C]