imx31lk_start.S revision 1.5
11.5Smatt/* $NetBSD: imx31lk_start.S,v 1.5 2014/03/30 23:12:26 matt Exp $ */ 21.4Smatt/*- 31.4Smatt * Copyright (c) 2011 The NetBSD Foundation, Inc. 41.4Smatt * All rights reserved. 51.4Smatt * 61.4Smatt * This code is derived from software contributed to The NetBSD Foundation 71.4Smatt * by Matt Thomas of 3am Software Foundry. 81.4Smatt * 91.4Smatt * Redistribution and use in source and binary forms, with or without 101.4Smatt * modification, are permitted provided that the following conditions 111.4Smatt * are met: 121.4Smatt * 1. Redistributions of source code must retain the above copyright 131.4Smatt * notice, this list of conditions and the following disclaimer. 141.4Smatt * 2. Redistributions in binary form must reproduce the above copyright 151.4Smatt * notice, this list of conditions and the following disclaimer in the 161.4Smatt * documentation and/or other materials provided with the distribution. 171.4Smatt * 181.4Smatt * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 191.4Smatt * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 201.4Smatt * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 211.4Smatt * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 221.4Smatt * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 231.4Smatt * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 241.4Smatt * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 251.4Smatt * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 261.4Smatt * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 271.4Smatt * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 281.4Smatt * POSSIBILITY OF SUCH DAMAGE. 291.4Smatt */ 301.2Smatt 311.2Smatt#include <machine/asm.h> 321.2Smatt#include <arm/armreg.h> 331.4Smatt#include "assym.h" 341.2Smatt 351.5SmattRCSID("$NetBSD: imx31lk_start.S,v 1.5 2014/03/30 23:12:26 matt Exp $") 361.2Smatt 371.2Smatt#ifndef SDRAM_START 381.2Smatt#define SDRAM_START 0x80000000 391.2Smatt#endif 401.2Smatt 411.3Suebayasi/* 421.3Suebayasi * L1 == "Level One" == "first-level" 431.3Suebayasi * L2 == "Level Two" == "second-level" 441.3Suebayasi */ 451.2Smatt 461.2Smatt .text 471.2Smatt 481.2Smatt .global _C_LABEL(imx31lk_start) 491.2Smatt_C_LABEL(imx31lk_start): 501.5Smatt cpsid if, #PSR_SVC32_MODE 511.2Smatt 521.2Smatt /* 531.2Smatt * Firmware already mapped SDRAM VA == PA. at 0x800.. 541.2Smatt * now map SDRAM also at VA 0x800... 551.2Smatt */ 561.3Suebayasi mrc p15, 0, r0, c2, c0, 0 /* L1 table addr into r0 */ 571.5Smatt#ifdef ARM_MMU_EXTENDED 581.5Smatt mcr p15, 0, r0, c2, c0, 1 /* copy it to TTBR1 */ 591.5Smatt mov r3, #TTBCR_S_N_1 601.5Smatt mcr p15, 0, r3, c2, c0, 2 /* set TTBCR to enable TTBR1 */ 611.5Smatt#endif 621.2Smatt 631.5Smatt mov r1, #(KERNEL_BASE_EXT >> L1_S_SHIFT) 641.5Smatt add r2, r1, #0x80 /* 128 1MB entries */ 651.5Smatt ldr r3, .Lsdram_pde 661.2Smatt1: 671.2Smatt /* and looplooploop */ 681.5Smatt str r3, [r0, r1, lsl #2] 691.5Smatt add r3, r3, #L1_S_SIZE 701.5Smatt add r1, r1, #1 711.5Smatt cmp r1, r2 721.5Smatt blt 1b 731.2Smatt 741.2Smatt /* 751.2Smatt * Map an L1 section for each device to make this easy. 761.2Smatt */ 771.2Smatt /* UART1 */ 781.5Smatt mov r1, #0xfd0 /* offset to 0xfd000000 */ 791.2Smatt 801.5Smatt ldr r3, .Lio_pde 811.5Smatt str r3, [r0, r1, lsl #2] 821.2Smatt 831.2Smatt /* etc, TBD... */ 841.2Smatt 851.2Smatt /* 861.2Smatt * Make domain control go full art. 871.2Smatt */ 881.5Smatt mov r0, #((DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL * 2))|DOMAIN_CLIENT) 891.2Smatt mcr p15, 0, r0, c3, c0, 0 901.2Smatt 911.2Smatt /* 921.5Smatt * Now let's clean the cache again to make sure everything is in place. 931.2Smatt */ 941.5Smatt bl _C_LABEL(arm11x6_idcache_wbinv_all) 951.2Smatt 961.2Smatt /* Invalidate TLBs just to be sure */ 971.5Smatt mov r0, #0 981.2Smatt mcr p15, 0, r0, c8, c7, 0 991.2Smatt 1001.2Smatt /* 1011.2Smatt * You are standing at the gate to NetBSD. --More-- 1021.2Smatt * Unspeakable cruelty and harm lurk down there. --More-- 1031.2Smatt * Are you sure you want to enter? 1041.2Smatt */ 1051.5Smatt#ifdef KERNEL_BASES_EQUAL 1061.5Smatt b start 1071.5Smatt#else 1081.5Smatt adr r0, .Lstart 1091.5Smatt ldr ip, [r0] 1101.5Smatt bx ip 1111.5Smatt#endif 1121.2Smatt 1131.2Smatt/* symbol to use for address calculation in the right VA */ 1141.5Smatt#ifndef KERNEL_BASES_EQUAL 1151.2Smatt.Lstart: 1161.2Smatt .word start 1171.5Smatt#endif 1181.2Smatt 1191.5Smatt#if L1_S_DOM_KERNEL 1201.5Smatt#error kernel domain (L1_S_DOM_KERNEL) is not 0 1211.5Smatt#endif 1221.2Smatt 1231.5Smatt.Lsdram_pde: 1241.5Smatt .word 0x80000000|L1_S_AP_KRW|L1_S_C|L1_S_B|L1_TYPE_S 1251.5Smatt.Lio_pde: 1261.5Smatt .word 0x43f00000|L1_S_AP_KRW|L1_TYPE_S 1271.5SmattEND(imx31lk_start) 128