2011-09-06 14:59:40 +08:00
/ *
* Copyright 2 0 1 1 F r e e s c a l e S e m i c o n d u c t o r , I n c .
* Copyright 2 0 1 1 L i n a r o L t d .
*
* The c o d e c o n t a i n e d h e r e i n i s l i c e n s e d u n d e r t h e G N U G e n e r a l P u b l i c
* License. Y o u m a y o b t a i n 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
* Version 2 o r l a t e r a t t h e f o l l o w i n g l o c a t i o n s :
*
* http : / / www. o p e n s o u r c e . o r g / l i c e n s e s / g p l - l i c e n s e . h t m l
* http : / / www. g n u . o r g / c o p y l e f t / g p l . h t m l
* /
# 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 >
2011-09-06 15:08:40 +08:00
# include < a s m / a s m - o f f s e t s . h >
2011-09-06 14:59:40 +08:00
# include < a s m / h a r d w a r e / c a c h e - l 2 x0 . h >
.section " .text .head " , " ax"
/ *
* 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
2011-12-30 16:16:07 +08:00
mcr p15 , 0 , r0 , c7 , c5 , 0 @ invalidate I cache
2011-09-06 14:59:40 +08:00
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 )
# ifdef C O N F I G _ S M P
ENTRY( v7 _ s e c o n d a r y _ s t a r t u p )
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( v7 _ s e c o n d a r y _ s t a r t u p )
# endif
2011-09-06 15:08:40 +08:00
2011-12-21 22:38:23 +08:00
# ifdef C O N F I G _ P M
2011-09-06 15:08:40 +08:00
/ *
* The f o l l o w i n g c o d e i s l o c a t e d i n t o t h e . d a t a s e c t i o n . T h i s i s t o
* allow p h y s _ l 2 x0 _ s a v e d _ r e g s t o b e a c c e s s e d w i t h a r e l a t i v e l o a d
* as w e a r e r u n n i n g o n p h y s i c a l a d d r e s s h e r e .
* /
.data
.align
2011-12-22 11:55:01 +08:00
# ifdef C O N F I G _ C A C H E _ L 2 X 0
2011-09-06 15:08:40 +08:00
.macro pl310_resume
ldr r2 , p h y s _ l 2 x0 _ s a v e d _ r e g s
ldr r0 , [ r2 , #L 2 X 0 _ R _ P H Y _ B A S E ] @ get physical base of l2x0
ldr r1 , [ r2 , #L 2 X 0 _ R _ A U X _ C T R L ] @ get aux_ctrl value
str r1 , [ r0 , #L 2 X 0 _ A U X _ C T R L ] @ restore aux_ctrl
mov r1 , #0x1
str r1 , [ r0 , #L 2 X 0 _ C T R L ] @ re-enable L2
.endm
2011-12-22 11:55:01 +08:00
.globl phys_l2x0_saved_regs
phys_l2x0_saved_regs :
.long 0
# else
.macro pl310_resume
.endm
# endif
2011-09-06 15:08:40 +08:00
ENTRY( v7 _ c p u _ r e s u m e )
bl v7 _ i n v a l i d a t e _ l 1
pl3 1 0 _ r e s u m e
b c p u _ r e s u m e
ENDPROC( v7 _ c p u _ r e s u m e )
2011-12-21 22:38:23 +08:00
# endif