1/*
2 * Copyright (C) 2012 Nobuhiro Iwamatsu <nobuhiro.Iwamatsu.yj@renesas.com>
3 * Copyright (C) 2012 Renesas Solutions Corp.
4 *
5 * SPDX-License-Identifier:	GPL-2.0+
6 */
7
8#include <config.h>
9#include <linux/linkage.h>
10
11ENTRY(lowlevel_init)
12	ldr		r0, =MERAM_BASE
13	mov		r1, #0x0
14	str		r1, [r0]
15
16	mrc		p15, 0, r0, c0, c0, 5
17	ands	r0, r0, #0xF
18	beq		lowlevel_init__
19	b		wait_interrupt
20
21	.pool
22	.align 4
23
24wait_interrupt:
25#ifdef ICCICR
26	ldr     r1, =ICCICR
27	mov     r2, #0x0
28	str     r2, [r1]
29	mov     r2, #0xF0
30	adds    r1, r1, #4 /* ICCPMR */
31	str     r2, [r1]
32	ldr     r1, =ICCICR
33	mov     r2, #0x1
34	str     r2, [r1]
35#endif
36
37wait_loop:
38	.long	0xE320F003 /* wfi */
39
40	ldr		r2, [r1, #0xC]
41	str		r2, [r1, #0x10]
42
43	ldr		r0, =MERAM_BASE
44	ldr		r2, [r0]
45	cmp		r2, #0
46	movne	pc, r2
47
48	b		wait_loop
49
50wait_loop_end:
51	.pool
52	.align 4
53
54lowlevel_init__:
55
56	mov r0, #0x200000
57
58loop0:
59	subs r0, r0, #1
60	bne  loop0
61
62	ldr sp, MERAM_STACK
63	b s_init
64
65	.pool
66	.align 4
67
68ENDPROC(lowlevel_init)
69	.ltorg
70
71MERAM_STACK:
72	.word LOW_LEVEL_MERAM_STACK
73