Merge branch 'agust@denx.de-next' of git://git.denx.de/u-boot-staging
[platform/kernel/u-boot.git] / arch / arm / cpu / armv7 / rmobile / lowlevel_init.S
1 /*
2  * Copyright (C) 2012 Nobuhiro Iwamatsu <nobuhiro.Iwamatsu.yj@renesas.com>
3  * Copyright (C) 2012 Renesas Solutions Corp.
4  *
5  * See file CREDITS for list of people who contributed to this
6  * project.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License as
10  * published by the Free Software Foundation; either version 2 of
11  * the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21  * MA 02111-1307 USA
22  */
23
24 #include <config.h>
25 #include <linux/linkage.h>
26
27 ENTRY(lowlevel_init)
28         ldr             r0, =MERAM_BASE
29         mov             r1, #0x0
30         str             r1, [r0]
31
32         mrc             p15, 0, r0, c0, c0, 5
33         ands    r0, r0, #0xF
34         beq             lowlevel_init__
35         b               wait_interrupt
36
37         .pool
38         .align 4
39
40 wait_interrupt:
41 #ifdef ICCICR
42         ldr     r1, =ICCICR
43         mov     r2, #0x0
44         str     r2, [r1]
45         mov     r2, #0xF0
46         adds    r1, r1, #4 /* ICCPMR */
47         str     r2, [r1]
48         ldr     r1, =ICCICR
49         mov     r2, #0x1
50         str     r2, [r1]
51 #endif
52
53 wait_loop:
54         .long   0xE320F003 /* wfi */
55
56         ldr             r2, [r1, #0xC]
57         str             r2, [r1, #0x10]
58
59         ldr             r0, =MERAM_BASE
60         ldr             r2, [r0]
61         cmp             r2, #0
62         movne   pc, r2
63
64         b               wait_loop
65
66 wait_loop_end:
67         .pool
68         .align 4
69
70 lowlevel_init__:
71
72         mov r0, #0x200000
73
74 loop0:
75         subs r0, r0, #1
76         bne  loop0
77
78         ldr sp, MERAM_STACK
79         b s_init
80
81         .pool
82         .align 4
83
84 ENDPROC(lowlevel_init)
85         .ltorg
86
87 MERAM_STACK:
88         .word LOW_LEVEL_MERAM_STACK