2007-11-29 17:11:23 +01:00
/ *
2005-07-27 11:44:44 -07:00
* DRAM/ S D R A M i n i t i a l i z a t i o n - a l t e r w i t h c a r e
* This f i l e i s i n t e n d e d t o b e i n c l u d e d f r o m o t h e r a s s e m b l e r f i l e s
*
* Note : This f i l e m a y n o t m o d i f y r8 o r r9 b e c a u s e t h e y a r e u s e d t o
2016-09-23 15:42:08 +02:00
* carry i n f o r m a t i o n f r o m t h e d e c o m p r e s s o r t o t h e k e r n e l
2005-07-27 11:44:44 -07:00
*
2007-11-29 17:11:23 +01:00
* Copyright ( C ) 2 0 0 0 - 2 0 0 7 A x i s C o m m u n i c a t i o n s A B
2005-07-27 11:44:44 -07:00
*
2007-11-29 17:11:23 +01:00
* Authors : Mikael S t a r v i k < s t a r v i k @axis.com>
2005-07-27 11:44:44 -07:00
* /
/ * Just t o b e c e r t a i n t h e c o n f i g f i l e i s i n c l u d e d , w e i n c l u d e i t h e r e
2016-02-23 15:30:07 -08:00
* explicitly i n s t e a d o f d e p e n d i n g o n i t b e i n g i n c l u d e d i n t h e f i l e t h a t
2005-07-27 11:44:44 -07:00
* uses t h i s c o d e .
* /
2007-11-29 17:11:23 +01:00
# include < h w r e g s / a s m / r e g _ m a p _ a s m . h >
# include < h w r e g s / a s m / b i f _ c o r e _ d e f s _ a s m . h >
2005-07-27 11:44:44 -07:00
;; WARNING! The registers r8 and r9 are used as parameters carrying
;; information from the decompressor (if the kernel was compressed).
;; They should not be used in the code below.
; Refer to BIF MDS for a description of SDRAM initialization
; Bank configuration
move. d R E G _ A D D R ( b i f _ c o r e , r e g i _ b i f _ c o r e , r w _ s d r a m _ c f g _ g r p0 ) , $ r0
move. d C O N F I G _ E T R A X _ S D R A M _ G R P 0 _ C O N F I G , $ r1
move. d $ r1 , [ $ r0 ]
move. d R E G _ A D D R ( b i f _ c o r e , r e g i _ b i f _ c o r e , r w _ s d r a m _ c f g _ g r p1 ) , $ r0
move. d C O N F I G _ E T R A X _ S D R A M _ G R P 1 _ C O N F I G , $ r1
move. d $ r1 , [ $ r0 ]
; Calculate value of mrs_data
; CAS latency = 2 && bus_width = 32 => 0x40
; CAS latency = 3 && bus_width = 32 => 0x60
; CAS latency = 2 && bus_width = 16 => 0x20
; CAS latency = 3 && bus_width = 16 => 0x30
; Check if value is already supplied in kernel config
move. d C O N F I G _ E T R A X _ S D R A M _ C O M M A N D , $ r2
bne _ s e t _ t i m i n g
nop
move. d 0 x40 , $ r4 ; Assume 32 bits and CAS latency = 2
move. d C O N F I G _ E T R A X _ S D R A M _ T I M I N G , $ r1
2007-11-29 17:11:23 +01:00
and. d 0 x07 , $ r1 ; Get CAS latency
2005-07-27 11:44:44 -07:00
cmpq 2 , $ r1 ; CL = 2 ?
beq _ b w _ c h e c k
nop
move. d 0 x60 , $ r4
_bw_check :
; Assume that group 0 width is equal to group 1. This assumption
; is wrong for a group 1 only hardware (such as the grand old
; StorPoint+).
move. d C O N F I G _ E T R A X _ S D R A M _ G R P 0 _ C O N F I G , $ r1
and. d 0 x20 0 , $ r1 ; DRAM width is bit 9
beq _ s e t _ t i m i n g
lslq 2 , $ r4 ; mrs_data starts at bit 2
lsrq 1 , $ r4 ; 16 bits. Shift down value.
; Set timing parameters (refresh off to avoid Guinness TR 83)
_set_timing :
move. d C O N F I G _ E T R A X _ S D R A M _ T I M I N G , $ r1
and. d ~ ( 3 < < r e g _ b i f _ c o r e _ r w _ s d r a m _ t i m i n g _ _ _ r e f _ _ _ l s b ) , $ r1
move. d R E G _ A D D R ( b i f _ c o r e , r e g i _ b i f _ c o r e , r w _ s d r a m _ t i m i n g ) , $ r0
move. d $ r1 , [ $ r0 ]
; Issue NOP command
move. d R E G _ A D D R ( b i f _ c o r e , r e g i _ b i f _ c o r e , r w _ s d r a m _ c m d ) , $ r5
moveq r e g k _ b i f _ c o r e _ n o p , $ r1
move. d $ r1 , [ $ r5 ]
; Wait 200us
move. d 1 0 0 0 0 , $ r2
1 : bne 1 b
subq 1 , $ r2
; Issue initialization command sequence
2007-11-29 17:11:23 +01:00
lapc _ s d r a m _ c o m m a n d s _ s t a r t , $ r2
lapc _ s d r a m _ c o m m a n d s _ e n d , $ r3
2005-07-27 11:44:44 -07:00
1 : clear. d $ r6
2007-11-29 17:11:23 +01:00
move. b [ $ r2 + ] , $ r6 ; Load command
2005-07-27 11:44:44 -07:00
or. d $ r4 , $ r6 ; Add calculated mrs
move. d $ r6 , [ $ r5 ] ; Write rw_sdram_cmd
; Wait 80 ns between each command
move. d 4 0 0 0 , $ r7
2 : bne 2 b
subq 1 , $ r7
cmp. d $ r2 , $ r3 ; Last command?
bne 1 b
nop
; Start refresh
move. d C O N F I G _ E T R A X _ S D R A M _ T I M I N G , $ r1
move. d R E G _ A D D R ( b i f _ c o r e , r e g i _ b i f _ c o r e , r w _ s d r a m _ t i m i n g ) , $ r0
move. d $ r1 , [ $ r0 ]
; Initialization finished
ba _ s d r a m _ c o m m a n d s _ e n d
nop
_sdram_commands_start :
.byte regk_bif_core_pre ; Precharge
.byte regk_bif_core_ref ; refresh
.byte regk_bif_core_ref ; refresh
.byte regk_bif_core_ref ; refresh
.byte regk_bif_core_ref ; refresh
.byte regk_bif_core_ref ; refresh
.byte regk_bif_core_ref ; refresh
.byte regk_bif_core_ref ; refresh
.byte regk_bif_core_ref ; refresh
.byte regk_bif_core_mrs ; mrs
_sdram_commands_end :