UBoot/iMX35 DDR2/mDDR配置

1. 背景知识参考

1.1 Customizing SDRAM Initialization

If the SDRAM device changes in the custom platform, then the i.MX35 enhanced SDRAM controller and
initialization sequence code should adapt to operate with the new device. The portions of the code that
should be focused to modify such initialization sequence are as follows:
• If a U-Boot binary with the Flash header (including the DCD data) is used—Open the
flash_header.S file and modify the values of the DCDGEN macros (or add/remove values) in
accordance with the SDRAM device specification sheet and i.MX35 (MCIMX35) Multimedia
Applications Processor Reference Manual (IMX35RM). The DCDGEN macro transforms the
identifier number, register address, value to be written into this register, and length of the access to
the corresponding data to be appended into the U-Boot binary. The format of the DCD data is
described thoroughly in the i.MX35 (MCIMX35) Multimedia Applications Processor Reference
Manual (IMX35RM).
NOTE
Ensure to adjust the length of the DCD structure if the data is added or
removed from DCD.
• If external boot (without DCD) is used—Open the lowlevel_init.S file and modify the assembly
code of the setup_sdram and setup_sdram_bank macros, if necessary. Generally, a fine-tuning of the
SDRAM timing parameters is the primary customization
.
The code in the lowlevel_init.S file
uses the constant values declared in the board-mx35_3stack.h file and is recommended to modify
the referenced values (ESDCTL_*) instead of writing a value directly into the assembly instruction.

2. Code分析

如上所述,我们主要修改lowlevel_init.s里面的setup_sdram和setup_sdram_bank两个宏包括的汇编代码:
.macro setup_sdram
        ldr r0, =ESDCTL_BASE_ADDR //这个是Enhanced SDRAM control registers的地址0xB8001000,这时r0指向这个地址
        mov r3, #0x2000  //给r3赋值为0x2000
        str r3, [r0, #0x0] //把r3的值0x2000 赋给r0指向的sdram control register 0xB8001000这个地址存储
        str r3, [r0, #0x8] //把r3的值0x2000又赋给0xB8001000+8这个地址存储下来

        /*ip(r12) has used to save lr register in upper calling*/
        mov fp, lr

        mov r5, #0x00
        mov r2, #0x00    /*r2用来判断当前用的是DDR2还是mDDR,0-DDR2,1-mDDR,我们在这里改成mov r2, #0x01即可*/
        mov r1, #CSD0_BASE_ADDR //r1寄存器指向0x80000000这个地址
        bl setup_sdram_bank //有返回的跳转,先跳转到setup_sdram_bank
        cmp r3, #0x0
        orreq r5, r5, #1
        eorne r2, r2, #0x1
        blne setup_sdram_bank


        mov lr, fp


        check_soc_version r3, r4
        cmp r1, #CHIP_REV_2_0
        bhs 1f
        cmp r5, #0
        movne r3, #L2CC_BASE_ADDR
        ldrne r4, [r3, #L2_CACHE_AUX_CTL_REG]
        orrne r4, r4, #0x1000
        strne r4, [r3, #L2_CACHE_AUX_CTL_REG]
1:
        ldr r3, =ESDCTL_DELAY_LINE5
        str r3, [r0, #0x30]
.endm /* setup_sdram */

/*
 * r0: ESDCTL control base, r1: sdram slot base
 * r2: DDR type(0:DDR2, 1:MDDR) r3, r4:working base
 */
setup_sdram_bank:
        mov r3, #0xE /*0xA + 0x4*/
        tst r2, #0x1 //判断r2里面的值&0x1是否为1,从上面的setup_sdram得知,此时r2为0,所以这个结果不为1
        orreq r3, r3, #0x300 /*DDR2*/
        str r3, [r0, #0x10]
        bic r3, r3, #0x00A
        str r3, [r0, #0x10]
        beq 2f


        mov r3, #0x20000
1:      subs r3, r3, #1
        bne 1b


2:      tst r2, #0x1
        ldreq r3, =ESDCTL_DDR2_CONFIG //这个宏里面保存DDR2的寄存器配置
        ldrne r3, =ESDCTL_MDDR_CONFIG //这个宏里面保存mDDR的寄存器配置
        cmp r1, #CSD1_BASE_ADDR
        strlo r3, [r0, #0x4]
        strhs r3, [r0, #0xC]


        ldr r3, =ESDCTL_0x92220000
        strlo r3, [r0, #0x0]
        strhs r3, [r0, #0x8]
        mov r3, #0xDA
        ldr r4, =ESDCTL_PRECHARGE
        strb r3, [r1, r4]


        tst r2, #0x1
        bne skip_set_mode


        cmp r1, #CSD1_BASE_ADDR
        ldr r3, =ESDCTL_0xB2220000
        strlo r3, [r0, #0x0]
        strhs r3, [r0, #0x8]
        mov r3, #0xDA
        ldr r4, =ESDCTL_DDR2_EMR2
        strb r3, [r1, r4]
        ldr r4, =ESDCTL_DDR2_EMR3
        strb r3, [r1, r4]
        ldr r4, =ESDCTL_DDR2_EN_DLL
        strb r3, [r1, r4]
        ldr r4, =ESDCTL_DDR2_RESET_DLL
        strb r3, [r1, r4]


        ldr r3, =ESDCTL_0x92220000
        strlo r3, [r0, #0x0]
        strhs r3, [r0, #0x8]
        mov r3, #0xDA
        ldr r4, =ESDCTL_PRECHARGE
        strb r3, [r1, r4]

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值