2008-02-08 15:19:31 +03:00
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# Virtual D M A d r i v e r f o r M N 1 0 3 0 0 s e r i a l p o r t s
#
# Copyright ( C ) 2 0 0 7 R e d H a t , I n c . A l l R i g h t s R e s e r v e d .
# Written b y D a v i d H o w e l l s ( d h o w e l l s @redhat.com)
#
# 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 i t 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 c e
# as p u b l i s h e d 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 ; either version
# 2 of t h e L i c e n c e , o r ( a t y o u r o p t i o n ) a n y l a t e r v e r s i o n .
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# include < l i n u x / s y s . h >
# include < l i n u x / l i n k a g e . h >
# include < a s m / p a g e . h >
# include < a s m / s m p . h >
# include < a s m / c p u - r e g s . h >
# include < a s m / f r a m e . i n c >
# include < a s m / t i m e r - r e g s . h >
2009-04-10 17:33:48 +04:00
# include < p r o c / c a c h e . h >
# include < u n i t / t i m e x . h >
2008-02-08 15:19:31 +03:00
# include " m n 1 0 3 0 0 - s e r i a l . h "
# define S C x C T R 0 x00
# define S C x I C R 0 x04
# define S C x T X B 0 x08
# define S C x R X B 0 x09
# define S C x S T R 0 x0 c
# define S C x T I M 0 x0 d
.text
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# serial p o r t i n t e r r u p t v i r t u a l D M A e n t r y p o i n t
# - intended t o r u n a t i n t e r r u p t p r i o r i t y 1 ( n o t a f f e c t e d b y l o c a l _ i r q _ d i s a b l e )
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
.balign L1_CACHE_BYTES
ENTRY( m n 1 0 3 0 0 _ s e r i a l _ v d m a _ i n t e r r u p t )
2010-10-27 20:28:55 +04:00
# or E P S W _ I E ,p s w # p e r m i t o v e r r i d i n g b y
2008-02-08 15:19:31 +03:00
# debugging i n t e r r u p t s
movm [ d2 ,d3 ,a2 ,a3 ,e x r e g 0 ] ,( s p )
movhu ( I A G R ) ,a2 # s e e i f w h i c h i n t e r r u p t i s
# pending
and I A G R _ G N ,a2
add a2 ,a2
add m n 1 0 3 0 0 _ s e r i a l _ i n t _ t b l ,a2
mov ( a2 + ) ,a3
mov ( _ _ i o b a s e ,a3 ) ,e 2
mov ( a2 ) ,a2
jmp ( a2 )
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# serial p o r t r e c e i v e i n t e r r u p t v i r t u a l D M A e n t r y p o i n t
# - intended t o r u n a t i n t e r r u p t p r i o r i t y 1 ( n o t a f f e c t e d b y l o c a l _ i r q _ d i s a b l e )
# - stores d a t a / s t a t u s b y t e p a i r s i n t h e r i n g b u f f e r
# - induces a s c h e d u l e r t i c k t i m e r i n t e r r u p t w h e n d o n e , w h i c h w e t h e n s u b v e r t
# on e n t r y :
# A3 s t r u c t m n 1 0 3 0 0 _ s e r i a l _ p o r t *
# E2 I / O p o r t b a s e
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
ENTRY( m n 1 0 3 0 0 _ s e r i a l _ v d m a _ r x _ h a n d l e r )
mov ( _ _ r x _ i c r ,a3 ) ,e 3
mov G x I C R _ D E T E C T ,d2
movbu d2 ,( e 3 ) # A C K t h e i n t e r r u p t
movhu ( e 3 ) ,d2 # f l u s h
mov ( _ _ r x _ i n p ,a3 ) ,d3
mov d3 ,a2
add 2 ,d3
and M N S C _ B U F F E R _ S I Z E - 1 ,d3
mov ( _ _ r x _ o u t p ,a3 ) ,d2
cmp d3 ,d2
beq m n s c _ v d m a _ r x _ o v e r f l o w
mov ( _ _ r x _ b u f f e r ,a3 ) ,d2
add d2 ,a2
movhu ( S C x S T R ,e 2 ) ,d2
movbu d2 ,( 1 ,a2 )
movbu ( S C x R X B ,e 2 ) ,d2
movbu d2 ,( a2 )
mov d3 ,( _ _ r x _ i n p ,a3 )
bset M N S C x _ R X _ A V A I L ,( _ _ i n t r _ f l a g s ,a3 )
mnsc_vdma_rx_done :
mov ( _ _ t m _ i c r ,a3 ) ,a2
mov G x I C R _ L E V E L _ 6 | G x I C R _ E N A B L E | G x I C R _ R E Q U E S T | G x I C R _ D E T E C T ,d2
movhu d2 ,( a2 ) # r e q u e s t a s l o w i n t e r r u p t
movhu ( a2 ) ,d2 # f l u s h
movm ( s p ) ,[ d2 ,d3 ,a2 ,a3 ,e x r e g 0 ]
rti
mnsc_vdma_rx_overflow :
bset M N S C x _ R X _ O V E R F ,( _ _ i n t r _ f l a g s ,a3 )
bra m n s c _ v d m a _ r x _ d o n e
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# serial p o r t t r a n s m i t i n t e r r u p t v i r t u a l D M A e n t r y p o i n t
# - intended t o r u n a t i n t e r r u p t p r i o r i t y 1 ( n o t a f f e c t e d b y l o c a l _ i r q _ d i s a b l e )
# - retrieves d a t a b y t e s f r o m t h e r i n g b u f f e r a n d p a s s e s t h e m t o t h e s e r i a l p o r t
# - induces a s c h e d u l e r t i c k t i m e r i n t e r r u p t w h e n d o n e , w h i c h w e t h e n s u b v e r t
# A3 s t r u c t m n 1 0 3 0 0 _ s e r i a l _ p o r t *
# E2 I / O p o r t b a s e
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
.balign L1_CACHE_BYTES
ENTRY( m n 1 0 3 0 0 _ s e r i a l _ v d m a _ t x _ h a n d l e r )
mov ( _ _ t x _ i c r ,a3 ) ,e 3
mov G x I C R _ D E T E C T ,d2
movbu d2 ,( e 3 ) # A C K t h e i n t e r r u p t
movhu ( e 3 ) ,d2 # f l u s h
2012-12-12 19:36:38 +04:00
btst 0 x F F ,( _ _ t x _ f l a g s ,a3 ) # h a n d l e t r a n s m i t f l a g s
bne m n s c _ v d m a _ t x _ f l a g s
2008-02-08 15:19:31 +03:00
movbu ( S C x S T R ,e 2 ) ,d2 # d o n ' t t r y a n d t r a n s m i t a c h a r i f t h e
# buffer i s n o t e m p t y
btst S C 0 1 S T R _ T B F ,d2 # ( m a y h a v e t r i e d t o j u m p s t a r t )
bne m n s c _ v d m a _ t x _ n o i n t
movbu ( _ _ t x _ x c h a r ,a3 ) ,d2 # h a n d l e h i - p r i X O N / X O F F
or d2 ,d2
bne m n s c _ v d m a _ t x _ x c h a r
2009-09-23 13:40:24 +04:00
mov ( _ _ u a r t _ s t a t e ,a3 ) ,a2 # s e e i f t h e T T Y T x q u e u e h a s a n y t h i n g i n i t
2008-02-08 15:19:31 +03:00
mov ( _ _ x m i t _ t a i l ,a2 ) ,d3
mov ( _ _ x m i t _ h e a d ,a2 ) ,d2
cmp d3 ,d2
beq m n s c _ v d m a _ t x _ e m p t y
mov ( _ _ x m i t _ b u f f e r ,a2 ) ,d2 # g e t a c h a r f r o m t h e b u f f e r a n d
# transmit i t
movbu ( d3 ,d2 ) ,d2
movbu d2 ,( S C x T X B ,e 2 ) # T x
inc d3 # a d v a n c e t h e b u f f e r p o i n t e r
and _ _ U A R T _ X M I T _ S I Z E - 1 ,d3
mov ( _ _ x m i t _ h e a d ,a2 ) ,d2
mov d3 ,( _ _ x m i t _ t a i l ,a2 )
sub d3 ,d2 # s e e i f w e ' v e w r i t t e n e v e r y t h i n g
beq m n s c _ v d m a _ t x _ e m p t y
and _ _ U A R T _ X M I T _ S I Z E - 1 ,d2 # s e e i f w e j u s t m a d e a h o l e
cmp _ _ U A R T _ X M I T _ S I Z E - 2 ,d2
beq m n s c _ v d m a _ t x _ m a d e _ h o l e
mnsc_vdma_tx_done :
mov ( _ _ t m _ i c r ,a3 ) ,a2
mov G x I C R _ L E V E L _ 6 | G x I C R _ E N A B L E | G x I C R _ R E Q U E S T | G x I C R _ D E T E C T ,d2
movhu d2 ,( a2 ) # r e q u e s t a s l o w i n t e r r u p t
movhu ( a2 ) ,d2 # f l u s h
mnsc_vdma_tx_noint :
movm ( s p ) ,[ d2 ,d3 ,a2 ,a3 ,e x r e g 0 ]
rti
mnsc_vdma_tx_empty :
2010-10-27 20:28:55 +04:00
mov + ( N U M 2 G x I C R _ L E V E L ( C O N F I G _ M N 1 0 3 0 0 _ S E R I A L _ I R Q _ L E V E L ) | G x I C R _ D E T E C T ) ,d2
2008-02-08 15:19:31 +03:00
movhu d2 ,( e 3 ) # d i s a b l e t h e i n t e r r u p t
movhu ( e 3 ) ,d2 # f l u s h
bset M N S C x _ T X _ E M P T Y ,( _ _ i n t r _ f l a g s ,a3 )
bra m n s c _ v d m a _ t x _ d o n e
2012-12-12 19:36:38 +04:00
mnsc_vdma_tx_flags :
btst M N S C x _ T X _ S T O P ,( _ _ t x _ f l a g s ,a3 )
bne m n s c _ v d m a _ t x _ s t o p
2008-02-08 15:19:31 +03:00
movhu ( S C x C T R ,e 2 ) ,d2 # t u r n o n b r e a k m o d e
or S C 0 1 C T R _ B K E ,d2
movhu d2 ,( S C x C T R ,e 2 )
2012-12-12 19:36:38 +04:00
mnsc_vdma_tx_stop :
2010-10-27 20:28:55 +04:00
mov + ( N U M 2 G x I C R _ L E V E L ( C O N F I G _ M N 1 0 3 0 0 _ S E R I A L _ I R Q _ L E V E L ) | G x I C R _ D E T E C T ) ,d2
2008-02-08 15:19:31 +03:00
movhu d2 ,( e 3 ) # d i s a b l e t r a n s m i t i n t e r r u p t s o n t h i s
# channel
movhu ( e 3 ) ,d2 # f l u s h
bra m n s c _ v d m a _ t x _ n o i n t
mnsc_vdma_tx_xchar :
bclr 0 x f f ,( _ _ t x _ x c h a r ,a3 )
movbu d2 ,( S C x T X B ,e 2 )
bra m n s c _ v d m a _ t x _ d o n e
mnsc_vdma_tx_made_hole :
bset M N S C x _ T X _ S P A C E ,( _ _ i n t r _ f l a g s ,a3 )
bra m n s c _ v d m a _ t x _ d o n e