Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Alexey Brodkin | 3a59d91 | 2014-02-04 12:56:14 +0400 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved. |
Alexey Brodkin | 3a59d91 | 2014-02-04 12:56:14 +0400 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <asm-offsets.h> |
| 7 | #include <config.h> |
Alexey Brodkin | 7a5f30d | 2015-02-19 18:40:58 +0300 | [diff] [blame] | 8 | #include <linux/linkage.h> |
Alexey Brodkin | 3a59d91 | 2014-02-04 12:56:14 +0400 | [diff] [blame] | 9 | #include <asm/arcregs.h> |
| 10 | |
Alexey Brodkin | 7a5f30d | 2015-02-19 18:40:58 +0300 | [diff] [blame] | 11 | ENTRY(_start) |
Igor Guryanov | 4fec6aa | 2014-12-24 17:17:11 +0300 | [diff] [blame] | 12 | /* Setup interrupt vector base that matches "__text_start" */ |
| 13 | sr __ivt_start, [ARC_AUX_INTR_VEC_BASE] |
| 14 | |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 15 | ; 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 Woerner | 43ec7e0 | 2019-05-03 09:41:00 -0400 | [diff] [blame] | 19 | #if !CONFIG_IS_ENABLED(SYS_ICACHE_OFF) |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 20 | 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 Paltsev | 346f16d | 2018-01-16 21:52:25 +0300 | [diff] [blame] | 26 | 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 Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 34 | 1: |
| 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 Woerner | 43ec7e0 | 2019-05-03 09:41:00 -0400 | [diff] [blame] | 40 | #if !CONFIG_IS_ENABLED(SYS_DCACHE_OFF) |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 41 | bclr r5, r5, 0 ; Enable (+Inv) |
| 42 | #else |
| 43 | bset r5, r5, 0 ; Disable (+Inv) |
| 44 | #endif |
| 45 | sr r5, [ARC_AUX_DC_CTRL] |
Igor Guryanov | 4fec6aa | 2014-12-24 17:17:11 +0300 | [diff] [blame] | 46 | |
Eugeniy Paltsev | 346f16d | 2018-01-16 21:52:25 +0300 | [diff] [blame] | 47 | mov r5, 1 |
| 48 | sr r5, [ARC_AUX_DC_IVDC] |
| 49 | |
| 50 | |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 51 | 1: |
Alexey Brodkin | 275583e | 2015-03-30 13:36:04 +0300 | [diff] [blame] | 52 | #ifdef CONFIG_ISA_ARCV2 |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 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 | |
| 61 | 1: |
Alexey Brodkin | 275583e | 2015-03-30 13:36:04 +0300 | [diff] [blame] | 62 | #endif |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 63 | |
Eugeniy Paltsev | f0aa995 | 2020-04-22 18:33:21 +0300 | [diff] [blame] | 64 | #ifdef CONFIG_ISA_ARCV2 |
| 65 | ; In case of DSP extension presence in HW some instructions |
| 66 | ; (related to integer multiply, multiply-accumulate, and divide |
| 67 | ; operation) executes on this DSP execution unit. So their |
| 68 | ; execution will depend on dsp configuration register (DSP_CTRL) |
| 69 | ; As we want these instructions to execute the same way regardless |
| 70 | ; of DSP presence we need to set DSP_CTRL properly. |
| 71 | lr r5, [ARC_AUX_DSP_BUILD] |
| 72 | bmsk r5, r5, 7 |
| 73 | breq r5, 0, 1f |
| 74 | mov r5, 0 |
| 75 | sr r5, [ARC_AUX_DSP_CTRL] |
| 76 | 1: |
| 77 | #endif |
| 78 | |
Alexey Brodkin | 9b56b5d | 2018-07-29 09:47:52 +0300 | [diff] [blame] | 79 | #ifdef __ARC_UNALIGNED__ |
| 80 | /* |
| 81 | * Enable handling of unaligned access in the CPU as by default |
| 82 | * this HW feature is disabled while GCC starting from 8.1.0 |
| 83 | * unconditionally uses it for ARC HS cores. |
| 84 | */ |
| 85 | flag 1 << STATUS_AD_BIT |
| 86 | #endif |
| 87 | |
Albert ARIBAUD | 6cb4c46 | 2015-11-25 17:56:32 +0100 | [diff] [blame] | 88 | /* Establish C runtime stack and frame */ |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 89 | mov %sp, CONFIG_SYS_INIT_SP_ADDR |
| 90 | mov %fp, %sp |
Igor Guryanov | 4fec6aa | 2014-12-24 17:17:11 +0300 | [diff] [blame] | 91 | |
Albert ARIBAUD | 6cb4c46 | 2015-11-25 17:56:32 +0100 | [diff] [blame] | 92 | /* Allocate reserved area from current top of stack */ |
Alexey Brodkin | 7f188f2 | 2015-02-25 18:10:18 +0300 | [diff] [blame] | 93 | mov %r0, %sp |
Albert ARIBAUD | 6cb4c46 | 2015-11-25 17:56:32 +0100 | [diff] [blame] | 94 | bl board_init_f_alloc_reserve |
| 95 | /* Set stack below reserved area, adjust frame pointer accordingly */ |
Alexey Brodkin | 7f188f2 | 2015-02-25 18:10:18 +0300 | [diff] [blame] | 96 | mov %sp, %r0 |
| 97 | mov %fp, %sp |
| 98 | |
Albert ARIBAUD | 6cb4c46 | 2015-11-25 17:56:32 +0100 | [diff] [blame] | 99 | /* Initialize reserved area - note: r0 already contains address */ |
| 100 | bl board_init_f_init_reserve |
| 101 | |
Eugeniy Paltsev | 14e1dd6 | 2018-05-03 15:01:58 +0300 | [diff] [blame] | 102 | #ifdef CONFIG_DEBUG_UART |
| 103 | /* Earliest point to set up early debug uart */ |
| 104 | bl debug_uart_init |
| 105 | #endif |
| 106 | |
Igor Guryanov | 4fec6aa | 2014-12-24 17:17:11 +0300 | [diff] [blame] | 107 | /* Zero the one and only argument of "board_init_f" */ |
| 108 | mov_s %r0, 0 |
Alexey Brodkin | c157ab9 | 2015-12-16 19:24:10 +0300 | [diff] [blame] | 109 | bl board_init_f |
| 110 | |
| 111 | /* We only get here if relocation is disabled by GD_FLG_SKIP_RELOC */ |
| 112 | /* Make sure we don't lose GD overwritten by zero new GD */ |
| 113 | mov %r0, %r25 |
| 114 | mov %r1, 0 |
| 115 | bl board_init_r |
Alexey Brodkin | 7a5f30d | 2015-02-19 18:40:58 +0300 | [diff] [blame] | 116 | ENDPROC(_start) |
Igor Guryanov | 4fec6aa | 2014-12-24 17:17:11 +0300 | [diff] [blame] | 117 | |
Alexey Brodkin | 3a59d91 | 2014-02-04 12:56:14 +0400 | [diff] [blame] | 118 | /* |
Alexey Brodkin | 913e9f0 | 2015-02-24 19:40:36 +0300 | [diff] [blame] | 119 | * void board_init_f_r_trampoline(stack-pointer address) |
Alexey Brodkin | 3a59d91 | 2014-02-04 12:56:14 +0400 | [diff] [blame] | 120 | * |
| 121 | * This "function" does not return, instead it continues in RAM |
| 122 | * after relocating the monitor code. |
| 123 | * |
Alexey Brodkin | 913e9f0 | 2015-02-24 19:40:36 +0300 | [diff] [blame] | 124 | * r0 = new stack-pointer |
Alexey Brodkin | 3a59d91 | 2014-02-04 12:56:14 +0400 | [diff] [blame] | 125 | */ |
Alexey Brodkin | 913e9f0 | 2015-02-24 19:40:36 +0300 | [diff] [blame] | 126 | ENTRY(board_init_f_r_trampoline) |
| 127 | /* Set up the stack- and frame-pointers */ |
| 128 | mov %sp, %r0 |
Alexey Brodkin | 3a59d91 | 2014-02-04 12:56:14 +0400 | [diff] [blame] | 129 | mov %fp, %sp |
| 130 | |
Alexey Brodkin | 913e9f0 | 2015-02-24 19:40:36 +0300 | [diff] [blame] | 131 | /* Update position of intterupt vector table */ |
| 132 | lr %r0, [ARC_AUX_INTR_VEC_BASE] |
| 133 | ld %r1, [%r25, GD_RELOC_OFF] |
| 134 | add %r0, %r0, %r1 |
| 135 | sr %r0, [ARC_AUX_INTR_VEC_BASE] |
Alexey Brodkin | 3a59d91 | 2014-02-04 12:56:14 +0400 | [diff] [blame] | 136 | |
Alexey Brodkin | 913e9f0 | 2015-02-24 19:40:36 +0300 | [diff] [blame] | 137 | /* Re-enter U-Boot by calling board_init_f_r */ |
| 138 | j board_init_f_r |
| 139 | ENDPROC(board_init_f_r_trampoline) |