📄 sdramcfg.s
字号:
;**********************************************************************
;
; Filename: sdramcfg.s
;
; Description: Configures SDRAM.
;
; THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
; ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
; THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
; PARTICULAR PURPOSE.
;
; Use of this source code is subject to the terms of the Cirrus end-user
; license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
; If you did not accept the terms of the EULA, you are not authorized to
; use this source code. For a copy of the EULA, please see the
; EULA.RTF on your install media.
;
; Copyright(c) Cirrus Logic Corporation 2005, All Rights Reserved
;
;**********************************************************************
OPT 2 ; disable listing
INCLUDE kxarm.h
INCLUDE memorymap.inc
OPT 1 ; reenable listing
OPT 128 ; disable listing of macro expansions
GLOBALCFG_INIT EQU 0x00000001
GLOBALCFG_MRS EQU 0x00000002
GLOBALCFG_CKE EQU 0x80000000
DEVCFG_EXTBUSWIDTH EQU 0x00000004
DEVCFG_BANKCOUNT EQU 0x00000008
DEVCFG_SROM512 EQU 0x00000010
DEVCFG_SROMLL EQU 0x00000020
DEVCFG_CASLAT_2 EQU 0x00010000
DEVCFG_CASLAT_3 EQU 0x00020000
DEVCFG_RASTOCAS_2 EQU 0x00200000
DEVCFG_RASTOCAS_3 EQU 0x00300000
REG_SDRAM_GLOBAL EQU 0x80060004
REG_SDRAM_REFRESH_TIMER EQU 0x80060008
;****************************************************************************
; Delay200 - Delays200 us
;
; = 200uS / 2 (Instructions/ Loop) * 150 (nS/Instruction)
;
; = 700
;
; Uses r0
;****************************************************************************
MACRO
Delay200
mov r0, #700
200 subs r0, r0, #1
bne %b200
MEND
;****************************************************************************
; Delay80 - Delays 80 Clocks
;
;
; Uses r0
;****************************************************************************
MACRO
Delay80
mov r0, #80
80 subs r0, r0, #1
bne %b80
MEND
TEXTAREA
;****************************************************************************
; IssuePrecharfe
;****************************************************************************
LEAF_ENTRY IssuePrecharfe
mov r0, #0xff
ldr r2, =EP93XX_SDRAM_PHY_ADDR
str r0, [r2]
IF EP93XX_SDRAM_WIDTH =32
add r1, r2, #0x00400000
str r0, [r1]
add r1, r2, #0x00800000
str r0, [r1]
add r1, r2, #0x00c00000
str r0, [r1]
ELSE
add r1, r2, #0x00200000
str r0, [r1]
add r1, r2, #0x00400000
str r0, [r1]
add r1, r2, #0x00600000
str r0, [r1]
ENDIF
mov pc, lr
;****************************************************************************
; ProgramModeReg
;****************************************************************************
LEAF_ENTRY ProgramModeReg
ldr r2, =EP93XX_SDRAM_PHY_ADDR
IF EP93XX_SDRAM_WIDTH =32
add r1, r2, #0x00008800
ldr r0, [r1]
ldr r3, =0x00408800
add r1, r2, r3
ldr r0, [r1]
ldr r3, =0x00808800
add r1, r2, r3
ldr r0, [r1]
ldr r3, =0x00C08800
add r1, r2, r3
ldr r0, [r1]
ELSE
add r1, r2, #0x00006600
ldr r0, [r1]
ldr r3, =0x00206600
add r1, r2, r3
ldr r0, [r1]
ldr r3, =0x00406600
add r1, r2, r3
ldr r0, [r1]
ldr r3, =0x00606600
add r1, r2, r3
ldr r0, [r1]
ENDIF
mov pc, lr
;****************************************************************************
; SdramCfg
;****************************************************************************
LEAF_ENTRY SdramCfg
EXPORT SdramCfg
mov r12, lr ;save lr to r12, so that we can return to caller use r12, because when we call to other functions,
;lr(r14) is changed to other values.
;
; Initialize the SDRAM Configuration
;
IF EP93XX_SDRAM_WIDTH = 32
ldr r0, =(DEVCFG_BANKCOUNT :or: DEVCFG_SROMLL :or: \
DEVCFG_CASLAT_2 :or: DEVCFG_RASTOCAS_2 )
ELSE
ldr r0, =(DEVCFG_BANKCOUNT :or: DEVCFG_SROMLL :or: \
DEVCFG_CASLAT_3 :or: DEVCFG_RASTOCAS_3 :or: \
DEVCFG_EXTBUSWIDTH )
ENDIF
ldr r1, =REG_SDRAM_DEVCFG
str r0, [r1]
Delay200
;
; Set the Initialize and MRS bits (issue continuous NOP commands (INIT & MRS set))
;
ldr r0, =(GLOBALCFG_INIT :or: GLOBALCFG_MRS :or: \
GLOBALCFG_CKE)
ldr r1, =REG_SDRAM_GLOBAL
str r0, [r1]
Delay200
;
; Clear the MRS bit to issue a precharge all.
;
ldr r0, =(GLOBALCFG_INIT :or: GLOBALCFG_CKE)
str r0, [r1]
;
; Accodring to SDRAM errata, precharge all doesn't work.
; Wrokaround is to do four precharge commands.
; Issue precharfe to each SDRAM bank.
;
bl IssuePrecharfe
;
; Temporarily set the refresh timer to 0x10. Make it really low so that auto refresh
; cycles are generated. is refreshed.
;
ldr r0, =0x10
ldr r1, =REG_SDRAM_REFRESH_TIMER
str r0, [r1]
Delay80
ldr r0, =0x204
ldr r1, =REG_SDRAM_REFRESH_TIMER
str r0, [r1]
;
; Select mode register update mode
;
ldr r0, =(GLOBALCFG_CKE :or: GLOBALCFG_MRS)
ldr r1, =REG_SDRAM_GLOBAL
str r0, [r1]
; *******************************************************************
;
; Program the SDRAM mode register using the row information.
;
; | | | |
; +--+--+--+--+--+--+--+--+--+--+--+--+--+--+
; |13|12|11|10|09|08|07|06|05|04|03|02|01|00|
; +--+--+--+--+--+--+--+--+--+--+--+--+--+--+
; +---------+------+ +---+--+ + +--+--+
; | | | |
; Must Be Zero | | |
; | | |
; | | |
; LTMODE ---------------+ | |
; | |
; Wrap type ---------------------+ |
; |
; CAS Latency ---------------------------+
;
; *******************************************************************
;
; Row Column mapping for 256Meg X 16 Bits X 1. SROM Look Alike mode
;
; B1 B0 A13 A12 A11 A10 A09 A08 A07 A06 A05 A04 A03 A02 A01 A00
;
; Row/Bank A22 A21 A27 A26 A20 A19 A18 A17 A16 A15 A14 A13 A12 A11 A10 A09
;
; Col A22 A21 AP A25 A24 A08 A07 A06 A05 A04 A03 A02 A01
;
; *******************************************************************
; Sets all four banks using - Cas latency 3
; - Wrap type sequential
; - Burst Length 8
;
; *******************************************************************
bl ProgramModeReg
;
; Select mode register update mode
;
ldr r0, =GLOBALCFG_CKE
ldr r1, =REG_SDRAM_GLOBAL
str r0, [r1]
;
; Perform a dummy read of memory.
;
ldr r0, =0xC0004000
ldr r1, [r0]
; r14 is stored in r12 when entering this function, and r14 is no longer valid to return to caller, so use r12.
mov pc, r12
;****************************************************************************
; EnterStandbyMode
;****************************************************************************
LEAF_ENTRY EnterStandbyMode
EXPORT EnterStandbyMode
ldr r0, =0xB093000C
ldr r1, [r0]
nop
nop
nop
nop
nop
mov pc, lr
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -