/* head-uc-fr401.S: FR401/3/5 uc-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/spr-regs.h>17#include <asm/mb86943a.h>18#include "head.inc"192021#define __400_DBR0 0xfe000e0022#define __400_DBR1 0xfe000e0823#define __400_DBR2 0xfe000e10 /* not on FR401 */24#define __400_DBR3 0xfe000e18 /* not on FR401 */25#define __400_DAM0 0xfe000f0026#define __400_DAM1 0xfe000f0827#define __400_DAM2 0xfe000f10 /* not on FR401 */28#define __400_DAM3 0xfe000f18 /* not on FR401 */29#define __400_LGCR 0xfe00001030#define __400_LCR 0xfe00010031#define __400_LSBR 0xfe000c003233__INIT34.balign 43536###############################################################################37#38# describe the position and layout of the SDRAM controller registers39#40# ENTRY: EXIT:41# GR5 - cacheline size42# GR11 - displacement of 2nd SDRAM addr reg from GR1443# GR12 - displacement of 3rd SDRAM addr reg from GR1444# GR13 - displacement of 4th SDRAM addr reg from GR1445# GR14 - address of 1st SDRAM addr reg46# GR15 - amount to shift address by to match SDRAM addr reg47# GR26 &__head_reference [saved]48# GR30 LED address [saved]49# CC0 - T if DBR0 is present50# CC1 - T if DBR1 is present51# CC2 - T if DBR2 is present (not FR401/FR401A)52# CC3 - T if DBR3 is present (not FR401/FR401A)53#54###############################################################################55.globl __head_fr401_describe_sdram56__head_fr401_describe_sdram:57sethi.p %hi(__400_DBR0),gr1458setlo %lo(__400_DBR0),gr1459setlos.p #__400_DBR1-__400_DBR0,gr1160setlos #__400_DBR2-__400_DBR0,gr1261setlos.p #__400_DBR3-__400_DBR0,gr1362setlos #32,gr5 ; cacheline size63setlos.p #0,gr15 ; amount to shift addr reg by6465# specify which DBR regs are present66setlos #0x00ff,gr467movgs gr4,cccr68movsg psr,gr3 ; check for FR401/FR401A69srli gr3,#25,gr370subicc gr3,#0x20>>1,gr0,icc071bnelr icc0,#172setlos #0x000f,gr473movgs gr4,cccr74bralr7576###############################################################################77#78# rearrange the bus controller registers79#80# ENTRY: EXIT:81# GR26 &__head_reference [saved]82# GR30 LED address revised LED address83#84###############################################################################85.globl __head_fr401_set_busctl86__head_fr401_set_busctl:87sethi.p %hi(__400_LGCR),gr488setlo %lo(__400_LGCR),gr489sethi.p %hi(__400_LSBR),gr1090setlo %lo(__400_LSBR),gr1091sethi.p %hi(__400_LCR),gr1192setlo %lo(__400_LCR),gr119394# set the bus controller95ldi @(gr4,#0),gr596ori gr5,#0xff,gr5 ; make sure all chip-selects are enabled97sti gr5,@(gr4,#0)9899sethi.p %hi(__region_CS1),gr4100setlo %lo(__region_CS1),gr4101sethi.p %hi(__region_CS1_M),gr5102setlo %lo(__region_CS1_M),gr5103sethi.p %hi(__region_CS1_C),gr6104setlo %lo(__region_CS1_C),gr6105sti gr4,@(gr10,#1*0x08)106sti gr5,@(gr10,#1*0x08+0x100)107sti gr6,@(gr11,#1*0x08)108sethi.p %hi(__region_CS2),gr4109setlo %lo(__region_CS2),gr4110sethi.p %hi(__region_CS2_M),gr5111setlo %lo(__region_CS2_M),gr5112sethi.p %hi(__region_CS2_C),gr6113setlo %lo(__region_CS2_C),gr6114sti gr4,@(gr10,#2*0x08)115sti gr5,@(gr10,#2*0x08+0x100)116sti gr6,@(gr11,#2*0x08)117sethi.p %hi(__region_CS3),gr4118setlo %lo(__region_CS3),gr4119sethi.p %hi(__region_CS3_M),gr5120setlo %lo(__region_CS3_M),gr5121sethi.p %hi(__region_CS3_C),gr6122setlo %lo(__region_CS3_C),gr6123sti gr4,@(gr10,#3*0x08)124sti gr5,@(gr10,#3*0x08+0x100)125sti gr6,@(gr11,#3*0x08)126sethi.p %hi(__region_CS4),gr4127setlo %lo(__region_CS4),gr4128sethi.p %hi(__region_CS4_M),gr5129setlo %lo(__region_CS4_M),gr5130sethi.p %hi(__region_CS4_C),gr6131setlo %lo(__region_CS4_C),gr6132sti gr4,@(gr10,#4*0x08)133sti gr5,@(gr10,#4*0x08+0x100)134sti gr6,@(gr11,#4*0x08)135sethi.p %hi(__region_CS5),gr4136setlo %lo(__region_CS5),gr4137sethi.p %hi(__region_CS5_M),gr5138setlo %lo(__region_CS5_M),gr5139sethi.p %hi(__region_CS5_C),gr6140setlo %lo(__region_CS5_C),gr6141sti gr4,@(gr10,#5*0x08)142sti gr5,@(gr10,#5*0x08+0x100)143sti gr6,@(gr11,#5*0x08)144sethi.p %hi(__region_CS6),gr4145setlo %lo(__region_CS6),gr4146sethi.p %hi(__region_CS6_M),gr5147setlo %lo(__region_CS6_M),gr5148sethi.p %hi(__region_CS6_C),gr6149setlo %lo(__region_CS6_C),gr6150sti gr4,@(gr10,#6*0x08)151sti gr5,@(gr10,#6*0x08+0x100)152sti gr6,@(gr11,#6*0x08)153sethi.p %hi(__region_CS7),gr4154setlo %lo(__region_CS7),gr4155sethi.p %hi(__region_CS7_M),gr5156setlo %lo(__region_CS7_M),gr5157sethi.p %hi(__region_CS7_C),gr6158setlo %lo(__region_CS7_C),gr6159sti gr4,@(gr10,#7*0x08)160sti gr5,@(gr10,#7*0x08+0x100)161sti gr6,@(gr11,#7*0x08)162membar163bar164165# adjust LED bank address166sethi.p %hi(LED_ADDR - 0x20000000 +__region_CS2),gr30167setlo %lo(LED_ADDR - 0x20000000 +__region_CS2),gr30168bralr169170###############################################################################171#172# determine the total SDRAM size173#174# ENTRY: EXIT:175# GR25 - SDRAM size176# GR26 &__head_reference [saved]177# GR30 LED address [saved]178#179###############################################################################180.globl __head_fr401_survey_sdram181__head_fr401_survey_sdram:182sethi.p %hi(__400_DAM0),gr11183setlo %lo(__400_DAM0),gr11184sethi.p %hi(__400_DBR0),gr12185setlo %lo(__400_DBR0),gr12186187sethi.p %hi(0xfe000000),gr17 ; unused SDRAM DBR value188setlo %lo(0xfe000000),gr17189setlos #0,gr25190191ldi @(gr12,#0x00),gr4 ; DAR0192subcc gr4,gr17,gr0,icc0193beq icc0,#0,__head_no_DCS0194ldi @(gr11,#0x00),gr6 ; DAM0: bits 31:20 match addr 31:20195add gr25,gr6,gr25196addi gr25,#1,gr25197__head_no_DCS0:198199ldi @(gr12,#0x08),gr4 ; DAR1200subcc gr4,gr17,gr0,icc0201beq icc0,#0,__head_no_DCS1202ldi @(gr11,#0x08),gr6 ; DAM1: bits 31:20 match addr 31:20203add gr25,gr6,gr25204addi gr25,#1,gr25205__head_no_DCS1:206207# FR401/FR401A does not have DCS2/3208movsg psr,gr3209srli gr3,#25,gr3210subicc gr3,#0x20>>1,gr0,icc0211beq icc0,#0,__head_no_DCS3212213ldi @(gr12,#0x10),gr4 ; DAR2214subcc gr4,gr17,gr0,icc0215beq icc0,#0,__head_no_DCS2216ldi @(gr11,#0x10),gr6 ; DAM2: bits 31:20 match addr 31:20217add gr25,gr6,gr25218addi gr25,#1,gr25219__head_no_DCS2:220221ldi @(gr12,#0x18),gr4 ; DAR3222subcc gr4,gr17,gr0,icc0223beq icc0,#0,__head_no_DCS3224ldi @(gr11,#0x18),gr6 ; DAM3: bits 31:20 match addr 31:20225add gr25,gr6,gr25226addi gr25,#1,gr25227__head_no_DCS3:228bralr229230###############################################################################231#232# set the protection map with the I/DAMPR registers233#234# ENTRY: EXIT:235# GR25 SDRAM size [saved]236# GR26 &__head_reference [saved]237# GR30 LED address [saved]238#239###############################################################################240.globl __head_fr401_set_protection241__head_fr401_set_protection:242movsg lr,gr27243244# set the I/O region protection registers for FR401/3/5245sethi.p %hi(__region_IO),gr5246setlo %lo(__region_IO),gr5247ori gr5,#xAMPRx_SS_512Mb|xAMPRx_S_KERNEL|xAMPRx_C|xAMPRx_V,gr5248movgs gr0,iampr7249movgs gr5,dampr7 ; General I/O tile250251# need to tile the remaining IAMPR/DAMPR registers to cover as much of the RAM as possible252# - start with the highest numbered registers253sethi.p %hi(__kernel_image_end),gr8254setlo %lo(__kernel_image_end),gr8255sethi.p %hi(32768),gr4 ; allow for a maximal allocator bitmap256setlo %lo(32768),gr4257add gr8,gr4,gr8258sethi.p %hi(1024*2048-1),gr4 ; round up to nearest 2MiB259setlo %lo(1024*2048-1),gr4260add.p gr8,gr4,gr8261not gr4,gr4262and gr8,gr4,gr8263264sethi.p %hi(__page_offset),gr9265setlo %lo(__page_offset),gr9266add gr9,gr25,gr9267268# GR8 = base of uncovered RAM269# GR9 = top of uncovered RAM270271#ifdef CONFIG_MB93093_PDK272sethi.p %hi(__region_CS2),gr4273setlo %lo(__region_CS2),gr4274ori gr4,#xAMPRx_SS_1Mb|xAMPRx_S_KERNEL|xAMPRx_C|xAMPRx_V,gr4275movgs gr4,dampr6276movgs gr0,iampr6277#else278call __head_split_region279movgs gr4,iampr6280movgs gr5,dampr6281#endif282call __head_split_region283movgs gr4,iampr5284movgs gr5,dampr5285call __head_split_region286movgs gr4,iampr4287movgs gr5,dampr4288call __head_split_region289movgs gr4,iampr3290movgs gr5,dampr3291call __head_split_region292movgs gr4,iampr2293movgs gr5,dampr2294call __head_split_region295movgs gr4,iampr1296movgs gr5,dampr1297298# cover kernel core image with kernel-only segment299sethi.p %hi(__page_offset),gr8300setlo %lo(__page_offset),gr8301call __head_split_region302303#ifdef CONFIG_PROTECT_KERNEL304ori.p gr4,#xAMPRx_S_KERNEL,gr4305ori gr5,#xAMPRx_S_KERNEL,gr5306#endif307308movgs gr4,iampr0309movgs gr5,dampr0310jmpl @(gr27,gr0)311312313