2007-07-09 22:06:53 +01:00
/ *
* Copyright ( C ) 2 0 0 7 L e n n e r t B u y t e n h e k < b u y t e n h @wantstofly.org>
2009-12-03 22:36:41 +02:00
* Copyright 2 0 0 4 - 2 0 0 9 F r e e s c a l e S e m i c o n d u c t o r , I n c . A l l R i g h t s R e s e r v e d .
2007-07-09 22:06:53 +01: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 .
* /
2008-12-18 11:51:57 +01:00
# include < m a c h / h a r d w a r e . h >
2008-09-09 11:29:41 +02:00
# define A V I C _ N I M A S K 0 x04
2007-07-09 22:06:53 +01:00
@ this macro disables fast irq (not implemented)
.macro disable_fiq
.endm
.macro get_ i r q n r _ p r e a m b l e , b a s e , t m p
2009-12-03 22:36:41 +02:00
# ifndef C O N F I G _ M X C _ T Z I C
2009-05-25 10:50:52 +02:00
ldr \ b a s e , =avic_base
ldr \ b a s e , [ \ b a s e ]
2008-09-09 11:29:41 +02:00
# ifdef C O N F I G _ M X C _ I R Q _ P R I O R
ldr r4 , [ \ b a s e , #A V I C _ N I M A S K ]
# endif
2009-12-03 22:36:41 +02:00
# elif d e f i n e d C O N F I G _ M X C _ T Z I C
ldr \ b a s e , =tzic_base
ldr \ b a s e , [ \ b a s e ]
# endif / * C O N F I G _ M X C _ T Z I C * /
2007-07-09 22:06:53 +01:00
.endm
.macro arch_ r e t _ t o _ u s e r , t m p1 , t m p2
.endm
@ this macro checks which interrupt occured
@ and returns its number in irqnr
@ and returns if an interrupt occured in irqstat
.macro get_ i r q n r _ a n d _ b a s e , i r q n r , i r q s t a t , b a s e , t m p
2009-12-03 22:36:41 +02:00
# ifndef C O N F I G _ M X C _ T Z I C
2007-07-09 22:06:53 +01:00
@ Load offset & priority of the highest priority
@ interrupt pending from AVIC_NIVECSR
ldr \ i r q s t a t , [ \ b a s e , #0x40 ]
@ Shift to get the decoded IRQ number, using ASR so
@ 'no interrupt pending' becomes 0xffffffff
mov \ i r q n r , \ i r q s t a t , a s r #16
@ set zero flag if IRQ + 1 == 0
adds \ t m p , \ i r q n r , #1
2008-09-09 11:29:41 +02:00
# ifdef C O N F I G _ M X C _ I R Q _ P R I O R
bicne \ t m p , \ i r q s t a t , #0xFFFFFFE0
strne \ t m p , [ \ b a s e , #A V I C _ N I M A S K ]
streq r4 , [ \ b a s e , #A V I C _ N I M A S K ]
2009-12-03 22:36:41 +02:00
# endif
# elif d e f i n e d C O N F I G _ M X C _ T Z I C
@ Load offset & priority of the highest priority
@ interrupt pending.
2010-12-06 11:37:38 +00:00
@ 0x080 is INTSEC0 register
2009-12-03 22:36:41 +02:00
@ 0xD80 is HIPND0 register
mov \ i r q n r , #0
2010-12-06 11:37:38 +00:00
1000 : add \ i r q s t a t , \ b a s e , \ i r q n r , l s r #3
ldr \ t m p , [ \ i r q s t a t , #0xd80 ]
ldr \ i r q s t a t , [ \ i r q s t a t , #0x080 ]
ands \ t m p , \ t m p , \ i r q s t a t
bne 1 0 0 1 f
add \ i r q n r , \ i r q n r , #32
2009-12-03 22:36:41 +02:00
cmp \ i r q n r , #128
blo 1 0 0 0 b
b 2 0 0 1 f
1001 : mov \ i r q s t a t , #1
1002 : tst \ t m p , \ i r q s t a t
bne 2 0 0 2 f
movs \ t m p , \ t m p , l s r #1
addne \ i r q n r , \ i r q n r , #1
bne 1 0 0 2 b
2001 :
mov \ i r q n r , #0
2002 :
movs \ i r q n r , \ i r q n r
2008-09-09 11:29:41 +02:00
# endif
2007-07-09 22:06:53 +01:00
.endm
@ irq priority table (not used)
.macro irq_prio_table
.endm