2005-04-16 15:20:36 -07:00
/ * head- u c - f r55 5 . S : F R 5 5 5 u c - l i n u x s p e c i f i c b i t s o f i n i t i a l i s a t i o n
*
* Copyright ( C ) 2 0 0 4 R e d H a t , I n c . A l l R i g h t s R e s e r v e d .
* Written b y D a v i d H o w e l l s ( d h o w e l l s @redhat.com)
*
* This p r o g r a m i s f r e e s o f t w a r e ; you can redistribute it and/or
* modify i t u n d e r t h e t e r m s o f t h e G N U G e n e r a l P u b l i c L i c e n s e
* as p u b l i s h e d b y t h e F r e e S o f t w a r e F o u n d a t i o n ; either version
* 2 of t h e L i c e n s e , o r ( a t y o u r o p t i o n ) a n y l a t e r v e r s i o n .
* /
2009-04-28 00:37:58 +01:00
# include < l i n u x / i n i t . h >
2005-04-16 15:20:36 -07:00
# include < l i n u x / t h r e a d s . h >
# include < l i n u x / l i n k a g e . h >
# include < a s m / p t r a c e . h >
# include < a s m / p a g e . h >
# include < a s m / s p r - r e g s . h >
# include < a s m / m b86 9 4 3 a . h >
# include " h e a d . i n c "
# define _ _ 5 5 1 _ D A R S 0 0 x f e f f01 0 0
# define _ _ 5 5 1 _ D A R S 1 0 x f e f f01 0 4
# define _ _ 5 5 1 _ D A R S 2 0 x f e f f01 0 8
# define _ _ 5 5 1 _ D A R S 3 0 x f e f f01 0 c
# define _ _ 5 5 1 _ D A M K 0 0 x f e f f01 1 0
# define _ _ 5 5 1 _ D A M K 1 0 x f e f f01 1 4
# define _ _ 5 5 1 _ D A M K 2 0 x f e f f01 1 8
# define _ _ 5 5 1 _ D A M K 3 0 x f e f f01 1 c
# define _ _ 5 5 1 _ L C R 0 x f e f f11 0 0
# define _ _ 5 5 1 _ L S B R 0 x f e f f1 c00
2009-04-28 00:37:58 +01:00
_ _ INIT
2005-04-16 15:20:36 -07:00
.balign 4
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# describe t h e p o s i t i o n a n d l a y o u t o f t h e S D R A M c o n t r o l l e r r e g i s t e r s
#
# ENTRY : EXIT :
# GR5 - c a c h e l i n e s i z e
# GR1 1 - d i s p l a c e m e n t o f 2 n d S D R A M a d d r r e g f r o m G R 1 4
# GR1 2 - d i s p l a c e m e n t o f 3 r d S D R A M a d d r r e g f r o m G R 1 4
# GR1 3 - d i s p l a c e m e n t o f 4 t h S D R A M a d d r r e g f r o m G R 1 4
# GR1 4 - a d d r e s s o f 1 s t S D R A M a d d r r e g
# GR1 5 - a m o u n t t o s h i f t a d d r e s s b y t o m a t c h S D R A M a d d r r e g
# GR2 6 & _ _ h e a d _ r e f e r e n c e [ s a v e d ]
# GR3 0 L E D a d d r e s s [ s a v e d ]
# CC0 - T i f D A R S 0 i s p r e s e n t
# CC1 - T i f D A R S 1 i s p r e s e n t
# CC2 - T i f D A R S 2 i s p r e s e n t
# CC3 - T i f D A R S 3 i s p r e s e n t
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
.globl __head_fr555_describe_sdram
__head_fr555_describe_sdram :
sethi. p % h i ( _ _ 5 5 1 _ D A R S 0 ) ,g r14
setlo % l o ( _ _ 5 5 1 _ D A R S 0 ) ,g r14
setlos. p #_ _ 551 _ D A R S 1 - _ _ 5 5 1 _ D A R S 0 ,g r11
setlos #_ _ 551 _ D A R S 2 - _ _ 5 5 1 _ D A R S 0 ,g r12
setlos. p #_ _ 551 _ D A R S 3 - _ _ 5 5 1 _ D A R S 0 ,g r13
setlos #64 ,g r5 ; cacheline size
setlos #20 ,g r15 ; amount to shift addr by
setlos #0x00ff ,g r4
movgs g r4 ,c c c r ; extant DARS/DAMK regs
bralr
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# rearrange t h e b u s c o n t r o l l e r r e g i s t e r s
#
# ENTRY : EXIT :
# GR2 6 & _ _ h e a d _ r e f e r e n c e [ s a v e d ]
# GR3 0 L E D a d d r e s s r e v i s e d L E D a d d r e s s
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
.globl __head_fr555_set_busctl
__head_fr555_set_busctl :
LEDS 0 x10 0 f
sethi. p % h i ( _ _ 5 5 1 _ L S B R ) ,g r10
setlo % l o ( _ _ 5 5 1 _ L S B R ) ,g r10
sethi. p % h i ( _ _ 5 5 1 _ L C R ) ,g r11
setlo % l o ( _ _ 5 5 1 _ L C R ) ,g r11
# set t h e b u s c o n t r o l l e r
sethi. p % h i ( _ _ r e g i o n _ C S 1 ) ,g r4
setlo % l o ( _ _ r e g i o n _ C S 1 ) ,g r4
sethi. p % h i ( _ _ r e g i o n _ C S 1 _ M ) ,g r5
setlo % l o ( _ _ r e g i o n _ C S 1 _ M ) ,g r5
sethi. p % h i ( _ _ r e g i o n _ C S 1 _ C ) ,g r6
setlo % l o ( _ _ r e g i o n _ C S 1 _ C ) ,g r6
sti g r4 ,@(gr10,#1*0x08)
sti g r5 ,@(gr10,#1*0x08+0x100)
sti g r6 ,@(gr11,#1*0x08)
sethi. p % h i ( _ _ r e g i o n _ C S 2 ) ,g r4
setlo % l o ( _ _ r e g i o n _ C S 2 ) ,g r4
sethi. p % h i ( _ _ r e g i o n _ C S 2 _ M ) ,g r5
setlo % l o ( _ _ r e g i o n _ C S 2 _ M ) ,g r5
sethi. p % h i ( _ _ r e g i o n _ C S 2 _ C ) ,g r6
setlo % l o ( _ _ r e g i o n _ C S 2 _ C ) ,g r6
sti g r4 ,@(gr10,#2*0x08)
sti g r5 ,@(gr10,#2*0x08+0x100)
sti g r6 ,@(gr11,#2*0x08)
sethi. p % h i ( _ _ r e g i o n _ C S 3 ) ,g r4
setlo % l o ( _ _ r e g i o n _ C S 3 ) ,g r4
sethi. p % h i ( _ _ r e g i o n _ C S 3 _ M ) ,g r5
setlo % l o ( _ _ r e g i o n _ C S 3 _ M ) ,g r5
sethi. p % h i ( _ _ r e g i o n _ C S 3 _ C ) ,g r6
setlo % l o ( _ _ r e g i o n _ C S 3 _ C ) ,g r6
sti g r4 ,@(gr10,#3*0x08)
sti g r5 ,@(gr10,#3*0x08+0x100)
sti g r6 ,@(gr11,#3*0x08)
sethi. p % h i ( _ _ r e g i o n _ C S 4 ) ,g r4
setlo % l o ( _ _ r e g i o n _ C S 4 ) ,g r4
sethi. p % h i ( _ _ r e g i o n _ C S 4 _ M ) ,g r5
setlo % l o ( _ _ r e g i o n _ C S 4 _ M ) ,g r5
sethi. p % h i ( _ _ r e g i o n _ C S 4 _ C ) ,g r6
setlo % l o ( _ _ r e g i o n _ C S 4 _ C ) ,g r6
sti g r4 ,@(gr10,#4*0x08)
sti g r5 ,@(gr10,#4*0x08+0x100)
sti g r6 ,@(gr11,#4*0x08)
sethi. p % h i ( _ _ r e g i o n _ C S 5 ) ,g r4
setlo % l o ( _ _ r e g i o n _ C S 5 ) ,g r4
sethi. p % h i ( _ _ r e g i o n _ C S 5 _ M ) ,g r5
setlo % l o ( _ _ r e g i o n _ C S 5 _ M ) ,g r5
sethi. p % h i ( _ _ r e g i o n _ C S 5 _ C ) ,g r6
setlo % l o ( _ _ r e g i o n _ C S 5 _ C ) ,g r6
sti g r4 ,@(gr10,#5*0x08)
sti g r5 ,@(gr10,#5*0x08+0x100)
sti g r6 ,@(gr11,#5*0x08)
sethi. p % h i ( _ _ r e g i o n _ C S 6 ) ,g r4
setlo % l o ( _ _ r e g i o n _ C S 6 ) ,g r4
sethi. p % h i ( _ _ r e g i o n _ C S 6 _ M ) ,g r5
setlo % l o ( _ _ r e g i o n _ C S 6 _ M ) ,g r5
sethi. p % h i ( _ _ r e g i o n _ C S 6 _ C ) ,g r6
setlo % l o ( _ _ r e g i o n _ C S 6 _ C ) ,g r6
sti g r4 ,@(gr10,#6*0x08)
sti g r5 ,@(gr10,#6*0x08+0x100)
sti g r6 ,@(gr11,#6*0x08)
sethi. p % h i ( _ _ r e g i o n _ C S 7 ) ,g r4
setlo % l o ( _ _ r e g i o n _ C S 7 ) ,g r4
sethi. p % h i ( _ _ r e g i o n _ C S 7 _ M ) ,g r5
setlo % l o ( _ _ r e g i o n _ C S 7 _ M ) ,g r5
sethi. p % h i ( _ _ r e g i o n _ C S 7 _ C ) ,g r6
setlo % l o ( _ _ r e g i o n _ C S 7 _ C ) ,g r6
sti g r4 ,@(gr10,#7*0x08)
sti g r5 ,@(gr10,#7*0x08+0x100)
sti g r6 ,@(gr11,#7*0x08)
membar
bar
# adjust L E D b a n k a d d r e s s
# ifdef C O N F I G _ M B 9 3 0 9 1 _ V D K
sethi. p % h i ( L E D _ A D D R - 0 x20 0 0 0 0 0 0 + _ _ r e g i o n _ C S 2 ) ,g r30
setlo % l o ( L E D _ A D D R - 0 x20 0 0 0 0 0 0 + _ _ r e g i o n _ C S 2 ) ,g r30
# endif
bralr
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# determine t h e t o t a l S D R A M s i z e
#
# ENTRY : EXIT :
# GR2 5 - S D R A M s i z e
# GR2 6 & _ _ h e a d _ r e f e r e n c e [ s a v e d ]
# GR3 0 L E D a d d r e s s [ s a v e d ]
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
.globl __head_fr555_survey_sdram
__head_fr555_survey_sdram :
sethi. p % h i ( _ _ 5 5 1 _ D A M K 0 ) ,g r11
setlo % l o ( _ _ 5 5 1 _ D A M K 0 ) ,g r11
sethi. p % h i ( _ _ 5 5 1 _ D A R S 0 ) ,g r12
setlo % l o ( _ _ 5 5 1 _ D A R S 0 ) ,g r12
sethi. p % h i ( 0 x f f f ) ,g r17 ; unused SDRAM AMK value
setlo % l o ( 0 x f f f ) ,g r17
setlos #0 ,g r25
ldi @(gr11,#0x00),gr6 ; DAMK0: bits 11:0 match addr 11:0
subcc g r6 ,g r17 ,g r0 ,i c c0
beq i c c0 ,#0 ,_ _ h e a d _ n o _ D C S 0
ldi @(gr12,#0x00),gr4 ; DARS0
add g r25 ,g r6 ,g r25
addi g r25 ,#1 ,g r25
__head_no_DCS0 :
ldi @(gr11,#0x04),gr6 ; DAMK1: bits 11:0 match addr 11:0
subcc g r6 ,g r17 ,g r0 ,i c c0
beq i c c0 ,#0 ,_ _ h e a d _ n o _ D C S 1
ldi @(gr12,#0x04),gr4 ; DARS1
add g r25 ,g r6 ,g r25
addi g r25 ,#1 ,g r25
__head_no_DCS1 :
ldi @(gr11,#0x8),gr6 ; DAMK2: bits 11:0 match addr 11:0
subcc g r6 ,g r17 ,g r0 ,i c c0
beq i c c0 ,#0 ,_ _ h e a d _ n o _ D C S 2
ldi @(gr12,#0x8),gr4 ; DARS2
add g r25 ,g r6 ,g r25
addi g r25 ,#1 ,g r25
__head_no_DCS2 :
ldi @(gr11,#0xc),gr6 ; DAMK3: bits 11:0 match addr 11:0
subcc g r6 ,g r17 ,g r0 ,i c c0
beq i c c0 ,#0 ,_ _ h e a d _ n o _ D C S 3
ldi @(gr12,#0xc),gr4 ; DARS3
add g r25 ,g r6 ,g r25
addi g r25 ,#1 ,g r25
__head_no_DCS3 :
slli g r25 ,#20 ,g r25 ; shift [11:0] -> [31:20]
bralr
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# set t h e p r o t e c t i o n m a p w i t h t h e I / D A M P R r e g i s t e r s
#
# ENTRY : EXIT :
# GR2 5 S D R A M s i z e s a v e d
# GR3 0 L E D a d d r e s s s a v e d
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
.globl __head_fr555_set_protection
__head_fr555_set_protection :
movsg l r ,g r27
sethi. p % h i ( 0 x f f f00 0 0 0 ) ,g r11
setlo % l o ( 0 x f f f00 0 0 0 ) ,g r11
# set t h e I / O r e g i o n p r o t e c t i o n r e g i s t e r s f o r F R 5 5 5
sethi. p % h i ( _ _ r e g i o n _ I O ) ,g r7
setlo % l o ( _ _ r e g i o n _ I O ) ,g r7
ori g r7 ,#x A M P R x _ S S _ 512 M b | x A M P R x _ S _ K E R N E L | x A M P R x _ C | x A M P R x _ V ,g r5
movgs g r0 ,i a m p r15
movgs g r0 ,i a m l r15
movgs g r5 ,d a m p r15
movgs g r7 ,d a m l r15
# need t o t i l e t h e r e m a i n i n g I A M P R / D A M P R r e g i s t e r s t o c o v e r a s m u c h o f t h e R A M a s p o s s i b l e
# - start w i t h t h e h i g h e s t n u m b e r e d r e g i s t e r s
sethi. p % h i ( _ _ k e r n e l _ i m a g e _ e n d ) ,g r8
setlo % l o ( _ _ k e r n e l _ i m a g e _ e n d ) ,g r8
sethi. p % h i ( 3 2 7 6 8 ) ,g r4 ; allow for a maximal allocator bitmap
setlo % l o ( 3 2 7 6 8 ) ,g r4
add g r8 ,g r4 ,g r8
sethi. p % h i ( 1 0 2 4 * 2 0 4 8 - 1 ) ,g r4 ; round up to nearest 2MiB
setlo % l o ( 1 0 2 4 * 2 0 4 8 - 1 ) ,g r4
add. p g r8 ,g r4 ,g r8
not g r4 ,g r4
and g r8 ,g r4 ,g r8
sethi. p % h i ( _ _ p a g e _ o f f s e t ) ,g r9
setlo % l o ( _ _ p a g e _ o f f s e t ) ,g r9
add g r9 ,g r25 ,g r9
# GR8 = b a s e o f u n c o v e r e d R A M
# GR9 = t o p o f u n c o v e r e d R A M
# GR1 1 - m a s k f o r D A M L R / I A M L R r e g s
#
call _ _ h e a d _ s p l i t _ r e g i o n
movgs g r4 ,i a m p r14
movgs g r6 ,i a m l r14
movgs g r5 ,d a m p r14
movgs g r7 ,d a m l r14
call _ _ h e a d _ s p l i t _ r e g i o n
movgs g r4 ,i a m p r13
movgs g r6 ,i a m l r13
movgs g r5 ,d a m p r13
movgs g r7 ,d a m l r13
call _ _ h e a d _ s p l i t _ r e g i o n
movgs g r4 ,i a m p r12
movgs g r6 ,i a m l r12
movgs g r5 ,d a m p r12
movgs g r7 ,d a m l r12
call _ _ h e a d _ s p l i t _ r e g i o n
movgs g r4 ,i a m p r11
movgs g r6 ,i a m l r11
movgs g r5 ,d a m p r11
movgs g r7 ,d a m l r11
call _ _ h e a d _ s p l i t _ r e g i o n
movgs g r4 ,i a m p r10
movgs g r6 ,i a m l r10
movgs g r5 ,d a m p r10
movgs g r7 ,d a m l r10
call _ _ h e a d _ s p l i t _ r e g i o n
movgs g r4 ,i a m p r9
movgs g r6 ,i a m l r9
movgs g r5 ,d a m p r9
movgs g r7 ,d a m l r9
call _ _ h e a d _ s p l i t _ r e g i o n
movgs g r4 ,i a m p r8
movgs g r6 ,i a m l r8
movgs g r5 ,d a m p r8
movgs g r7 ,d a m l r8
call _ _ h e a d _ s p l i t _ r e g i o n
movgs g r4 ,i a m p r7
movgs g r6 ,i a m l r7
movgs g r5 ,d a m p r7
movgs g r7 ,d a m l r7
call _ _ h e a d _ s p l i t _ r e g i o n
movgs g r4 ,i a m p r6
movgs g r6 ,i a m l r6
movgs g r5 ,d a m p r6
movgs g r7 ,d a m l r6
call _ _ h e a d _ s p l i t _ r e g i o n
movgs g r4 ,i a m p r5
movgs g r6 ,i a m l r5
movgs g r5 ,d a m p r5
movgs g r7 ,d a m l r5
call _ _ h e a d _ s p l i t _ r e g i o n
movgs g r4 ,i a m p r4
movgs g r6 ,i a m l r4
movgs g r5 ,d a m p r4
movgs g r7 ,d a m l r4
call _ _ h e a d _ s p l i t _ r e g i o n
movgs g r4 ,i a m p r3
movgs g r6 ,i a m l r3
movgs g r5 ,d a m p r3
movgs g r7 ,d a m l r3
call _ _ h e a d _ s p l i t _ r e g i o n
movgs g r4 ,i a m p r2
movgs g r6 ,i a m l r2
movgs g r5 ,d a m p r2
movgs g r7 ,d a m l r2
call _ _ h e a d _ s p l i t _ r e g i o n
movgs g r4 ,i a m p r1
movgs g r6 ,i a m l r1
movgs g r5 ,d a m p r1
movgs g r7 ,d a m l r1
# cover k e r n e l c o r e i m a g e w i t h k e r n e l - o n l y s e g m e n t
sethi. p % h i ( _ _ p a g e _ o f f s e t ) ,g r8
setlo % l o ( _ _ p a g e _ o f f s e t ) ,g r8
call _ _ h e a d _ s p l i t _ r e g i o n
# ifdef C O N F I G _ P R O T E C T _ K E R N E L
ori. p g r4 ,#x A M P R x _ S _ K E R N E L , g r 4
ori g r5 ,#x A M P R x _ S _ K E R N E L , g r 5
# endif
movgs g r4 ,i a m p r0
movgs g r6 ,i a m l r0
movgs g r5 ,d a m p r0
movgs g r7 ,d a m l r0
jmpl @(gr27,gr0)