2 * boot.S - simple register setup code for stand-alone Linux booting
4 * Copyright (C) 2012 ARM Limited. All rights reserved.
6 * Use of this source code is governed by a BSD-style license that can be
7 * found in the LICENSE.txt file.
19 b.ne start_ns // skip EL3 initialisation
22 orr x0, x0, #(1 << 0) // Non-secure EL1
23 orr x0, x0, #(1 << 8) // HVC enable
24 orr x0, x0, #(1 << 10) // 64-bit EL2
27 msr cptr_el3, xzr // Disable copro. traps to EL3
33 * Check for the primary CPU to avoid a race on the distributor
37 // ARM MPIDR_EL1 bytes: Aff3 (AArch64), Stuff, Aff2, Aff1, Aff0
38 // Test the the MPIDR_EL1 register against 0xff00ffffff to
39 // extract the primary CPU.
41 tst x0, x1 // check for cpuid==zero
42 b.ne 1f // secondary CPU
44 ldr x1, =GIC_DIST_BASE // GICD_CTLR
45 mov w0, #3 // EnableGrp0 | EnableGrp1
48 1: ldr x1, =GIC_DIST_BASE + 0x80 // GICD_IGROUPR
49 mov w0, #~0 // Grp1 interrupts
51 b.ne 2f // Only local interrupts for secondary CPUs
55 2: ldr x1, =GIC_CPU_BASE // GICC_CTLR
57 mov w0, #3 // EnableGrp0 | EnableGrp1
60 mov w0, #1 << 7 // allow NS access to GICC_PMR
61 str w0, [x1, #4] // GICC_PMR
66 * Prepare the switch to the EL2_SP1 mode from EL3
68 ldr x0, =start_ns // Return after mode switch
69 mov x1, #0x3c9 // EL2_SP1 | D | A | I | F
84 // ARM MPIDR_EL1 bytes: Aff3 (AArch64), Stuff, Aff2, Aff1, Aff0
85 // Test the the MPIDR_EL1 register against 0xff00ffffff to
86 // extract the primary CPU.
88 tst x4, x1 // check for cpuid==zero
89 mov x1, xzr // load previous 'xzr' value back to x1
90 b.eq 2f // secondary CPU
96 ldr x4, =PHYS_OFFSET + 0xfff8
99 br x4 // branch to the given address
103 * UART initialisation (38400 8N1)
105 ldr x4, =UART_BASE // UART base
106 mov w5, #0x10 // ibrd
109 orr w5, w5, #0x0001 // cr
113 * CLCD output site MB
115 ldr x4, =SYSREGS_BASE
116 ldr w5, =(1 << 31) | (1 << 30) | (7 << 20) | (0 << 16) // START|WRITE|MUXFPGA|SITE_MB
117 str wzr, [x4, #0xa0] // V2M_SYS_CFGDATA
118 str w5, [x4, #0xa4] // V2M_SYS_CFGCTRL
120 // set up the arch timer frequency
127 ldr x0, =PHYS_OFFSET + 0x8000000 // device tree blob
128 ldr x6, =PHYS_OFFSET + 0x80000 // kernel start address