2018-09-07 01:43:23 +00:00
/ * SPDX- L i c e n s e - I d e n t i f i e r : G P L - 2 . 0
*
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
* /
# include < l i n u x / i n i t . h >
2014-06-06 16:20:10 +09:00
# include < l i n u x / l i n k a g e . h >
# include < l i n u x / t h r e a d s . h >
2014-06-30 16:29:12 +01:00
# include < a s m / a s s e m b l e r . 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
2018-02-28 17:40:22 +00:00
# define S C T L R _ M M U 0 x01
# define B O O T R O M _ A D D R E S S 0 x E 6 3 4 0 0 0 0
# define R W T C S R A _ A D D R E S S 0 x E 6 0 2 0 0 0 4
# define R W T C S R A _ W O V F 0 x10
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 .
* /
2013-07-10 10:56:36 +09:00
.arm
2010-12-14 16:56:55 +09:00
.align 12
2013-06-10 18:19:36 +09:00
ENTRY( s h m o b i l e _ b o o t _ v e c t o r )
2013-07-10 10:56:36 +09:00
ldr r1 , 1 f
bx r1
2013-06-10 18:19:36 +09:00
ENDPROC( s h m o b i l e _ b o o t _ v e c t o r )
2013-07-10 10:56:37 +09:00
.align 2
2013-06-10 18:19:36 +09:00
.globl shmobile_boot_fn
shmobile_boot_fn :
1 : .space 4
2013-08-08 07:14:07 +09:00
.globl shmobile_boot_size
shmobile_boot_size :
.long . - shmobile_ b o o t _ v e c t o r
2013-08-01 03:38:18 +09:00
2018-02-28 17:40:22 +00:00
# ifdef C O N F I G _ A R C H _ R C A R _ G E N 2
/ *
* Reset v e c t o r f o r R - C a r G e n 2 a n d R Z / G 1 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 .
* /
ENTRY( s h m o b i l e _ b o o t _ v e c t o r _ g e n 2 )
mrc p15 , 0 , r0 , c0 , c0 , 5 @ r0 = MPIDR
ldr r1 , s h m o b i l e _ b o o t _ c p u _ g e n 2
cmp r0 , r1
bne s h m o b i l e _ s m p _ c o n t i n u e _ g e n 2
mrc p15 , 0 , r1 , c1 , c0 , 0 @ r1 = SCTLR
and r0 , r1 , #S C T L R _ M M U
cmp r0 , #S C T L R _ M M U
beq s h m o b i l e _ s m p _ c o n t i n u e _ g e n 2
ldr r0 , r w t c s r a
mov r1 , #0
ldrb r1 , [ r0 ]
and r0 , r1 , #R W T C S R A _ W O V F
cmp r0 , #R W T C S R A _ W O V F
bne s h m o b i l e _ s m p _ c o n t i n u e _ g e n 2
ldr r0 , b o o t r o m
bx r0
shmobile_smp_continue_gen2 :
ldr r1 , s h m o b i l e _ b o o t _ f n _ g e n 2
bx r1
ENDPROC( s h m o b i l e _ b o o t _ v e c t o r _ g e n 2 )
.align 4
rwtcsra :
.word RWTCSRA_ADDRESS
bootrom :
.word BOOTROM_ADDRESS
.globl shmobile_boot_cpu_gen2
shmobile_boot_cpu_gen2 :
.word 0x00000000
.align 2
.globl shmobile_boot_fn_gen2
shmobile_boot_fn_gen2 :
.space 4
.globl shmobile_boot_size_gen2
shmobile_boot_size_gen2 :
.long . - shmobile_ b o o t _ v e c t o r _ g e n 2
# endif / * C O N F I G _ A R C H _ R C A R _ G E N 2 * /
2013-08-01 03:38:18 +09:00
/ *
* Per- C P U S M P b o o t f u n c t i o n / a r g u m e n t s e l e c t i o n c o d e b a s e d o n M P I D R
* /
ENTRY( s h m o b i l e _ s m p _ b o o t )
mrc p15 , 0 , r1 , c0 , c0 , 5 @ r1 = MPIDR
2016-02-15 13:20:08 +01:00
and r0 , r1 , #0xffffff @ MPIDR_HWID_BITMASK
@ r0 = cpu_logical_map() value
2013-08-01 03:38:18 +09:00
mov r1 , #0 @ r1 = CPU index
2016-02-15 13:20:07 +01:00
adr r2 , 1 f
ldmia r2 , { r5 , r6 , r7 }
add r5 , r5 , r2 @ array of per-cpu mpidr values
add r6 , r6 , r2 @ array of per-cpu functions
add r7 , r7 , r2 @ array of per-cpu arguments
2013-08-01 03:38:18 +09:00
shmobile_smp_boot_find_mpidr :
ldr r8 , [ r5 , r1 , l s l #2 ]
cmp r8 , r0
bne s h m o b i l e _ s m p _ b o o t _ n e x t
ldr r9 , [ r6 , r1 , l s l #2 ]
cmp r9 , #0
bne s h m o b i l e _ s m p _ b o o t _ f o u n d
shmobile_smp_boot_next :
add r1 , r1 , #1
2014-06-06 16:20:10 +09:00
cmp r1 , #N R _ C P U S
2013-08-01 03:38:18 +09:00
blo s h m o b i l e _ s m p _ b o o t _ f i n d _ m p i d r
b s h m o b i l e _ s m p _ s l e e p
shmobile_smp_boot_found :
ldr r0 , [ r7 , r1 , l s l #2 ]
2014-06-30 16:29:12 +01:00
ret r9
2013-08-01 03:38:18 +09:00
ENDPROC( s h m o b i l e _ s m p _ b o o t )
ENTRY( s h m o b i l e _ s m p _ s l e e p )
wfi
b s h m o b i l e _ s m p _ b o o t
ENDPROC( s h m o b i l e _ s m p _ s l e e p )
2016-02-15 13:20:07 +01:00
.align 2
1 : .long s h m o b i l e _ s m p _ m p i d r - .
.long shmobile_smp_fn - 1 b
.long shmobile_smp_arg - 1 b
.bss
2013-08-01 03:38:18 +09:00
.globl shmobile_smp_mpidr
shmobile_smp_mpidr :
2016-02-15 13:20:07 +01:00
.space NR_CPUS * 4
2013-08-01 03:38:18 +09:00
.globl shmobile_smp_fn
shmobile_smp_fn :
2016-02-15 13:20:07 +01:00
.space NR_CPUS * 4
2013-08-01 03:38:18 +09:00
.globl shmobile_smp_arg
shmobile_smp_arg :
2016-02-15 13:20:07 +01:00
.space NR_CPUS * 4