第十三章、Tiny4412 U-BOOT移植十三 DDR3初始化源码分析

第一步、设置时钟

         按上一章中步骤来说明:

1.  DMC must assert and hold CKE to a logic lowlevel to provide stable power for memory device and then apply stable clock.

设置DMC,由于时钟已经在clock_init_mytiny4412.S中进行了设置,这里可以不用再做设置了。只要保持CKE为低电平。

第二步、设置Phycontrol_n寄存器

2.  Set the PhyControl0.ctrl_start_point andPhyControl0.ctrl_inc bit-fields to a correct value according to clockfrequency. Set the PhyControl0.ctrl_dll_on bit-field to "1" toactivate the PHY DLL.

依照时钟频率正确配置PhyControl0.ctrl_start_point和PhyControl0.ctrl_inc bit-fields的值。配置的PhyControl0.ctrl_dll_on值为'1'以打开PHY DLL。

3.  DQS cleaning: Set the PhyControl1.ctrl_shiftcand PhyControl1.ctrl_offsetc bit-fields to the appropriate value according toclock frequency, board delay, and memory tDQSCK parameter.

4.  Set the PhyControl0.ctrl_start bit-field to"1".

那开始配置PhyControl0和PhyControl1的相关位,查看手册的第18章,找到相关寄存器的配置。

表13-1、PhyControl0和PhyControl1相关寄存器地址

第2步中我们要配置我们需要正确配置PhyControl0寄存器的ctrl_start_point和ctrl_inc这两个位的值,OK,查看寄存器的描述。

表13-2、PhyControl0相关寄存器地址

第十三章、Tiny4412 U-BOOT移植十三 DDR3初始化源码分析_第1张图片



ctrl_start_point和ctrl_inc这两位芯片手册上给的参考值为0x10,先配这两位,则为:

ctrl_start_point: 0x10---- 10000(二进制)

ctrl_inc: 0x10 ---- 10000(二进制)

那么ctrl_force怎么搞呢,我也没有闹明白,代码一开始设置是0x71,在上面的第11步中有这么句话:

11.  Wait for the PhyStatus0.ctrl_lockedbit-fields to change to "1". Verify whether PHY DLL is locked.PHY DLLcompensates the changes of delay amount that pressure, volume, and temperaturevariation causes during memory operation. Therefore, you should not power offPHY DLL for reliable operation. It can be in power-off mode except when it runsat low frequency.When you use the power-off mode, setthe PhyControl0.ctrl_force bit-fieldto the correct value according to the PhyStatus0.ctrl_lock_value[9:2] bit-fieldfor fix delay amount. Clear the PhyControl0.ctrl_dll_on bit-field to turn offPHY DLL.

上面说不能关闭了PHY DLL的电源,只有当他在低的时钟频率时才可以切换到Power-off 模式,当我们用power-off 模式,参考PhyStatus0.ctrl_lock_value[9:2]的延时参数来设置PhyControl0.ctrl_force bit-field,清除PhyControl0.ctrl_dll_on bit-field来关闭 PHY DLL。我查看了PhyStatus寄存器的说明,他是只读的,上电初始化是0x0,那FriendlyARM为什么设置这个值呢?我也不是很清楚了。DDR3的工作原理还是没有搞的很清楚呀,暂留一疑问吧。

ctrl_dfdps:这一位手册说明如果是LPDDR2这一位一定要置位,所以这一位设置为1.

其余的位全部配成0,最终为0111 0001 00001 0000 0001 0000 00001000,即0x7E101008。

 

接着往下看

3. DQS cleaning: Setthe PhyControl1.ctrl_shiftc and PhyControl1.ctrl_offsetc bit-fields to theappropriate value according to clock frequency, board delay, and memory tDQSCKparameter.

依照时钟频率和内存的tAC参数正确设置PhyControl1.ctrl_shiftc and PhyControl1.ctrl_offsetc bit-fields位的值。

查看PhyControl1的ctrl_shiftc和ctrl_offsetc这两位的描述

我们的内存是DDR3-1300,参考其原代码其ctrl_shiftc配置为0x6 即0B110,具体什么原因我也不清楚。ctrl_offsetc的配置暂时参考三星的裸板参数配置为0,ctrl_ref配置为1000。

 

后面的步骤,全部是按照三星的芯片手册上的那21步来一步一步的在操作寄存器,没有一步有漏掉,但初始化上,可能会有调整,所以,对比着芯片手册上的那21步一行一行的查看代码就OK了。有一点,在配置完14-19步后,到第19步时--配置第14到第19步,如果有两组DDR芯片,重复14-19步配置chip1的内存,刚刚配置的是chip0,也就是第一组内存芯片。这里就把第14-19步重新再做一次,初始化chip1就OK了。代码太多,这里就不详细重复了,最好找到三星的裸板的DDR源码,进行修改配置,以便减少出错可能。至此,DDR的源码也分析完成,下面,应该可以开始将这些移植进一个新的U-Boot中去了。

 

需要说明一下,实际FrinedlyARM中提供的代码初始化流程可能有点变化,但设置原理应基于此。此出我也未深入,以后那天有时间,得好好的静下心来,好好的查看其如何设置的。

你可能感兴趣的:(tiny4412,U-Boot,移植)