Alexey Brodkin | 3a59d91 | 2014-02-04 12:56:14 +0400 | [diff] [blame] | 1 | /* |
| 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 Brodkin | 7a5f30d | 2015-02-19 18:40:58 +0300 | [diff] [blame] | 9 | #include <linux/linkage.h> |
Alexey Brodkin | 3a59d91 | 2014-02-04 12:56:14 +0400 | [diff] [blame] | 10 | #include <asm/arcregs.h> |
| 11 | |
Alexey Brodkin | 7a5f30d | 2015-02-19 18:40:58 +0300 | [diff] [blame] | 12 | ENTRY(_start) |
Alexey Brodkin | d52ba0a | 2017-04-11 18:24:25 +0300 | [diff] [blame] | 13 | ; ARCompact devices are not supposed to be SMP so master/slave check |
| 14 | ; makes no sense. |
| 15 | #ifdef CONFIG_ISA_ARCV2 |
Alexey Brodkin | 5b9c8a0 | 2017-03-30 17:50:45 +0300 | [diff] [blame] | 16 | ; Non-masters will be halted immediately, they might be kicked later |
| 17 | ; by platform code right before passing control to the Linux kernel |
| 18 | ; in bootm.c:boot_jump_linux(). |
| 19 | lr r5, [identity] |
| 20 | lsr r5, r5, 8 |
| 21 | bmsk r5, r5, 7 |
| 22 | cmp r5, 0 |
| 23 | mov.nz r0, r5 |
| 24 | bz .Lmaster_proceed |
| 25 | flag 1 |
| 26 | nop |
| 27 | nop |
| 28 | nop |
| 29 | |
| 30 | .Lmaster_proceed: |
Alexey Brodkin | d52ba0a | 2017-04-11 18:24:25 +0300 | [diff] [blame] | 31 | #endif |
Alexey Brodkin | 5b9c8a0 | 2017-03-30 17:50:45 +0300 | [diff] [blame] | 32 | |
Igor Guryanov | 4fec6aa | 2014-12-24 17:17:11 +0300 | [diff] [blame] | 33 | /* Setup interrupt vector base that matches "__text_start" */ |
| 34 | sr __ivt_start, [ARC_AUX_INTR_VEC_BASE] |
| 35 | |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 36 | ; Disable/enable I-cache according to configuration |
| 37 | lr r5, [ARC_BCR_IC_BUILD] |
| 38 | breq r5, 0, 1f ; I$ doesn't exist |
| 39 | lr r5, [ARC_AUX_IC_CTRL] |
| 40 | #ifndef CONFIG_SYS_ICACHE_OFF |
| 41 | bclr r5, r5, 0 ; 0 - Enable, 1 is Disable |
| 42 | #else |
| 43 | bset r5, r5, 0 ; I$ exists, but is not used |
| 44 | #endif |
| 45 | sr r5, [ARC_AUX_IC_CTRL] |
| 46 | |
| 47 | 1: |
| 48 | ; Disable/enable D-cache according to configuration |
| 49 | lr r5, [ARC_BCR_DC_BUILD] |
| 50 | breq r5, 0, 1f ; D$ doesn't exist |
| 51 | lr r5, [ARC_AUX_DC_CTRL] |
| 52 | bclr r5, r5, 6 ; Invalidate (discard w/o wback) |
| 53 | #ifndef CONFIG_SYS_DCACHE_OFF |
| 54 | bclr r5, r5, 0 ; Enable (+Inv) |
| 55 | #else |
| 56 | bset r5, r5, 0 ; Disable (+Inv) |
| 57 | #endif |
| 58 | sr r5, [ARC_AUX_DC_CTRL] |
Igor Guryanov | 4fec6aa | 2014-12-24 17:17:11 +0300 | [diff] [blame] | 59 | |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 60 | 1: |
Alexey Brodkin | 275583e | 2015-03-30 13:36:04 +0300 | [diff] [blame] | 61 | #ifdef CONFIG_ISA_ARCV2 |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 62 | ; Disable System-Level Cache (SLC) |
| 63 | lr r5, [ARC_BCR_SLC] |
| 64 | breq r5, 0, 1f ; SLC doesn't exist |
| 65 | lr r5, [ARC_AUX_SLC_CTRL] |
| 66 | bclr r5, r5, 6 ; Invalidate (discard w/o wback) |
| 67 | bclr r5, r5, 0 ; Enable (+Inv) |
| 68 | sr r5, [ARC_AUX_SLC_CTRL] |
| 69 | |
| 70 | 1: |
Alexey Brodkin | 275583e | 2015-03-30 13:36:04 +0300 | [diff] [blame] | 71 | #endif |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 72 | |
Albert ARIBAUD | 6cb4c46 | 2015-11-25 17:56:32 +0100 | [diff] [blame] | 73 | /* Establish C runtime stack and frame */ |
Alexey Brodkin | 9f916ee | 2015-05-18 16:56:26 +0300 | [diff] [blame] | 74 | mov %sp, CONFIG_SYS_INIT_SP_ADDR |
| 75 | mov %fp, %sp |
Igor Guryanov | 4fec6aa | 2014-12-24 17:17:11 +0300 | [diff] [blame] | 76 | |
Albert ARIBAUD | 6cb4c46 | 2015-11-25 17:56:32 +0100 | [diff] [blame] | 77 | /* Allocate reserved area from current top of stack */ |
Alexey Brodkin | 7f188f2 | 2015-02-25 18:10:18 +0300 | [diff] [blame] | 78 | mov %r0, %sp |
Albert ARIBAUD | 6cb4c46 | 2015-11-25 17:56:32 +0100 | [diff] [blame] | 79 | bl board_init_f_alloc_reserve |
| 80 | /* Set stack below reserved area, adjust frame pointer accordingly */ |
Alexey Brodkin | 7f188f2 | 2015-02-25 18:10:18 +0300 | [diff] [blame] | 81 | mov %sp, %r0 |
| 82 | mov %fp, %sp |
| 83 | |
Albert ARIBAUD | 6cb4c46 | 2015-11-25 17:56:32 +0100 | [diff] [blame] | 84 | /* Initialize reserved area - note: r0 already contains address */ |
| 85 | bl board_init_f_init_reserve |
| 86 | |
Igor Guryanov | 4fec6aa | 2014-12-24 17:17:11 +0300 | [diff] [blame] | 87 | /* Zero the one and only argument of "board_init_f" */ |
| 88 | mov_s %r0, 0 |
| 89 | j board_init_f |
Alexey Brodkin | 7a5f30d | 2015-02-19 18:40:58 +0300 | [diff] [blame] | 90 | ENDPROC(_start) |
Igor Guryanov | 4fec6aa | 2014-12-24 17:17:11 +0300 | [diff] [blame] | 91 | |
Alexey Brodkin | 3a59d91 | 2014-02-04 12:56:14 +0400 | [diff] [blame] | 92 | /* |
Alexey Brodkin | 913e9f0 | 2015-02-24 19:40:36 +0300 | [diff] [blame] | 93 | * void board_init_f_r_trampoline(stack-pointer address) |
Alexey Brodkin | 3a59d91 | 2014-02-04 12:56:14 +0400 | [diff] [blame] | 94 | * |
| 95 | * This "function" does not return, instead it continues in RAM |
| 96 | * after relocating the monitor code. |
| 97 | * |
Alexey Brodkin | 913e9f0 | 2015-02-24 19:40:36 +0300 | [diff] [blame] | 98 | * r0 = new stack-pointer |
Alexey Brodkin | 3a59d91 | 2014-02-04 12:56:14 +0400 | [diff] [blame] | 99 | */ |
Alexey Brodkin | 913e9f0 | 2015-02-24 19:40:36 +0300 | [diff] [blame] | 100 | ENTRY(board_init_f_r_trampoline) |
| 101 | /* Set up the stack- and frame-pointers */ |
| 102 | mov %sp, %r0 |
Alexey Brodkin | 3a59d91 | 2014-02-04 12:56:14 +0400 | [diff] [blame] | 103 | mov %fp, %sp |
| 104 | |
Alexey Brodkin | 913e9f0 | 2015-02-24 19:40:36 +0300 | [diff] [blame] | 105 | /* Update position of intterupt vector table */ |
| 106 | lr %r0, [ARC_AUX_INTR_VEC_BASE] |
| 107 | ld %r1, [%r25, GD_RELOC_OFF] |
| 108 | add %r0, %r0, %r1 |
| 109 | sr %r0, [ARC_AUX_INTR_VEC_BASE] |
Alexey Brodkin | 3a59d91 | 2014-02-04 12:56:14 +0400 | [diff] [blame] | 110 | |
Alexey Brodkin | 913e9f0 | 2015-02-24 19:40:36 +0300 | [diff] [blame] | 111 | /* Re-enter U-Boot by calling board_init_f_r */ |
| 112 | j board_init_f_r |
| 113 | ENDPROC(board_init_f_r_trampoline) |