/ *
* Memory s u b - s y s t e m i n i t i a l i z a t i o n c o d e f o r D a n u b e b o a r d .
* Andre M e s s e r s c h m i d t
* Copyright ( c ) 2 0 0 5 I n f i n e o n T e c h n o l o g i e s A G
*
* Based o n I n c a - I P c o d e
* Copyright ( c ) 2 0 0 3 W o l f g a n g D e n k < w d @denx.de>
*
* See f i l e C R E D I T S f o r l i s t o f p e o p l e w h o c o n t r i b u t e d t o t h i s
* project.
*
* 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 a s
* published 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
* the 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 .
*
* This p r o g r a m i s d i s t r i b u t e d i n t h e h o p e t h a t i t w i l l b e u s e f u l ,
* but W I T H O U T A N Y W A R R A N T Y ; without even the implied warranty of
* MERCHANTABILITY o r F I T N E S S F O R A P A R T I C U L A R P U R P O S E . S e e t h e
* GNU G e n e r a l P u b l i c L i c e n s e f o r m o r e d e t a i l s .
*
* You s h o u l d h a v e r e c e i v e d a c o p y 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
* along w i t h t h i s p r o g r a m ; if not, write to the Free Software
* Foundation, I n c . , 5 9 T e m p l e P l a c e , S u i t e 3 3 0 , B o s t o n ,
* MA 0 2 1 1 1 - 1 3 0 7 U S A
* /
/ * History :
peng l i u M a y 2 5 , 2 0 0 6 , f o r P L L s e t t i n g a f t e r r e s e t , 0 5 2 5 2 0 0 6
* /
# include < c o n f i g . h >
# include < v e r s i o n . h >
# include < a s m / r e g d e f . h >
# if d e f i n e d ( C O N F I G _ U S E _ D D R _ P S C _ 3 2 )
# include " d d r _ s e t t i n g s _ p s c _ 3 2 . h "
# define D D R 1 6 6
# elif d e f i n e d ( C O N F I G _ U S E _ D D R _ P S C _ 6 4 )
# include " d d r _ s e t t i n g s _ p s c _ 6 4 . h "
# define D D R 1 6 6
# else
# error " m i s s i n g d e f i n i t i o n f o r R A M "
# endif
# define E B U _ M O D U L _ B A S E 0 x B E 1 0 5 3 0 0
# define E B U _ C L C ( v a l u e ) 0 x00 0 0 ( v a l u e )
# define E B U _ C O N ( v a l u e ) 0 x00 1 0 ( v a l u e )
# define E B U _ A D D S E L 0 ( v a l u e ) 0 x00 2 0 ( v a l u e )
# define E B U _ A D D S E L 1 ( v a l u e ) 0 x00 2 4 ( v a l u e )
# define E B U _ A D D S E L 2 ( v a l u e ) 0 x00 2 8 ( v a l u e )
# define E B U _ A D D S E L 3 ( v a l u e ) 0 x00 2 C ( v a l u e )
# define E B U _ B U S C O N 0 ( v a l u e ) 0 x00 6 0 ( v a l u e )
# define E B U _ B U S C O N 1 ( v a l u e ) 0 x00 6 4 ( v a l u e )
# define E B U _ B U S C O N 2 ( v a l u e ) 0 x00 6 8 ( v a l u e )
# define E B U _ B U S C O N 3 ( v a l u e ) 0 x00 6 C ( v a l u e )
# define M C _ M O D U L _ B A S E 0 x B F 8 0 0 0 0 0
# define M C _ E R R C A U S E ( v a l u e ) 0 x00 1 0 ( v a l u e )
# define M C _ E R R A D D R ( v a l u e ) 0 x00 2 0 ( v a l u e )
# define M C _ C O N ( v a l u e ) 0 x00 6 0 ( v a l u e )
# define M C _ S R A M _ E N A B L E 0 x00 0 0 0 0 0 4
# define M C _ S D R A M _ E N A B L E 0 x00 0 0 0 0 0 2
# define M C _ D D R R A M _ E N A B L E 0 x00 0 0 0 0 0 1
# define M C _ S D R _ M O D U L _ B A S E 0 x B F 8 0 0 2 0 0
# define M C _ I O G P ( v a l u e ) 0 x00 0 0 ( v a l u e )
# define M C _ C T R L E N A ( v a l u e ) 0 x00 1 0 ( v a l u e )
# define M C _ M R S C O D E ( v a l u e ) 0 x00 2 0 ( v a l u e )
# define M C _ C F G D W ( v a l u e ) 0 x00 3 0 ( v a l u e )
# define M C _ C F G P B 0 ( v a l u e ) 0 x00 4 0 ( v a l u e )
# define M C _ L A T E N C Y ( v a l u e ) 0 x00 8 0 ( v a l u e )
# define M C _ T R E F R E S H ( v a l u e ) 0 x00 9 0 ( v a l u e )
# define M C _ S E L F R F S H ( v a l u e ) 0 x00 A 0 ( v a l u e )
# define M C _ D D R _ M O D U L _ B A S E 0 x B F 8 0 1 0 0 0
# define M C _ D C 0 0 ( v a l u e ) 0 x00 0 0 ( v a l u e )
# define M C _ D C 0 1 ( v a l u e ) 0 x00 1 0 ( v a l u e )
# define M C _ D C 0 2 ( v a l u e ) 0 x00 2 0 ( v a l u e )
# define M C _ D C 0 3 ( v a l u e ) 0 x00 3 0 ( v a l u e )
# define M C _ D C 0 4 ( v a l u e ) 0 x00 4 0 ( v a l u e )
# define M C _ D C 0 5 ( v a l u e ) 0 x00 5 0 ( v a l u e )
# define M C _ D C 0 6 ( v a l u e ) 0 x00 6 0 ( v a l u e )
# define M C _ D C 0 7 ( v a l u e ) 0 x00 7 0 ( v a l u e )
# define M C _ D C 0 8 ( v a l u e ) 0 x00 8 0 ( v a l u e )
# define M C _ D C 0 9 ( v a l u e ) 0 x00 9 0 ( v a l u e )
# define M C _ D C 1 0 ( v a l u e ) 0 x00 A 0 ( v a l u e )
# define M C _ D C 1 1 ( v a l u e ) 0 x00 B 0 ( v a l u e )
# define M C _ D C 1 2 ( v a l u e ) 0 x00 C 0 ( v a l u e )
# define M C _ D C 1 3 ( v a l u e ) 0 x00 D 0 ( v a l u e )
# define M C _ D C 1 4 ( v a l u e ) 0 x00 E 0 ( v a l u e )
# define M C _ D C 1 5 ( v a l u e ) 0 x00 F 0 ( v a l u e )
# define M C _ D C 1 6 ( v a l u e ) 0 x01 0 0 ( v a l u e )
# define M C _ D C 1 7 ( v a l u e ) 0 x01 1 0 ( v a l u e )
# define M C _ D C 1 8 ( v a l u e ) 0 x01 2 0 ( v a l u e )
# define M C _ D C 1 9 ( v a l u e ) 0 x01 3 0 ( v a l u e )
# define M C _ D C 2 0 ( v a l u e ) 0 x01 4 0 ( v a l u e )
# define M C _ D C 2 1 ( v a l u e ) 0 x01 5 0 ( v a l u e )
# define M C _ D C 2 2 ( v a l u e ) 0 x01 6 0 ( v a l u e )
# define M C _ D C 2 3 ( v a l u e ) 0 x01 7 0 ( v a l u e )
# define M C _ D C 2 4 ( v a l u e ) 0 x01 8 0 ( v a l u e )
# define M C _ D C 2 5 ( v a l u e ) 0 x01 9 0 ( v a l u e )
# define M C _ D C 2 6 ( v a l u e ) 0 x01 A 0 ( v a l u e )
# define M C _ D C 2 7 ( v a l u e ) 0 x01 B 0 ( v a l u e )
# define M C _ D C 2 8 ( v a l u e ) 0 x01 C 0 ( v a l u e )
# define M C _ D C 2 9 ( v a l u e ) 0 x01 D 0 ( v a l u e )
# define M C _ D C 3 0 ( v a l u e ) 0 x01 E 0 ( v a l u e )
# define M C _ D C 3 1 ( v a l u e ) 0 x01 F 0 ( v a l u e )
# define M C _ D C 3 2 ( v a l u e ) 0 x02 0 0 ( v a l u e )
# define M C _ D C 3 3 ( v a l u e ) 0 x02 1 0 ( v a l u e )
# define M C _ D C 3 4 ( v a l u e ) 0 x02 2 0 ( v a l u e )
# define M C _ D C 3 5 ( v a l u e ) 0 x02 3 0 ( v a l u e )
# define M C _ D C 3 6 ( v a l u e ) 0 x02 4 0 ( v a l u e )
# define M C _ D C 3 7 ( v a l u e ) 0 x02 5 0 ( v a l u e )
# define M C _ D C 3 8 ( v a l u e ) 0 x02 6 0 ( v a l u e )
# define M C _ D C 3 9 ( v a l u e ) 0 x02 7 0 ( v a l u e )
# define M C _ D C 4 0 ( v a l u e ) 0 x02 8 0 ( v a l u e )
# define M C _ D C 4 1 ( v a l u e ) 0 x02 9 0 ( v a l u e )
# define M C _ D C 4 2 ( v a l u e ) 0 x02 A 0 ( v a l u e )
# define M C _ D C 4 3 ( v a l u e ) 0 x02 B 0 ( v a l u e )
# define M C _ D C 4 4 ( v a l u e ) 0 x02 C 0 ( v a l u e )
# define M C _ D C 4 5 ( v a l u e ) 0 x02 D 0 ( v a l u e )
# define M C _ D C 4 6 ( v a l u e ) 0 x02 E 0 ( v a l u e )
# define R C U _ O F F S E T 0 x B F 2 0 3 0 0 0
# define R C U _ R S T _ R E Q ( R C U _ O F F S E T + 0 x00 1 0 )
# define R C U _ S T S ( R C U _ O F F S E T + 0 x00 1 4 )
# define C G U _ O F F S E T 0 x B F 1 0 3 0 0 0
# define P L L 0 _ C F G ( C G U _ O F F S E T + 0 x00 0 4 )
# define P L L 1 _ C F G ( C G U _ O F F S E T + 0 x00 0 8 )
# define P L L 2 _ C F G ( C G U _ O F F S E T + 0 x00 0 C )
# define C G U _ S Y S ( C G U _ O F F S E T + 0 x00 1 0 )
# define C G U _ U P D A T E ( C G U _ O F F S E T + 0 x00 1 4 )
# define I F _ C L K ( C G U _ O F F S E T + 0 x00 1 8 )
# define C G U _ S M D ( C G U _ O F F S E T + 0 x00 2 0 )
# define C G U _ C T 1 S R ( C G U _ O F F S E T + 0 x00 2 8 )
# define C G U _ C T 2 S R ( C G U _ O F F S E T + 0 x00 2 C )
# define C G U _ P C M C R ( C G U _ O F F S E T + 0 x00 3 0 )
# define P C I _ C R _ P C I ( C G U _ O F F S E T + 0 x00 3 4 )
# define C G U _ O S C _ C T R L ( C G U _ O F F S E T + 0 x00 1 C )
# define C G U _ M I P S _ P W R _ D W N ( C G U _ O F F S E T + 0 x00 3 8 )
# define C L K _ M E A S U R E ( C G U _ O F F S E T + 0 x00 3 C )
/ / 0 5 2 5 2 0 0 6
# define p l l 0 _ 3 5 M H z _ C O N F I G 0 x9 D 8 6 1 0 5 9
# define p l l 1 _ 3 5 M H z _ C O N F I G 0 x1 A 2 6 0 C D 9
# define p l l 2 _ 3 5 M H z _ C O N F I G 0 x80 0 0 f1 e 5
# define p l l 0 _ 3 6 M H z _ C O N F I G 0 x10 0 0 1 2 5 D
# define p l l 1 _ 3 6 M H z _ C O N F I G 0 x1 B 1 E 0 C 9 9
# define p l l 2 _ 3 6 M H z _ C O N F I G 0 x80 0 2 f2 a1
/ / 0 5 2 5 2 0 0 6
/ / 0 6 0 6 3 0 0 1 - joelin d i s a b l e t h e P C I C F R A M E m a s k - s t a r t
/ * CFRAME i s a n I / O s i g n a l , i n t h e c h i p , t h e o u t p u t C F R A M E i s s e l e c t e d v i a G P I O a l t s e l p i n s , s o i f y o u s e l e c t M I I 1 R X D 1 , t h e C F R A M E w i l l n o t c o m e o u t .
But t h e C F R A M E i n p u t s t i l l t a k e t h e s i g n a l f r o m t h e p a d a n d n o t d i s a b l e d w h e n a l t s e l c h o o s e o t h e r f u n c t i o n . S o w h e n M I I 1 _ R X D 1 i s l o w f r o m o t h e r d e v i c e , t h e E B U i n t e r f a c e w i l l b e d i s a b l e d .
The c h i p f u n c t i o n i n s u c h a w a y t h a t d i s a b l e t h e C F R A M E m a s k m e a n E B U n o t l o n g e r c h e c k C F R A M E t o b e t h e d e v i c e u s i n g t h e b u s .
The s i d e e f f e c t i s t h e e n t i r e P C I b l o c k w i l l s e e C F R A M E l o w a l l t h e t i m e m e a n i n g P C I c a n n o t u s e t h e b u s a t a l l s o n o m o r e P C I f u n c t i o n .
* /
# define P C I _ C R _ P R _ O F F S E T 0 x B E 1 0 5 4 0 0
# define P C I _ C R _ P C I _ M O D _ R E G ( P C I _ C R _ P R _ O F F S E T + 0 x00 3 0 )
# define P C I _ C O N F I G _ S P A C E 0 x B 7 0 0 0 0 0 0
# define C S _ C F M ( P C I _ C O N F I G _ S P A C E + 0 x6 C )
/ / 0 6 0 6 3 0 0 1 - joelin d i s a b l e t h e P C I C F R A M E m a s k - e n d
.set noreorder
/ *
* void e b u _ i n i t ( v o i d )
* /
.globl ebu_init
.ent ebu_init
ebu_init :
j r a
nop
.end ebu_init
/ *
* void c g u _ i n i t ( l o n g )
*
* a0 h a s t h e c l o c k v a l u e
* /
.globl cgu_init
.ent cgu_init
cgu_init :
li t 2 , C G U _ S Y S
lw t 2 ,0 ( t 2 )
beq t 2 ,a0 ,f r e q _ u p2 d a t e
nop
li t 2 , R C U _ S T S
lw t 2 , 0 ( t 2 )
and t 2 ,0 x00 0 2 0 0 0 0
beq t 2 ,0 x00 0 2 0 0 0 0 ,b o o t _ 3 6 M H Z
nop
/ / 0 5 2 5 2 0 0 6
li t 1 , P L L 0 _ C F G
li t 2 , p l l 0 _ 3 5 M H z _ C O N F I G
sw t 2 ,0 ( t 1 )
li t 1 , P L L 1 _ C F G
li t 2 , p l l 1 _ 3 5 M H z _ C O N F I G
sw t 2 ,0 ( t 1 )
li t 1 , P L L 2 _ C F G
li t 2 , p l l 2 _ 3 5 M H z _ C O N F I G
sw t 2 ,0 ( t 1 )
li t 1 , C G U _ S Y S
sw a0 ,0 ( t 1 )
li t 1 , R C U _ R S T _ R E Q
li t 2 , 0 x40 0 0 0 0 0 8
sw t 2 ,0 ( t 1 )
b w a i t _ r e s e t
nop
boot_36MHZ :
li t 1 , P L L 0 _ C F G
li t 2 , p l l 0 _ 3 6 M H z _ C O N F I G
sw t 2 ,0 ( t 1 )
li t 1 , P L L 1 _ C F G
li t 2 , p l l 1 _ 3 6 M H z _ C O N F I G
sw t 2 ,0 ( t 1 )
li t 1 , P L L 2 _ C F G
li t 2 , p l l 2 _ 3 6 M H z _ C O N F I G
sw t 2 ,0 ( t 1 )
li t 1 , C G U _ S Y S
sw a0 ,0 ( t 1 )
li t 1 , R C U _ R S T _ R E Q
li t 2 , 0 x40 0 0 0 0 0 8
sw t 2 ,0 ( t 1 )
/ / 0 5 2 5 2 0 0 6
wait_reset :
b w a i t _ r e s e t
nop
freq_up2date :
j r a
nop
.end cgu_init
.globl lowlevel_init
.ent lowlevel_init
lowlevel_init :
/ * EBU, C G U a n d S D R A M / D D R - R A M I n i t i a l i z a t i o n .
* /
move t 0 , r a
/ * We r e l y o n t h e f a c t t h a t n o n o f t h e f o l l o w i n g . . . _ i n i t ( ) f u n c t i o n s
* modify t 0
* /
bal e b u _ i n i t
nop
/ / 0 6 0 6 3 0 0 1 - joelin d i s a b l e t h e P C I C F R A M E m a s k - s t a r t
# ifdef D I S A B L E _ C F R A M E
li t 1 , P C I _ C R _ P C I / / m w b f10 3 0 3 4 8 0 0 0 0 0 0 0
li t 2 , 0 x80 0 0 0 0 0 0
sw t 2 ,0 ( t 1 )
li t 1 , P C I _ C R _ P C I _ M O D _ R E G / / m w b e 1 0 5 4 3 0 1 0 3
li t 2 , 0 x10 3
sw t 2 ,0 ( t 1 )
li t 1 , C S _ C F M / / m w b70 0 0 0 6 c 0
li t 2 , 0 x00
sw t 2 , 0 ( t 1 )
li t 1 , P C I _ C R _ P C I _ M O D _ R E G / / m w b e 1 0 5 4 3 0 1 0 3
li t 2 , 0 x10 0 0 1 0 3
sw t 2 , 0 ( t 1 )
# endif
/ / 0 6 0 6 3 0 0 1 - joelin d i s a b l e t h e P C I C F R A M E m a s k - e n d
move r a , t 0
j r a
nop
.end lowlevel_init