Chander Kashyap | 0aee53b | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Lowlevel setup for SMDK5250 board based on S5PC520 |
| 3 | * |
| 4 | * Copyright (C) 2012 Samsung Electronics |
| 5 | * |
| 6 | * See file CREDITS for list of people who contributed to this |
| 7 | * project. |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or |
| 10 | * modify it under the terms of the GNU General Public License as |
| 11 | * published by the Free Software Foundation; either version 2 of |
| 12 | * the License, or (at your option) any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program; if not, write to the Free Software |
| 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 22 | * MA 02111-1307 USA |
| 23 | */ |
| 24 | |
| 25 | #include <config.h> |
| 26 | #include <version.h> |
| 27 | #include <asm/arch/cpu.h> |
| 28 | |
| 29 | _TEXT_BASE: |
| 30 | .word CONFIG_SYS_TEXT_BASE |
| 31 | |
| 32 | .globl lowlevel_init |
| 33 | lowlevel_init: |
| 34 | |
Christoffer Dall | 3d28a18 | 2012-11-17 22:46:19 -0500 | [diff] [blame^] | 35 | #ifdef CONFIG_SPL_BUILD |
| 36 | /* check if we're the first cpu or not */ |
| 37 | mrc p15, 0, r0, c0, c0, 5 /* MPIDR */ |
| 38 | and r0, r0, #15 |
| 39 | cmp r0, #0 |
| 40 | beq first_cpu |
| 41 | |
| 42 | /* Secondary CPU */ |
| 43 | bl arch_timer_init |
| 44 | bl non_secure_init |
| 45 | bl monitor_init |
| 46 | bl enter_ns |
| 47 | bl enter_hyp |
| 48 | b enter_smp_pen |
| 49 | |
| 50 | /* |
| 51 | * We entered the SMP pen above, and we expect kernels to write an |
| 52 | * address into the ALIVE SFR SYSFLAGS register thingy at 0x02020000 |
| 53 | * which should not be here, but some kernel secondary entry point. |
| 54 | */ |
| 55 | #endif |
| 56 | |
| 57 | first_cpu: |
Chander Kashyap | 0aee53b | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 58 | /* use iRAM stack in bl2 */ |
| 59 | ldr sp, =CONFIG_IRAM_STACK |
| 60 | stmdb r13!, {ip,lr} |
| 61 | |
| 62 | /* check reset status */ |
| 63 | ldr r0, =(EXYNOS5_POWER_BASE + INFORM1_OFFSET) |
| 64 | ldr r1, [r0] |
| 65 | |
| 66 | /* AFTR wakeup reset */ |
| 67 | ldr r2, =S5P_CHECK_DIDLE |
| 68 | cmp r1, r2 |
| 69 | beq exit_wakeup |
| 70 | |
| 71 | /* LPA wakeup reset */ |
| 72 | ldr r2, =S5P_CHECK_LPA |
| 73 | cmp r1, r2 |
| 74 | beq exit_wakeup |
| 75 | |
| 76 | /* Sleep wakeup reset */ |
| 77 | ldr r2, =S5P_CHECK_SLEEP |
| 78 | cmp r1, r2 |
| 79 | beq wakeup_reset |
| 80 | |
Christoffer Dall | 3d28a18 | 2012-11-17 22:46:19 -0500 | [diff] [blame^] | 81 | /* Init architected timers */ |
| 82 | bl arch_timer_init |
| 83 | |
| 84 | /* Non-secure-init */ |
| 85 | bl non_secure_init |
| 86 | |
Yuvaraj CD | 1f838e8 | 2012-11-15 17:21:16 +0530 | [diff] [blame] | 87 | /*PS-Hold High*/ |
| 88 | ldr r0, =0x1004330c |
| 89 | ldr r1, [r0] |
| 90 | orr r1, r1, #0x100 |
| 91 | str r1, [r0] |
Chander Kashyap | 0aee53b | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 92 | /* |
| 93 | * If U-boot is already running in RAM, no need to relocate U-Boot. |
| 94 | * Memory controller must be configured before relocating U-Boot |
| 95 | * in ram. |
| 96 | */ |
| 97 | ldr r0, =0x0ffffff /* r0 <- Mask Bits*/ |
| 98 | bic r1, pc, r0 /* pc <- current addr of code */ |
| 99 | /* r1 <- unmasked bits of pc */ |
| 100 | ldr r2, _TEXT_BASE /* r2 <- original base addr in ram */ |
| 101 | bic r2, r2, r0 /* r2 <- unmasked bits of r2*/ |
| 102 | cmp r1, r2 /* compare r1, r2 */ |
| 103 | beq 1f /* r0 == r1 then skip sdram init */ |
| 104 | |
| 105 | /* init system clock */ |
| 106 | bl system_clock_init |
| 107 | |
| 108 | /* Memory initialize */ |
| 109 | bl mem_ctrl_init |
| 110 | |
| 111 | 1: |
| 112 | bl tzpc_init |
Christoffer Dall | 3d28a18 | 2012-11-17 22:46:19 -0500 | [diff] [blame^] | 113 | #ifdef CONFIG_SPL_BUILD |
| 114 | bl smp_kick_secondary /* Bring other CPU1 into smp pen */ |
| 115 | #else |
| 116 | bl monitor_init /* Setup monitor mode */ |
| 117 | #endif |
Chander Kashyap | 0aee53b | 2012-02-05 23:01:47 +0000 | [diff] [blame] | 118 | ldmia r13!, {ip,pc} |
| 119 | |
| 120 | wakeup_reset: |
| 121 | bl system_clock_init |
| 122 | bl mem_ctrl_init |
| 123 | bl tzpc_init |
| 124 | |
| 125 | exit_wakeup: |
| 126 | /* Load return address and jump to kernel */ |
| 127 | ldr r0, =(EXYNOS5_POWER_BASE + INFORM0_OFFSET) |
| 128 | |
| 129 | /* r1 = physical address of exynos5_cpu_resume function*/ |
| 130 | ldr r1, [r0] |
| 131 | |
| 132 | /* Jump to kernel */ |
| 133 | mov pc, r1 |
| 134 | nop |
| 135 | nop |