uboot源码学习(10)DDR初始化程序分析之二

step13之前,是配置DMC端的过程。从step14-step24,是配置DDR Device的过程,将参数写到Device中。

step14:Issue a NOP command using the DirectCmd register to assert and to hold CKE to a logic high level.
给DirectCmd 寄存器发送NOP指令,将CKE拉高,为了保证时钟从下电模式进入后时钟稳定。

//4、初始化DDR2 DRAM
//DirectCmd chip0 Deselect
ldr r1,=0x07000000
str r1,[r0,#DIRECTCMD]

在这里插入图片描述
step15:Wait for minimum 400ns.
DEMO程序未执行此步,因为此时并不是从下电模式进入,所以不必执行。
step16:Issue a PALL command using the DirectCmd register.
给DirectCmd 寄存器发送PALL指令,使所有bank进入预充电状态。参考上表。

//step16:DirectCmd chip0 PALL
ldr r1,=0x01000000
str r1,[r0,#DIRECTCMD]

17. Issue an EMRS2 command using the DirectCmd register to program the operating parameters.

//step17:DirectCmd chip0 EMRS2
ldr r1,=0x00020000
str r1,[r0,#DIRECTCMD]

在这里插入图片描述
EMRS2基本没有有用的功能,全写0就可以。
在这里插入图片描述
18. Issue an EMRS3 command using the DirectCmd register to program the operating parameters.

//step18:DirectCmd chip0 EMRS3
ldr r1,=0x00030000
str r1,[r0,#DIRECTCMD]

同理,EMRS3保留,全写0。
19. Issue an EMRS command using the DirectCmd register to enable the memory DLLs.

//step19:DirectCmd chip0 EMRS1 (MEM DLL on,DQS#disable)
ldr r1,=0x00010400
str r1,[r0,#DIRECTCMD]

在这里插入图片描述
在这里插入图片描述
其中,因为只用到了一个DIMM,所以ODT功能关闭。
addictive Latency就是t_al。DEMO将其设为0。
OCD模式暂时不用,设为0。25步的时候还会用到。
A10决定DQS是差分还是单端模式。DEMO中A10设为1,禁用了/DQS,使用单端模式。
A11为RDQS选择,现在已不用,设为0。原理图中,RDQS和DM共用一个管脚。
A12Qoff现在也不用,设为0;
20. Issue a MRS command using the DirectCmd register to reset the memory DLL.

//step20:DirectCmd chip0 MRS (MEM DLL reset) CL=4,BL=4 
ldr r1,=0x00000542
str r1,[r0,#DIRECTCMD]

在这里插入图片描述
其中,cas在前面的DMC的TimingData寄存器中配成了4,此处也要配成4。
WR计算公式,在上图tip2处有写,查手册的tWR=15ns,则WR=tWR/tCK=15ns*200M=3。此处设为3。
A12一般设置为快速下电,0x0。

21. Issue a PALL command using the DirectCmd register.

//step21:DirectCmd chip0 PALL
ldr r1,=0x01000000
str r1,[r0,#DIRECTCMD]

22. Issue two Auto Refresh commands using the DirectCmd register.
连续发2个Auto Refresh指令。

//step22:DirectCmd chip0 REFA
ldr r1,=0x05000000
str r1,[r0,#DIRECTCMD]
//DirectCmd chip0 REFA
ldr r1,=0x05000000
str r1,[r0,#DIRECTCMD]

23. Issue a MRS command using the DirectCmd register to program the operating parameters without resetting the memory DLL.

//step23:DirectCmd chip0 MRS (MEM DLL unreset) 
ldr r1,=0x00000442
str r1,[r0,#DIRECTCMD]

此步设置MRS寄存器,将DLL_reset位置为0。
在这里插入图片描述
24. Wait for minimum 200 clock cycles.
此步等待200个时钟周期,是为了使时钟稳定,以接下来配置ODT功能,但是ODT功能现在基本不用,所以此步可以跳过。

25. Issue an EMRS command using the DirectCmd register to program the operating parameters. If OCD calibration is not used, issue an EMRS command to set OCD Calibration Default. After that, issue an EMRS command to exit OCD Calibration Mode and to program the operating parameters.
先将OCD校准设为default,再退出。

//step25:DirectCmd chip0 EMRS1 (OCD default) 
ldr r1,=0x00010780
str r1,[r0,#DIRECTCMD]
//DirectCmd chip0 EMRS1 (OCD exit) 
ldr r1,=0x00010400
str r1,[r0,#DIRECTCMD]

在这里插入图片描述
26. If there are two external memory chips, perform steps 14~25 for chip1 memory device.
如果有两个rank的话,重复step14-step25。此时只有1个rank,所以此步跳过。
**27. Set the ConControl to turn on an auto refresh counter. **
设置ConControl 寄存器,将自刷新功能打开。

//step27:ConControl auto refresh on
ldr r1,=0FF02030
str r1,[r0,#DMC_CONCONTROL]

在这里插入图片描述
28. If power down modes is required, set the MemControl registers.
如果需要power down 模式,则配置MemControl 寄存器。前面step8中的power down 在此处配置。

//PwrdnConfig
ldr r1,=0xFFFF00FF
str r1,[r0,#DMC_PWRDNCONFIG]
//MemControl BL=4,chip,DDR2 type,dynamic self refresh,force precharge,dynamic power down off
ldr r1,=0x00202400
str r1,[r0,#DMC_MEMCONTROL]	

在这里插入图片描述
dsref_cyc:如果有dsref_cyc+1的时钟周期未给MemControl的指令队列发指令,则会强制Memory Device进入自刷新状态。
dpwrdn_cyc:如果有dpwrdn_cyc+1的时钟周期未给MemControl的指令队列发指令,则会强制Memory Device进入激活/预充电掉电状态。
在这里插入图片描述
从DEMO程序看,dpwrdn_en为0,即关闭了动态掉电模式。所以,即使计时到dsref_cyc和dpwrdn_cyc后,也不会进入到自刷新和激活/预充电掉电状态。

mov pc,lr

至此,DDR初始化完成,程序跳转回lowlevel_init.S中执行。

  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值