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