Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Guennadi Liakhovetski | 8c170c5 | 2008-08-31 00:39:46 +0200 | [diff] [blame] | 2 | /* |
Cyril Chemparathy | 4e3ad93 | 2010-06-07 14:13:27 -0400 | [diff] [blame] | 3 | * armboot - Startup Code for ARM1176 CPU-core |
Guennadi Liakhovetski | 8c170c5 | 2008-08-31 00:39:46 +0200 | [diff] [blame] | 4 | * |
| 5 | * Copyright (c) 2007 Samsung Electronics |
| 6 | * |
| 7 | * Copyright (C) 2008 |
| 8 | * Guennadi Liakhovetki, DENX Software Engineering, <lg@denx.de> |
| 9 | * |
Guennadi Liakhovetski | 8c170c5 | 2008-08-31 00:39:46 +0200 | [diff] [blame] | 10 | * 2007-09-21 - Restructured codes by jsgood (jsgood.yang@samsung.com) |
| 11 | * 2007-09-21 - Added MoviNAND and OneNAND boot codes by |
| 12 | * jsgood (jsgood.yang@samsung.com) |
| 13 | * Base codes by scsuh (sc.suh) |
| 14 | */ |
| 15 | |
Wolfgang Denk | 0191e47 | 2010-10-26 14:34:52 +0200 | [diff] [blame] | 16 | #include <asm-offsets.h> |
Guennadi Liakhovetski | 8c170c5 | 2008-08-31 00:39:46 +0200 | [diff] [blame] | 17 | #include <config.h> |
Cédric Schieli | 4bcddad | 2016-11-11 11:59:06 +0100 | [diff] [blame] | 18 | #include <linux/linkage.h> |
Guennadi Liakhovetski | 8c170c5 | 2008-08-31 00:39:46 +0200 | [diff] [blame] | 19 | |
Guennadi Liakhovetski | 8c170c5 | 2008-08-31 00:39:46 +0200 | [diff] [blame] | 20 | /* |
| 21 | ************************************************************************* |
| 22 | * |
Guennadi Liakhovetski | 8c170c5 | 2008-08-31 00:39:46 +0200 | [diff] [blame] | 23 | * Startup Code (reset vector) |
| 24 | * |
| 25 | * do important init only if we don't start from memory! |
| 26 | * setup Memory and board specific bits prior to relocation. |
| 27 | * relocate armboot to ram |
| 28 | * setup stack |
| 29 | * |
| 30 | ************************************************************************* |
| 31 | */ |
| 32 | |
Albert ARIBAUD | 9852cc6 | 2014-04-15 16:13:51 +0200 | [diff] [blame] | 33 | .globl reset |
Guennadi Liakhovetski | 8c170c5 | 2008-08-31 00:39:46 +0200 | [diff] [blame] | 34 | |
| 35 | reset: |
Cédric Schieli | 4bcddad | 2016-11-11 11:59:06 +0100 | [diff] [blame] | 36 | /* Allow the board to save important registers */ |
| 37 | b save_boot_params |
| 38 | .globl save_boot_params_ret |
| 39 | save_boot_params_ret: |
| 40 | |
Guennadi Liakhovetski | 8c170c5 | 2008-08-31 00:39:46 +0200 | [diff] [blame] | 41 | /* |
| 42 | * set the cpu to SVC32 mode |
| 43 | */ |
| 44 | mrs r0, cpsr |
| 45 | bic r0, r0, #0x3f |
| 46 | orr r0, r0, #0xd3 |
| 47 | msr cpsr, r0 |
| 48 | |
| 49 | /* |
| 50 | ************************************************************************* |
| 51 | * |
| 52 | * CPU_init_critical registers |
| 53 | * |
| 54 | * setup important registers |
| 55 | * setup memory timing |
| 56 | * |
| 57 | ************************************************************************* |
| 58 | */ |
| 59 | /* |
| 60 | * we do sys-critical inits only at reboot, |
| 61 | * not when booting from ram! |
| 62 | */ |
| 63 | cpu_init_crit: |
| 64 | /* |
| 65 | * When booting from NAND - it has definitely been a reset, so, no need |
| 66 | * to flush caches and disable the MMU |
| 67 | */ |
Benoît Thébaudeau | 80f2f93 | 2013-04-11 09:36:01 +0000 | [diff] [blame] | 68 | #ifndef CONFIG_SPL_BUILD |
Guennadi Liakhovetski | 8c170c5 | 2008-08-31 00:39:46 +0200 | [diff] [blame] | 69 | /* |
| 70 | * flush v4 I/D caches |
| 71 | */ |
| 72 | mov r0, #0 |
| 73 | mcr p15, 0, r0, c7, c7, 0 /* flush v3/v4 cache */ |
| 74 | mcr p15, 0, r0, c8, c7, 0 /* flush v4 TLB */ |
| 75 | |
| 76 | /* |
| 77 | * disable MMU stuff and caches |
| 78 | */ |
| 79 | mrc p15, 0, r0, c1, c0, 0 |
| 80 | bic r0, r0, #0x00002300 @ clear bits 13, 9:8 (--V- --RS) |
| 81 | bic r0, r0, #0x00000087 @ clear bits 7, 2:0 (B--- -CAM) |
Yuichiro Goto | 8d4b7e9 | 2016-02-25 10:23:34 +0900 | [diff] [blame] | 82 | orr r0, r0, #0x00000002 @ set bit 1 (A) Align |
Guennadi Liakhovetski | 8c170c5 | 2008-08-31 00:39:46 +0200 | [diff] [blame] | 83 | orr r0, r0, #0x00001000 @ set bit 12 (I) I-Cache |
Cyril Chemparathy | 4e3ad93 | 2010-06-07 14:13:27 -0400 | [diff] [blame] | 84 | |
Guennadi Liakhovetski | 8c170c5 | 2008-08-31 00:39:46 +0200 | [diff] [blame] | 85 | /* Prepare to disable the MMU */ |
Cyril Chemparathy | 4e3ad93 | 2010-06-07 14:13:27 -0400 | [diff] [blame] | 86 | adr r2, mmu_disable_phys |
Tom Rini | d259d9c | 2023-01-10 11:19:28 -0500 | [diff] [blame] | 87 | sub r2, r2, #(CFG_SYS_UBOOT_BASE - CONFIG_TEXT_BASE) |
Guennadi Liakhovetski | 8c170c5 | 2008-08-31 00:39:46 +0200 | [diff] [blame] | 88 | b mmu_disable |
| 89 | |
| 90 | .align 5 |
| 91 | /* Run in a single cache-line */ |
| 92 | mmu_disable: |
| 93 | mcr p15, 0, r0, c1, c0, 0 |
| 94 | nop |
| 95 | nop |
| 96 | mov pc, r2 |
Cyril Chemparathy | 4e3ad93 | 2010-06-07 14:13:27 -0400 | [diff] [blame] | 97 | mmu_disable_phys: |
| 98 | |
Joonyoung Shim | ce0cdc5 | 2010-02-08 22:00:52 +0900 | [diff] [blame] | 99 | #endif |
Guennadi Liakhovetski | 8c170c5 | 2008-08-31 00:39:46 +0200 | [diff] [blame] | 100 | |
| 101 | /* |
| 102 | * Go setup Memory and board specific bits prior to relocation. |
| 103 | */ |
| 104 | bl lowlevel_init /* go setup pll,mux,memory */ |
| 105 | |
Albert ARIBAUD | facdae5 | 2013-01-08 10:18:02 +0000 | [diff] [blame] | 106 | bl _main |
Heiko Schocher | 55f965a | 2010-09-17 13:10:53 +0200 | [diff] [blame] | 107 | |
| 108 | /*------------------------------------------------------------------------------*/ |
| 109 | |
Albert ARIBAUD | facdae5 | 2013-01-08 10:18:02 +0000 | [diff] [blame] | 110 | .globl c_runtime_cpu_setup |
| 111 | c_runtime_cpu_setup: |
| 112 | |
| 113 | mov pc, lr |
Cédric Schieli | 4bcddad | 2016-11-11 11:59:06 +0100 | [diff] [blame] | 114 | |
| 115 | WEAK(save_boot_params) |
| 116 | b save_boot_params_ret /* back to my caller */ |
| 117 | ENDPROC(save_boot_params) |