2012-08-02 11:16:29 +03:00
/ *
* Coherency f a b r i c : l o w l e v e l f u n c t i o n s
*
* Copyright ( C ) 2 0 1 2 M a r v e l l
*
* Gregory C L E M E N T < g r e g o r y . c l e m e n t @free-electrons.com>
*
* This f i l e i s l i c e n s e d 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
* License v e r s i o n 2 . T h i s p r o g r a m i s l i c e n s e d " a s i s " w i t h o u t a n y
* warranty o f a n y k i n d , w h e t h e r e x p r e s s o r i m p l i e d .
*
* This f i l e i m p l e m e n t s t h e a s s e m b l y f u n c t i o n t o a d d a C P U t o t h e
* coherency f a b r i c . T h i s f u n c t i o n i s c a l l e d b y e a c h o f t h e s e c o n d a r y
* CPUs d u r i n g t h e i r e a r l y b o o t i n a n S M P k e r n e l , t h i s w h y t h i s
* function h a v e t o c a l l a b l e f r o m a s s e m b l y . I t c a n a l s o b e c a l l e d b y a
* primary C P U f r o m C c o d e d u r i n g i t s b o o t .
* /
# include < l i n u x / l i n k a g e . h >
# define A R M A D A _ X P _ C F B _ C T L _ R E G _ O F F S E T 0 x0
# define A R M A D A _ X P _ C F B _ C F G _ R E G _ O F F S E T 0 x4
2013-02-01 10:36:22 +00:00
# include < a s m / a s s e m b l e r . h >
2014-04-14 17:10:05 +02:00
# include < a s m / c p15 . h >
2013-02-01 10:36:22 +00:00
2012-08-02 11:16:29 +03:00
.text
2014-05-22 14:48:01 +02:00
/* Returns the coherency base address in r1 (r0 is untouched) */
2014-04-14 17:10:08 +02:00
ENTRY( l l _ g e t _ c o h e r e n c y _ b a s e )
2014-04-14 17:10:05 +02:00
mrc p15 , 0 , r1 , c1 , c0 , 0
tst r1 , #C R _ M @ C h e c k M M U b i t e n a b l e d
bne 1 f
2014-05-22 14:48:01 +02:00
/ *
* MMU i s d i s a b l e d , u s e t h e p h y s i c a l a d d r e s s o f t h e c o h e r e n c y
* base a d d r e s s .
* /
2014-04-14 17:10:08 +02:00
adr r1 , 3 f
ldr r3 , [ r1 ]
ldr r1 , [ r1 , r3 ]
2014-04-14 17:10:05 +02:00
b 2 f
1 :
2014-05-22 14:48:01 +02:00
/ *
* MMU i s e n a b l e d , u s e t h e v i r t u a l a d d r e s s o f t h e c o h e r e n c y
* base a d d r e s s .
* /
2014-04-14 17:10:08 +02:00
ldr r1 , =coherency_base
ldr r1 , [ r1 ]
2014-04-14 17:10:05 +02:00
2 :
2014-04-14 17:10:08 +02:00
mov p c , l r
ENDPROC( l l _ g e t _ c o h e r e n c y _ b a s e )
ARM: mvebu: returns ll_get_cpuid() to ll_get_coherency_cpumask()
In the refactoring of the coherency fabric assembly code, a function
called ll_get_cpuid() was created to factorize common logic between
functions adding CPU to the SMP coherency group, enabling and
disabling the coherency.
However, the name of the function is highly misleading: ll_get_cpuid()
makes one think tat it returns the ID of the CPU, i.e 0 for CPU0, 1
for CPU1, etc. In fact, this is not at all what this function returns:
it returns a CPU mask for the current CPU, usable for the coherency
fabric configuration and control registers.
Therefore this commit renames this function to
ll_get_coherency_cpumask(), and adds additional comments on top of the
function to explain in more details what it does, and also how the
endianess issue is handled.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Link: https://lkml.kernel.org/r/1400762882-10116-5-git-send-email-thomas.petazzoni@free-electrons.com
Acked-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2014-05-22 14:48:02 +02:00
/ *
* Returns t h e c o h e r e n c y C P U m a s k i n r3 ( r0 i s u n t o u c h e d ) . T h i s
* coherency C P U m a s k c a n b e u s e d w i t h t h e c o h e r e n c y f a b r i c
* configuration a n d c o n t r o l r e g i s t e r s . N o t e t h a t t h e m a s k i s a l r e a d y
* endian- s w a p p e d a s a p p r o p r i a t e s o t h a t t h e c a l l i n g f u n c t i o n s d o n o t
* have t o c a r e a b o u t e n d i a n n e s s i s s u e s w h i l e a c c e s s i n g t h e c o h e r e n c y
* fabric r e g i s t e r s
* /
ENTRY( l l _ g e t _ c o h e r e n c y _ c p u m a s k )
2014-04-14 17:10:08 +02:00
mrc 1 5 , 0 , r3 , c r0 , c r0 , 5
and r3 , r3 , #15
2014-04-14 17:10:06 +02:00
mov r2 , #( 1 < < 2 4 )
2014-04-14 17:10:08 +02:00
lsl r3 , r2 , r3
2014-05-22 14:47:59 +02:00
ARM_ B E 8 ( r e v r3 , r3 )
2014-04-14 17:10:08 +02:00
mov p c , l r
ARM: mvebu: returns ll_get_cpuid() to ll_get_coherency_cpumask()
In the refactoring of the coherency fabric assembly code, a function
called ll_get_cpuid() was created to factorize common logic between
functions adding CPU to the SMP coherency group, enabling and
disabling the coherency.
However, the name of the function is highly misleading: ll_get_cpuid()
makes one think tat it returns the ID of the CPU, i.e 0 for CPU0, 1
for CPU1, etc. In fact, this is not at all what this function returns:
it returns a CPU mask for the current CPU, usable for the coherency
fabric configuration and control registers.
Therefore this commit renames this function to
ll_get_coherency_cpumask(), and adds additional comments on top of the
function to explain in more details what it does, and also how the
endianess issue is handled.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Link: https://lkml.kernel.org/r/1400762882-10116-5-git-send-email-thomas.petazzoni@free-electrons.com
Acked-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2014-05-22 14:48:02 +02:00
ENDPROC( l l _ g e t _ c o h e r e n c y _ c p u m a s k )
2012-08-02 11:16:29 +03:00
2014-05-22 14:48:01 +02:00
/ *
* ll_ a d d _ c p u _ t o _ s m p _ g r o u p ( ) , l l _ e n a b l e _ c o h e r e n c y ( ) a n d
* ll_ d i s a b l e _ c o h e r e n c y ( ) u s e t h e s t r e x / l d r e x i n s t r u c t i o n s w h i l e t h e
* MMU c a n b e d i s a b l e d . T h e A r m a d a X P S o C h a s a n e x c l u s i v e m o n i t o r
* that t r a c k s t r a n s a c t i o n s t o D e v i c e a n d / o r S O m e m o r y a n d t h a n k s t o
* that, e x c l u s i v e t r a n s a c t i o n s a r e f u n c t i o n a l e v e n w h e n t h e M M U i s
* disabled.
2014-04-14 17:10:08 +02:00
* /
2012-08-02 11:16:29 +03:00
2014-04-14 17:10:08 +02:00
ENTRY( l l _ a d d _ c p u _ t o _ s m p _ g r o u p )
/ *
2014-05-22 14:48:01 +02:00
* As r0 i s n o t m o d i f i e d b y l l _ g e t _ c o h e r e n c y _ b a s e ( ) a n d
ARM: mvebu: returns ll_get_cpuid() to ll_get_coherency_cpumask()
In the refactoring of the coherency fabric assembly code, a function
called ll_get_cpuid() was created to factorize common logic between
functions adding CPU to the SMP coherency group, enabling and
disabling the coherency.
However, the name of the function is highly misleading: ll_get_cpuid()
makes one think tat it returns the ID of the CPU, i.e 0 for CPU0, 1
for CPU1, etc. In fact, this is not at all what this function returns:
it returns a CPU mask for the current CPU, usable for the coherency
fabric configuration and control registers.
Therefore this commit renames this function to
ll_get_coherency_cpumask(), and adds additional comments on top of the
function to explain in more details what it does, and also how the
endianess issue is handled.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Link: https://lkml.kernel.org/r/1400762882-10116-5-git-send-email-thomas.petazzoni@free-electrons.com
Acked-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2014-05-22 14:48:02 +02:00
* ll_ g e t _ c o h e r e n c y _ c p u m a s k ( ) , w e u s e i t t o t e m p o r a r l y s a v e l r
* and a v o i d i t b e i n g m o d i f i e d b y t h e b r a n c h a n d l i n k
* calls. T h i s f u n c t i o n i s u s e d v e r y e a r l y i n t h e s e c o n d a r y
* CPU b o o t , a n d n o s t a c k i s a v a i l a b l e a t t h i s p o i n t .
2014-04-14 17:10:08 +02:00
* /
2014-05-22 14:48:00 +02:00
mov r0 , l r
2014-04-14 17:10:08 +02:00
bl l l _ g e t _ c o h e r e n c y _ b a s e
ARM: mvebu: returns ll_get_cpuid() to ll_get_coherency_cpumask()
In the refactoring of the coherency fabric assembly code, a function
called ll_get_cpuid() was created to factorize common logic between
functions adding CPU to the SMP coherency group, enabling and
disabling the coherency.
However, the name of the function is highly misleading: ll_get_cpuid()
makes one think tat it returns the ID of the CPU, i.e 0 for CPU0, 1
for CPU1, etc. In fact, this is not at all what this function returns:
it returns a CPU mask for the current CPU, usable for the coherency
fabric configuration and control registers.
Therefore this commit renames this function to
ll_get_coherency_cpumask(), and adds additional comments on top of the
function to explain in more details what it does, and also how the
endianess issue is handled.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Link: https://lkml.kernel.org/r/1400762882-10116-5-git-send-email-thomas.petazzoni@free-electrons.com
Acked-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2014-05-22 14:48:02 +02:00
bl l l _ g e t _ c o h e r e n c y _ c p u m a s k
2014-05-22 14:48:00 +02:00
mov l r , r0
2014-04-14 17:10:08 +02:00
add r0 , r1 , #A R M A D A _ X P _ C F B _ C F G _ R E G _ O F F S E T
2013-05-23 10:54:02 +02:00
1 :
2014-04-14 17:10:08 +02:00
ldrex r2 , [ r0 ]
orr r2 , r2 , r3
strex r1 , r2 , [ r0 ]
cmp r1 , #0
bne 1 b
mov p c , l r
ENDPROC( l l _ a d d _ c p u _ t o _ s m p _ g r o u p )
2012-08-02 11:16:29 +03:00
2014-04-14 17:10:08 +02:00
ENTRY( l l _ e n a b l e _ c o h e r e n c y )
/ *
2014-05-22 14:48:01 +02:00
* As r0 i s n o t m o d i f i e d b y l l _ g e t _ c o h e r e n c y _ b a s e ( ) a n d
ARM: mvebu: returns ll_get_cpuid() to ll_get_coherency_cpumask()
In the refactoring of the coherency fabric assembly code, a function
called ll_get_cpuid() was created to factorize common logic between
functions adding CPU to the SMP coherency group, enabling and
disabling the coherency.
However, the name of the function is highly misleading: ll_get_cpuid()
makes one think tat it returns the ID of the CPU, i.e 0 for CPU0, 1
for CPU1, etc. In fact, this is not at all what this function returns:
it returns a CPU mask for the current CPU, usable for the coherency
fabric configuration and control registers.
Therefore this commit renames this function to
ll_get_coherency_cpumask(), and adds additional comments on top of the
function to explain in more details what it does, and also how the
endianess issue is handled.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Link: https://lkml.kernel.org/r/1400762882-10116-5-git-send-email-thomas.petazzoni@free-electrons.com
Acked-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2014-05-22 14:48:02 +02:00
* ll_ g e t _ c o h e r e n c y _ c p u m a s k ( ) , w e u s e i t t o t e m p o r a r l y s a v e l r
* and a v o i d i t b e i n g m o d i f i e d b y t h e b r a n c h a n d l i n k
* calls. T h i s f u n c t i o n i s u s e d v e r y e a r l y i n t h e s e c o n d a r y
* CPU b o o t , a n d n o s t a c k i s a v a i l a b l e a t t h i s p o i n t .
2014-04-14 17:10:08 +02:00
* /
mov r0 , l r
bl l l _ g e t _ c o h e r e n c y _ b a s e
ARM: mvebu: returns ll_get_cpuid() to ll_get_coherency_cpumask()
In the refactoring of the coherency fabric assembly code, a function
called ll_get_cpuid() was created to factorize common logic between
functions adding CPU to the SMP coherency group, enabling and
disabling the coherency.
However, the name of the function is highly misleading: ll_get_cpuid()
makes one think tat it returns the ID of the CPU, i.e 0 for CPU0, 1
for CPU1, etc. In fact, this is not at all what this function returns:
it returns a CPU mask for the current CPU, usable for the coherency
fabric configuration and control registers.
Therefore this commit renames this function to
ll_get_coherency_cpumask(), and adds additional comments on top of the
function to explain in more details what it does, and also how the
endianess issue is handled.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Link: https://lkml.kernel.org/r/1400762882-10116-5-git-send-email-thomas.petazzoni@free-electrons.com
Acked-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2014-05-22 14:48:02 +02:00
bl l l _ g e t _ c o h e r e n c y _ c p u m a s k
2014-04-14 17:10:08 +02:00
mov l r , r0
add r0 , r1 , #A R M A D A _ X P _ C F B _ C T L _ R E G _ O F F S E T
1 :
ldrex r2 , [ r0 ]
orr r2 , r2 , r3
strex r1 , r2 , [ r0 ]
cmp r1 , #0
bne 1 b
2012-08-02 11:16:29 +03:00
dsb
mov r0 , #0
mov p c , l r
2014-04-14 17:10:08 +02:00
ENDPROC( l l _ e n a b l e _ c o h e r e n c y )
2014-04-14 17:10:09 +02:00
ENTRY( l l _ d i s a b l e _ c o h e r e n c y )
/ *
2014-05-22 14:48:01 +02:00
* As r0 i s n o t m o d i f i e d b y l l _ g e t _ c o h e r e n c y _ b a s e ( ) a n d
ARM: mvebu: returns ll_get_cpuid() to ll_get_coherency_cpumask()
In the refactoring of the coherency fabric assembly code, a function
called ll_get_cpuid() was created to factorize common logic between
functions adding CPU to the SMP coherency group, enabling and
disabling the coherency.
However, the name of the function is highly misleading: ll_get_cpuid()
makes one think tat it returns the ID of the CPU, i.e 0 for CPU0, 1
for CPU1, etc. In fact, this is not at all what this function returns:
it returns a CPU mask for the current CPU, usable for the coherency
fabric configuration and control registers.
Therefore this commit renames this function to
ll_get_coherency_cpumask(), and adds additional comments on top of the
function to explain in more details what it does, and also how the
endianess issue is handled.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Link: https://lkml.kernel.org/r/1400762882-10116-5-git-send-email-thomas.petazzoni@free-electrons.com
Acked-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2014-05-22 14:48:02 +02:00
* ll_ g e t _ c o h e r e n c y _ c p u m a s k ( ) , w e u s e i t t o t e m p o r a r l y s a v e l r
* and a v o i d i t b e i n g m o d i f i e d b y t h e b r a n c h a n d l i n k
* calls. T h i s f u n c t i o n i s u s e d v e r y e a r l y i n t h e s e c o n d a r y
* CPU b o o t , a n d n o s t a c k i s a v a i l a b l e a t t h i s p o i n t .
2014-04-14 17:10:09 +02:00
* /
2014-05-22 14:48:00 +02:00
mov r0 , l r
2014-04-14 17:10:09 +02:00
bl l l _ g e t _ c o h e r e n c y _ b a s e
ARM: mvebu: returns ll_get_cpuid() to ll_get_coherency_cpumask()
In the refactoring of the coherency fabric assembly code, a function
called ll_get_cpuid() was created to factorize common logic between
functions adding CPU to the SMP coherency group, enabling and
disabling the coherency.
However, the name of the function is highly misleading: ll_get_cpuid()
makes one think tat it returns the ID of the CPU, i.e 0 for CPU0, 1
for CPU1, etc. In fact, this is not at all what this function returns:
it returns a CPU mask for the current CPU, usable for the coherency
fabric configuration and control registers.
Therefore this commit renames this function to
ll_get_coherency_cpumask(), and adds additional comments on top of the
function to explain in more details what it does, and also how the
endianess issue is handled.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Link: https://lkml.kernel.org/r/1400762882-10116-5-git-send-email-thomas.petazzoni@free-electrons.com
Acked-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2014-05-22 14:48:02 +02:00
bl l l _ g e t _ c o h e r e n c y _ c p u m a s k
2014-05-22 14:48:00 +02:00
mov l r , r0
2014-04-14 17:10:09 +02:00
add r0 , r1 , #A R M A D A _ X P _ C F B _ C T L _ R E G _ O F F S E T
1 :
ldrex r2 , [ r0 ]
bic r2 , r2 , r3
strex r1 , r2 , [ r0 ]
cmp r1 , #0
bne 1 b
dsb
mov p c , l r
ENDPROC( l l _ d i s a b l e _ c o h e r e n c y )
2014-04-14 17:10:05 +02:00
.align 2
3 :
.long coherency_phys_base - .