blob: 1bd391e8403e7c8a7c4e17d3774752e896d06353 [file] [log] [blame]
Nobuhiro Iwamatsu940103d2012-08-19 04:40:05 +00001/*
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
27ENTRY(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
40wait_interrupt:
Nobuhiro Iwamatsufe1c4bc2012-07-25 15:48:27 +090041#ifdef ICCICR
Nobuhiro Iwamatsu940103d2012-08-19 04:40:05 +000042 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]
Nobuhiro Iwamatsufe1c4bc2012-07-25 15:48:27 +090051#endif
Nobuhiro Iwamatsu940103d2012-08-19 04:40:05 +000052
53wait_loop:
Nobuhiro Iwamatsu7cd76e12012-07-06 08:53:02 +090054 .long 0xE320F003 /* wfi */
Nobuhiro Iwamatsu940103d2012-08-19 04:40:05 +000055
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
66wait_loop_end:
67 .pool
68 .align 4
69
70lowlevel_init__:
71
72 mov r0, #0x200000
73
74loop0:
75 subs r0, r0, #1
76 bne loop0
77
78 ldr sp, MERAM_STACK
79
80 str ip, [sp] /* stash old link register */
81 mov ip, lr /* save link reg across call */
Nobuhiro Iwamatsufe1c4bc2012-07-25 15:48:27 +090082
Nobuhiro Iwamatsu940103d2012-08-19 04:40:05 +000083 bl s_init
84
85 ldr ip, [sp] /* restore save ip */
86 mov lr, ip /* restore link reg */
87
88 /* back to arch calling code */
89 mov pc, lr
90
91 .pool
92 .align 4
93
94ENDPROC(lowlevel_init)
95 .ltorg
96
97MERAM_STACK:
98 .word LOW_LEVEL_MERAM_STACK