2009-03-25 13:10:01 +02:00
/ *
* linux/ a r c h / a r m / m m / c a c h e - f a . S
*
* Copyright ( C ) 2 0 0 5 F a r a d a y C o r p .
* Copyright ( C ) 2 0 0 8 - 2 0 0 9 P a u l i u s Z a l e c k a s < p a u l i u s . z a l e c k a s @teltonika.lt>
*
* Based o n c a c h e - v4 w b . S :
* Copyright ( C ) 1 9 9 7 - 2 0 0 2 R u s s e l l k i n g
*
* 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 .
*
* Processors : FA5 2 0 F A 5 2 6 F A 6 2 6
* /
# 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 >
# include < a s m / m e m o r y . h >
# include < a s m / p a g e . h >
# include " p r o c - m a c r o s . S "
/ *
* The s i z e o f o n e d a t a c a c h e l i n e .
* /
# define C A C H E _ D L I N E S I Z E 1 6
/ *
* The t o t a l s i z e o f t h e d a t a c a c h e .
* /
# ifdef C O N F I G _ A R C H _ G E M I N I
# define C A C H E _ D S I Z E 8 1 9 2
# else
# define C A C H E _ D S I Z E 1 6 3 8 4
# endif
/* FIXME: put optimal value here. Current one is just estimation */
# define C A C H E _ D L I M I T ( C A C H E _ D S I Z E * 2 )
2010-10-28 11:27:40 +01:00
/ *
* flush_ i c a c h e _ a l l ( )
*
* Unconditionally c l e a n a n d i n v a l i d a t e t h e e n t i r e i c a c h e .
* /
ENTRY( f a _ f l u s h _ i c a c h e _ a l l )
mov r0 , #0
mcr p15 , 0 , r0 , c7 , c5 , 0 @ invalidate I cache
mov p c , l r
ENDPROC( f a _ f l u s h _ i c a c h e _ a l l )
2009-03-25 13:10:01 +02:00
/ *
* flush_ u s e r _ c a c h e _ a l l ( )
*
* Clean a n d i n v a l i d a t e a l l c a c h e e n t r i e s i n a p a r t i c u l a r a d d r e s s
* space.
* /
ENTRY( f a _ f l u s h _ u s e r _ c a c h e _ a l l )
/* FALLTHROUGH */
/ *
* flush_ k e r n _ c a c h e _ a l l ( )
*
* Clean a n d i n v a l i d a t e t h e e n t i r e c a c h e .
* /
ENTRY( f a _ f l u s h _ k e r n _ c a c h e _ a l l )
mov i p , #0
mov r2 , #V M _ E X E C
__flush_whole_cache :
mcr p15 , 0 , i p , c7 , c14 , 0 @ clean/invalidate D cache
tst r2 , #V M _ E X E C
mcrne p15 , 0 , i p , c7 , c5 , 0 @ invalidate I cache
mcrne p15 , 0 , i p , c7 , c5 , 6 @ invalidate BTB
mcrne p15 , 0 , i p , c7 , c10 , 4 @ drain write buffer
mcrne p15 , 0 , i p , c7 , c5 , 4 @ prefetch flush
mov p c , l r
/ *
* flush_ u s e r _ c a c h e _ r a n g e ( s t a r t , e n d , f l a g s )
*
* Invalidate a r a n g e o f c a c h e e n t r i e s i n t h e s p e c i f i e d
* address s p a c e .
*
* - start - s t a r t a d d r e s s ( i n c l u s i v e , p a g e a l i g n e d )
* - end - e n d a d d r e s s ( e x c l u s i v e , p a g e a l i g n e d )
* - flags - v m a _ a r e a _ s t r u c t f l a g s d e s c r i b i n g a d d r e s s s p a c e
* /
ENTRY( f a _ f l u s h _ u s e r _ c a c h e _ r a n g e )
mov i p , #0
sub r3 , r1 , r0 @ calculate total size
cmp r3 , #C A C H E _ D L I M I T @ t o t a l s i z e > = l i m i t ?
bhs _ _ f l u s h _ w h o l e _ c a c h e @ flush whole D cache
1 : tst r2 , #V M _ E X E C
mcrne p15 , 0 , r0 , c7 , c5 , 1 @ invalidate I line
mcr p15 , 0 , r0 , c7 , c14 , 1 @ clean and invalidate D entry
add r0 , r0 , #C A C H E _ D L I N E S I Z E
cmp r0 , r1
blo 1 b
tst r2 , #V M _ E X E C
mcrne p15 , 0 , i p , c7 , c5 , 6 @ invalidate BTB
mcrne p15 , 0 , i p , c7 , c10 , 4 @ data write barrier
mcrne p15 , 0 , i p , c7 , c5 , 4 @ prefetch flush
mov p c , l r
/ *
* coherent_ k e r n _ r a n g e ( s t a r t , e n d )
*
* Ensure c o h e r e n c y b e t w e e n t h e I c a c h e a n d t h e D c a c h e i n t h e
* region d e s c r i b e d b y s t a r t . I f y o u h a v e n o n - s n o o p i n g
* Harvard c a c h e s , y o u n e e d t o i m p l e m e n t t h i s f u n c t i o n .
*
* - start - v i r t u a l s t a r t a d d r e s s
* - end - v i r t u a l e n d a d d r e s s
* /
ENTRY( f a _ c o h e r e n t _ k e r n _ r a n g e )
/* fall through */
/ *
* coherent_ u s e r _ r a n g e ( s t a r t , e n d )
*
* Ensure c o h e r e n c y b e t w e e n t h e I c a c h e a n d t h e D c a c h e i n t h e
* region d e s c r i b e d b y s t a r t . I f y o u h a v e n o n - s n o o p i n g
* Harvard c a c h e s , y o u n e e d t o i m p l e m e n t t h i s f u n c t i o n .
*
* - start - v i r t u a l s t a r t a d d r e s s
* - end - v i r t u a l e n d a d d r e s s
* /
ENTRY( f a _ c o h e r e n t _ u s e r _ r a n g e )
bic r0 , r0 , #C A C H E _ D L I N E S I Z E - 1
1 : mcr p15 , 0 , r0 , c7 , c14 , 1 @ clean and invalidate D entry
mcr p15 , 0 , r0 , c7 , c5 , 1 @ invalidate I entry
add r0 , r0 , #C A C H E _ D L I N E S I Z E
cmp r0 , r1
blo 1 b
mov r0 , #0
mcr p15 , 0 , r0 , c7 , c5 , 6 @ invalidate BTB
mcr p15 , 0 , r0 , c7 , c10 , 4 @ drain write buffer
mcr p15 , 0 , r0 , c7 , c5 , 4 @ prefetch flush
mov p c , l r
/ *
2009-11-26 12:56:21 +00:00
* flush_ k e r n _ d c a c h e _ a r e a ( v o i d * a d d r , s i z e _ t s i z e )
2009-03-25 13:10:01 +02:00
*
* Ensure t h a t t h e d a t a h e l d i n t h e p a g e k a d d r i s w r i t t e n b a c k
* to t h e p a g e i n q u e s t i o n .
*
2009-11-26 12:56:21 +00:00
* - addr - k e r n e l a d d r e s s
* - size - s i z e o f r e g i o n
2009-03-25 13:10:01 +02:00
* /
2009-11-26 12:56:21 +00:00
ENTRY( f a _ f l u s h _ k e r n _ d c a c h e _ a r e a )
add r1 , r0 , r1
2009-03-25 13:10:01 +02:00
1 : mcr p15 , 0 , r0 , c7 , c14 , 1 @ clean & invalidate D line
add r0 , r0 , #C A C H E _ D L I N E S I Z E
cmp r0 , r1
blo 1 b
mov r0 , #0
mcr p15 , 0 , r0 , c7 , c5 , 0 @ invalidate I cache
mcr p15 , 0 , r0 , c7 , c10 , 4 @ drain write buffer
mov p c , l r
/ *
* dma_ i n v _ r a n g e ( s t a r t , e n d )
*
* Invalidate ( d i s c a r d ) t h e s p e c i f i e d v i r t u a l a d d r e s s r a n g e .
* May n o t w r i t e b a c k a n y e n t r i e s . I f ' s t a r t ' o r ' e n d '
* are n o t c a c h e l i n e a l i g n e d , t h o s e l i n e s m u s t b e w r i t t e n
* back.
*
* - start - v i r t u a l s t a r t a d d r e s s
* - end - v i r t u a l e n d a d d r e s s
* /
2009-11-26 16:24:19 +00:00
fa_dma_inv_range :
2009-03-25 13:10:01 +02:00
tst r0 , #C A C H E _ D L I N E S I Z E - 1
bic r0 , r0 , #C A C H E _ D L I N E S I Z E - 1
mcrne p15 , 0 , r0 , c7 , c14 , 1 @ clean & invalidate D entry
tst r1 , #C A C H E _ D L I N E S I Z E - 1
bic r1 , r1 , #C A C H E _ D L I N E S I Z E - 1
mcrne p15 , 0 , r1 , c7 , c14 , 1 @ clean & invalidate D entry
1 : mcr p15 , 0 , r0 , c7 , c6 , 1 @ invalidate D entry
add r0 , r0 , #C A C H E _ D L I N E S I Z E
cmp r0 , r1
blo 1 b
mov r0 , #0
mcr p15 , 0 , r0 , c7 , c10 , 4 @ drain write buffer
mov p c , l r
/ *
* dma_ c l e a n _ r a n g e ( s t a r t , e n d )
*
* Clean ( w r i t e b a c k ) t h e s p e c i f i e d v i r t u a l a d d r e s s r a n g e .
*
* - start - v i r t u a l s t a r t a d d r e s s
* - end - v i r t u a l e n d a d d r e s s
* /
2009-11-26 16:24:19 +00:00
fa_dma_clean_range :
2009-03-25 13:10:01 +02:00
bic r0 , r0 , #C A C H E _ D L I N E S I Z E - 1
1 : mcr p15 , 0 , r0 , c7 , c10 , 1 @ clean D entry
add r0 , r0 , #C A C H E _ D L I N E S I Z E
cmp r0 , r1
blo 1 b
mov r0 , #0
mcr p15 , 0 , r0 , c7 , c10 , 4 @ drain write buffer
mov p c , l r
/ *
* dma_ f l u s h _ r a n g e ( s t a r t ,e n d )
* - start - v i r t u a l s t a r t a d d r e s s o f r e g i o n
* - end - v i r t u a l e n d a d d r e s s o f r e g i o n
* /
ENTRY( f a _ d m a _ f l u s h _ r a n g e )
bic r0 , r0 , #C A C H E _ D L I N E S I Z E - 1
1 : mcr p15 , 0 , r0 , c7 , c14 , 1 @ clean & invalidate D entry
add r0 , r0 , #C A C H E _ D L I N E S I Z E
cmp r0 , r1
blo 1 b
mov r0 , #0
mcr p15 , 0 , r0 , c7 , c10 , 4 @ drain write buffer
mov p c , l r
2009-11-26 16:19:58 +00:00
/ *
* dma_ m a p _ a r e a ( s t a r t , s i z e , d i r )
* - start - k e r n e l v i r t u a l s t a r t a d d r e s s
* - size - s i z e o f r e g i o n
* - dir - D M A d i r e c t i o n
* /
ENTRY( f a _ d m a _ m a p _ a r e a )
add r1 , r1 , r0
cmp r2 , #D M A _ T O _ D E V I C E
beq f a _ d m a _ c l e a n _ r a n g e
bcs f a _ d m a _ i n v _ r a n g e
b f a _ d m a _ f l u s h _ r a n g e
ENDPROC( f a _ d m a _ m a p _ a r e a )
/ *
* dma_ u n m a p _ a r e a ( s t a r t , s i z e , d i r )
* - start - k e r n e l v i r t u a l s t a r t a d d r e s s
* - size - s i z e o f r e g i o n
* - dir - D M A d i r e c t i o n
* /
ENTRY( f a _ d m a _ u n m a p _ a r e a )
mov p c , l r
ENDPROC( f a _ d m a _ u n m a p _ a r e a )
2012-09-06 18:35:13 +05:30
.globl fa_flush_kern_cache_louis
.equ fa_ f l u s h _ k e r n _ c a c h e _ l o u i s , f a _ f l u s h _ k e r n _ c a c h e _ a l l
2009-03-25 13:10:01 +02:00
_ _ INITDATA
2011-06-23 17:11:16 +01:00
@ define struct cpu_cache_fns (see <asm/cacheflush.h> and proc-macros.S)
define_ c a c h e _ f u n c t i o n s f a