blob: 8c744f5be7f188879ad39751dc3d5c7b3380a3c5 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Alexey Brodkin2f16ac92014-02-04 12:56:14 +04002/*
3 * Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved.
Alexey Brodkin2f16ac92014-02-04 12:56:14 +04004 */
5
6#include <asm-offsets.h>
7#include <config.h>
Alexey Brodkin4d936172015-02-19 18:40:58 +03008#include <linux/linkage.h>
Alexey Brodkin2f16ac92014-02-04 12:56:14 +04009#include <asm/arcregs.h>
10
Alexey Brodkin4d936172015-02-19 18:40:58 +030011ENTRY(_start)
Igor Guryanov20a58ac2014-12-24 17:17:11 +030012 /* Setup interrupt vector base that matches "__text_start" */
13 sr __ivt_start, [ARC_AUX_INTR_VEC_BASE]
14
Alexey Brodkinef639e62015-05-18 16:56:26 +030015 ; Disable/enable I-cache according to configuration
16 lr r5, [ARC_BCR_IC_BUILD]
17 breq r5, 0, 1f ; I$ doesn't exist
18 lr r5, [ARC_AUX_IC_CTRL]
Trevor Woerner10015022019-05-03 09:41:00 -040019#if !CONFIG_IS_ENABLED(SYS_ICACHE_OFF)
Alexey Brodkinef639e62015-05-18 16:56:26 +030020 bclr r5, r5, 0 ; 0 - Enable, 1 is Disable
21#else
22 bset r5, r5, 0 ; I$ exists, but is not used
23#endif
24 sr r5, [ARC_AUX_IC_CTRL]
25
Eugeniy Paltsevc0e67692018-01-16 21:52:25 +030026 mov r5, 1
27 sr r5, [ARC_AUX_IC_IVIC]
28 ; As per ARC HS databook (see chapter 5.3.3.2)
29 ; it is required to add 3 NOPs after each write to IC_IVIC.
30 nop
31 nop
32 nop
33
Alexey Brodkinef639e62015-05-18 16:56:26 +0300341:
35 ; Disable/enable D-cache according to configuration
36 lr r5, [ARC_BCR_DC_BUILD]
37 breq r5, 0, 1f ; D$ doesn't exist
38 lr r5, [ARC_AUX_DC_CTRL]
39 bclr r5, r5, 6 ; Invalidate (discard w/o wback)
Trevor Woerner10015022019-05-03 09:41:00 -040040#if !CONFIG_IS_ENABLED(SYS_DCACHE_OFF)
Alexey Brodkinef639e62015-05-18 16:56:26 +030041 bclr r5, r5, 0 ; Enable (+Inv)
42#else
43 bset r5, r5, 0 ; Disable (+Inv)
44#endif
45 sr r5, [ARC_AUX_DC_CTRL]
46
Eugeniy Paltsevc0e67692018-01-16 21:52:25 +030047 mov r5, 1
48 sr r5, [ARC_AUX_DC_IVDC]
49
50
Alexey Brodkinef639e62015-05-18 16:56:26 +0300511:
52#ifdef CONFIG_ISA_ARCV2
53 ; Disable System-Level Cache (SLC)
54 lr r5, [ARC_BCR_SLC]
55 breq r5, 0, 1f ; SLC doesn't exist
56 lr r5, [ARC_AUX_SLC_CTRL]
57 bclr r5, r5, 6 ; Invalidate (discard w/o wback)
58 bclr r5, r5, 0 ; Enable (+Inv)
59 sr r5, [ARC_AUX_SLC_CTRL]
60
611:
62#endif
63
Alexey Brodkin8f590062018-07-29 09:47:52 +030064#ifdef __ARC_UNALIGNED__
65 /*
66 * Enable handling of unaligned access in the CPU as by default
67 * this HW feature is disabled while GCC starting from 8.1.0
68 * unconditionally uses it for ARC HS cores.
69 */
70 flag 1 << STATUS_AD_BIT
71#endif
72
Albert ARIBAUDecc30662015-11-25 17:56:32 +010073 /* Establish C runtime stack and frame */
Igor Guryanov20a58ac2014-12-24 17:17:11 +030074 mov %sp, CONFIG_SYS_INIT_SP_ADDR
75 mov %fp, %sp
76
Albert ARIBAUDecc30662015-11-25 17:56:32 +010077 /* Allocate reserved area from current top of stack */
Alexey Brodkinf56d6252015-02-25 18:10:18 +030078 mov %r0, %sp
Albert ARIBAUDecc30662015-11-25 17:56:32 +010079 bl board_init_f_alloc_reserve
80 /* Set stack below reserved area, adjust frame pointer accordingly */
Alexey Brodkinf56d6252015-02-25 18:10:18 +030081 mov %sp, %r0
82 mov %fp, %sp
83
Albert ARIBAUDecc30662015-11-25 17:56:32 +010084 /* Initialize reserved area - note: r0 already contains address */
85 bl board_init_f_init_reserve
86
Eugeniy Paltsev429fa252018-05-03 15:01:58 +030087#ifdef CONFIG_DEBUG_UART
88 /* Earliest point to set up early debug uart */
89 bl debug_uart_init
90#endif
91
Igor Guryanov20a58ac2014-12-24 17:17:11 +030092 /* Zero the one and only argument of "board_init_f" */
93 mov_s %r0, 0
Alexey Brodkin264d2982015-12-16 19:24:10 +030094 bl board_init_f
95
96 /* We only get here if relocation is disabled by GD_FLG_SKIP_RELOC */
97 /* Make sure we don't lose GD overwritten by zero new GD */
98 mov %r0, %r25
99 mov %r1, 0
100 bl board_init_r
Alexey Brodkin4d936172015-02-19 18:40:58 +0300101ENDPROC(_start)
Igor Guryanov20a58ac2014-12-24 17:17:11 +0300102
Alexey Brodkin2f16ac92014-02-04 12:56:14 +0400103/*
Alexey Brodkin3fb80162015-02-24 19:40:36 +0300104 * void board_init_f_r_trampoline(stack-pointer address)
Alexey Brodkin2f16ac92014-02-04 12:56:14 +0400105 *
106 * This "function" does not return, instead it continues in RAM
107 * after relocating the monitor code.
108 *
Alexey Brodkin3fb80162015-02-24 19:40:36 +0300109 * r0 = new stack-pointer
Alexey Brodkin2f16ac92014-02-04 12:56:14 +0400110 */
Alexey Brodkin3fb80162015-02-24 19:40:36 +0300111ENTRY(board_init_f_r_trampoline)
112 /* Set up the stack- and frame-pointers */
113 mov %sp, %r0
Alexey Brodkin2f16ac92014-02-04 12:56:14 +0400114 mov %fp, %sp
115
Alexey Brodkin3fb80162015-02-24 19:40:36 +0300116 /* Update position of intterupt vector table */
117 lr %r0, [ARC_AUX_INTR_VEC_BASE]
118 ld %r1, [%r25, GD_RELOC_OFF]
119 add %r0, %r0, %r1
120 sr %r0, [ARC_AUX_INTR_VEC_BASE]
Alexey Brodkin2f16ac92014-02-04 12:56:14 +0400121
Alexey Brodkin3fb80162015-02-24 19:40:36 +0300122 /* Re-enter U-Boot by calling board_init_f_r */
123 j board_init_f_r
124ENDPROC(board_init_f_r_trampoline)