Path: blob/master/arch/frv/kernel/head-mmu-fr451.S
10817 views
/* head-mmu-fr451.S: FR451 mmu-linux specific bits of initialisation1*2* Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.3* Written by David Howells ([email protected])4*5* This program is free software; you can redistribute it and/or6* modify it under the terms of the GNU General Public License7* as published by the Free Software Foundation; either version8* 2 of the License, or (at your option) any later version.9*/1011#include <linux/init.h>12#include <linux/threads.h>13#include <linux/linkage.h>14#include <asm/ptrace.h>15#include <asm/page.h>16#include <asm/mem-layout.h>17#include <asm/spr-regs.h>18#include <asm/mb86943a.h>19#include "head.inc"202122#define __400_DBR0 0xfe000e0023#define __400_DBR1 0xfe000e0824#define __400_DBR2 0xfe000e1025#define __400_DBR3 0xfe000e1826#define __400_DAM0 0xfe000f0027#define __400_DAM1 0xfe000f0828#define __400_DAM2 0xfe000f1029#define __400_DAM3 0xfe000f1830#define __400_LGCR 0xfe00001031#define __400_LCR 0xfe00010032#define __400_LSBR 0xfe000c003334__INIT35.balign 43637###############################################################################38#39# describe the position and layout of the SDRAM controller registers40#41# ENTRY: EXIT:42# GR5 - cacheline size43# GR11 - displacement of 2nd SDRAM addr reg from GR1444# GR12 - displacement of 3rd SDRAM addr reg from GR1445# GR13 - displacement of 4th SDRAM addr reg from GR1446# GR14 - address of 1st SDRAM addr reg47# GR15 - amount to shift address by to match SDRAM addr reg48# GR26 &__head_reference [saved]49# GR30 LED address [saved]50# CC0 - T if DBR0 is present51# CC1 - T if DBR1 is present52# CC2 - T if DBR2 is present53# CC3 - T if DBR3 is present54#55###############################################################################56.globl __head_fr451_describe_sdram57__head_fr451_describe_sdram:58sethi.p %hi(__400_DBR0),gr1459setlo %lo(__400_DBR0),gr1460setlos.p #__400_DBR1-__400_DBR0,gr1161setlos #__400_DBR2-__400_DBR0,gr1262setlos.p #__400_DBR3-__400_DBR0,gr1363setlos #32,gr5 ; cacheline size64setlos.p #0,gr15 ; amount to shift addr reg by65setlos #0x00ff,gr466movgs gr4,cccr ; extant DARS/DAMK regs67bralr6869###############################################################################70#71# rearrange the bus controller registers72#73# ENTRY: EXIT:74# GR26 &__head_reference [saved]75# GR30 LED address revised LED address76#77###############################################################################78.globl __head_fr451_set_busctl79__head_fr451_set_busctl:80sethi.p %hi(__400_LGCR),gr481setlo %lo(__400_LGCR),gr482sethi.p %hi(__400_LSBR),gr1083setlo %lo(__400_LSBR),gr1084sethi.p %hi(__400_LCR),gr1185setlo %lo(__400_LCR),gr118687# set the bus controller88ldi @(gr4,#0),gr589ori gr5,#0xff,gr5 ; make sure all chip-selects are enabled90sti gr5,@(gr4,#0)9192sethi.p %hi(__region_CS1),gr493setlo %lo(__region_CS1),gr494sethi.p %hi(__region_CS1_M),gr595setlo %lo(__region_CS1_M),gr596sethi.p %hi(__region_CS1_C),gr697setlo %lo(__region_CS1_C),gr698sti gr4,@(gr10,#1*0x08)99sti gr5,@(gr10,#1*0x08+0x100)100sti gr6,@(gr11,#1*0x08)101sethi.p %hi(__region_CS2),gr4102setlo %lo(__region_CS2),gr4103sethi.p %hi(__region_CS2_M),gr5104setlo %lo(__region_CS2_M),gr5105sethi.p %hi(__region_CS2_C),gr6106setlo %lo(__region_CS2_C),gr6107sti gr4,@(gr10,#2*0x08)108sti gr5,@(gr10,#2*0x08+0x100)109sti gr6,@(gr11,#2*0x08)110sethi.p %hi(__region_CS3),gr4111setlo %lo(__region_CS3),gr4112sethi.p %hi(__region_CS3_M),gr5113setlo %lo(__region_CS3_M),gr5114sethi.p %hi(__region_CS3_C),gr6115setlo %lo(__region_CS3_C),gr6116sti gr4,@(gr10,#3*0x08)117sti gr5,@(gr10,#3*0x08+0x100)118sti gr6,@(gr11,#3*0x08)119sethi.p %hi(__region_CS4),gr4120setlo %lo(__region_CS4),gr4121sethi.p %hi(__region_CS4_M),gr5122setlo %lo(__region_CS4_M),gr5123sethi.p %hi(__region_CS4_C),gr6124setlo %lo(__region_CS4_C),gr6125sti gr4,@(gr10,#4*0x08)126sti gr5,@(gr10,#4*0x08+0x100)127sti gr6,@(gr11,#4*0x08)128sethi.p %hi(__region_CS5),gr4129setlo %lo(__region_CS5),gr4130sethi.p %hi(__region_CS5_M),gr5131setlo %lo(__region_CS5_M),gr5132sethi.p %hi(__region_CS5_C),gr6133setlo %lo(__region_CS5_C),gr6134sti gr4,@(gr10,#5*0x08)135sti gr5,@(gr10,#5*0x08+0x100)136sti gr6,@(gr11,#5*0x08)137sethi.p %hi(__region_CS6),gr4138setlo %lo(__region_CS6),gr4139sethi.p %hi(__region_CS6_M),gr5140setlo %lo(__region_CS6_M),gr5141sethi.p %hi(__region_CS6_C),gr6142setlo %lo(__region_CS6_C),gr6143sti gr4,@(gr10,#6*0x08)144sti gr5,@(gr10,#6*0x08+0x100)145sti gr6,@(gr11,#6*0x08)146sethi.p %hi(__region_CS7),gr4147setlo %lo(__region_CS7),gr4148sethi.p %hi(__region_CS7_M),gr5149setlo %lo(__region_CS7_M),gr5150sethi.p %hi(__region_CS7_C),gr6151setlo %lo(__region_CS7_C),gr6152sti gr4,@(gr10,#7*0x08)153sti gr5,@(gr10,#7*0x08+0x100)154sti gr6,@(gr11,#7*0x08)155membar156bar157158# adjust LED bank address159#ifdef CONFIG_MB93091_VDK160sethi.p %hi(__region_CS2 + 0x01200004),gr30161setlo %lo(__region_CS2 + 0x01200004),gr30162#endif163bralr164165###############################################################################166#167# determine the total SDRAM size168#169# ENTRY: EXIT:170# GR25 - SDRAM size171# GR26 &__head_reference [saved]172# GR30 LED address [saved]173#174###############################################################################175.globl __head_fr451_survey_sdram176__head_fr451_survey_sdram:177sethi.p %hi(__400_DAM0),gr11178setlo %lo(__400_DAM0),gr11179sethi.p %hi(__400_DBR0),gr12180setlo %lo(__400_DBR0),gr12181182sethi.p %hi(0xfe000000),gr17 ; unused SDRAM DBR value183setlo %lo(0xfe000000),gr17184setlos #0,gr25185186ldi @(gr12,#0x00),gr4 ; DAR0187subcc gr4,gr17,gr0,icc0188beq icc0,#0,__head_no_DCS0189ldi @(gr11,#0x00),gr6 ; DAM0: bits 31:20 match addr 31:20190add gr25,gr6,gr25191addi gr25,#1,gr25192__head_no_DCS0:193194ldi @(gr12,#0x08),gr4 ; DAR1195subcc gr4,gr17,gr0,icc0196beq icc0,#0,__head_no_DCS1197ldi @(gr11,#0x08),gr6 ; DAM1: bits 31:20 match addr 31:20198add gr25,gr6,gr25199addi gr25,#1,gr25200__head_no_DCS1:201202ldi @(gr12,#0x10),gr4 ; DAR2203subcc gr4,gr17,gr0,icc0204beq icc0,#0,__head_no_DCS2205ldi @(gr11,#0x10),gr6 ; DAM2: bits 31:20 match addr 31:20206add gr25,gr6,gr25207addi gr25,#1,gr25208__head_no_DCS2:209210ldi @(gr12,#0x18),gr4 ; DAR3211subcc gr4,gr17,gr0,icc0212beq icc0,#0,__head_no_DCS3213ldi @(gr11,#0x18),gr6 ; DAM3: bits 31:20 match addr 31:20214add gr25,gr6,gr25215addi gr25,#1,gr25216__head_no_DCS3:217bralr218219###############################################################################220#221# set the protection map with the I/DAMPR registers222#223# ENTRY: EXIT:224# GR25 SDRAM size [saved]225# GR26 &__head_reference [saved]226# GR30 LED address [saved]227#228#229# Using this map:230# REGISTERS ADDRESS RANGE VIEW231# =============== ====================== ===============================232# IAMPR0/DAMPR0 0xC0000000-0xCFFFFFFF Cached kernel RAM Window233# DAMPR11 0xE0000000-0xFFFFFFFF Uncached I/O234#235###############################################################################236.globl __head_fr451_set_protection237__head_fr451_set_protection:238movsg lr,gr27239240# set the I/O region protection registers for FR451 in MMU mode241#define PGPROT_IO xAMPRx_L|xAMPRx_M|xAMPRx_S_KERNEL|xAMPRx_C|xAMPRx_V242243sethi.p %hi(__region_IO),gr5244setlo %lo(__region_IO),gr5245setlos #PGPROT_IO|xAMPRx_SS_512Mb,gr4246or gr4,gr5,gr4247movgs gr5,damlr11 ; General I/O tile248movgs gr4,dampr11249250# need to open a window onto at least part of the RAM for the kernel's use251sethi.p %hi(__sdram_base),gr8252setlo %lo(__sdram_base),gr8 ; physical address253sethi.p %hi(__page_offset),gr9254setlo %lo(__page_offset),gr9 ; virtual address255256setlos #xAMPRx_L|xAMPRx_M|xAMPRx_SS_256Mb|xAMPRx_S_KERNEL|xAMPRx_V,gr11257or gr8,gr11,gr8258259movgs gr9,iamlr0 ; mapped from real address 0260movgs gr8,iampr0 ; cached kernel memory at 0xC0000000261movgs gr9,damlr0262movgs gr8,dampr0263264# set a temporary mapping for the kernel running at address 0 until we've turned on the MMU265sethi.p %hi(__sdram_base),gr9266setlo %lo(__sdram_base),gr9 ; virtual address267268and.p gr4,gr11,gr4269and gr5,gr11,gr5270or.p gr4,gr11,gr4271or gr5,gr11,gr5272273movgs gr9,iamlr1 ; mapped from real address 0274movgs gr8,iampr1 ; cached kernel memory at 0x00000000275movgs gr9,damlr1276movgs gr8,dampr1277278# we use DAMR2-10 for kmap_atomic(), cache flush and TLB management279# since the DAMLR regs are not going to change, we can set them now280# also set up IAMLR2 to the same as DAMLR5281sethi.p %hi(KMAP_ATOMIC_PRIMARY_FRAME),gr4282setlo %lo(KMAP_ATOMIC_PRIMARY_FRAME),gr4283sethi.p %hi(PAGE_SIZE),gr5284setlo %lo(PAGE_SIZE),gr5285286movgs gr4,damlr2287movgs gr4,iamlr2288add gr4,gr5,gr4289movgs gr4,damlr3290add gr4,gr5,gr4291movgs gr4,damlr4292add gr4,gr5,gr4293movgs gr4,damlr5294add gr4,gr5,gr4295movgs gr4,damlr6296add gr4,gr5,gr4297movgs gr4,damlr7298add gr4,gr5,gr4299movgs gr4,damlr8300add gr4,gr5,gr4301movgs gr4,damlr9302add gr4,gr5,gr4303movgs gr4,damlr10304305movgs gr0,dampr2306movgs gr0,dampr4307movgs gr0,dampr5308movgs gr0,dampr6309movgs gr0,dampr7310movgs gr0,dampr8311movgs gr0,dampr9312movgs gr0,dampr10313314movgs gr0,iamlr3315movgs gr0,iamlr4316movgs gr0,iamlr5317movgs gr0,iamlr6318movgs gr0,iamlr7319320movgs gr0,iampr2321movgs gr0,iampr3322movgs gr0,iampr4323movgs gr0,iampr5324movgs gr0,iampr6325movgs gr0,iampr7326327# start in TLB context 0 with the swapper's page tables328movgs gr0,cxnr329330sethi.p %hi(swapper_pg_dir),gr4331setlo %lo(swapper_pg_dir),gr4332sethi.p %hi(__page_offset),gr5333setlo %lo(__page_offset),gr5334sub gr4,gr5,gr4335movgs gr4,ttbr336setlos #xAMPRx_L|xAMPRx_M|xAMPRx_SS_16Kb|xAMPRx_S|xAMPRx_C|xAMPRx_V,gr5337or gr4,gr5,gr4338movgs gr4,dampr3339340# the FR451 also has an extra trap base register341movsg tbr,gr4342movgs gr4,btbr343344LEDS 0x3300345jmpl @(gr27,gr0)346347###############################################################################348#349# finish setting up the protection registers350#351###############################################################################352.globl __head_fr451_finalise_protection353__head_fr451_finalise_protection:354# turn on the timers as appropriate355movgs gr0,timerh356movgs gr0,timerl357movgs gr0,timerd358movsg hsr0,gr4359sethi.p %hi(HSR0_ETMI),gr5360setlo %lo(HSR0_ETMI),gr5361or gr4,gr5,gr4362movgs gr4,hsr0363364# clear the TLB entry cache365movgs gr0,iamlr1366movgs gr0,iampr1367movgs gr0,damlr1368movgs gr0,dampr1369370# clear the PGE cache371sethi.p %hi(__flush_tlb_all),gr4372setlo %lo(__flush_tlb_all),gr4373jmpl @(gr4,gr0)374375376