2005-04-16 15:20:36 -07:00
/ *
* linux/ a r c h / m 3 2 r / b o o t / s e t u p . S - - A s e t u p c o d e .
*
2006-01-06 00:18:44 -08:00
* Copyright ( C ) 2 0 0 1 - 2 0 0 5 H i r o y u k i K o n d o , H i r o k a z u T a k a t a ,
* Hitoshi Y a m a m o t o , H a y a t o F u j i w a r a
2005-04-16 15:20:36 -07:00
*
* /
# include < l i n u x / l i n k a g e . h >
# include < a s m / s e g m e n t . h >
# include < a s m / p a g e . h >
# include < a s m / p g t a b l e . h >
# include < a s m / a s s e m b l e r . h >
# include < a s m / m m u _ c o n t e x t . h >
# include < a s m / m 3 2 r . h >
/ *
* References t o m e m b e r s o f t h e b o o t _ c p u _ d a t a s t r u c t u r e .
* /
# define C P U _ P A R A M S b o o t _ c p u _ d a t a
# define M 3 2 R _ M C I C A R 0 x f f f f f f f0
# define M 3 2 R _ M C D C A R 0 x f f f f f f f4
# define M 3 2 R _ M C C R 0 x f f f f f f f c
# define M 3 2 R _ B S C R 0 0 x f f f f f f d2
;BSEL
# define B S E L 0 C R 0 0 x00 e f50 0 0
# define B S E L 0 C R 1 0 x00 e f50 0 4
# define B S E L 1 C R 0 0 x00 e f51 0 0
# define B S E L 1 C R 1 0 x00 e f51 0 4
# define B S E L 0 C R 0 _ V A L 0 x00 0 0 0 0 0 0
# define B S E L 0 C R 1 _ V A L 0 x01 2 0 0 1 0 0
# define B S E L 1 C R 0 _ V A L 0 x01 0 1 8 0 0 0
# define B S E L 1 C R 1 _ V A L 0 x00 2 0 0 0 0 1
;SDRAMC
# define S D R A M C _ S D R F 0 0 x00 e f60 0 0
# define S D R A M C _ S D R F 1 0 x00 e f60 0 4
# define S D R A M C _ S D I R 0 0 x00 e f60 0 8
# define S D R A M C _ S D I R 1 0 x00 e f60 0 c
# define S D R A M C _ S D 0 A D R 0 x00 e f60 2 0
# define S D R A M C _ S D 0 E R 0 x00 e f60 2 4
# define S D R A M C _ S D 0 T R 0 x00 e f60 2 8
# define S D R A M C _ S D 0 M O D 0 x00 e f60 2 c
# define S D R A M C _ S D 1 A D R 0 x00 e f60 4 0
# define S D R A M C _ S D 1 E R 0 x00 e f60 4 4
# define S D R A M C _ S D 1 T R 0 x00 e f60 4 8
# define S D R A M C _ S D 1 M O D 0 x00 e f60 4 c
# define S D R A M 0 0 x18 0 0 0 0 0 0
# define S D R A M 1 0 x1 c00 0 0 0 0
/ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* start u p
* /
/ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* Kernel e n t r y
* /
.section .boot , " ax"
ENTRY( b o o t )
/* Set cache mode */
# if d e f i n e d ( C O N F I G _ C H I P _ X N U X 2 )
ldi r0 , #- 2 ;LDIMM (r0, M32R_MCCR)
ldi r1 , #0x0101 ; cache on (with invalidation)
; ldi r1, #0x00 ; cache off
sth r1 , @r0
# elif d e f i n e d ( C O N F I G _ C H I P _ M 3 2 7 0 0 ) | | d e f i n e d ( C O N F I G _ C H I P _ V D E C 2 ) \
| | defined( C O N F I G _ C H I P _ O P S P )
ldi r0 , #- 4 ;LDIMM (r0, M32R_MCCR)
ldi r1 , #0x73 ; cache on (with invalidation)
; ldi r1, #0x00 ; cache off
st r1 , @r0
# elif d e f i n e d ( C O N F I G _ C H I P _ M 3 2 1 0 2 )
ldi r0 , #- 4 ;LDIMM (r0, M32R_MCCR)
ldi r1 , #0x101 ; cache on (with invalidation)
; ldi r1, #0x00 ; cache off
st r1 , @r0
2006-01-06 00:18:41 -08:00
# elif d e f i n e d ( C O N F I G _ C H I P _ M 3 2 1 0 4 )
2006-01-06 00:18:44 -08:00
ldi r0 , #- 96 ; DNCR0
seth r1 , #0x0060 ; from 0x00600000
or3 r1 , r1 , #0x0005 ; size 2MB
st r1 , @r0
seth r1 , #0x0100 ; from 0x01000000
or3 r1 , r1 , #0x0003 ; size 16MB
st r1 , @+r0
seth r1 , #0x0200 ; from 0x02000000
or3 r1 , r1 , #0x0002 ; size 32MB
st r1 , @+r0
2006-01-06 00:18:41 -08:00
ldi r0 , #- 4 ;LDIMM (r0, M32R_MCCR)
ldi r1 , #0x703 ; cache on (with invalidation)
st r1 , @r0
2005-04-16 15:20:36 -07:00
# else
# error u n k n o w n c h i p c o n f i g u r a t i o n
# endif
# ifdef C O N F I G _ S M P
;; if not BSP (CPU#0) goto AP_loop
seth r5 , #s h i g h ( M 32 R _ C P U I D _ P O R T L )
ld r5 , @(low(M32R_CPUID_PORTL), r5)
bnez r5 , A P _ l o o p
# if ! d e f i n e d ( C O N F I G _ P L A T _ U S R V )
;; boot AP
ld2 4 r5 , #0xeff2f8 ; IPICR7
ldi r6 , #0x2 ; IPI to CPU1
st r6 , @r5
# endif
# endif
/ *
* Now, J u m p t o s t e x t
* if w i t h M M U , T L B o n .
* if w i t h n o M M U , o n l y j u m p .
* /
.global eit_vector
mmu_on :
LDIMM ( r13 , s t e x t )
# ifdef C O N F I G _ M M U
bl i n i t _ t l b
LDIMM ( r2 , e i t _ v e c t o r ) ; set EVB(cr5)
mvtc r2 , c r5
seth r0 , #h i g h ( M M U _ R E G _ B A S E ) ; S e t M M U _ R E G _ B A S E h i g h e r
or3 r0 , r0 , #l o w ( M M U _ R E G _ B A S E ) ; S e t M M U _ R E G _ B A S E l o w e r
ldi r1 , #0x01
st r1 , @(MATM_offset,r0) ; Set MATM (T bit ON)
ld r0 , @(MATM_offset,r0) ; Check
# else
2006-01-06 00:18:41 -08:00
# if d e f i n e d ( C O N F I G _ C H I P _ M 3 2 7 0 0 )
2005-04-16 15:20:36 -07:00
seth r0 ,#h i g h ( M 32 R _ M C D C A R )
or3 r0 ,r0 ,#l o w ( M 32 R _ M C D C A R )
ld2 4 r1 ,#0x8080
st r1 ,@r0
2006-01-06 00:18:41 -08:00
# elif d e f i n e d ( C O N F I G _ C H I P _ M 3 2 1 0 4 )
LDIMM ( r2 , e i t _ v e c t o r ) ; set EVB(cr5)
mvtc r2 , c r5
# endif
2005-04-16 15:20:36 -07:00
# endif / * C O N F I G _ M M U * /
jmp r13
nop
nop
# ifdef C O N F I G _ S M P
/ *
* AP w a i t l o o p
* /
ENTRY( A P _ l o o p )
;; disable interrupt
clrpsw #0x40
;; reset EVB
LDIMM ( r4 , _ A P _ R E )
seth r5 , #h i g h ( _ _ P A G E _ O F F S E T )
or3 r5 , r5 , #l o w ( _ _ P A G E _ O F F S E T )
not r5 , r5
and r4 , r5
mvtc r4 , c r5
;; disable maskable interrupt
seth r4 , #h i g h ( M 32 R _ I C U _ I M A S K _ P O R T L )
or3 r4 , r4 , #l o w ( M 32 R _ I C U _ I M A S K _ P O R T L )
ldi r5 , #0
st r5 , @r4
ld r5 , @r4
;; enable only IPI
setpsw #0x40
;; LOOOOOOOOOOOOOOP!!!
.fillinsn
2 :
nop
nop
bra 2 b
nop
nop
# ifdef C O N F I G _ C H I P _ M 3 2 7 0 0 _ T S 1
.global dcache_dummy
.balign 1 6 , 0
dcache_dummy :
.byte 16
# endif / * C O N F I G _ C H I P _ M 3 2 7 0 0 _ T S 1 * /
# endif / * C O N F I G _ S M P * /
.end