Chinaunix首页 | 论坛 | 博客
  • 博客访问: 345799
  • 博文数量: 97
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 636
  • 用 户 组: 普通用户
  • 注册时间: 2014-10-12 22:41
文章分类

全部博文(97)

文章存档

2017年(8)

2015年(87)

2014年(2)

我的朋友

分类: 嵌入式

2015-09-19 00:17:16

本文基于 am335x-evm
uboot版本为 u-boot-2014.07




uboot中 ddr初始化在s_init函数中,该函数在 :\board-support\u-boot-2014.07-g7e537bf\arch\arm\cpu\armv7\am33xx\board.c中
它调用config_ddr 函数进行初始化操作,
config_ddr() 定义在  arch\arm\cpu\armv7\am33xx\emif4.c 中

点击(此处)折叠或打开

  1. void config_ddr(unsigned int pll, const struct ctrl_ioregs *ioregs,
  2. const struct ddr_data *data, const struct cmd_control *ctrl,
  3. const struct emif_regs *regs, int nr)
  4. {
  5. ddr_pll_config(pll);
  6. #ifndef CONFIG_TI81XX
  7. /*
  8. * If coming from a warm reset, skip the vtp configuration. This
  9. * reg is warm reset insensitive.
  10. */
  11. if (!(readl(&prm_device->prm_rstst) & PRM_RSTST_WARM_RESET_MASK))
  12. config_vtp(nr);
  13. else
  14. writel(readl(&prm_device->prm_rstst) | PRM_RSTST_WARM_RESET_MASK,
  15.       &prm_device->prm_rstst);
  16. #endif
  17. config_cmd_ctrl(ctrl, nr);


  18. config_ddr_data(data, nr);
  19. #ifdef CONFIG_AM33XX
  20. config_io_ctrl(ioregs);


  21. /* Set CKE to be controlled by EMIF/DDR PHY */
  22. writel(DDR_CKE_CTRL_NORMAL, &ddrctrl->ddrckectrl);


  23. #endif
  24. #ifdef CONFIG_AM43XX
  25. writel(readl(&cm_device->cm_dll_ctrl) & ~0x1, &cm_device->cm_dll_ctrl);
  26. while ((readl(&cm_device->cm_dll_ctrl) & CM_DLL_READYST) == 0)
  27. ;


  28. config_io_ctrl(ioregs);     //将ioctrl值写入 0x44e1 1404 ~ 0x44e1 1444 ddr_cmd0_ioctrl等


  29. /* Set CKE to be controlled by EMIF/DDR PHY */
  30. writel(DDR_CKE_CTRL_NORMAL, &ddrctrl->ddrckectrl);


  31. if (emif_sdram_type(regs->sdram_config) == EMIF_SDRAM_TYPE_DDR3)
  32. /* Allow EMIF to control DDR_RESET */
  33. writel(0x00000000, &ddrctrl->ddrioctrl);
  34. #endif


  35. /* Program EMIF instance */
  36. config_ddr_phy(regs, nr);
  37. set_sdram_timings(regs, nr);
  38. if (get_emif_rev(EMIF1_BASE) == EMIF_4D5)
  39. config_sdram_emif4d5(regs, nr);
  40. else
  41. config_sdram(regs, nr);
  42. }


#endif
参数解析:  
int nr: 选择哪个phy控制器,默认为0
ddr_pll_config(); 函数
config_cmd_ctrl , 初始化 DDR2/3/mDDR PHY 寄存器的cmd控制部分,地址为:0x44E1_2000 ~ 0x44e1 20c8
config_ddr_data,初始化 DDR2/3/mDDR PHY 寄存器的data部分。地址为:0x44E120C8 ~ 0x44e12120 
config_io_ctrl 函数对ddr控制器操作,地址为:0x44e1 1404~ 0x44e1 1444 wince中对这些寄存器写入 0x18B
config_ddr_phy(regs, nr); 操作emif寄存器中的DDR_PHY_CTRL_1,对应 0x4c00 00e4
set_sdram_timings(regs, nr); 操作timg
config_sdram(regs, nr);


移植时,在sdram_init()中添加目标板ddr初始化代码,这里贴上ISSI的 IS43TR16640 128M ddr3的初始化参数

点击(此处)折叠或打开

  1. #define IS43TR16640A15GBLI_EMIF_READ_LATENCY    0x000006    //0x44c0 00e4 ~ 0x44c0 00e8
  2. #define IS43TR16640A15GBLI_EMIF_TIM1     0x0888a39b     //0x44c0 0018
  3. #define IS43TR16640A15GBLI_EMIF_TIM2     0x26337fda     //0x44c0 0020
  4. #define IS43TR16640A15GBLI_EMIF_TIM3     0x501f830f     //0x44c0 0028
  5. #define IS43TR16640A15GBLI_EMIF_SDCFG     0x61c04ab2     //0x44c0 0008
  6. #define IS43TR16640A15GBLI_EMIF_SDREF     0x0000093b     //0x44c0 0010
  7. #define IS43TR16640A15GBLI_ZQ_CFG     0x50074BE4     //0x44c0 00c8
  8. #define IS43TR16640A15GBLI_RATIO     0x40     //0x44e1 2000 ~ 0x44e1 20c8
  9. #define IS43TR16640A15GBLI_INVERT_CLKOUT     0x01     //0x44e1 2000 ~ 0x44e1 20c8
  10. #define IS43TR16640A15GBLI_RD_DQS     0x3b     //0x44e1 20c8
  11. #define IS43TR16640A15GBLI_WR_DQS     0x85 //0x44e1 20dc
  12. #define IS43TR16640A15GBLI_PHY_WRLVL     0x00      //ddr2 used
  13. #define IS43TR16640A15GBLI_PHY_GATELVL     0x00     //ddr2 used
  14. #define IS43TR16640A15GBLI_PHY_WR_DATA     0xc1     //0x44e1 2120
  15. #define IS43TR16640A15GBLI_PHY_FIFO_WE     0x100     //0x44e1 2108
  16. #define IS43TR16640A15GBLI_IOCTRL_VALUE     0x18B     //0x44e1 1404 ~ 0x44e1 1444


  17. // ----------------------------------------------------------------
  18. // define zy ddr3 IS43DR16640A-15GBLI
  19. static const struct ddr_data ddr3_IS43DR1664_data = {
  20. .datardsratio0 = IS43TR16640A15GBLI_RD_DQS,
  21. .datawdsratio0 = IS43TR16640A15GBLI_WR_DQS,
  22. .datafwsratio0 = IS43TR16640A15GBLI_PHY_FIFO_WE,
  23. .datawrsratio0 = IS43TR16640A15GBLI_PHY_WR_DATA,
  24. };


  25. static const struct cmd_control ddr3_IS43DR1664_cmd_ctrl_data = {
  26. .cmd0csratio = IS43TR16640A15GBLI_RATIO,
  27. .cmd0iclkout = IS43TR16640A15GBLI_INVERT_CLKOUT,
  28. .cmd1csratio = IS43TR16640A15GBLI_RATIO,
  29. .cmd1iclkout = IS43TR16640A15GBLI_INVERT_CLKOUT,
  30. .cmd2csratio = IS43TR16640A15GBLI_RATIO,
  31. .cmd2iclkout = IS43TR16640A15GBLI_INVERT_CLKOUT,
  32. };
  33. static struct emif_regs ddr3_IS43DR1664_emif_reg_data = {
  34. .sdram_config = IS43TR16640A15GBLI_EMIF_SDCFG,
  35. .ref_ctrl = IS43TR16640A15GBLI_EMIF_SDREF,
  36. .sdram_tim1 = IS43TR16640A15GBLI_EMIF_TIM1,
  37. .sdram_tim2 = IS43TR16640A15GBLI_EMIF_TIM2,
  38. .sdram_tim3 = IS43TR16640A15GBLI_EMIF_TIM3,
  39. .zq_config = IS43TR16640A15GBLI_ZQ_CFG,
  40. .emif_ddr_phy_ctlr_1 = IS43TR16640A15GBLI_EMIF_READ_LATENCY/* |PHY_EN_DYN_PWRDN*/,
  41. };
  42. // ----------------------------------------------------------------

完成修改后,重新编译生成MLO文件,即可看到uboot中的串口输出信息了,系统已经能够在内存中欢腾的运行



阅读(5390) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~