2005-04-17 02:20:36 +04:00
/ *
* linux/ a r c h / a r m / m m / p r o c - s a11 0 0 . S
*
* Copyright ( C ) 1 9 9 7 - 2 0 0 2 R u s s e l l K i n g
2006-06-28 17:10:01 +04:00
* hacked f o r n o n - p a g e d - M M b y H y o k S . C h o i , 2 0 0 3 .
2005-04-17 02:20:36 +04:00
*
* 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 S A 1 1 0
*
* These a r e t h e l o w l e v e l a s s e m b l e r f o r p e r f o r m i n g c a c h e a n d T L B
* functions o n t h e S t r o n g A R M - 1 1 0 0 a n d S t r o n g A R M - 1 1 1 0 .
*
* Note t h a t S A 1 1 0 0 a n d S A 1 1 1 0 s h a r e e v e r y t h i n g b u t t h e i r n a m e a n d C P U I D .
*
* 1 2 - jun- 2 0 0 0 , E r i k M o u w ( J . A . K . M o u w @its.tudelft.nl):
* Flush t h e r e a d b u f f e r a t c o n t e x t s w i t c h e s
* /
# 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 >
2005-09-09 23:08:59 +04:00
# include < a s m / a s m - o f f s e t s . h >
2008-09-07 22:15:31 +04:00
# include < a s m / h w c a p . h >
2008-08-05 19:14:15 +04:00
# include < m a c h / h a r d w a r e . h >
2006-03-16 17:44:36 +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 g t a b l e . h >
2006-07-03 04:21:18 +04:00
# include " p r o c - m a c r o s . S "
2005-04-17 02:20:36 +04:00
/ *
* 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 D C A C H E L I N E S I Z E 3 2
2011-06-21 21:57:31 +04:00
.section .text
2005-04-17 02:20:36 +04:00
/ *
* cpu_ s a11 0 0 _ p r o c _ i n i t ( )
* /
ENTRY( c p u _ s a11 0 0 _ p r o c _ i n i t )
mov r0 , #0
mcr p15 , 0 , r0 , c15 , c1 , 2 @ Enable clock switching
mcr p15 , 0 , r0 , c9 , c0 , 5 @ Allow read-buffer operations from userland
2014-06-30 19:29:12 +04:00
ret l r
2005-04-17 02:20:36 +04:00
/ *
* cpu_ s a11 0 0 _ p r o c _ f i n ( )
*
* Prepare t h e C P U f o r r e s e t :
* - Disable i n t e r r u p t s
* - Clean a n d t u r n o f f c a c h e s .
* /
ENTRY( c p u _ s a11 0 0 _ p r o c _ f i n )
2006-04-07 16:17:15 +04:00
mcr p15 , 0 , i p , c15 , c2 , 2 @ Disable clock switching
2005-04-17 02:20:36 +04:00
mrc p15 , 0 , r0 , c1 , c0 , 0 @ ctrl register
bic r0 , r0 , #0x1000 @ ...i............
bic r0 , r0 , #0x000e @ ............wca.
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_ s a11 0 0 _ 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
* /
.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 _ s a11 0 0 _ r e s e t )
mov i p , #0
mcr p15 , 0 , i p , c7 , c7 , 0 @ invalidate I,D caches
mcr p15 , 0 , i p , c7 , c10 , 4 @ drain WB
2006-06-28 17:10:01 +04:00
# ifdef C O N F I G _ M M U
2005-04-17 02:20:36 +04:00
mcr p15 , 0 , i p , c8 , c7 , 0 @ invalidate I & D TLBs
2006-06-28 17:10:01 +04:00
# endif
2005-04-17 02:20:36 +04:00
mrc p15 , 0 , i p , c1 , c0 , 0 @ ctrl register
bic i p , i p , #0x000f @ ............wcam
bic i p , i p , #0x1100 @ ...i...s........
mcr p15 , 0 , i p , c1 , c0 , 0 @ ctrl register
2014-06-30 19:29:12 +04:00
ret r0
2011-11-15 17:25:04 +04:00
ENDPROC( c p u _ s a11 0 0 _ r e s e t )
.popsection
2005-04-17 02:20:36 +04:00
/ *
* cpu_ s a11 0 0 _ d o _ i d l e ( t y p e )
*
* Cause t h e p r o c e s s o r t o i d l e
*
* type : call t y p e :
* 0 = slow i d l e
* 1 = fast i d l e
* 2 = switch t o s l o w p r o c e s s o r c l o c k
* 3 = switch t o f a s t p r o c e s s o r c l o c k
* /
.align 5
ENTRY( c p u _ s a11 0 0 _ d o _ i d l e )
mov r0 , r0 @ 4 nop padding
mov r0 , r0
mov r0 , r0
mov r0 , r0 @ 4 nop padding
mov r0 , r0
mov r0 , r0
mov r0 , #0
ldr r1 , =UNCACHEABLE_ADDR @ ptr to uncacheable address
@ --- aligned to a cache line
mcr p15 , 0 , r0 , c15 , c2 , 2 @ disable clock switching
ldr r1 , [ r1 , #0 ] @ force switch to MCLK
mcr p15 , 0 , r0 , c15 , c8 , 2 @ wait for interrupt
mov r0 , r0 @ safety
mcr p15 , 0 , r0 , c15 , c1 , 2 @ enable clock switching
2014-06-30 19:29:12 +04:00
ret l r
2005-04-17 02:20:36 +04:00
/* ================================= CACHE ================================ */
/ *
* cpu_ s a11 0 0 _ d c a c h e _ c l e a n _ a r e a ( a d d r ,s z )
*
* Clean t h e s p e c i f i e d e n t r y o f a n y c a c h e s s u c h t h a t t h e M M U
* translation f e t c h e s w i l l o b t a i n c o r r e c t d a t a .
*
* addr : cache- u n a l i g n e d v i r t u a l a d d r e s s
* /
.align 5
ENTRY( c p u _ s a11 0 0 _ 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 , #D C A C H E L I N E S I Z E
subs r1 , r1 , #D 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_ s a11 0 0 _ 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 _ s a11 0 0 _ s w i t c h _ m m )
2006-06-28 17:10:01 +04:00
# ifdef C O N F I G _ M M U
2006-04-07 16:17:15 +04:00
str l r , [ s p , #- 4 ] !
bl v4 w b _ f l u s h _ k e r n _ c a c h e _ a l l @ clears IP
2005-04-17 02:20:36 +04:00
mcr p15 , 0 , i p , c9 , c0 , 0 @ invalidate RB
mcr p15 , 0 , r0 , c2 , c0 , 0 @ load page table pointer
mcr p15 , 0 , i p , c8 , c7 , 0 @ invalidate I & D TLBs
2006-04-07 16:17:15 +04:00
ldr p c , [ s p ] , #4
2006-06-28 17:10:01 +04:00
# else
2014-06-30 19:29:12 +04:00
ret l r
2006-06-28 17:10:01 +04:00
# endif
2005-04-17 02:20:36 +04:00
/ *
2006-12-13 17:34:43 +03:00
* cpu_ s a11 0 0 _ 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
* /
.align 5
2006-12-13 17:34:43 +03:00
ENTRY( c p u _ s a11 0 0 _ s e t _ p t e _ e x t )
2006-06-28 17:10:01 +04:00
# ifdef C O N F I G _ M M U
2008-09-06 20:19:08 +04:00
armv3 _ s e t _ p t e _ e x t w c _ d i s a b l e =0
2005-04-17 02:20:36 +04:00
mov r0 , r0
mcr p15 , 0 , r0 , c7 , c10 , 1 @ clean D entry
mcr p15 , 0 , r0 , c7 , c10 , 4 @ drain WB
2006-06-28 17:10:01 +04:00
# endif
2014-06-30 19:29:12 +04:00
ret l r
2005-04-17 02:20:36 +04:00
2011-02-06 18:48:39 +03:00
.globl cpu_sa1100_suspend_size
2011-08-28 01:39:09 +04:00
.equ cpu_ s a11 0 0 _ s u s p e n d _ s i z e , 4 * 3
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 _ s a11 0 0 _ d o _ s u s p e n d )
2011-08-28 01:39:09 +04:00
stmfd s p ! , { r4 - r6 , l r }
2011-02-06 18:48:39 +03:00
mrc p15 , 0 , r4 , c3 , c0 , 0 @ domain ID
2011-08-28 01:39:09 +04:00
mrc p15 , 0 , r5 , c13 , c0 , 0 @ PID
mrc p15 , 0 , r6 , c1 , c0 , 0 @ control reg
stmia r0 , { r4 - r6 } @ store cp regs
ldmfd s p ! , { r4 - r6 , p c }
2011-02-06 18:48:39 +03:00
ENDPROC( c p u _ s a11 0 0 _ d o _ s u s p e n d )
ENTRY( c p u _ s a11 0 0 _ d o _ r e s u m e )
2011-08-28 01:39:09 +04:00
ldmia r0 , { r4 - r6 } @ load cp regs
2011-08-27 14:37:58 +04:00
mov i p , #0
mcr p15 , 0 , i p , c8 , c7 , 0 @ flush I+D TLBs
mcr p15 , 0 , i p , c7 , c7 , 0 @ flush I&D cache
mcr p15 , 0 , i p , c9 , c0 , 0 @ invalidate RB
mcr p15 , 0 , i p , c9 , c0 , 5 @ allow user space to use RB
2011-02-06 18:48:39 +03:00
mcr p15 , 0 , r4 , c3 , c0 , 0 @ domain ID
2011-08-28 01:39:09 +04:00
mcr p15 , 0 , r1 , c2 , c0 , 0 @ translation table base addr
mcr p15 , 0 , r5 , c13 , c0 , 0 @ PID
mov r0 , r6 @ 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 _ s a11 0 0 _ d o _ r e s u m e )
# endif
2005-04-17 02:20:36 +04:00
.type _ _ sa1 1 0 0 _ s e t u p , #f u n c t i o n
__sa1100_setup :
mov r0 , #0
mcr p15 , 0 , r0 , c7 , c7 @ invalidate I,D caches on v4
mcr p15 , 0 , r0 , c7 , c10 , 4 @ drain write buffer on v4
2006-06-28 17:10:01 +04:00
# ifdef C O N F I G _ M M U
2005-04-17 02:20:36 +04:00
mcr p15 , 0 , r0 , c8 , c7 @ invalidate I,D TLBs on v4
2006-06-28 17:10:01 +04:00
# endif
2006-06-29 18:09:57 +04:00
adr r5 , s a11 0 0 _ c r v a l
ldmia r5 , { r5 , r6 }
2005-04-17 02:20:36 +04:00
mrc p15 , 0 , r0 , c1 , c0 @ get control register v4
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 _ _ sa1 1 0 0 _ s e t u p , . - _ _ s a11 0 0 _ s e t u p
/ *
* R
* .RVI ZFRS BLDP W C A M
* . .11 0001 . .11 1101
*
* /
2006-06-29 18:09:57 +04:00
.type sa1 1 0 0 _ c r v a l , #o b j e c t
sa1100_crval :
crval c l e a r =0x00003f3f , m m u s e t =0x0000313d , u c s e t =0x00001130
2005-04-17 02:20:36 +04:00
_ _ INITDATA
/ *
* SA1 1 0 0 a n d S A 1 1 1 0 s h a r e t h e s a m e f u n c t i o n c a l l s
* /
2011-06-23 20:25:30 +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 s a11 0 0 , d a b o r t =v4_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
2011-06-23 20:25:30 +04:00
.section " .rodata "
2005-04-17 02:20:36 +04:00
2011-06-23 20:25:30 +04:00
string c p u _ a r c h _ n a m e , " a r m v4 "
string c p u _ e l f _ n a m e , " v4 "
string c p u _ s a11 0 0 _ n a m e , " S t r o n g A R M - 1 1 0 0 "
string c p u _ s a11 1 0 _ n a m e , " S t r o n g A R M - 1 1 1 0 "
2005-04-17 02:20:36 +04:00
.align
2005-09-20 19:35:03 +04:00
.section " .proc .info .init " , # alloc, #e x e c i n s t r
2005-04-17 02:20:36 +04:00
2011-06-23 20:25:30 +04:00
.macro sa1100_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
.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
2005-04-17 02:20:36 +04:00
.long PMD_TYPE_SECT | \
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
2006-06-29 21:24:21 +04:00
.long PMD_TYPE_SECT | \
PMD_ S E C T _ A P _ W R I T E | \
PMD_ S E C T _ A P _ R E A D
2005-04-17 02:20:36 +04:00
b _ _ s a11 0 0 _ s e t u p
.long cpu_arch_name
.long cpu_elf_name
.long HWCAP_SWP | HWCAP_ H A L F | H W C A P _ 2 6 B I T | H W C A P _ F A S T _ M U L T
2011-06-23 20:25:30 +04:00
.long \ cpu_ n a m e
2005-04-17 02:20:36 +04:00
.long sa1100_processor_functions
.long v4wb_tlb_fns
.long v4_mc_user_fns
.long v4wb_cache_fns
2011-06-23 20:25:30 +04:00
.size _ _ \ name\ ( ) _ p r o c _ i n f o , . - _ _ \ n a m e \ ( ) _ p r o c _ i n f o
.endm
2005-04-17 02:20:36 +04:00
2011-06-23 20:25:30 +04:00
sa1 1 0 0 _ p r o c _ i n f o s a11 0 0 , 0 x44 0 1 a11 0 , 0 x f f f f f f f0 , c p u _ s a11 0 0 _ n a m e
sa1 1 0 0 _ p r o c _ i n f o s a11 1 0 , 0 x69 0 1 b11 0 , 0 x f f f f f f f0 , c p u _ s a11 1 0 _ n a m e