2010-12-14 16:56:55 +09:00
/ *
* SMP s u p p o r t f o r R - M o b i l e / S H - M o b i l e
*
* Copyright ( C ) 2 0 1 0 M a g n u s D a m m
* Copyright ( C ) 2 0 1 0 T a k a s h i Y o s h i i
*
* Based o n v e x p r e s s , C o p y r i g h t ( c ) 2 0 0 3 A R M L i m i t e d , A l l R i g h t s R e s e r v e d
*
* 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
* it 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 v e r s i o n 2 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 .
* /
# include < l i n u x / l i n k a g e . h >
# include < l i n u x / i n i t . h >
2010-12-20 11:04:50 +00:00
# include < a s m / m e m o r y . h >
2010-12-14 16:56:55 +09:00
2011-12-28 16:44:06 +09:00
_ _ CPUINIT
2010-12-14 16:56:55 +09:00
2012-05-09 16:24:59 +09:00
/ * Cache i n v a l i d a t i o n n i c k e d f r o m a r c h / a r m / m a c h - i m x / h e a d - v7 . S , t h a n k s !
*
* The s e c o n d a r y k e r n e l i n i t c a l l s v7 _ f l u s h _ d c a c h e _ a l l b e f o r e i t e n a b l e s
* the L 1 ; however, the L1 comes out of reset in an undefined state, so
* the c l e a n + i n v a l i d a t e p e r f o r m e d b y v7 _ f l u s h _ d c a c h e _ a l l c a u s e s a b u n c h
* of c a c h e l i n e s w i t h u n i n i t i a l i z e d d a t a a n d u n i n i t i a l i z e d t a g s t o g e t
* written o u t t o m e m o r y , w h i c h d o e s r e a l l y u n p l e a s a n t t h i n g s t o t h e m a i n
* processor. W e f i x t h i s b y p e r f o r m i n g a n i n v a l i d a t e , r a t h e r t h a n a
* clean + i n v a l i d a t e , b e f o r e j u m p i n g i n t o t h e k e r n e l .
*
* This f u n c i t o n i s c l o n e d f r o m a r c h / a r m / m a c h - t e g r a / h e a d s m p . S , a n d n e e d s
* to b e c a l l e d f o r b o t h s e c o n d a r y c o r e s s t a r t u p a n d p r i m a r y c o r e r e s u m e
* procedures. I d e a l l y , i t s h o u l d b e m o v e d i n t o a r c h / a r m / m m / c a c h e - v7 . S .
* /
ENTRY( v7 _ i n v a l i d a t e _ l 1 )
mov r0 , #0
mcr p15 , 0 , r0 , c7 , c5 , 0 @ invalidate I cache
mcr p15 , 2 , r0 , c0 , c0 , 0
mrc p15 , 1 , r0 , c0 , c0 , 0
ldr r1 , =0x7fff
and r2 , r1 , r0 , l s r #13
ldr r1 , =0x3ff
and r3 , r1 , r0 , l s r #3 @ NumWays - 1
add r2 , r2 , #1 @ NumSets
and r0 , r0 , #0x7
add r0 , r0 , #4 @ SetShift
clz r1 , r3 @ WayShift
add r4 , r3 , #1 @ NumWays
1 : sub r2 , r2 , #1 @ NumSets--
mov r3 , r4 @ Temp = NumWays
2 : subs r3 , r3 , #1 @ Temp--
mov r5 , r3 , l s l r1
mov r6 , r2 , l s l r0
orr r5 , r5 , r6 @ Reg = (Temp<<WayShift)|(NumSets<<SetShift)
mcr p15 , 0 , r5 , c7 , c6 , 2
bgt 2 b
cmp r2 , #0
bgt 1 b
dsb
isb
mov p c , l r
ENDPROC( v7 _ i n v a l i d a t e _ l 1 )
ENTRY( s h m o b i l e _ i n v a l i d a t e _ s t a r t )
bl v7 _ i n v a l i d a t e _ l 1
b s e c o n d a r y _ s t a r t u p
ENDPROC( s h m o b i l e _ i n v a l i d a t e _ s t a r t )
2010-12-14 16:56:55 +09:00
/ *
* Reset v e c t o r f o r s e c o n d a r y C P U s .
* This w i l l b e m a p p e d a t a d d r e s s 0 b y S B A R r e g i s t e r .
* We n e e d _ l o n g _ j u m p t o t h e p h y s i c a l a d d r e s s .
* /
.align 12
ENTRY( s h m o b i l e _ s e c o n d a r y _ v e c t o r )
ldr p c , 1 f
2012-05-09 16:24:59 +09:00
1 : .long s h m o b i l e _ i n v a l i d a t e _ s t a r t - P A G E _ O F F S E T + P L A T _ P H Y S _ O F F S E T
ENDPROC( s h m o b i l e _ s e c o n d a r y _ v e c t o r )