blob: c78dd001d81d2996cb99ffe6fbc4baae9be2e500 [file] [log] [blame]
Alexey Brodkin3a59d912014-02-04 12:56:14 +04001/*
2 * Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved.
3 *
4 * SPDX-License-Identifier: GPL-2.0+
5 */
6
7#include <asm-offsets.h>
8#include <config.h>
Alexey Brodkin7a5f30d2015-02-19 18:40:58 +03009#include <linux/linkage.h>
Alexey Brodkin3a59d912014-02-04 12:56:14 +040010#include <asm/arcregs.h>
11
Alexey Brodkin7a5f30d2015-02-19 18:40:58 +030012ENTRY(_start)
Igor Guryanov4fec6aa2014-12-24 17:17:11 +030013 /* Setup interrupt vector base that matches "__text_start" */
14 sr __ivt_start, [ARC_AUX_INTR_VEC_BASE]
15
Alexey Brodkin9f916ee2015-05-18 16:56:26 +030016 ; Disable/enable I-cache according to configuration
17 lr r5, [ARC_BCR_IC_BUILD]
18 breq r5, 0, 1f ; I$ doesn't exist
19 lr r5, [ARC_AUX_IC_CTRL]
20#ifndef CONFIG_SYS_ICACHE_OFF
21 bclr r5, r5, 0 ; 0 - Enable, 1 is Disable
22#else
23 bset r5, r5, 0 ; I$ exists, but is not used
24#endif
25 sr r5, [ARC_AUX_IC_CTRL]
26
Eugeniy Paltsev346f16d2018-01-16 21:52:25 +030027 mov r5, 1
28 sr r5, [ARC_AUX_IC_IVIC]
29 ; As per ARC HS databook (see chapter 5.3.3.2)
30 ; it is required to add 3 NOPs after each write to IC_IVIC.
31 nop
32 nop
33 nop
34
Alexey Brodkin9f916ee2015-05-18 16:56:26 +0300351:
36 ; Disable/enable D-cache according to configuration
37 lr r5, [ARC_BCR_DC_BUILD]
38 breq r5, 0, 1f ; D$ doesn't exist
39 lr r5, [ARC_AUX_DC_CTRL]
40 bclr r5, r5, 6 ; Invalidate (discard w/o wback)
41#ifndef CONFIG_SYS_DCACHE_OFF
42 bclr r5, r5, 0 ; Enable (+Inv)
43#else
44 bset r5, r5, 0 ; Disable (+Inv)
45#endif
46 sr r5, [ARC_AUX_DC_CTRL]
Igor Guryanov4fec6aa2014-12-24 17:17:11 +030047
Eugeniy Paltsev346f16d2018-01-16 21:52:25 +030048 mov r5, 1
49 sr r5, [ARC_AUX_DC_IVDC]
50
51
Alexey Brodkin9f916ee2015-05-18 16:56:26 +0300521:
Alexey Brodkin275583e2015-03-30 13:36:04 +030053#ifdef CONFIG_ISA_ARCV2
Alexey Brodkin9f916ee2015-05-18 16:56:26 +030054 ; Disable System-Level Cache (SLC)
55 lr r5, [ARC_BCR_SLC]
56 breq r5, 0, 1f ; SLC doesn't exist
57 lr r5, [ARC_AUX_SLC_CTRL]
58 bclr r5, r5, 6 ; Invalidate (discard w/o wback)
59 bclr r5, r5, 0 ; Enable (+Inv)
60 sr r5, [ARC_AUX_SLC_CTRL]
61
621:
Alexey Brodkin275583e2015-03-30 13:36:04 +030063#endif
Alexey Brodkin9f916ee2015-05-18 16:56:26 +030064
Albert ARIBAUD6cb4c462015-11-25 17:56:32 +010065 /* Establish C runtime stack and frame */
Alexey Brodkin9f916ee2015-05-18 16:56:26 +030066 mov %sp, CONFIG_SYS_INIT_SP_ADDR
67 mov %fp, %sp
Igor Guryanov4fec6aa2014-12-24 17:17:11 +030068
Albert ARIBAUD6cb4c462015-11-25 17:56:32 +010069 /* Allocate reserved area from current top of stack */
Alexey Brodkin7f188f22015-02-25 18:10:18 +030070 mov %r0, %sp
Albert ARIBAUD6cb4c462015-11-25 17:56:32 +010071 bl board_init_f_alloc_reserve
72 /* Set stack below reserved area, adjust frame pointer accordingly */
Alexey Brodkin7f188f22015-02-25 18:10:18 +030073 mov %sp, %r0
74 mov %fp, %sp
75
Albert ARIBAUD6cb4c462015-11-25 17:56:32 +010076 /* Initialize reserved area - note: r0 already contains address */
77 bl board_init_f_init_reserve
78
Igor Guryanov4fec6aa2014-12-24 17:17:11 +030079 /* Zero the one and only argument of "board_init_f" */
80 mov_s %r0, 0
Alexey Brodkinc157ab92015-12-16 19:24:10 +030081 bl board_init_f
82
83 /* We only get here if relocation is disabled by GD_FLG_SKIP_RELOC */
84 /* Make sure we don't lose GD overwritten by zero new GD */
85 mov %r0, %r25
86 mov %r1, 0
87 bl board_init_r
Alexey Brodkin7a5f30d2015-02-19 18:40:58 +030088ENDPROC(_start)
Igor Guryanov4fec6aa2014-12-24 17:17:11 +030089
Alexey Brodkin3a59d912014-02-04 12:56:14 +040090/*
Alexey Brodkin913e9f02015-02-24 19:40:36 +030091 * void board_init_f_r_trampoline(stack-pointer address)
Alexey Brodkin3a59d912014-02-04 12:56:14 +040092 *
93 * This "function" does not return, instead it continues in RAM
94 * after relocating the monitor code.
95 *
Alexey Brodkin913e9f02015-02-24 19:40:36 +030096 * r0 = new stack-pointer
Alexey Brodkin3a59d912014-02-04 12:56:14 +040097 */
Alexey Brodkin913e9f02015-02-24 19:40:36 +030098ENTRY(board_init_f_r_trampoline)
99 /* Set up the stack- and frame-pointers */
100 mov %sp, %r0
Alexey Brodkin3a59d912014-02-04 12:56:14 +0400101 mov %fp, %sp
102
Alexey Brodkin913e9f02015-02-24 19:40:36 +0300103 /* Update position of intterupt vector table */
104 lr %r0, [ARC_AUX_INTR_VEC_BASE]
105 ld %r1, [%r25, GD_RELOC_OFF]
106 add %r0, %r0, %r1
107 sr %r0, [ARC_AUX_INTR_VEC_BASE]
Alexey Brodkin3a59d912014-02-04 12:56:14 +0400108
Alexey Brodkin913e9f02015-02-24 19:40:36 +0300109 /* Re-enter U-Boot by calling board_init_f_r */
110 j board_init_f_r
111ENDPROC(board_init_f_r_trampoline)