1/* $NetBSD: imx31lk_start.S,v 1.5 2014/03/30 23:12:26 matt Exp $ */ 2/*- 3 * Copyright (c) 2011 The NetBSD Foundation, Inc. 4 * All rights reserved. 5 * 6 * This code is derived from software contributed to The NetBSD Foundation 7 * by Matt Thomas of 3am Software Foundry. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31#include <machine/asm.h> 32#include <arm/armreg.h> 33#include "assym.h" 34 35RCSID("$NetBSD: imx31lk_start.S,v 1.5 2014/03/30 23:12:26 matt Exp $") 36 37#ifndef SDRAM_START 38#define SDRAM_START 0x80000000 39#endif 40 41/* 42 * L1 == "Level One" == "first-level" 43 * L2 == "Level Two" == "second-level" 44 */ 45 46 .text 47 48 .global _C_LABEL(imx31lk_start) 49_C_LABEL(imx31lk_start): 50 cpsid if, #PSR_SVC32_MODE 51 52 /* 53 * Firmware already mapped SDRAM VA == PA. at 0x800.. 54 * now map SDRAM also at VA 0x800... 55 */ 56 mrc p15, 0, r0, c2, c0, 0 /* L1 table addr into r0 */ 57#ifdef ARM_MMU_EXTENDED 58 mcr p15, 0, r0, c2, c0, 1 /* copy it to TTBR1 */ 59 mov r3, #TTBCR_S_N_1 60 mcr p15, 0, r3, c2, c0, 2 /* set TTBCR to enable TTBR1 */ 61#endif 62 63 mov r1, #(KERNEL_BASE_EXT >> L1_S_SHIFT) 64 add r2, r1, #0x80 /* 128 1MB entries */ 65 ldr r3, .Lsdram_pde 661: 67 /* and looplooploop */ 68 str r3, [r0, r1, lsl #2] 69 add r3, r3, #L1_S_SIZE 70 add r1, r1, #1 71 cmp r1, r2 72 blt 1b 73 74 /* 75 * Map an L1 section for each device to make this easy. 76 */ 77 /* UART1 */ 78 mov r1, #0xfd0 /* offset to 0xfd000000 */ 79 80 ldr r3, .Lio_pde 81 str r3, [r0, r1, lsl #2] 82 83 /* etc, TBD... */ 84 85 /* 86 * Make domain control go full art. 87 */ 88 mov r0, #((DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL * 2))|DOMAIN_CLIENT) 89 mcr p15, 0, r0, c3, c0, 0 90 91 /* 92 * Now let's clean the cache again to make sure everything is in place. 93 */ 94 bl _C_LABEL(arm11x6_idcache_wbinv_all) 95 96 /* Invalidate TLBs just to be sure */ 97 mov r0, #0 98 mcr p15, 0, r0, c8, c7, 0 99 100 /* 101 * You are standing at the gate to NetBSD. --More-- 102 * Unspeakable cruelty and harm lurk down there. --More-- 103 * Are you sure you want to enter? 104 */ 105#ifdef KERNEL_BASES_EQUAL 106 b start 107#else 108 adr r0, .Lstart 109 ldr ip, [r0] 110 bx ip 111#endif 112 113/* symbol to use for address calculation in the right VA */ 114#ifndef KERNEL_BASES_EQUAL 115.Lstart: 116 .word start 117#endif 118 119#if L1_S_DOM_KERNEL 120#error kernel domain (L1_S_DOM_KERNEL) is not 0 121#endif 122 123.Lsdram_pde: 124 .word 0x80000000|L1_S_AP_KRW|L1_S_C|L1_S_B|L1_TYPE_S 125.Lio_pde: 126 .word 0x43f00000|L1_S_AP_KRW|L1_TYPE_S 127END(imx31lk_start) 128