2005-04-17 02:20:36 +04:00
/ *
* linux/ a r c h / a r m / m m / p r o c - x s c a l e . S
*
* Author : Nicolas P i t r e
* Created : November 2 0 0 0
* Copyright : ( C) 2 0 0 0 , 2 0 0 1 M o n t a V i s t a S o f t w a r e I n c .
*
* 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 .
*
* MMU f u n c t i o n s f o r t h e I n t e l X S c a l e C P U s
*
* 2 0 0 1 Aug 2 1 :
* some c o n t r i b u t i o n s b y B r e t t G a i n e s < b r e t t . w . g a i n e s @intel.com>
* Copyright 2 0 0 1 b y I n t e l C o r p .
*
* 2 0 0 1 Sep 0 8 :
* Completely r e v i s i t e d , m a n y i m p o r t a n t f i x e s
2009-09-14 11:25:28 +04:00
* Nicolas P i t r e < n i c o @fluxnic.net>
2005-04-17 02:20:36 +04:00
* /
# 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 / a s s e m b l e r . h >
2008-09-07 22:15:31 +04:00
# include < a s m / h w c a p . h >
2005-04-17 02:20:36 +04:00
# include < a s m / p g t a b l e . h >
2006-03-26 01:08:55 +03:00
# include < a s m / p g t a b l e - h w d e f . h >
2005-04-17 02:20:36 +04:00
# include < a s m / p a g e . h >
# include < a s m / p t r a c e . h >
# include " p r o c - m a c r o s . S "
/ *
* This i s t h e m a x i m u m s i z e o f a n a r e a w h i c h w i l l b e f l u s h e d . I f t h e a r e a
* is l a r g e r t h a n t h i s , t h e n w e f l u s h t h e w h o l e c a c h e
* /
# define M A X _ A R E A _ S I Z E 3 2 7 6 8
/ *
* the c a c h e l i n e s i z e o f t h e I a n d D c a c h e
* /
# define C A C H E L I N E S I Z E 3 2
/ *
* the s i z e o f t h e d a t a c a c h e
* /
# define C A C H E S I Z E 3 2 7 6 8
/ *
* Virtual a d d r e s s u s e d t o a l l o c a t e t h e c a c h e w h e n f l u s h e d
*
* This m u s t b e a n a d d r e s s r a n g e w h i c h i s _ n e v e r _ u s e d . I t s h o u l d
* apparently h a v e a m a p p i n g i n t h e c o r r e s p o n d i n g p a g e t a b l e f o r
* compatibility w i t h f u t u r e C P U s t h a t _ c o u l d _ r e q u i r e i t . F o r i n s t a n c e w e
* don' t c a r e .
*
* This m u s t b e a l i g n e d o n a 2 * C A C H E S I Z E b o u n d a r y . T h e c o d e s e l e c t s o n e o f
* the 2 a r e a s i n a l t e r n a n c e e a c h t i m e t h e c l e a n _ d _ c a c h e m a c r o i s u s e d .
* Without t h i s t h e X S c a l e c o r e e x h i b i t s c a c h e e v i c t i o n p r o b l e m s a n d n o o n e
* knows w h y .
*
* Reminder : the v e c t o r t a b l e i s l o c a t e d a t 0 x f f f f00 0 0 - 0 x f f f f0 f f f .
* /
# define C L E A N _ A D D R 0 x f f f e 0 0 0 0
/ *
* This m a c r o i s u s e d t o w a i t f o r a C P 1 5 w r i t e a n d i s n e e d e d
* when w e h a v e t o e n s u r e t h a t t h e l a s t o p e r a t i o n t o t h e c o - p r o
* was c o m p l e t e d b e f o r e c o n t i n u i n g w i t h o p e r a t i o n .
* /
.macro cpwait, r d
mrc p15 , 0 , \ r d , c2 , c0 , 0 @ arbitrary read of cp15
mov \ r d , \ r d @ wait for completion
sub p c , p c , #4 @ flush instruction pipeline
.endm
.macro cpwait_ r e t , l r , r d
mrc p15 , 0 , \ r d , c2 , c0 , 0 @ arbitrary read of cp15
sub p c , \ l r , \ r d , L S R #32 @ wait for completion and
@ flush instruction pipeline
.endm
/ *
* This m a c r o c l e a n s t h e e n t i r e d c a c h e u s i n g l i n e a l l o c a t e .
* The m a i n l o o p h a s b e e n u n r o l l e d t o r e d u c e l o o p o v e r h e a d .
* rd a n d r s a r e t w o s c r a t c h r e g i s t e r s .
* /
.macro clean_ d _ c a c h e , r d , r s
ldr \ r s , =clean_addr
ldr \ r d , [ \ r s ]
eor \ r d , \ r d , #C A C H E S I Z E
str \ r d , [ \ r s ]
add \ r s , \ r d , #C A C H E S I Z E
1 : mcr p15 , 0 , \ r d , c7 , c2 , 5 @ allocate D cache line
add \ r d , \ r d , #C A C H E L I N E S I Z E
mcr p15 , 0 , \ r d , c7 , c2 , 5 @ allocate D cache line
add \ r d , \ r d , #C A C H E L I N E S I Z E
mcr p15 , 0 , \ r d , c7 , c2 , 5 @ allocate D cache line
add \ r d , \ r d , #C A C H E L I N E S I Z E
mcr p15 , 0 , \ r d , c7 , c2 , 5 @ allocate D cache line
add \ r d , \ r d , #C A C H E L I N E S I Z E
teq \ r d , \ r s
bne 1 b
.endm
.data
2017-07-26 14:49:31 +03:00
.align 2
2005-04-17 02:20:36 +04:00
clean_addr : .word C L E A N _ A D D R
.text
/ *
* cpu_ x s c a l e _ p r o c _ i n i t ( )
*
* Nothing t o o e x c i t i n g a t t h e m o m e n t
* /
ENTRY( c p u _ x s c a l e _ p r o c _ i n i t )
2008-03-13 11:53:21 +03:00
@ enable write buffer coalescing. Some bootloader disable it
mrc p15 , 0 , r1 , c1 , c0 , 1
bic r1 , r1 , #1
mcr p15 , 0 , r1 , c1 , c0 , 1
2014-06-30 19:29:12 +04:00
ret l r
2005-04-17 02:20:36 +04:00
/ *
* cpu_ x s c a l e _ p r o c _ f i n ( )
* /
ENTRY( c p u _ x s c a l e _ p r o c _ f i n )
mrc p15 , 0 , r0 , c1 , c0 , 0 @ ctrl register
bic r0 , r0 , #0x1800 @ ...IZ...........
bic r0 , r0 , #0x0006 @ .............CA.
mcr p15 , 0 , r0 , c1 , c0 , 0 @ disable caches
2014-06-30 19:29:12 +04:00
ret l r
2005-04-17 02:20:36 +04:00
/ *
* cpu_ x s c a l e _ r e s e t ( l o c )
*
* Perform a s o f t r e s e t o f t h e s y s t e m . P u t t h e C P U i n t o t h e
* same s t a t e a s i t w o u l d b e i f i t h a d b e e n r e s e t , a n d b r a n c h
* to w h a t w o u l d b e t h e r e s e t v e c t o r .
*
* loc : location t o j u m p t o f o r s o f t r e s e t
2006-07-02 00:29:32 +04:00
*
* Beware P X A 2 7 0 e r r a t u m E 7 .
2005-04-17 02:20:36 +04:00
* /
.align 5
2011-11-15 17:25:04 +04:00
.pushsection .idmap .text , " ax"
2005-04-17 02:20:36 +04:00
ENTRY( c p u _ x s c a l e _ r e s e t )
mov r1 , #P S R _ F _ B I T | P S R _ I _ B I T | S V C _ M O D E
msr c p s r _ c , r1 @ reset CPSR
2006-07-02 00:29:32 +04:00
mcr p15 , 0 , r1 , c10 , c4 , 1 @ unlock I-TLB
mcr p15 , 0 , r1 , c8 , c5 , 0 @ invalidate I-TLB
2005-04-17 02:20:36 +04:00
mrc p15 , 0 , r1 , c1 , c0 , 0 @ ctrl register
bic r1 , r1 , #0x0086 @ ........B....CA.
bic r1 , r1 , #0x3900 @ ..VIZ..S........
2006-07-02 00:29:32 +04:00
sub p c , p c , #4 @ flush pipeline
@ *** cache line aligned ***
2005-04-17 02:20:36 +04:00
mcr p15 , 0 , r1 , c1 , c0 , 0 @ ctrl register
bic r1 , r1 , #0x0001 @ ...............M
2006-07-02 00:29:32 +04:00
mcr p15 , 0 , i p , c7 , c7 , 0 @ invalidate I,D caches & BTB
2005-04-17 02:20:36 +04:00
mcr p15 , 0 , r1 , c1 , c0 , 0 @ ctrl register
@ CAUTION: MMU turned off from this point. We count on the pipeline
@ already containing those two last instructions to survive.
mcr p15 , 0 , i p , c8 , c7 , 0 @ invalidate I & D TLBs
2014-06-30 19:29:12 +04:00
ret r0
2011-11-15 17:25:04 +04:00
ENDPROC( c p u _ x s c a l e _ r e s e t )
.popsection
2005-04-17 02:20:36 +04:00
/ *
* cpu_ x s c a l e _ d o _ i d l e ( )
*
* Cause t h e p r o c e s s o r t o i d l e
*
* For n o w w e d o n o t h i n g b u t g o t o i d l e m o d e f o r e v e r y c a s e
*
* XScale s u p p o r t s c l o c k s w i t c h i n g , b u t u s i n g i d l e m o d e s u p p o r t
* allows e x t e r n a l h a r d w a r e t o r e a c t t o s y s t e m s t a t e c h a n g e s .
* /
.align 5
ENTRY( c p u _ x s c a l e _ d o _ i d l e )
mov r0 , #1
mcr p14 , 0 , r0 , c7 , c0 , 0 @ Go to IDLE
2014-06-30 19:29:12 +04:00
ret l r
2005-04-17 02:20:36 +04:00
/* ================================= CACHE ================================ */
2010-10-28 14:27:40 +04: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( x s c a l e _ 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
2014-06-30 19:29:12 +04:00
ret l r
2010-10-28 14:27:40 +04:00
ENDPROC( x s c a l e _ f l u s h _ i c a c h e _ a l l )
2005-04-17 02:20:36 +04:00
/ *
* flush_ u s e r _ c a c h e _ a l l ( )
*
* Invalidate 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( x s c a l e _ 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( x s c a l e _ f l u s h _ k e r n _ c a c h e _ a l l )
mov r2 , #V M _ E X E C
mov i p , #0
__flush_whole_cache :
clean_ d _ c a c h e r0 , r1
tst r2 , #V M _ E X E C
mcrne p15 , 0 , i p , c7 , c5 , 0 @ Invalidate I cache & BTB
mcrne p15 , 0 , i p , c7 , c10 , 4 @ Drain Write (& Fill) Buffer
2014-06-30 19:29:12 +04:00
ret l r
2005-04-17 02:20:36 +04:00
/ *
* flush_ u s e r _ c a c h e _ r a n g e ( s t a r t , e n d , v m _ 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 ( m a y n o t b 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 , m a y n o t b e a l i g n e d )
* - vma - v m a _ a r e a _ s t r u c t d e s c r i b i n g a d d r e s s s p a c e
* /
.align 5
ENTRY( x s c a l e _ 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 , #M A X _ A R E A _ S I Z E
bhs _ _ f l u s h _ w h o l e _ c a c h e
1 : tst r2 , #V M _ E X E C
mcrne p15 , 0 , r0 , c7 , c5 , 1 @ Invalidate I cache line
mcr p15 , 0 , r0 , c7 , c10 , 1 @ Clean D cache line
mcr p15 , 0 , r0 , c7 , c6 , 1 @ Invalidate D cache line
add r0 , r0 , #C A C H E 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 @ Drain Write (& Fill) Buffer
2014-06-30 19:29:12 +04:00
ret l r
2005-04-17 02:20:36 +04:00
/ *
* 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
*
* Note : single I - c a c h e l i n e i n v a l i d a t i o n i s n ' t u s e d h e r e s i n c e
* it a l s o t r a s h e s t h e m i n i I - c a c h e u s e d b y J T A G d e b u g g e r s .
* /
ENTRY( x s c a l e _ c o h e r e n t _ k e r n _ r a n g e )
2006-02-01 22:26:01 +03:00
bic r0 , r0 , #C A C H E 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 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 & BTB
mcr p15 , 0 , r0 , c7 , c10 , 4 @ Drain Write (& Fill) Buffer
2014-06-30 19:29:12 +04:00
ret l r
2005-04-17 02:20:36 +04:00
/ *
* 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( x s c a l e _ 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 L I N E S I Z E - 1
1 : mcr p15 , 0 , r0 , c7 , c10 , 1 @ clean D entry
2006-02-01 22:26:01 +03:00
mcr p15 , 0 , r0 , c7 , c5 , 1 @ Invalidate I cache entry
2005-04-17 02:20:36 +04:00
add r0 , r0 , #C A C H E L I N E S I Z E
cmp r0 , r1
blo 1 b
mov r0 , #0
2006-02-01 22:26:01 +03:00
mcr p15 , 0 , r0 , c7 , c5 , 6 @ Invalidate BTB
2005-04-17 02:20:36 +04:00
mcr p15 , 0 , r0 , c7 , c10 , 4 @ Drain Write (& Fill) Buffer
2014-06-30 19:29:12 +04:00
ret l r
2005-04-17 02:20:36 +04:00
/ *
2009-11-26 15:56:21 +03: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 )
2005-04-17 02:20:36 +04:00
*
* Ensure n o D c a c h e a l i a s i n g o c c u r s , e i t h e r w i t h i t s e l f o r
* the I c a c h e
*
2009-11-26 15:56:21 +03:00
* - addr - k e r n e l a d d r e s s
* - size - r e g i o n s i z e
2005-04-17 02:20:36 +04:00
* /
2009-11-26 15:56:21 +03:00
ENTRY( x s c a l e _ f l u s h _ k e r n _ d c a c h e _ a r e a )
add r1 , r0 , r1
2005-04-17 02:20:36 +04:00
1 : mcr p15 , 0 , r0 , c7 , c10 , 1 @ clean D entry
mcr p15 , 0 , r0 , c7 , c6 , 1 @ invalidate D entry
add r0 , r0 , #C A C H E 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 & BTB
mcr p15 , 0 , r0 , c7 , c10 , 4 @ Drain Write (& Fill) Buffer
2014-06-30 19:29:12 +04:00
ret l r
2005-04-17 02:20:36 +04:00
/ *
* 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 19:24:19 +03:00
xscale_dma_inv_range :
2005-04-17 02:20:36 +04:00
tst r0 , #C A C H E L I N E S I Z E - 1
bic r0 , r0 , #C A C H E L I N E S I Z E - 1
mcrne p15 , 0 , r0 , c7 , c10 , 1 @ clean D entry
tst r1 , #C A C H E L I N E S I Z E - 1
mcrne p15 , 0 , r1 , c7 , c10 , 1 @ clean D entry
1 : mcr p15 , 0 , r0 , c7 , c6 , 1 @ invalidate D entry
add r0 , r0 , #C A C H E L I N E S I Z E
cmp r0 , r1
blo 1 b
mcr p15 , 0 , r0 , c7 , c10 , 4 @ Drain Write (& Fill) Buffer
2014-06-30 19:29:12 +04:00
ret l r
2005-04-17 02:20:36 +04:00
/ *
* dma_ c l e a n _ r a n g e ( s t a r t , e n d )
*
* Clean 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 19:24:19 +03:00
xscale_dma_clean_range :
2005-04-17 02:20:36 +04:00
bic r0 , r0 , #C A C H E 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 L I N E S I Z E
cmp r0 , r1
blo 1 b
mcr p15 , 0 , r0 , c7 , c10 , 4 @ Drain Write (& Fill) Buffer
2014-06-30 19:29:12 +04:00
ret l r
2005-04-17 02:20:36 +04:00
/ *
* dma_ f l u s h _ r a n g e ( s t a r t , e n d )
*
* Clean a n d i n v a l i d a t e 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
* /
ENTRY( x s c a l e _ d m a _ f l u s h _ r a n g e )
bic r0 , r0 , #C A C H E L I N E S I Z E - 1
1 : mcr p15 , 0 , r0 , c7 , c10 , 1 @ clean D entry
mcr p15 , 0 , r0 , c7 , c6 , 1 @ invalidate D entry
add r0 , r0 , #C A C H E L I N E S I Z E
cmp r0 , r1
blo 1 b
mcr p15 , 0 , r0 , c7 , c10 , 4 @ Drain Write (& Fill) Buffer
2014-06-30 19:29:12 +04:00
ret l r
2005-04-17 02:20:36 +04:00
2009-11-26 19:19:58 +03: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( x s c a l e _ 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 x s c a l e _ d m a _ c l e a n _ r a n g e
bcs x s c a l e _ d m a _ i n v _ r a n g e
b x s c a l e _ d m a _ f l u s h _ r a n g e
ENDPROC( x s c a l e _ d m a _ m a p _ a r e a )
/ *
* 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
* /
2011-06-23 20:26:56 +04:00
ENTRY( x s c a l e _ 8 0 2 0 0 _ A 0 _ A 1 _ d m a _ m a p _ a r e a )
2009-11-26 19:19:58 +03:00
add r1 , r1 , r0
teq r2 , #D M A _ T O _ D E V I C E
beq x s c a l e _ d m a _ c l e a n _ r a n g e
b x s c a l e _ d m a _ f l u s h _ r a n g e
2011-06-23 20:26:56 +04:00
ENDPROC( x s c a l e _ 8 0 2 0 0 _ A 0 _ A 1 _ d m a _ m a p _ a r e a )
2009-11-26 19:19:58 +03:00
/ *
* 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( x s c a l e _ d m a _ u n m a p _ a r e a )
2014-06-30 19:29:12 +04:00
ret l r
2009-11-26 19:19:58 +03:00
ENDPROC( x s c a l e _ d m a _ u n m a p _ a r e a )
2012-09-06 17:05:13 +04:00
.globl xscale_flush_kern_cache_louis
.equ xscale_ f l u s h _ k e r n _ c a c h e _ l o u i s , x s c a l e _ f l u s h _ k e r n _ c a c h e _ a l l
2011-06-23 20:26:56 +04: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 x s c a l e
2005-04-17 02:20:36 +04:00
2006-09-16 13:52:02 +04:00
/ *
* On s t e p p i n g A 0 / A 1 o f t h e 8 0 2 0 0 , i n v a l i d a t i n g D - c a c h e b y l i n e d o e s n ' t
* clear t h e d i r t y b i t s , w h i c h m e a n s t h a t i f w e i n v a l i d a t e a d i r t y l i n e ,
* the d i r t y d a t a c a n s t i l l b e w r i t t e n b a c k t o e x t e r n a l m e m o r y l a t e r o n .
*
* The r e c o m m e n d e d w o r k a r o u n d i s t o a l w a y s d o a c l e a n D - c a c h e l i n e b e f o r e
* doing a n i n v a l i d a t e D - c a c h e l i n e , s o o n t h e a f f e c t e d p r o c e s s o r s ,
* dma_ i n v _ r a n g e ( ) i s i m p l e m e n t e d a s d m a _ f l u s h _ r a n g e ( ) .
*
* See e r r a t u m #25 o f " I n t e l 8 0 2 0 0 P r o c e s s o r S p e c i f i c a t i o n U p d a t e " ,
* revision J a n u a r y 2 2 , 2 0 0 3 , a v a i l a b l e a t :
* http : / / www. i n t e l . c o m / d e s i g n / i i o / s p e c u p d t / 2 7 3 4 1 5 . h t m
* /
2011-06-23 20:26:56 +04:00
.macro a0_alias basename
.globl xscale_ 8 0 2 0 0 _ A 0 _ A 1 _ \ b a s e n a m e
.type xscale_ 8 0 2 0 0 _ A 0 _ A 1 _ \ b a s e n a m e , % f u n c t i o n
.equ xscale_ 8 0 2 0 0 _ A 0 _ A 1 _ \ b a s e n a m e , x s c a l e _ \ b a s e n a m e
.endm
/ *
* Most o f t h e c a c h e f u n c t i o n s a r e u n c h a n g e d f o r t h e s e p r o c e s s o r r e v i s i o n s .
* Export s u i t a b l e a l i a s s y m b o l s f o r t h e u n c h a n g e d f u n c t i o n s :
* /
a0 _ a l i a s f l u s h _ i c a c h e _ a l l
a0 _ a l i a s f l u s h _ u s e r _ c a c h e _ a l l
a0 _ a l i a s f l u s h _ k e r n _ c a c h e _ a l l
2012-09-28 18:09:59 +04:00
a0 _ a l i a s f l u s h _ k e r n _ c a c h e _ l o u i s
2011-06-23 20:26:56 +04:00
a0 _ a l i a s f l u s h _ u s e r _ c a c h e _ r a n g e
a0 _ a l i a s c o h e r e n t _ k e r n _ r a n g e
a0 _ a l i a s c o h e r e n t _ u s e r _ r a n g e
a0 _ a l i a s f l u s h _ k e r n _ d c a c h e _ a r e a
a0 _ a l i a s d m a _ f l u s h _ r a n g e
a0 _ a l i a s d m a _ u n m a p _ a r e a
@ 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 x s c a l e _ 8 0 2 0 0 _ A 0 _ A 1
2006-09-16 13:52:02 +04:00
2005-04-17 02:20:36 +04:00
ENTRY( c p u _ x s c a l e _ d c a c h e _ c l e a n _ a r e a )
1 : mcr p15 , 0 , r0 , c7 , c10 , 1 @ clean D entry
add r0 , r0 , #C A C H E L I N E S I Z E
subs r1 , r1 , #C A C H E L I N E S I Z E
bhi 1 b
2014-06-30 19:29:12 +04:00
ret l r
2005-04-17 02:20:36 +04:00
/* =============================== PageTable ============================== */
/ *
* cpu_ x s c a l e _ s w i t c h _ m m ( p g d )
*
* Set t h e t r a n s l a t i o n b a s e p o i n t e r t o b e a s d e s c r i b e d b y p g d .
*
* pgd : new p a g e t a b l e s
* /
.align 5
ENTRY( c p u _ x s c a l e _ s w i t c h _ m m )
clean_ d _ c a c h e r1 , r2
mcr p15 , 0 , i p , c7 , c5 , 0 @ Invalidate I cache & BTB
mcr p15 , 0 , i p , c7 , c10 , 4 @ Drain Write (& Fill) Buffer
mcr p15 , 0 , r0 , c2 , c0 , 0 @ load page table pointer
mcr p15 , 0 , i p , c8 , c7 , 0 @ invalidate I & D TLBs
cpwait_ r e t l r , i p
/ *
2006-12-13 17:34:43 +03:00
* cpu_ x s c a l e _ s e t _ p t e _ e x t ( p t e p , p t e , e x t )
2005-04-17 02:20:36 +04:00
*
* Set a P T E a n d f l u s h i t o u t
*
* Errata 4 0 : m u s t s e t m e m o r y t o w r i t e - t h r o u g h f o r u s e r r e a d - o n l y p a g e s .
* /
2008-09-06 23:47:54 +04:00
cpu_xscale_mt_table :
.long 0x00 @ L_PTE_MT_UNCACHED
.long PTE_BUFFERABLE @ L_PTE_MT_BUFFERABLE
.long PTE_CACHEABLE @ L_PTE_MT_WRITETHROUGH
.long PTE_CACHEABLE | PTE_ B U F F E R A B L E @ L_PTE_MT_WRITEBACK
2008-09-07 15:36:46 +04:00
.long PTE_ E X T _ T E X ( 1 ) | P T E _ B U F F E R A B L E @ L_PTE_MT_DEV_SHARED
2008-09-07 00:07:45 +04:00
.long 0x00 @ unused
2008-09-06 23:47:54 +04:00
.long PTE_ E X T _ T E X ( 1 ) | P T E _ C A C H E A B L E @ L_PTE_MT_MINICACHE
.long PTE_ E X T _ T E X ( 1 ) | P T E _ C A C H E A B L E | P T E _ B U F F E R A B L E @ L_PTE_MT_WRITEALLOC
2008-09-07 00:07:45 +04:00
.long 0x00 @ unused
2008-09-06 23:47:54 +04:00
.long PTE_BUFFERABLE @ L_PTE_MT_DEV_WC
.long 0x00 @ unused
.long PTE_CACHEABLE | PTE_ B U F F E R A B L E @ L_PTE_MT_DEV_CACHED
.long 0x00 @ L_PTE_MT_DEV_NONSHARED
2008-09-07 15:42:51 +04:00
.long 0x00 @ unused
2008-09-06 23:47:54 +04:00
.long 0x00 @ unused
.long 0x00 @ unused
2005-04-17 02:20:36 +04:00
.align 5
2006-12-13 17:34:43 +03:00
ENTRY( c p u _ x s c a l e _ s e t _ p t e _ e x t )
2008-09-06 20:19:08 +04:00
xscale_ s e t _ p t e _ e x t _ p r o l o g u e
2005-04-17 02:20:36 +04:00
@
2008-09-06 23:47:54 +04:00
@ Erratum 40: must set memory to write-through for user read-only pages
2005-04-17 02:20:36 +04:00
@
2010-11-16 11:40:36 +03:00
and i p , r1 , #( L _ P T E _ M T _ M A S K | L _ P T E _ U S E R | L _ P T E _ R D O N L Y ) & ~ ( 4 < < 2 )
teq i p , #L _ P T E _ M T _ W R I T E B A C K | L _ P T E _ U S E R | L _ P T E _ R D O N L Y
2008-09-06 23:47:54 +04:00
moveq r1 , #L _ P T E _ M T _ W R I T E T H R O U G H
and r1 , r1 , #L _ P T E _ M T _ M A S K
adr i p , c p u _ x s c a l e _ m t _ t a b l e
ldr i p , [ i p , r1 ]
bic r2 , r2 , #0x0c
orr r2 , r2 , i p
2005-04-17 02:20:36 +04:00
2008-09-06 20:19:08 +04:00
xscale_ s e t _ p t e _ e x t _ e p i l o g u e
2014-06-30 19:29:12 +04:00
ret l r
2005-04-17 02:20:36 +04:00
.ltorg
.align
2011-02-06 18:48:39 +03:00
.globl cpu_xscale_suspend_size
2011-08-28 01:39:09 +04:00
.equ cpu_ x s c a l e _ s u s p e n d _ s i z e , 4 * 6
2013-04-08 14:44:57 +04:00
# ifdef C O N F I G _ A R M _ C P U _ S U S P E N D
2011-02-06 18:48:39 +03:00
ENTRY( c p u _ x s c a l e _ d o _ s u s p e n d )
2011-08-28 01:39:09 +04:00
stmfd s p ! , { r4 - r9 , l r }
2011-02-06 18:48:39 +03:00
mrc p14 , 0 , r4 , c6 , c0 , 0 @ clock configuration, for turbo mode
mrc p15 , 0 , r5 , c15 , c1 , 0 @ CP access reg
mrc p15 , 0 , r6 , c13 , c0 , 0 @ PID
mrc p15 , 0 , r7 , c3 , c0 , 0 @ domain ID
2014-11-21 17:29:00 +03:00
mrc p15 , 0 , r8 , c1 , c0 , 1 @ auxiliary control reg
2011-08-28 01:39:09 +04:00
mrc p15 , 0 , r9 , c1 , c0 , 0 @ control reg
2011-02-06 18:48:39 +03:00
bic r4 , r4 , #2 @ clear frequency change bit
2011-08-28 01:39:09 +04:00
stmia r0 , { r4 - r9 } @ store cp regs
ldmfd s p ! , { r4 - r9 , p c }
2011-02-06 18:48:39 +03:00
ENDPROC( c p u _ x s c a l e _ d o _ s u s p e n d )
ENTRY( c p u _ x s c a l e _ d o _ r e s u m e )
2011-08-28 01:39:09 +04:00
ldmia r0 , { r4 - r9 } @ load cp regs
2011-02-06 18:48:39 +03:00
mov i p , #0
mcr p15 , 0 , i p , c8 , c7 , 0 @ invalidate I & D TLBs
mcr p15 , 0 , i p , c7 , c7 , 0 @ invalidate I & D caches, BTB
mcr p14 , 0 , r4 , c6 , c0 , 0 @ clock configuration, turbo mode.
mcr p15 , 0 , r5 , c15 , c1 , 0 @ CP access reg
mcr p15 , 0 , r6 , c13 , c0 , 0 @ PID
mcr p15 , 0 , r7 , c3 , c0 , 0 @ domain ID
2011-08-28 01:39:09 +04:00
mcr p15 , 0 , r1 , c2 , c0 , 0 @ translation table base addr
2014-11-21 17:29:00 +03:00
mcr p15 , 0 , r8 , c1 , c0 , 1 @ auxiliary control reg
2011-08-28 01:39:09 +04:00
mov r0 , r9 @ control register
2011-02-06 18:48:39 +03:00
b c p u _ r e s u m e _ m m u
ENDPROC( c p u _ x s c a l e _ d o _ r e s u m e )
# endif
2005-04-17 02:20:36 +04:00
.type _ _ xscale_ s e t u p , #f u n c t i o n
__xscale_setup :
mcr p15 , 0 , i p , c7 , c7 , 0 @ invalidate I, D caches & BTB
mcr p15 , 0 , i p , c7 , c10 , 4 @ Drain Write (& Fill) Buffer
mcr p15 , 0 , i p , c8 , c7 , 0 @ invalidate I, D TLBs
[ARM] 3881/4: xscale: clean up cp0/cp1 handling
XScale cores either have a DSP coprocessor (which contains a single
40 bit accumulator register), or an iWMMXt coprocessor (which contains
eight 64 bit registers.)
Because of the small amount of state in the DSP coprocessor, access to
the DSP coprocessor (CP0) is always enabled, and DSP context switching
is done unconditionally on every task switch. Access to the iWMMXt
coprocessor (CP0/CP1) is enabled only when an iWMMXt instruction is
first issued, and iWMMXt context switching is done lazily.
CONFIG_IWMMXT is supposed to mean 'the cpu we will be running on will
have iWMMXt support', but boards are supposed to select this config
symbol by hand, and at least one pxa27x board doesn't get this right,
so on that board, proc-xscale.S will incorrectly assume that we have a
DSP coprocessor, enable CP0 on boot, and we will then only save the
first iWMMXt register (wR0) on context switches, which is Bad.
This patch redefines CONFIG_IWMMXT as 'the cpu we will be running on
might have iWMMXt support, and we will enable iWMMXt context switching
if it does.' This means that with this patch, running a CONFIG_IWMMXT=n
kernel on an iWMMXt-capable CPU will no longer potentially corrupt iWMMXt
state over context switches, and running a CONFIG_IWMMXT=y kernel on a
non-iWMMXt capable CPU will still do DSP context save/restore.
These changes should make iWMMXt work on PXA3xx, and as a side effect,
enable proper acc0 save/restore on non-iWMMXt capable xsc3 cores such
as IOP13xx and IXP23xx (which will not have CONFIG_CPU_XSCALE defined),
as well as setting and using HWCAP_IWMMXT properly.
Signed-off-by: Lennert Buytenhek <buytenh@wantstofly.org>
Acked-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2006-12-03 20:51:14 +03:00
mov r0 , #1 < < 6 @ cp6 for IOP3xx and Bulverde
2005-04-17 02:20:36 +04:00
orr r0 , r0 , #1 < < 1 3 @ Its undefined whether this
mcr p15 , 0 , r0 , c15 , c1 , 0 @ affects USR or SVC modes
2006-06-29 18:09:57 +04:00
adr r5 , x s c a l e _ c r v a l
ldmia r5 , { r5 , r6 }
2005-04-17 02:20:36 +04:00
mrc p15 , 0 , r0 , c1 , c0 , 0 @ get control register
bic r0 , r0 , r5
2006-06-29 18:09:57 +04:00
orr r0 , r0 , r6
2014-06-30 19:29:12 +04:00
ret l r
2005-04-17 02:20:36 +04:00
.size _ _ xscale_ s e t u p , . - _ _ x s c a l e _ s e t u p
/ *
* R
* .RVI ZFRS BLDP W C A M
* . .11 1 .01 . . . . .101
*
* /
2006-06-29 18:09:57 +04:00
.type xscale_ c r v a l , #o b j e c t
xscale_crval :
crval c l e a r =0x00003b07 , m m u s e t =0x00003905 , u c s e t =0x00001900
2005-04-17 02:20:36 +04:00
_ _ INITDATA
2011-06-23 20:26:56 +04:00
@ define struct processor (see <asm/proc-fns.h> and proc-macros.S)
define_ p r o c e s s o r _ f u n c t i o n s x s c a l e , d a b o r t =v5t_early_abort , p a b o r t =legacy_pabort , s u s p e n d =1
2005-04-17 02:20:36 +04:00
.section " .rodata "
2011-06-23 20:26:56 +04:00
string c p u _ a r c h _ n a m e , " a r m v5 t e "
string c p u _ e l f _ n a m e , " v5 "
string c p u _ 8 0 2 0 0 _ A 0 _ A 1 _ n a m e , " X S c a l e - 8 0 2 0 0 A 0 / A 1 "
string c p u _ 8 0 2 0 0 _ n a m e , " X S c a l e - 8 0 2 0 0 "
string c p u _ 8 0 2 1 9 _ n a m e , " X S c a l e - 8 0 2 1 9 "
string c p u _ 8 0 3 2 x _ n a m e , " X S c a l e - I O P 8 0 3 2 x F a m i l y "
string c p u _ 8 0 3 3 x _ n a m e , " X S c a l e - I O P 8 0 3 3 x F a m i l y "
string c p u _ p x a25 0 _ n a m e , " X S c a l e - P X A 2 5 0 "
string c p u _ p x a21 0 _ n a m e , " X S c a l e - P X A 2 1 0 "
string c p u _ i x p42 x _ n a m e , " X S c a l e - I X P 4 2 x F a m i l y "
string c p u _ i x p43 x _ n a m e , " X S c a l e - I X P 4 3 x F a m i l y "
string c p u _ i x p46 x _ n a m e , " X S c a l e - I X P 4 6 x F a m i l y "
string c p u _ i x p24 0 0 _ n a m e , " X S c a l e - I X P 2 4 0 0 "
string c p u _ i x p28 0 0 _ n a m e , " X S c a l e - I X P 2 8 0 0 "
string c p u _ p x a25 5 _ n a m e , " X S c a l e - P X A 2 5 5 "
string c p u _ p x a27 0 _ n a m e , " X S c a l e - P X A 2 7 0 "
2005-04-17 02:20:36 +04:00
.align
2015-03-18 09:29:32 +03:00
.section " .proc .info .init " , # alloc
2005-04-17 02:20:36 +04:00
2011-06-23 20:26:56 +04:00
.macro xscale_proc_info name : req, c p u _ v a l : r e q , c p u _ m a s k : r e q , c p u _ n a m e : r e q , c a c h e
.type _ _ \ name\ ( ) _ p r o c _ i n f o ,#o b j e c t
_ _ \ name\ ( ) _ p r o c _ i n f o :
.long \ cpu_ v a l
.long \ cpu_ m a s k
.long PMD_TYPE_SECT | \
2005-04-17 02:20:36 +04:00
PMD_ S E C T _ B U F F E R A B L E | \
PMD_ S E C T _ C A C H E A B L E | \
PMD_ S E C T _ A P _ W R I T E | \
PMD_ S E C T _ A P _ R E A D
2011-06-23 20:26:56 +04:00
.long PMD_TYPE_SECT | \
2006-06-29 21:24:21 +04:00
PMD_ S E C T _ A P _ W R I T E | \
PMD_ S E C T _ A P _ R E A D
2015-03-18 09:29:32 +03:00
initfn _ _ x s c a l e _ s e t u p , _ _ \ n a m e \ ( ) _ p r o c _ i n f o
2005-04-17 02:20:36 +04:00
.long cpu_arch_name
.long cpu_elf_name
.long HWCAP_ S W P | H W C A P _ H A L F | H W C A P _ T H U M B | H W C A P _ F A S T _ M U L T | H W C A P _ E D S P
2011-06-23 20:26:56 +04:00
.long \ cpu_ n a m e
2005-04-17 02:20:36 +04:00
.long xscale_processor_functions
.long v4wbi_tlb_fns
.long xscale_mc_user_fns
2011-06-23 20:26:56 +04:00
.ifb \ cache
.long xscale_cache_fns
.else
.long \ cache
.endif
.size _ _ \ name\ ( ) _ p r o c _ i n f o , . - _ _ \ n a m e \ ( ) _ p r o c _ i n f o
.endm
xscale_ p r o c _ i n f o 8 0 2 0 0 _ A 0 _ A 1 , 0 x69 0 5 2 0 0 0 , 0 x f f f f f f f e , c p u _ 8 0 2 0 0 _ n a m e , \
cache=xscale_80200_A0_A1_cache_fns
xscale_ p r o c _ i n f o 8 0 2 0 0 , 0 x69 0 5 2 0 0 0 , 0 x f f f f f f f0 , c p u _ 8 0 2 0 0 _ n a m e
xscale_ p r o c _ i n f o 8 0 2 1 9 , 0 x69 0 5 2 e 2 0 , 0 x f f f f f f e 0 , c p u _ 8 0 2 1 9 _ n a m e
xscale_ p r o c _ i n f o 8 0 3 2 x , 0 x69 0 5 2 4 2 0 , 0 x f f f f f7 e 0 , c p u _ 8 0 3 2 x _ n a m e
xscale_ p r o c _ i n f o 8 0 3 3 x , 0 x69 0 5 4 0 1 0 , 0 x f f f f f d30 , c p u _ 8 0 3 3 x _ n a m e
xscale_ p r o c _ i n f o p x a25 0 , 0 x69 0 5 2 1 0 0 , 0 x f f f f f7 f0 , c p u _ p x a25 0 _ n a m e
xscale_ p r o c _ i n f o p x a21 0 , 0 x69 0 5 2 1 2 0 , 0 x f f f f f3 f0 , c p u _ p x a21 0 _ n a m e
xscale_ p r o c _ i n f o i x p24 0 0 , 0 x69 0 5 4 1 9 0 , 0 x f f f f f f f0 , c p u _ i x p24 0 0 _ n a m e
xscale_ p r o c _ i n f o i x p28 0 0 , 0 x69 0 5 4 1 a0 , 0 x f f f f f f f0 , c p u _ i x p28 0 0 _ n a m e
xscale_ p r o c _ i n f o i x p42 x , 0 x69 0 5 4 1 c0 , 0 x f f f f f f c0 , c p u _ i x p42 x _ n a m e
xscale_ p r o c _ i n f o i x p43 x , 0 x69 0 5 4 0 4 0 , 0 x f f f f f f f0 , c p u _ i x p43 x _ n a m e
xscale_ p r o c _ i n f o i x p46 x , 0 x69 0 5 4 2 0 0 , 0 x f f f f f f00 , c p u _ i x p46 x _ n a m e
xscale_ p r o c _ i n f o p x a25 5 , 0 x69 0 5 2 d00 , 0 x f f f f f f f0 , c p u _ p x a25 5 _ n a m e
xscale_ p r o c _ i n f o p x a27 0 , 0 x69 0 5 4 1 1 0 , 0 x f f f f f f f0 , c p u _ p x a27 0 _ n a m e